content
stringlengths
23
1.05M
--- src/test-main.adb.orig 2021-05-19 05:08:26 UTC +++ src/test-main.adb @@ -30,6 +30,8 @@ with Test.Common; procedure Test.Main is + pragma Linker_Options ("-lgnarl"); + pragma Linker_Options ("-lpthread"); -- Main procedure for gnattest procedure Callback (Phase : Parse_Phase; Swit : Dynamically_Typed_Switch);
package BBS.info is pragma Pure; -- -- This file is auto generated by the build script. It should not -- be edited by hand. -- name : constant String := "Tiny Lisp"; timestamp : constant String := "Fri Sep 3 09:03:26 MST 2021"; build_date : constant String := "2021-Sep-03"; version_string : constant String := "V01.01"; version_date : constant Integer := 20210903; -- yyyymmdd version_number : constant Integer := 2; end;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Text_IO; use Ada.Text_IO; with player; use player; with inventory_list; use inventory_list; package body save_load_game is SaveDir : String := "Saves/"; procedure newGame(player: out Player_Type; dungeon: out Integer) is begin clearCharacter(player); dungeon := 1; end newGame; procedure saveGame(player: in Player_Type; dungeon: in Integer; fileNum: in Integer) is save : File_Type; begin if fileNum = 1 then open(save, Out_File, SaveDir & "saveFile1.save"); put(save, "saveFile1"); elsif fileNum = 2 then open(save, Out_File, SaveDir & "saveFile2.save"); put(save, "saveFile2"); elsif fileNum = 3 then open(save, Out_File, SaveDir & "saveFile3.save"); put(save, "saveFile3"); end if; new_line(save); put(save, player.weapon.itemID, 2); new_line(save); put(save, player.helmet.itemID, 2); new_line(save); put(save, player.chestArmor.itemID, 2); new_line(save); put(save, player.gauntlets.itemID, 2); new_line(save); put(save, player.legArmor.itemID, 2); new_line(save); put(save, player.boots.itemID, 2); new_line (save, 2); put(save, player.stats.HP, 3); put(save, " "); put(save, player.stats.MaxHP, 3); new_line(save); put(save, player.stats.Magic, 3); put(save, " "); put(save, player.stats.MaxMag, 3); new_line(save); put(save, player.stats.attack, 3); new_line(save); put(save, player.stats.defense, 3); new_line(save); put(save, player.stats.agility, 3); new_line(save); put(save, player.stats.xp, 3); new_line(save); put(save, player.stats.level, 3); new_line (save, 2); saveInventory (player.backpack, save); new_line (save, 2); put(save, dungeon, 1); close (save); end saveGame; procedure loadGame(player: in out Player_Type; dungeon: in out Integer; fileNum: in Integer) is save : File_Type; current : Integer; begin clearCharacter (player); if fileNum = 1 then open (save, In_File, SaveDir & "saveFile1.save"); elsif fileNum = 2 then open (save, In_File, SaveDir & "saveFile2.save"); elsif fileNum = 3 then open (save, In_File, SaveDir & "saveFile3.save"); end if; skip_line(save); --equipment for i in Integer range 1 .. 6 loop get(save, current); if current > 0 then Insert (current, player.backpack); equipOrUse (current, player); end if; current := -1; skip_line(save); end loop; skip_line(save); --HP get(save, player.stats.HP); get(save, player.stats.MaxHP); skip_line(save); --Magic get(save, player.stats.Magic); get(save, player.stats.MaxMag); skip_line(save); --attack get(save, player.stats.attack); skip_line(save); --defense get(save, player.stats.defense); skip_line(save); --agility get(save, player.stats.agility); skip_line(save); --xp get(save, player.stats.xp); skip_line(save); --level get(save, player.stats.level); skip_line(save, 2); --inventory loop get(save, current); Insert (current, player.backpack); exit when current = 0; end loop; skip_line(save, 2); --dungeon level get(save, dungeon); close (save); end loadGame; end save_load_game;
----------------------------------------------------------------------- -- util-xunit - Unit tests on top of AHven -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Ada.IO_Exceptions; with Ada.Text_IO; with Ada.Calendar; with Ahven.Listeners.Basic; with Ahven.XML_Runner; with Ahven.Text_Runner; with Util.Tests; package body Util.XUnit is -- ------------------------------ -- Build a message from a string (Adaptation for AUnit API). -- ------------------------------ function Format (S : in String) return Message_String is begin return S; end Format; -- ------------------------------ -- Build a message with the source and line number. -- ------------------------------ function Build_Message (Message : in String; Source : in String; Line : in Natural) return String is L : constant String := Natural'Image (Line); begin return Source & ":" & L (2 .. L'Last) & ": " & Message; end Build_Message; procedure Run_Test_Case (T : in out Ahven.Framework.Test_Case'Class); procedure Run_Test_Case (T : in out Ahven.Framework.Test_Case'Class) is begin Test_Case'Class (T).Run_Test; end Run_Test_Case; overriding procedure Initialize (T : in out Test_Case) is begin Ahven.Framework.Add_Test_Routine (T, Run_Test_Case'Access, "Test case"); end Initialize; -- ------------------------------ -- Return the name of the test case. -- ------------------------------ overriding function Get_Name (T : Test_Case) return String is begin return Test_Case'Class (T).Name; end Get_Name; -- maybe_overriding procedure Assert (T : in Test_Case; Condition : in Boolean; Message : in String := "Test failed"; Source : in String := GNAT.Source_Info.File; Line : in Natural := GNAT.Source_Info.Line) is pragma Unreferenced (T); begin Ahven.Assert (Condition => Condition, Message => Build_Message (Message => Message, Source => Source, Line => Line)); end Assert; -- ------------------------------ -- Check that the value matches what we expect. -- ------------------------------ procedure Assert (T : in Test; Condition : in Boolean; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line) is pragma Unreferenced (T); begin Ahven.Assert (Condition => Condition, Message => Build_Message (Message => Message, Source => Source, Line => Line)); end Assert; First_Test : Test_Object_Access := null; -- ------------------------------ -- Register a test object in the test suite. -- ------------------------------ procedure Register (T : in Test_Object_Access) is begin T.Next := First_Test; First_Test := T; end Register; -- ------------------------------ -- Report passes, skips, failures, and errors from the result collection. -- ------------------------------ procedure Report_Results (Result : in Ahven.Results.Result_Collection; Time : in Duration) is T_Count : constant Integer := Ahven.Results.Test_Count (Result); F_Count : constant Integer := Ahven.Results.Failure_Count (Result); S_Count : constant Integer := Ahven.Results.Skipped_Count (Result); E_Count : constant Integer := Ahven.Results.Error_Count (Result); begin if F_Count > 0 then Ahven.Text_Runner.Print_Failures (Result, 0); end if; if E_Count > 0 then Ahven.Text_Runner.Print_Errors (Result, 0); end if; Ada.Text_IO.Put_Line ("Tests run:" & Integer'Image (T_Count - S_Count) & ", Failures:" & Integer'Image (F_Count) & ", Errors:" & Integer'Image (E_Count) & ", Skipped:" & Integer'Image (S_Count) & ", Time elapsed:" & Duration'Image (Time)); end Report_Results; -- ------------------------------ -- The main testsuite program. This launches the tests, collects the -- results, create performance logs and set the program exit status -- according to the testsuite execution status. -- ------------------------------ procedure Harness (Output : in Ada.Strings.Unbounded.Unbounded_String; XML : in Boolean; Result : out Status) is pragma Unreferenced (XML, Output); use Ahven.Listeners.Basic; use Ahven.Framework; use Ahven.Results; use type Ada.Calendar.Time; Tests : constant Access_Test_Suite := Suite; T : Test_Object_Access := First_Test; Listener : Ahven.Listeners.Basic.Basic_Listener; Timeout : constant Test_Duration := Test_Duration (Util.Tests.Get_Test_Timeout ("all")); Out_Dir : constant String := Util.Tests.Get_Test_Path ("regtests/result"); Start : Ada.Calendar.Time; begin while T /= null loop Ahven.Framework.Add_Static_Test (Tests.all, T.Test.all); T := T.Next; end loop; Set_Output_Capture (Listener, True); if not Ada.Directories.Exists (Out_Dir) then Ada.Directories.Create_Path (Out_Dir); end if; Start := Ada.Calendar.Clock; Ahven.Framework.Execute (Tests.all, Listener, Timeout); Report_Results (Listener.Main_Result, Ada.Calendar.Clock - Start); Ahven.XML_Runner.Report_Results (Listener.Main_Result, Out_Dir); if (Error_Count (Listener.Main_Result) > 0) or (Failure_Count (Listener.Main_Result) > 0) then Result := Failure; else Result := Success; end if; exception when Ada.IO_Exceptions.Name_Error => Ada.Text_IO.Put_Line ("Cannot create file"); Result := Failure; end Harness; end Util.XUnit;
package body Multiplicative_Order is function Find_Order(Element, Modulus: Positive) return Positive is function Power(Exp, Pow, M: Positive) return Positive is -- computes Exp**Pow mod M; -- note that Ada's native integer exponentiation "**" may overflow on -- computing Exp**Pow before ever computing the "mod M" part Result: Positive := 1; E: Positive := Exp; P: Natural := Pow; begin while P > 0 loop if P mod 2 = 1 then Result := (Result * E) mod M; end if; E := (E * E) mod M; P := P / 2; end loop; return Result; end Power; begin -- Find_Order(Element, Modulus) for I in 1 .. Modulus loop if Power(Element, I, Modulus) = 1 then return Positive(I); end if; end loop; raise Program_Error with Positive'Image(Element) &" is not coprime to" &Positive'Image(Modulus); end Find_Order; function Find_Order(Element: Positive; Coprime_Factors: Positive_Array) return Positive is function GCD (A, B : Positive) return Integer is M : Natural := A; N : Natural := B; T : Natural; begin while N /= 0 loop T := M; M := N; N ;:= T mod N; end loop; return M; end GCD; -- from http://rosettacode.org/wiki/Least_common_multiple#Ada function LCM (A, B : Natural) return Integer is begin if A = 0 or B = 0 then return 0; end if; return abs (A * B) / Gcd (A, B); end LCM; -- from http://rosettacode.org/wiki/Least_common_multiple#Ada Result : Positive := 1; begin -- Find_Order(Element, Coprime_Factors) for I in Coprime_Factors'Range loop Result := LCM(Result, Find_Order(Element, Coprime_Factors(I))); end loop; return Result; end Find_Order; end Multiplicative_Order;
-- Ascon.Compare_Tags -- Compare two Tag_Type values using a constant-time approach. This is split -- out into a separate child unit from Ascon so that different compilation flags -- can be used. It is advisable to prevent optimisation of this function or -- else a clever compiler might use a short-circuit approach. That might produce -- logically identical results but it would leak information to attackers if the -- timing of the decoding program can be observed. -- Copyright (c) 2016, James Humphry - see LICENSE file for details pragma Restrictions(No_Implementation_Attributes, No_Implementation_Identifiers, No_Implementation_Units, No_Obsolescent_Features); generic function Ascon.Compare_Tags (L, R : Tag_Type) return Boolean; -- This function compares two tags and returns a Boolean to indicate -- if they are equal. It aims to perform the comparison in constant -- time regardless of the inputs.
with GID.Buffering; use GID.Buffering; package body GID.Decoding_BMP is procedure Load (image: in out Image_descriptor) is b01, b, br, bg, bb: U8:= 0; x, x_max, y: Natural; -- function Times_257(x: Primary_color_range) return Primary_color_range is pragma Inline(Times_257); begin return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x -- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8. end Times_257; full_opaque: constant Primary_color_range:= Primary_color_range'Last; -- procedure Pixel_with_palette is pragma Inline(Pixel_with_palette); begin case Primary_color_range'Modulus is when 256 => Put_Pixel( Primary_color_range(image.palette(Integer(b)).red), Primary_color_range(image.palette(Integer(b)).green), Primary_color_range(image.palette(Integer(b)).blue), full_opaque ); when 65_536 => Put_Pixel( Times_257(Primary_color_range(image.palette(Integer(b)).red)), Times_257(Primary_color_range(image.palette(Integer(b)).green)), Times_257(Primary_color_range(image.palette(Integer(b)).blue)), -- Times_257 makes max intensity FF go to FFFF full_opaque ); when others => raise invalid_primary_color_range with "BMP: color range not supported"; end case; end Pixel_with_palette; -- pair: Boolean; bit: Natural range 0..7; -- line_bits: constant Float:= Float(image.width * Positive_32 (image.bits_per_pixel)); padded_line_size: constant Positive:= 4 * Integer(Float'Ceiling(line_bits / 32.0)); unpadded_line_size: constant Positive:= Integer(Float'Ceiling(line_bits / 8.0)); -- (in bytes) begin Attach_Stream(image.buffer, image.stream); y:= 0; while y <= Integer (image.height) - 1 loop x:= 0; x_max:= Integer (image.width) - 1; case image.bits_per_pixel is when 1 => -- B/W bit:= 0; Set_X_Y(x,y); while x <= x_max loop if bit=0 then Get_Byte(image.buffer, b01); end if; b:= (b01 and 16#80#) / 16#80#; Pixel_with_palette; b01:= b01 * 2; -- cannot overflow. if bit=7 then bit:= 0; else bit:= bit + 1; end if; x:= x + 1; end loop; when 4 => -- 16 colour image pair:= True; Set_X_Y(x,y); while x <= x_max loop if pair then Get_Byte(image.buffer, b01); b:= (b01 and 16#F0#) / 16#10#; else b:= (b01 and 16#0F#); end if; pair:= not pair; Pixel_with_palette; x:= x + 1; end loop; when 8 => -- 256 colour image Set_X_Y(x,y); while x <= x_max loop Get_Byte(image.buffer, b); Pixel_with_palette; x:= x + 1; end loop; when 24 => -- RGB, 256 colour per primary colour Set_X_Y(x,y); while x <= x_max loop Get_Byte(image.buffer, bb); Get_Byte(image.buffer, bg); Get_Byte(image.buffer, br); case Primary_color_range'Modulus is when 256 => Put_Pixel( Primary_color_range(br), Primary_color_range(bg), Primary_color_range(bb), full_opaque ); when 65_536 => Put_Pixel( Times_257(Primary_color_range(br)), Times_257(Primary_color_range(bg)), Times_257(Primary_color_range(bb)), -- Times_257 makes max intensity FF go to FFFF full_opaque ); when others => raise invalid_primary_color_range with "BMP: color range not supported"; end case; x:= x + 1; end loop; when others => null; end case; for i in unpadded_line_size + 1 .. padded_line_size loop Get_Byte(image.buffer, b); end loop; y:= y + 1; Feedback((y*100) / Integer (image.height)); end loop; end Load; end GID.Decoding_BMP;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 7 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Namet; use Namet; with Types; use Types; package Exp_Ch7 is procedure Expand_N_Package_Body (N : Node_Id); procedure Expand_N_Package_Declaration (N : Node_Id); ----------------------------- -- Finalization Management -- ----------------------------- procedure Build_Anonymous_Master (Ptr_Typ : Entity_Id); -- Build a finalization master for an anonymous access-to-controlled type -- denoted by Ptr_Typ. The master is inserted in the declarations of the -- current unit. procedure Build_Controlling_Procs (Typ : Entity_Id); -- Typ is a record, and array type having controlled components. -- Create the procedures Deep_Initialize, Deep_Adjust and Deep_Finalize -- that take care of finalization management at run-time. -- Support of exceptions from user finalization procedures -- There is a specific mechanism to handle these exceptions, continue -- finalization and then raise PE. This mechanism is used by this package -- but also by exp_intr for Ada.Unchecked_Deallocation. -- There are 3 subprograms to use this mechanism, and the type -- Finalization_Exception_Data carries internal data between these -- subprograms: -- -- 1. Build_Object_Declaration: create the variables for the next two -- subprograms. -- 2. Build_Exception_Handler: create the exception handler for a call -- to a user finalization procedure. -- 3. Build_Raise_Stmt: create code to potentially raise a PE exception -- if an exception was raise in a user finalization procedure. type Finalization_Exception_Data is record Loc : Source_Ptr; -- Sloc for the added nodes Abort_Id : Entity_Id; -- Boolean variable set to true if the finalization was triggered by -- an abort. E_Id : Entity_Id; -- Variable containing the exception occurrence raised by user code Raised_Id : Entity_Id; -- Boolean variable set to true if an exception was raised in user code end record; function Build_Exception_Handler (Data : Finalization_Exception_Data; For_Library : Boolean := False) return Node_Id; -- Subsidiary to Build_Finalizer, Make_Deep_Array_Body and Make_Deep_Record -- _Body. Create an exception handler of the following form: -- -- when others => -- if not Raised_Id then -- Raised_Id := True; -- Save_Occurrence (E_Id, Get_Current_Excep.all.all); -- end if; -- -- If flag For_Library is set (and not in restricted profile): -- -- when others => -- if not Raised_Id then -- Raised_Id := True; -- Save_Library_Occurrence (Get_Current_Excep.all); -- end if; -- -- E_Id denotes the defining identifier of a local exception occurrence. -- Raised_Id is the entity of a local boolean flag. Flag For_Library is -- used when operating at the library level, when enabled the current -- exception will be saved to a global location. procedure Build_Finalization_Master (Typ : Entity_Id; For_Lib_Level : Boolean := False; For_Private : Boolean := False; Context_Scope : Entity_Id := Empty; Insertion_Node : Node_Id := Empty); -- Build a finalization master for an access type. The designated type may -- not necessarily be controlled or need finalization actions depending on -- the context. Flag For_Lib_Level must be set when creating a master for a -- build-in-place function call access result type. Flag For_Private must -- be set when the designated type contains a private component. Parameters -- Context_Scope and Insertion_Node must be used in conjunction with flag -- For_Private. Context_Scope is the scope of the context where the -- finalization master must be analyzed. Insertion_Node is the insertion -- point before which the master is to be inserted. procedure Build_Late_Proc (Typ : Entity_Id; Nam : Name_Id); -- Build one controlling procedure when a late body overrides one of the -- controlling operations. procedure Build_Object_Declarations (Data : out Finalization_Exception_Data; Decls : List_Id; Loc : Source_Ptr; For_Package : Boolean := False); -- Subsidiary to Make_Deep_Array_Body and Make_Deep_Record_Body. Create the -- list List containing the object declarations of boolean flag Abort_Id, -- the exception occurrence E_Id and boolean flag Raised_Id. -- -- Abort_Id : constant Boolean := -- Exception_Identity (Get_Current_Excep.all) = -- Standard'Abort_Signal'Identity; -- <or> -- Abort_Id : constant Boolean := False; -- no abort or For_Package -- -- E_Id : Exception_Occurrence; -- Raised_Id : Boolean := False; function Build_Raise_Statement (Data : Finalization_Exception_Data) return Node_Id; -- Subsidiary to routines Build_Finalizer, Make_Deep_Array_Body and Make_ -- Deep_Record_Body. Generate the following conditional raise statement: -- -- if Raised_Id and then not Abort_Id then -- Raise_From_Controlled_Operation (E_Id); -- end if; -- -- Abort_Id is a local boolean flag which is set when the finalization was -- triggered by an abort, E_Id denotes the defining identifier of a local -- exception occurrence, Raised_Id is the entity of a local boolean flag. function CW_Or_Has_Controlled_Part (T : Entity_Id) return Boolean; -- True if T is a class-wide type, or if it has controlled parts ("part" -- means T or any of its subcomponents). Same as Needs_Finalization, except -- when pragma Restrictions (No_Finalization) applies, in which case we -- know that class-wide objects do not contain controlled parts. function Has_New_Controlled_Component (E : Entity_Id) return Boolean; -- E is a type entity. Give the same result as Has_Controlled_Component -- except for tagged extensions where the result is True only if the -- latest extension contains a controlled component. function Make_Adjust_Call (Obj_Ref : Node_Id; Typ : Entity_Id; Skip_Self : Boolean := False) return Node_Id; -- Create a call to either Adjust or Deep_Adjust depending on the structure -- of type Typ. Obj_Ref is an expression with no side effects (not required -- to have been previously analyzed) that references the object to be -- adjusted. Typ is the expected type of Obj_Ref. When Skip_Self is set, -- only the components (if any) are adjusted. Return Empty if Adjust or -- Deep_Adjust is not available, possibly due to previous errors. function Make_Detach_Call (Obj_Ref : Node_Id) return Node_Id; -- Create a call to unhook an object from an arbitrary list. Obj_Ref is the -- object. Generate the following: -- -- Ada.Finalization.Heap_Management.Detach -- (System.Finalization_Root.Root_Controlled_Ptr (Obj_Ref)); function Make_Final_Call (Obj_Ref : Node_Id; Typ : Entity_Id; Skip_Self : Boolean := False) return Node_Id; -- Create a call to either Finalize or Deep_Finalize, depending on the -- structure of type Typ. Obj_Ref is an expression (with no side effects -- and is not required to have been previously analyzed) that references -- the object to be finalized. Typ is the expected type of Obj_Ref. When -- Skip_Self is set, only the components (if any) are finalized. Return -- Empty if Finalize or Deep_Finalize is not available, possibly due to -- previous errors. procedure Make_Finalize_Address_Body (Typ : Entity_Id); -- Create the body of TSS routine Finalize_Address if Typ is controlled and -- does not have a TSS entry for Finalize_Address. The procedure converts -- an address into a pointer and subsequently calls Deep_Finalize on the -- dereference. function Make_Init_Call (Obj_Ref : Node_Id; Typ : Entity_Id) return Node_Id; -- Create a call to either Initialize or Deep_Initialize, depending on the -- structure of type Typ. Obj_Ref is an expression with no side effects -- (not required to have been previously analyzed) that references the -- object to be initialized. Typ is the expected type of Obj_Ref. Return -- Empty if Initialize or Deep_Initialize is not available, possibly due to -- previous errors. function Make_Handler_For_Ctrl_Operation (Loc : Source_Ptr) return Node_Id; -- Generate an implicit exception handler with an 'others' choice, -- converting any occurrence to a raise of Program_Error. function Make_Local_Deep_Finalize (Typ : Entity_Id; Nam : Entity_Id) return Node_Id; -- Create a special version of Deep_Finalize with identifier Nam. The -- routine has state information and can perform partial finalization. function Make_Set_Finalize_Address_Call (Loc : Source_Ptr; Ptr_Typ : Entity_Id) return Node_Id; -- Associate the Finalize_Address primitive of the designated type with the -- finalization master of access type Ptr_Typ. The returned call is: -- -- Set_Finalize_Address -- (<Ptr_Typ>FM, <Desig_Typ>FD'Unrestricted_Access); -------------------------------------------- -- Task and Protected Object finalization -- -------------------------------------------- function Cleanup_Array (N : Node_Id; Obj : Node_Id; Typ : Entity_Id) return List_Id; -- Generate loops to finalize any tasks or simple protected objects that -- are subcomponents of an array. function Cleanup_Protected_Object (N : Node_Id; Ref : Node_Id) return Node_Id; -- Generate code to finalize a protected object without entries function Cleanup_Record (N : Node_Id; Obj : Node_Id; Typ : Entity_Id) return List_Id; -- For each subcomponent of a record that contains tasks or simple -- protected objects, generate the appropriate finalization call. function Cleanup_Task (N : Node_Id; Ref : Node_Id) return Node_Id; -- Generate code to finalize a task function Has_Simple_Protected_Object (T : Entity_Id) return Boolean; -- Check whether composite type contains a simple protected component function Is_Simple_Protected_Type (T : Entity_Id) return Boolean; -- Determine whether T denotes a protected type without entries whose -- _object field is of type System.Tasking.Protected_Objects.Protection. -- Something wrong here, implementation was changed to test Lock_Free -- but this spec does not mention that ??? -------------------------------- -- Transient Scope Management -- -------------------------------- procedure Expand_Cleanup_Actions (N : Node_Id); -- Expand the necessary stuff into a scope to enable finalization of local -- objects and deallocation of transient data when exiting the scope. N is -- a "scope node" that is to say one of the following: N_Block_Statement, -- N_Subprogram_Body, N_Task_Body, N_Entry_Body. procedure Establish_Transient_Scope (N : Node_Id; Manage_Sec_Stack : Boolean); -- Push a new transient scope on the scope stack. N is the node which must -- be serviced by the transient scope. Set Manage_Sec_Stack when the scope -- must mark and release the secondary stack. function Node_To_Be_Wrapped return Node_Id; -- Return the node to be wrapped if the current scope is transient procedure Store_Before_Actions_In_Scope (L : List_Id); -- Append the list L of actions to the end of the before-actions store in -- the top of the scope stack (also analyzes these actions). procedure Store_After_Actions_In_Scope (L : List_Id); -- Prepend the list L of actions to the beginning of the after-actions -- stored in the top of the scope stack (also analyzes these actions). -- -- Note that we are prepending here rather than appending. This means that -- if several calls are made to this procedure for the same scope, the -- actions will be executed in reverse order of the calls (actions for the -- last call executed first). Within the list L for a single call, the -- actions are executed in the order in which they appear in this list. procedure Store_Cleanup_Actions_In_Scope (L : List_Id); -- Prepend the list L of actions to the beginning of the cleanup-actions -- store in the top of the scope stack. procedure Wrap_Transient_Declaration (N : Node_Id); -- N is an object declaration. Expand the finalization calls after the -- declaration and make the outer scope being the transient one. procedure Wrap_Transient_Expression (N : Node_Id); -- N is a sub-expression. Expand a transient block around an expression procedure Wrap_Transient_Statement (N : Node_Id); -- N is a statement. Expand a transient block around an instruction end Exp_Ch7;
-- -- Jan & Uwe R. Zimmer, Australia, July 2011 -- with Ada.Numerics.Generic_Elementary_Functions; package body Quaternions is package Elementary_Functions is new Ada.Numerics.Generic_Elementary_Functions (Real); use Elementary_Functions; -- function "abs" (Quad : Quaternion_Real) return Real is (Sqrt (Quad.w**2 + Quad.x**2 + Quad.y**2 + Quad.z**2)); function Unit (Quad : Quaternion_Real) return Quaternion_Real is (Quad / abs (Quad)); function Conj (Quad : Quaternion_Real) return Quaternion_Real is (w => Quad.w, x => -Quad.x, y => -Quad.y, z => -Quad.z); function "-" (Quad : Quaternion_Real) return Quaternion_Real is (w => -Quad.w, x => -Quad.x, y => -Quad.y, z => -Quad.z); function "+" (Left, Right : Quaternion_Real) return Quaternion_Real is (w => Left.w + Right.w, x => Left.x + Right.x, y => Left.y + Right.y, z => Left.z + Right.z); function "-" (Left, Right : Quaternion_Real) return Quaternion_Real is (w => Left.w - Right.w, x => Left.x - Right.x, y => Left.y - Right.y, z => Left.z - Right.z); function "*" (Left : Quaternion_Real; Right : Real) return Quaternion_Real is (w => Left.w * Right, x => Left.x * Right, y => Left.y * Right, z => Left.z * Right); function "*" (Left : Real; Right : Quaternion_Real) return Quaternion_Real is (Right * Left); function "/" (Left : Quaternion_Real; Right : Real) return Quaternion_Real is (w => Left.w / Right, x => Left.x / Right, y => Left.y / Right, z => Left.z / Right); function "/" (Left : Real; Right : Quaternion_Real) return Quaternion_Real is (Right / Left); function "*" (Left, Right : Quaternion_Real) return Quaternion_Real is (w => Left.w * Right.w - Left.x * Right.x - Left.y * Right.y - Left.z * Right.z, x => Left.w * Right.x + Left.x * Right.w + Left.y * Right.z - Left.z * Right.y, y => Left.w * Right.y - Left.x * Right.z + Left.y * Right.w + Left.z * Right.x, z => Left.w * Right.z + Left.x * Right.y - Left.y * Right.x + Left.z * Right.w); function "/" (Left, Right : Quaternion_Real) return Quaternion_Real is (w => Left.w * Right.w + Left.x * Right.x + Left.y * Right.y + Left.z * Right.z, x => Left.w * Right.x - Left.x * Right.w - Left.y * Right.z + Left.z * Right.y, y => Left.w * Right.y + Left.x * Right.z - Left.y * Right.w - Left.z * Right.x, z => Left.w * Right.z - Left.x * Right.y + Left.y * Right.x - Left.z * Right.w); function Image (Quad : Quaternion_Real) return String is (Real'Image (Quad.w) & " +" & Real'Image (Quad.x) & "i +" & Real'Image (Quad.y) & "j +" & Real'Image (Quad.z) & "k"); -- end Quaternions;
----------------------------------------------------------------------- -- AUnit utils - Helper for writing unit tests -- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Calendar; with GNAT.Source_Info; with Util.Properties; with Util.Assertions; with Util.XUnit; package Util.Tests is use Ada.Strings.Unbounded; subtype Message_String is Util.XUnit.Message_String; subtype Test_Case is Util.XUnit.Test_Case; subtype Test_Suite is Util.XUnit.Test_Suite; subtype Access_Test_Suite is Util.XUnit.Access_Test_Suite; function Format (S : in String) return Message_String renames Util.XUnit.Format; type Test is new Util.XUnit.Test with null record; -- Get a path to access a test file. function Get_Path (File : String) return String; -- Get a path to create a test file. function Get_Test_Path (File : String) return String; -- Get the timeout for the test execution. function Get_Test_Timeout (Name : in String) return Duration; -- Get the testsuite harness prefix. This prefix is added to the test class name. -- By default it is empty. It is allows to execute the test harness on different -- environment (ex: MySQL or SQLlite) and be able to merge and collect the two result -- sets together. function Get_Harness_Prefix return String; -- Get a test configuration parameter. function Get_Parameter (Name : String; Default : String := "") return String; -- Get the test configuration properties. function Get_Properties return Util.Properties.Manager; -- Get a new unique string function Get_Uuid return String; -- Get the verbose flag that can be activated with the <tt>-v</tt> option. function Verbose return Boolean; -- Returns True if the test with the given name is enabled. -- By default all the tests are enabled. When the -r test option is passed -- all the tests are disabled except the test specified by the -r option. function Is_Test_Enabled (Name : in String) return Boolean; -- Check that two files are equal. This is intended to be used by -- tests that create files that are then checked against patterns. procedure Assert_Equal_Files (T : in Test_Case'Class; Expect : in String; Test : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that two files are equal. This is intended to be used by -- tests that create files that are then checked against patterns. procedure Assert_Equal_Files (T : in Test'Class; Expect : in String; Test : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that the value matches what we expect. procedure Assert_Equals is new Assertions.Assert_Equals_T (Value_Type => Integer); procedure Assert_Equals is new Assertions.Assert_Equals_T (Value_Type => Character); procedure Assert_Equals is new Assertions.Assert_Equals_T (Value_Type => Long_Long_Integer); -- Check that the value matches what we expect. -- procedure Assert (T : in Test'Class; -- Condition : in Boolean; -- Message : in String := "Test failed"; -- Source : String := GNAT.Source_Info.File; -- Line : Natural := GNAT.Source_Info.Line); -- Check that the value matches what we expect. procedure Assert_Equals (T : in Test'Class; Expect, Value : in Ada.Calendar.Time; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that the value matches what we expect. procedure Assert_Equals (T : in Test'Class; Expect, Value : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that the value matches what we expect. procedure Assert_Equals (T : in Test'Class; Expect : in String; Value : in Unbounded_String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that the value matches the regular expression procedure Assert_Matches (T : in Test'Class; Pattern : in String; Value : in Unbounded_String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that the value matches the regular expression procedure Assert_Matches (T : in Test'Class; Pattern : in String; Value : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Check that the file exists. procedure Assert_Exists (T : in Test'Class; File : in String; Message : in String := "Test failed"; Source : String := GNAT.Source_Info.File; Line : Natural := GNAT.Source_Info.Line); -- Report a test failed. procedure Fail (T : in Test'Class; Message : in String := "Test failed"; Source : in String := GNAT.Source_Info.File; Line : in Natural := GNAT.Source_Info.Line); -- Default initialization procedure. procedure Initialize_Test (Props : in Util.Properties.Manager); -- The main testsuite program. This launches the tests, collects the -- results, create performance logs and set the program exit status -- according to the testsuite execution status. -- -- The <b>Initialize</b> procedure is called before launching the unit tests. It is intended -- to configure the tests according to some external environment (paths, database access). -- -- The <b>Finish</b> procedure is called after the test suite has executed. generic with function Suite return Access_Test_Suite; with procedure Initialize (Props : in Util.Properties.Manager) is Initialize_Test; with procedure Finish (Status : in Util.XUnit.Status) is null; procedure Harness (Name : in String); end Util.Tests;
----------------------------------------------------------------------- -- ado-sessions -- Sessions Management -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log; with Util.Log.Loggers; with Ada.Unchecked_Deallocation; with ADO.Sequences; with ADO.Statements.Create; package body ADO.Sessions is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Sessions"); procedure Check_Session (Database : in Session'Class; Message : in String := "") is begin if Database.Impl = null then Log.Error ("Session is closed or not initialized"); raise Session_Error; end if; if Message'Length > 0 then Log.Info (Message, Database.Impl.Database.Value.Ident); end if; end Check_Session; -- --------- -- Session -- --------- -- ------------------------------ -- Get the session status. -- ------------------------------ function Get_Status (Database : in Session) return Connection_Status is begin if Database.Impl = null or else Database.Impl.Database.Is_Null then return CLOSED; else return OPEN; end if; end Get_Status; -- ------------------------------ -- Get the database driver which manages this connection. -- ------------------------------ function Get_Driver (Database : in Session) return ADO.Connections.Driver_Access is begin if Database.Impl = null or else Database.Impl.Database.Is_Null then return null; else return Database.Impl.Database.Value.Get_Driver; end if; end Get_Driver; -- ------------------------------ -- Close the session. -- ------------------------------ procedure Close (Database : in out Session) is procedure Free is new Ada.Unchecked_Deallocation (Object => Session_Record, Name => Session_Record_Access); Is_Zero : Boolean; begin Log.Info ("Closing session"); if Database.Impl /= null then ADO.Objects.Release_Proxy (Database.Impl.Proxy); Database.Impl.Database.Value.Close; Util.Concurrent.Counters.Decrement (Database.Impl.Counter, Is_Zero); if Is_Zero then Free (Database.Impl); end if; Database.Impl := null; end if; end Close; -- ------------------------------ -- Insert a new cache in the manager. The cache is identified by the given name. -- ------------------------------ procedure Add_Cache (Database : in out Session; Name : in String; Cache : in ADO.Caches.Cache_Type_Access) is begin Check_Session (Database); Database.Impl.Values.Add_Cache (Name, Cache); end Add_Cache; -- ------------------------------ -- Attach the object to the session. -- ------------------------------ procedure Attach (Database : in out Session; Object : in ADO.Objects.Object_Ref'Class) is pragma Unreferenced (Object); begin Check_Session (Database); end Attach; -- ------------------------------ -- Check if the session contains the object identified by the given key. -- ------------------------------ function Contains (Database : in Session; Item : in ADO.Objects.Object_Key) return Boolean is begin Check_Session (Database); return ADO.Objects.Cache.Contains (Database.Impl.Cache, Item); end Contains; -- ------------------------------ -- Remove the object from the session cache. -- ------------------------------ procedure Evict (Database : in out Session; Item : in ADO.Objects.Object_Key) is begin Check_Session (Database); ADO.Objects.Cache.Remove (Database.Impl.Cache, Item); end Evict; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement is begin Check_Session (Database); declare Query : constant Query_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Query, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Query : in String) return Query_Statement is begin Check_Session (Database); declare Stmt : constant Query_Statement_Access := Database.Impl.Database.Value.Create_Statement (Query); begin return ADO.Statements.Create.Create_Statement (Stmt, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Query : in ADO.Queries.Context'Class) return Query_Statement is begin Check_Session (Database); declare SQL : constant String := Query.Get_SQL (Database.Impl.Queries.all); Stmt : Query_Statement := Database.Create_Statement (SQL); begin Stmt.Set_Parameters (Query); return Stmt; end; end Create_Statement; -- ------------------------------ -- Create a query statement and initialize the SQL statement with the query definition. -- ------------------------------ function Create_Statement (Database : in Session; Query : in ADO.Queries.Query_Definition_Access) return Query_Statement is begin Check_Session (Database); declare SQL : constant String := ADO.Queries.Get_SQL (Query, Database.Impl.Queries.all, False); begin return Database.Create_Statement (SQL); end; end Create_Statement; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Query : in ADO.SQL.Query'Class; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement is begin Check_Session (Database); declare Stmt : Query_Statement := Database.Create_Statement (Table); begin if Query in ADO.Queries.Context'Class then declare SQL : constant String := ADO.Queries.Context'Class (Query).Get_SQL (Database.Impl.Queries.all); begin ADO.SQL.Append (Stmt.Get_Query.SQL, SQL); end; end if; Stmt.Set_Parameters (Query); return Stmt; end; end Create_Statement; -- ------------------------------ -- Load the database schema definition for the current database. -- ------------------------------ procedure Load_Schema (Database : in Session; Schema : out ADO.Schemas.Schema_Definition) is begin Check_Session (Database, "Loading schema {0}"); Database.Impl.Database.Value.Load_Schema (Schema); end Load_Schema; -- --------- -- Master Session -- --------- -- ------------------------------ -- Start a transaction. -- ------------------------------ procedure Begin_Transaction (Database : in out Master_Session) is begin Check_Session (Database, "Begin transaction {0}"); Database.Impl.Database.Value.Begin_Transaction; end Begin_Transaction; -- ------------------------------ -- Commit the current transaction. -- ------------------------------ procedure Commit (Database : in out Master_Session) is begin Check_Session (Database, "Commit transaction {0}"); Database.Impl.Database.Value.Commit; end Commit; -- ------------------------------ -- Rollback the current transaction. -- ------------------------------ procedure Rollback (Database : in out Master_Session) is begin Check_Session (Database, "Rollback transaction {0}"); Database.Impl.Database.Value.Rollback; end Rollback; -- ------------------------------ -- Allocate an identifier for the table. -- ------------------------------ procedure Allocate (Database : in out Master_Session; Id : in out ADO.Objects.Object_Record'Class) is begin Check_Session (Database); ADO.Sequences.Allocate (Database.Sequences.all, Id); end Allocate; -- ------------------------------ -- Flush the objects that were modified. -- ------------------------------ procedure Flush (Database : in out Master_Session) is begin Check_Session (Database); end Flush; overriding procedure Adjust (Object : in out Session) is begin if Object.Impl /= null then Util.Concurrent.Counters.Increment (Object.Impl.Counter); end if; end Adjust; overriding procedure Finalize (Object : in out Session) is procedure Free is new Ada.Unchecked_Deallocation (Object => Session_Record, Name => Session_Record_Access); Is_Zero : Boolean; begin if Object.Impl /= null then Util.Concurrent.Counters.Decrement (Object.Impl.Counter, Is_Zero); if Is_Zero then ADO.Objects.Release_Proxy (Object.Impl.Proxy, Detach => True); if not Object.Impl.Database.Is_Null then Object.Impl.Database.Value.Close; end if; Free (Object.Impl); end if; Object.Impl := null; end if; end Finalize; -- ------------------------------ -- Create a delete statement -- ------------------------------ function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement is begin Check_Session (Database); declare Stmt : constant Delete_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Stmt.all'Access, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create an update statement -- ------------------------------ function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement is begin Check_Session (Database); declare Stmt : constant Update_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Stmt.all'Access, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create an insert statement -- ------------------------------ function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement is begin Check_Session (Database); declare Stmt : constant Insert_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Stmt.all'Access, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Get the audit manager. -- ------------------------------ function Get_Audit_Manager (Database : in Master_Session) return access Audits.Audit_Manager'Class is begin return Database.Audit; end Get_Audit_Manager; -- ------------------------------ -- Internal operation to get access to the database connection. -- ------------------------------ procedure Access_Connection (Database : in out Master_Session; Process : not null access procedure (Connection : in out Database_Connection'Class)) is begin Check_Session (Database); Process (Database.Impl.Database.Value); end Access_Connection; -- ------------------------------ -- Internal method to get the session proxy associated with the given database session. -- The session proxy is associated with some ADO objects to be able to retrieve the database -- session for the implementation of lazy loading. The session proxy is kept until the -- session exist and at least one ADO object is refering to it. -- ------------------------------ function Get_Session_Proxy (Database : in Session) return ADO.Objects.Session_Proxy_Access is use type ADO.Objects.Session_Proxy_Access; begin Check_Session (Database); if Database.Impl.Proxy = null then Database.Impl.Proxy := ADO.Objects.Create_Session_Proxy (Database.Impl); end if; return Database.Impl.Proxy; end Get_Session_Proxy; end ADO.Sessions;
package Return2_Pkg is function F return String; function G (Line : String; Index : Positive) return String; end Return2_Pkg;
with Interfaces.C; with System; with PortAudioAda; use PortAudioAda; package PaEx_Sine_Callbacks is ----------------------------------------------------------------------------- -- This routine will be called by the PortAudio engine when audio is needed. -- It may called at interrupt level on some machines so don't do anything -- that could mess up the system like calling malloc() or free(). function paTestCallback (inputBuffer : System.Address; outputBuffer : System.Address; framesPerBuffer : Interfaces.C.unsigned_long; timeInfo : access PA_Stream_Callback_Time_Info; statusFlags : PA_Stream_Callback_Flags; userData : System.Address) return PA_Stream_Callback_Result; pragma Export (C, paTestCallback); ----------------------------------------------------------------------------- -- This routine is called by portaudio when playback is done. procedure StreamFinished (userData : System.Address); pragma Export (C, StreamFinished); end PaEx_Sine_Callbacks;
-- This spec has been automatically generated from STM32L5x2.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; -- STM32L5x2 package STM32_SVD is pragma Preelaborate; -------------------- -- Base addresses -- -------------------- DFSDM1_Base : constant System.Address := System'To_Address (16#40016000#); SEC_DFSDM1_Base : constant System.Address := System'To_Address (16#50016000#); DMAMUX1_Base : constant System.Address := System'To_Address (16#40020800#); SEC_DMAMUX1_Base : constant System.Address := System'To_Address (16#50020800#); EXTI_Base : constant System.Address := System'To_Address (16#4002F400#); SEC_EXTI_Base : constant System.Address := System'To_Address (16#5002F400#); FLASH_Base : constant System.Address := System'To_Address (16#40022000#); SEC_FLASH_Base : constant System.Address := System'To_Address (16#50022000#); GPIOA_Base : constant System.Address := System'To_Address (16#42020000#); SEC_GPIOA_Base : constant System.Address := System'To_Address (16#52020000#); GPIOB_Base : constant System.Address := System'To_Address (16#42020400#); SEC_GPIOB_Base : constant System.Address := System'To_Address (16#52020400#); GPIOC_Base : constant System.Address := System'To_Address (16#42020800#); GPIOD_Base : constant System.Address := System'To_Address (16#42020C00#); GPIOE_Base : constant System.Address := System'To_Address (16#42021000#); GPIOF_Base : constant System.Address := System'To_Address (16#42021400#); GPIOG_Base : constant System.Address := System'To_Address (16#42021800#); SEC_GPIOC_Base : constant System.Address := System'To_Address (16#52020800#); SEC_GPIOD_Base : constant System.Address := System'To_Address (16#52020C00#); SEC_GPIOE_Base : constant System.Address := System'To_Address (16#52021000#); SEC_GPIOF_Base : constant System.Address := System'To_Address (16#52021400#); SEC_GPIOG_Base : constant System.Address := System'To_Address (16#52021800#); GPIOH_Base : constant System.Address := System'To_Address (16#42021C00#); SEC_GPIOH_Base : constant System.Address := System'To_Address (16#52021C00#); TAMP_Base : constant System.Address := System'To_Address (16#50003400#); I2C1_Base : constant System.Address := System'To_Address (16#40005400#); I2C2_Base : constant System.Address := System'To_Address (16#40005800#); I2C3_Base : constant System.Address := System'To_Address (16#40005C00#); I2C4_Base : constant System.Address := System'To_Address (16#40008400#); SEC_I2C1_Base : constant System.Address := System'To_Address (16#50005400#); SEC_I2C2_Base : constant System.Address := System'To_Address (16#50005800#); SEC_I2C3_Base : constant System.Address := System'To_Address (16#50005C00#); SEC_I2C4_Base : constant System.Address := System'To_Address (16#50008400#); ICache_Base : constant System.Address := System'To_Address (16#40030400#); SEC_ICache_Base : constant System.Address := System'To_Address (16#50030400#); IWDG_Base : constant System.Address := System'To_Address (16#40003000#); SEC_IWDG_Base : constant System.Address := System'To_Address (16#50003000#); LPTIM1_Base : constant System.Address := System'To_Address (16#40007C00#); LPTIM2_Base : constant System.Address := System'To_Address (16#40009400#); LPTIM3_Base : constant System.Address := System'To_Address (16#40009800#); SEC_LPTIM1_Base : constant System.Address := System'To_Address (16#50007C00#); SEC_LPTIM2_Base : constant System.Address := System'To_Address (16#50009400#); SEC_LPTIM3_Base : constant System.Address := System'To_Address (16#50009800#); MPCBB1_Base : constant System.Address := System'To_Address (16#40032C00#); MPCBB2_Base : constant System.Address := System'To_Address (16#40033000#); PWR_Base : constant System.Address := System'To_Address (16#40007000#); SEC_PWR_Base : constant System.Address := System'To_Address (16#50007000#); RCC_Base : constant System.Address := System'To_Address (16#40021000#); SEC_RCC_Base : constant System.Address := System'To_Address (16#50021000#); RTC_Base : constant System.Address := System'To_Address (16#40002800#); SEC_RTC_Base : constant System.Address := System'To_Address (16#50002800#); SAI1_Base : constant System.Address := System'To_Address (16#40015400#); SAI2_Base : constant System.Address := System'To_Address (16#40015800#); SEC_SAI1_Base : constant System.Address := System'To_Address (16#50015400#); SEC_SAI2_Base : constant System.Address := System'To_Address (16#50015800#); DMA1_Base : constant System.Address := System'To_Address (16#40020000#); SEC_DMA1_Base : constant System.Address := System'To_Address (16#50020000#); DMA2_Base : constant System.Address := System'To_Address (16#40020400#); SEC_DMA2_Base : constant System.Address := System'To_Address (16#50020400#); SEC_MPCBB1_Base : constant System.Address := System'To_Address (16#50032C00#); SEC_MPCBB2_Base : constant System.Address := System'To_Address (16#50033000#); SPI1_Base : constant System.Address := System'To_Address (16#40013000#); SPI2_Base : constant System.Address := System'To_Address (16#40003800#); SPI3_Base : constant System.Address := System'To_Address (16#40003C00#); SEC_SPI1_Base : constant System.Address := System'To_Address (16#50013000#); SEC_SPI2_Base : constant System.Address := System'To_Address (16#50003800#); SEC_SPI3_Base : constant System.Address := System'To_Address (16#50003C00#); TIM1_Base : constant System.Address := System'To_Address (16#40012C00#); SEC_TIM1_Base : constant System.Address := System'To_Address (16#50012C00#); TIM15_Base : constant System.Address := System'To_Address (16#40014000#); SEC_TIM15_Base : constant System.Address := System'To_Address (16#50014000#); TIM16_Base : constant System.Address := System'To_Address (16#40014400#); SEC_TIM16_Base : constant System.Address := System'To_Address (16#50014400#); TIM17_Base : constant System.Address := System'To_Address (16#40014800#); SEC_TIM17_Base : constant System.Address := System'To_Address (16#50014800#); TIM2_Base : constant System.Address := System'To_Address (16#40000000#); SEC_TIM2_Base : constant System.Address := System'To_Address (16#50000000#); TIM3_Base : constant System.Address := System'To_Address (16#40000400#); SEC_TIM3_Base : constant System.Address := System'To_Address (16#50000400#); TIM4_Base : constant System.Address := System'To_Address (16#40000800#); SEC_TIM4_Base : constant System.Address := System'To_Address (16#50000800#); TIM5_Base : constant System.Address := System'To_Address (16#40000C00#); SEC_TIM5_Base : constant System.Address := System'To_Address (16#50000C00#); TIM8_Base : constant System.Address := System'To_Address (16#40013400#); SEC_TIM8_Base : constant System.Address := System'To_Address (16#50013400#); TZIC_Base : constant System.Address := System'To_Address (16#40032800#); SEC_TZIC_Base : constant System.Address := System'To_Address (16#50032800#); TZSC_Base : constant System.Address := System'To_Address (16#40032400#); SEC_TZSC_Base : constant System.Address := System'To_Address (16#50032400#); WWDG_Base : constant System.Address := System'To_Address (16#40002C00#); SEC_WWDG_Base : constant System.Address := System'To_Address (16#50002C00#); SYSCFG_Base : constant System.Address := System'To_Address (16#40010000#); SEC_SYSCFG_Base : constant System.Address := System'To_Address (16#50010000#); SEC_RNG_Base : constant System.Address := System'To_Address (16#520c0800#); RNG_Base : constant System.Address := System'To_Address (16#420c0800#); PKA_Base : constant System.Address := System'To_Address (16#420C2000#); SEC_PKA_Base : constant System.Address := System'To_Address (16#520C2000#); DBGMCU_Base : constant System.Address := System'To_Address (16#E0044000#); USB_Base : constant System.Address := System'To_Address (16#4000D400#); SEC_USB_Base : constant System.Address := System'To_Address (16#5000D400#); OCTOSPI1_Base : constant System.Address := System'To_Address (16#44021000#); SEC_OCTOSPI1_Base : constant System.Address := System'To_Address (16#54021000#); LPUART1_Base : constant System.Address := System'To_Address (16#40008000#); SEC_LPUART1_Base : constant System.Address := System'To_Address (16#50008000#); COMP_Base : constant System.Address := System'To_Address (16#40010200#); SEC_COMP_Base : constant System.Address := System'To_Address (16#50010200#); VREFBUF_Base : constant System.Address := System'To_Address (16#40010030#); SEC_VREFBUF_Base : constant System.Address := System'To_Address (16#50010030#); TSC_Base : constant System.Address := System'To_Address (16#40024000#); SEC_TSC_Base : constant System.Address := System'To_Address (16#50024000#); UCPD1_Base : constant System.Address := System'To_Address (16#4000DC00#); SEC_UCPD1_Base : constant System.Address := System'To_Address (16#5000DC00#); FDCAN1_Base : constant System.Address := System'To_Address (16#4000A400#); SEC_FDCAN1_Base : constant System.Address := System'To_Address (16#5000A400#); CRC_Base : constant System.Address := System'To_Address (16#40023000#); SEC_CRC_Base : constant System.Address := System'To_Address (16#50023000#); CRS_Base : constant System.Address := System'To_Address (16#40006000#); SEC_CRS_Base : constant System.Address := System'To_Address (16#50006000#); USART1_Base : constant System.Address := System'To_Address (16#40013800#); SEC_USART1_Base : constant System.Address := System'To_Address (16#50013800#); USART2_Base : constant System.Address := System'To_Address (16#40004400#); SEC_USART2_Base : constant System.Address := System'To_Address (16#50004400#); USART3_Base : constant System.Address := System'To_Address (16#40004800#); SEC_USART3_Base : constant System.Address := System'To_Address (16#50004800#); UART4_Base : constant System.Address := System'To_Address (16#40004C00#); UART5_Base : constant System.Address := System'To_Address (16#40005000#); SEC_UART4_Base : constant System.Address := System'To_Address (16#50004C00#); SEC_UART5_Base : constant System.Address := System'To_Address (16#50005000#); ADC_Common_Base : constant System.Address := System'To_Address (16#42028300#); SEC_ADC_Common_Base : constant System.Address := System'To_Address (16#52028300#); ADC_Base : constant System.Address := System'To_Address (16#42028000#); SEC_ADC_Base : constant System.Address := System'To_Address (16#52028000#); NVIC_Base : constant System.Address := System'To_Address (16#E000E100#); NVIC_STIR_Base : constant System.Address := System'To_Address (16#E000EF00#); SAU_Base : constant System.Address := System'To_Address (16#E000EDD0#); MPU_Base : constant System.Address := System'To_Address (16#E000ED90#); HASH_Base : constant System.Address := System'To_Address (16#420C0400#); SEC_HASH_Base : constant System.Address := System'To_Address (16#520C0400#); DAC_Base : constant System.Address := System'To_Address (16#40007400#); SEC_DAC_Base : constant System.Address := System'To_Address (16#50007400#); end STM32_SVD;
with impact.d2.orbs.Joint.distance, impact.d2.orbs.Joint.friction, impact.d2.orbs.Solid, ada.unchecked_Deallocation; package body impact.d2.orbs.Joint is function Create (def : in b2JointDef'Class) return Joint.view is use impact.d2.orbs.Joint.distance, impact.d2.orbs.Joint.friction; joint : access b2Joint'Class; pragma Unreferenced (joint); begin case def.kind is when e_distanceJoint => joint := new b2DistanceJoint '(to_b2DistanceJoint (b2DistanceJointDef (def))); -- when e_mouseJoint => joint := new b2MouseJoint ' (to_b2MouseJoint (b2MouseJointDef (def))); -- when e_prismaticJoint => joint := new b2PrismaticJoint' (to_b2PrismaticJoint (b2PrismaticJointDef (def))); -- when e_revoluteJoint => joint := new b2RevoluteJoint ' (to_b2RevoluteJoint (b2RevoluteJoint (def))); -- when e_pulleyJoint => joint := new b2PulleyJoint ' (to_b2PulleyJoint (b2PulleyJointDef (def))); -- when e_gearJoint => joint := new b2GearJoint ' (to_b2GearJoint (b2GearJointDef (def))); -- when e_lineJoint => joint := new b2LineJoint ' (to_b2LineJoint (b2LineJointDef (def))); -- when e_weldJoint => joint := new b2WeldJoint ' (to_b2WeldJoint (b2WeldJointDef (def))); when e_frictionJoint => joint := new b2FrictionJoint '(to_b2FrictionJoint (b2FrictionJointDef (def))); when others => pragma Assert (False); raise Program_Error; end case; return null; -- joint; end Create; procedure Destroy (Self : in out Joint.view) is procedure free is new ada.unchecked_Deallocation (b2Joint'Class, Joint.view); begin Self.destruct; free (Self); end Destroy; procedure SetZero (Self : in out b2Jacobian) is begin Self.linearA := (0.0, 0.0); Self.angularA := 0.0; Self.linearB := (0.0, 0.0); Self.angularB := 0.0; end SetZero; procedure Set (Self : in out b2Jacobian; x1 : b2Vec2; a1 : float32; x2 : b2Vec2; a2 : float32) is begin Self.linearA := x1; Self.angularA := a1; Self.linearB := x2; Self.angularB := a2; end Set; function Compute (Self : in b2Jacobian; x1 : b2Vec2; a1 : float32; x2 : b2Vec2; a2 : float32) return float32 is begin return b2Dot (Self.linearA, x1) + Self.angularA * a1 + b2Dot (Self.linearB, x2) + Self.angularB * a2; end Compute; function GetNext (Self : in b2Joint) return Joint.view is begin return Self.m_next; end GetNext; procedure m_islandFlag_is (Self : in out b2Joint; Now : in Boolean) is begin Self.m_islandFlag := Now; end m_islandFlag_is; function m_islandFlag (Self : in b2Joint) return Boolean is begin return Self.m_islandFlag; end m_islandFlag; function m_collideConnected (Self : in b2Joint) return Boolean is begin return Self.m_collideConnected; end m_collideConnected; function m_edgeA (Self : access b2Joint) return b2JointEdge_view is begin return Self.m_edgeA'Access; end m_edgeA; function m_edgeB (Self : access b2Joint) return b2JointEdge_view is begin return Self.m_edgeB'Access; end m_edgeB; function m_prev (Self : access b2Joint) return Joint.view is begin return Self.m_prev; end m_prev; procedure m_prev_is (Self : in out b2Joint; Now : Joint.view) is begin Self.m_prev := Now; end m_prev_is; procedure m_next_is (Self : in out b2Joint; Now : Joint.view) is begin Self.m_next := Now; end m_next_is; function getBodyA (Self : in b2Joint) return Solid_view is begin return Self.m_bodyA; end getBodyA; function getBodyB (Self : in b2Joint) return Solid_view is begin return Self.m_bodyB; end getBodyB; function getType (Self : in b2Joint) return b2JointType is begin return Self.m_type; end getType; function GetUserData (Self : in b2Joint) return Any_view is begin return Self.m_userData; end GetUserData; procedure SetUserData (Self : in out b2Joint; data : Any_view) is begin Self.m_userData := data; end SetUserData; function IsActive (Self : in b2Joint) return Boolean is begin return Self.m_bodyA.IsActive and then Self.m_bodyB.IsActive; end IsActive; procedure define (Self : in out b2Joint; Def : in b2JointDef'class) is begin pragma Assert (def.bodyA /= def.bodyB); Self.m_type := def.kind; Self.m_bodyA := def.bodyA; Self.m_bodyB := def.bodyB; Self.m_collideConnected := def.collideConnected; Self.m_islandFlag := False; Self.m_userData := def.userData; end define; end impact.d2.orbs.Joint;
with Ada.Text_IO; use Ada.Text_IO; with Memory.RAM; use Memory.RAM; with Device; with Test.Cache; with Test.DRAM; with Test.Flip; with Test.Offset; with Test.Prefetch; with Test.RAM; with Test.Register; with Test.Shift; with Test.Split; with Test.SPM; package body Test is function Create_Monitor(latency : Time_Type := 0; ram : Boolean := True) return Monitor_Pointer is result : constant Monitor_Pointer := new Monitor_Type; begin result.latency := latency; if ram then Set_Memory(result.all, Create_RAM(latency => 1, word_size => 8)); end if; return result; end Create_Monitor; function Clone(mem : Monitor_Type) return Memory_Pointer is begin return null; end Clone; procedure Read(mem : in out Monitor_Type; address : in Address_Type; size : in Positive) is begin Check(address < Address_Type(2) ** 32); Read(Container_Type(mem), address, size); mem.last_addr := address; mem.last_size := size; mem.reads := mem.reads + 1; Advance(mem, mem.latency); mem.cycles := mem.cycles + mem.latency; end Read; procedure Write(mem : in out Monitor_Type; address : in Address_Type; size : in Positive) is begin Check(address < Address_Type(2) ** 32); Write(Container_Type(mem), address, size); mem.last_addr := address; mem.last_size := size; mem.writes := mem.writes + 1; Advance(mem, mem.latency); mem.cycles := mem.cycles + mem.latency; end Write; procedure Idle(mem : in out Monitor_Type; cycles : in Time_Type) is begin Idle(Container_Type(mem), cycles); mem.cycles := mem.cycles + cycles; end Idle; procedure Generate(mem : in Monitor_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is other : constant Memory_Pointer := Get_Memory(mem); begin Generate(other.all, sigs, code); end Generate; procedure Run_Tests is begin count := 0; failed := 0; Device.Set_Device("virtex7"); Device.Set_Address_Bits(32); RAM.Run_Tests; Cache.Run_Tests; DRAM.Run_Tests; SPM.Run_Tests; Flip.Run_Tests; Offset.Run_Tests; Shift.Run_Tests; Split.Run_Tests; Prefetch.Run_Tests; Register.Run_Tests; Put_Line("ran" & Natural'Image(count) & " tests"); if failed > 1 then Put_Line(Natural'Image(failed) & " tests failed"); elsif failed = 1 then Put_Line(Natural'Image(failed) & " test failed"); else Put_Line("all tests passed"); end if; end Run_Tests; procedure Check(cond : in Boolean; source : in String := GNAT.Source_Info.File; line : in Natural := GNAT.Source_Info.Line) is lstr : constant String := Natural'Image(line); msg : constant String := source & "[" & lstr(lstr'First + 1 .. lstr'Last) & "]"; begin count := count + 1; if not cond then Put_Line(msg & ": FAILED"); failed := failed + 1; end if; end Check; end Test;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Exceptions; with Ada.Text_IO; with Coroutines.Polling; package body TCP_Servers is type Listener_Arguments is record Port : GNAT.Sockets.Port_Type; Run : not null TCP_Coroutine; Stack : System.Storage_Elements.Storage_Count; end record; procedure Listen (Args : Listener_Arguments); ------------ -- Listen -- ------------ procedure Listen (Args : Listener_Arguments) is procedure Start is new Coroutines.Generic_Start (GNAT.Sockets.Socket_Type); Address : GNAT.Sockets.Sock_Addr_Type := (Family => GNAT.Sockets.Family_Inet, Addr => GNAT.Sockets.Any_Inet_Addr, Port => Args.Port); Server : GNAT.Sockets.Socket_Type; Dont_Block : GNAT.Sockets.Request_Type := (Name => GNAT.Sockets.Non_Blocking_IO, Enabled => True); begin GNAT.Sockets.Create_Socket (Server); GNAT.Sockets.Set_Socket_Option (Server, GNAT.Sockets.Socket_Level, (GNAT.Sockets.Reuse_Address, True)); GNAT.Sockets.Control_Socket (Server, Dont_Block); GNAT.Sockets.Bind_Socket (Server, Address); declare Socket : GNAT.Sockets.Socket_Type; begin GNAT.Sockets.Listen_Socket (Server); loop -- Wait a Server socket event Coroutines.Yield (Coroutines.Polling.Watch (Coroutines.Polling.FD (GNAT.Sockets.To_C (Server)), (Coroutines.Polling.Input | Coroutines.Polling.Error | Coroutines.Polling.Close => True, others => False))); begin GNAT.Sockets.Accept_Socket (Server, Socket, Address); Start (Args.Run, Args.Stack, Socket); exception when E : GNAT.Sockets.Socket_Error => if GNAT.Sockets.Resolve_Exception (E) not in GNAT.Sockets.Resource_Temporarily_Unavailable then Ada.Text_IO.Put_Line ("Listen_Socket Error:" & Ada.Exceptions.Exception_Message (E)); Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); exit; end if; end; end loop; end; end Listen; ----------------- -- Listen_Port -- ----------------- procedure Listen_Port (Port : GNAT.Sockets.Port_Type; Run : not null TCP_Coroutine; Stack : System.Storage_Elements.Storage_Count) is procedure Start is new Coroutines.Generic_Start (Listener_Arguments); begin Start (Listen'Access, Stack, (Port, Run, Stack)); end Listen_Port; end TCP_Servers;
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Containers.Hashed_Maps; with Ada.Containers.Doubly_Linked_Lists; with League.Strings.Hash; with LSP.Messages; with Incr.Lexers.Incremental; with Incr.Nodes; with Incr.Parsers.Incremental; with Ada_LSP.Ada_Lexers; with Ada_LSP.Ada_Parser_Data; with Ada_LSP.Completions; with Ada_LSP.Documents; package Ada_LSP.Contexts is type Context is tagged limited private; not overriding procedure Initialize (Self : in out Context; Root : League.Strings.Universal_String); not overriding procedure Load_Document (Self : in out Context; Item : LSP.Messages.TextDocumentItem); not overriding function Get_Document (Self : Context; URI : LSP.Messages.DocumentUri) return Ada_LSP.Documents.Document_Access; not overriding procedure Update_Document (Self : in out Context; Item : not null Ada_LSP.Documents.Document_Access); -- Reparse document after changes not overriding procedure Add_Completion_Handler (Self : in out Context; Value : not null Ada_LSP.Completions.Handler_Access); not overriding procedure Fill_Completions (Self : Context; Context : Ada_LSP.Completions.Context'Class; Result : in out LSP.Messages.CompletionList); not overriding function Get_Parser_Data_Provider (Self : Context) return Ada_LSP.Ada_Parser_Data.Provider_Access; private package Document_Maps is new Ada.Containers.Hashed_Maps (Key_Type => LSP.Messages.DocumentUri, Element_Type => Ada_LSP.Documents.Document_Access, Hash => League.Strings.Hash, Equivalent_Keys => League.Strings."=", "=" => Ada_LSP.Documents."="); type Kind_Map is array (Incr.Nodes.Node_Kind range <>) of Boolean; type Provider is new Ada_LSP.Ada_Parser_Data.Provider with record Is_Defining_Name : Kind_Map (108 .. 120); end record; overriding function Is_Defining_Name (Self : Provider; Kind : Incr.Nodes.Node_Kind) return Boolean; package Completion_Handler_Lists is new Ada.Containers.Doubly_Linked_Lists (Ada_LSP.Completions.Handler_Access, Ada_LSP.Completions."="); type Context is tagged limited record Root : League.Strings.Universal_String; Documents : Document_Maps.Map; Batch_Lexer : aliased Ada_LSP.Ada_Lexers.Batch_Lexer; Incr_Lexer : aliased Incr.Lexers.Incremental.Incremental_Lexer; Incr_Parser : aliased Incr.Parsers.Incremental.Incremental_Parser; Provider : aliased Ada_LSP.Contexts.Provider; Completions : Completion_Handler_Lists.List; end record; end Ada_LSP.Contexts;
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl> -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Ada.Containers.Generic_Array_Sort; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Interfaces.C.Strings; use Interfaces.C.Strings; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with CArgv; with Tcl; use Tcl; with Tcl.Ada; use Tcl.Ada; with Tcl.Tk.Ada; use Tcl.Tk.Ada; with Tcl.Tk.Ada.Grid; with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets; with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas; with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu; with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame; with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel; with Tcl.Tk.Ada.Widgets.TtkPanedWindow; use Tcl.Tk.Ada.Widgets.TtkPanedWindow; with Tcl.Tk.Ada.Widgets.TtkTreeView; use Tcl.Tk.Ada.Widgets.TtkTreeView; with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo; with Tcl.Tklib.Ada.Tooltip; use Tcl.Tklib.Ada.Tooltip; with Crafts; use Crafts; with CoreUI; use CoreUI; with Goals; use Goals; with Items; use Items; with Maps.UI; use Maps.UI; with Missions; use Missions; with Ships; use Ships; with Utils.UI; use Utils.UI; package body Statistics.UI is -- ****iv* SUI/SUI.Crafting_Indexes -- FUNCTION -- Indexes of the finished crafting orders -- SOURCE Crafting_Indexes: Positive_Container.Vector; -- **** -- ****iv* SUI/SUI.Missions_Indexes -- FUNCTION -- Indexes of the finished missions -- SOURCE Missions_Indexes: Positive_Container.Vector; -- **** -- ****iv* SUI/SUI.Goals_Indexes -- FUNCTION -- Indexes of the finished goals -- SOURCE Goals_Indexes: Positive_Container.Vector; -- **** -- ****iv* SUI/SUI.Destroyed_Indexes -- FUNCTION -- Indexes of the destroyed ships -- SOURCE Destroyed_Indexes: Positive_Container.Vector; -- **** -- ****iv* SUI/SUI.Killed_Indexes -- FUNCTION -- Indexes of the killed mobs -- SOURCE Killed_Indexes: Positive_Container.Vector; -- **** procedure ShowStatistics(Refresh: Boolean := False) is TotalFinished, TotalDestroyed: Natural := 0; StatsText: Unbounded_String; ProtoIndex: Positive; StatsFrame: Ttk_Frame := Get_Widget(Main_Paned & ".statsframe"); StatsCanvas: constant Tk_Canvas := Get_Widget(StatsFrame & ".canvas"); Label: Ttk_Label := Get_Widget(StatsCanvas & ".stats.left.points"); TreeView: Ttk_Tree_View; begin if Winfo_Get(Label, "exists") = "0" then Tcl_EvalFile (Get_Context, To_String(Data_Directory) & "ui" & Dir_Separator & "stats.tcl"); Bind(StatsFrame, "<Configure>", "{ResizeCanvas %W.canvas %w %h}"); elsif Winfo_Get(Label, "ismapped") = "1" and not Refresh then Tcl_Eval(Get_Context, "InvokeButton " & Close_Button); Tcl.Tk.Ada.Grid.Grid_Remove(Close_Button); return; end if; Entry_Configure(GameMenu, "Help", "-command {ShowHelp general}"); configure(Label, "-text {Points:" & Natural'Image(GetGamePoints) & "}"); Add(Label, "The amount of points gained in this game"); StatsText := To_Unbounded_String("Time passed:"); declare MinutesDiff: constant Natural := (Game_Date.Minutes + (Game_Date.Hour * 60) + (Game_Date.Day * 1_440) + (Game_Date.Month * 43_200) + (Game_Date.Year * 518_400)) - 829_571_520; begin Minutes_To_Date(MinutesDiff, StatsText); end; Label := Get_Widget(StatsCanvas & ".stats.left.time"); configure(Label, "-text {" & To_String(StatsText) & "}"); Add(Label, "In game time which was passed since it started"); declare type VisitedFactor is digits 4 range 0.0 .. 100.0; VisitedPercent: VisitedFactor; VisitedString: String(1 .. 5); begin VisitedPercent := VisitedFactor((Float(GameStats.BasesVisited) / 1_024.0) * 100.0); Put (To => VisitedString, Item => Float(VisitedPercent), Aft => 3, Exp => 0); StatsText := To_Unbounded_String ("Bases visited:" & Positive'Image(GameStats.BasesVisited) & " (" & VisitedString & "%)"); Label := Get_Widget(StatsCanvas & ".stats.left.bases"); configure(Label, "-text {" & To_String(StatsText) & "}"); Add (Label, "The amount of sky bases visited and total percentage of all bases"); VisitedPercent := VisitedFactor(Float(GameStats.MapVisited) / (1_024.0 * 1_024.0)) * 100.0; if VisitedPercent < 0.001 then VisitedPercent := 0.001; end if; Put (To => VisitedString, Item => Float(VisitedPercent), Aft => 3, Exp => 0); StatsText := To_Unbounded_String("Map discovered: " & VisitedString & "%"); Label := Get_Widget(StatsCanvas & ".stats.left.map"); configure(Label, "-text {" & To_String(StatsText) & "}"); Add(Label, "The amount of unique map's fields visited"); end; StatsText := To_Unbounded_String ("Distance traveled:" & Natural'Image(GameStats.DistanceTraveled)); Label := Get_Widget(StatsCanvas & ".stats.left.distance"); configure(Label, "-text {" & To_String(StatsText) & "}"); Add(Label, "The total amount of map's fields visited"); StatsFrame.Name := New_String(StatsCanvas & ".stats"); TotalFinished := 0; Count_Finished_Crafting_Loop : for CraftingOrder of GameStats.CraftingOrders loop TotalFinished := TotalFinished + CraftingOrder.Amount; end loop Count_Finished_Crafting_Loop; Label.Name := New_String(StatsFrame & ".left.crafts"); configure (Label, "-text {Crafting orders finished:" & Natural'Image(TotalFinished) & "}"); Add(Label, "The total amount of crafting orders finished in this game"); StatsFrame := Get_Widget(StatsCanvas & ".stats.left.craftsframe"); TreeView := Get_Widget(StatsFrame & ".craftsview"); if Children(TreeView, "{}") /= "{}" then Delete(TreeView, "[list " & Children(TreeView, "{}") & "]"); end if; if TotalFinished > 0 then if Crafting_Indexes.Length /= GameStats.CraftingOrders.Length then Crafting_Indexes.Clear; for I in GameStats.CraftingOrders.Iterate loop Crafting_Indexes.Append(Statistics_Container.To_Index(I)); end loop; end if; Show_Finished_Crafting_Loop : for I of Crafting_Indexes loop Insert (TreeView, "{} end -values [list {" & To_String (Items_List (Recipes_List(GameStats.CraftingOrders(I).Index) .ResultIndex) .Name) & "} {" & Positive'Image(GameStats.CraftingOrders(I).Amount) & "}]"); end loop Show_Finished_Crafting_Loop; configure (TreeView, "-height" & (if GameStats.CraftingOrders.Length < 10 then Positive'Image(Positive(GameStats.CraftingOrders.Length)) else " 10")); Tcl.Tk.Ada.Grid.Grid(StatsFrame); else Tcl.Tk.Ada.Grid.Grid_Remove(StatsFrame); end if; TotalFinished := 0; Count_Finished_Missions_Loop : for FinishedMission of GameStats.FinishedMissions loop TotalFinished := TotalFinished + FinishedMission.Amount; end loop Count_Finished_Missions_Loop; Label.Name := New_String(StatsCanvas & ".stats.left.missions"); declare MissionsPercent: Natural := 0; begin if GameStats.AcceptedMissions > 0 then MissionsPercent := Natural ((Float(TotalFinished) / Float(GameStats.AcceptedMissions)) * 100.0); end if; configure (Label, "-text {Missions completed:" & Natural'Image(TotalFinished) & " (" & To_String (Trim (To_Unbounded_String(Natural'Image(MissionsPercent)), Ada.Strings.Left)) & "%)" & "}"); Add(Label, "The total amount of missions finished in this game"); end; StatsFrame := Get_Widget(StatsCanvas & ".stats.left.missionsframe"); TreeView.Name := New_String(StatsFrame & ".missionsview"); if Children(TreeView, "{}") /= "{}" then Delete(TreeView, "[list " & Children(TreeView, "{}") & "]"); end if; if TotalFinished > 0 then if Missions_Indexes.Length /= GameStats.FinishedMissions.Length then Missions_Indexes.Clear; for I in GameStats.FinishedMissions.Iterate loop Missions_Indexes.Append(Statistics_Container.To_Index(I)); end loop; end if; Show_Finished_Missions_Loop : for I of Missions_Indexes loop case Missions_Types'Val (Integer'Value (To_String(GameStats.FinishedMissions(I).Index))) is when Deliver => Insert (TreeView, "{} end -values [list {Delivered items} {" & Positive'Image(GameStats.FinishedMissions(I).Amount) & "}]"); when Patrol => Insert (TreeView, "{} end -values [list {Patroled areas} {" & Positive'Image(GameStats.FinishedMissions(I).Amount) & "}]"); when Destroy => Insert (TreeView, "{} end -values [list {Destroyed ships} {" & Positive'Image(GameStats.FinishedMissions(I).Amount) & "}]"); when Explore => Insert (TreeView, "{} end -values [list {Explored areas} {" & Positive'Image(GameStats.FinishedMissions(I).Amount) & "}]"); when Passenger => Insert (TreeView, "{} end -values [list {Passengers transported} {" & Positive'Image(GameStats.FinishedMissions(I).Amount) & "}]"); end case; end loop Show_Finished_Missions_Loop; configure (TreeView, "-height" & (if GameStats.FinishedMissions.Length < 10 then Positive'Image(Positive(GameStats.FinishedMissions.Length)) else " 10")); Tcl.Tk.Ada.Grid.Grid(StatsFrame); else Tcl.Tk.Ada.Grid.Grid_Remove(StatsFrame); end if; Label.Name := New_String(StatsCanvas & ".stats.left.goal"); configure (Label, "-text {" & (if GoalText(0)'Length < 22 then GoalText(0) else GoalText(0)(1 .. 22)) & "...}"); Add(Label, "The current goal: " & GoalText(0)); TotalFinished := 0; Count_Finished_Goals_Loop : for FinishedGoal of GameStats.FinishedGoals loop TotalFinished := TotalFinished + FinishedGoal.Amount; end loop Count_Finished_Goals_Loop; Label.Name := New_String(StatsCanvas & ".stats.left.goals"); configure (Label, "-text {Finished goals:" & Natural'Image(TotalFinished) & "}"); Add(Label, "The total amount of goals finished in this game"); StatsFrame := Get_Widget(StatsCanvas & ".stats.left.goalsframe"); TreeView.Name := New_String(StatsFrame & ".goalsview"); if Children(TreeView, "{}") /= "{}" then Delete(TreeView, "[list " & Children(TreeView, "{}") & "]"); end if; if TotalFinished > 0 then if Goals_Indexes.Length /= GameStats.FinishedGoals.Length then Goals_Indexes.Clear; for I in GameStats.FinishedGoals.Iterate loop Goals_Indexes.Append(Statistics_Container.To_Index(I)); end loop; end if; Show_Finished_Goals_Loop : for I of Goals_Indexes loop Get_Proto_Goal_Loop : for J in Goals_List.Iterate loop if Goals_List(J).Index = GameStats.FinishedGoals(I).Index then ProtoIndex := Goals_Container.To_Index(J); exit Get_Proto_Goal_Loop; end if; end loop Get_Proto_Goal_Loop; Insert (TreeView, "{} end -values [list {" & GoalText(ProtoIndex) & "} {" & Positive'Image(GameStats.FinishedGoals(I).Amount) & "}]"); end loop Show_Finished_Goals_Loop; configure (TreeView, "-height" & (if GameStats.FinishedGoals.Length < 10 then Positive'Image(Positive(GameStats.FinishedGoals.Length)) else " 10")); Tcl.Tk.Ada.Grid.Grid(StatsFrame); else Tcl.Tk.Ada.Grid.Grid_Remove(StatsFrame); end if; StatsFrame := Get_Widget(StatsCanvas & ".stats.right.destroyedframe"); TreeView.Name := New_String(StatsFrame & ".destroyedview"); if GameStats.DestroyedShips.Length > 0 then if Children(TreeView, "{}") /= "{}" then Delete(TreeView, "[list " & Children(TreeView, "{}") & "]"); end if; if Destroyed_Indexes.Length /= GameStats.DestroyedShips.Length then Destroyed_Indexes.Clear; for I in GameStats.DestroyedShips.Iterate loop Destroyed_Indexes.Append(Statistics_Container.To_Index(I)); end loop; end if; Count_Destroyed_Ships_Loop : for I of Destroyed_Indexes loop Get_Proto_Ship_Loop : for J in Proto_Ships_List.Iterate loop if Proto_Ships_Container.Key(J) = GameStats.DestroyedShips(I).Index then Insert (TreeView, "{} end -values [list {" & To_String(Proto_Ships_List(J).Name) & "} {" & Positive'Image(GameStats.DestroyedShips(I).Amount) & "}]"); exit Get_Proto_Ship_Loop; end if; end loop Get_Proto_Ship_Loop; TotalDestroyed := TotalDestroyed + GameStats.DestroyedShips(I).Amount; end loop Count_Destroyed_Ships_Loop; configure (TreeView, "-height" & (if GameStats.DestroyedShips.Length < 10 then Positive'Image(Positive(GameStats.DestroyedShips.Length)) else " 10")); Tcl.Tk.Ada.Grid.Grid(StatsFrame); else Tcl.Tk.Ada.Grid.Grid_Remove(StatsFrame); end if; Label.Name := New_String(StatsCanvas & ".stats.right.destroyed"); configure (Label, "-text {Destroyed ships (Total:" & Natural'Image(TotalDestroyed) & ")}"); Add(Label, "The total amount of destroyed ships in this game"); StatsFrame := Get_Widget(StatsCanvas & ".stats.right.killedframe"); TreeView.Name := New_String(StatsFrame & ".killedview"); TotalDestroyed := 0; if GameStats.KilledMobs.Length > 0 then if Children(TreeView, "{}") /= "{}" then Delete(TreeView, "[list " & Children(TreeView, "{}") & "]"); end if; if Killed_Indexes.Length /= GameStats.KilledMobs.Length then Killed_Indexes.Clear; for I in GameStats.KilledMobs.Iterate loop Killed_Indexes.Append(Statistics_Container.To_Index(I)); end loop; end if; Show_Killed_Mobs_Loop : for KilledMob of GameStats.KilledMobs loop Insert (TreeView, "{} end -values [list {" & To_String(KilledMob.Index) & "} {" & Positive'Image(KilledMob.Amount) & "}]"); TotalDestroyed := TotalDestroyed + KilledMob.Amount; end loop Show_Killed_Mobs_Loop; configure (TreeView, "-height" & (if GameStats.KilledMobs.Length < 10 then Positive'Image(Positive(GameStats.KilledMobs.Length)) else " 10")); Tcl.Tk.Ada.Grid.Grid(StatsFrame); else Tcl.Tk.Ada.Grid.Grid_Remove(StatsFrame); end if; Label.Name := New_String(StatsCanvas & ".stats.right.killed"); configure (Label, "-text {Killed enemies (Total:" & Natural'Image(TotalDestroyed) & ")}"); Add (Label, "The total amount of enemies killed in melee combat in this game"); configure (StatsCanvas, "-height [expr " & SashPos(Main_Paned, "0") & " - 20] -width " & cget(Main_Paned, "-width")); Tcl_Eval(Get_Context, "update"); StatsFrame := Get_Widget(StatsCanvas & ".stats"); Canvas_Create (StatsCanvas, "window", "0 0 -anchor nw -window " & StatsFrame); Tcl_Eval(Get_Context, "update"); configure (StatsCanvas, "-scrollregion [list " & BBox(StatsCanvas, "all") & "]"); Show_Screen("statsframe"); end ShowStatistics; -- ****it* SUI/SUI.Lists_Sort_Orders -- FUNCTION -- Sorting orders for the various lists -- OPTIONS -- NAMEASC - Sort list by name ascending -- NAMEDESC - Sort list by name descending -- AMOUNTASC - Sort list by amount ascending -- AMOUNTDESC - Sort list by amount descending -- NONE - No sorting list (default) -- HISTORY -- 6.5 - Added -- 6.6 - Changed to List_Sort_Orders -- SOURCE type List_Sort_Orders is (NAMEASC, NAMEDESC, AMOUNTASC, AMOUNTDESC, NONE) with Default_Value => NONE; -- **** -- ****id* SUI/SUI.Default_List_Sort_Order -- FUNCTION -- Default sorting order for the various lists -- HISTORY -- 6.5 - Added -- 6.6 - Changed to Default_List_Sort_Order -- SOURCE Default_List_Sort_Order: constant List_Sort_Orders := NONE; -- **** -- ****is* SUI/SUI.Sorting_Data -- FUNCTION -- Data structure used to sort various lists -- PARAMETERS -- Name - The name of the item (mission, goal, crafting order, etc) -- Amount - The amount of the item (mission, goal, crafting order, etc) -- Id - The index of the item on the list -- HISTORY -- 6.6 - Added -- SOURCE type Sorting_Data is record Name: Unbounded_String; Amount: Positive; Id: Positive; end record; -- **** -- ****it* SUI/SUI.Sorting_Array -- FUNCTION -- Array used to sort various lists -- SOURCE type Sorting_Array is array(Positive range <>) of Sorting_Data; -- **** -- ****if* SUI/SUI.Set_Sorting_Order -- FUNCTION -- Set sorting order for the selected list -- PARAMETERS -- Sorting_Order - The sorting order to set -- Column - The column in ttk_tree_view whith was clicked -- OUTPUT -- Parameter Sorting_Order -- HISTORY -- 6.6 - Added -- SOURCE procedure Set_Sorting_Order (Sorting_Order: in out List_Sort_Orders; Column: Positive) is -- **** begin Sorting_Order := (case Column is when 1 => (if Sorting_Order = NAMEASC then NAMEDESC else NAMEASC), when 2 => (if Sorting_Order = AMOUNTASC then AMOUNTDESC else AMOUNTASC), when others => NONE); end Set_Sorting_Order; -- ****iv* SUI/SUI.Crafting_Sort_Order -- FUNCTION -- The current sorting order for the list of finished crafting orders -- HISTORY -- 6.5 - Added -- SOURCE Crafting_Sort_Order: List_Sort_Orders := Default_List_Sort_Order; -- **** -- ****o* SUI/SUI.Sort_Crafting_Command -- FUNCTION -- Sort the list of finished crafting orders -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SortFinishedCrafting x -- X is the number of column where the player clicked the mouse button -- SOURCE function Sort_Crafting_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Sort_Crafting_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc); Column: constant Positive := Natural'Value(CArgv.Arg(Argv, 1)); Local_Crafting: Sorting_Array (1 .. Positive(GameStats.CraftingOrders.Length)); function "<"(Left, Right: Sorting_Data) return Boolean is begin if Crafting_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Crafting_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Crafting_Sort_Order = AMOUNTASC and then Left.Amount < Right.Amount then return True; end if; if Crafting_Sort_Order = AMOUNTDESC and then Left.Amount > Right.Amount then return True; end if; return False; end "<"; procedure Sort_Crafting is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Sorting_Data, Array_Type => Sorting_Array); begin Set_Sorting_Order(Crafting_Sort_Order, Column); if Crafting_Sort_Order = NONE then return TCL_OK; end if; for I in GameStats.CraftingOrders.Iterate loop Local_Crafting(Statistics_Container.To_Index(I)) := (Name => Items_List (Recipes_List(GameStats.CraftingOrders(I).Index).ResultIndex) .Name, Amount => GameStats.CraftingOrders(I).Amount, Id => Statistics_Container.To_Index(I)); end loop; Sort_Crafting(Local_Crafting); Crafting_Indexes.Clear; for Order of Local_Crafting loop Crafting_Indexes.Append(Order.Id); end loop; ShowStatistics(True); return TCL_OK; end Sort_Crafting_Command; -- ****iv* SUI/SUI.Missions_Sort_Order -- FUNCTION -- The current sorting order for the list of finished missions -- HISTORY -- 6.5 - Added -- SOURCE Missions_Sort_Order: List_Sort_Orders := Default_List_Sort_Order; -- **** -- ****o* SUI/SUI.Sort_Missions_Command -- FUNCTION -- Sort the list of finished missions -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SortFinishedMissions x -- X is the number of column where the player clicked the mouse button -- SOURCE function Sort_Missions_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Sort_Missions_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc); Column: constant Positive := Natural'Value(CArgv.Arg(Argv, 1)); Local_Missions: Sorting_Array (1 .. Positive(GameStats.FinishedMissions.Length)); function "<"(Left, Right: Sorting_Data) return Boolean is begin if Missions_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Missions_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Missions_Sort_Order = AMOUNTASC and then Left.Amount < Right.Amount then return True; end if; if Missions_Sort_Order = AMOUNTDESC and then Left.Amount > Right.Amount then return True; end if; return False; end "<"; procedure Sort_Missions is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Sorting_Data, Array_Type => Sorting_Array); begin Set_Sorting_Order(Missions_Sort_Order, Column); if Missions_Sort_Order = NONE then return TCL_OK; end if; for I in GameStats.FinishedMissions.Iterate loop Local_Missions(Statistics_Container.To_Index(I)) := (Name => (case Missions_Types'Val (Integer'Value (To_String(GameStats.FinishedMissions(I).Index))) is when Deliver => To_Unbounded_String("Delivered items"), when Patrol => To_Unbounded_String("Patroled areas"), when Destroy => To_Unbounded_String("Destroyed ships"), when Explore => To_Unbounded_String("Explored areas"), when Passenger => To_Unbounded_String("Passengers transported")), Amount => GameStats.FinishedMissions(I).Amount, Id => Statistics_Container.To_Index(I)); end loop; Sort_Missions(Local_Missions); Missions_Indexes.Clear; for Mission of Local_Missions loop Missions_Indexes.Append(Mission.Id); end loop; ShowStatistics(True); return TCL_OK; end Sort_Missions_Command; -- ****iv* SUI/SUI.Goals_Sort_Order -- FUNCTION -- The current sorting order for the list of finished goals -- HISTORY -- 6.6 - Added -- SOURCE Goals_Sort_Order: List_Sort_Orders := Default_List_Sort_Order; -- **** -- ****o* SUI/SUI.Sort_Goals_Command -- FUNCTION -- Sort the list of finished goals -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SortFinishedGoals x -- X is the number of column where the player clicked the mouse button -- SOURCE function Sort_Goals_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Sort_Goals_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc); Column: constant Positive := Natural'Value(CArgv.Arg(Argv, 1)); ProtoIndex: Positive := 1; Local_Goals: Sorting_Array (1 .. Positive(GameStats.FinishedGoals.Length)); function "<"(Left, Right: Sorting_Data) return Boolean is begin if Goals_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Goals_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Goals_Sort_Order = AMOUNTASC and then Left.Amount < Right.Amount then return True; end if; if Goals_Sort_Order = AMOUNTDESC and then Left.Amount > Right.Amount then return True; end if; return False; end "<"; procedure Sort_Goals is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Sorting_Data, Array_Type => Sorting_Array); begin Set_Sorting_Order(Goals_Sort_Order, Column); if Goals_Sort_Order = NONE then return TCL_OK; end if; for I in GameStats.FinishedGoals.Iterate loop Get_Proto_Goal_Loop : for J in Goals_List.Iterate loop if Goals_List(J).Index = GameStats.FinishedGoals(I).Index then ProtoIndex := Goals_Container.To_Index(J); exit Get_Proto_Goal_Loop; end if; end loop Get_Proto_Goal_Loop; Local_Goals(Statistics_Container.To_Index(I)) := (Name => To_Unbounded_String(GoalText(ProtoIndex)), Amount => GameStats.FinishedGoals(I).Amount, Id => Statistics_Container.To_Index(I)); end loop; Sort_Goals(Local_Goals); Goals_Indexes.Clear; for Goal of Local_Goals loop Goals_Indexes.Append(Goal.Id); end loop; ShowStatistics(True); return TCL_OK; end Sort_Goals_Command; -- ****iv* SUI/SUI.Destroyed_Sort_Order -- FUNCTION -- The current sorting order for the list of destroyed enemy ships -- HISTORY -- 6.6 - Added -- SOURCE Destroyed_Sort_Order: List_Sort_Orders := Default_List_Sort_Order; -- **** -- ****o* SUI/SUI.Sort_Destroyed_Command -- FUNCTION -- Sort the list of destroyed enemy ships -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SortDestroyedShips x -- X is the number of column where the player clicked the mouse button -- SOURCE function Sort_Destroyed_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Sort_Destroyed_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc); Column: constant Positive := Natural'Value(CArgv.Arg(Argv, 1)); Local_Destroyed: Sorting_Array (1 .. Positive(GameStats.DestroyedShips.Length)); function "<"(Left, Right: Sorting_Data) return Boolean is begin if Destroyed_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Destroyed_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Destroyed_Sort_Order = AMOUNTASC and then Left.Amount < Right.Amount then return True; end if; if Destroyed_Sort_Order = AMOUNTDESC and then Left.Amount > Right.Amount then return True; end if; return False; end "<"; procedure Sort_Destroyed is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Sorting_Data, Array_Type => Sorting_Array); begin Set_Sorting_Order(Destroyed_Sort_Order, Column); if Destroyed_Sort_Order = NONE then return TCL_OK; end if; for I in GameStats.DestroyedShips.Iterate loop Get_Proto_Ship_Loop : for J in Proto_Ships_List.Iterate loop if Proto_Ships_Container.Key(J) = GameStats.DestroyedShips(I).Index then Local_Destroyed(Statistics_Container.To_Index(I)) := (Name => Proto_Ships_List(J).Name, Amount => GameStats.DestroyedShips(I).Amount, Id => Statistics_Container.To_Index(I)); exit Get_Proto_Ship_Loop; end if; end loop Get_Proto_Ship_Loop; end loop; Sort_Destroyed(Local_Destroyed); Destroyed_Indexes.Clear; for Ship of Local_Destroyed loop Destroyed_Indexes.Append(Ship.Id); end loop; ShowStatistics(True); return TCL_OK; end Sort_Destroyed_Command; -- ****iv* SUI/SUI.Killed_Sort_Order -- FUNCTION -- The current sorting order for the list of killed enemies -- HISTORY -- 6.6 - Added -- SOURCE Killed_Sort_Order: List_Sort_Orders := Default_List_Sort_Order; -- **** -- ****o* SUI/SUI.Sort_Killed_Command -- FUNCTION -- Sort the list of killed enemies -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SortKilledEnemies x -- X is the number of column where the player clicked the mouse button -- SOURCE function Sort_Killed_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Sort_Killed_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc); Column: constant Positive := Natural'Value(CArgv.Arg(Argv, 1)); Local_Killed: Sorting_Array(1 .. Positive(GameStats.KilledMobs.Length)); function "<"(Left, Right: Sorting_Data) return Boolean is begin if Killed_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Killed_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Killed_Sort_Order = AMOUNTASC and then Left.Amount < Right.Amount then return True; end if; if Killed_Sort_Order = AMOUNTDESC and then Left.Amount > Right.Amount then return True; end if; return False; end "<"; procedure Sort_Killed is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Sorting_Data, Array_Type => Sorting_Array); begin Set_Sorting_Order(Killed_Sort_Order, Column); if Killed_Sort_Order = NONE then return TCL_OK; end if; for I in GameStats.KilledMobs.Iterate loop Local_Killed(Statistics_Container.To_Index(I)) := (Name => GameStats.KilledMobs(I).Index, Amount => GameStats.KilledMobs(I).Amount, Id => Statistics_Container.To_Index(I)); end loop; Sort_Killed(Local_Killed); Killed_Indexes.Clear; for Mob of Local_Killed loop Killed_Indexes.Append(Mob.Id); end loop; ShowStatistics(True); return TCL_OK; end Sort_Killed_Command; procedure AddCommands is begin Add_Command("SortFinishedCrafting", Sort_Crafting_Command'Access); Add_Command("SortFinishedMissions", Sort_Missions_Command'Access); Add_Command("SortFinishedGoals", Sort_Goals_Command'Access); Add_Command("SortDestroyedShips", Sort_Destroyed_Command'Access); Add_Command("SortKilledMobs", Sort_Killed_Command'Access); end AddCommands; end Statistics.UI;
-- PR ada/43106 -- Testcase by Bill Neven <neven@hitt.nl> -- { dg-do run } -- { dg-options "-O2 -flto" { target lto } } with Lto1_Pkg; use Lto1_Pkg; procedure Lto1 is Radar : Radar_T; begin Radar.Sensor_Type := radcmb; Initialize (Radar); end;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . S T R E A M S . S T O R A G E . B O U N D E D -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ package body Ada.Streams.Storage.Bounded is ---------- -- Read -- ---------- overriding procedure Read (Stream : in out Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is EA : Stream_Element_Array renames Stream.Elements (1 .. Element_Count (Stream)); begin if Item'Length = 0 then Last := Item'First - 1; -- If the entire content of the stream fits in Item, then copy it and -- clear the stream. This is likely the usual case. elsif Element_Count (Stream) <= Item'Length then Last := Item'First + Element_Count (Stream) - 1; Item (Item'First .. Last) := EA; Clear (Stream); -- Otherwise, copy as much into Item as will fit. Then slide the -- remaining part of the stream down, and compute the new Count. -- We expect this to be the unusual case, so the cost of copying -- the remaining part probably doesn't matter. else Last := Item'Last; declare New_Count : constant Stream_Element_Count := Element_Count (Stream) - Item'Length; begin Item := EA (1 .. Item'Length); EA (1 .. New_Count) := EA (Element_Count (Stream) - New_Count + 1 .. Element_Count (Stream)); Stream.Count := New_Count; end; end if; end Read; ----------- -- Write -- ----------- overriding procedure Write (Stream : in out Stream_Type; Item : Stream_Element_Array) is begin if Element_Count (Stream) + Item'Length > Stream.Max_Elements then -- That is a precondition in the RM raise Constraint_Error; end if; declare New_Count : constant Stream_Element_Count := Element_Count (Stream) + Item'Length; begin Stream.Elements (Element_Count (Stream) + 1 .. New_Count) := Item; Stream.Count := New_Count; end; end Write; ------------------- -- Element_Count -- ------------------- overriding function Element_Count (Stream : Stream_Type) return Stream_Element_Count is begin return Stream.Count; end Element_Count; ----------- -- Clear -- ----------- overriding procedure Clear (Stream : in out Stream_Type) is begin Stream.Count := 0; end Clear; end Ada.Streams.Storage.Bounded;
----------------------------------------------------------------------- -- awa-blogs-tests -- Unit tests for blogs module -- Copyright (C) 2011, 2012, 2013, 2014, 2015, 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with ADO; with Security.Contexts; with AWA.Services.Contexts; with AWA.Blogs.Modules; with AWA.Tests.Helpers.Users; package body AWA.Blogs.Modules.Tests is use ADO; package Caller is new Util.Test_Caller (Test, "Blogs.Services"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Blogs.Services.Create_Blog", Test_Create_Blog'Access); Caller.Add_Test (Suite, "Test AWA.Blogs.Services.Create_Post", Test_Create_Post'Access); end Add_Tests; -- ------------------------------ -- Test creation of a blog -- ------------------------------ procedure Test_Create_Blog (T : in out Test) is Manager : AWA.Blogs.Modules.Blog_Module_Access; Blog_Id : ADO.Identifier; Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-blog@test.com"); Manager := AWA.Blogs.Modules.Get_Blog_Module; Manager.Create_Blog (Title => "My blog", Result => Blog_Id); T.Assert (Blog_Id > 0, "Invalid blog identifier"); end Test_Create_Blog; -- ------------------------------ -- Test creating and updating of a blog post -- ------------------------------ procedure Test_Create_Post (T : in out Test) is Manager : AWA.Blogs.Modules.Blog_Module_Access; Blog_Id : ADO.Identifier; Post_Id : ADO.Identifier; Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-blog-post@test.com"); Manager := AWA.Blogs.Modules.Get_Blog_Module; Manager.Create_Blog (Title => "My blog post", Result => Blog_Id); T.Assert (Blog_Id > 0, "Invalid blog identifier"); for I in 1 .. 5 loop Manager.Create_Post (Blog_Id => Blog_Id, Title => "Testing blog title", URI => "testing-blog-title", Text => "The blog content", Summary => "Summary", Format => AWA.Blogs.Models.FORMAT_DOTCLEAR, Comment => False, Status => AWA.Blogs.Models.POST_DRAFT, Result => Post_Id); T.Assert (Post_Id > 0, "Invalid post identifier"); Manager.Update_Post (Post_Id => Post_Id, Title => "New blog post title", URI => "testing-blog-title", Text => "The new post content", Summary => "New summary", Format => AWA.Blogs.Models.FORMAT_DOTCLEAR, Publish_Date => ADO.Nullable_Time '(Is_Null => True, others => <>), Comment => True, Status => AWA.Blogs.Models.POST_DRAFT); -- Keep the last post in the database. exit when I = 5; Manager.Delete_Post (Post_Id => Post_Id); -- Verify that a Not_Found exception is raised if the post was deleted. begin Manager.Update_Post (Post_Id => Post_Id, Title => "Something", Text => "Content", Summary => "Summary", Format => AWA.Blogs.Models.FORMAT_DOTCLEAR, URI => "testing-blog-title", Publish_Date => ADO.Nullable_Time '(Is_Null => True, others => <>), Comment => True, Status => AWA.Blogs.Models.POST_DRAFT); T.Assert (False, "Exception Not_Found was not raised"); exception when Not_Found => null; end; -- Verify that a Not_Found exception is raised if the post was deleted. begin Manager.Delete_Post (Post_Id => Post_Id); T.Assert (False, "Exception Not_Found was not raised"); exception when Not_Found => null; end; end loop; end Test_Create_Post; end AWA.Blogs.Modules.Tests;
package Chi_Square is type Flt is digits 18; type Bins_Type is array(Positive range <>) of Natural; function Distance(Bins: Bins_Type) return Flt; end Chi_Square;
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ U N B O U N D E D -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Wide_Fixed; with Ada.Strings.Wide_Search; with Ada.Unchecked_Deallocation; package body Ada.Strings.Wide_Unbounded is use Ada.Finalization; --------- -- "&" -- --------- function "&" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Unbounded_Wide_String is L_Length : constant Integer := Left.Reference.all'Length; R_Length : constant Integer := Right.Reference.all'Length; Length : constant Integer := L_Length + R_Length; Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Length); Result.Reference.all (1 .. L_Length) := Left.Reference.all; Result.Reference.all (L_Length + 1 .. Length) := Right.Reference.all; return Result; end "&"; function "&" (Left : Unbounded_Wide_String; Right : Wide_String) return Unbounded_Wide_String is L_Length : constant Integer := Left.Reference.all'Length; Length : constant Integer := L_Length + Right'Length; Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Length); Result.Reference.all (1 .. L_Length) := Left.Reference.all; Result.Reference.all (L_Length + 1 .. Length) := Right; return Result; end "&"; function "&" (Left : Wide_String; Right : Unbounded_Wide_String) return Unbounded_Wide_String is R_Length : constant Integer := Right.Reference.all'Length; Length : constant Integer := Left'Length + R_Length; Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Length); Result.Reference.all (1 .. Left'Length) := Left; Result.Reference.all (Left'Length + 1 .. Length) := Right.Reference.all; return Result; end "&"; function "&" (Left : Unbounded_Wide_String; Right : Wide_Character) return Unbounded_Wide_String is Length : constant Integer := Left.Reference.all'Length + 1; Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Length); Result.Reference.all (1 .. Length - 1) := Left.Reference.all; Result.Reference.all (Length) := Right; return Result; end "&"; function "&" (Left : Wide_Character; Right : Unbounded_Wide_String) return Unbounded_Wide_String is Length : constant Integer := Right.Reference.all'Length + 1; Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Length); Result.Reference.all (1) := Left; Result.Reference.all (2 .. Length) := Right.Reference.all; return Result; end "&"; --------- -- "*" -- --------- function "*" (Left : Natural; Right : Wide_Character) return Unbounded_Wide_String is Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Left); for J in Result.Reference'Range loop Result.Reference (J) := Right; end loop; return Result; end "*"; function "*" (Left : Natural; Right : Wide_String) return Unbounded_Wide_String is Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Left * Right'Length); for J in 1 .. Left loop Result.Reference.all (Right'Length * J - Right'Length + 1 .. Right'Length * J) := Right; end loop; return Result; end "*"; function "*" (Left : Natural; Right : Unbounded_Wide_String) return Unbounded_Wide_String is R_Length : constant Integer := Right.Reference.all'Length; Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Left * R_Length); for I in 1 .. Left loop Result.Reference.all (R_Length * I - R_Length + 1 .. R_Length * I) := Right.Reference.all; end loop; return Result; end "*"; --------- -- "<" -- --------- function "<" (Left : in Unbounded_Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left.Reference.all < Right.Reference.all; end "<"; function "<" (Left : in Unbounded_Wide_String; Right : in Wide_String) return Boolean is begin return Left.Reference.all < Right; end "<"; function "<" (Left : in Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left < Right.Reference.all; end "<"; ---------- -- "<=" -- ---------- function "<=" (Left : in Unbounded_Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left.Reference.all <= Right.Reference.all; end "<="; function "<=" (Left : in Unbounded_Wide_String; Right : in Wide_String) return Boolean is begin return Left.Reference.all <= Right; end "<="; function "<=" (Left : in Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left <= Right.Reference.all; end "<="; --------- -- "=" -- --------- function "=" (Left : in Unbounded_Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left.Reference.all = Right.Reference.all; end "="; function "=" (Left : in Unbounded_Wide_String; Right : in Wide_String) return Boolean is begin return Left.Reference.all = Right; end "="; function "=" (Left : in Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left = Right.Reference.all; end "="; --------- -- ">" -- --------- function ">" (Left : in Unbounded_Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left.Reference.all > Right.Reference.all; end ">"; function ">" (Left : in Unbounded_Wide_String; Right : in Wide_String) return Boolean is begin return Left.Reference.all > Right; end ">"; function ">" (Left : in Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left > Right.Reference.all; end ">"; ---------- -- ">=" -- ---------- function ">=" (Left : in Unbounded_Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left.Reference.all >= Right.Reference.all; end ">="; function ">=" (Left : in Unbounded_Wide_String; Right : in Wide_String) return Boolean is begin return Left.Reference.all >= Right; end ">="; function ">=" (Left : in Wide_String; Right : in Unbounded_Wide_String) return Boolean is begin return Left >= Right.Reference.all; end ">="; ------------ -- Adjust -- ------------ procedure Adjust (Object : in out Unbounded_Wide_String) is begin -- Copy string, except we do not copy the statically allocated -- null string, since it can never be deallocated. if Object.Reference /= Null_Wide_String'Access then Object.Reference := new Wide_String'(Object.Reference.all); end if; end Adjust; ------------ -- Append -- ------------ procedure Append (Source : in out Unbounded_Wide_String; New_Item : in Unbounded_Wide_String) is S_Length : constant Integer := Source.Reference.all'Length; Length : constant Integer := S_Length + New_Item.Reference.all'Length; Temp : Wide_String_Access := Source.Reference; begin if Source.Reference = Null_Wide_String'Access then Source := To_Unbounded_Wide_String (New_Item.Reference.all); return; end if; Source.Reference := new Wide_String (1 .. Length); Source.Reference.all (1 .. S_Length) := Temp.all; Source.Reference.all (S_Length + 1 .. Length) := New_Item.Reference.all; Free (Temp); end Append; procedure Append (Source : in out Unbounded_Wide_String; New_Item : in Wide_String) is S_Length : constant Integer := Source.Reference.all'Length; Length : constant Integer := S_Length + New_Item'Length; Temp : Wide_String_Access := Source.Reference; begin if Source.Reference = Null_Wide_String'Access then Source := To_Unbounded_Wide_String (New_Item); return; end if; Source.Reference := new Wide_String (1 .. Length); Source.Reference.all (1 .. S_Length) := Temp.all; Source.Reference.all (S_Length + 1 .. Length) := New_Item; Free (Temp); end Append; procedure Append (Source : in out Unbounded_Wide_String; New_Item : in Wide_Character) is S_Length : constant Integer := Source.Reference.all'Length; Length : constant Integer := S_Length + 1; Temp : Wide_String_Access := Source.Reference; begin if Source.Reference = Null_Wide_String'Access then Source := To_Unbounded_Wide_String ("" & New_Item); return; end if; Source.Reference := new Wide_String (1 .. Length); Source.Reference.all (1 .. S_Length) := Temp.all; Source.Reference.all (S_Length + 1) := New_Item; Free (Temp); end Append; ----------- -- Count -- ----------- function Count (Source : Unbounded_Wide_String; Pattern : Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural is begin return Wide_Search.Count (Source.Reference.all, Pattern, Mapping); end Count; function Count (Source : in Unbounded_Wide_String; Pattern : in Wide_String; Mapping : in Wide_Maps.Wide_Character_Mapping_Function) return Natural is begin return Wide_Search.Count (Source.Reference.all, Pattern, Mapping); end Count; function Count (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set) return Natural is begin return Wide_Search.Count (Source.Reference.all, Set); end Count; ------------ -- Delete -- ------------ function Delete (Source : Unbounded_Wide_String; From : Positive; Through : Natural) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Delete (Source.Reference.all, From, Through)); end Delete; procedure Delete (Source : in out Unbounded_Wide_String; From : in Positive; Through : in Natural) is Temp : Wide_String_Access := Source.Reference; begin Source := To_Unbounded_Wide_String (Wide_Fixed.Delete (Temp.all, From, Through)); end Delete; ------------- -- Element -- ------------- function Element (Source : Unbounded_Wide_String; Index : Positive) return Wide_Character is begin if Index <= Source.Reference.all'Last then return Source.Reference.all (Index); else raise Strings.Index_Error; end if; end Element; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Unbounded_Wide_String) is procedure Deallocate is new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access); begin -- Note: Don't try to free statically allocated null string if Object.Reference /= Null_Wide_String'Access then Deallocate (Object.Reference); Object.Reference := Null_Unbounded_Wide_String.Reference; end if; end Finalize; ---------------- -- Find_Token -- ---------------- procedure Find_Token (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set; Test : Strings.Membership; First : out Positive; Last : out Natural) is begin Wide_Search.Find_Token (Source.Reference.all, Set, Test, First, Last); end Find_Token; ---------- -- Free -- ---------- procedure Free (X : in out Wide_String_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access); begin Deallocate (X); end Free; ---------- -- Head -- ---------- function Head (Source : Unbounded_Wide_String; Count : Natural; Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Head (Source.Reference.all, Count, Pad)); end Head; procedure Head (Source : in out Unbounded_Wide_String; Count : in Natural; Pad : in Wide_Character := Wide_Space) is begin Source := To_Unbounded_Wide_String (Wide_Fixed.Head (Source.Reference.all, Count, Pad)); end Head; ----------- -- Index -- ----------- function Index (Source : Unbounded_Wide_String; Pattern : Wide_String; Going : Strings.Direction := Strings.Forward; Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural is begin return Wide_Search.Index (Source.Reference.all, Pattern, Going, Mapping); end Index; function Index (Source : in Unbounded_Wide_String; Pattern : in Wide_String; Going : in Direction := Forward; Mapping : in Wide_Maps.Wide_Character_Mapping_Function) return Natural is begin return Wide_Search.Index (Source.Reference.all, Pattern, Going, Mapping); end Index; function Index (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set; Test : Strings.Membership := Strings.Inside; Going : Strings.Direction := Strings.Forward) return Natural is begin return Wide_Search.Index (Source.Reference.all, Set, Test, Going); end Index; function Index_Non_Blank (Source : Unbounded_Wide_String; Going : Strings.Direction := Strings.Forward) return Natural is begin return Wide_Search.Index_Non_Blank (Source.Reference.all, Going); end Index_Non_Blank; ---------------- -- Initialize -- ---------------- procedure Initialize (Object : in out Unbounded_Wide_String) is begin Object.Reference := Null_Unbounded_Wide_String.Reference; end Initialize; ------------ -- Insert -- ------------ function Insert (Source : Unbounded_Wide_String; Before : Positive; New_Item : Wide_String) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Insert (Source.Reference.all, Before, New_Item)); end Insert; procedure Insert (Source : in out Unbounded_Wide_String; Before : in Positive; New_Item : in Wide_String) is begin Source := To_Unbounded_Wide_String (Wide_Fixed.Insert (Source.Reference.all, Before, New_Item)); end Insert; ------------ -- Length -- ------------ function Length (Source : Unbounded_Wide_String) return Natural is begin return Source.Reference.all'Length; end Length; --------------- -- Overwrite -- --------------- function Overwrite (Source : Unbounded_Wide_String; Position : Positive; New_Item : Wide_String) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Overwrite (Source.Reference.all, Position, New_Item)); end Overwrite; procedure Overwrite (Source : in out Unbounded_Wide_String; Position : in Positive; New_Item : in Wide_String) is Temp : Wide_String_Access := Source.Reference; begin Source := To_Unbounded_Wide_String (Wide_Fixed.Overwrite (Temp.all, Position, New_Item)); end Overwrite; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Source : in out Unbounded_Wide_String; Index : Positive; By : Wide_Character) is begin if Index <= Source.Reference.all'Last then Source.Reference.all (Index) := By; else raise Strings.Index_Error; end if; end Replace_Element; ------------------- -- Replace_Slice -- ------------------- function Replace_Slice (Source : Unbounded_Wide_String; Low : Positive; High : Natural; By : Wide_String) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Replace_Slice (Source.Reference.all, Low, High, By)); end Replace_Slice; procedure Replace_Slice (Source : in out Unbounded_Wide_String; Low : in Positive; High : in Natural; By : in Wide_String) is Temp : Wide_String_Access := Source.Reference; begin Source := To_Unbounded_Wide_String (Wide_Fixed.Replace_Slice (Temp.all, Low, High, By)); end Replace_Slice; ----------- -- Slice -- ----------- function Slice (Source : Unbounded_Wide_String; Low : Positive; High : Natural) return Wide_String is Length : constant Natural := Source.Reference'Length; begin -- Note: test of High > Length is in accordance with AI95-00128 if Low > Length + 1 or else High > Length then raise Index_Error; else declare Result : Wide_String (1 .. High - Low + 1); begin Result := Source.Reference.all (Low .. High); return Result; end; end if; end Slice; ---------- -- Tail -- ---------- function Tail (Source : Unbounded_Wide_String; Count : Natural; Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Tail (Source.Reference.all, Count, Pad)); end Tail; procedure Tail (Source : in out Unbounded_Wide_String; Count : in Natural; Pad : in Wide_Character := Wide_Space) is Temp : Wide_String_Access := Source.Reference; begin Source := To_Unbounded_Wide_String (Wide_Fixed.Tail (Temp.all, Count, Pad)); end Tail; ------------------------------ -- To_Unbounded_Wide_String -- ------------------------------ function To_Unbounded_Wide_String (Source : Wide_String) return Unbounded_Wide_String is Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Source'Length); Result.Reference.all := Source; return Result; end To_Unbounded_Wide_String; function To_Unbounded_Wide_String (Length : in Natural) return Unbounded_Wide_String is Result : Unbounded_Wide_String; begin Result.Reference := new Wide_String (1 .. Length); return Result; end To_Unbounded_Wide_String; -------------------- -- To_Wide_String -- -------------------- function To_Wide_String (Source : Unbounded_Wide_String) return Wide_String is begin return Source.Reference.all; end To_Wide_String; --------------- -- Translate -- --------------- function Translate (Source : Unbounded_Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Translate (Source.Reference.all, Mapping)); end Translate; procedure Translate (Source : in out Unbounded_Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping) is begin Wide_Fixed.Translate (Source.Reference.all, Mapping); end Translate; function Translate (Source : in Unbounded_Wide_String; Mapping : in Wide_Maps.Wide_Character_Mapping_Function) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Translate (Source.Reference.all, Mapping)); end Translate; procedure Translate (Source : in out Unbounded_Wide_String; Mapping : in Wide_Maps.Wide_Character_Mapping_Function) is begin Wide_Fixed.Translate (Source.Reference.all, Mapping); end Translate; ---------- -- Trim -- ---------- function Trim (Source : in Unbounded_Wide_String; Side : in Trim_End) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Trim (Source.Reference.all, Side)); end Trim; procedure Trim (Source : in out Unbounded_Wide_String; Side : in Trim_End) is Old : Wide_String_Access := Source.Reference; begin Source.Reference := new Wide_String'(Wide_Fixed.Trim (Old.all, Side)); Free (Old); end Trim; function Trim (Source : in Unbounded_Wide_String; Left : in Wide_Maps.Wide_Character_Set; Right : in Wide_Maps.Wide_Character_Set) return Unbounded_Wide_String is begin return To_Unbounded_Wide_String (Wide_Fixed.Trim (Source.Reference.all, Left, Right)); end Trim; procedure Trim (Source : in out Unbounded_Wide_String; Left : in Wide_Maps.Wide_Character_Set; Right : in Wide_Maps.Wide_Character_Set) is Old : Wide_String_Access := Source.Reference; begin Source.Reference := new Wide_String'(Wide_Fixed.Trim (Old.all, Left, Right)); Free (Old); end Trim; end Ada.Strings.Wide_Unbounded;
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------------ -- -- SPARK Proof Analysis Tool -- -- S.P.A.T. - Heuristic stuff. Tries to find optimal prover configuration. -- ------------------------------------------------------------------------------ with SPAT.GPR_Support; with Ada.Containers.Vectors; package SPAT.Spark_Info.Heuristics is type Workloads is record -- The name of the prover. Success_Time : Duration; -- accumulated time of successful attempts Failed_Time : Duration; -- accumulated time of failed attempts Max_Success : Time_And_Steps; -- maximum time/steps for a successful attempt end record; type Prover_Data is record Name : Prover_Name; Workload : Workloads; end record; package Prover_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Prover_Data); type File_Data is record Name : Source_File_Name; Provers : Prover_Vectors.Vector; end record; package File_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => File_Data); --------------------------------------------------------------------------- -- Find_Optimum -- -- This is a highly experimental feature. -- -- Tries to find an "optimal" prover configuration. --------------------------------------------------------------------------- function Find_Optimum (Info : in T; File_Map : in GPR_Support.SPARK_Source_Maps.Map) return File_Vectors.Vector; end SPAT.Spark_Info.Heuristics;
-- -- Copyright (C) 2015-2017 secunet Security Networks AG -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with HW.GFX.GMA.Config; with HW.GFX.GMA.Panel; with HW.GFX.GMA.DP_Info; with HW.Debug; with GNAT.Source_Info; package body HW.GFX.GMA.Connector_Info is procedure Preferred_Link_Setting (Port_Cfg : in out Port_Config; Success : out Boolean) is DP_Port : constant GMA.DP_Port := (if Port_Cfg.Port = DIGI_A then DP_A else (case Port_Cfg.PCH_Port is when PCH_DP_B => DP_B, when PCH_DP_C => DP_C, when PCH_DP_D => DP_D, when others => GMA.DP_Port'First)); begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Port_Cfg.Display = DP then if Port_Cfg.Port = DIGI_A then if GMA.Config.Use_PP_VDD_Override then Panel.VDD_Override; else Panel.On; end if; end if; DP_Info.Read_Caps (Link => Port_Cfg.DP, Port => DP_Port, Success => Success); if Success then DP_Info.Preferred_Link_Setting (Link => Port_Cfg.DP, Mode => Port_Cfg.Mode, Success => Success); pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP)); end if; else Success := True; end if; end Preferred_Link_Setting; procedure Next_Link_Setting (Port_Cfg : in out Port_Config; Success : out Boolean) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Port_Cfg.Display = DP then DP_Info.Next_Link_Setting (Link => Port_Cfg.DP, Mode => Port_Cfg.Mode, Success => Success); pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP)); else Success := False; end if; end Next_Link_Setting; ---------------------------------------------------------------------------- function Default_BPC (Port_Cfg : Port_Config) return HW.GFX.BPC_Type is begin return (if Port_Cfg.Port = DIGI_A or (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS) or Port_Cfg.Port = LVDS then 6 else 8); end Default_BPC; end HW.GFX.GMA.Connector_Info;
with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put('A'); New_Line; return; Put('b'); New_Line; end Hello; -- Local Variables: -- compile-command: "gnatmake return1.adb && ./return1" -- End:
-------------------------------------------------------------------------------- -- -- -- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU Lesser General Public -- -- License as published by the Free Software Foundation; either -- -- version 2.1 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Lesser General Public License for more details. -- -- -- -- You should have received a copy of the GNU Lesser General Public -- -- License along with this library; if not, write to the Free Software -- -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- -------------------------------------------------------------------------------- -- $Author$ -- $Date$ -- $Revision$ with RASCAL.Memory; use RASCAL.Memory; with RASCAL.OS; use RASCAL.OS; with RASCAL.Utility; use RASCAL.Utility; with Kernel; use Kernel; with Interfaces.C; use Interfaces.C; with Reporter; package body RASCAL.Toolbox is Toolbox_CreateObject : constant := 16#044EC0#; Toolbox_DeleteObject : constant := 16#044EC1#; Toolbox_CopyObject : constant := 16#044EC2#; Toolbox_Show_Object : constant := 16#044EC3#; Toolbox_Hide_Object : constant := 16#044EC4#; Toolbox_GetObjectInfo : constant := 16#044EC5#; Toolbox_ObjectMiscOp : constant := 16#044EC6#; Toolbox_SetClientHandle : constant := 16#044EC7#; Toolbox_GetClientHandle : constant := 16#044EC8#; Toolbox_GetObjectClass : constant := 16#044EC9#; Toolbox_GetParent : constant := 16#044ECA#; Toolbox_GetAncestor : constant := 16#044ECB#; Toolbox_GetTemplateName : constant := 16#044ECC#; Toolbox_RaiseToolboxEvent : constant := 16#044ECD#; Toolbox_GetSysInfo : constant := 16#044ECE#; Toolbox_Initialise : constant := 16#044ECF#; Toolbox_Load_Resources : constant := 16#044ED0#; Toolbox_Memory : constant := 16#044EF9#; Toolbox_DeRegisterObjectModule : constant := 16#044EFA#; Toolbox_Template_LookUp : constant := 16#044EFB#; Toolbox_GetInternalHandle : constant := 16#044EFC#; Toolbox_RegisterPostFilter : constant := 16#044EFD#; Toolbox_RegisterPreFilter : constant := 16#044EFE#; Toolbox_RegisterObjectModule : constant := 16#044EFF#; -- function Create_Object (Template : in string; Flags : in Creation_Type := From_Template) return Object_ID is Register : aliased Kernel.swi_regs; Error : oserror_access; Template_0 : string := Template & ASCII.NUL; begin Register.R(0) := Creation_Type'Pos(Flags); Register.R(1) := Adr_To_Int(Template_0'Address); Error := Kernel.swi(Toolbox_CreateObject,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Create_Object: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; return Object_ID(Register.R(0)); end Create_Object; -- procedure Delete_Object (Object : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_DeleteObject,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Delete_Object: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Delete_Object; -- procedure Get_Ancestor (Object : in Object_ID; Ancestor : out Object_ID; Component: out Component_ID; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_GetAncestor,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Get_Ancestor: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; Ancestor := Object_ID(Register.R(0)); Component := Component_ID(Register.R(1)); end Get_Ancestor; -- function Get_Client (Object : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) return Object_ID is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_GetClientHandle,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Get_Client: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; return Object_ID(Register.R(0)); end Get_Client; -- function Get_Class (Object : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) return Object_Class is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_GetObjectClass,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Get_Class: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; return Object_Class(Register.R(0)); end Get_Class; -- function Get_State (Object : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) return Object_State is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_GetObjectInfo,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Get_State: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; return Object_State'Val(integer(Register.R(0))); end Get_State; -- procedure Get_Parent (Object : in Object_ID; Parent : out Object_ID; Component: out Component_ID; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_GetParent,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Get_Parent: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; Parent := Object_ID(Register.R(0)); Component := Component_ID(Register.R(1)); end Get_Parent; -- function Get_Template_Name (Object : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) return string is Register : aliased Kernel.swi_regs; Error : oserror_access; Buffer_Size : integer; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Register.R(2) := 0; Register.R(3) := 0; Error := Kernel.swi(Toolbox_GetTemplateName,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Get_Template_Name: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; Buffer_Size := integer(Register.R(3)); declare Buffer : string(1..Buffer_Size); begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Register.R(2) := Adr_To_Int(Buffer'Address); Register.R(3) := int(Buffer_Size); Error := Kernel.swi(Toolbox_GetTemplateName,Register'Access,Register'Access); if Error /=null then return ""; else return MemoryToString(Buffer'Address,0,integer(Register.R(3))-1); end if; end; end Get_Template_Name; -- procedure Hide_Object (Object : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Error := Kernel.swi(Toolbox_Hide_Object,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Hide_Object: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Hide_Object; -- procedure Load_Resources (Filename : in string; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; Filename_0 : string := Filename & ASCII.NUL; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := Adr_To_Int(Filename_0'Address); Error := Kernel.swi(Toolbox_Load_Resources,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Load_Reaources: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Load_Resources; -- procedure Set_Client_Handle (Object : in Object_ID; Client : in Object_ID; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; Toolbox_Client_Handle: constant Interfaces.C.unsigned :=16#44EC7#; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Register.R(2) := int(Object); Error := Kernel.swi(Toolbox_Client_Handle,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Set_Client_Handle: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Set_Client_Handle; -- procedure Show_Object_At (Object : in Object_ID; X : integer; Y : integer; Parent_Object : in Object_ID; Parent_Component : in Component_ID; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; BBox : Toolbox_BBox_Type; begin BBox.XMin := x; BBox.YMin := y; Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Register.R(2) := 2; Register.R(3) := Adr_To_Int(BBox'Address); Register.R(4) := int(Parent_Object); Register.R(5) := int(Parent_Component); Error := Kernel.swi(Toolbox_Show_Object,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Show_Object_At: " & To_Ada(Error.errmess))); OS.Raise_Error(Error); end if; end Show_Object_At; -- procedure Show_Object (Object : in Object_ID; Parent_Object : in Object_ID := 0; Parent_Component : in Component_ID := 0; Show : in Object_ShowType := Default; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Object); Register.R(2) := int(Object_ShowType'Pos(Show)); Register.R(3) := 0; Register.R(4) := int(Parent_Object); Register.R(5) := int(Parent_Component); Error := Kernel.swi(Toolbox_Show_Object,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Show_Object: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Show_Object; -- function Template_Lookup(Template_Name : in string; Flags : in System.Unsigned_Types.Unsigned := 0) return Address is Register : aliased Kernel.swi_regs; Error : oserror_access; Template_0 : string := Template_Name & ASCII.NUL; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := Adr_To_Int(Template_0'Address); Error := Kernel.swi(Toolbox_Template_Lookup,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Template_Lookup: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; return Int_To_adr(Register.R(0)); end Template_Lookup; -- procedure Raise_Event (Object : in Object_ID; Component : in Component_ID; Event : in Address; Flags : in System.Unsigned_Types.Unsigned := 0) is Toolbox_RaiseToolboxEvent : constant Interfaces.C.unsigned :=16#44ecd#; Register : aliased Kernel.swi_regs; Error : oserror_access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Integer(Object)); Register.R(2) := int(Integer(Component)); Register.R(3) := Adr_To_Int(Event); Error := Kernel.swi(Toolbox_RaiseToolboxEvent,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Toolbox.Raise_Event: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Raise_Event; -- end RASCAL.Toolbox;
with agar.gui.widget.button; with agar.gui.widget.textbox; with agar.gui.widget.tlist; with agar.gui.window; package agar.gui.widget.combo is use type c.unsigned; type flags_t is new c.unsigned; COMBO_POLL : constant flags_t := 16#01#; COMBO_TREE : constant flags_t := 16#02#; COMBO_ANY_TEXT : constant flags_t := 16#04#; COMBO_HFILL : constant flags_t := 16#08#; COMBO_VFILL : constant flags_t := 16#10#; COMBO_EXPAND : constant flags_t := COMBO_HFILL or COMBO_VFILL; type combo_t is limited private; type combo_access_t is access all combo_t; pragma convention (c, combo_access_t); -- API function allocate (parent : widget_access_t; flags : flags_t; label : string) return combo_access_t; pragma inline (allocate); procedure size_hint (combo : combo_access_t; text : string; items : integer); pragma inline (size_hint); procedure size_hint_pixels (combo : combo_access_t; width : positive; height : positive); pragma inline (size_hint_pixels); procedure select_item (combo : combo_access_t; item : agar.gui.widget.tlist.tlist_access_t); pragma import (c, select_item, "AG_ComboSelect"); procedure select_pointer (combo : combo_access_t; ptr : agar.core.types.void_ptr_t); pragma import (c, select_pointer, "AG_ComboSelectPointer"); procedure select_text (combo : combo_access_t; text : string); pragma inline (select_text); private type combo_t is record widget : widget_t; flags : flags_t; textbox : agar.gui.widget.textbox.textbox_access_t; button : agar.gui.widget.button.button_access_t; list : agar.gui.widget.tlist.tlist_access_t; panel : agar.gui.window.window_access_t; width_saved : c.int; height_saved : c.int; width_pre : c.int; height_pre : c.int; end record; pragma convention (c, combo_t); end agar.gui.widget.combo;
with Gnat.Heap_Sort_G; procedure Integer_Sort is -- Heap sort package requires data to be in index values starting at -- 1 while index value 0 is used as temporary storage type Int_Array is array(Natural range <>) of Integer; Values : Int_Array := (0,1,8,2,7,3,6,4,5); -- define move and less than subprograms for use by the heap sort package procedure Move_Int(From : Natural; To : Natural) is begin Values(To) := Values(From); end Move_Int; function Lt_Int(Left, Right : Natural) return Boolean is begin return Values(Left) < Values (Right); end Lt_Int; -- Instantiate the generic heap sort package package Heap_Sort is new Gnat.Heap_Sort_G(Move_Int, Lt_Int); begin Heap_Sort.Sort(8); end Integer_Sort; requires an Ada05 compiler, e.g GNAT GPL 2007 with Ada.Containers.Generic_Array_Sort; procedure Integer_Sort is -- type Int_Array is array(Natural range <>) of Integer; Values : Int_Array := (0,1,8,2,7,3,6,4,5); -- Instantiate the generic sort package from the standard Ada library procedure Sort is new Ada.Containers.Generic_Array_Sort (Index_Type => Natural, Element_Type => Integer, Array_Type => Int_Array); begin Sort(Values); end Integer_Sort;
----------------------------------------------------------------------- -- gen-model-packages -- Packages holding model, query representation -- Copyright (C) 2009 - 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers.Hashed_Maps; with Ada.Strings.Unbounded.Hash; with Util.Beans.Objects; with Util.Beans.Objects.Vectors; with Util.Strings.Sets; with Gen.Model.List; with Gen.Model.Mappings; limited with Gen.Model.Enums; limited with Gen.Model.Tables; limited with Gen.Model.Queries; limited with Gen.Model.Beans; limited with Gen.Model.Stypes; package Gen.Model.Packages is -- ------------------------------ -- Model Definition -- ------------------------------ -- The <b>Model_Definition</b> contains the complete model from one or -- several files. It maintains a list of Ada packages that must be generated. type Model_Definition is new Definition with private; type Model_Definition_Access is access all Model_Definition'Class; -- Validate the definition by checking and reporting problems to the logger interface. overriding procedure Validate (Def : in out Model_Definition; Log : in out Util.Log.Logging'Class); -- ------------------------------ -- Package Definition -- ------------------------------ -- The <b>Package_Definition</b> holds the tables, queries and other information -- that must be generated for a given Ada package. type Package_Definition is new Definition with private; type Package_Definition_Access is access all Package_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 Package_Definition; Name : in String) return UBO.Object; -- Prepare the generation of the package: -- o identify the column types which are used -- o build a list of package for the with clauses. overriding procedure Prepare (O : in out Package_Definition); -- Validate the definition by checking and reporting problems to the logger interface. overriding procedure Validate (Def : in out Package_Definition; Log : in out Util.Log.Logging'Class); -- Initialize the package instance overriding procedure Initialize (O : in out Package_Definition); -- Find the type identified by the name. function Find_Type (From : in Package_Definition; Name : in UString) return Gen.Model.Mappings.Mapping_Definition_Access; -- Get the model which contains all the package definitions. function Get_Model (From : in Package_Definition) return Model_Definition_Access; -- Returns True if the package is a pre-defined package and must not be generated. function Is_Predefined (From : in Package_Definition) return Boolean; -- Set the package as a pre-defined package. procedure Set_Predefined (From : in out Package_Definition); -- 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 : Model_Definition; Name : String) return UBO.Object; -- Initialize the model definition instance. overriding procedure Initialize (O : in out Model_Definition); -- Returns True if the model contains at least one package. function Has_Packages (O : in Model_Definition) return Boolean; -- Register or find the package knowing its name procedure Register_Package (O : in out Model_Definition; Name : in UString; Result : out Package_Definition_Access); -- Register the declaration of the given enum in the model. procedure Register_Enum (O : in out Model_Definition; Enum : access Gen.Model.Enums.Enum_Definition'Class); -- Register the declaration of the given data type in the model. procedure Register_Stype (O : in out Model_Definition; Stype : access Gen.Model.Stypes.Stype_Definition'Class); -- Register the declaration of the given table in the model. procedure Register_Table (O : in out Model_Definition; Table : access Gen.Model.Tables.Table_Definition'Class); -- Register the declaration of the given query in the model. procedure Register_Query (O : in out Model_Definition; Table : access Gen.Model.Queries.Query_File_Definition'Class); -- Register the declaration of the given bean in the model. procedure Register_Bean (O : in out Model_Definition; Bean : access Gen.Model.Beans.Bean_Definition'Class); -- Register a type mapping. The <b>From</b> type describes a type in the XML -- configuration files (hibernate, query, ...) and the <b>To</b> represents the -- corresponding Ada type. procedure Register_Type (O : in out Model_Definition; From : in String; To : in String); -- Find the type identified by the name. function Find_Type (From : in Model_Definition; Name : in UString) return Gen.Model.Mappings.Mapping_Definition_Access; -- Set the directory name associated with the model. This directory name allows to -- save and build a model in separate directories for the application, the unit tests -- and others. procedure Set_Dirname (O : in out Model_Definition; Target_Dir : in String; Model_Dir : in String); -- Get the directory name associated with the model. function Get_Dirname (O : in Model_Definition) return String; -- Get the directory name which contains the model. function Get_Model_Directory (O : in Model_Definition) return String; -- Enable the generation of the Ada package given by the name. By default all the Ada -- packages found in the model are generated. When called, this enables the generation -- only for the Ada packages registered here. procedure Enable_Package_Generation (Model : in out Model_Definition; Name : in String); -- Returns True if the generation is enabled for the given package name. function Is_Generation_Enabled (Model : in Model_Definition; Name : in String) return Boolean; -- Iterate over the model tables. procedure Iterate_Tables (Model : in Model_Definition; Process : not null access procedure (Item : in out Tables.Table_Definition)); -- Iterate over the model enums. procedure Iterate_Enums (Model : in Model_Definition; Process : not null access procedure (Item : in out Enums.Enum_Definition)); -- Prepare the generation of the package: -- o identify the column types which are used -- o build a list of package for the with clauses. overriding procedure Prepare (O : in out Model_Definition); package Package_Map is new Ada.Containers.Hashed_Maps (Key_Type => UString, Element_Type => Package_Definition_Access, Hash => Ada.Strings.Unbounded.Hash, Equivalent_Keys => "="); subtype Package_Cursor is Package_Map.Cursor; -- Get the first package of the model definition. function First (From : Model_Definition) return Package_Cursor; -- Returns true if the package cursor contains a valid package function Has_Element (Position : Package_Cursor) return Boolean renames Package_Map.Has_Element; -- Returns the package definition. function Element (Position : Package_Cursor) return Package_Definition_Access renames Package_Map.Element; -- Move the iterator to the next package definition. procedure Next (Position : in out Package_Cursor) renames Package_Map.Next; private package Table_List is new Gen.Model.List (T => Definition, T_Access => Definition_Access); -- Returns False if the <tt>Left</tt> table does not depend on <tt>Right</tt>. -- Returns True if the <tt>Left</tt> table depends on the <tt>Right</tt> table. function Dependency_Compare (Left, Right : in Definition_Access) return Boolean; -- Sort the tables on their dependency. procedure Dependency_Sort is new Table_List.Sort_On ("<" => Dependency_Compare); subtype Table_List_Definition is Table_List.List_Definition; subtype Enum_List_Definition is Table_List.List_Definition; subtype Types_List_Definition is Table_List.List_Definition; subtype Stype_List_Definition is Table_List.List_Definition; type List_Object is new Util.Beans.Basic.List_Bean with record Values : UBO.Vectors.Vector; Row : Natural; Value_Bean : UBO.Object; end record; -- Get the number of elements in the list. overriding function Get_Count (From : in List_Object) return Natural; -- Set the current row index. Valid row indexes start at 1. overriding procedure Set_Row_Index (From : in out List_Object; Index : in Natural); -- Get the element at the current row index. overriding function Get_Row (From : in List_Object) return UBO.Object; -- 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 List_Object; Name : in String) return UBO.Object; type Package_Definition is new Definition with record -- Enums defined in the package. Enums : aliased Enum_List_Definition; Enums_Bean : UBO.Object; -- Simple data types defined in the package. Stypes : aliased Stype_List_Definition; Stypes_Bean : UBO.Object; -- Hibernate tables Tables : aliased Table_List_Definition; Tables_Bean : UBO.Object; -- Custom queries Queries : aliased Table_List_Definition; Queries_Bean : UBO.Object; -- Ada Beans Beans : aliased Table_List_Definition; Beans_Bean : UBO.Object; -- A list of external packages which are used (used for with clause generation). Used_Spec_Types : aliased List_Object; Used_Spec : UBO.Object; -- A list of external packages which are used (used for with clause generation). Used_Body_Types : aliased List_Object; Used_Body : UBO.Object; -- A map of all types defined in this package. Types : Gen.Model.Mappings.Mapping_Maps.Map; -- The base name for the package (ex: gen-model-users) Base_Name : UString; -- The global model (used to resolve types from other packages). Model : Model_Definition_Access; -- True if the package uses Ada.Calendar.Time Uses_Calendar_Time : Boolean := False; -- True if the package is a pre-defined package (ie, defined by a UML profile). Is_Predefined : Boolean := False; end record; type Model_Definition is new Definition with record -- List of all enums. Enums : aliased Enum_List_Definition; Enums_Bean : UBO.Object; -- Simple data types defined in the package. Stypes : aliased Stype_List_Definition; Stypes_Bean : UBO.Object; -- List of all tables. Tables : aliased Table_List_Definition; Tables_Bean : UBO.Object; -- List of all queries. Queries : aliased Table_List_Definition; Queries_Bean : UBO.Object; -- Ada Beans Beans : aliased Table_List_Definition; Beans_Bean : UBO.Object; -- Map of all packages. Packages : Package_Map.Map; -- Directory associated with the model ('src', 'samples', 'regtests', ...). Dir_Name : UString; -- Directory that contains the SQL and model files. DB_Name : UString; -- When not empty, a list of packages that must be taken into account for the generation. -- By default all packages and tables defined in the model are generated. Gen_Packages : Util.Strings.Sets.Set; end record; end Gen.Model.Packages;
-------------------------------------------------------------------------------- -- Copyright (c) 2013, Felix Krause <contact@flyx.org> -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- with CL.Memory.CL_GL; with CL.Enumerations.CL_GL; with GL.Low_Level.Enums; with GL.Objects.Textures; with GL.Types; package CL.API.CL_GL is function Create_From_GL_Buffer (Context : System.Address; Flags : Bitfield; GL_Object : IFC.unsigned; Error : Enumerations.Error_Ptr) return System.Address; pragma Import (Convention => StdCall, Entity => Create_From_GL_Buffer, External_Name => "clCreateFromGLBuffer"); function Create_From_GL_Texture_2D (Context : System.Address; Flags : Bitfield; Image_Type : GL.Low_Level.Enums.Texture_Kind; Mip_Level : GL.Objects.Textures.Mipmap_Level; Source : GL.Types.UInt; Error : Enumerations.Error_Ptr) return System.Address; pragma Import (Convention => StdCall, Entity => Create_From_GL_Texture_2D, External_Name => "clCreateFromGLTexture2D"); function Create_From_GL_Texture_3D (Context : System.Address; Flags : Bitfield; Image_Type : GL.Low_Level.Enums.Texture_Kind; Mip_Level : GL.Objects.Textures.Mipmap_Level; Source : GL.Types.UInt; Error : Enumerations.Error_Ptr) return System.Address; pragma Import (Convention => StdCall, Entity => Create_From_GL_Texture_3D, External_Name => "clCreateFromGLTexture3D"); function Create_From_GL_Renderbuffer (Context : System.Address; Flags : Bitfield; Renderbuffer : GL.Low_Level.Enums.Renderbuffer_Kind; Error : Enumerations.Error_Ptr) return System.Address; pragma Import (Convention => StdCall, Entity => Create_From_GL_Renderbuffer, External_Name => "clCreateFromGLRenderbuffer"); function Get_GL_Object_Info (Mem_Object : System.Address; Object_Type : access CL.Memory.CL_GL.Object_Kind; Object_Name : access GL.Types.UInt) return Enumerations.Error_Code; pragma Import (Convention => StdCall, Entity => Get_GL_Object_Info, External_Name => "clGetGLObjectInfo"); function Get_GL_Texture_Info (Mem_Object : System.Address; Param_Name : Enumerations.CL_GL.GL_Texture_Info; Num_Entries : Size; Value : System.Address; Return_Size : Size_Ptr) return Enumerations.Error_Code; pragma Import (Convention => StdCall, Entity => Get_GL_Texture_Info, External_Name => "clGetGLTextureInfo"); function Enqueue_Acquire_GL_Objects (Command_Queue : System.Address; Num_Objects : UInt; Object_List : Address_Ptr; Num_Events : UInt; Event_List : Address_Ptr; Event : Address_Ptr) return Enumerations.Error_Code; pragma Import (Convention => StdCall, Entity => Enqueue_Acquire_GL_Objects, External_Name => "clEnqueueAcquireGLObjects"); function Enqueue_Release_GL_Objects (Command_Queue : System.Address; Num_Objects : UInt; Object_List : Address_Ptr; Num_Events : UInt; Event_List : Address_Ptr; Event : Address_Ptr) return Enumerations.Error_Code; pragma Import (Convention => StdCall, Entity => Enqueue_Release_GL_Objects, External_Name => "clEnqueueReleaseGLObjects"); end CL.API.CL_GL;
-- Copyright 2017 Steven Stewart-Gallus -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied. See the License for the specific language governing -- permissions and limitations under the License. generic type Element_T is mod <>; package Linted.Mod_Atomics is pragma Pure; protected type Atomic with Lock_Free is private procedure Set (New_Ptr : Element_T) with Global => null, Depends => (Atomic => New_Ptr, null => Atomic); function Get return Element_T with Global => null, Depends => (Get'Result => Atomic); procedure Compare_And_Swap (Old_Ptr : Element_T; New_Ptr : Element_T; Success : in out Boolean) with Global => null, Depends => (Success => (Old_Ptr, Atomic), Atomic =>+ (Old_Ptr, New_Ptr), null => Success); procedure Swap (Old_Ptr : in out Element_T; New_Ptr : Element_T) with Global => null, Depends => (Old_Ptr => Atomic, Atomic =>+ New_Ptr, null => Old_Ptr); procedure Saturating_Increment with Global => null, Depends => (Atomic =>+ null); procedure Saturating_Decrement with Global => null, Depends => (Atomic =>+ null); Ptr : Element_T; end Atomic; procedure Set (A : in out Atomic; Element : Element_T) with Global => null, Depends => (A =>+ Element); procedure Get (A : in out Atomic; Element : out Element_T) with Global => null, Depends => (Element => A, A => A); procedure Compare_And_Swap (A : in out Atomic; Old_Element : Element_T; New_Element : Element_T; Success : out Boolean) with Global => null, Depends => (Success => (A, Old_Element), A =>+ (Old_Element, New_Element)); procedure Swap (A : in out Atomic; Old_Element : out Element_T; New_Element : Element_T) with Global => null, Depends => (Old_Element => A, A =>+ New_Element); procedure Saturating_Increment (A : in out Atomic) with Global => null, Depends => (A => A); procedure Saturating_Decrement (A : in out Atomic) with Global => null, Depends => (A => A); end Linted.Mod_Atomics;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This program demonstrates using one timer to generate several periodic -- interrupts, each with a different period. Each interrupt is tied to a -- separate LED such that the LED blinks at the corresponding rate. -- This file declares the main procedure for the demonstration. -- We use the STM F4 Discovery board for the sake of the four LEDs but another -- board could be used, with different LED configurations. Using a board -- with fewer LEDs is possible but less interesting. In that case, change the -- number of channels driven (and interrupts generated) to match the number of -- LEDs available. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with STM32.Board; use STM32.Board; with STM32.Device; use STM32.Device; with STM32.Timers; use STM32.Timers; with STM32F4_Timer_Interrupts; use STM32F4_Timer_Interrupts; with HAL; use HAL; procedure Demo is begin Initialize_LEDs; -- set up the timer base Enable_Clock (Timer_3); Reset (Timer_3); Configure (Timer_3, Prescaler => Prescaler, Period => UInt32 (UInt16'Last), -- all the way up Clock_Divisor => Div1, Counter_Mode => Up); Configure_Prescaler (Timer_3, Prescaler => Prescaler, Reload_Mode => Immediate); -- configure the channel outputs for Next_Channel in Timer_Channel loop Configure_Channel_Output (Timer_3, Channel => Next_Channel, Mode => Frozen, State => Enable, Pulse => Channel_Periods (Next_Channel), Polarity => High); Set_Output_Preload_Enable (Timer_3, Next_Channel, False); end loop; -- enable the timer's four channel interrupts and go Enable_Interrupt (Timer_3, Timer_CC1_Interrupt & Timer_CC2_Interrupt & Timer_CC3_Interrupt & Timer_CC4_Interrupt); Enable (Timer_3); loop null; end loop; end Demo;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Element_Vectors; with Program.Lexical_Elements; generic type Vector_Interface is limited interface and Program.Element_Vectors.Element_Vector; package Program.Nodes.Generic_Vectors is pragma Preelaborate; type Vector; function Create (Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class) return Vector; type Vector (<>) is new Vector_Interface with private; overriding function Get_Length (Self : Vector) return Positive; overriding function Element (Self : Vector; Index : Positive) return not null Program.Elements.Element_Access; overriding function Delimiter (Self : Vector; Index : Positive) return Program.Lexical_Elements.Lexical_Element_Access; private type Element_Array is array (Positive range <>) of Program.Elements.Element_Access; type Lexical_Element_Array is array (Positive range <>) of Program.Lexical_Elements.Lexical_Element_Access; type Vector (Elements, Tokens : Natural) is new Vector_Interface with record Element_List : Element_Array (1 .. Elements); Token_List : Lexical_Element_Array (1 .. Tokens); end record; end Program.Nodes.Generic_Vectors;
with System; use System; package Qsort is type vector is array (Integer range <>) of Integer; type vector_ptr is access vector; task type SortTask is entry PortIn(ValIn : in vector_ptr); entry PortOut(ValOut : out vector); end SortTask; type Sort_access is access SortTask; procedure Sort (List : in out vector_ptr); end Qsort;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . T H R E A D S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides facilities to register a thread to the runtime, -- and allocate its task specific datas. -- This package is currently implemented for: -- VxWorks AE653 rts-cert -- VxWorks AE653 rts-full (not rts-kernel) with Ada.Exceptions; -- used for Exception_Occurrence with System.Soft_Links; -- used for TSD with Unchecked_Conversion; package System.Threads is type ATSD is limited private; -- Type of the Ada thread specific data. It contains datas needed -- by the GNAT runtime. type ATSD_Access is access ATSD; function From_Address is new Unchecked_Conversion (Address, ATSD_Access); -------------------------- -- Thread Body Handling -- -------------------------- -- The subprograms in this section are called from the process body -- wrapper in the APEX process registration package. procedure Thread_Body_Enter (Sec_Stack_Address : System.Address; Sec_Stack_Size : Natural; Process_ATSD_Address : System.Address); -- Enter thread body, see above for details procedure Thread_Body_Leave; -- Leave thread body (normally), see above for details procedure Thread_Body_Exceptional_Exit (EO : Ada.Exceptions.Exception_Occurrence); -- Leave thread body (abnormally on exception), see above for details private type ATSD is new System.Soft_Links.TSD; end System.Threads;
pragma License (Unrestricted); -- extended unit with Ada.Strings.Wide_Wide_Functions.Maps; package Ada.Strings.Unbounded_Wide_Wide_Strings.Functions.Maps is new Generic_Maps (Wide_Wide_Functions.Maps); pragma Preelaborate (Ada.Strings.Unbounded_Wide_Wide_Strings.Functions.Maps);
-- Copyright 2016-2021 Bartek thindil Jasicki -- -- This file is part of Steam Sky. -- -- Steam Sky is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- Steam Sky is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with Steam Sky. If not, see <http://www.gnu.org/licenses/>. with Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; with Game; use Game; package body Config is procedure Load_Config is Config_File: File_Type; Raw_Data, Field_Name, Value: Unbounded_String := Null_Unbounded_String; Equal_Index: Natural := 0; function Load_Boolean return Boolean is begin if Value = To_Unbounded_String(Source => "Yes") then return True; end if; return False; end Load_Boolean; begin New_Game_Settings := Default_New_Game_Settings; Game_Settings := Default_Game_Settings; Open (File => Config_File, Mode => In_File, Name => To_String(Source => Save_Directory) & "game.cfg"); Read_Config_File_Loop : while not End_Of_File(File => Config_File) loop Raw_Data := To_Unbounded_String(Source => Get_Line(File => Config_File)); if Length(Source => Raw_Data) = 0 then goto End_Of_Loop; end if; Equal_Index := Index(Source => Raw_Data, Pattern => "="); Field_Name := Head(Source => Raw_Data, Count => Equal_Index - 2); Value := Tail (Source => Raw_Data, Count => Length(Source => Raw_Data) - Equal_Index - 1); if Field_Name = To_Unbounded_String(Source => "PlayerName") then New_Game_Settings.Player_Name := Value; elsif Field_Name = To_Unbounded_String(Source => "PlayerGender") then New_Game_Settings.Player_Gender := Element(Source => Value, Index => 1); elsif Field_Name = To_Unbounded_String(Source => "ShipName") then New_Game_Settings.Ship_Name := Value; elsif Field_Name = To_Unbounded_String(Source => "PlayerFaction") then New_Game_Settings.Player_Faction := Value; elsif Field_Name = To_Unbounded_String(Source => "PlayerCareer") then New_Game_Settings.Player_Career := Value; elsif Field_Name = To_Unbounded_String(Source => "StartingBase") then New_Game_Settings.Starting_Base := Value; elsif Field_Name = To_Unbounded_String(Source => "EnemyDamageBonus") then New_Game_Settings.Enemy_Damage_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "PlayerDamageBonus") then New_Game_Settings.Player_Damage_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "EnemyMeleeDamageBonus") then New_Game_Settings.Enemy_Melee_Damage_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "PlayerMeleeDamageBonus") then New_Game_Settings.Player_Melee_Damage_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "ExperienceBonus") then New_Game_Settings.Experience_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "ReputationBonus") then New_Game_Settings.Reputation_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "UpgradeCostBonus") then New_Game_Settings.Upgrade_Cost_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "PricesBonus") then New_Game_Settings.Prices_Bonus := Bonus_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "DifficultyLevel") then if To_String(Source => Value) in "VERY_EASY" | "EASY" | "NORMAL" | "HARD" | "VERY_HARD" | "CUSTOM" then New_Game_Settings.Difficulty_Level := Difficulty_Type'Value(To_String(Source => Value)); else New_Game_Settings.Difficulty_Level := Default_Difficulty_Type; end if; elsif Field_Name = To_Unbounded_String(Source => "AutoRest") then Game_Settings.Auto_Rest := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "UndockSpeed") then Game_Settings.Undock_Speed := Ship_Speed'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "AutoCenter") then Game_Settings.Auto_Center := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "AutoReturn") then Game_Settings.Auto_Return := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "AutoFinish") then Game_Settings.Auto_Finish := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "LowFuel") then Game_Settings.Low_Fuel := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "LowDrinks") then Game_Settings.Low_Drinks := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "LowFood") then Game_Settings.Low_Food := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "AutoMoveStop") then Game_Settings.Auto_Move_Stop := Auto_Move_Break'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "WindowWidth") then Game_Settings.Window_Width := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "WindowHeight") then Game_Settings.Window_Height := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "MessagesLimit") then Game_Settings.Messages_Limit := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "SavedMessages") then Game_Settings.Saved_Messages := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "HelpFontSize") then Game_Settings.Help_Font_Size := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "MapFontSize") then Game_Settings.Map_Font_Size := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "InterfaceFontSize") then Game_Settings.Interface_Font_Size := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "InterfaceTheme") then Game_Settings.Interface_Theme := Value; elsif Field_Name = To_Unbounded_String(Source => "MessagesOrder") then Game_Settings.Messages_Order := Messages_Order_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "AutoAskForBases") then Game_Settings.Auto_Ask_For_Bases := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "AutoAskForEvents") then Game_Settings.Auto_Ask_For_Events := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "ShowTooltips") then Game_Settings.Show_Tooltips := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "ShowLastMessages") then Game_Settings.Show_Last_Messages := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "MessagesPosition") then Game_Settings.Messages_Position := Natural'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "FullScreen") then Game_Settings.Full_Screen := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "AutoCloseMessagesTime") then Game_Settings.Auto_Close_Messages_Time := Positive'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "AutoSave") then Game_Settings.Auto_Save := Auto_Save_Type'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "TopicsPosition") then Game_Settings.Topics_Position := Natural'Value(To_String(Source => Value)); elsif Field_Name = To_Unbounded_String(Source => "ShowNumbers") then Game_Settings.Show_Numbers := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "RightButton") then Game_Settings.Right_Button := Load_Boolean; elsif Field_Name = To_Unbounded_String(Source => "ListsLimit") then Game_Settings.Lists_Limit := Positive'Value(To_String(Source => Value)); end if; <<End_Of_Loop>> end loop Read_Config_File_Loop; Close(File => Config_File); exception when Ada.Directories.Name_Error => null; end Load_Config; procedure Save_Config is Config_File: File_Type; procedure Save_Boolean(Value: Boolean; Name: String) is begin if Value then Put_Line(File => Config_File, Item => Name & " = Yes"); else Put_Line(File => Config_File, Item => Name & " = No"); end if; end Save_Boolean; begin Create (File => Config_File, Mode => Append_File, Name => To_String(Source => Save_Directory) & "game.cfg"); Put_Line (File => Config_File, Item => "PlayerName = " & To_String(Source => New_Game_Settings.Player_Name)); Put_Line (File => Config_File, Item => "PlayerGender = " & New_Game_Settings.Player_Gender); Put_Line (File => Config_File, Item => "ShipName = " & To_String(Source => New_Game_Settings.Ship_Name)); Put_Line (File => Config_File, Item => "PlayerFaction = " & To_String(Source => New_Game_Settings.Player_Faction)); Put_Line (File => Config_File, Item => "PlayerCareer = " & To_String(Source => New_Game_Settings.Player_Career)); Put_Line (File => Config_File, Item => "StartingBase = " & To_String(Source => New_Game_Settings.Starting_Base)); Put_Line (File => Config_File, Item => "EnemyDamageBonus =" & Bonus_Type'Image(New_Game_Settings.Enemy_Damage_Bonus)); Put_Line (File => Config_File, Item => "PlayerDamageBonus =" & Bonus_Type'Image(New_Game_Settings.Player_Damage_Bonus)); Put_Line (File => Config_File, Item => "EnemyMeleeDamageBonus =" & Bonus_Type'Image(New_Game_Settings.Enemy_Melee_Damage_Bonus)); Put_Line (File => Config_File, Item => "PlayerMeleeDamageBonus =" & Bonus_Type'Image(New_Game_Settings.Player_Melee_Damage_Bonus)); Put_Line (File => Config_File, Item => "ExperienceBonus =" & Bonus_Type'Image(New_Game_Settings.Experience_Bonus)); Put_Line (File => Config_File, Item => "ReputationBonus =" & Bonus_Type'Image(New_Game_Settings.Reputation_Bonus)); Put_Line (File => Config_File, Item => "UpgradeCostBonus =" & Bonus_Type'Image(New_Game_Settings.Upgrade_Cost_Bonus)); Put_Line (File => Config_File, Item => "PricesBonus =" & Bonus_Type'Image(New_Game_Settings.Prices_Bonus)); Put_Line (File => Config_File, Item => "DifficultyLevel = " & Difficulty_Type'Image(New_Game_Settings.Difficulty_Level)); Save_Boolean(Value => Game_Settings.Auto_Rest, Name => "AutoRest"); Put_Line (File => Config_File, Item => "UndockSpeed = " & Ship_Speed'Image(Game_Settings.Undock_Speed)); Save_Boolean(Value => Game_Settings.Auto_Center, Name => "AutoCenter"); Save_Boolean(Value => Game_Settings.Auto_Return, Name => "AutoReturn"); Save_Boolean(Value => Game_Settings.Auto_Finish, Name => "AutoFinish"); Put_Line (File => Config_File, Item => "LowFuel =" & Positive'Image(Game_Settings.Low_Fuel)); Put_Line (File => Config_File, Item => "LowDrinks =" & Positive'Image(Game_Settings.Low_Drinks)); Put_Line (File => Config_File, Item => "LowFood =" & Positive'Image(Game_Settings.Low_Food)); Put_Line (File => Config_File, Item => "AutoMoveStop = " & Auto_Move_Break'Image(Game_Settings.Auto_Move_Stop)); Put_Line (File => Config_File, Item => "WindowWidth =" & Positive'Image(Game_Settings.Window_Width)); Put_Line (File => Config_File, Item => "WindowHeight =" & Positive'Image(Game_Settings.Window_Height)); Put_Line (File => Config_File, Item => "MessagesLimit =" & Positive'Image(Game_Settings.Messages_Limit)); Put_Line (File => Config_File, Item => "SavedMessages =" & Positive'Image(Game_Settings.Saved_Messages)); Put_Line (File => Config_File, Item => "HelpFontSize =" & Positive'Image(Game_Settings.Help_Font_Size)); Put_Line (File => Config_File, Item => "MapFontSize =" & Positive'Image(Game_Settings.Map_Font_Size)); Put_Line (File => Config_File, Item => "InterfaceFontSize =" & Positive'Image(Game_Settings.Interface_Font_Size)); Put_Line (File => Config_File, Item => "InterfaceTheme = " & To_String(Source => Game_Settings.Interface_Theme)); Put_Line (File => Config_File, Item => "MessagesOrder = " & Messages_Order_Type'Image(Game_Settings.Messages_Order)); Save_Boolean (Value => Game_Settings.Auto_Ask_For_Bases, Name => "AutoAskForBases"); Save_Boolean (Value => Game_Settings.Auto_Ask_For_Events, Name => "AutoAskForEvents"); Save_Boolean (Value => Game_Settings.Show_Tooltips, Name => "ShowTooltips"); Save_Boolean (Value => Game_Settings.Show_Last_Messages, Name => "ShowLastMessages"); Put_Line (File => Config_File, Item => "MessagesPosition =" & Natural'Image(Game_Settings.Messages_Position)); Save_Boolean(Value => Game_Settings.Full_Screen, Name => "FullScreen"); Put_Line (File => Config_File, Item => "AutoCloseMessagesTime =" & Positive'Image(Game_Settings.Auto_Close_Messages_Time)); Put_Line (File => Config_File, Item => "AutoSave = " & Auto_Save_Type'Image(Game_Settings.Auto_Save)); Put_Line (File => Config_File, Item => "TopicsPosition =" & Natural'Image(Game_Settings.Topics_Position)); Save_Boolean(Value => Game_Settings.Show_Numbers, Name => "ShowNumbers"); Save_Boolean(Value => Game_Settings.Right_Button, Name => "RightButton"); Put_Line (File => Config_File, Item => "ListsLimit =" & Positive'Image(Game_Settings.Lists_Limit)); Close(File => Config_File); end Save_Config; end Config;
------------------------------------------------------------------------------ -- protected_counters.adb -- -- Implementation of the protected counter. ------------------------------------------------------------------------------ package body Protected_Counters is protected body Counter is procedure Decrement_And_Test_If_Zero (Is_Zero: out Boolean) is begin Value := Value - 1; Is_Zero := Value = 0; end Decrement_And_Test_If_Zero; end Counter; end Protected_Counters;
with Ada.Text_IO; use Ada.Text_IO; with Glib; use Glib; with Glib.Error; use Glib.Error; with Glib.Object; use Glib.Object; with Gtk.Box; use Gtk.Box; with Gtk.Builder; use Gtk.Builder; with Gtk.Button; use Gtk.Button; with Gtk.Frame; use Gtk.Frame; with Gtk.Handlers; with adam.Assist; package body aIDE.Palette.of_types_package is use Adam; type button_Info is record package_Name : Text; types_Palette : aIDE.Palette.types.view; end record; procedure on_type_Button_clicked (the_Button : access Gtk_Button_Record'Class; the_Info : in button_Info) is the_type_Name : constant String := the_Button.Get_Label; begin the_Info.types_Palette.choice_is (assist.Tail_of (the_type_Name), +the_Info.package_Name); end on_type_Button_clicked; package Button_Callbacks is new Gtk.Handlers.User_Callback (Gtk_Button_Record, button_Info); -- Forge -- function to_types_Palette_package return View is Self : constant Palette.types_package.view := new Palette.types_package.item; the_Builder : Gtk_Builder; Error : aliased GError; Result : Guint; begin Gtk_New (the_Builder); Result := the_Builder.Add_From_File ("glade/palette/types_palette-package.glade", Error'Access); if Error /= null then Put_Line ("Error: 'adam.Palette.types_package.to_types_Palette_package' ~ " & Get_Message (Error)); Error_Free (Error); end if; Self.Top := gtk_Frame (the_Builder.get_Object ("top_Frame")); Self.children_Notebook := gtk_Notebook (the_Builder.get_Object ("children_Notebook")); Self.types_Box := gtk_Box (the_Builder.get_Object ("types_Box")); Self.types_Window := Gtk_Scrolled_Window (the_Builder.get_Object ("types_Window")); -- enable_bold_Tabs_for (Self.children_Notebook); -- self.types_Window.Hide; self.types_Window.Show_all; self.types_Window.Show_now; return Self; end to_types_Palette_package; function new_Button (Named : in String; package_Name : in String; types_Palette : in palette.types.view; use_simple_Name : in Boolean) return gtk_Button is full_Name : constant String := package_Name & "." & Named; the_Button : gtk_Button; begin if use_simple_Name then gtk_New (the_Button, Named); else gtk_New (the_Button, assist.type_button_Name_of (full_Name)); end if; the_Button.Set_Tooltip_Text (full_Name); Button_Callbacks.connect (the_Button, "clicked", on_type_Button_clicked'Access, (+package_Name, types_Palette)); return the_Button; end new_Button; -- Attributes -- procedure Parent_is (Self : in out Item; Now : in aIDE.Palette.types.view) is begin Self.Parent := Now; end Parent_is; function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget is begin return gtk.Widget.Gtk_Widget (Self.Top); end top_Widget; function children_Notebook (Self : in Item) return gtk_Notebook is begin return Self.children_Notebook; end children_Notebook; -- Operations -- procedure add_Type (Self : access Item; Named : in String; package_Name : in String) is the_Button : constant gtk_Button := new_Button (Named, package_Name, Self.Parent, use_simple_Name => True); begin -- Button_Callbacks.connect (the_Button, -- "clicked", -- on_type_Button_clicked'Access, -- (+package_Name, -- adam.Palette.types.view (Self.Parent))); Self.types_Box.pack_Start (the_Button, Expand => False, Fill => False, Padding => 1); -- self.types_Window.Hide; -- Self.types_Box.Hide; self.types_Window.Show_all; self.types_Window.Show_now; end add_Type; end aIDE.Palette.of_types_package;
-- //////////////////////////////////////////////////////////// -- // -- // SFML - Simple and Fast Multimedia Library -- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -- // -- // This software is provided 'as-is', without any express or implied warranty. -- // In no event will the authors be held liable for any damages arising from the use of this software. -- // -- // Permission is granted to anyone to use this software for any purpose, -- // including commercial applications, and to alter it and redistribute it freely, -- // subject to the following restrictions: -- // -- // 1. The origin of this software must not be misrepresented; -- // you must not claim that you wrote the original software. -- // If you use this software 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. -- // -- //////////////////////////////////////////////////////////// -- //////////////////////////////////////////////////////////// -- // Headers -- //////////////////////////////////////////////////////////// with Sf.Config; with Sf.Audio.Types; package Sf.Audio.SoundBuffer is use Sf.Config; use Sf.Audio.Types; -- //////////////////////////////////////////////////////////// -- /// Create a new sound buffer and load it from a file -- /// -- /// \param Filename : Path of the music file to open -- /// -- /// \return A new sfSoundBuffer object (NULL if failed) -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_CreateFromFile (Filename : String) return sfSoundBuffer_Ptr; -- //////////////////////////////////////////////////////////// -- /// Create a new sound buffer and load it from a file in memory -- /// -- /// \param Data : Pointer to the file data in memory -- /// \param SizeInBytes : Size of the data to load, in bytes -- /// -- /// \return A new sfSoundBuffer object (NULL if failed) -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_CreateFromMemory (Data : sfInt8_Ptr; SizeInBytes : sfSize_t) return sfSoundBuffer_Ptr; -- //////////////////////////////////////////////////////////// -- /// Create a new sound buffer and load it from an array of -- /// samples in memory - assumed format for samples is -- /// 16 bits signed integer -- /// -- /// \param Samples : Pointer to the samples in memory -- /// \param SamplesCount : Number of samples pointed by Samples -- /// \param ChannelsCount : Number of channels (1 = mono, 2 = stereo, ...) -- /// \param SampleRate : Frequency (number of samples to play per second) -- /// -- /// \return A new sfSoundBuffer object (NULL if failed) -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_CreateFromSamples (Samples : sfInt16_Ptr; SamplesCount : sfSize_t; ChannelsCount : sfUint32; SampleRate : sfUint32) return sfSoundBuffer_Ptr; -- //////////////////////////////////////////////////////////// -- /// Destroy an existing sound buffer -- /// -- /// \param SoundBuffer : Sound buffer to delete -- /// -- //////////////////////////////////////////////////////////// procedure sfSoundBuffer_Destroy (SoundBuffer : sfSoundBuffer_Ptr); -- //////////////////////////////////////////////////////////// -- /// Save a sound buffer to a file -- /// -- /// \param SoundBuffer : Sound buffer to save -- /// \param Filename : Path of the sound file to write -- /// -- /// \return sfTrue if saving has been successful -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_SaveToFile (SoundBuffer : sfSoundBuffer_Ptr; Filename : String) return sfBool; -- //////////////////////////////////////////////////////////// -- /// Return the samples contained in a sound buffer -- /// -- /// \param SoundBuffer : Sound buffer to get samples from -- /// -- /// \return Pointer to the array of sound samples, in 16 bits signed integer format -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_GetSamples (SoundBuffer : sfSoundBuffer_Ptr) return sfInt16_Ptr; -- //////////////////////////////////////////////////////////// -- /// Return the number of samples contained in a sound buffer -- /// -- /// \param SoundBuffer : Sound buffer to get samples count from -- /// -- /// \return Number of samples -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_GetSamplesCount (SoundBuffer : sfSoundBuffer_Ptr) return sfSize_t; -- //////////////////////////////////////////////////////////// -- /// Get the sample rate of a sound buffer -- /// -- /// \param SoundBuffer : Sound buffer to get sample rate from -- /// -- /// \return Sound frequency (number of samples per second) -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_GetSampleRate (SoundBuffer : sfSoundBuffer_Ptr) return sfUint32; -- //////////////////////////////////////////////////////////// -- /// Return the number of channels of a sound buffer (1 = mono, 2 = stereo, ...) -- /// -- /// \param SoundBuffer : Sound buffer to get channels count from -- /// -- /// \return Number of channels -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_GetChannelsCount (SoundBuffer : sfSoundBuffer_Ptr) return sfUint32; -- //////////////////////////////////////////////////////////// -- /// Get the duration of a sound buffer -- /// -- /// \param SoundBuffer : Sound buffer to get duration from -- /// -- /// \return Sound duration, in seconds -- /// -- //////////////////////////////////////////////////////////// function sfSoundBuffer_GetDuration (SoundBuffer : sfSoundBuffer_Ptr) return Float; private pragma Import (C, sfSoundBuffer_CreateFromMemory, "sfSoundBuffer_CreateFromMemory"); pragma Import (C, sfSoundBuffer_CreateFromSamples, "sfSoundBuffer_CreateFromSamples"); pragma Import (C, sfSoundBuffer_Destroy, "sfSoundBuffer_Destroy"); pragma Import (C, sfSoundBuffer_GetSamples, "sfSoundBuffer_GetSamples"); pragma Import (C, sfSoundBuffer_GetSamplesCount, "sfSoundBuffer_GetSamplesCount"); pragma Import (C, sfSoundBuffer_GetSampleRate, "sfSoundBuffer_GetSampleRate"); pragma Import (C, sfSoundBuffer_GetChannelsCount, "sfSoundBuffer_GetChannelsCount"); pragma Import (C, sfSoundBuffer_GetDuration, "sfSoundBuffer_GetDuration"); end Sf.Audio.SoundBuffer;
pragma Warnings (Off); pragma Style_Checks (Off); with GLOBE_3D.Options, GLOBE_3D.Textures, GLOBE_3D.Math; with GL.geometry.primitives; use GL.geometry.primitives; with Ada.Exceptions; use Ada.Exceptions; with ada.text_io; use ada.text_io; with ada.unchecked_Conversion; with System; package body GLOBE_3D.tri_Mesh.vertex_array is use GLOBE_3D.Options; package G3DT renames GLOBE_3D.Textures; package G3DM renames GLOBE_3D.Math; procedure destroy (o : in out tri_Mesh) is use GL.skinned_geometry; begin destroy (o.skinned_Geometry); end; function skinned_Geometrys (o : in tri_Mesh) return GL.skinned_geometry.skinned_Geometrys is begin return (1 => o.skinned_Geometry); end; procedure set_Alpha (o : in out tri_Mesh; Alpha : in GL.Double) is begin null; -- tbd: end; function is_Transparent (o : in tri_Mesh) return Boolean is use type GL.Double; begin return o.skinned_Geometry.Skin.is_Transparent; end; procedure Pre_calculate (o : in out tri_Mesh) is use GL, G3DM; begin null; -- tbd: end Pre_calculate; procedure Display (o : in out tri_Mesh; clip : in Clipping_data) is begin null; end Display; procedure set_Vertices (Self : in out tri_Mesh; To : access GL.geometry.GL_vertex_Array) is use GL.Geometry, GL.Geometry.primal; the_Geometry : GL.geometry.primal.primal_Geometry renames GL.geometry.primal.primal_Geometry (self.skinned_geometry.Geometry.all); begin the_Geometry.set_Vertices (to => To); end; procedure set_Indices (Self : in out tri_Mesh; To : access GL.geometry.vertex_Id_array) is use GL.Geometry, GL.Geometry.primal; the_Geometry : GL.geometry.primal.primal_Geometry renames GL.geometry.primal.primal_Geometry (self.skinned_geometry.Geometry.all); begin the_Geometry.set_Indices (to => To); end; procedure Skin_is (o : in out tri_Mesh; Now : in GL.skins.p_Skin) is begin o.skinned_Geometry.Skin := Now; o.skinned_Geometry.Veneer := Now.all.new_Veneer (for_geometry => o.skinned_Geometry.Geometry.all); end; function face_Count (o : in tri_Mesh) return Natural is use GL; the_Geometry : GL.geometry.primal.primal_Geometry renames GL.geometry.primal.primal_Geometry (o.skinned_geometry.Geometry.all); begin return Natural (the_Geometry.primitive.indices'Length / 3); end; function Bounds (o : in tri_Mesh) return GL.geometry.Bounds_record is begin return o.skinned_geometry.Geometry.Bounds; end; end GLOBE_3D.tri_Mesh.vertex_array;
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (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 Ada.Integer_Text_IO; with Latin_Utils.Config; with Latin_Utils.Latin_File_Names; use Latin_Utils.Latin_File_Names; --with Latin_Utils.Preface; package body Latin_Utils.Inflections_Package is --------------------------------------------------------------------------- function "<" (Left, Right : Decn_Record) return Boolean is begin if Left.Which < Right.Which or else (Left.Which = Right.Which and then Left.Var < Right.Var) then return True; else return False; end if; end "<"; --------------------------------------------------------------------------- -- FIXME: should the function below, comparing two Quality_Records -- not call the function above, comparing two Decn_Records? function "<" (Left, Right : Quality_Record) return Boolean is begin if Left.Pofs = Right.Pofs then case Left.Pofs is when N => if Left.Noun.Decl.Which < Right.Noun.Decl.Which or else (Left.Noun.Decl.Which = Right.Noun.Decl.Which and then Left.Noun.Decl.Var < Right.Noun.Decl.Var) or else (Left.Noun.Decl.Which = Right.Noun.Decl.Which and then Left.Noun.Decl.Var = Right.Noun.Decl.Var and then Left.Noun.Number < Right.Noun.Number) or else (Left.Noun.Decl.Which = Right.Noun.Decl.Which and then Left.Noun.Decl.Var = Right.Noun.Decl.Var and then Left.Noun.Number = Right.Noun.Number and then Left.Noun.Of_Case < Right.Noun.Of_Case) or else (Left.Noun.Decl.Which = Right.Noun.Decl.Which and then Left.Noun.Decl.Var = Right.Noun.Decl.Var and then Left.Noun.Number = Right.Noun.Number and then Left.Noun.Of_Case = Right.Noun.Of_Case and then Left.Noun.Gender < Right.Noun.Gender) then return True; end if; when Pron => if Left.Pron.Decl.Which < Right.Pron.Decl.Which or else (Left.Pron.Decl.Which = Right.Pron.Decl.Which and then Left.Pron.Decl.Var < Right.Pron.Decl.Var) or else (Left.Pron.Decl.Which = Right.Pron.Decl.Which and then Left.Pron.Decl.Var = Right.Pron.Decl.Var and then Left.Pron.Number < Right.Pron.Number) or else (Left.Pron.Decl.Which = Right.Pron.Decl.Which and then Left.Pron.Decl.Var = Right.Pron.Decl.Var and then Left.Pron.Number = Right.Pron.Number and then Left.Pron.Of_Case < Right.Pron.Of_Case) or else (Left.Pron.Decl.Which = Right.Pron.Decl.Which and then Left.Pron.Decl.Var = Right.Pron.Decl.Var and then Left.Pron.Number = Right.Pron.Number and then Left.Pron.Of_Case = Right.Pron.Of_Case and then Left.Pron.Gender < Right.Pron.Gender) then return True; end if; when Pack => if Left.Pack.Decl.Which < Right.Pack.Decl.Which or else (Left.Pack.Decl.Which = Right.Pack.Decl.Which and then Left.Pack.Decl.Var < Right.Pack.Decl.Var) or else (Left.Pack.Decl.Which = Right.Pack.Decl.Which and then Left.Pack.Decl.Var = Right.Pack.Decl.Var and then Left.Pack.Number < Right.Pack.Number) or else (Left.Pack.Decl.Which = Right.Pack.Decl.Which and then Left.Pack.Decl.Var = Right.Pack.Decl.Var and then Left.Pack.Number = Right.Pack.Number and then Left.Pack.Of_Case < Right.Pack.Of_Case) or else (Left.Pack.Decl.Which = Right.Pack.Decl.Which and then Left.Pack.Decl.Var = Right.Pack.Decl.Var and then Left.Pack.Number = Right.Pack.Number and then Left.Pack.Of_Case = Right.Pack.Of_Case and then Left.Pack.Gender < Right.Pack.Gender) then return True; end if; when Adj => if Left.Adj.Decl.Which < Right.Adj.Decl.Which or else (Left.Adj.Decl.Which = Right.Adj.Decl.Which and then Left.Adj.Decl.Var < Right.Adj.Decl.Var) or else (Left.Adj.Decl.Which = Right.Adj.Decl.Which and then Left.Adj.Decl.Var = Right.Adj.Decl.Var and then Left.Adj.Number < Right.Adj.Number) or else (Left.Adj.Decl.Which = Right.Adj.Decl.Which and then Left.Adj.Decl.Var = Right.Adj.Decl.Var and then Left.Adj.Number = Right.Adj.Number and then Left.Adj.Of_Case < Right.Adj.Of_Case) or else (Left.Adj.Decl.Which = Right.Adj.Decl.Which and then Left.Adj.Decl.Var = Right.Adj.Decl.Var and then Left.Adj.Number = Right.Adj.Number and then Left.Adj.Of_Case = Right.Adj.Of_Case and then Left.Adj.Gender < Right.Adj.Gender) or else (Left.Adj.Decl.Which = Right.Adj.Decl.Which and then Left.Adj.Decl.Var = Right.Adj.Decl.Var and then Left.Adj.Number = Right.Adj.Number and then Left.Adj.Of_Case = Right.Adj.Of_Case and then Left.Adj.Gender = Right.Adj.Gender and then Left.Adj.Comparison < Right.Adj.Comparison) then return True; end if; when Adv => return Left.Adv.Comparison < Right.Adv.Comparison; when V => if (Left.Verb.Con.Which < Right.Verb.Con.Which) or else (Left.Verb.Con.Which = Right.Verb.Con.Which and then Left.Verb.Con.Var < Right.Verb.Con.Var) or else (Left.Verb.Con.Which = Right.Verb.Con.Which and then Left.Verb.Con.Var = Right.Verb.Con.Var and then Left.Verb.Number < Right.Verb.Number) or else (Left.Verb.Con.Which = Right.Verb.Con.Which and then Left.Verb.Con.Var = Right.Verb.Con.Var and then Left.Verb.Number = Right.Verb.Number and then Left.Verb.Tense_Voice_Mood.Tense < Right.Verb.Tense_Voice_Mood.Tense) or else (Left.Verb.Con.Which = Right.Verb.Con.Which and then Left.Verb.Con.Var = Right.Verb.Con.Var and then Left.Verb.Number = Right.Verb.Number and then Left.Verb.Tense_Voice_Mood.Tense = Right.Verb.Tense_Voice_Mood.Tense and then Left.Verb.Tense_Voice_Mood.Voice < Right.Verb.Tense_Voice_Mood.Voice) or else (Left.Verb.Con.Which = Right.Verb.Con.Which and then Left.Verb.Con.Var = Right.Verb.Con.Var and then Left.Verb.Number = Right.Verb.Number and then Left.Verb.Tense_Voice_Mood.Tense = Right.Verb.Tense_Voice_Mood.Tense and then Left.Verb.Tense_Voice_Mood.Voice = Right.Verb.Tense_Voice_Mood.Voice and then Left.Verb.Tense_Voice_Mood.Mood < Right.Verb.Tense_Voice_Mood.Mood) or else (Left.Verb.Con.Which = Right.Verb.Con.Which and then Left.Verb.Con.Var = Right.Verb.Con.Var and then Left.Verb.Number = Right.Verb.Number and then Left.Verb.Tense_Voice_Mood.Tense = Right.Verb.Tense_Voice_Mood.Tense and then Left.Verb.Tense_Voice_Mood.Voice = Right.Verb.Tense_Voice_Mood.Voice and then Left.Verb.Tense_Voice_Mood.Mood = Right.Verb.Tense_Voice_Mood.Mood and then Left.Verb.Person < Right.Verb.Person) then return True; end if; when Vpar => if Left.Vpar.Con.Which < Right.Vpar.Con.Which or else (Left.Vpar.Con.Which = Right.Vpar.Con.Which and then Left.Vpar.Con.Var < Right.Vpar.Con.Var) or else (Left.Vpar.Con.Which = Right.Vpar.Con.Which and then Left.Vpar.Con.Var = Right.Vpar.Con.Var and then Left.Vpar.Number < Right.Vpar.Number) or else (Left.Vpar.Con.Which = Right.Vpar.Con.Which and then Left.Vpar.Con.Var = Right.Vpar.Con.Var and then Left.Vpar.Number = Right.Vpar.Number and then Left.Vpar.Of_Case < Right.Vpar.Of_Case) or else (Left.Vpar.Con.Which = Right.Vpar.Con.Which and then Left.Vpar.Con.Var = Right.Vpar.Con.Var and then Left.Vpar.Number = Right.Vpar.Number and then Left.Vpar.Of_Case = Right.Vpar.Of_Case and then Left.Vpar.Gender < Right.Vpar.Gender) then return True; end if; when Supine => if Left.Supine.Con.Which < Right.Supine.Con.Which or else (Left.Supine.Con.Which = Right.Supine.Con.Which and then Left.Supine.Con.Var < Right.Supine.Con.Var) or else (Left.Supine.Con.Which = Right.Supine.Con.Which and then Left.Supine.Con.Var = Right.Supine.Con.Var and then Left.Supine.Number < Right.Supine.Number) or else (Left.Supine.Con.Which = Right.Supine.Con.Which and then Left.Supine.Con.Var = Right.Supine.Con.Var and then Left.Supine.Number = Right.Supine.Number and then Left.Supine.Of_Case < Right.Supine.Of_Case) or else (Left.Supine.Con.Which = Right.Supine.Con.Which and then Left.Supine.Con.Var = Right.Supine.Con.Var and then Left.Supine.Number = Right.Supine.Number and then Left.Supine.Of_Case = Right.Supine.Of_Case and then Left.Supine.Gender < Right.Supine.Gender) then return True; end if; when Prep => return Left.Prep.Of_Case < Right.Prep.Of_Case; when Conj => null; when Interj => null; when Num => if Left.Num.Decl.Which < Right.Num.Decl.Which or else (Left.Num.Decl.Which = Right.Num.Decl.Which and then Left.Num.Decl.Var < Right.Num.Decl.Var) or else (Left.Num.Decl.Which = Right.Num.Decl.Which and then Left.Num.Decl.Var = Right.Num.Decl.Var and then Left.Num.Number < Right.Num.Number) or else (Left.Num.Decl.Which = Right.Num.Decl.Which and then Left.Num.Decl.Var = Right.Num.Decl.Var and then Left.Num.Number = Right.Num.Number and then Left.Num.Of_Case < Right.Num.Of_Case) or else (Left.Num.Decl.Which = Right.Num.Decl.Which and then Left.Num.Decl.Var = Right.Num.Decl.Var and then Left.Num.Number = Right.Num.Number and then Left.Num.Of_Case = Right.Num.Of_Case and then Left.Num.Gender < Right.Num.Gender) or else (Left.Num.Decl.Which = Right.Num.Decl.Which and then Left.Num.Decl.Var = Right.Num.Decl.Var and then Left.Num.Number = Right.Num.Number and then Left.Num.Of_Case = Right.Num.Of_Case and then Left.Num.Gender = Right.Num.Gender and then Left.Num.Sort < Right.Num.Sort) then return True; end if; when Tackon .. Suffix => null; when X => null; end case; else return Left.Pofs < Right.Pofs; end if; return False; exception when Constraint_Error => return Left.Pofs < Right.Pofs; end "<"; overriding function "<=" (Left, Right : Part_Of_Speech_Type) return Boolean is begin if Right = Left or else (Left = Pack and Right = Pron) or else Right = X then return True; else return False; end if; end "<="; function "<=" (Left, Right : Decn_Record) return Boolean is begin if Right = Left or else (Right = Decn_Record'(0, 0) and Left.Which /= 9) or else Right = Decn_Record'(Left.Which, 0) then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Gender_Type) return Boolean is begin if Right = Left or else Right = X or else (Right = C and then (Left = M or Left = F)) then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Case_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Number_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Person_Type) return Boolean is begin if Right = Left or else Right = 0 then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Comparison_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; function "<=" (Left, Right : Tense_Voice_Mood_Record) return Boolean is begin if (Right.Tense = Left.Tense or else Right.Tense = X) and then (Right.Voice = Left.Voice or else Right.Voice = X) and then (Right.Mood = Left.Mood or else Right.Mood = X) then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Noun_Kind_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Pronoun_Kind_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Stem_Key_Type) return Boolean is begin -- Only works for 2 stem parts, not verbs if Right = Left or else Right = 0 then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Age_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; overriding function "<=" (Left, Right : Frequency_Type) return Boolean is begin if Right = Left or else Right = X then return True; else return False; end if; end "<="; --------------------------------------------------------------------------- package body Stem_Type_IO is separate; package body Decn_Record_IO is separate; package body Tense_Voice_Mood_Record_IO is separate; package body Noun_Record_IO is separate; package body Pronoun_Record_IO is separate; package body Propack_Record_IO is separate; package body Adjective_Record_IO is separate; package body Numeral_Record_IO is separate; package body Adverb_Record_IO is separate; package body Verb_Record_IO is separate; package body Vpar_Record_IO is separate; package body Supine_Record_IO is separate; package body Preposition_Record_IO is separate; package body Conjunction_Record_IO is separate; package body Interjection_Record_IO is separate; package body Tackon_Record_IO is separate; package body Prefix_Record_IO is separate; package body Suffix_Record_IO is separate; package body Quality_Record_IO is separate; package body Ending_Record_IO is separate; package body Inflection_Record_IO is separate; --------------------------------------------------------------------------- procedure Establish_Inflections_Section is -- Loads the inflection array from the file prepared in -- FILE_INFLECTIONS_SECTION -- If N = 0 (an artificial flag for the section for blank -- inflections = 5) -- computes the LELL .. LELF indices for use in WORD use Lel_Section_Io; procedure Load_Lel_Indexes is -- Load arrays from file I : Integer := 0; N, Xn : Integer := 0; Ch, Xch : Character := ' '; Inflections_Sections_File : Lel_Section_Io.File_Type; -- FIXME: This enumeration and its values should be changed to -- something more meaningful. type Paradigm is (P1, P2, P3, P4, P5); procedure Read_Inflections (P : Paradigm) is Count : constant Integer := Paradigm'Pos (P) + 1; begin if P /= P5 then Lel_Section_Io.Read (Inflections_Sections_File, Lel, Lel_Section_Io.Positive_Count (Count)); I := 1; end if; N := Lel (I).Ending.Size; Ch := Lel (I).Ending.Suf (N); Xn := N; Xch := Ch; if P /= P5 then Lelf (N, Ch) := I; else Pelf (N, Ch) := I; Pell (N, Ch) := 0; end if; C1_Loop : loop N1_Loop : loop case P is when P1 | P2 | P3 | P5 => exit C1_Loop when Lel (I) = Null_Inflection_Record; when P4 => exit C1_Loop when Lel (I).Qual.Pofs = Pron and then (Lel (I).Qual.Pron.Decl.Which = 1 or Lel (I).Qual.Pron.Decl.Which = 2); end case; N := Lel (I).Ending.Size; Ch := Lel (I).Ending.Suf (N); case P is when P1 | P4 | P5 => null; when P2 => exit N1_Loop when Ch > 'r'; when P3 => exit N1_Loop when Ch > 's'; end case; if P /= P5 then if Ch /= Xch then Lell (Xn, Xch) := I - 1; Lelf (N, Ch) := I; Lell (N, Ch) := 0; Xch := Ch; Xn := N; elsif N /= Xn then Lell (Xn, Ch) := I - 1; Lelf (N, Ch) := I; Lell (N, Ch) := 0; Xn := N; exit N1_Loop; end if; else if Ch /= Xch then Pell (Xn, Xch) := I - 1; Pelf (N, Ch) := I; Pell (N, Ch) := 0; Xch := Ch; Xn := N; elsif N /= Xn then Pell (Xn, Ch) := I - 1; Pelf (N, Ch) := I; Pell (N, Ch) := 0; Xn := N; exit N1_Loop; end if; end if; I := I + 1; end loop N1_Loop; end loop C1_Loop; if P /= P5 then Lell (Xn, Xch) := I - 1; end if; end Read_Inflections; begin Open (Inflections_Sections_File, In_File, Latin_Utils.Config.Path (Inflections_Sections_Name)); Number_Of_Inflections := 0; Lel_Section_Io.Read (Inflections_Sections_File, Lel, Lel_Section_Io.Positive_Count (5)); I := 1; Belf (0, ' ') := I; Bell (0, ' ') := 0; loop exit when Lel (I) = Null_Inflection_Record; Bel (I) := Lel (I); Bell (0, ' ') := I; I := I + 1; end loop; for K in Paradigm'Range loop if K /= P5 then Number_Of_Inflections := Number_Of_Inflections + I - 1; end if; Read_Inflections (K); end loop; Pell (Xn, Xch) := I - 1; Number_Of_Inflections := Number_Of_Inflections + I - 1; Close (Inflections_Sections_File); end Load_Lel_Indexes; begin --Preface.Put ("INFLECTION_ARRAY being loaded"); --Preface.Set_Col (33); Load_Lel_Indexes; -- Makes indexes from array --Preface.Put (Number_Of_Inflections, 6); --Preface.Put (" entries"); --Preface.Set_Col (55); Preface.Put_Line ("-- Loaded correctly"); exception when Ada.Text_IO.Name_Error => New_Line; Put_Line ("There is no " & Inflections_Sections_Name & " file."); Put_Line ("The program cannot work without one."); Put_Line ("Make sure you are in the" & " subdirectory containing the files"); Put_Line ("for inflections, dictionary, addons and uniques."); raise Give_Up; end Establish_Inflections_Section; begin -- initialization of body of INFLECTIONS_PACKAGE Part_Of_Speech_Type_IO.Default_Width := Part_Of_Speech_Type'Width; Gender_Type_IO.Default_Width := Gender_Type'Width; Case_Type_IO.Default_Width := Case_Type'Width; Number_Type_IO.Default_Width := Number_Type'Width; Person_Type_IO.Default_Width := 1; Comparison_Type_IO.Default_Width := Comparison_Type'Width; Tense_Type_IO.Default_Width := Tense_Type'Width; Voice_Type_IO.Default_Width := Voice_Type'Width; Mood_Type_IO.Default_Width := Mood_Type'Width; Numeral_Sort_Type_IO.Default_Width := Numeral_Sort_Type'Width; end Latin_Utils.Inflections_Package;
----------------------------------------------------------------------- -- keystore-repository-entries -- Repository management for the keystore -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- private package Keystore.Repository.Entries is subtype Wallet_Manager is Wallet_Repository; -- Load the complete wallet directory by starting at the given block. procedure Load_Complete_Directory (Manager : in out Wallet_Manager; Block : in Keystore.IO.Storage_Block); procedure Initialize_Directory_Block (Manager : in out Wallet_Manager; Block : in IO.Storage_Block; Space : in IO.Buffer_Size; Directory : out Wallet_Directory_Entry_Access); -- Add a new entry in the wallet directory. procedure Add_Entry (Manager : in out Wallet_Manager; Name : in String; Kind : in Entry_Type; Item : out Wallet_Entry_Access); -- Update an existing entry in the wallet directory. procedure Update_Entry (Manager : in out Wallet_Manager; Item : in Wallet_Entry_Access; Kind : in Entry_Type; Size : in Interfaces.Unsigned_64); -- Delete the entry from the repository. procedure Delete_Entry (Manager : in out Wallet_Manager; Item : in Wallet_Entry_Access); -- Load the wallet directory block in the wallet manager buffer. -- Extract the directory if this is the first time the data block is read. procedure Load_Directory (Manager : in out Wallet_Manager; Directory : in Wallet_Directory_Entry_Access; Into : in out IO.Marshaller); -- Find and load a directory block to hold a new entry that occupies the given space. -- The first directory block that has enough space is used otherwise a new block -- is allocated and initialized. procedure Find_Directory_Block (Manager : in out Wallet_Manager; Space : in IO.Block_Index; Directory : out Wallet_Directory_Entry_Access); -- Save the directory blocks that have been modified. procedure Save (Manager : in out Wallet_Manager); private -- Size of the wallet entry in the repository. function Entry_Size (Item : in Wallet_Entry_Access) return IO.Block_Index is (DATA_NAME_ENTRY_SIZE + Item.Name'Length); end Keystore.Repository.Entries;
with ATree; procedure launch is begin ATree.main; end launch;
with Ada.Text_IO; use Ada.Text_IO; -- arbres binaires de recherche procedure BST is type Node; type BST is access Node; type Node is record Value: Integer; Left, Right: BST; end record; -- insertion utilisant le passage par référence procedure Add(X: Integer; B: in out BST) is begin if B = null then B := new Node; B.Value := X; return; end if; if X < B.Value then Add(X, B.Left); elsif X > B.Value then Add(X, B.Right); end if; end; function Mem(X: Integer; B: BST) return boolean is begin if B = null then return False; end if; if X < B.Value then return Mem(X, B.Left); elsif X > B.Value then return Mem(X, B.Right); else return True; end if; end; procedure PrintInt(N: Integer) is C: Integer := N rem 10; begin if N > 9 then PrintInt(N / 10); end if; Put(Character'Val(48 + C)); end; procedure PrintBool(b: boolean) is begin if B then Put('T'); else Put('F'); end if; end; procedure Print(B: in BST) is begin if B = null then return; end if; Put('('); Print(B.Left); -- Put(','); PrintInt(B.Value); -- Put(','); Print(B.Right); Put(')'); end; B: BST; begin B := null; Print(B); New_Line; Add(5, B); Print(B); New_Line; Add(2, B); Print(B); New_Line; Add(7, B); Print(B); New_Line; for I in 1 .. 10 loop PrintBool(Mem(I, B)); Add(I, B); end loop; New_Line; Print(B); New_Line; end; -- Local Variables: -- compile-command: "gnatmake bst.adb && ./bst" -- End:
private with Ada.Containers.Vectors; generic type Element_Type is private; with function "<=" (Left, Right : in Element_Type) return Boolean is <>; package Heap is pragma Remote_Types; type Heap is private; Empty_Heap : constant Heap; procedure Insert(hp : in out Heap; element : in Element_Type); procedure Remove(hp : in out Heap); procedure Remove(hp : in out Heap; element : out Element_Type); procedure Replace_Head(hp : in out Heap; Element : in Element_Type); function Is_Empty(hp : in Heap) return Boolean; function Peek(hp : in Heap) return Element_Type; private pragma inline(Is_Empty); pragma inline(Peek); package Underlying_Vector is new Ada.Containers.Vectors(Index_Type => Positive, Element_Type => Element_Type); type Heap is Record vector : Underlying_Vector.Vector; end Record; Empty_Heap : constant Heap := (vector => Underlying_Vector.Empty_Vector); end Heap;
----------------------------------------------------------------------- -- asf-helpers-beans -- Helper packages to write ASF applications -- Copyright (C) 2012, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Beans.Objects; with ASF.Contexts.Faces; package body ASF.Helpers.Beans is -- ------------------------------ -- Get a bean instance associated under the given name from the current faces context. -- A null value is returned if the bean does not exist or is not of the good type. -- ------------------------------ function Get_Bean (Name : in String) return Element_Access is use type ASF.Contexts.Faces.Faces_Context_Access; use type Util.Beans.Basic.Readonly_Bean_Access; Context : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current; begin if Context = null then return null; end if; declare Bean : constant Util.Beans.Basic.Readonly_Bean_Access := Context.Get_Bean (Name); begin if Bean = null or else not (Bean.all in Element_Type'Class) then return null; else return Element_Type'Class (Bean.all)'Access; end if; end; end Get_Bean; -- ------------------------------ -- Get a bean instance associated under the given name from the request. -- A null value is returned if the bean does not exist or is not of the good type. -- ------------------------------ function Get_Request_Bean (Request : in ASF.Requests.Request'Class; Name : in String) return Element_Access is Value : constant Util.Beans.Objects.Object := Request.Get_Attribute (Name); Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); begin if Bean = null or else not (Bean.all in Element_Type'Class) then return null; else return Element_Type'Class (Bean.all)'Access; end if; end Get_Request_Bean; end ASF.Helpers.Beans;
with posix.Permissions, ada.Streams; package lace.Environ -- -- Models an operating system environment. -- is use posix.Permissions; function to_octal_Mode (Permissions : in Permission_Set) return String; subtype Data is ada.Streams.Stream_Element_Array; Error : exception; end lace.Environ;
with Ada.Text_IO; use Ada.Text_IO; procedure Fib is procedure PrintInt(N: Integer) is C: Integer := N rem 10; begin if N > 9 then PrintInt(N / 10); end if; Put(Character'Val(48 + C)); end; f : integer; procedure fib(n : integer) is procedure somme is tmp : integer; begin fib(n-2); tmp := f; fib(n-1); f := f + Tmp; end; begin if n <= 1 then f := N; else somme; end if; end; begin fib(10); printint(f); New_Line; end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E R R _ V A R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains variables common to error reporting packages -- including Errout and Prj.Err. with Namet; use Namet; with Types; use Types; with Uintp; use Uintp; package Err_Vars is -- All of these variables are set when needed, so they do not need to be -- initialized. However, there is code that saves and restores existing -- values, which may malfunction in -gnatVa mode if the variable has never -- been initialized, so we initialize some variables to avoid exceptions -- from invalid values in such cases. ------------------ -- Error Counts -- ------------------ Serious_Errors_Detected : Nat := 0; -- This is a count of errors that are serious enough to stop expansion, -- and hence to prevent generation of an object file even if the -- switch -gnatQ is set. Initialized to zero at the start of compilation. -- Initialized for -gnatVa use, see comment above. Total_Errors_Detected : Nat := 0; -- Number of errors detected so far. Includes count of serious errors and -- non-serious errors, so this value is always greater than or equal to the -- Serious_Errors_Detected value. Initialized to zero at the start of -- compilation. Initialized for -gnatVa use, see comment above. Warnings_Detected : Nat := 0; -- Number of warnings detected. Initialized to zero at the start of -- compilation. Initialized for -gnatVa use, see comment above. ---------------------------------- -- Error Message Mode Variables -- ---------------------------------- -- These variables control special error message modes. The initialized -- values below give the normal default behavior, but they can be reset -- by the caller to get different behavior as noted in the comments. These -- variables are not reset by calls to the error message routines, so the -- caller is responsible for resetting the default behavior after use. Error_Msg_Qual_Level : Int; -- Number of levels of qualification required for type name (see the -- description of the } insertion character. Note that this value does -- note get reset by any Error_Msg call, so the caller is responsible -- for resetting it. Warn_On_Instance : Boolean := False; -- Normally if a warning is generated in a generic template from the -- analysis of the template, then the warning really belongs in the -- template, and the default value of False for this Boolean achieves -- that effect. If Warn_On_Instance is set True, then the warnings are -- generated on the instantiation (referring to the template) rather -- than on the template itself. Raise_Exception_On_Error : Nat := 0; -- If this value is non-zero, then any attempt to generate an error -- message raises the exception Error_Msg_Exception, and the error -- message is not output. This is used for defending against junk -- resulting from illegalities, and also for substitution of more -- appropriate error messages from higher semantic levels. It is -- a counter so that the increment/decrement protocol nests neatly. -- Initialized for -gnatVa use, see comment above. Error_Msg_Exception : exception; -- Exception raised if Raise_Exception_On_Error is true Current_Error_Source_File : Source_File_Index := Internal_Source_File; -- Id of current messages. Used to post file name when unit changes. This -- is initialized to Main_Source_File at the start of a compilation, which -- means that no file names will be output unless there are errors in units -- other than the main unit. However, if the main unit has a pragma -- Source_Reference line, then this is initialized to No_Source_File, -- to force an initial reference to the real source file name. ---------------------------------------- -- Error Message Insertion Parameters -- ---------------------------------------- -- The error message routines work with strings that contain insertion -- sequences that result in the insertion of variable data. The following -- variables contain the required data. The procedure is to set one or more -- of the following global variables to appropriate values before making a -- call to one of the error message routines with a string containing the -- insertion character to get the value inserted in an appropriate format. Error_Msg_Col : Column_Number; -- Column for @ insertion character in message Error_Msg_Uint_1 : Uint; Error_Msg_Uint_2 : Uint; -- Uint values for ^ insertion characters in message Error_Msg_Sloc : Source_Ptr; -- Source location for # insertion character in message Error_Msg_Name_1 : Name_Id; Error_Msg_Name_2 : Name_Id; Error_Msg_Name_3 : Name_Id; -- Name_Id values for % insertion characters in message Error_Msg_File_1 : File_Name_Type; Error_Msg_File_2 : File_Name_Type; Error_Msg_File_3 : File_Name_Type; -- File_Name_Type values for { insertion characters in message Error_Msg_Unit_1 : Unit_Name_Type; Error_Msg_Unit_2 : Unit_Name_Type; -- Unit_Name_Type values for $ insertion characters in message Error_Msg_Node_1 : Node_Id; Error_Msg_Node_2 : Node_Id; -- Node_Id values for & insertion characters in message Error_Msg_Warn : Boolean; -- Used if current message contains a < insertion character to indicate -- if the current message is a warning message. Error_Msg_String : String (1 .. 4096); Error_Msg_Strlen : Natural; -- Used if current message contains a ~ insertion character to indicate -- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen). end Err_Vars;
with Ada.Text_IO; use Ada.Text_IO; with AWS.Default; with AWS.Server; with Hello_World_CB; procedure Server is WS : AWS.Server.HTTP; Port : Positive := AWS.Default.Server_Port; begin Put_Line("Call me on port" & Positive'Image(Port) & ", I will stop if you press Q."); AWS.Server.Start(WS, "Hello, World", Max_Connection => 1, Port => Port, Callback => Hello_World_CB.HW_CB'Access); AWS.Server.Wait(AWS.Server.Q_Key_Pressed); AWS.Server.Shutdown(WS); end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P_ D I S T -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Einfo; use Einfo; with Elists; use Elists; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with GNAT.HTable; use GNAT.HTable; with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Ch3; use Sem_Ch3; with Sem_Ch8; use Sem_Ch8; with Sem_Dist; use Sem_Dist; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Tbuild; use Tbuild; with Uintp; use Uintp; with Uname; use Uname; package body Exp_Dist is -- The following model has been used to implement distributed objects: -- given a designated type D and a RACW type R, then a record of the -- form: -- type Stub is tagged record -- [...declaration similar to s-parint.ads RACW_Stub_Type...] -- end Stub; -- is built. This type has two properties: -- -- 1) Since it has the same structure than RACW_Stub_Type, it can be -- converted to and from this type to make it suitable for -- System.Partition_Interface.Get_Unique_Remote_Pointer in order -- to avoid memory leaks when the same remote object arrive on the -- same partition by following different pathes -- -- 2) It also has the same dispatching table as the designated type D, -- and thus can be used as an object designated by a value of type -- R on any partition other than the one on which the object has -- been created, since only dispatching calls will be performed and -- the fields themselves will not be used. We call Derive_Subprograms -- to fake half a derivation to ensure that the subprograms do have -- the same dispatching table. ----------------------- -- Local subprograms -- ----------------------- procedure Build_General_Calling_Stubs (Decls : in List_Id; Statements : in List_Id; Target_Partition : in Entity_Id; RPC_Receiver : in Node_Id; Subprogram_Id : in Node_Id; Asynchronous : in Node_Id := Empty; Is_Known_Asynchronous : in Boolean := False; Is_Known_Non_Asynchronous : in Boolean := False; Is_Function : in Boolean; Spec : in Node_Id; Object_Type : in Entity_Id := Empty; Nod : in Node_Id); -- Build calling stubs for general purpose. The parameters are: -- Decls : a place to put declarations -- Statements : a place to put statements -- Target_Partition : a node containing the target partition that must -- be a N_Defining_Identifier -- RPC_Receiver : a node containing the RPC receiver -- Subprogram_Id : a node containing the subprogram ID -- Asynchronous : True if an APC must be made instead of an RPC. -- The value needs not be supplied if one of the -- Is_Known_... is True. -- Is_Known_Async... : True if we know that this is asynchronous -- Is_Known_Non_A... : True if we know that this is not asynchronous -- Spec : a node with a Parameter_Specifications and -- a Subtype_Mark if applicable -- Object_Type : in case of a RACW, parameters of type access to -- Object_Type will be marshalled using the -- address of this object (the addr field) rather -- than using the 'Write on the object itself -- Nod : used to provide sloc for generated code function Build_Subprogram_Calling_Stubs (Vis_Decl : Node_Id; Subp_Id : Int; Asynchronous : Boolean; Dynamically_Asynchronous : Boolean := False; Stub_Type : Entity_Id := Empty; Locator : Entity_Id := Empty; New_Name : Name_Id := No_Name) return Node_Id; -- Build the calling stub for a given subprogram with the subprogram ID -- being Subp_Id. If Stub_Type is given, then the "addr" field of -- parameters of this type will be marshalled instead of the object -- itself. It will then be converted into Stub_Type before performing -- the real call. If Dynamically_Asynchronous is True, then it will be -- computed at run time whether the call is asynchronous or not. -- Otherwise, the value of the formal Asynchronous will be used. -- If Locator is not Empty, it will be used instead of RCI_Cache. If -- New_Name is given, then it will be used instead of the original name. function Build_Subprogram_Receiving_Stubs (Vis_Decl : Node_Id; Asynchronous : Boolean; Dynamically_Asynchronous : Boolean := False; Stub_Type : Entity_Id := Empty; RACW_Type : Entity_Id := Empty; Parent_Primitive : Entity_Id := Empty) return Node_Id; -- Build the receiving stub for a given subprogram. The subprogram -- declaration is also built by this procedure, and the value returned -- is a N_Subprogram_Body. If a parameter of type access to Stub_Type is -- found in the specification, then its address is read from the stream -- instead of the object itself and converted into an access to -- class-wide type before doing the real call using any of the RACW type -- pointing on the designated type. function Build_Ordered_Parameters_List (Spec : Node_Id) return List_Id; -- Return an ordered parameter list: unconstrained parameters are put -- at the beginning of the list and constrained ones are put after. If -- there are no parameters, an empty list is returned. procedure Add_Calling_Stubs_To_Declarations (Pkg_Spec : in Node_Id; Decls : in List_Id); -- Add calling stubs to the declarative part procedure Add_Receiving_Stubs_To_Declarations (Pkg_Spec : in Node_Id; Decls : in List_Id); -- Add receiving stubs to the declarative part procedure Add_RAS_Dereference_Attribute (N : in Node_Id); -- Add a subprogram body for RAS dereference procedure Add_RAS_Access_Attribute (N : in Node_Id); -- Add a subprogram body for RAS Access attribute function Could_Be_Asynchronous (Spec : Node_Id) return Boolean; -- Return True if nothing prevents the program whose specification is -- given to be asynchronous (i.e. no out parameter). function Get_Pkg_Name_String_Id (Decl_Node : Node_Id) return String_Id; function Get_String_Id (Val : String) return String_Id; -- Ugly functions used to retrieve a package name. Inherited from the -- old exp_dist.adb and not rewritten yet ??? function Pack_Entity_Into_Stream_Access (Loc : Source_Ptr; Stream : Entity_Id; Object : Entity_Id; Etyp : Entity_Id := Empty) return Node_Id; -- Pack Object (of type Etyp) into Stream. If Etyp is not given, -- then Etype (Object) will be used if present. If the type is -- constrained, then 'Write will be used to output the object, -- If the type is unconstrained, 'Output will be used. function Pack_Node_Into_Stream (Loc : Source_Ptr; Stream : Entity_Id; Object : Node_Id; Etyp : Entity_Id) return Node_Id; -- Similar to above, with an arbitrary node instead of an entity function Pack_Node_Into_Stream_Access (Loc : Source_Ptr; Stream : Entity_Id; Object : Node_Id; Etyp : Entity_Id) return Node_Id; -- Similar to above, with Stream instead of Stream'Access function Copy_Specification (Loc : Source_Ptr; Spec : Node_Id; Object_Type : Entity_Id := Empty; Stub_Type : Entity_Id := Empty; New_Name : Name_Id := No_Name) return Node_Id; -- Build a specification from another one. If Object_Type is not Empty -- and any access to Object_Type is found, then it is replaced by an -- access to Stub_Type. If New_Name is given, then it will be used as -- the name for the newly created spec. function Scope_Of_Spec (Spec : Node_Id) return Entity_Id; -- Return the scope represented by a given spec function Need_Extra_Constrained (Parameter : Node_Id) return Boolean; -- Return True if the current parameter needs an extra formal to reflect -- its constrained status. function Is_RACW_Controlling_Formal (Parameter : Node_Id; Stub_Type : Entity_Id) return Boolean; -- Return True if the current parameter is a controlling formal argument -- of type Stub_Type or access to Stub_Type. type Stub_Structure is record Stub_Type : Entity_Id; Stub_Type_Access : Entity_Id; Object_RPC_Receiver : Entity_Id; RPC_Receiver_Stream : Entity_Id; RPC_Receiver_Result : Entity_Id; RACW_Type : Entity_Id; end record; -- This structure is necessary because of the two phases analysis of -- a RACW declaration occurring in the same Remote_Types package as the -- designated type. RACW_Type is any of the RACW types pointing on this -- designated type, it is used here to save an anonymous type creation -- for each primitive operation. Empty_Stub_Structure : constant Stub_Structure := (Empty, Empty, Empty, Empty, Empty, Empty); type Hash_Index is range 0 .. 50; function Hash (F : Entity_Id) return Hash_Index; package Stubs_Table is new Simple_HTable (Header_Num => Hash_Index, Element => Stub_Structure, No_Element => Empty_Stub_Structure, Key => Entity_Id, Hash => Hash, Equal => "="); -- Mapping between a RACW designated type and its stub type package Asynchronous_Flags_Table is new Simple_HTable (Header_Num => Hash_Index, Element => Node_Id, No_Element => Empty, Key => Entity_Id, Hash => Hash, Equal => "="); -- Mapping between a RACW type and the node holding the value True if -- the RACW is asynchronous and False otherwise. package RCI_Locator_Table is new Simple_HTable (Header_Num => Hash_Index, Element => Entity_Id, No_Element => Empty, Key => Entity_Id, Hash => Hash, Equal => "="); -- Mapping between a RCI package on which All_Calls_Remote applies and -- the generic instantiation of RCI_Info for this package. package RCI_Calling_Stubs_Table is new Simple_HTable (Header_Num => Hash_Index, Element => Entity_Id, No_Element => Empty, Key => Entity_Id, Hash => Hash, Equal => "="); -- Mapping between a RCI subprogram and the corresponding calling stubs procedure Add_Stub_Type (Designated_Type : in Entity_Id; RACW_Type : in Entity_Id; Decls : in List_Id; Stub_Type : out Entity_Id; Stub_Type_Access : out Entity_Id; Object_RPC_Receiver : out Entity_Id; Existing : out Boolean); -- Add the declaration of the stub type, the access to stub type and the -- object RPC receiver at the end of Decls. If these already exist, -- then nothing is added in the tree but the right values are returned -- anyhow and Existing is set to True. procedure Add_RACW_Read_Attribute (RACW_Type : in Entity_Id; Stub_Type : in Entity_Id; Stub_Type_Access : in Entity_Id; Declarations : in List_Id); -- Add Read attribute in Decls for the RACW type. The Read attribute -- is added right after the RACW_Type declaration while the body is -- inserted after Declarations. procedure Add_RACW_Write_Attribute (RACW_Type : in Entity_Id; Stub_Type : in Entity_Id; Stub_Type_Access : in Entity_Id; Object_RPC_Receiver : in Entity_Id; Declarations : in List_Id); -- Same thing for the Write attribute procedure Add_RACW_Read_Write_Attributes (RACW_Type : in Entity_Id; Stub_Type : in Entity_Id; Stub_Type_Access : in Entity_Id; Object_RPC_Receiver : in Entity_Id; Declarations : in List_Id); -- Add Read and Write attributes declarations and bodies for a given -- RACW type. The declarations are added just after the declaration -- of the RACW type itself, while the bodies are inserted at the end -- of Decls. function RCI_Package_Locator (Loc : Source_Ptr; Package_Spec : Node_Id) return Node_Id; -- Instantiate the generic package RCI_Info in order to locate the -- RCI package whose spec is given as argument. function Make_Tag_Check (Loc : Source_Ptr; N : Node_Id) return Node_Id; -- Surround a node N by a tag check, as in: -- begin -- <N>; -- exception -- when E : Ada.Tags.Tag_Error => -- Raise_Exception (Program_Error'Identity, -- Exception_Message (E)); -- end; function Input_With_Tag_Check (Loc : Source_Ptr; Var_Type : Entity_Id; Stream : Entity_Id) return Node_Id; -- Return a function with the following form: -- function R return Var_Type is -- begin -- return Var_Type'Input (S); -- exception -- when E : Ada.Tags.Tag_Error => -- Raise_Exception (Program_Error'Identity, -- Exception_Message (E)); -- end R; ------------------------------------ -- Local variables and structures -- ------------------------------------ RCI_Cache : Node_Id; Output_From_Constrained : constant array (Boolean) of Name_Id := (False => Name_Output, True => Name_Write); -- The attribute to choose depending on the fact that the parameter -- is constrained or not. There is no such thing as Input_From_Constrained -- since this require separate mechanisms ('Input is a function while -- 'Read is a procedure). --------------------------------------- -- Add_Calling_Stubs_To_Declarations -- --------------------------------------- procedure Add_Calling_Stubs_To_Declarations (Pkg_Spec : in Node_Id; Decls : in List_Id) is Current_Subprogram_Number : Int := 0; Current_Declaration : Node_Id; Loc : constant Source_Ptr := Sloc (Pkg_Spec); RCI_Instantiation : Node_Id; Subp_Stubs : Node_Id; begin -- The first thing added is an instantiation of the generic package -- System.Partition_interface.RCI_Info with the name of the (current) -- remote package. This will act as an interface with the name server -- to determine the Partition_ID and the RPC_Receiver for the -- receiver of this package. RCI_Instantiation := RCI_Package_Locator (Loc, Pkg_Spec); RCI_Cache := Defining_Unit_Name (RCI_Instantiation); Append_To (Decls, RCI_Instantiation); Analyze (RCI_Instantiation); -- For each subprogram declaration visible in the spec, we do -- build a body. We also increment a counter to assign a different -- Subprogram_Id to each subprograms. The receiving stubs processing -- do use the same mechanism and will thus assign the same Id and -- do the correct dispatching. Current_Declaration := First (Visible_Declarations (Pkg_Spec)); while Current_Declaration /= Empty loop if Nkind (Current_Declaration) = N_Subprogram_Declaration and then Comes_From_Source (Current_Declaration) then pragma Assert (Current_Subprogram_Number = Get_Subprogram_Id (Defining_Unit_Name (Specification ( Current_Declaration)))); Subp_Stubs := Build_Subprogram_Calling_Stubs ( Vis_Decl => Current_Declaration, Subp_Id => Current_Subprogram_Number, Asynchronous => Nkind (Specification (Current_Declaration)) = N_Procedure_Specification and then Is_Asynchronous (Defining_Unit_Name (Specification (Current_Declaration)))); Append_To (Decls, Subp_Stubs); Analyze (Subp_Stubs); Current_Subprogram_Number := Current_Subprogram_Number + 1; end if; Next (Current_Declaration); end loop; end Add_Calling_Stubs_To_Declarations; ----------------------- -- Add_RACW_Features -- ----------------------- procedure Add_RACW_Features (RACW_Type : in Entity_Id) is Desig : constant Entity_Id := Etype (Designated_Type (RACW_Type)); Decls : List_Id := List_Containing (Declaration_Node (RACW_Type)); Same_Scope : constant Boolean := Scope (Desig) = Scope (RACW_Type); Stub_Type : Entity_Id; Stub_Type_Access : Entity_Id; Object_RPC_Receiver : Entity_Id; Existing : Boolean; begin if not Expander_Active then return; end if; if Same_Scope then -- We are declaring a RACW in the same package than its designated -- type, so the list to use for late declarations must be the -- private part of the package. We do know that this private part -- exists since the designated type has to be a private one. Decls := Private_Declarations (Package_Specification_Of_Scope (Current_Scope)); elsif Nkind (Parent (Decls)) = N_Package_Specification and then Present (Private_Declarations (Parent (Decls))) then Decls := Private_Declarations (Parent (Decls)); end if; -- If we were unable to find the declarations, that means that the -- completion of the type was missing. We can safely return and let -- the error be caught by the semantic analysis. if No (Decls) then return; end if; Add_Stub_Type (Designated_Type => Desig, RACW_Type => RACW_Type, Decls => Decls, Stub_Type => Stub_Type, Stub_Type_Access => Stub_Type_Access, Object_RPC_Receiver => Object_RPC_Receiver, Existing => Existing); Add_RACW_Read_Write_Attributes (RACW_Type => RACW_Type, Stub_Type => Stub_Type, Stub_Type_Access => Stub_Type_Access, Object_RPC_Receiver => Object_RPC_Receiver, Declarations => Decls); if not Same_Scope and then not Existing then -- The RACW has been declared in another scope than the designated -- type and has not been handled by another RACW in the same -- package as the first one, so add primitive for the stub type -- here. Add_RACW_Primitive_Declarations_And_Bodies (Designated_Type => Desig, Insertion_Node => Parent (Declaration_Node (Object_RPC_Receiver)), Decls => Decls); else Add_Access_Type_To_Process (E => Desig, A => RACW_Type); end if; end Add_RACW_Features; ------------------------------------------------- -- Add_RACW_Primitive_Declarations_And_Bodies -- ------------------------------------------------- procedure Add_RACW_Primitive_Declarations_And_Bodies (Designated_Type : in Entity_Id; Insertion_Node : in Node_Id; Decls : in List_Id) is -- Set sloc of generated declaration to be that of the -- insertion node, so the declarations are recognized as -- belonging to the current package. Loc : constant Source_Ptr := Sloc (Insertion_Node); Stub_Elements : constant Stub_Structure := Stubs_Table.Get (Designated_Type); pragma Assert (Stub_Elements /= Empty_Stub_Structure); Current_Insertion_Node : Node_Id := Insertion_Node; RPC_Receiver_Declarations : List_Id; RPC_Receiver_Statements : List_Id; RPC_Receiver_Case_Alternatives : constant List_Id := New_List; RPC_Receiver_Subp_Id : Entity_Id; Current_Primitive_Elmt : Elmt_Id; Current_Primitive : Entity_Id; Current_Primitive_Body : Node_Id; Current_Primitive_Spec : Node_Id; Current_Primitive_Decl : Node_Id; Current_Primitive_Number : Int := 0; Current_Primitive_Alias : Node_Id; Current_Receiver : Entity_Id; Current_Receiver_Body : Node_Id; RPC_Receiver_Decl : Node_Id; Possibly_Asynchronous : Boolean; begin if not Expander_Active then return; end if; -- Build callers, receivers for every primitive operations and a RPC -- receiver for this type. if Present (Primitive_Operations (Designated_Type)) then Current_Primitive_Elmt := First_Elmt (Primitive_Operations (Designated_Type)); while Current_Primitive_Elmt /= No_Elmt loop Current_Primitive := Node (Current_Primitive_Elmt); -- Copy the primitive of all the parents, except predefined -- ones that are not remotely dispatching. if Chars (Current_Primitive) /= Name_uSize and then Chars (Current_Primitive) /= Name_uDeep_Finalize then -- The first thing to do is build an up-to-date copy of -- the spec with all the formals referencing Designated_Type -- transformed into formals referencing Stub_Type. Since this -- primitive may have been inherited, go back the alias chain -- until the real primitive has been found. Current_Primitive_Alias := Current_Primitive; while Present (Alias (Current_Primitive_Alias)) loop pragma Assert (Current_Primitive_Alias /= Alias (Current_Primitive_Alias)); Current_Primitive_Alias := Alias (Current_Primitive_Alias); end loop; Current_Primitive_Spec := Copy_Specification (Loc, Spec => Parent (Current_Primitive_Alias), Object_Type => Designated_Type, Stub_Type => Stub_Elements.Stub_Type); Current_Primitive_Decl := Make_Subprogram_Declaration (Loc, Specification => Current_Primitive_Spec); Insert_After (Current_Insertion_Node, Current_Primitive_Decl); Analyze (Current_Primitive_Decl); Current_Insertion_Node := Current_Primitive_Decl; Possibly_Asynchronous := Nkind (Current_Primitive_Spec) = N_Procedure_Specification and then Could_Be_Asynchronous (Current_Primitive_Spec); Current_Primitive_Body := Build_Subprogram_Calling_Stubs (Vis_Decl => Current_Primitive_Decl, Subp_Id => Current_Primitive_Number, Asynchronous => Possibly_Asynchronous, Dynamically_Asynchronous => Possibly_Asynchronous, Stub_Type => Stub_Elements.Stub_Type); Append_To (Decls, Current_Primitive_Body); -- Analyzing the body here would cause the Stub type to be -- frozen, thus preventing subsequent primitive declarations. -- For this reason, it will be analyzed later in the -- regular flow. -- Build the receiver stubs Current_Receiver_Body := Build_Subprogram_Receiving_Stubs (Vis_Decl => Current_Primitive_Decl, Asynchronous => Possibly_Asynchronous, Dynamically_Asynchronous => Possibly_Asynchronous, Stub_Type => Stub_Elements.Stub_Type, RACW_Type => Stub_Elements.RACW_Type, Parent_Primitive => Current_Primitive); Current_Receiver := Defining_Unit_Name (Specification (Current_Receiver_Body)); Append_To (Decls, Current_Receiver_Body); -- Add a case alternative to the receiver Append_To (RPC_Receiver_Case_Alternatives, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List ( Make_Integer_Literal (Loc, Current_Primitive_Number)), Statements => New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Current_Receiver, Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Stub_Elements.RPC_Receiver_Stream, Loc), New_Occurrence_Of (Stub_Elements.RPC_Receiver_Result, Loc)))))); -- Increment the index of current primitive Current_Primitive_Number := Current_Primitive_Number + 1; end if; Next_Elmt (Current_Primitive_Elmt); end loop; end if; -- Build the case statement and the heart of the subprogram Append_To (RPC_Receiver_Case_Alternatives, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List (Make_Null_Statement (Loc)))); RPC_Receiver_Subp_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); RPC_Receiver_Declarations := New_List ( Make_Object_Declaration (Loc, Defining_Identifier => RPC_Receiver_Subp_Id, Object_Definition => New_Occurrence_Of (RTE (RE_Subprogram_Id), Loc))); RPC_Receiver_Statements := New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Subprogram_Id), Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stub_Elements.RPC_Receiver_Stream, Loc), New_Occurrence_Of (RPC_Receiver_Subp_Id, Loc)))); Append_To (RPC_Receiver_Statements, Make_Case_Statement (Loc, Expression => New_Occurrence_Of (RPC_Receiver_Subp_Id, Loc), Alternatives => RPC_Receiver_Case_Alternatives)); RPC_Receiver_Decl := Make_Subprogram_Body (Loc, Specification => Copy_Specification (Loc, Parent (Stub_Elements.Object_RPC_Receiver)), Declarations => RPC_Receiver_Declarations, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => RPC_Receiver_Statements)); Append_To (Decls, RPC_Receiver_Decl); -- Do not analyze RPC receiver at this stage since it will otherwise -- reference subprograms that have not been analyzed yet. It will -- be analyzed in the regular flow. end Add_RACW_Primitive_Declarations_And_Bodies; ----------------------------- -- Add_RACW_Read_Attribute -- ----------------------------- procedure Add_RACW_Read_Attribute (RACW_Type : in Entity_Id; Stub_Type : in Entity_Id; Stub_Type_Access : in Entity_Id; Declarations : in List_Id) is Loc : constant Source_Ptr := Sloc (RACW_Type); Proc_Spec : Node_Id; -- Specification and body of the currently built procedure Proc_Body_Spec : Node_Id; Proc_Decl : Node_Id; Attr_Decl : Node_Id; Body_Node : Node_Id; Decls : List_Id; Statements : List_Id; Local_Statements : List_Id; Remote_Statements : List_Id; -- Various parts of the procedure Procedure_Name : constant Name_Id := New_Internal_Name ('R'); Source_Partition : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Source_Receiver : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Source_Address : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Stream_Parameter : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Result : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Stubbed_Result : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Asynchronous_Flag : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Asynchronous_Node : constant Node_Id := New_Occurrence_Of (Standard_False, Loc); begin -- Declare the asynchronous flag. This flag will be changed to True -- whenever it is known that the RACW type is asynchronous. Also, the -- node gets stored since it may be rewritten when we process the -- asynchronous pragma. Append_To (Declarations, Make_Object_Declaration (Loc, Defining_Identifier => Asynchronous_Flag, Constant_Present => True, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => Asynchronous_Node)); Asynchronous_Flags_Table.Set (RACW_Type, Asynchronous_Node); -- Object declarations Decls := New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Source_Partition, Object_Definition => New_Occurrence_Of (RTE (RE_Partition_ID), Loc)), Make_Object_Declaration (Loc, Defining_Identifier => Source_Receiver, Object_Definition => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc)), Make_Object_Declaration (Loc, Defining_Identifier => Source_Address, Object_Definition => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc)), Make_Object_Declaration (Loc, Defining_Identifier => Stubbed_Result, Object_Definition => New_Occurrence_Of (Stub_Type_Access, Loc))); -- Read the source Partition_ID and RPC_Receiver from incoming stream Statements := New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Partition_ID), Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Source_Partition, Loc))), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Source_Receiver, Loc))), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Source_Address, Loc)))); -- If the Address is Null_Address, then return a null object Append_To (Statements, Make_Implicit_If_Statement (RACW_Type, Condition => Make_Op_Eq (Loc, Left_Opnd => New_Occurrence_Of (Source_Address, Loc), Right_Opnd => Make_Integer_Literal (Loc, Uint_0)), Then_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Result, Loc), Expression => Make_Null (Loc)), Make_Return_Statement (Loc)))); -- If the RACW denotes an object created on the current partition, then -- Local_Statements will be executed. The real object will be used. Local_Statements := New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Result, Loc), Expression => Unchecked_Convert_To (RACW_Type, OK_Convert_To (RTE (RE_Address), New_Occurrence_Of (Source_Address, Loc))))); -- If the object is located on another partition, then a stub object -- will be created with all the information needed to rebuild the -- real object at the other end. Remote_Statements := New_List ( Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Stubbed_Result, Loc), Expression => Make_Allocator (Loc, New_Occurrence_Of (Stub_Type, Loc))), Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Stubbed_Result, Loc), Selector_Name => Make_Identifier (Loc, Name_Origin)), Expression => New_Occurrence_Of (Source_Partition, Loc)), Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Stubbed_Result, Loc), Selector_Name => Make_Identifier (Loc, Name_Receiver)), Expression => New_Occurrence_Of (Source_Receiver, Loc)), Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Stubbed_Result, Loc), Selector_Name => Make_Identifier (Loc, Name_Addr)), Expression => New_Occurrence_Of (Source_Address, Loc))); Append_To (Remote_Statements, Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Stubbed_Result, Loc), Selector_Name => Make_Identifier (Loc, Name_Asynchronous)), Expression => New_Occurrence_Of (Asynchronous_Flag, Loc))); Append_To (Remote_Statements, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Get_Unique_Remote_Pointer), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_RACW_Stub_Type_Access), New_Occurrence_Of (Stubbed_Result, Loc))))); Append_To (Remote_Statements, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Result, Loc), Expression => Unchecked_Convert_To (RACW_Type, New_Occurrence_Of (Stubbed_Result, Loc)))); -- Distinguish between the local and remote cases, and execute the -- appropriate piece of code. Append_To (Statements, Make_Implicit_If_Statement (RACW_Type, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Get_Local_Partition_Id), Loc)), Right_Opnd => New_Occurrence_Of (Source_Partition, Loc)), Then_Statements => Local_Statements, Else_Statements => Remote_Statements)); Proc_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Procedure_Name), Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Stream_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Root_Stream_Type), Loc), Attribute_Name => Name_Class))), Make_Parameter_Specification (Loc, Defining_Identifier => Result, Out_Present => True, Parameter_Type => New_Occurrence_Of (RACW_Type, Loc)))); Proc_Body_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Procedure_Name), Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Chars (Stream_Parameter)), Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Root_Stream_Type), Loc), Attribute_Name => Name_Class))), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Chars (Result)), Out_Present => True, Parameter_Type => New_Occurrence_Of (RACW_Type, Loc)))); Body_Node := Make_Subprogram_Body (Loc, Specification => Proc_Body_Spec, Declarations => Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Statements)); Proc_Decl := Make_Subprogram_Declaration (Loc, Specification => Proc_Spec); Attr_Decl := Make_Attribute_Definition_Clause (Loc, Name => New_Occurrence_Of (RACW_Type, Loc), Chars => Name_Read, Expression => New_Occurrence_Of (Defining_Unit_Name (Proc_Spec), Loc)); Insert_After (Declaration_Node (RACW_Type), Proc_Decl); Insert_After (Proc_Decl, Attr_Decl); Append_To (Declarations, Body_Node); end Add_RACW_Read_Attribute; ------------------------------------ -- Add_RACW_Read_Write_Attributes -- ------------------------------------ procedure Add_RACW_Read_Write_Attributes (RACW_Type : in Entity_Id; Stub_Type : in Entity_Id; Stub_Type_Access : in Entity_Id; Object_RPC_Receiver : in Entity_Id; Declarations : in List_Id) is begin Add_RACW_Write_Attribute (RACW_Type => RACW_Type, Stub_Type => Stub_Type, Stub_Type_Access => Stub_Type_Access, Object_RPC_Receiver => Object_RPC_Receiver, Declarations => Declarations); Add_RACW_Read_Attribute (RACW_Type => RACW_Type, Stub_Type => Stub_Type, Stub_Type_Access => Stub_Type_Access, Declarations => Declarations); end Add_RACW_Read_Write_Attributes; ------------------------------ -- Add_RACW_Write_Attribute -- ------------------------------ procedure Add_RACW_Write_Attribute (RACW_Type : in Entity_Id; Stub_Type : in Entity_Id; Stub_Type_Access : in Entity_Id; Object_RPC_Receiver : in Entity_Id; Declarations : in List_Id) is Loc : constant Source_Ptr := Sloc (RACW_Type); Proc_Spec : Node_Id; Proc_Body_Spec : Node_Id; Body_Node : Node_Id; Proc_Decl : Node_Id; Attr_Decl : Node_Id; Statements : List_Id; Local_Statements : List_Id; Remote_Statements : List_Id; Null_Statements : List_Id; Procedure_Name : constant Name_Id := New_Internal_Name ('R'); Stream_Parameter : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Object : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); begin -- Build the code fragment corresponding to the marshalling of a -- local object. Local_Statements := New_List ( Pack_Entity_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => RTE (RE_Get_Local_Partition_Id)), Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => OK_Convert_To (RTE (RE_Unsigned_64), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Object_RPC_Receiver, Loc), Attribute_Name => Name_Address)), Etyp => RTE (RE_Unsigned_64)), Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => OK_Convert_To (RTE (RE_Unsigned_64), Make_Attribute_Reference (Loc, Prefix => Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Object, Loc)), Attribute_Name => Name_Address)), Etyp => RTE (RE_Unsigned_64))); -- Build the code fragment corresponding to the marshalling of -- a remote object. Remote_Statements := New_List ( Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => Make_Selected_Component (Loc, Prefix => Unchecked_Convert_To (Stub_Type_Access, New_Occurrence_Of (Object, Loc)), Selector_Name => Make_Identifier (Loc, Name_Origin)), Etyp => RTE (RE_Partition_ID)), Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => Make_Selected_Component (Loc, Prefix => Unchecked_Convert_To (Stub_Type_Access, New_Occurrence_Of (Object, Loc)), Selector_Name => Make_Identifier (Loc, Name_Receiver)), Etyp => RTE (RE_Unsigned_64)), Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => Make_Selected_Component (Loc, Prefix => Unchecked_Convert_To (Stub_Type_Access, New_Occurrence_Of (Object, Loc)), Selector_Name => Make_Identifier (Loc, Name_Addr)), Etyp => RTE (RE_Unsigned_64))); -- Build the code fragment corresponding to the marshalling of a null -- object. Null_Statements := New_List ( Pack_Entity_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => RTE (RE_Get_Local_Partition_Id)), Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => OK_Convert_To (RTE (RE_Unsigned_64), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Object_RPC_Receiver, Loc), Attribute_Name => Name_Address)), Etyp => RTE (RE_Unsigned_64)), Pack_Node_Into_Stream_Access (Loc, Stream => Stream_Parameter, Object => Make_Integer_Literal (Loc, Uint_0), Etyp => RTE (RE_Unsigned_64))); Statements := New_List ( Make_Implicit_If_Statement (RACW_Type, Condition => Make_Op_Eq (Loc, Left_Opnd => New_Occurrence_Of (Object, Loc), Right_Opnd => Make_Null (Loc)), Then_Statements => Null_Statements, Elsif_Parts => New_List ( Make_Elsif_Part (Loc, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Object, Loc), Attribute_Name => Name_Tag), Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stub_Type, Loc), Attribute_Name => Name_Tag)), Then_Statements => Remote_Statements)), Else_Statements => Local_Statements)); Proc_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Procedure_Name), Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Stream_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Root_Stream_Type), Loc), Attribute_Name => Name_Class))), Make_Parameter_Specification (Loc, Defining_Identifier => Object, In_Present => True, Parameter_Type => New_Occurrence_Of (RACW_Type, Loc)))); Proc_Decl := Make_Subprogram_Declaration (Loc, Specification => Proc_Spec); Attr_Decl := Make_Attribute_Definition_Clause (Loc, Name => New_Occurrence_Of (RACW_Type, Loc), Chars => Name_Write, Expression => New_Occurrence_Of (Defining_Unit_Name (Proc_Spec), Loc)); Proc_Body_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Procedure_Name), Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Chars (Stream_Parameter)), Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Root_Stream_Type), Loc), Attribute_Name => Name_Class))), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Chars (Object)), In_Present => True, Parameter_Type => New_Occurrence_Of (RACW_Type, Loc)))); Body_Node := Make_Subprogram_Body (Loc, Specification => Proc_Body_Spec, Declarations => No_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Statements)); Insert_After (Declaration_Node (RACW_Type), Proc_Decl); Insert_After (Proc_Decl, Attr_Decl); Append_To (Declarations, Body_Node); end Add_RACW_Write_Attribute; ------------------------------ -- Add_RAS_Access_Attribute -- ------------------------------ procedure Add_RAS_Access_Attribute (N : in Node_Id) is Ras_Type : constant Entity_Id := Defining_Identifier (N); Fat_Type : constant Entity_Id := Equivalent_Type (Ras_Type); -- Ras_Type is the access to subprogram type while Fat_Type points to -- the record type corresponding to a remote access to subprogram type. Proc_Decls : constant List_Id := New_List; Proc_Statements : constant List_Id := New_List; Proc_Spec : Node_Id; Proc_Body : Node_Id; Proc : Node_Id; Param : Node_Id; Package_Name : Node_Id; Subp_Id : Node_Id; Asynchronous : Node_Id; Return_Value : Node_Id; Loc : constant Source_Ptr := Sloc (N); procedure Set_Field (Field_Name : in Name_Id; Value : in Node_Id); -- Set a field name for the return value procedure Set_Field (Field_Name : in Name_Id; Value : in Node_Id) is begin Append_To (Proc_Statements, Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Return_Value, Loc), Selector_Name => Make_Identifier (Loc, Field_Name)), Expression => Value)); end Set_Field; -- Start of processing for Add_RAS_Access_Attribute begin Param := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Package_Name := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Subp_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('N')); Asynchronous := Make_Defining_Identifier (Loc, New_Internal_Name ('B')); Return_Value := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); -- Create the object which will be returned of type Fat_Type Append_To (Proc_Decls, Make_Object_Declaration (Loc, Defining_Identifier => Return_Value, Object_Definition => New_Occurrence_Of (Fat_Type, Loc))); -- Initialize the fields of the record type with the appropriate data Set_Field (Name_Ras, OK_Convert_To (RTE (RE_Unsigned_64), New_Occurrence_Of (Param, Loc))); Set_Field (Name_Origin, Unchecked_Convert_To (Standard_Integer, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Get_Active_Partition_Id), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Package_Name, Loc))))); Set_Field (Name_Receiver, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Get_RCI_Package_Receiver), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Package_Name, Loc)))); Set_Field (Name_Subp_Id, New_Occurrence_Of (Subp_Id, Loc)); Set_Field (Name_Async, New_Occurrence_Of (Asynchronous, Loc)); -- Return the newly created value Append_To (Proc_Statements, Make_Return_Statement (Loc, Expression => New_Occurrence_Of (Return_Value, Loc))); Proc := Make_Defining_Identifier (Loc, Name_uRAS_Access); Proc_Spec := Make_Function_Specification (Loc, Defining_Unit_Name => Proc, Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Param, Parameter_Type => New_Occurrence_Of (RTE (RE_Address), Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Package_Name, Parameter_Type => New_Occurrence_Of (Standard_String, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Subp_Id, Parameter_Type => New_Occurrence_Of (Standard_Natural, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Asynchronous, Parameter_Type => New_Occurrence_Of (Standard_Boolean, Loc))), Subtype_Mark => New_Occurrence_Of (Fat_Type, Loc)); -- Set the kind and return type of the function to prevent ambiguities -- between Ras_Type and Fat_Type in subsequent analysis. Set_Ekind (Proc, E_Function); Set_Etype (Proc, New_Occurrence_Of (Fat_Type, Loc)); Proc_Body := Make_Subprogram_Body (Loc, Specification => Proc_Spec, Declarations => Proc_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Proc_Statements)); Set_TSS (Fat_Type, Proc); end Add_RAS_Access_Attribute; ----------------------------------- -- Add_RAS_Dereference_Attribute -- ----------------------------------- procedure Add_RAS_Dereference_Attribute (N : in Node_Id) is Loc : constant Source_Ptr := Sloc (N); Type_Def : constant Node_Id := Type_Definition (N); Ras_Type : constant Entity_Id := Defining_Identifier (N); Fat_Type : constant Entity_Id := Equivalent_Type (Ras_Type); Proc_Decls : constant List_Id := New_List; Proc_Statements : constant List_Id := New_List; Inner_Decls : constant List_Id := New_List; Inner_Statements : constant List_Id := New_List; Direct_Statements : constant List_Id := New_List; Proc : Node_Id; Proc_Spec : Node_Id; Proc_Body : Node_Id; Param_Specs : constant List_Id := New_List; Param_Assoc : constant List_Id := New_List; Pointer : Node_Id; Converted_Ras : Node_Id; Target_Partition : Node_Id; RPC_Receiver : Node_Id; Subprogram_Id : Node_Id; Asynchronous : Node_Id; Is_Function : constant Boolean := Nkind (Type_Def) = N_Access_Function_Definition; Spec : constant Node_Id := Type_Def; Current_Parameter : Node_Id; begin -- The way to do it is test if the Ras field is non-null and then if -- the Origin field is equal to the current partition ID (which is in -- fact Current_Package'Partition_ID). If this is the case, then it -- is safe to dereference the Ras field directly rather than -- performing a remote call. Pointer := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Target_Partition := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Append_To (Proc_Decls, Make_Object_Declaration (Loc, Defining_Identifier => Target_Partition, Constant_Present => True, Object_Definition => New_Occurrence_Of (RTE (RE_Partition_ID), Loc), Expression => Unchecked_Convert_To (RTE (RE_Partition_ID), Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Pointer, Loc), Selector_Name => Make_Identifier (Loc, Name_Origin))))); RPC_Receiver := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Pointer, Loc), Selector_Name => Make_Identifier (Loc, Name_Receiver)); Subprogram_Id := Unchecked_Convert_To (RTE (RE_Subprogram_Id), Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Pointer, Loc), Selector_Name => Make_Identifier (Loc, Name_Subp_Id))); -- A function is never asynchronous. A procedure may or may not be -- asynchronous depending on whether a pragma Asynchronous applies -- on it. Since a RAST may point onto various subprograms, this is -- only known at runtime so both versions (synchronous and asynchronous) -- must be built every times it is not a function. if Is_Function then Asynchronous := Empty; else Asynchronous := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Pointer, Loc), Selector_Name => Make_Identifier (Loc, Name_Async)); end if; if Present (Parameter_Specifications (Type_Def)) then Current_Parameter := First (Parameter_Specifications (Type_Def)); while Current_Parameter /= Empty loop Append_To (Param_Specs, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Chars => Chars (Defining_Identifier (Current_Parameter))), In_Present => In_Present (Current_Parameter), Out_Present => Out_Present (Current_Parameter), Parameter_Type => New_Occurrence_Of (Etype (Parameter_Type (Current_Parameter)), Loc), Expression => New_Copy_Tree (Expression (Current_Parameter)))); Append_To (Param_Assoc, Make_Identifier (Loc, Chars => Chars (Defining_Identifier (Current_Parameter)))); Next (Current_Parameter); end loop; end if; Proc := Make_Defining_Identifier (Loc, Name_uRAS_Dereference); if Is_Function then Proc_Spec := Make_Function_Specification (Loc, Defining_Unit_Name => Proc, Parameter_Specifications => Param_Specs, Subtype_Mark => New_Occurrence_Of ( Entity (Subtype_Mark (Spec)), Loc)); Set_Ekind (Proc, E_Function); Set_Etype (Proc, New_Occurrence_Of (Entity (Subtype_Mark (Spec)), Loc)); else Proc_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Proc, Parameter_Specifications => Param_Specs); Set_Ekind (Proc, E_Procedure); Set_Etype (Proc, Standard_Void_Type); end if; -- Build the calling stubs for the dereference of the RAS Build_General_Calling_Stubs (Decls => Inner_Decls, Statements => Inner_Statements, Target_Partition => Target_Partition, RPC_Receiver => RPC_Receiver, Subprogram_Id => Subprogram_Id, Asynchronous => Asynchronous, Is_Known_Non_Asynchronous => Is_Function, Is_Function => Is_Function, Spec => Proc_Spec, Nod => N); Converted_Ras := Unchecked_Convert_To (Ras_Type, OK_Convert_To (RTE (RE_Address), Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Pointer, Loc), Selector_Name => Make_Identifier (Loc, Name_Ras)))); if Is_Function then Append_To (Direct_Statements, Make_Return_Statement (Loc, Expression => Make_Function_Call (Loc, Name => Make_Explicit_Dereference (Loc, Prefix => Converted_Ras), Parameter_Associations => Param_Assoc))); else Append_To (Direct_Statements, Make_Procedure_Call_Statement (Loc, Name => Make_Explicit_Dereference (Loc, Prefix => Converted_Ras), Parameter_Associations => Param_Assoc)); end if; Prepend_To (Param_Specs, Make_Parameter_Specification (Loc, Defining_Identifier => Pointer, In_Present => True, Parameter_Type => New_Occurrence_Of (Fat_Type, Loc))); Append_To (Proc_Statements, Make_Implicit_If_Statement (N, Condition => Make_And_Then (Loc, Left_Opnd => Make_Op_Ne (Loc, Left_Opnd => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Pointer, Loc), Selector_Name => Make_Identifier (Loc, Name_Ras)), Right_Opnd => Make_Integer_Literal (Loc, Uint_0)), Right_Opnd => Make_Op_Eq (Loc, Left_Opnd => New_Occurrence_Of (Target_Partition, Loc), Right_Opnd => Make_Function_Call (Loc, New_Occurrence_Of ( RTE (RE_Get_Local_Partition_Id), Loc)))), Then_Statements => Direct_Statements, Else_Statements => New_List ( Make_Block_Statement (Loc, Declarations => Inner_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Inner_Statements))))); Proc_Body := Make_Subprogram_Body (Loc, Specification => Proc_Spec, Declarations => Proc_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Proc_Statements)); Set_TSS (Fat_Type, Defining_Unit_Name (Proc_Spec)); end Add_RAS_Dereference_Attribute; ----------------------- -- Add_RAST_Features -- ----------------------- procedure Add_RAST_Features (Vis_Decl : Node_Id) is begin -- Do not add attributes more than once in any case. This should -- be replaced by an assert or this comment removed if we decide -- that this is normal to be called several times ??? if Present (TSS (Equivalent_Type (Defining_Identifier (Vis_Decl)), Name_uRAS_Access)) then return; end if; Add_RAS_Dereference_Attribute (Vis_Decl); Add_RAS_Access_Attribute (Vis_Decl); end Add_RAST_Features; ----------------------------------------- -- Add_Receiving_Stubs_To_Declarations -- ----------------------------------------- procedure Add_Receiving_Stubs_To_Declarations (Pkg_Spec : in Node_Id; Decls : in List_Id) is Loc : constant Source_Ptr := Sloc (Pkg_Spec); Stream_Parameter : Node_Id; Result_Parameter : Node_Id; Pkg_RPC_Receiver : Node_Id; Pkg_RPC_Receiver_Spec : Node_Id; Pkg_RPC_Receiver_Formals : List_Id; Pkg_RPC_Receiver_Decls : List_Id; Pkg_RPC_Receiver_Statements : List_Id; Pkg_RPC_Receiver_Cases : List_Id := New_List; Pkg_RPC_Receiver_Body : Node_Id; -- A Pkg_RPC_Receiver is built to decode the request Subp_Id : Node_Id; -- Subprogram_Id as read from the incoming stream Current_Declaration : Node_Id; Current_Subprogram_Number : Int := 0; Current_Stubs : Node_Id; Actuals : List_Id; Dummy_Register_Name : Name_Id; Dummy_Register_Spec : Node_Id; Dummy_Register_Decl : Node_Id; Dummy_Register_Body : Node_Id; begin -- Building receiving stubs consist in several operations: -- - a package RPC receiver must be built. This subprogram -- will get a Subprogram_Id from the incoming stream -- and will dispatch the call to the right subprogram -- - a receiving stub for any subprogram visible in the package -- spec. This stub will read all the parameters from the stream, -- and put the result as well as the exception occurrence in the -- output stream -- - a dummy package with an empty spec and a body made of an -- elaboration part, whose job is to register the receiving -- part of this RCI package on the name server. This is done -- by calling System.Partition_Interface.Register_Receiving_Stub Stream_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Result_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('R')); Subp_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Pkg_RPC_Receiver := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); -- The parameters of the package RPC receiver are made of two -- streams, an input one and an output one. Pkg_RPC_Receiver_Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Stream_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc))), Make_Parameter_Specification (Loc, Defining_Identifier => Result_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc)))); Pkg_RPC_Receiver_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Pkg_RPC_Receiver, Parameter_Specifications => Pkg_RPC_Receiver_Formals); Pkg_RPC_Receiver_Decls := New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Subp_Id, Object_Definition => New_Occurrence_Of (RTE (RE_Subprogram_Id), Loc))); Pkg_RPC_Receiver_Statements := New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Subprogram_Id), Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Subp_Id, Loc)))); -- For each subprogram, the receiving stub will be built and a -- case statement will be made on the Subprogram_Id to dispatch -- to the right subprogram. Current_Declaration := First (Visible_Declarations (Pkg_Spec)); while Current_Declaration /= Empty loop if Nkind (Current_Declaration) = N_Subprogram_Declaration and then Comes_From_Source (Current_Declaration) then pragma Assert (Current_Subprogram_Number = Get_Subprogram_Id (Defining_Unit_Name (Specification ( Current_Declaration)))); Current_Stubs := Build_Subprogram_Receiving_Stubs (Vis_Decl => Current_Declaration, Asynchronous => Nkind (Specification (Current_Declaration)) = N_Procedure_Specification and then Is_Asynchronous (Defining_Unit_Name (Specification (Current_Declaration)))); Append_To (Decls, Current_Stubs); Analyze (Current_Stubs); Actuals := New_List (New_Occurrence_Of (Stream_Parameter, Loc)); if Nkind (Specification (Current_Declaration)) = N_Function_Specification or else not Is_Asynchronous ( Defining_Entity (Specification (Current_Declaration))) then -- An asynchronous procedure does not want an output parameter -- since no result and no exception will ever be returned. Append_To (Actuals, New_Occurrence_Of (Result_Parameter, Loc)); end if; Append_To (Pkg_RPC_Receiver_Cases, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List ( Make_Integer_Literal (Loc, Current_Subprogram_Number)), Statements => New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of ( Defining_Entity (Current_Stubs), Loc), Parameter_Associations => Actuals)))); Current_Subprogram_Number := Current_Subprogram_Number + 1; end if; Next (Current_Declaration); end loop; -- If we receive an invalid Subprogram_Id, it is best to do nothing -- rather than raising an exception since we do not want someone -- to crash a remote partition by sending invalid subprogram ids. -- This is consistent with the other parts of the case statement -- since even in presence of incorrect parameters in the stream, -- every exception will be caught and (if the subprogram is not an -- APC) put into the result stream and sent away. Append_To (Pkg_RPC_Receiver_Cases, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List (Make_Null_Statement (Loc)))); Append_To (Pkg_RPC_Receiver_Statements, Make_Case_Statement (Loc, Expression => New_Occurrence_Of (Subp_Id, Loc), Alternatives => Pkg_RPC_Receiver_Cases)); Pkg_RPC_Receiver_Body := Make_Subprogram_Body (Loc, Specification => Pkg_RPC_Receiver_Spec, Declarations => Pkg_RPC_Receiver_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Pkg_RPC_Receiver_Statements)); Append_To (Decls, Pkg_RPC_Receiver_Body); Analyze (Pkg_RPC_Receiver_Body); -- Construction of the dummy package used to register the package -- receiving stubs on the nameserver. Dummy_Register_Name := New_Internal_Name ('P'); Dummy_Register_Spec := Make_Package_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Dummy_Register_Name), Visible_Declarations => No_List, End_Label => Empty); Dummy_Register_Decl := Make_Package_Declaration (Loc, Specification => Dummy_Register_Spec); Append_To (Decls, Dummy_Register_Decl); Analyze (Dummy_Register_Decl); Dummy_Register_Body := Make_Package_Body (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Dummy_Register_Name), Declarations => No_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Register_Receiving_Stub), Loc), Parameter_Associations => New_List ( Make_String_Literal (Loc, Strval => Get_Pkg_Name_String_Id (Pkg_Spec)), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Pkg_RPC_Receiver, Loc), Attribute_Name => Name_Unrestricted_Access), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Defining_Entity (Pkg_Spec), Loc), Attribute_Name => Name_Version)))))); Append_To (Decls, Dummy_Register_Body); Analyze (Dummy_Register_Body); end Add_Receiving_Stubs_To_Declarations; ------------------- -- Add_Stub_Type -- ------------------- procedure Add_Stub_Type (Designated_Type : in Entity_Id; RACW_Type : in Entity_Id; Decls : in List_Id; Stub_Type : out Entity_Id; Stub_Type_Access : out Entity_Id; Object_RPC_Receiver : out Entity_Id; Existing : out Boolean) is Loc : constant Source_Ptr := Sloc (RACW_Type); Stub_Elements : constant Stub_Structure := Stubs_Table.Get (Designated_Type); Stub_Type_Declaration : Node_Id; Stub_Type_Access_Declaration : Node_Id; Object_RPC_Receiver_Declaration : Node_Id; RPC_Receiver_Stream : Entity_Id; RPC_Receiver_Result : Entity_Id; begin if Stub_Elements /= Empty_Stub_Structure then Stub_Type := Stub_Elements.Stub_Type; Stub_Type_Access := Stub_Elements.Stub_Type_Access; Object_RPC_Receiver := Stub_Elements.Object_RPC_Receiver; Existing := True; return; end if; Existing := False; Stub_Type := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Stub_Type_Access := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Object_RPC_Receiver := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); RPC_Receiver_Stream := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); RPC_Receiver_Result := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Stubs_Table.Set (Designated_Type, (Stub_Type => Stub_Type, Stub_Type_Access => Stub_Type_Access, Object_RPC_Receiver => Object_RPC_Receiver, RPC_Receiver_Stream => RPC_Receiver_Stream, RPC_Receiver_Result => RPC_Receiver_Result, RACW_Type => RACW_Type)); -- The stub type definition below must match exactly the one in -- s-parint.ads, since unchecked conversions will be used in -- s-parint.adb to modify pointers passed to Get_Unique_Remote_Pointer. Stub_Type_Declaration := Make_Full_Type_Declaration (Loc, Defining_Identifier => Stub_Type, Type_Definition => Make_Record_Definition (Loc, Tagged_Present => True, Limited_Present => True, Component_List => Make_Component_List (Loc, Component_Items => New_List ( Make_Component_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Origin), Subtype_Indication => New_Occurrence_Of (RTE (RE_Partition_ID), Loc)), Make_Component_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Receiver), Subtype_Indication => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc)), Make_Component_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Addr), Subtype_Indication => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc)), Make_Component_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Asynchronous), Subtype_Indication => New_Occurrence_Of (Standard_Boolean, Loc)))))); Append_To (Decls, Stub_Type_Declaration); Analyze (Stub_Type_Declaration); -- This is in no way a type derivation, but we fake it to make -- sure that the dispatching table gets built with the corresponding -- primitive operations at the right place. Derive_Subprograms (Parent_Type => Designated_Type, Derived_Type => Stub_Type); Stub_Type_Access_Declaration := Make_Full_Type_Declaration (Loc, Defining_Identifier => Stub_Type_Access, Type_Definition => Make_Access_To_Object_Definition (Loc, Subtype_Indication => New_Occurrence_Of (Stub_Type, Loc))); Append_To (Decls, Stub_Type_Access_Declaration); Analyze (Stub_Type_Access_Declaration); Object_RPC_Receiver_Declaration := Make_Subprogram_Declaration (Loc, Make_Procedure_Specification (Loc, Defining_Unit_Name => Object_RPC_Receiver, Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => RPC_Receiver_Stream, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc))), Make_Parameter_Specification (Loc, Defining_Identifier => RPC_Receiver_Result, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc)))))); Append_To (Decls, Object_RPC_Receiver_Declaration); end Add_Stub_Type; --------------------------------- -- Build_General_Calling_Stubs -- --------------------------------- procedure Build_General_Calling_Stubs (Decls : List_Id; Statements : List_Id; Target_Partition : Entity_Id; RPC_Receiver : Node_Id; Subprogram_Id : Node_Id; Asynchronous : Node_Id := Empty; Is_Known_Asynchronous : Boolean := False; Is_Known_Non_Asynchronous : Boolean := False; Is_Function : Boolean; Spec : Node_Id; Object_Type : Entity_Id := Empty; Nod : Node_Id) is Loc : constant Source_Ptr := Sloc (Nod); Stream_Parameter : Node_Id; -- Name of the stream used to transmit parameters to the remote package Result_Parameter : Node_Id; -- Name of the result parameter (in non-APC cases) which get the -- result of the remote subprogram. Exception_Return_Parameter : Node_Id; -- Name of the parameter which will hold the exception sent by the -- remote subprogram. Current_Parameter : Node_Id; -- Current parameter being handled Ordered_Parameters_List : constant List_Id := Build_Ordered_Parameters_List (Spec); Asynchronous_Statements : List_Id := No_List; Non_Asynchronous_Statements : List_Id := No_List; -- Statements specifics to the Asynchronous/Non-Asynchronous cases. Extra_Formal_Statements : constant List_Id := New_List; -- List of statements for extra formal parameters. It will appear after -- the regular statements for writing out parameters. begin -- The general form of a calling stub for a given subprogram is: -- procedure X (...) is -- P : constant Partition_ID := RCI_Cache.Get_Active_Partition_ID; -- Stream, Result : aliased System.RPC.Params_Stream_Type (0); -- begin -- Put_Package_RPC_Receiver_In_Stream; (the package RPC receiver -- comes from RCI_Cache.Get_RCI_Package_Receiver) -- Put_Subprogram_Id_In_Stream; -- Put_Parameters_In_Stream; -- Do_RPC (Stream, Result); -- Read_Exception_Occurrence_From_Result; Raise_It; -- Read_Out_Parameters_And_Function_Return_From_Stream; -- end X; -- There are some variations: Do_APC is called for an asynchronous -- procedure and the part after the call is completely ommitted -- as well as the declaration of Result. For a function call, -- 'Input is always used to read the result even if it is constrained. Stream_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Stream_Parameter, Aliased_Present => True, Object_Definition => Make_Subtype_Indication (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc), Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => New_List (Make_Integer_Literal (Loc, 0)))))); if not Is_Known_Asynchronous then Result_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('R')); Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Result_Parameter, Aliased_Present => True, Object_Definition => Make_Subtype_Indication (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc), Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => New_List (Make_Integer_Literal (Loc, 0)))))); Exception_Return_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Exception_Return_Parameter, Object_Definition => New_Occurrence_Of (RTE (RE_Exception_Occurrence), Loc))); else Result_Parameter := Empty; Exception_Return_Parameter := Empty; end if; -- Put first the RPC receiver corresponding to the remote package Append_To (Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Unsigned_64), Loc), Attribute_Name => Name_Write, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), RPC_Receiver))); -- Then put the Subprogram_Id of the subprogram we want to call in -- the stream. Append_To (Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Subprogram_Id), Loc), Attribute_Name => Name_Write, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), Subprogram_Id))); Current_Parameter := First (Ordered_Parameters_List); while Current_Parameter /= Empty loop if Is_RACW_Controlling_Formal (Current_Parameter, Object_Type) then -- In the case of a controlling formal argument, we marshall -- its addr field rather than the local stub. Append_To (Statements, Pack_Node_Into_Stream (Loc, Stream => Stream_Parameter, Object => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc), Selector_Name => Make_Identifier (Loc, Name_Addr)), Etyp => RTE (RE_Unsigned_64))); else declare Etyp : constant Entity_Id := Etype (Parameter_Type (Current_Parameter)); Constrained : constant Boolean := Is_Constrained (Etyp) or else Is_Elementary_Type (Etyp); begin if In_Present (Current_Parameter) or else not Out_Present (Current_Parameter) or else not Constrained then Append_To (Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etyp, Loc), Attribute_Name => Output_From_Constrained (Constrained), Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc)))); end if; end; end if; -- If the current parameter has a dynamic constrained status, -- then this status is transmitted as well. -- This should be done for accessibility as well ??? if Nkind (Parameter_Type (Current_Parameter)) /= N_Access_Definition and then Need_Extra_Constrained (Current_Parameter) then -- In this block, we do not use the extra formal that has been -- created because it does not exist at the time of expansion -- when building calling stubs for remote access to subprogram -- types. We create an extra variable of this type and push it -- in the stream after the regular parameters. declare Extra_Parameter : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); begin Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Extra_Parameter, Constant_Present => True, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc), Attribute_Name => Name_Constrained))); Append_To (Extra_Formal_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Standard_Boolean, Loc), Attribute_Name => Name_Write, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), New_Occurrence_Of (Extra_Parameter, Loc)))); end; end if; Next (Current_Parameter); end loop; -- Append the formal statements list to the statements Append_List_To (Statements, Extra_Formal_Statements); if not Is_Known_Non_Asynchronous then -- Build the call to System.RPC.Do_APC Asynchronous_Statements := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Do_Apc), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Target_Partition, Loc), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access)))); else Asynchronous_Statements := No_List; end if; if not Is_Known_Asynchronous then -- Build the call to System.RPC.Do_RPC Non_Asynchronous_Statements := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Do_Rpc), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Target_Partition, Loc), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Result_Parameter, Loc), Attribute_Name => Name_Access)))); -- Read the exception occurrence from the result stream and -- reraise it. It does no harm if this is a Null_Occurrence since -- this does nothing. Append_To (Non_Asynchronous_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Exception_Occurrence), Loc), Attribute_Name => Name_Read, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Result_Parameter, Loc), Attribute_Name => Name_Access), New_Occurrence_Of (Exception_Return_Parameter, Loc)))); Append_To (Non_Asynchronous_Statements, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Reraise_Occurrence), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Exception_Return_Parameter, Loc)))); if Is_Function then -- If this is a function call, then read the value and return -- it. The return value is written/read using 'Output/'Input. Append_To (Non_Asynchronous_Statements, Make_Tag_Check (Loc, Make_Return_Statement (Loc, Expression => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of ( Etype (Subtype_Mark (Spec)), Loc), Attribute_Name => Name_Input, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Result_Parameter, Loc), Attribute_Name => Name_Access)))))); else -- Loop around parameters and assign out (or in out) parameters. -- In the case of RACW, controlling arguments cannot possibly -- have changed since they are remote, so we do not read them -- from the stream. Current_Parameter := First (Ordered_Parameters_List); while Current_Parameter /= Empty loop if Out_Present (Current_Parameter) and then Etype (Parameter_Type (Current_Parameter)) /= Object_Type then Append_To (Non_Asynchronous_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of ( Etype (Parameter_Type (Current_Parameter)), Loc), Attribute_Name => Name_Read, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Result_Parameter, Loc), Attribute_Name => Name_Access), New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc)))); end if; Next (Current_Parameter); end loop; end if; end if; if Is_Known_Asynchronous then Append_List_To (Statements, Asynchronous_Statements); elsif Is_Known_Non_Asynchronous then Append_List_To (Statements, Non_Asynchronous_Statements); else pragma Assert (Asynchronous /= Empty); Prepend_To (Asynchronous_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Standard_Boolean, Loc), Attribute_Name => Name_Write, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), New_Occurrence_Of (Standard_True, Loc)))); Prepend_To (Non_Asynchronous_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Standard_Boolean, Loc), Attribute_Name => Name_Write, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream_Parameter, Loc), Attribute_Name => Name_Access), New_Occurrence_Of (Standard_False, Loc)))); Append_To (Statements, Make_Implicit_If_Statement (Nod, Condition => Asynchronous, Then_Statements => Asynchronous_Statements, Else_Statements => Non_Asynchronous_Statements)); end if; end Build_General_Calling_Stubs; ----------------------------------- -- Build_Ordered_Parameters_List -- ----------------------------------- function Build_Ordered_Parameters_List (Spec : Node_Id) return List_Id is Constrained_List : List_Id; Unconstrained_List : List_Id; Current_Parameter : Node_Id; begin if not Present (Parameter_Specifications (Spec)) then return New_List; end if; Constrained_List := New_List; Unconstrained_List := New_List; -- Loop through the parameters and add them to the right list Current_Parameter := First (Parameter_Specifications (Spec)); while Current_Parameter /= Empty loop if Nkind (Parameter_Type (Current_Parameter)) = N_Access_Definition or else Is_Constrained (Etype (Parameter_Type (Current_Parameter))) or else Is_Elementary_Type (Etype (Parameter_Type (Current_Parameter))) then Append_To (Constrained_List, New_Copy (Current_Parameter)); else Append_To (Unconstrained_List, New_Copy (Current_Parameter)); end if; Next (Current_Parameter); end loop; -- Unconstrained parameters are returned first Append_List_To (Unconstrained_List, Constrained_List); return Unconstrained_List; end Build_Ordered_Parameters_List; ---------------------------------- -- Build_Passive_Partition_Stub -- ---------------------------------- procedure Build_Passive_Partition_Stub (U : Node_Id) is Pkg_Spec : Node_Id; L : List_Id; Reg : Node_Id; Loc : constant Source_Ptr := Sloc (U); Dist_OK : Entity_Id; begin -- Verify that the implementation supports distribution, by accessing -- a type defined in the proper version of system.rpc Dist_OK := RTE (RE_Params_Stream_Type); -- Use body if present, spec otherwise if Nkind (U) = N_Package_Declaration then Pkg_Spec := Specification (U); L := Visible_Declarations (Pkg_Spec); else Pkg_Spec := Parent (Corresponding_Spec (U)); L := Declarations (U); end if; Reg := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Register_Passive_Package), Loc), Parameter_Associations => New_List ( Make_String_Literal (Loc, Get_Pkg_Name_String_Id (Pkg_Spec)), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Defining_Entity (Pkg_Spec), Loc), Attribute_Name => Name_Version))); Append_To (L, Reg); Analyze (Reg); end Build_Passive_Partition_Stub; ------------------------------------ -- Build_Subprogram_Calling_Stubs -- ------------------------------------ function Build_Subprogram_Calling_Stubs (Vis_Decl : Node_Id; Subp_Id : Int; Asynchronous : Boolean; Dynamically_Asynchronous : Boolean := False; Stub_Type : Entity_Id := Empty; Locator : Entity_Id := Empty; New_Name : Name_Id := No_Name) return Node_Id is Loc : constant Source_Ptr := Sloc (Vis_Decl); Target_Partition : Node_Id; -- Contains the name of the target partition Decls : constant List_Id := New_List; Statements : constant List_Id := New_List; Subp_Spec : Node_Id; -- The specification of the body Controlling_Parameter : Entity_Id := Empty; RPC_Receiver : Node_Id; Asynchronous_Expr : Node_Id := Empty; RCI_Locator : Entity_Id; Spec_To_Use : Node_Id; procedure Insert_Partition_Check (Parameter : in Node_Id); -- Check that the parameter has been elaborated on the same partition -- than the controlling parameter (E.4(19)). ---------------------------- -- Insert_Partition_Check -- ---------------------------- procedure Insert_Partition_Check (Parameter : in Node_Id) is Parameter_Entity : constant Entity_Id := Defining_Identifier (Parameter); Designated_Object : Node_Id; Condition : Node_Id; begin -- The expression that will be built is of the form: -- if not (Parameter in Stub_Type and then -- Parameter.Origin = Controlling.Origin) -- then -- raise Constraint_Error; -- end if; -- -- Condition contains the reversed condition. Also, Parameter is -- dereferenced if it is an access type. We do not check that -- Parameter is in Stub_Type since such a check has been inserted -- at the point of call already (a tag check since we have multiple -- controlling operands). if Nkind (Parameter_Type (Parameter)) = N_Access_Definition then Designated_Object := Make_Explicit_Dereference (Loc, Prefix => New_Occurrence_Of (Parameter_Entity, Loc)); else Designated_Object := New_Occurrence_Of (Parameter_Entity, Loc); end if; Condition := Make_Op_Eq (Loc, Left_Opnd => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Parameter_Entity, Loc), Selector_Name => Make_Identifier (Loc, Name_Origin)), Right_Opnd => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Controlling_Parameter, Loc), Selector_Name => Make_Identifier (Loc, Name_Origin))); Append_To (Decls, Make_Raise_Constraint_Error (Loc, Condition => Make_Op_Not (Loc, Right_Opnd => Condition))); end Insert_Partition_Check; -- Start of processing for Build_Subprogram_Calling_Stubs begin Target_Partition := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Subp_Spec := Copy_Specification (Loc, Spec => Specification (Vis_Decl), New_Name => New_Name); if Locator = Empty then RCI_Locator := RCI_Cache; Spec_To_Use := Specification (Vis_Decl); else RCI_Locator := Locator; Spec_To_Use := Subp_Spec; end if; -- Find a controlling argument if we have a stub type. Also check -- if this subprogram can be made asynchronous. if Stub_Type /= Empty and then Present (Parameter_Specifications (Spec_To_Use)) then declare Current_Parameter : Node_Id := First (Parameter_Specifications (Spec_To_Use)); begin while Current_Parameter /= Empty loop if Is_RACW_Controlling_Formal (Current_Parameter, Stub_Type) then if Controlling_Parameter = Empty then Controlling_Parameter := Defining_Identifier (Current_Parameter); else Insert_Partition_Check (Current_Parameter); end if; end if; Next (Current_Parameter); end loop; end; end if; if Stub_Type /= Empty then pragma Assert (Controlling_Parameter /= Empty); Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Target_Partition, Constant_Present => True, Object_Definition => New_Occurrence_Of (RTE (RE_Partition_ID), Loc), Expression => Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Controlling_Parameter, Loc), Selector_Name => Make_Identifier (Loc, Name_Origin)))); RPC_Receiver := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Controlling_Parameter, Loc), Selector_Name => Make_Identifier (Loc, Name_Receiver)); else Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Target_Partition, Constant_Present => True, Object_Definition => New_Occurrence_Of (RTE (RE_Partition_ID), Loc), Expression => Make_Function_Call (Loc, Name => Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Chars (RCI_Locator)), Selector_Name => Make_Identifier (Loc, Name_Get_Active_Partition_ID))))); RPC_Receiver := Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Chars (RCI_Locator)), Selector_Name => Make_Identifier (Loc, Name_Get_RCI_Package_Receiver)); end if; if Dynamically_Asynchronous then Asynchronous_Expr := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (Controlling_Parameter, Loc), Selector_Name => Make_Identifier (Loc, Name_Asynchronous)); end if; Build_General_Calling_Stubs (Decls => Decls, Statements => Statements, Target_Partition => Target_Partition, RPC_Receiver => RPC_Receiver, Subprogram_Id => Make_Integer_Literal (Loc, Subp_Id), Asynchronous => Asynchronous_Expr, Is_Known_Asynchronous => Asynchronous and then not Dynamically_Asynchronous, Is_Known_Non_Asynchronous => not Asynchronous and then not Dynamically_Asynchronous, Is_Function => Nkind (Spec_To_Use) = N_Function_Specification, Spec => Spec_To_Use, Object_Type => Stub_Type, Nod => Vis_Decl); RCI_Calling_Stubs_Table.Set (Defining_Unit_Name (Specification (Vis_Decl)), Defining_Unit_Name (Spec_To_Use)); return Make_Subprogram_Body (Loc, Specification => Subp_Spec, Declarations => Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements)); end Build_Subprogram_Calling_Stubs; -------------------------------------- -- Build_Subprogram_Receiving_Stubs -- -------------------------------------- function Build_Subprogram_Receiving_Stubs (Vis_Decl : Node_Id; Asynchronous : Boolean; Dynamically_Asynchronous : Boolean := False; Stub_Type : Entity_Id := Empty; RACW_Type : Entity_Id := Empty; Parent_Primitive : Entity_Id := Empty) return Node_Id is Loc : constant Source_Ptr := Sloc (Vis_Decl); Stream_Parameter : Node_Id; Result_Parameter : Node_Id; -- See explanations of those in Build_Subprogram_Calling_Stubs Decls : List_Id := New_List; -- All the parameters will get declared before calling the real -- subprograms. Also the out parameters will be declared. Statements : List_Id := New_List; Extra_Formal_Statements : List_Id := New_List; -- Statements concerning extra formal parameters After_Statements : List_Id := New_List; -- Statements to be executed after the subprogram call Inner_Decls : List_Id := No_List; -- In case of a function, the inner declarations are needed since -- the result may be unconstrained. Excep_Handler : Node_Id; Excep_Choice : Entity_Id; Excep_Code : List_Id; Parameter_List : List_Id := New_List; -- List of parameters to be passed to the subprogram. Current_Parameter : Node_Id; Ordered_Parameters_List : constant List_Id := Build_Ordered_Parameters_List (Specification (Vis_Decl)); Subp_Spec : Node_Id; -- Subprogram specification Called_Subprogram : Node_Id; -- The subprogram to call Null_Raise_Statement : Node_Id; Dynamic_Async : Entity_Id; begin if RACW_Type /= Empty then Called_Subprogram := New_Occurrence_Of (Parent_Primitive, Loc); else Called_Subprogram := New_Occurrence_Of ( Defining_Unit_Name (Specification (Vis_Decl)), Loc); end if; Stream_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); if Dynamically_Asynchronous then Dynamic_Async := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); else Dynamic_Async := Empty; end if; if not Asynchronous or else Dynamically_Asynchronous then Result_Parameter := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); -- The first statement after the subprogram call is a statement to -- writes a Null_Occurrence into the result stream. Null_Raise_Statement := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Exception_Occurrence), Loc), Attribute_Name => Name_Write, Expressions => New_List ( New_Occurrence_Of (Result_Parameter, Loc), New_Occurrence_Of (RTE (RE_Null_Occurrence), Loc))); if Dynamically_Asynchronous then Null_Raise_Statement := Make_Implicit_If_Statement (Vis_Decl, Condition => Make_Op_Not (Loc, New_Occurrence_Of (Dynamic_Async, Loc)), Then_Statements => New_List (Null_Raise_Statement)); end if; Append_To (After_Statements, Null_Raise_Statement); else Result_Parameter := Empty; end if; -- Loop through every parameter and get its value from the stream. If -- the parameter is unconstrained, then the parameter is read using -- 'Input at the point of declaration. Current_Parameter := First (Ordered_Parameters_List); while Current_Parameter /= Empty loop declare Etyp : Entity_Id; Constrained : Boolean; Object : Entity_Id; Expr : Node_Id := Empty; begin Object := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Set_Ekind (Object, E_Variable); if Is_RACW_Controlling_Formal (Current_Parameter, Stub_Type) then -- We have a controlling formal parameter. Read its address -- rather than a real object. The address is in Unsigned_64 -- form. Etyp := RTE (RE_Unsigned_64); else Etyp := Etype (Parameter_Type (Current_Parameter)); end if; Constrained := Is_Constrained (Etyp) or else Is_Elementary_Type (Etyp); if In_Present (Current_Parameter) or else not Out_Present (Current_Parameter) or else not Constrained then -- If an input parameter is contrained, then its reading is -- deferred until the beginning of the subprogram body. If -- it is unconstrained, then an expression is built for -- the object declaration and the variable is set using -- 'Input instead of 'Read. if Constrained then Append_To (Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etyp, Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Object, Loc)))); else Expr := Input_With_Tag_Check (Loc, Var_Type => Etyp, Stream => Stream_Parameter); Append_To (Decls, Expr); Expr := Make_Function_Call (Loc, New_Occurrence_Of (Defining_Unit_Name (Specification (Expr)), Loc)); end if; end if; -- If we do not have to output the current parameter, then -- it can well be flagged as constant. This may allow further -- optimizations done by the back end. Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Object, Constant_Present => not Constrained and then not Out_Present (Current_Parameter), Object_Definition => New_Occurrence_Of (Etyp, Loc), Expression => Expr)); -- An out parameter may be written back using a 'Write -- attribute instead of a 'Output because it has been -- constrained by the parameter given to the caller. Note that -- out controlling arguments in the case of a RACW are not put -- back in the stream because the pointer on them has not -- changed. if Out_Present (Current_Parameter) and then Etype (Parameter_Type (Current_Parameter)) /= Stub_Type then Append_To (After_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etyp, Loc), Attribute_Name => Name_Write, Expressions => New_List ( New_Occurrence_Of (Result_Parameter, Loc), New_Occurrence_Of (Object, Loc)))); end if; if Is_RACW_Controlling_Formal (Current_Parameter, Stub_Type) then if Nkind (Parameter_Type (Current_Parameter)) /= N_Access_Definition then Append_To (Parameter_List, Make_Parameter_Association (Loc, Selector_Name => New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc), Explicit_Actual_Parameter => Make_Explicit_Dereference (Loc, Unchecked_Convert_To (RACW_Type, OK_Convert_To (RTE (RE_Address), New_Occurrence_Of (Object, Loc)))))); else Append_To (Parameter_List, Make_Parameter_Association (Loc, Selector_Name => New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc), Explicit_Actual_Parameter => Unchecked_Convert_To (RACW_Type, OK_Convert_To (RTE (RE_Address), New_Occurrence_Of (Object, Loc))))); end if; else Append_To (Parameter_List, Make_Parameter_Association (Loc, Selector_Name => New_Occurrence_Of ( Defining_Identifier (Current_Parameter), Loc), Explicit_Actual_Parameter => New_Occurrence_Of (Object, Loc))); end if; -- If the current parameter needs an extra formal, then read it -- from the stream and set the corresponding semantic field in -- the variable. If the kind of the parameter identifier is -- E_Void, then this is a compiler generated parameter that -- doesn't need an extra constrained status. -- The case of Extra_Accessibility should also be handled ??? if Nkind (Parameter_Type (Current_Parameter)) /= N_Access_Definition and then Ekind (Defining_Identifier (Current_Parameter)) /= E_Void and then Present (Extra_Constrained (Defining_Identifier (Current_Parameter))) then declare Extra_Parameter : constant Entity_Id := Extra_Constrained (Defining_Identifier (Current_Parameter)); Formal_Entity : constant Entity_Id := Make_Defining_Identifier (Loc, Chars (Extra_Parameter)); Formal_Type : constant Entity_Id := Etype (Extra_Parameter); begin Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Formal_Entity, Object_Definition => New_Occurrence_Of (Formal_Type, Loc))); Append_To (Extra_Formal_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Formal_Type, Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Formal_Entity, Loc)))); Set_Extra_Constrained (Object, Formal_Entity); end; end if; end; Next (Current_Parameter); end loop; -- Append the formal statements list at the end of regular statements Append_List_To (Statements, Extra_Formal_Statements); if Nkind (Specification (Vis_Decl)) = N_Function_Specification then -- The remote subprogram is a function. We build an inner block to -- be able to hold a potentially unconstrained result in a variable. declare Etyp : constant Entity_Id := Etype (Subtype_Mark (Specification (Vis_Decl))); Result : constant Node_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('R')); begin Inner_Decls := New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Result, Constant_Present => True, Object_Definition => New_Occurrence_Of (Etyp, Loc), Expression => Make_Function_Call (Loc, Name => Called_Subprogram, Parameter_Associations => Parameter_List))); Append_To (After_Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etyp, Loc), Attribute_Name => Name_Output, Expressions => New_List ( New_Occurrence_Of (Result_Parameter, Loc), New_Occurrence_Of (Result, Loc)))); end; Append_To (Statements, Make_Block_Statement (Loc, Declarations => Inner_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => After_Statements))); else -- The remote subprogram is a procedure. We do not need any inner -- block in this case. if Dynamically_Asynchronous then Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Dynamic_Async, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc))); Append_To (Statements, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Standard_Boolean, Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Occurrence_Of (Stream_Parameter, Loc), New_Occurrence_Of (Dynamic_Async, Loc)))); end if; Append_To (Statements, Make_Procedure_Call_Statement (Loc, Name => Called_Subprogram, Parameter_Associations => Parameter_List)); Append_List_To (Statements, After_Statements); end if; if Asynchronous and then not Dynamically_Asynchronous then -- An asynchronous procedure does not want a Result -- parameter. Also, we put an exception handler with an others -- clause that does nothing. Subp_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, New_Internal_Name ('F')), Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Stream_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc))))); Excep_Handler := Make_Exception_Handler (Loc, Exception_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( Make_Null_Statement (Loc))); else -- In the other cases, if an exception is raised, then the -- exception occurrence is copied into the output stream and -- no other output parameter is written. Excep_Choice := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); Excep_Code := New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (RTE (RE_Exception_Occurrence), Loc), Attribute_Name => Name_Write, Expressions => New_List ( New_Occurrence_Of (Result_Parameter, Loc), New_Occurrence_Of (Excep_Choice, Loc)))); if Dynamically_Asynchronous then Excep_Code := New_List ( Make_Implicit_If_Statement (Vis_Decl, Condition => Make_Op_Not (Loc, New_Occurrence_Of (Dynamic_Async, Loc)), Then_Statements => Excep_Code)); end if; Excep_Handler := Make_Exception_Handler (Loc, Choice_Parameter => Excep_Choice, Exception_Choices => New_List (Make_Others_Choice (Loc)), Statements => Excep_Code); Subp_Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, New_Internal_Name ('F')), Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Stream_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc))), Make_Parameter_Specification (Loc, Defining_Identifier => Result_Parameter, Parameter_Type => Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Params_Stream_Type), Loc))))); end if; return Make_Subprogram_Body (Loc, Specification => Subp_Spec, Declarations => Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Statements, Exception_Handlers => New_List (Excep_Handler))); end Build_Subprogram_Receiving_Stubs; ------------------------ -- Copy_Specification -- ------------------------ function Copy_Specification (Loc : Source_Ptr; Spec : Node_Id; Object_Type : Entity_Id := Empty; Stub_Type : Entity_Id := Empty; New_Name : Name_Id := No_Name) return Node_Id is Parameters : List_Id := No_List; Current_Parameter : Node_Id; Current_Type : Node_Id; Name_For_New_Spec : Name_Id; New_Identifier : Entity_Id; begin if New_Name = No_Name then Name_For_New_Spec := Chars (Defining_Unit_Name (Spec)); else Name_For_New_Spec := New_Name; end if; if Present (Parameter_Specifications (Spec)) then Parameters := New_List; Current_Parameter := First (Parameter_Specifications (Spec)); while Current_Parameter /= Empty loop Current_Type := Parameter_Type (Current_Parameter); if Nkind (Current_Type) = N_Access_Definition then if Object_Type = Empty then Current_Type := Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (Etype ( Subtype_Mark (Current_Type)), Loc)); else pragma Assert (Root_Type (Etype (Subtype_Mark (Current_Type))) = Root_Type (Object_Type)); Current_Type := Make_Access_Definition (Loc, Subtype_Mark => New_Occurrence_Of (Stub_Type, Loc)); end if; elsif Object_Type /= Empty and then Etype (Current_Type) = Object_Type then Current_Type := New_Occurrence_Of (Stub_Type, Loc); else Current_Type := New_Occurrence_Of (Etype (Current_Type), Loc); end if; New_Identifier := Make_Defining_Identifier (Loc, Chars (Defining_Identifier (Current_Parameter))); Append_To (Parameters, Make_Parameter_Specification (Loc, Defining_Identifier => New_Identifier, Parameter_Type => Current_Type, In_Present => In_Present (Current_Parameter), Out_Present => Out_Present (Current_Parameter), Expression => New_Copy_Tree (Expression (Current_Parameter)))); Next (Current_Parameter); end loop; end if; if Nkind (Spec) = N_Function_Specification then return Make_Function_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Chars => Name_For_New_Spec), Parameter_Specifications => Parameters, Subtype_Mark => New_Occurrence_Of (Etype (Subtype_Mark (Spec)), Loc)); else return Make_Procedure_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, Chars => Name_For_New_Spec), Parameter_Specifications => Parameters); end if; end Copy_Specification; --------------------------- -- Could_Be_Asynchronous -- --------------------------- function Could_Be_Asynchronous (Spec : Node_Id) return Boolean is Current_Parameter : Node_Id; begin if Present (Parameter_Specifications (Spec)) then Current_Parameter := First (Parameter_Specifications (Spec)); while Current_Parameter /= Empty loop if Out_Present (Current_Parameter) then return False; end if; Next (Current_Parameter); end loop; end if; return True; end Could_Be_Asynchronous; --------------------------------------------- -- Expand_All_Calls_Remote_Subprogram_Call -- --------------------------------------------- procedure Expand_All_Calls_Remote_Subprogram_Call (N : in Node_Id) is Called_Subprogram : constant Entity_Id := Entity (Name (N)); RCI_Package : constant Entity_Id := Scope (Called_Subprogram); Loc : constant Source_Ptr := Sloc (N); RCI_Locator : Node_Id; RCI_Cache : Entity_Id; Calling_Stubs : Node_Id; E_Calling_Stubs : Entity_Id; begin E_Calling_Stubs := RCI_Calling_Stubs_Table.Get (Called_Subprogram); if E_Calling_Stubs = Empty then RCI_Cache := RCI_Locator_Table.Get (RCI_Package); if RCI_Cache = Empty then RCI_Locator := RCI_Package_Locator (Loc, Specification (Unit_Declaration_Node (RCI_Package))); Prepend_To (Current_Sem_Unit_Declarations, RCI_Locator); -- The RCI_Locator package is inserted at the top level in the -- current unit, and must appear in the proper scope, so that it -- is not prematurely removed by the GCC back-end. declare Scop : Entity_Id := Cunit_Entity (Current_Sem_Unit); begin if Ekind (Scop) = E_Package_Body then New_Scope (Spec_Entity (Scop)); elsif Ekind (Scop) = E_Subprogram_Body then New_Scope (Corresponding_Spec (Unit_Declaration_Node (Scop))); else New_Scope (Scop); end if; Analyze (RCI_Locator); Pop_Scope; end; RCI_Cache := Defining_Unit_Name (RCI_Locator); else RCI_Locator := Parent (RCI_Cache); end if; Calling_Stubs := Build_Subprogram_Calling_Stubs (Vis_Decl => Parent (Parent (Called_Subprogram)), Subp_Id => Get_Subprogram_Id (Called_Subprogram), Asynchronous => Nkind (N) = N_Procedure_Call_Statement and then Is_Asynchronous (Called_Subprogram), Locator => RCI_Cache, New_Name => New_Internal_Name ('S')); Insert_After (RCI_Locator, Calling_Stubs); Analyze (Calling_Stubs); E_Calling_Stubs := Defining_Unit_Name (Specification (Calling_Stubs)); end if; Rewrite (Name (N), New_Occurrence_Of (E_Calling_Stubs, Loc)); end Expand_All_Calls_Remote_Subprogram_Call; --------------------------------- -- Expand_Calling_Stubs_Bodies -- --------------------------------- procedure Expand_Calling_Stubs_Bodies (Unit_Node : in Node_Id) is Spec : constant Node_Id := Specification (Unit_Node); Decls : constant List_Id := Visible_Declarations (Spec); begin New_Scope (Scope_Of_Spec (Spec)); Add_Calling_Stubs_To_Declarations (Specification (Unit_Node), Decls); Pop_Scope; end Expand_Calling_Stubs_Bodies; ----------------------------------- -- Expand_Receiving_Stubs_Bodies -- ----------------------------------- procedure Expand_Receiving_Stubs_Bodies (Unit_Node : in Node_Id) is Spec : Node_Id; Decls : List_Id; Temp : List_Id; begin if Nkind (Unit_Node) = N_Package_Declaration then Spec := Specification (Unit_Node); Decls := Visible_Declarations (Spec); New_Scope (Scope_Of_Spec (Spec)); Add_Receiving_Stubs_To_Declarations (Spec, Decls); else Spec := Package_Specification_Of_Scope (Corresponding_Spec (Unit_Node)); Decls := Declarations (Unit_Node); New_Scope (Scope_Of_Spec (Unit_Node)); Temp := New_List; Add_Receiving_Stubs_To_Declarations (Spec, Temp); Insert_List_Before (First (Decls), Temp); end if; Pop_Scope; end Expand_Receiving_Stubs_Bodies; ---------------------------- -- Get_Pkg_Name_string_Id -- ---------------------------- function Get_Pkg_Name_String_Id (Decl_Node : Node_Id) return String_Id is Unit_Name_Id : Unit_Name_Type := Get_Unit_Name (Decl_Node); begin Get_Unit_Name_String (Unit_Name_Id); -- Remove seven last character (" (spec)" or " (body)"). Name_Len := Name_Len - 7; pragma Assert (Name_Buffer (Name_Len + 1) = ' '); return Get_String_Id (Name_Buffer (1 .. Name_Len)); end Get_Pkg_Name_String_Id; ------------------- -- Get_String_Id -- ------------------- function Get_String_Id (Val : String) return String_Id is begin Start_String; Store_String_Chars (Val); return End_String; end Get_String_Id; ---------- -- Hash -- ---------- function Hash (F : Entity_Id) return Hash_Index is begin return Hash_Index (Natural (F) mod Positive (Hash_Index'Last + 1)); end Hash; -------------------------- -- Input_With_Tag_Check -- -------------------------- function Input_With_Tag_Check (Loc : Source_Ptr; Var_Type : Entity_Id; Stream : Entity_Id) return Node_Id is begin return Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, New_Internal_Name ('S')), Subtype_Mark => New_Occurrence_Of (Var_Type, Loc)), Declarations => No_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, New_List ( Make_Tag_Check (Loc, Make_Return_Statement (Loc, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Var_Type, Loc), Attribute_Name => Name_Input, Expressions => New_List (New_Occurrence_Of (Stream, Loc)))))))); end Input_With_Tag_Check; -------------------------------- -- Is_RACW_Controlling_Formal -- -------------------------------- function Is_RACW_Controlling_Formal (Parameter : Node_Id; Stub_Type : Entity_Id) return Boolean is Typ : Entity_Id; begin -- If the kind of the parameter is E_Void, then it is not a -- controlling formal (this can happen in the context of RAS). if Ekind (Defining_Identifier (Parameter)) = E_Void then return False; end if; -- If the parameter is not a controlling formal, then it cannot -- be possibly a RACW_Controlling_Formal. if not Is_Controlling_Formal (Defining_Identifier (Parameter)) then return False; end if; Typ := Parameter_Type (Parameter); return (Nkind (Typ) = N_Access_Definition and then Etype (Subtype_Mark (Typ)) = Stub_Type) or else Etype (Typ) = Stub_Type; end Is_RACW_Controlling_Formal; -------------------- -- Make_Tag_Check -- -------------------- function Make_Tag_Check (Loc : Source_Ptr; N : Node_Id) return Node_Id is Occ : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); begin return Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (N), Exception_Handlers => New_List ( Make_Exception_Handler (Loc, Choice_Parameter => Occ, Exception_Choices => New_List (New_Occurrence_Of (RTE (RE_Tag_Error), Loc)), Statements => New_List (Make_Procedure_Call_Statement (Loc, New_Occurrence_Of (RTE (RE_Raise_Program_Error_Unknown_Tag), Loc), New_List (New_Occurrence_Of (Occ, Loc)))))))); end Make_Tag_Check; ---------------------------- -- Need_Extra_Constrained -- ---------------------------- function Need_Extra_Constrained (Parameter : Node_Id) return Boolean is Etyp : constant Entity_Id := Etype (Parameter_Type (Parameter)); begin return Out_Present (Parameter) and then Has_Discriminants (Etyp) and then not Is_Constrained (Etyp) and then not Is_Indefinite_Subtype (Etyp); end Need_Extra_Constrained; ------------------------------------ -- Pack_Entity_Into_Stream_Access -- ------------------------------------ function Pack_Entity_Into_Stream_Access (Loc : Source_Ptr; Stream : Entity_Id; Object : Entity_Id; Etyp : Entity_Id := Empty) return Node_Id is Typ : Entity_Id; begin if Etyp /= Empty then Typ := Etyp; else Typ := Etype (Object); end if; return Pack_Node_Into_Stream_Access (Loc, Stream => Stream, Object => New_Occurrence_Of (Object, Loc), Etyp => Typ); end Pack_Entity_Into_Stream_Access; --------------------------- -- Pack_Node_Into_Stream -- --------------------------- function Pack_Node_Into_Stream (Loc : Source_Ptr; Stream : Entity_Id; Object : Node_Id; Etyp : Entity_Id) return Node_Id is Write_Attribute : Name_Id := Name_Write; begin if not Is_Constrained (Etyp) then Write_Attribute := Name_Output; end if; return Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etyp, Loc), Attribute_Name => Write_Attribute, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Stream, Loc), Attribute_Name => Name_Access), Object)); end Pack_Node_Into_Stream; ---------------------------------- -- Pack_Node_Into_Stream_Access -- ---------------------------------- function Pack_Node_Into_Stream_Access (Loc : Source_Ptr; Stream : Entity_Id; Object : Node_Id; Etyp : Entity_Id) return Node_Id is Write_Attribute : Name_Id := Name_Write; begin if not Is_Constrained (Etyp) then Write_Attribute := Name_Output; end if; return Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etyp, Loc), Attribute_Name => Write_Attribute, Expressions => New_List ( New_Occurrence_Of (Stream, Loc), Object)); end Pack_Node_Into_Stream_Access; ------------------------------- -- RACW_Type_Is_Asynchronous -- ------------------------------- procedure RACW_Type_Is_Asynchronous (RACW_Type : in Entity_Id) is N : constant Node_Id := Asynchronous_Flags_Table.Get (RACW_Type); pragma Assert (N /= Empty); begin Replace (N, New_Occurrence_Of (Standard_True, Sloc (N))); end RACW_Type_Is_Asynchronous; ------------------------- -- RCI_Package_Locator -- ------------------------- function RCI_Package_Locator (Loc : Source_Ptr; Package_Spec : Node_Id) return Node_Id is Inst : constant Node_Id := Make_Package_Instantiation (Loc, Defining_Unit_Name => Make_Defining_Identifier (Loc, New_Internal_Name ('R')), Name => New_Occurrence_Of (RTE (RE_RCI_Info), Loc), Generic_Associations => New_List ( Make_Generic_Association (Loc, Selector_Name => Make_Identifier (Loc, Name_RCI_Name), Explicit_Generic_Actual_Parameter => Make_String_Literal (Loc, Strval => Get_Pkg_Name_String_Id (Package_Spec))))); begin RCI_Locator_Table.Set (Defining_Unit_Name (Package_Spec), Defining_Unit_Name (Inst)); return Inst; end RCI_Package_Locator; ----------------------------------------------- -- Remote_Types_Tagged_Full_View_Encountered -- ----------------------------------------------- procedure Remote_Types_Tagged_Full_View_Encountered (Full_View : in Entity_Id) is Stub_Elements : constant Stub_Structure := Stubs_Table.Get (Full_View); begin if Stub_Elements /= Empty_Stub_Structure then Add_RACW_Primitive_Declarations_And_Bodies (Full_View, Parent (Declaration_Node (Stub_Elements.Object_RPC_Receiver)), List_Containing (Declaration_Node (Full_View))); end if; end Remote_Types_Tagged_Full_View_Encountered; ------------------- -- Scope_Of_Spec -- ------------------- function Scope_Of_Spec (Spec : Node_Id) return Entity_Id is Unit_Name : Node_Id := Defining_Unit_Name (Spec); begin while Nkind (Unit_Name) /= N_Defining_Identifier loop Unit_Name := Defining_Identifier (Unit_Name); end loop; return Unit_Name; end Scope_Of_Spec; end Exp_Dist;
-- -- PQueue -- Generic protected queue package -- -- -- Standard packages with Ada.Unchecked_Deallocation; package body PQueue is ------------------------------------------------------------------------------ -- -- Package subroutines -- ------------------------------------------------------------------------------ -- Instantiate this so we can free storage allocated for queue items once -- they are removed from the queue procedure Free_Queue_Element is new Ada.Unchecked_Deallocation (Queue_Element_Type, Queue_Element_Pointer); ------------------------------------------------------------------------------ -- -- Public protected objects -- ------------------------------------------------------------------------------ protected body Protected_Queue_Type is ------------------------------------------------------------------------ -- Place an item on the back of the queue. Doesn't block. procedure Enqueue (Item : in Data_Type) is New_Element : Queue_Element_Pointer; begin -- Enqueue -- Allocate a new node for the list New_Element := new Queue_Element_Type'(Item, null); -- If the queue is empty, stick it on the "front"; if not, add it to -- the back if Queue.Len = 0 then Queue.Front := New_Element; else Queue.Back.Next := New_Element; end if; -- Whatever our previous status, the queue now has a new item on its -- back end Queue.Back := New_Element; Queue.Len := Queue.Len + 1; end Enqueue; ------------------------------------------------------------------------ -- Remove an item from the front of the queue. Blocks if no items are -- present, accomplished by a guard condition on the entry. entry Dequeue (Item : out Data_Type) when Queue.Len > 0 is Old_Front : Queue_Element_Pointer; begin -- Dequeue -- Once the guard lets us get here, there's at least one item on the -- queue; remove it by advancing the "front" pointer (which may thus -- become null) Old_Front := Queue.Front; Queue.Front := Queue.Front.Next; -- Return the dequeued item to the caller Item := Old_Front.Data; -- Free the list node now that we've copied its data, and decrement -- the item count Free_Queue_Element (Old_Front); Queue.Len := Queue.Len - 1; end Dequeue; ------------------------------------------------------------------------ -- Return the number of items presently on the queue. Doesn't block. function Length return natural is begin -- Length return Queue.Len; end Length; ------------------------------------------------------------------------ end Protected_Queue_Type; --------------------------------------------------------------------------- end PQueue;
----------------------------------------------------------------------- -- secret-tests - Unit tests for secret service library -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Exceptions; with Util.Test_Caller; with Secret.Values; with Secret.Attributes; with Secret.Services; package body Secret.Tests is package Caller is new Util.Test_Caller (Test, "Secret.Service"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Secret.Values", Test_Value'Access); Caller.Add_Test (Suite, "Test Secret.Attributes", Test_Attributes'Access); Caller.Add_Test (Suite, "Test Secret.Service.Store", Test_Store'Access); end Add_Tests; -- ------------------------------ -- Test operations on the Secret_Type value. -- ------------------------------ procedure Test_Value (T : in out Test) is V : Values.Secret_Type; begin T.Assert (V.Is_Null, "Secret_Type must be null"); V := Values.Create ("test-secret"); T.Assert (not V.Is_Null, "Secret_Type must not be null"); Util.Tests.Assert_Equals (T, "test-secret", V.Get_Value, "Invalid Get_Value"); Util.Tests.Assert_Equals (T, "text/plain", V.Get_Content_Type, "Invalid Get_Content_Type"); V := Values.Create ("test-secret-2"); Util.Tests.Assert_Equals (T, "test-secret-2", V.Get_Value, "Invalid Get_Value"); Util.Tests.Assert_Equals (T, "text/plain", V.Get_Content_Type, "Invalid Get_Content_Type"); end Test_Value; -- ------------------------------ -- Test attributes operations. -- ------------------------------ procedure Test_Attributes (T : in out Test) is List : Secret.Attributes.Map; begin T.Assert (List.Is_Null, "Attributes map must be null"); Secret.Attributes.Insert (List, "my-name", "my-value"); T.Assert (not List.Is_Null, "Attributes map must not be null"); end Test_Attributes; -- ------------------------------ -- Test storing a secret value. -- ------------------------------ procedure Test_Store (T : in out Test) is List : Secret.Attributes.Map; S : Secret.Services.Service_Type; V : Values.Secret_Type; R : Values.Secret_Type; begin S.Initialize; Secret.Attributes.Insert (List, "test-my-name", "my-value"); V := Values.Create ("my-secret-value"); S.Store (List, "my-test-password", V); Secret.Attributes.Insert (List, "secret-password-password", "admin"); R := S.Lookup (List); if not R.Is_Null then Util.Tests.Assert_Equals (T, "my-secret-value", R.Get_Value, "Invalig lookup"); end if; S.Remove (List); R := S.Lookup (List); T.Assert (R.Is_Null, "The secret value was not removed"); exception when E : Secret.Services.Service_Error => Util.Tests.Assert_Matches (T, ".*autolaunch D-Bus without X11.*", Ada.Exceptions.Exception_Message (E), "Invalid exception raised"); end Test_Store; end Secret.Tests;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.PDEC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Operation Mode type CTRLA_MODESelect is (-- QDEC operating mode QDEC, -- HALL operating mode HALL, -- COUNTER operating mode COUNTER) with Size => 2; for CTRLA_MODESelect use (QDEC => 0, HALL => 1, COUNTER => 2); -- PDEC Configuration type CTRLA_CONFSelect is (-- Quadrature decoder direction X4, -- Secure Quadrature decoder direction X4S, -- Decoder direction X2, -- Secure decoder direction X2S, -- Auto correction mode AUTOC) with Size => 3; for CTRLA_CONFSelect use (X4 => 0, X4S => 1, X2 => 2, X2S => 3, AUTOC => 4); -- PDEC_CTRLA_PINEN array type PDEC_CTRLA_PINEN_Field_Array is array (0 .. 2) of Boolean with Component_Size => 1, Size => 3; -- Type definition for PDEC_CTRLA_PINEN type PDEC_CTRLA_PINEN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PINEN as a value Val : HAL.UInt3; when True => -- PINEN as an array Arr : PDEC_CTRLA_PINEN_Field_Array; end case; end record with Unchecked_Union, Size => 3; for PDEC_CTRLA_PINEN_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- PDEC_CTRLA_PINVEN array type PDEC_CTRLA_PINVEN_Field_Array is array (0 .. 2) of Boolean with Component_Size => 1, Size => 3; -- Type definition for PDEC_CTRLA_PINVEN type PDEC_CTRLA_PINVEN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PINVEN as a value Val : HAL.UInt3; when True => -- PINVEN as an array Arr : PDEC_CTRLA_PINVEN_Field_Array; end case; end record with Unchecked_Union, Size => 3; for PDEC_CTRLA_PINVEN_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; subtype PDEC_CTRLA_ANGULAR_Field is HAL.UInt3; subtype PDEC_CTRLA_MAXCMP_Field is HAL.UInt4; -- Control A type PDEC_CTRLA_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operation Mode MODE : CTRLA_MODESelect := SAM_SVD.PDEC.QDEC; -- unspecified Reserved_4_5 : HAL.UInt2 := 16#0#; -- Run in Standby RUNSTDBY : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- PDEC Configuration CONF : CTRLA_CONFSelect := SAM_SVD.PDEC.X4; -- Auto Lock ALOCK : Boolean := False; -- unspecified Reserved_12_13 : HAL.UInt2 := 16#0#; -- PDEC Phase A and B Swap SWAP : Boolean := False; -- Period Enable PEREN : Boolean := False; -- PDEC Input From Pin 0 Enable PINEN : PDEC_CTRLA_PINEN_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_19_19 : HAL.Bit := 16#0#; -- IO Pin 0 Invert Enable PINVEN : PDEC_CTRLA_PINVEN_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Angular Counter Length ANGULAR : PDEC_CTRLA_ANGULAR_Field := 16#0#; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Maximum Consecutive Missing Pulses MAXCMP : PDEC_CTRLA_MAXCMP_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PDEC_CTRLA_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 3; Reserved_4_5 at 0 range 4 .. 5; RUNSTDBY at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CONF at 0 range 8 .. 10; ALOCK at 0 range 11 .. 11; Reserved_12_13 at 0 range 12 .. 13; SWAP at 0 range 14 .. 14; PEREN at 0 range 15 .. 15; PINEN at 0 range 16 .. 18; Reserved_19_19 at 0 range 19 .. 19; PINVEN at 0 range 20 .. 22; Reserved_23_23 at 0 range 23 .. 23; ANGULAR at 0 range 24 .. 26; Reserved_27_27 at 0 range 27 .. 27; MAXCMP at 0 range 28 .. 31; end record; -- Command type CTRLBCLR_CMDSelect is (-- No action NONE, -- Force a counter restart or retrigger RETRIGGER, -- Force update of double buffered registers UPDATE, -- Force a read synchronization of COUNT READSYNC, -- Start QDEC/HALL START, -- Stop QDEC/HALL STOP) with Size => 3; for CTRLBCLR_CMDSelect use (NONE => 0, RETRIGGER => 1, UPDATE => 2, READSYNC => 3, START => 4, STOP => 5); -- Control B Clear type PDEC_CTRLBCLR_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Lock Update LUPD : Boolean := False; -- unspecified Reserved_2_4 : HAL.UInt3 := 16#0#; -- Command CMD : CTRLBCLR_CMDSelect := SAM_SVD.PDEC.NONE; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_CTRLBCLR_Register use record Reserved_0_0 at 0 range 0 .. 0; LUPD at 0 range 1 .. 1; Reserved_2_4 at 0 range 2 .. 4; CMD at 0 range 5 .. 7; end record; -- Command type CTRLBSET_CMDSelect is (-- No action NONE, -- Force a counter restart or retrigger RETRIGGER, -- Force update of double buffered registers UPDATE, -- Force a read synchronization of COUNT READSYNC, -- Start QDEC/HALL START, -- Stop QDEC/HALL STOP) with Size => 3; for CTRLBSET_CMDSelect use (NONE => 0, RETRIGGER => 1, UPDATE => 2, READSYNC => 3, START => 4, STOP => 5); -- Control B Set type PDEC_CTRLBSET_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Lock Update LUPD : Boolean := False; -- unspecified Reserved_2_4 : HAL.UInt3 := 16#0#; -- Command CMD : CTRLBSET_CMDSelect := SAM_SVD.PDEC.NONE; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_CTRLBSET_Register use record Reserved_0_0 at 0 range 0 .. 0; LUPD at 0 range 1 .. 1; Reserved_2_4 at 0 range 2 .. 4; CMD at 0 range 5 .. 7; end record; -- Event Action type EVCTRL_EVACTSelect is (-- Event action disabled OFF, -- Start, restart or retrigger on event RETRIGGER, -- Count on event COUNT) with Size => 2; for EVCTRL_EVACTSelect use (OFF => 0, RETRIGGER => 1, COUNT => 2); subtype PDEC_EVCTRL_EVINV_Field is HAL.UInt3; subtype PDEC_EVCTRL_EVEI_Field is HAL.UInt3; -- PDEC_EVCTRL_MCEO array type PDEC_EVCTRL_MCEO_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PDEC_EVCTRL_MCEO type PDEC_EVCTRL_MCEO_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MCEO as a value Val : HAL.UInt2; when True => -- MCEO as an array Arr : PDEC_EVCTRL_MCEO_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PDEC_EVCTRL_MCEO_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Event Control type PDEC_EVCTRL_Register is record -- Event Action EVACT : EVCTRL_EVACTSelect := SAM_SVD.PDEC.OFF; -- Inverted Event Input Enable EVINV : PDEC_EVCTRL_EVINV_Field := 16#0#; -- Event Input Enable EVEI : PDEC_EVCTRL_EVEI_Field := 16#0#; -- Overflow/Underflow Output Event Enable OVFEO : Boolean := False; -- Error Output Event Enable ERREO : Boolean := False; -- Direction Output Event Enable DIREO : Boolean := False; -- Velocity Output Event Enable VLCEO : Boolean := False; -- Match Channel 0 Event Output Enable MCEO : PDEC_EVCTRL_MCEO_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for PDEC_EVCTRL_Register use record EVACT at 0 range 0 .. 1; EVINV at 0 range 2 .. 4; EVEI at 0 range 5 .. 7; OVFEO at 0 range 8 .. 8; ERREO at 0 range 9 .. 9; DIREO at 0 range 10 .. 10; VLCEO at 0 range 11 .. 11; MCEO at 0 range 12 .. 13; Reserved_14_15 at 0 range 14 .. 15; end record; -- PDEC_INTENCLR_MC array type PDEC_INTENCLR_MC_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PDEC_INTENCLR_MC type PDEC_INTENCLR_MC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MC as a value Val : HAL.UInt2; when True => -- MC as an array Arr : PDEC_INTENCLR_MC_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PDEC_INTENCLR_MC_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Interrupt Enable Clear type PDEC_INTENCLR_Register is record -- Overflow/Underflow Interrupt Disable OVF : Boolean := False; -- Error Interrupt Disable ERR : Boolean := False; -- Direction Interrupt Disable DIR : Boolean := False; -- Velocity Interrupt Disable VLC : Boolean := False; -- Channel 0 Compare Match Disable MC : PDEC_INTENCLR_MC_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_INTENCLR_Register use record OVF at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DIR at 0 range 2 .. 2; VLC at 0 range 3 .. 3; MC at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; end record; -- PDEC_INTENSET_MC array type PDEC_INTENSET_MC_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PDEC_INTENSET_MC type PDEC_INTENSET_MC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MC as a value Val : HAL.UInt2; when True => -- MC as an array Arr : PDEC_INTENSET_MC_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PDEC_INTENSET_MC_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Interrupt Enable Set type PDEC_INTENSET_Register is record -- Overflow/Underflow Interrupt Enable OVF : Boolean := False; -- Error Interrupt Enable ERR : Boolean := False; -- Direction Interrupt Enable DIR : Boolean := False; -- Velocity Interrupt Enable VLC : Boolean := False; -- Channel 0 Compare Match Enable MC : PDEC_INTENSET_MC_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_INTENSET_Register use record OVF at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DIR at 0 range 2 .. 2; VLC at 0 range 3 .. 3; MC at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; end record; -- PDEC_INTFLAG_MC array type PDEC_INTFLAG_MC_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PDEC_INTFLAG_MC type PDEC_INTFLAG_MC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MC as a value Val : HAL.UInt2; when True => -- MC as an array Arr : PDEC_INTFLAG_MC_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PDEC_INTFLAG_MC_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Interrupt Flag Status and Clear type PDEC_INTFLAG_Register is record -- Overflow/Underflow OVF : Boolean := False; -- Error ERR : Boolean := False; -- Direction Change DIR : Boolean := False; -- Velocity VLC : Boolean := False; -- Channel 0 Compare Match MC : PDEC_INTFLAG_MC_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_INTFLAG_Register use record OVF at 0 range 0 .. 0; ERR at 0 range 1 .. 1; DIR at 0 range 2 .. 2; VLC at 0 range 3 .. 3; MC at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; end record; -- PDEC_STATUS_CCBUFV array type PDEC_STATUS_CCBUFV_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PDEC_STATUS_CCBUFV type PDEC_STATUS_CCBUFV_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CCBUFV as a value Val : HAL.UInt2; when True => -- CCBUFV as an array Arr : PDEC_STATUS_CCBUFV_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PDEC_STATUS_CCBUFV_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Status type PDEC_STATUS_Register is record -- Quadrature Error Flag QERR : Boolean := False; -- Index Error Flag IDXERR : Boolean := False; -- Missing Pulse Error flag MPERR : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Window Error Flag WINERR : Boolean := False; -- Hall Error Flag HERR : Boolean := False; -- Stop STOP : Boolean := True; -- Direction Status Flag DIR : Boolean := False; -- Prescaler Buffer Valid PRESCBUFV : Boolean := False; -- Filter Buffer Valid FILTERBUFV : Boolean := False; -- unspecified Reserved_10_11 : HAL.UInt2 := 16#0#; -- Compare Channel 0 Buffer Valid CCBUFV : PDEC_STATUS_CCBUFV_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for PDEC_STATUS_Register use record QERR at 0 range 0 .. 0; IDXERR at 0 range 1 .. 1; MPERR at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; WINERR at 0 range 4 .. 4; HERR at 0 range 5 .. 5; STOP at 0 range 6 .. 6; DIR at 0 range 7 .. 7; PRESCBUFV at 0 range 8 .. 8; FILTERBUFV at 0 range 9 .. 9; Reserved_10_11 at 0 range 10 .. 11; CCBUFV at 0 range 12 .. 13; Reserved_14_15 at 0 range 14 .. 15; end record; -- Debug Control type PDEC_DBGCTRL_Register is record -- Debug Run Mode DBGRUN : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_DBGCTRL_Register use record DBGRUN at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- PDEC_SYNCBUSY_CC array type PDEC_SYNCBUSY_CC_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for PDEC_SYNCBUSY_CC type PDEC_SYNCBUSY_CC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CC as a value Val : HAL.UInt2; when True => -- CC as an array Arr : PDEC_SYNCBUSY_CC_Field_Array; end case; end record with Unchecked_Union, Size => 2; for PDEC_SYNCBUSY_CC_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Synchronization Status type PDEC_SYNCBUSY_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. Enable Synchronization Busy ENABLE : Boolean; -- Read-only. Control B Synchronization Busy CTRLB : Boolean; -- Read-only. Status Synchronization Busy STATUS : Boolean; -- Read-only. Prescaler Synchronization Busy PRESC : Boolean; -- Read-only. Filter Synchronization Busy FILTER : Boolean; -- Read-only. Count Synchronization Busy COUNT : Boolean; -- Read-only. Compare Channel 0 Synchronization Busy CC : PDEC_SYNCBUSY_CC_Field; -- unspecified Reserved_9_31 : HAL.UInt23; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PDEC_SYNCBUSY_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; CTRLB at 0 range 2 .. 2; STATUS at 0 range 3 .. 3; PRESC at 0 range 4 .. 4; FILTER at 0 range 5 .. 5; COUNT at 0 range 6 .. 6; CC at 0 range 7 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; -- Prescaler Value type PRESC_PRESCSelect is (-- No division DIV1, -- Divide by 2 DIV2, -- Divide by 4 DIV4, -- Divide by 8 DIV8, -- Divide by 16 DIV16, -- Divide by 32 DIV32, -- Divide by 64 DIV64, -- Divide by 128 DIV128, -- Divide by 256 DIV256, -- Divide by 512 DIV512, -- Divide by 1024 DIV1024) with Size => 4; for PRESC_PRESCSelect use (DIV1 => 0, DIV2 => 1, DIV4 => 2, DIV8 => 3, DIV16 => 4, DIV32 => 5, DIV64 => 6, DIV128 => 7, DIV256 => 8, DIV512 => 9, DIV1024 => 10); -- Prescaler Value type PDEC_PRESC_Register is record -- Prescaler Value PRESC : PRESC_PRESCSelect := SAM_SVD.PDEC.DIV1; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_PRESC_Register use record PRESC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; end record; -- Prescaler Buffer Value type PRESCBUF_PRESCBUFSelect is (-- No division DIV1, -- Divide by 2 DIV2, -- Divide by 4 DIV4, -- Divide by 8 DIV8, -- Divide by 16 DIV16, -- Divide by 32 DIV32, -- Divide by 64 DIV64, -- Divide by 128 DIV128, -- Divide by 256 DIV256, -- Divide by 512 DIV512, -- Divide by 1024 DIV1024) with Size => 4; for PRESCBUF_PRESCBUFSelect use (DIV1 => 0, DIV2 => 1, DIV4 => 2, DIV8 => 3, DIV16 => 4, DIV32 => 5, DIV64 => 6, DIV128 => 7, DIV256 => 8, DIV512 => 9, DIV1024 => 10); -- Prescaler Buffer Value type PDEC_PRESCBUF_Register is record -- Prescaler Buffer Value PRESCBUF : PRESCBUF_PRESCBUFSelect := SAM_SVD.PDEC.DIV1; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PDEC_PRESCBUF_Register use record PRESCBUF at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; end record; subtype PDEC_COUNT_COUNT_Field is HAL.UInt16; -- Counter Value type PDEC_COUNT_Register is record -- Counter Value COUNT : PDEC_COUNT_COUNT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PDEC_COUNT_Register use record COUNT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype PDEC_CC_CC_Field is HAL.UInt16; -- Channel n Compare Value type PDEC_CC_Register is record -- Channel Compare Value CC : PDEC_CC_CC_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PDEC_CC_Register use record CC at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Channel n Compare Value type PDEC_CC_Registers is array (0 .. 1) of PDEC_CC_Register; subtype PDEC_CCBUF_CCBUF_Field is HAL.UInt16; -- Channel Compare Buffer Value type PDEC_CCBUF_Register is record -- Channel Compare Buffer Value CCBUF : PDEC_CCBUF_CCBUF_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PDEC_CCBUF_Register use record CCBUF at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Channel Compare Buffer Value type PDEC_CCBUF_Registers is array (0 .. 1) of PDEC_CCBUF_Register; ----------------- -- Peripherals -- ----------------- -- Quadrature Decodeur type PDEC_Peripheral is record -- Control A CTRLA : aliased PDEC_CTRLA_Register; -- Control B Clear CTRLBCLR : aliased PDEC_CTRLBCLR_Register; -- Control B Set CTRLBSET : aliased PDEC_CTRLBSET_Register; -- Event Control EVCTRL : aliased PDEC_EVCTRL_Register; -- Interrupt Enable Clear INTENCLR : aliased PDEC_INTENCLR_Register; -- Interrupt Enable Set INTENSET : aliased PDEC_INTENSET_Register; -- Interrupt Flag Status and Clear INTFLAG : aliased PDEC_INTFLAG_Register; -- Status STATUS : aliased PDEC_STATUS_Register; -- Debug Control DBGCTRL : aliased PDEC_DBGCTRL_Register; -- Synchronization Status SYNCBUSY : aliased PDEC_SYNCBUSY_Register; -- Prescaler Value PRESC : aliased PDEC_PRESC_Register; -- Filter Value FILTER : aliased HAL.UInt8; -- Prescaler Buffer Value PRESCBUF : aliased PDEC_PRESCBUF_Register; -- Filter Buffer Value FILTERBUF : aliased HAL.UInt8; -- Counter Value COUNT : aliased PDEC_COUNT_Register; -- Channel n Compare Value CC : aliased PDEC_CC_Registers; -- Channel Compare Buffer Value CCBUF : aliased PDEC_CCBUF_Registers; end record with Volatile; for PDEC_Peripheral use record CTRLA at 16#0# range 0 .. 31; CTRLBCLR at 16#4# range 0 .. 7; CTRLBSET at 16#5# range 0 .. 7; EVCTRL at 16#6# range 0 .. 15; INTENCLR at 16#8# range 0 .. 7; INTENSET at 16#9# range 0 .. 7; INTFLAG at 16#A# range 0 .. 7; STATUS at 16#C# range 0 .. 15; DBGCTRL at 16#F# range 0 .. 7; SYNCBUSY at 16#10# range 0 .. 31; PRESC at 16#14# range 0 .. 7; FILTER at 16#15# range 0 .. 7; PRESCBUF at 16#18# range 0 .. 7; FILTERBUF at 16#19# range 0 .. 7; COUNT at 16#1C# range 0 .. 31; CC at 16#20# range 0 .. 63; CCBUF at 16#30# range 0 .. 63; end record; -- Quadrature Decodeur PDEC_Periph : aliased PDEC_Peripheral with Import, Address => PDEC_Base; end SAM_SVD.PDEC;
select delay 10.0; Put_Line ("Cannot finish this in 10s"); then abort -- do some lengthy calculation ... end select;
-- { dg-do compile } -- { dg-options "-gnatws" } procedure Discr17 is F1_Poe : Integer := 18; function F1 return Integer is begin F1_Poe := F1_Poe - 1; return F1_Poe; end F1; generic type T is limited private; with function Is_Ok (X : T) return Boolean; procedure Check; procedure Check is begin declare type Poe is new T; X : Poe; Y : Poe; begin null; end; declare type Poe is new T; type Arr is array (1 .. 2) of Poe; X : Arr; B : Boolean := Is_Ok (T (X (1))); begin null; end; end; protected type Poe (D3 : Integer := F1) is entry E (D3 .. F1); -- F1 evaluated function Is_Ok return Boolean; end Poe; protected body Poe is entry E (for I in D3 .. F1) when True is begin null; end E; function Is_Ok return Boolean is begin return False; end Is_Ok; end Poe; function Is_Ok (C : Poe) return Boolean is begin return C.Is_Ok; end Is_Ok; procedure Chk is new Check (Poe, Is_Ok); begin Chk; end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R . C H 1 0 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks (All_Checks); -- Turn off subprogram body ordering check. Subprograms are in order -- by RM section rather than alphabetical with Fname.UF; use Fname.UF; with Uname; use Uname; separate (Par) package body Ch10 is -- Local functions, used only in this chapter function P_Context_Clause return List_Id; function P_Subunit return Node_Id; function Set_Location return Source_Ptr; -- The current compilation unit starts with Token at Token_Ptr. This -- function determines the corresponding source location for the start -- of the unit, including any preceding comment lines. procedure Unit_Display (Cunit : Node_Id; Loc : Source_Ptr; SR_Present : Boolean); -- This procedure is used to generate a line of output for a unit in -- the source program. Cunit is the node for the compilation unit, and -- Loc is the source location for the start of the unit in the source -- file (which is not necessarily the Sloc of the Cunit node). This -- output is written to the standard output file for use by gnatchop. procedure Unit_Location (Sind : Source_File_Index; Loc : Source_Ptr); -- This routine has the same calling sequence as Unit_Display, but -- it outputs only the line number and offset of the location, Loc, -- using Cunit to obtain the proper source file index. ------------------------- -- 10.1.1 Compilation -- ------------------------- -- COMPILATION ::= {COMPILATION_UNIT} -- There is no specific parsing routine for a compilation, since we only -- permit a single compilation in a source file, so there is no explicit -- occurrence of compilations as such (our representation of a compilation -- is a series of separate source files). ------------------------------ -- 10.1.1 Compilation unit -- ------------------------------ -- COMPILATION_UNIT ::= -- CONTEXT_CLAUSE LIBRARY_ITEM -- | CONTEXT_CLAUSE SUBUNIT -- LIBRARY_ITEM ::= -- private LIBRARY_UNIT_DECLARATION -- | LIBRARY_UNIT_BODY -- | [private] LIBRARY_UNIT_RENAMING_DECLARATION -- LIBRARY_UNIT_DECLARATION ::= -- SUBPROGRAM_DECLARATION | PACKAGE_DECLARATION -- | GENERIC_DECLARATION | GENERIC_INSTANTIATION -- LIBRARY_UNIT_RENAMING_DECLARATION ::= -- PACKAGE_RENAMING_DECLARATION -- | GENERIC_RENAMING_DECLARATION -- | SUBPROGRAM_RENAMING_DECLARATION -- LIBRARY_UNIT_BODY ::= SUBPROGRAM_BODY | PACKAGE_BODY -- Error recovery: cannot raise Error_Resync. If an error occurs, tokens -- are skipped up to the next possible beginning of a compilation unit. -- Note: if only configuration pragmas are found, Empty is returned -- Note: in syntax-only mode, it is possible for P_Compilation_Unit -- to return strange things that are not really compilation units. -- This is done to help out gnatchop when it is faced with nonsense. function P_Compilation_Unit return Node_Id is Scan_State : Saved_Scan_State; Body_Node : Node_Id; Specification_Node : Node_Id; Unit_Node : Node_Id; Comp_Unit_Node : Node_Id; Name_Node : Node_Id; Item : Node_Id; Private_Sloc : Source_Ptr := No_Location; Config_Pragmas : List_Id; P : Node_Id; SR_Present : Boolean; No_Body : Boolean; Cunit_Error_Flag : Boolean := False; -- This flag is set True if we have to scan for a compilation unit -- token. It is used to ensure clean termination in such cases by -- not insisting on being at the end of file, and, in the syntax only -- case by not scanning for additional compilation units. Cunit_Location : Source_Ptr; -- Location of unit for unit identification output (List_Unit option) begin Num_Library_Units := Num_Library_Units + 1; -- Set location of the compilation unit if unit list option set -- and we are in syntax check only mode if List_Units and then Operating_Mode = Check_Syntax then Cunit_Location := Set_Location; else Cunit_Location := No_Location; end if; -- Deal with initial pragmas Config_Pragmas := No_List; -- If we have an initial Source_Reference pragma, then remember the fact -- to generate an NR parameter in the output line. SR_Present := False; -- If we see a pragma No_Body, remember not to complain about no body No_Body := False; if Token = Tok_Pragma then Save_Scan_State (Scan_State); Item := P_Pragma; if Item = Error or else Pragma_Name_Unmapped (Item) /= Name_Source_Reference then Restore_Scan_State (Scan_State); else SR_Present := True; -- If first unit, record the file name for gnatchop use if Operating_Mode = Check_Syntax and then List_Units and then Num_Library_Units = 1 then Write_Str ("Source_Reference pragma for file """); Write_Name (Full_Ref_Name (Current_Source_File)); Write_Char ('"'); Write_Eol; end if; Config_Pragmas := New_List (Item); end if; end if; -- Scan out any configuration pragmas while Token = Tok_Pragma loop Save_Scan_State (Scan_State); Item := P_Pragma; if Item /= Error and then Pragma_Name_Unmapped (Item) = Name_No_Body then No_Body := True; end if; if Item = Error or else not Is_Configuration_Pragma_Name (Pragma_Name_Unmapped (Item)) then Restore_Scan_State (Scan_State); exit; end if; if Config_Pragmas = No_List then Config_Pragmas := Empty_List; if Operating_Mode = Check_Syntax and then List_Units then Write_Str ("Configuration pragmas at"); Unit_Location (Current_Source_File, Cunit_Location); Write_Eol; end if; end if; Append (Item, Config_Pragmas); Cunit_Location := Set_Location; end loop; -- Establish compilation unit node and scan context items Comp_Unit_Node := New_Node (N_Compilation_Unit, No_Location); Set_Cunit (Current_Source_Unit, Comp_Unit_Node); Set_Context_Items (Comp_Unit_Node, P_Context_Clause); Set_Aux_Decls_Node (Comp_Unit_Node, New_Node (N_Compilation_Unit_Aux, No_Location)); if Present (Config_Pragmas) then -- Check for case of only configuration pragmas present if Token = Tok_EOF and then Is_Empty_List (Context_Items (Comp_Unit_Node)) then if Operating_Mode = Check_Syntax then return Empty; else Item := First (Config_Pragmas); Error_Msg_N ("cannot compile configuration pragmas with gcc!", Item); Error_Msg_N ("\use gnatchop -c to process configuration pragmas!", Item); raise Unrecoverable_Error; end if; -- Otherwise configuration pragmas are simply prepended to the -- context of the current unit. else Append_List (Context_Items (Comp_Unit_Node), Config_Pragmas); Set_Context_Items (Comp_Unit_Node, Config_Pragmas); end if; end if; -- Check for PRIVATE. Note that for the moment we allow this in -- Ada_83 mode, since we do not yet know if we are compiling a -- predefined unit, and if we are then it would be allowed anyway. if Token = Tok_Private then Private_Sloc := Token_Ptr; Set_Keyword_Casing (Current_Source_File, Determine_Token_Casing); if Style_Check then Style.Check_Indentation; end if; Save_Scan_State (Scan_State); -- at PRIVATE Scan; -- past PRIVATE if Token = Tok_Separate then Error_Msg_SP ("cannot have private subunits!"); elsif Token = Tok_Package then Scan; -- past PACKAGE if Token = Tok_Body then Restore_Scan_State (Scan_State); -- to PRIVATE Error_Msg_SC ("cannot have private package body!"); Scan; -- ignore PRIVATE else Restore_Scan_State (Scan_State); -- to PRIVATE Scan; -- past PRIVATE Set_Private_Present (Comp_Unit_Node, True); end if; elsif Token = Tok_Procedure or else Token = Tok_Function or else Token = Tok_Generic then Set_Private_Present (Comp_Unit_Node, True); end if; end if; -- Loop to find our way to a compilation unit token loop exit when Token in Token_Class_Cunit and then Token /= Tok_With; exit when Bad_Spelling_Of (Tok_Package) or else Bad_Spelling_Of (Tok_Function) or else Bad_Spelling_Of (Tok_Generic) or else Bad_Spelling_Of (Tok_Separate) or else Bad_Spelling_Of (Tok_Procedure); -- Allow task and protected for nice error recovery purposes exit when Token = Tok_Task or else Token = Tok_Protected; if Token = Tok_With then Error_Msg_SC ("misplaced WITH"); Append_List (P_Context_Clause, Context_Items (Comp_Unit_Node)); elsif Bad_Spelling_Of (Tok_With) then Append_List (P_Context_Clause, Context_Items (Comp_Unit_Node)); else if Operating_Mode = Check_Syntax and then Token = Tok_EOF then -- Do not complain if there is a pragma No_Body if not No_Body then Error_Msg_SC ("??file contains no compilation units"); end if; else Error_Msg_SC ("compilation unit expected"); Cunit_Error_Flag := True; Resync_Cunit; end if; -- If we are at an end of file, then just quit, the above error -- message was complaint enough. if Token = Tok_EOF then return Error; end if; end if; end loop; -- We have a compilation unit token, so that's a reasonable choice for -- determining the standard casing convention used for keywords in case -- it hasn't already been done on seeing a WITH or PRIVATE. Set_Keyword_Casing (Current_Source_File, Determine_Token_Casing); if Style_Check then Style.Check_Indentation; end if; -- Remaining processing depends on particular type of compilation unit if Token = Tok_Package then -- A common error is to omit the body keyword after package. We can -- often diagnose this early on (before getting loads of errors from -- contained subprogram bodies), by knowing that the file we -- are compiling has a name that requires a body to be found. Save_Scan_State (Scan_State); Scan; -- past Package keyword if Token /= Tok_Body and then Get_Expected_Unit_Type (File_Name (Current_Source_File)) = Expect_Body then Error_Msg_BC -- CODEFIX ("keyword BODY expected here '[see file name']"); Restore_Scan_State (Scan_State); Set_Unit (Comp_Unit_Node, P_Package (Pf_Pbod_Pexp)); else Restore_Scan_State (Scan_State); Set_Unit (Comp_Unit_Node, P_Package (Pf_Decl_Gins_Pbod_Rnam_Pexp)); end if; elsif Token = Tok_Generic then Set_Unit (Comp_Unit_Node, P_Generic); elsif Token = Tok_Separate then Set_Unit (Comp_Unit_Node, P_Subunit); elsif Token = Tok_Function or else Token = Tok_Not or else Token = Tok_Overriding or else Token = Tok_Procedure then Set_Unit (Comp_Unit_Node, P_Subprogram (Pf_Decl_Gins_Pbod_Rnam_Pexp)); -- A little bit of an error recovery check here. If we just scanned -- a subprogram declaration (as indicated by an SIS entry being -- active), then if the following token is BEGIN or an identifier, -- or a token which can reasonably start a declaration but cannot -- start a compilation unit, then we assume that the semicolon in -- the declaration should have been IS. if SIS_Entry_Active then if Token = Tok_Begin or else Token = Tok_Identifier or else Token in Token_Class_Deckn then Push_Scope_Stack; Scopes (Scope.Last).Etyp := E_Name; Scopes (Scope.Last).Sloc := SIS_Sloc; Scopes (Scope.Last).Ecol := SIS_Ecol; Scopes (Scope.Last).Lreq := False; SIS_Entry_Active := False; -- If we had a missing semicolon in the declaration, then -- change the message to from <missing ";"> to <missing "is"> if SIS_Missing_Semicolon_Message /= No_Error_Msg then Change_Error_Text -- Replace: "missing "";"" " (SIS_Missing_Semicolon_Message, "missing IS"); -- Otherwise we saved the semicolon position, so complain else Error_Msg -- CODEFIX (""";"" should be IS", SIS_Semicolon_Sloc); end if; Body_Node := Unit (Comp_Unit_Node); Specification_Node := Specification (Body_Node); Change_Node (Body_Node, N_Subprogram_Body); Set_Specification (Body_Node, Specification_Node); Parse_Decls_Begin_End (Body_Node); Set_Unit (Comp_Unit_Node, Body_Node); end if; -- If we scanned a subprogram body, make sure we did not have private elsif Private_Sloc /= No_Location and then Nkind (Unit (Comp_Unit_Node)) not in N_Subprogram_Instantiation and then Nkind (Unit (Comp_Unit_Node)) /= N_Subprogram_Renaming_Declaration then Error_Msg ("cannot have private subprogram body", Private_Sloc); -- P_Subprogram can yield an abstract subprogram, but this cannot -- be a compilation unit. Treat as a subprogram declaration. elsif Nkind (Unit (Comp_Unit_Node)) = N_Abstract_Subprogram_Declaration then Error_Msg_N ("compilation unit cannot be abstract subprogram", Unit (Comp_Unit_Node)); Unit_Node := New_Node (N_Subprogram_Declaration, Sloc (Comp_Unit_Node)); Set_Specification (Unit_Node, Specification (Unit (Comp_Unit_Node))); Set_Unit (Comp_Unit_Node, Unit_Node); end if; -- Otherwise we have TASK. This is not really an acceptable token, -- but we accept it to improve error recovery. elsif Token = Tok_Task then Scan; -- Past TASK if Token = Tok_Type then Error_Msg_SP ("task type cannot be used as compilation unit"); else Error_Msg_SP ("task declaration cannot be used as compilation unit"); end if; -- If in check syntax mode, accept the task anyway. This is done -- particularly to improve the behavior of GNATCHOP in this case. if Operating_Mode = Check_Syntax then Set_Unit (Comp_Unit_Node, P_Task); -- If not in syntax only mode, treat this as horrible error else Cunit_Error_Flag := True; return Error; end if; else pragma Assert (Token = Tok_Protected); Scan; -- Past PROTECTED if Token = Tok_Type then Error_Msg_SP ("protected type cannot be used as compilation unit"); else Error_Msg_SP ("protected declaration cannot be used as compilation unit"); end if; -- If in check syntax mode, accept protected anyway. This is done -- particularly to improve the behavior of GNATCHOP in this case. if Operating_Mode = Check_Syntax then Set_Unit (Comp_Unit_Node, P_Protected); -- If not in syntax only mode, treat this as horrible error else Cunit_Error_Flag := True; return Error; end if; end if; -- Here is where locate the compilation unit entity. This is a little -- tricky, since it is buried in various places. Unit_Node := Unit (Comp_Unit_Node); -- Another error from which it is hard to recover if Nkind (Unit_Node) in N_Subprogram_Body_Stub | N_Package_Body_Stub then Cunit_Error_Flag := True; return Error; end if; -- Only try this if we got an OK unit if Unit_Node /= Error then if Nkind (Unit_Node) = N_Subunit then Unit_Node := Proper_Body (Unit_Node); end if; if Nkind (Unit_Node) in N_Generic_Declaration then Unit_Node := Specification (Unit_Node); end if; if Nkind (Unit_Node) in N_Package_Declaration | N_Subprogram_Declaration | N_Subprogram_Body | N_Subprogram_Renaming_Declaration then Unit_Node := Specification (Unit_Node); elsif Nkind (Unit_Node) = N_Subprogram_Renaming_Declaration then if Ada_Version = Ada_83 then Error_Msg_N ("(Ada 83) library unit renaming not allowed", Unit_Node); end if; end if; if Nkind (Unit_Node) in N_Task_Body | N_Protected_Body | N_Task_Type_Declaration | N_Protected_Type_Declaration | N_Single_Task_Declaration | N_Single_Protected_Declaration then Name_Node := Defining_Identifier (Unit_Node); elsif Nkind (Unit_Node) in N_Function_Instantiation | N_Function_Specification | N_Generic_Function_Renaming_Declaration | N_Generic_Package_Renaming_Declaration | N_Generic_Procedure_Renaming_Declaration or else Nkind (Unit_Node) in N_Package_Body | N_Package_Instantiation | N_Package_Renaming_Declaration | N_Package_Specification | N_Procedure_Instantiation | N_Procedure_Specification then Name_Node := Defining_Unit_Name (Unit_Node); elsif Nkind (Unit_Node) = N_Expression_Function then Error_Msg_SP ("expression function cannot be used as compilation unit"); return Comp_Unit_Node; -- Anything else is a serious error, abandon scan else raise Error_Resync; end if; Set_Sloc (Comp_Unit_Node, Sloc (Name_Node)); Set_Sloc (Aux_Decls_Node (Comp_Unit_Node), Sloc (Name_Node)); -- Set Entity field in file table. Easier now that we have name. -- Note that this is also skipped if we had a bad unit if Nkind (Name_Node) = N_Defining_Program_Unit_Name then Set_Cunit_Entity (Current_Source_Unit, Defining_Identifier (Name_Node)); else Set_Cunit_Entity (Current_Source_Unit, Name_Node); end if; Set_Unit_Name (Current_Source_Unit, Get_Unit_Name (Unit (Comp_Unit_Node))); -- If we had a bad unit, make sure the fatal flag is set in the file -- table entry, since this is surely a fatal error and also set our -- flag to inhibit the requirement that we be at end of file. else Cunit_Error_Flag := True; Set_Fatal_Error (Current_Source_Unit, Error_Detected); end if; -- Clear away any missing semicolon indication, we are done with that -- unit, so what's done is done, and we don't want anything hanging -- around from the attempt to parse it. SIS_Entry_Active := False; -- Scan out pragmas after unit while Token = Tok_Pragma loop Save_Scan_State (Scan_State); -- If we are in syntax scan mode allowing multiple units, then start -- the next unit if we encounter a configuration pragma, or a source -- reference pragma. We take care not to actually scan the pragma in -- this case (we don't want it to take effect for the current unit). if Operating_Mode = Check_Syntax then Scan; -- past Pragma if Token = Tok_Identifier and then (Is_Configuration_Pragma_Name (Token_Name) or else Token_Name = Name_Source_Reference) then Restore_Scan_State (Scan_State); -- to Pragma exit; end if; end if; -- Otherwise eat the pragma, it definitely belongs with the -- current unit, and not with the following unit. Restore_Scan_State (Scan_State); -- to Pragma P := P_Pragma; if No (Pragmas_After (Aux_Decls_Node (Comp_Unit_Node))) then Set_Pragmas_After (Aux_Decls_Node (Comp_Unit_Node), New_List); end if; Append (P, Pragmas_After (Aux_Decls_Node (Comp_Unit_Node))); end loop; -- Cancel effect of any outstanding pragma Warnings (Off) Set_Warnings_Mode_On (Scan_Ptr); -- Ada 83 error checks if Ada_Version = Ada_83 then -- Check we did not with any child units Item := First (Context_Items (Comp_Unit_Node)); while Present (Item) loop if Nkind (Item) = N_With_Clause and then Nkind (Name (Item)) /= N_Identifier then Error_Msg_N ("(Ada 83) child units not allowed", Item); end if; Next (Item); end loop; -- Check that we did not have a PRIVATE keyword present if Private_Present (Comp_Unit_Node) then Error_Msg ("(Ada 83) private units not allowed", Private_Sloc); end if; end if; -- If no serious error, then output possible unit information line -- for gnatchop if we are in syntax only, list units mode. if not Cunit_Error_Flag and then List_Units and then Operating_Mode = Check_Syntax then Unit_Display (Comp_Unit_Node, Cunit_Location, SR_Present); end if; -- And now we should be at the end of file if Token /= Tok_EOF then -- If we already had to scan for a compilation unit, then don't -- give any further error message, since it just seems to make -- things worse, and we already gave a serious error message. if Cunit_Error_Flag then null; -- If we are in check syntax mode, then we allow multiple units -- so we just return with Token not set to Tok_EOF and no message. elsif Operating_Mode = Check_Syntax then return Comp_Unit_Node; -- We also allow multiple units if we are in multiple unit mode elsif Multiple_Unit_Index /= 0 then -- Skip tokens to end of file, so that the -gnatl listing -- will be complete in this situation, but no need to parse -- the remaining units; no style checking either. declare Save_Style_Check : constant Boolean := Style_Check; begin Style_Check := False; while Token /= Tok_EOF loop Scan; end loop; Style_Check := Save_Style_Check; end; return Comp_Unit_Node; -- Otherwise we have an error. We suppress the error message -- if we already had a fatal error, since this stops junk -- cascaded messages in some situations. else if Fatal_Error (Current_Source_Unit) /= Error_Detected then if Token in Token_Class_Cunit then Error_Msg_SC ("end of file expected, " & "file can have only one compilation unit"); else Error_Msg_SC ("end of file expected"); end if; end if; end if; -- Skip tokens to end of file, so that the -gnatl listing -- will be complete in this situation, but no error checking -- other than that provided at the token level. while Token /= Tok_EOF loop Scan; end loop; return Error; -- Normal return (we were at the end of file as expected) else return Comp_Unit_Node; end if; exception -- An error resync is a serious bomb, so indicate result unit no good when Error_Resync => Set_Fatal_Error (Current_Source_Unit, Error_Detected); return Error; end P_Compilation_Unit; -------------------------- -- 10.1.1 Library Item -- -------------------------- -- Parsed by P_Compilation_Unit (10.1.1) -------------------------------------- -- 10.1.1 Library Unit Declaration -- -------------------------------------- -- Parsed by P_Compilation_Unit (10.1.1) ------------------------------------------------ -- 10.1.1 Library Unit Renaming Declaration -- ------------------------------------------------ -- Parsed by P_Compilation_Unit (10.1.1) ------------------------------- -- 10.1.1 Library Unit Body -- ------------------------------- -- Parsed by P_Compilation_Unit (10.1.1) ------------------------------ -- 10.1.1 Parent Unit Name -- ------------------------------ -- Parsed (as a name) by its parent construct ---------------------------- -- 10.1.2 Context Clause -- ---------------------------- -- CONTEXT_CLAUSE ::= {CONTEXT_ITEM} -- CONTEXT_ITEM ::= WITH_CLAUSE | USE_CLAUSE | WITH_TYPE_CLAUSE -- WITH_CLAUSE ::= -- [LIMITED] [PRIVATE] with library_unit_NAME {,library_unit_NAME}; -- Note: the two qualifiers are Ada 2005 extensions. -- WITH_TYPE_CLAUSE ::= -- with type type_NAME is access; | with type type_NAME is tagged; -- Note: this form is obsolete (old GNAT extension). -- Error recovery: Cannot raise Error_Resync function P_Context_Clause return List_Id is Item_List : List_Id; Has_Limited : Boolean := False; Has_Private : Boolean := False; Scan_State : Saved_Scan_State; With_Node : Node_Id; First_Flag : Boolean; begin Item_List := New_List; -- Get keyword casing from WITH keyword in case not set yet if Token = Tok_With then Set_Keyword_Casing (Current_Source_File, Determine_Token_Casing); end if; -- Loop through context items loop if Style_Check then Style.Check_Indentation; end if; -- Gather any pragmas appearing in the context clause P_Pragmas_Opt (Item_List); -- Processing for WITH clause -- Ada 2005 (AI-50217, AI-262): First check for LIMITED WITH, -- PRIVATE WITH, or both. if Token = Tok_Limited then Has_Limited := True; Has_Private := False; Scan; -- past LIMITED -- In the context, LIMITED can only appear in a with_clause if Token = Tok_Private then Has_Private := True; Scan; -- past PRIVATE end if; if Token /= Tok_With then Error_Msg_SC -- CODEFIX ("unexpected LIMITED ignored"); end if; if Ada_Version < Ada_2005 then Error_Msg_SP ("LIMITED WITH is an Ada 2005 extension"); Error_Msg_SP ("\unit must be compiled with -gnat05 switch"); end if; elsif Token = Tok_Private then Has_Limited := False; Has_Private := True; Save_Scan_State (Scan_State); Scan; -- past PRIVATE if Token /= Tok_With then -- Keyword is beginning of private child unit Restore_Scan_State (Scan_State); -- to PRIVATE return Item_List; elsif Ada_Version < Ada_2005 then Error_Msg_SP ("`PRIVATE WITH` is an Ada 2005 extension"); Error_Msg_SP ("\unit must be compiled with -gnat05 switch"); end if; else Has_Limited := False; Has_Private := False; end if; if Token = Tok_With then Scan; -- past WITH if Token = Tok_Type then -- WITH TYPE is an obsolete GNAT specific extension Error_Msg_SP ("`WITH TYPE` is an obsolete 'G'N'A'T extension"); Error_Msg_SP ("\use Ada 2005 `LIMITED WITH` clause instead"); Scan; -- past TYPE T_Is; if Token = Tok_Tagged then Scan; elsif Token = Tok_Access then Scan; else Error_Msg_SC ("expect tagged or access qualifier"); end if; TF_Semicolon; else First_Flag := True; -- Loop through names in one with clause, generating a separate -- N_With_Clause node for each name encountered. loop With_Node := New_Node (N_With_Clause, Token_Ptr); Append (With_Node, Item_List); -- Note that we allow with'ing of child units, even in -- Ada 83 mode, since presumably if this is not desired, -- then the compilation of the child unit itself is the -- place where such an "error" should be caught. Set_Name (With_Node, P_Qualified_Simple_Name); if Name (With_Node) = Error then Remove (With_Node); end if; Set_First_Name (With_Node, First_Flag); Set_Limited_Present (With_Node, Has_Limited); Set_Private_Present (With_Node, Has_Private); First_Flag := False; -- All done if no comma exit when Token /= Tok_Comma; -- If comma is followed by compilation unit token -- or by USE, or PRAGMA, then it should have been a -- semicolon after all Save_Scan_State (Scan_State); Scan; -- past comma if Token in Token_Class_Cunit or else Token = Tok_Use or else Token = Tok_Pragma then Restore_Scan_State (Scan_State); exit; end if; end loop; Set_Last_Name (With_Node, True); TF_Semicolon; end if; -- Processing for USE clause elsif Token = Tok_Use then P_Use_Clause (Item_List); -- Anything else is end of context clause else exit; end if; end loop; return Item_List; end P_Context_Clause; -------------------------- -- 10.1.2 Context Item -- -------------------------- -- Parsed by P_Context_Clause (10.1.2) ------------------------- -- 10.1.2 With Clause -- ------------------------- -- Parsed by P_Context_Clause (10.1.2) ----------------------- -- 10.1.3 Body Stub -- ----------------------- -- Subprogram stub parsed by P_Subprogram (6.1) -- Package stub parsed by P_Package (7.1) -- Task stub parsed by P_Task (9.1) -- Protected stub parsed by P_Protected (9.4) ---------------------------------- -- 10.1.3 Subprogram Body Stub -- ---------------------------------- -- Parsed by P_Subprogram (6.1) ------------------------------- -- 10.1.3 Package Body Stub -- ------------------------------- -- Parsed by P_Package (7.1) ---------------------------- -- 10.1.3 Task Body Stub -- ---------------------------- -- Parsed by P_Task (9.1) --------------------------------- -- 10.1.3 Protected Body Stub -- --------------------------------- -- Parsed by P_Protected (9.4) --------------------- -- 10.1.3 Subunit -- --------------------- -- SUBUNIT ::= separate (PARENT_UNIT_NAME) PROPER_BODY -- PARENT_UNIT_NAME ::= NAME -- The caller has checked that the initial token is SEPARATE -- Error recovery: cannot raise Error_Resync function P_Subunit return Node_Id is Subunit_Node : Node_Id; Body_Node : Node_Id; begin Subunit_Node := New_Node (N_Subunit, Token_Ptr); Body_Node := Error; -- in case no good body found Scan; -- past SEPARATE; U_Left_Paren; Set_Name (Subunit_Node, P_Qualified_Simple_Name); U_Right_Paren; Ignore (Tok_Semicolon); if Token = Tok_Function or else Token = Tok_Not or else Token = Tok_Overriding or else Token = Tok_Procedure then Body_Node := P_Subprogram (Pf_Pbod_Pexp); elsif Token = Tok_Package then Body_Node := P_Package (Pf_Pbod_Pexp); elsif Token = Tok_Protected then Scan; -- past PROTECTED if Token = Tok_Body then Body_Node := P_Protected; else Error_Msg_AP ("BODY expected"); return Error; end if; elsif Token = Tok_Task then Scan; -- past TASK if Token = Tok_Body then Body_Node := P_Task; else Error_Msg_AP ("BODY expected"); return Error; end if; else Error_Msg_SC ("proper body expected"); return Error; end if; Set_Proper_Body (Subunit_Node, Body_Node); return Subunit_Node; end P_Subunit; ------------------ -- Set_Location -- ------------------ function Set_Location return Source_Ptr is Physical : Boolean; Loc : Source_Ptr; Scan_State : Saved_Scan_State; begin -- A special check. If the first token is pragma, and this is a -- Source_Reference pragma, then do NOT eat previous comments, since -- the Source_Reference pragma is required to be the first line in -- the source file. if Token = Tok_Pragma then Save_Scan_State (Scan_State); Scan; -- past Pragma if Token = Tok_Identifier and then Token_Name = Name_Source_Reference then Restore_Scan_State (Scan_State); return Token_Ptr; end if; Restore_Scan_State (Scan_State); end if; -- Otherwise acquire previous comments and blank lines if Prev_Token = No_Token then return Source_First (Current_Source_File); else Loc := Prev_Token_Ptr; loop exit when Loc = Token_Ptr; -- Should we worry about UTF_32 line terminators here if Source (Loc) in Line_Terminator then Skip_Line_Terminators (Loc, Physical); exit when Physical; end if; Loc := Loc + 1; end loop; return Loc; end if; end Set_Location; ------------------ -- Unit_Display -- ------------------ -- The format of the generated line, as expected by GNATCHOP is -- Unit {unit} line {line}, file offset {offs} [, SR], file name {file} -- where -- {unit} unit name with terminating (spec) or (body) -- {line} starting line number -- {offs} offset to start of text in file -- {file} source file name -- The SR parameter is present only if a source reference pragma was -- scanned for this unit. The significance is that gnatchop should not -- attempt to add another one. procedure Unit_Display (Cunit : Node_Id; Loc : Source_Ptr; SR_Present : Boolean) is Unum : constant Unit_Number_Type := Get_Cunit_Unit_Number (Cunit); Sind : constant Source_File_Index := Source_Index (Unum); Unam : constant Unit_Name_Type := Unit_Name (Unum); begin if List_Units then Write_Str ("Unit "); Write_Unit_Name (Unit_Name (Unum)); Unit_Location (Sind, Loc); if SR_Present then Write_Str (", SR"); end if; Write_Str (", file name "); Write_Name (Get_File_Name (Unam, Nkind (Unit (Cunit)) = N_Subunit)); Write_Eol; end if; end Unit_Display; ------------------- -- Unit_Location -- ------------------- procedure Unit_Location (Sind : Source_File_Index; Loc : Source_Ptr) is Line : constant Logical_Line_Number := Get_Logical_Line_Number (Loc); -- Should the above be the physical line number ??? begin Write_Str (" line "); Write_Int (Int (Line)); Write_Str (", file offset "); Write_Int (Int (Loc) - Int (Source_First (Sind))); end Unit_Location; end Ch10;
pragma License (Unrestricted); package GNAT.Heap_Sort is pragma Pure; type Xchg_Procedure is access procedure (Op1, Op2 : Natural); type Lt_Function is access function (Op1, Op2 : Natural) return Boolean; procedure Sort (N : Natural; Xchg : Xchg_Procedure; Lt : Lt_Function); end GNAT.Heap_Sort;
with STRINGS_PACKAGE; use STRINGS_PACKAGE; with INFLECTIONS_PACKAGE; use INFLECTIONS_PACKAGE; pragma ELABORATE(INFLECTIONS_PACKAGE); package body DICTIONARY_PACKAGE is use STEM_KEY_TYPE_IO; use TEXT_IO; MNPC_IO_DEFAULT_WIDTH : constant NATURAL := 6; NUMERAL_VALUE_TYPE_IO_DEFAULT_WIDTH : constant NATURAL := 5; KIND_ENTRY_IO_DEFAULT_WIDTH : constant NATURAL := VERB_KIND_TYPE_IO.DEFAULT_WIDTH; --PART_WIDTH : NATURAL; function NUMBER_OF_STEMS(P : PART_OF_SPEECH_TYPE) return STEM_KEY_TYPE is begin case P is when N => return 2; when PRON => return 2; when PACK => return 2; when ADJ => return 4; when NUM => return 4; when ADV => return 3; when V => return 4; when VPAR => return 0; when SUPINE => return 0; when PREP => return 1; when CONJ => return 1; when INTERJ => return 1; when others => return 0; end case; end NUMBER_OF_STEMS; package body PARSE_RECORD_IO is use TEXT_IO; use INFLECTION_RECORD_IO; use DICTIONARY_KIND_IO; use MNPC_IO; SPACER : CHARACTER := ' '; procedure GET(F : in TEXT_IO.FILE_TYPE; PR: out PARSE_RECORD) is begin GET(F, PR.STEM); GET(F, SPACER); GET(F, PR.IR); GET(F, SPACER); GET(F, PR.D_K); GET(F, SPACER); GET(F, PR.MNPC); end GET; procedure GET(PR : out PARSE_RECORD) is begin GET(PR.STEM); GET(SPACER); GET(PR.IR); GET(SPACER); GET(PR.D_K); GET(SPACER); GET(PR.MNPC); end GET; procedure PUT(F : in TEXT_IO.FILE_TYPE; PR : in PARSE_RECORD) is begin PUT(F, PR.STEM); PUT(F, ' '); PUT(F, PR.IR); PUT(F, ' '); PUT(F, PR.D_K); PUT(F, ' '); PUT(F, PR.MNPC); end PUT; procedure PUT(PR : in PARSE_RECORD) is begin TEXT_IO.PUT(PR.STEM); TEXT_IO.PUT(' '); INFLECTION_RECORD_IO.PUT(PR.IR); TEXT_IO.PUT(' '); DICTIONARY_KIND_IO.PUT(PR.D_K); TEXT_IO.PUT(' '); MNPC_IO.PUT(PR.MNPC); end PUT; procedure GET(S : in STRING; PR : out PARSE_RECORD; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin STEM_TYPE_IO.GET(S, PR.STEM, L); L := L + 1; GET(S(L+1..S'LAST), PR.IR, L); L := L + 1; GET(S(L+1..S'LAST), PR.D_K, L); L := L + 1; GET(S(L+1..S'LAST), PR.MNPC, LAST); end GET; procedure PUT(S : out STRING; PR : in PARSE_RECORD) is L : INTEGER := 0; M : INTEGER := 0; begin M := L + MAX_STEM_SIZE; S(L+1..M) := PR.STEM; L := M + 1; S(L) := ' '; M := L + INFLECTION_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), PR.IR); L := M + 1; S(L) := ' '; M := L + DICTIONARY_KIND_IO.DEFAULT_WIDTH; PUT(S(L+1..M), PR.D_K); L := M + 1; S(L) := ' '; M := L + MNPC_IO_DEFAULT_WIDTH; PUT(S(L+1..M), PR.MNPC); S(M+1..S'LAST) := (others => ' '); end PUT; end PARSE_RECORD_IO; package body NOUN_ENTRY_IO is use DECN_RECORD_IO; use GENDER_TYPE_IO; use NOUN_KIND_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; N : out NOUN_ENTRY) is begin GET(F, N.DECL); GET(F, SPACER); GET(F, N.GENDER); GET(F, SPACER); GET(F, N.KIND); end GET; procedure GET(N : out NOUN_ENTRY) is begin GET(N.DECL); GET(SPACER); GET(N.GENDER); GET(SPACER); GET(N.KIND); end GET; procedure PUT(F : in FILE_TYPE; N : in NOUN_ENTRY) is begin PUT(F, N.DECL); PUT(F, ' '); PUT(F, N.GENDER); PUT(F, ' '); PUT(F, N.KIND); end PUT; procedure PUT(N : in NOUN_ENTRY) is begin PUT(N.DECL); PUT(' '); PUT(N.GENDER); PUT(' '); PUT(N.KIND); end PUT; procedure GET(S : in STRING; N : out NOUN_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), N.DECL, L); L := L + 1; GET(S(L+1..S'LAST), N.GENDER, L); L := L + 1; GET(S(L+1..S'LAST), N.KIND, LAST); end GET; procedure PUT(S : out STRING; N : in NOUN_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + DECN_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), N.DECL); L := M + 1; S(L) := ' '; M := L + GENDER_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), N.GENDER); L := M + 1; S(L) := ' '; M := L + NOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), N.KIND); S(M+1..S'LAST) := (others => ' '); end PUT; end NOUN_ENTRY_IO; package body PRONOUN_ENTRY_IO is use DECN_RECORD_IO; use PRONOUN_KIND_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; P : out PRONOUN_ENTRY) is begin GET(F, P.DECL); GET(F, SPACER); GET(F, P.KIND); end GET; procedure GET(P : out PRONOUN_ENTRY) is begin GET(P.DECL); GET(SPACER); GET(P.KIND); end GET; procedure PUT(F : in FILE_TYPE; P : in PRONOUN_ENTRY) is begin PUT(F, P.DECL); PUT(F, ' '); PUT(F, P.KIND); end PUT; procedure PUT(P : in PRONOUN_ENTRY) is begin PUT(P.DECL); PUT(' '); PUT(P.KIND); end PUT; procedure GET(S : in STRING; P : out PRONOUN_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), P.DECL, L); L := L + 1; GET(S(L+1..S'LAST), P.KIND, LAST); end GET; procedure PUT(S : out STRING; P : in PRONOUN_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + DECN_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.DECL); L := M + 1; S(L) := ' '; M := L + PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.KIND); S(M+1..S'LAST) := (others => ' '); end PUT; end PRONOUN_ENTRY_IO; package body PROPACK_ENTRY_IO is use DECN_RECORD_IO; use PRONOUN_KIND_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; P : out PROPACK_ENTRY) is begin GET(F, P.DECL); GET(F, SPACER); GET(F, P.KIND); end GET; procedure GET(P : out PROPACK_ENTRY) is begin GET(P.DECL); GET(SPACER); GET(P.KIND); end GET; procedure PUT(F : in FILE_TYPE; P : in PROPACK_ENTRY) is begin PUT(F, P.DECL); PUT(F, ' '); PUT(F, P.KIND); end PUT; procedure PUT(P : in PROPACK_ENTRY) is begin PUT(P.DECL); PUT(' '); PUT(P.KIND); end PUT; procedure GET(S : in STRING; P : out PROPACK_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), P.DECL, L); L := L + 1; GET(S(L+1..S'LAST), P.KIND, LAST); end GET; procedure PUT(S : out STRING; P : in PROPACK_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + DECN_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.DECL); L := M + 1; S(L) := ' '; M := L + PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.KIND); S(M+1..S'LAST) := (others => ' '); end PUT; end PROPACK_ENTRY_IO; package body ADJECTIVE_ENTRY_IO is use DECN_RECORD_IO; use GENDER_TYPE_IO; use CASE_TYPE_IO; use NUMBER_TYPE_IO; use COMPARISON_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; A : out ADJECTIVE_ENTRY) is begin GET(F, A.DECL); GET(F, SPACER); GET(F, A.CO); end GET; procedure GET(A : out ADJECTIVE_ENTRY) is begin GET(A.DECL); GET(SPACER); GET(A.CO); end GET; procedure PUT(F : in FILE_TYPE; A : in ADJECTIVE_ENTRY) is begin PUT(F, A.DECL); PUT(F, ' '); PUT(F, A.CO); end PUT; procedure PUT(A : in ADJECTIVE_ENTRY) is begin PUT(A.DECL); PUT(' '); PUT(A.CO); end PUT; procedure GET(S : in STRING; A : out ADJECTIVE_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), A.DECL, L); L := L + 1; GET(S(L+1..S'LAST), A.CO, LAST); end GET; procedure PUT(S : out STRING; A : in ADJECTIVE_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + DECN_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), A.DECL); L := M + 1; S(L) := ' '; M := L + COMPARISON_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), A.CO); S(M+1..S'LAST) := (others => ' '); end PUT; end ADJECTIVE_ENTRY_IO; package body NUMERAL_ENTRY_IO is use DECN_RECORD_IO; use NUMERAL_SORT_TYPE_IO; use INFLECTIONS_PACKAGE.INTEGER_IO; SPACER : CHARACTER := ' '; NUM_OUT_SIZE : constant := 5; -- Set in spec !!!!!!!!!!!!!!!!!!!!!!!!! procedure GET(F : in FILE_TYPE; NUM : out NUMERAL_ENTRY) is begin GET(F, NUM.DECL); GET(F, SPACER); GET(F, NUM.SORT); GET(F, SPACER); GET(F, NUM.VALUE); end GET; procedure GET(NUM : out NUMERAL_ENTRY) is begin GET(NUM.DECL); GET(SPACER); GET(NUM.SORT); GET(SPACER); GET(NUM.VALUE); end GET; procedure PUT(F : in FILE_TYPE; NUM : in NUMERAL_ENTRY) is begin PUT(F, NUM.DECL); PUT(F, ' '); PUT(F, NUM.SORT); PUT(F, ' '); PUT(F, NUM.VALUE, NUM_OUT_SIZE); end PUT; procedure PUT(NUM : in NUMERAL_ENTRY) is begin PUT(NUM.DECL); PUT(' '); PUT(NUM.SORT); PUT(' '); PUT(NUM.VALUE, NUM_OUT_SIZE); end PUT; procedure GET(S : in STRING; NUM : out NUMERAL_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin --TEXT_IO.PUT("+1"); GET(S(L+1..S'LAST), NUM.DECL, L); --TEXT_IO.PUT("+2"); L := L + 1; GET(S(L+1..S'LAST), NUM.SORT, L); --TEXT_IO.PUT("+3"); L := L + 1; GET(S(L+1..S'LAST), NUM.VALUE, LAST); --TEXT_IO.PUT("+4"); end GET; procedure PUT(S : out STRING; NUM : in NUMERAL_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + DECN_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), NUM.DECL); L := M + 1; S(L) := ' '; M := L + NUMERAL_SORT_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), NUM.SORT); L := M + 1; S(L) := ' '; --M := L + NUMERAL_VALUE_TYPE_IO.DEFAULT_WIDTH; M := L + NUM_OUT_SIZE; PUT(S(L+1..M), NUM.VALUE); S(M+1..S'LAST) := (others => ' '); end PUT; end NUMERAL_ENTRY_IO; package body ADVERB_ENTRY_IO is use COMPARISON_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; A : out ADVERB_ENTRY) is begin GET(F, A.CO); end GET; procedure GET(A : out ADVERB_ENTRY) is begin GET(A.CO); end GET; procedure PUT(F : in FILE_TYPE; A : in ADVERB_ENTRY) is begin PUT(F, A.CO); end PUT; procedure PUT(A : in ADVERB_ENTRY) is begin PUT(A.CO); end PUT; procedure GET(S : in STRING; A : out ADVERB_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), A.CO, LAST); end GET; procedure PUT(S : out STRING; A : in ADVERB_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + COMPARISON_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), A.CO); S(M+1..S'LAST) := (others => ' '); end PUT; end ADVERB_ENTRY_IO; package body VERB_ENTRY_IO is use DECN_RECORD_IO; use VERB_KIND_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; V : out VERB_ENTRY) is begin GET(F, V.CON); GET(F, SPACER); GET(F, V.KIND); end GET; procedure GET(V : out VERB_ENTRY) is begin GET(V.CON); GET(SPACER); GET(V.KIND); end GET; procedure PUT(F : in FILE_TYPE; V : in VERB_ENTRY) is begin PUT(F, V.CON); PUT(F, ' '); PUT(F, V.KIND); end PUT; procedure PUT(V : in VERB_ENTRY) is begin PUT(V.CON); PUT(' '); PUT(V.KIND); end PUT; procedure GET(S : in STRING; V : out VERB_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), V.CON, L); L := L + 1; GET(S(L+1..S'LAST), V.KIND, LAST); end GET; procedure PUT(S : out STRING; V : in VERB_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + DECN_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), V.CON); L := M + 1; S(L) := ' '; M := L + VERB_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), V.KIND); S(M+1..S'LAST) := (others => ' '); end PUT; end VERB_ENTRY_IO; package body PREPOSITION_ENTRY_IO is use CASE_TYPE_IO; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; P : out PREPOSITION_ENTRY) is begin GET(F, P.OBJ); end GET; procedure GET(P : out PREPOSITION_ENTRY) is begin GET(P.OBJ); end GET; procedure PUT(F : in FILE_TYPE; P : in PREPOSITION_ENTRY) is begin PUT(F, P.OBJ); end PUT; procedure PUT(P : in PREPOSITION_ENTRY) is begin PUT(P.OBJ); end PUT; procedure GET(S : in STRING; P : out PREPOSITION_ENTRY; LAST : out INTEGER) is begin GET(S, P.OBJ, LAST); end GET; procedure PUT(S : out STRING; P : in PREPOSITION_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + CASE_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.OBJ); S(M+1..S'LAST) := (others => ' '); end PUT; end PREPOSITION_ENTRY_IO; package body CONJUNCTION_ENTRY_IO is NULL_CONJUNCTION_ENTRY : CONJUNCTION_ENTRY; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; C : out CONJUNCTION_ENTRY) is begin C := NULL_CONJUNCTION_ENTRY; end GET; procedure GET(C : out CONJUNCTION_ENTRY) is begin C := NULL_CONJUNCTION_ENTRY; end GET; procedure PUT(F : in FILE_TYPE; C : in CONJUNCTION_ENTRY) is begin null; end PUT; procedure PUT(C : in CONJUNCTION_ENTRY) is begin null; end PUT; procedure GET(S : in STRING; C : out CONJUNCTION_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin C := NULL_CONJUNCTION_ENTRY; LAST := L; end GET; procedure PUT(S : out STRING; C : in CONJUNCTION_ENTRY) is begin S(S'FIRST..S'LAST) := (others => ' '); end PUT; end CONJUNCTION_ENTRY_IO; package body INTERJECTION_ENTRY_IO is NULL_INTERJECTION_ENTRY : INTERJECTION_ENTRY; SPACER : CHARACTER := ' '; procedure GET(F : in FILE_TYPE; I : out INTERJECTION_ENTRY) is begin I := NULL_INTERJECTION_ENTRY; end GET; procedure GET(I : out INTERJECTION_ENTRY) is begin I := NULL_INTERJECTION_ENTRY; end GET; procedure PUT(F : in FILE_TYPE; I : in INTERJECTION_ENTRY) is begin null; end PUT; procedure PUT(I : in INTERJECTION_ENTRY) is begin null; end PUT; procedure GET(S : in STRING; I : out INTERJECTION_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin I := NULL_INTERJECTION_ENTRY; LAST := L; end GET; procedure PUT(S : out STRING; I : in INTERJECTION_ENTRY) is begin S(S'FIRST..S'LAST) := (others => ' '); end PUT; end INTERJECTION_ENTRY_IO; function "<" (LEFT, RIGHT : PART_ENTRY) return BOOLEAN is begin if LEFT.POFS = RIGHT.POFS then case LEFT.POFS is when N => if LEFT.N.DECL < RIGHT.N.DECL or else (LEFT.N.DECL = RIGHT.N.DECL and then LEFT.N.GENDER < RIGHT.N.GENDER) or else ((LEFT.N.DECL = RIGHT.N.DECL and LEFT.N.GENDER = RIGHT.N.GENDER) and then LEFT.N.KIND < RIGHT.N.KIND) then return TRUE; end if; when PRON => if LEFT.PRON.DECL < RIGHT.PRON.DECL or else (LEFT.PRON.DECL = RIGHT.PRON.DECL and then LEFT.PRON.KIND < RIGHT.PRON.KIND) then return TRUE; end if; when PACK => if LEFT.PACK.DECL < RIGHT.PACK.DECL or else (LEFT.PACK.DECL = RIGHT.PACK.DECL and then LEFT.PACK.KIND < RIGHT.PACK.KIND) then return TRUE; end if; when ADJ => if LEFT.ADJ.DECL < RIGHT.ADJ.DECL or else (LEFT.ADJ.DECL = RIGHT.ADJ.DECL and then LEFT.ADJ.CO < RIGHT.ADJ.CO) then return TRUE; end if; when NUM => if LEFT.NUM.DECL < RIGHT.NUM.DECL or else (LEFT.NUM.DECL = RIGHT.NUM.DECL and then LEFT.NUM.SORT < RIGHT.NUM.SORT) or else ((LEFT.NUM.DECL = RIGHT.NUM.DECL) and then (LEFT.NUM.SORT = RIGHT.NUM.SORT) and then LEFT.NUM.VALUE < RIGHT.NUM.VALUE) then return TRUE; end if;when ADV => return LEFT.ADV.CO < RIGHT.ADV.CO; when V => if (LEFT.V.CON < RIGHT.V.CON) or else (LEFT.V.CON = RIGHT.V.CON and then LEFT.V.KIND < RIGHT.V.KIND) then return TRUE; end if; when PREP => return LEFT.PREP.OBJ < RIGHT.PREP.OBJ; when others => null; end case; else return LEFT.POFS < RIGHT.POFS; end if; return FALSE; exception when CONSTRAINT_ERROR => return LEFT.POFS < RIGHT.POFS; end "<"; package body PART_ENTRY_IO is use PART_OF_SPEECH_TYPE_IO; use NOUN_ENTRY_IO; use PRONOUN_ENTRY_IO; use PROPACK_ENTRY_IO; use ADJECTIVE_ENTRY_IO; use NUMERAL_ENTRY_IO; use ADVERB_ENTRY_IO; use VERB_ENTRY_IO; use PREPOSITION_ENTRY_IO; use CONJUNCTION_ENTRY_IO; use INTERJECTION_ENTRY_IO; SPACER : CHARACTER := ' '; NOUN : NOUN_ENTRY; PRONOUN : PRONOUN_ENTRY; PROPACK : PROPACK_ENTRY; ADJECTIVE : ADJECTIVE_ENTRY; NUMERAL : NUMERAL_ENTRY; ADVERB : ADVERB_ENTRY; VERB : VERB_ENTRY; PREPOSITION : PREPOSITION_ENTRY; CONJUNCTION : CONJUNCTION_ENTRY; INTERJECTION : INTERJECTION_ENTRY; PR : PART_ENTRY; procedure GET(F : in FILE_TYPE; P : out PART_ENTRY) is PS : PART_OF_SPEECH_TYPE := X; C : POSITIVE_COUNT := COL(F); begin GET(F, PS); GET(F, SPACER); case PS is when N => GET(F, NOUN); P := (N, NOUN); when PRON => GET(F, PRONOUN); P := (PRON, PRONOUN); when PACK => GET(F, PROPACK); P := (PACK, PROPACK); when ADJ => GET(F, ADJECTIVE); P := (ADJ, ADJECTIVE); when NUM => GET(F, NUMERAL); P := (NUM, NUMERAL); when ADV => GET(F, ADVERB); P := (ADV, ADVERB); when V => GET(F, VERB); P := (V, VERB); when VPAR => null; -- No VAPR entry when SUPINE => null; -- No SUPINE entry when PREP => GET(F, PREPOSITION); P := (PREP, PREPOSITION); when CONJ => GET(F, CONJUNCTION); P := (CONJ, CONJUNCTION); when INTERJ => GET(F, INTERJECTION); P := (INTERJ, INTERJECTION); when PREFIX => P := (POFS => PREFIX); when SUFFIX => P := (POFS => SUFFIX); when TACKON => P := (POFS => TACKON); when X => P := (POFS => X); end case; SET_COL(F, POSITIVE_COUNT(PART_ENTRY_IO.DEFAULT_WIDTH)+C); return; end GET; procedure GET(P : out PART_ENTRY) is PS : PART_OF_SPEECH_TYPE := X; begin GET(PS); GET(SPACER); case PS is when N => GET(NOUN); P := (N, NOUN); when PRON => GET(PRONOUN); P := (PRON, PRONOUN); when PACK => GET(PROPACK); P := (PACK, PROPACK); when ADJ => GET(ADJECTIVE); P := (ADJ, ADJECTIVE); when NUM => GET(NUMERAL); P := (NUM, NUMERAL); when ADV => GET(ADVERB); P := (ADV, ADVERB); when V => GET(VERB); P := (V, VERB); when VPAR => null; -- No VAPR entry when SUPINE => null; -- No SUPINE entry when PREP => GET(PREPOSITION); P := (PREP, PREPOSITION); when CONJ => GET(CONJUNCTION); P := (CONJ, CONJUNCTION); when INTERJ => GET(INTERJECTION); P := (INTERJ, INTERJECTION); when PREFIX => P := (POFS => PREFIX); when SUFFIX => P := (POFS => SUFFIX); when TACKON => P := (POFS => TACKON); when X => P := (POFS => X); end case; return; end GET; procedure PUT(F : in FILE_TYPE; P : in PART_ENTRY) is C : POSITIVE := POSITIVE(COL(F)); begin PUT(F, P.POFS); PUT(F, ' '); case P.POFS is when N => PUT(F, P.N); when PRON => PUT(F, P.PRON); when PACK => PUT(F, P.PACK); when ADJ => PUT(F, P.ADJ); when NUM => PUT(F, P.NUM); when ADV => PUT(F, P.ADV); when V => PUT(F, P.V); when VPAR => null; -- No VAPR entry when SUPINE => null; -- No SUPINE entry when PREP => PUT(F, P.PREP); when CONJ => PUT(F, P.CONJ); when INTERJ => PUT(F, P.INTERJ); when others => null; end case; --PUT(F, STRING'((INTEGER(COL(F))..PART_ENTRY_IO.DEFAULT_WIDTH+C-1 => ' '))); return; end PUT; procedure PUT(P : in PART_ENTRY) is C : POSITIVE := POSITIVE(COL); begin PUT(P.POFS); PUT(' '); case P.POFS is when N => PUT(P.N); when PRON => PUT(P.PRON); when PACK => PUT(P.PACK); when ADJ => PUT(P.ADJ); when NUM => PUT(P.NUM); when ADV => PUT(P.ADV); when V => PUT(P.V); when VPAR => null; -- No VAPR entry when SUPINE => null; -- No SUPINE entry when PREP => PUT(P.PREP); when CONJ => PUT(P.CONJ); when INTERJ => PUT(P.INTERJ); when others => null; end case; --PUT(STRING'((INTEGER(COL)..PART_ENTRY_IO.DEFAULT_WIDTH+C-1 => ' '))); return; end PUT; procedure GET(S : in STRING; P : out PART_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; PS : PART_OF_SPEECH_TYPE := X; begin LAST := L; -- In case it is not set later GET(S, PS, L); L := L + 1; case PS is when N => GET(S(L+1..S'LAST), NOUN, LAST); P := (N, NOUN); when PRON => GET(S(L+1..S'LAST), PRONOUN, LAST); P := (PRON, PRONOUN); when PACK => GET(S(L+1..S'LAST), PROPACK, LAST); P := (PACK, PROPACK); when ADJ => GET(S(L+1..S'LAST), ADJECTIVE, LAST); P := (ADJ, ADJECTIVE); when NUM => GET(S(L+1..S'LAST), NUMERAL, LAST); P := (NUM, NUMERAL); when ADV => GET(S(L+1..S'LAST), ADVERB, LAST); P := (ADV, ADVERB); when V => GET(S(L+1..S'LAST), VERB, LAST); P := (V, VERB); when VPAR => null; -- No VAPR entry when SUPINE => null; -- No SUPINE entry when PREP => GET(S(L+1..S'LAST), PREPOSITION, LAST); P := (PREP, PREPOSITION); when CONJ => GET(S(L+1..S'LAST), CONJUNCTION, LAST); P := (CONJ, CONJUNCTION); when INTERJ => GET(S(L+1..S'LAST), INTERJECTION, LAST); P := (INTERJ, INTERJECTION); when PREFIX => P := (POFS => PREFIX); when SUFFIX => P := (POFS => SUFFIX); when TACKON => P := (POFS => TACKON); when X => P := (POFS => X); end case; end GET; procedure PUT(S : out STRING; P : in PART_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin M := L + PART_OF_SPEECH_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.POFS); L := M + 1; S(L) := ' '; case P.POFS is when N => M := L + NOUN_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.N); when PRON => M := L + PRONOUN_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.PRON); when PACK => M := L + PROPACK_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.PACK); when ADJ => M := L + ADJECTIVE_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.ADJ); when NUM => M := L + NUMERAL_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.NUM); when ADV => M := L + ADVERB_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.ADV); when V => M := L + VERB_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.V); when VPAR => null; -- No VAPR entryR when SUPINE => null; -- No SUPINE entry when PREP => M := L + PREPOSITION_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.PREP); when CONJ => M := L + CONJUNCTION_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.CONJ); when INTERJ => M := L + INTERJECTION_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.INTERJ); when others => null; end case; --S(M+1..S'LAST) := (others => ' '); end PUT; end PART_ENTRY_IO; package body KIND_ENTRY_IO is use NOUN_KIND_TYPE_IO; use PRONOUN_KIND_TYPE_IO; use INFLECTIONS_PACKAGE.INTEGER_IO; use VERB_KIND_TYPE_IO; SPACER : CHARACTER := ' '; NOUN_KIND : NOUN_KIND_TYPE; PRONOUN_KIND : PRONOUN_KIND_TYPE; PROPACK_KIND : PRONOUN_KIND_TYPE; VERB_KIND : VERB_KIND_TYPE; VPAR_KIND : VERB_KIND_TYPE; SUPINE_KIND : VERB_KIND_TYPE; NUMERAL_VALUE : NUMERAL_VALUE_TYPE; procedure GET(F : in FILE_TYPE; PS : in PART_OF_SPEECH_TYPE; P : out KIND_ENTRY) is begin case PS is when N => GET(F, NOUN_KIND); P := (N, NOUN_KIND); when PRON => GET(F, PRONOUN_KIND); P := (PRON, PRONOUN_KIND); when PACK => GET(F, PROPACK_KIND); P := (PACK, PROPACK_KIND); when ADJ => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => ADJ); when NUM => GET(F, NUMERAL_VALUE); P := (NUM, NUMERAL_VALUE); when ADV => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => ADV); when V => GET(F, VERB_KIND); P := (V, VERB_KIND); when VPAR => GET(F, VPAR_KIND); P := (VPAR, VPAR_KIND); when SUPINE => GET(F, SUPINE_KIND); P := (SUPINE, SUPINE_KIND); when PREP => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => PREP); when CONJ => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => CONJ); when INTERJ => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => INTERJ); when TACKON => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => TACKON); when PREFIX => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => PREFIX); when SUFFIX => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => SUFFIX); when X => SET_COL(F, COL(F) + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => X); end case; return; end GET; procedure GET(PS : in PART_OF_SPEECH_TYPE; P : out KIND_ENTRY) is begin case PS is when N => GET(NOUN_KIND); P := (N, NOUN_KIND); when PRON => GET(PRONOUN_KIND); P := (PRON, PRONOUN_KIND); when PACK => GET(PROPACK_KIND); P := (PACK, PROPACK_KIND); when ADJ => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => ADJ); when NUM => GET(NUMERAL_VALUE); P := (NUM, NUMERAL_VALUE); when ADV => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => ADV); when V => GET(VERB_KIND); P := (V, VERB_KIND); when VPAR => GET(VPAR_KIND); P := (VPAR, VPAR_KIND); when SUPINE => GET(SUPINE_KIND); P := (SUPINE, SUPINE_KIND); when PREP => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => PREP); when CONJ => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => CONJ); when INTERJ => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => INTERJ); when TACKON => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => TACKON); when PREFIX => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => PREFIX); when SUFFIX => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => SUFFIX); when X => SET_COL(COL + POSITIVE_COUNT(KIND_ENTRY_IO.DEFAULT_WIDTH)); P := (POFS => X); end case; return; end GET; procedure PUT(F : in FILE_TYPE; PS : in PART_OF_SPEECH_TYPE; P : in KIND_ENTRY) is C : POSITIVE := POSITIVE(COL(F)); begin case P.POFS is when N => PUT(F, P.N_KIND); when PRON => PUT(F, P.PRON_KIND); when PACK => PUT(F, P.PACK_KIND); when NUM => PUT(F, P.NUM_VALUE, NUMERAL_VALUE_TYPE_IO_DEFAULT_WIDTH); when V => PUT(F, P.V_KIND); when VPAR => PUT(F, P.VPAR_KIND); when SUPINE => PUT(F, P.SUPINE_KIND); when others => null; end case; PUT(F, STRING'((INTEGER(COL(F))..KIND_ENTRY_IO.DEFAULT_WIDTH+C-1 => ' '))); return; end PUT; procedure PUT(PS : in PART_OF_SPEECH_TYPE; P : in KIND_ENTRY) is C : POSITIVE := POSITIVE(COL); begin case P.POFS is when N => PUT(P.N_KIND); when PRON => PUT(P.PRON_KIND); when PACK => PUT(P.PACK_KIND); when NUM => PUT(P.NUM_VALUE, NUMERAL_VALUE_TYPE_IO_DEFAULT_WIDTH); when V => PUT(P.V_KIND); when VPAR => PUT(P.VPAR_KIND); when SUPINE => PUT(P.SUPINE_KIND); when others => null; end case; PUT(STRING'((INTEGER(COL)..KIND_ENTRY_IO.DEFAULT_WIDTH+C-1 => ' '))); return; end PUT; procedure GET(S : in STRING; PS : in PART_OF_SPEECH_TYPE; P : out KIND_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin LAST := L; -- In case it is not set later case PS is when N => GET(S(L+1..S'LAST), NOUN_KIND, LAST); P := (N, NOUN_KIND); when PRON => GET(S(L+1..S'LAST), PRONOUN_KIND, LAST); P := (PRON, PRONOUN_KIND); when PACK => GET(S(L+1..S'LAST), PROPACK_KIND, LAST); P := (PACK, PROPACK_KIND); when ADJ => P := (POFS => ADJ); when NUM => GET(S(L+1..S'LAST), NUMERAL_VALUE, LAST); P := (NUM, NUMERAL_VALUE); when ADV => P := (POFS => ADV); when V => GET(S(L+1..S'LAST), VERB_KIND, LAST); P := (V, VERB_KIND); when VPAR => GET(S(L+1..S'LAST), VPAR_KIND, LAST); P := (VPAR, VPAR_KIND); when SUPINE => GET(S(L+1..S'LAST), SUPINE_KIND, LAST); P := (SUPINE, SUPINE_KIND); when PREP => P := (POFS => PREP); when CONJ => P := (POFS => CONJ); when INTERJ => P := (POFS => INTERJ); when TACKON => P := (POFS => TACKON); when PREFIX => P := (POFS => PREFIX); when SUFFIX => P := (POFS => SUFFIX); when X => P := (POFS => X); end case; return; end GET; procedure PUT(S : out STRING; PS : in PART_OF_SPEECH_TYPE; P : in KIND_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin case P.POFS is when N => M := L + NOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.N_KIND); when PRON => M := L + PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.PRON_KIND); when PACK => M := L + PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.PACK_KIND); when NUM => M := L + NUMERAL_VALUE_TYPE_IO_DEFAULT_WIDTH; PUT(S(L+1..M), P.NUM_VALUE); when V => M := L + VERB_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.V_KIND); when VPAR => M := L + VERB_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.VPAR_KIND); when SUPINE => M := L + VERB_KIND_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), P.SUPINE_KIND); when others => null; end case; S(M+1..S'LAST) := (others => ' '); end PUT; end KIND_ENTRY_IO; package body TRANSLATION_RECORD_IO is use TEXT_IO; use AGE_TYPE_IO; use AREA_TYPE_IO; use GEO_TYPE_IO; use FREQUENCY_TYPE_IO; use SOURCE_TYPE_IO; SPACER : CHARACTER := ' '; --LINE : STRING(1..250); LAST : INTEGER := 0; procedure GET(F : in TEXT_IO.FILE_TYPE; TR: out TRANSLATION_RECORD) is begin GET(F, TR.AGE); GET(F, SPACER); GET(F, TR.AREA); GET(F, SPACER); GET(F, TR.GEO); GET(F, SPACER); GET(F, TR.FREQ); GET(F, SPACER); GET(F, TR.SOURCE); --GET(F, SPACER); --GET_LINE(F, LINE, LAST); --TR.MEAN := HEAD(LINE(1..LAST), MAX_MEANING_SIZE); end GET; procedure GET(TR : out TRANSLATION_RECORD) is begin GET(TR.AGE); GET(SPACER); GET(TR.AREA); GET(SPACER); GET(TR.GEO); GET(SPACER); GET(TR.FREQ); GET(SPACER); GET(TR.SOURCE); --GET(SPACER); --GET_LINE(LINE, LAST); --TR.MEAN := HEAD(LINE(1..LAST), MAX_MEANING_SIZE); end GET; procedure PUT(F : in TEXT_IO.FILE_TYPE; TR : in TRANSLATION_RECORD) is begin PUT(F, TR.AGE); PUT(F, ' '); PUT(F, TR.AREA); PUT(F, ' '); PUT(F, TR.GEO); PUT(F, ' '); PUT(F, TR.FREQ); PUT(F, ' '); PUT(F, TR.SOURCE); --PUT(F, ' '); --PUT(F, TR.MEAN); end PUT; procedure PUT(TR : in TRANSLATION_RECORD) is begin AGE_TYPE_IO.PUT(TR.AGE); TEXT_IO.PUT(' '); AREA_TYPE_IO.PUT(TR.AREA); TEXT_IO.PUT(' '); GEO_TYPE_IO.PUT(TR.GEO); TEXT_IO.PUT(' '); FREQUENCY_TYPE_IO.PUT(TR.FREQ); TEXT_IO.PUT(' '); SOURCE_TYPE_IO.PUT(TR.SOURCE); --TEXT_IO.PUT(' '); --TEXT_IO.PUT(TR.MEAN); end PUT; procedure GET(S : in STRING; TR : out TRANSLATION_RECORD; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; begin GET(S(L+1..S'LAST), TR.AGE, L); --PUT(TR.AGE); TEXT_IO.PUT('-'); L := L + 1; GET(S(L+1..S'LAST), TR.AREA, L); --PUT(TR.AREA); TEXT_IO.PUT('-'); L := L + 1; GET(S(L+1..S'LAST), TR.GEO, L); --PUT(TR.GEO); TEXT_IO.PUT('-'); L := L + 1; GET(S(L+1..S'LAST), TR.FREQ, L); --PUT(TR.FREQ); TEXT_IO.PUT('-'); L := L + 1; GET(S(L+1..S'LAST), TR.SOURCE, LAST); --PUT(TR.SOURCE); TEXT_IO.PUT('-'); --L := M + 1; --M := L + MAX_MEANING_SIZE; --TR.MEAN := HEAD(S(L+1..S'LAST), MAX_MEANING_SIZE); --LAST := M; end GET; procedure PUT(S : out STRING; TR : in TRANSLATION_RECORD) is L : INTEGER := 0; M : INTEGER := 0; begin M := L + AGE_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), TR.AGE); L := M + 1; S(L) := ' '; M := L + AREA_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), TR.AREA); L := M + 1; S(L) := ' '; M := L + GEO_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), TR.GEO); L := M + 1; S(L) := ' '; M := L + FREQUENCY_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), TR.FREQ); L := M + 1; S(L) := ' '; M := L + SOURCE_TYPE_IO.DEFAULT_WIDTH; PUT(S(L+1..M), TR.SOURCE); --L := M + 1; --S(L) := ' '; --M := L + MAX_MEANING_SIZE; --S(L+1..M) := TR.MEAN; S(M+1..S'LAST) := (others => ' '); end PUT; end TRANSLATION_RECORD_IO; package body DICTIONARY_ENTRY_IO is use PART_ENTRY_IO; use TRANSLATION_RECORD_IO; --use KIND_ENTRY_IO; SPACER : CHARACTER := ' '; PART_COL : NATURAL := 0; DE : DICTIONARY_ENTRY; procedure GET(F : in FILE_TYPE; D : out DICTIONARY_ENTRY) is begin for I in STEM_KEY_TYPE range 1..4 loop GET(F, D.STEMS(I)); GET(F, SPACER); end loop; GET(F, D.PART); -- GET(F, SPACER); -- GET(F, D.PART.POFS, D.KIND); GET(F, SPACER); GET(F, D.TRAN); GET(F, SPACER); GET(F, D.MEAN); end GET; procedure GET(D : out DICTIONARY_ENTRY) is begin for I in STEM_KEY_TYPE range 1..4 loop GET(D.STEMS(I)); GET(SPACER); end loop; GET(D.PART); -- GET(SPACER); -- GET(D.PART.POFS, D.KIND); GET(SPACER); GET(D.TRAN); GET(SPACER); GET(D.MEAN); end GET; procedure PUT(F : in FILE_TYPE; D : in DICTIONARY_ENTRY) is begin for I in STEM_KEY_TYPE range 1..4 loop PUT(F, D.STEMS(I)); PUT(F, ' '); end loop; PART_COL := NATURAL(COL(F)); PUT(F, D.PART); -- PUT(F, ' '); -- PUT(F, D.PART.POFS, D.KIND); SET_COL(F, COUNT(PART_COL + PART_ENTRY_IO.DEFAULT_WIDTH + 1)); PUT(F, D.TRAN); PUT(F, ' '); PUT(F, D.MEAN); end PUT; procedure PUT(D : in DICTIONARY_ENTRY) is begin for I in STEM_KEY_TYPE range 1..4 loop PUT(D.STEMS(I)); PUT(' '); end loop; PART_COL := NATURAL(COL); PUT(D.PART); -- PUT(' '); -- PUT(D.PART.POFS, D.KIND); SET_COL(COUNT(PART_COL + PART_ENTRY_IO.DEFAULT_WIDTH + 1)); PUT(D.TRAN); PUT(' '); PUT(D.MEAN); end PUT; procedure GET(S : in STRING; D : out DICTIONARY_ENTRY; LAST : out INTEGER) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; I : INTEGER := 0; begin for I in STEM_KEY_TYPE range 1..4 loop STEM_TYPE_IO.GET(S(L+1..S'LAST), D.STEMS(I), L); end loop; GET(S(L+1..S'LAST), D.PART, L); -- L := L + 1; -- GET(S(L+1..S'LAST), D.PART.POFS, D.KIND, L); L := L + 1; GET(S(L+1..S'LAST), D.TRAN, L); L := L + 1; D.MEAN := HEAD(S(L+1..S'LAST), MAX_MEANING_SIZE); I := L+1; while S(I) = ' ' loop I := I + 1; end loop; while (S(I) not in 'A'..'Z') and (S(I) not in 'a'..'z') loop LAST := I; I := I + 1; exit; end loop; end GET; procedure PUT(S : out STRING; D : in DICTIONARY_ENTRY) is L : INTEGER := S'FIRST - 1; M : INTEGER := 0; begin for I in STEM_KEY_TYPE range 1..4 loop M := L + MAX_STEM_SIZE; S(L+1..M) := D.STEMS(I); L := M + 1; S(L) := ' '; end loop; PART_COL := L + 1; M := L + PART_ENTRY_IO.DEFAULT_WIDTH; PUT(S(L+1..M), D.PART); -- L := M + 1; -- S(L) := ' '; -- M := L + KIND_ENTRY_IO_DEFAULT_WIDTH; -- PUT(S(L+1..M), D.PART.POFS, D.KIND); L := PART_COL + PART_ENTRY_IO.DEFAULT_WIDTH + 1; M := L + TRANSLATION_RECORD_IO.DEFAULT_WIDTH; PUT(S(L+1..M), D.TRAN); L := M + 1; S(L) := ' '; M := M + MAX_MEANING_SIZE; S(L+1..M) := D.MEAN; S(M+1..S'LAST) := (others => ' '); end PUT; end DICTIONARY_ENTRY_IO; function "<=" (LEFT, RIGHT : AREA_TYPE) return BOOLEAN is begin if RIGHT = LEFT or else RIGHT = X then return TRUE; else return FALSE; end if; end "<="; begin -- initialization of body of DICTIONARY_PACKAGE --TEXT_IO.PUT_LINE("Initializing DICTIONARY_PACKAGE"); DICTIONARY_KIND_IO.DEFAULT_WIDTH := DICTIONARY_KIND'WIDTH; --NUMERAL_VALUE_TYPE_IO.DEFAULT_WIDTH := 5; AREA_TYPE_IO.DEFAULT_WIDTH := AREA_TYPE'WIDTH; GEO_TYPE_IO.DEFAULT_WIDTH := GEO_TYPE'WIDTH; FREQUENCY_TYPE_IO.DEFAULT_WIDTH := FREQUENCY_TYPE'WIDTH; SOURCE_TYPE_IO.DEFAULT_WIDTH := SOURCE_TYPE'WIDTH; PARSE_RECORD_IO.DEFAULT_WIDTH := STEM_TYPE_IO.DEFAULT_WIDTH + 1 + INFLECTION_RECORD_IO.DEFAULT_WIDTH + 1 + DICTIONARY_KIND_IO.DEFAULT_WIDTH + 1 + MNPC_IO_DEFAULT_WIDTH; NOUN_ENTRY_IO.DEFAULT_WIDTH := DECN_RECORD_IO.DEFAULT_WIDTH + 1 + GENDER_TYPE_IO.DEFAULT_WIDTH + 1 + NOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PRONOUN_ENTRY_IO.DEFAULT_WIDTH := DECN_RECORD_IO.DEFAULT_WIDTH + 1 + PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH; PROPACK_ENTRY_IO.DEFAULT_WIDTH := DECN_RECORD_IO.DEFAULT_WIDTH + 1 + PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH; ADJECTIVE_ENTRY_IO.DEFAULT_WIDTH := DECN_RECORD_IO.DEFAULT_WIDTH + 1 + COMPARISON_TYPE_IO.DEFAULT_WIDTH; ADVERB_ENTRY_IO.DEFAULT_WIDTH := COMPARISON_TYPE_IO.DEFAULT_WIDTH; VERB_ENTRY_IO.DEFAULT_WIDTH := DECN_RECORD_IO.DEFAULT_WIDTH + 1 + VERB_KIND_TYPE_IO.DEFAULT_WIDTH; PREPOSITION_ENTRY_IO.DEFAULT_WIDTH := 0; CONJUNCTION_ENTRY_IO.DEFAULT_WIDTH := 0; INTERJECTION_ENTRY_IO.DEFAULT_WIDTH := 0; NUMERAL_ENTRY_IO.DEFAULT_WIDTH := DECN_RECORD_IO.DEFAULT_WIDTH + 1 + NUMERAL_SORT_TYPE_IO.DEFAULT_WIDTH + 1 + NUMERAL_VALUE_TYPE_IO_DEFAULT_WIDTH; PART_ENTRY_IO.DEFAULT_WIDTH := PART_OF_SPEECH_TYPE_IO.DEFAULT_WIDTH + 1 + NUMERAL_ENTRY_IO.DEFAULT_WIDTH; -- Largest -- Should make up a MAX of PART_ENTRY + KIND_ENTRY (same POFS) WIDTHS TRANSLATION_RECORD_IO.DEFAULT_WIDTH := AGE_TYPE_IO.DEFAULT_WIDTH + 1 + AREA_TYPE_IO.DEFAULT_WIDTH + 1 + GEO_TYPE_IO.DEFAULT_WIDTH + 1 + FREQUENCY_TYPE_IO.DEFAULT_WIDTH + 1 + SOURCE_TYPE_IO.DEFAULT_WIDTH; DICTIONARY_ENTRY_IO.DEFAULT_WIDTH := 4 * (MAX_STEM_SIZE + 1) + PART_ENTRY_IO.DEFAULT_WIDTH + 1 + TRANSLATION_RECORD_IO.DEFAULT_WIDTH + 1 + MAX_MEANING_SIZE; --TEXT_IO.PUT_LINE("Initialized DICTIONARY_PACKAGE"); end DICTIONARY_PACKAGE;
with DOM.Core; package UxAS.Comms.LMCP_Net_Client.Service is pragma Elaborate_Body; type Service_Base is abstract new LMCP_Object_Network_Client_Base with private; type Any_Service is access all Service_Base'Class; -- ServiceBase::ServiceBase(const std::string& serviceType, const std::string& workDirectoryName) -- : m_serviceType(serviceType), m_workDirectoryName(workDirectoryName) procedure Construct_Service (This : in out Service_Base; Service_Type : String; Work_Directory_Name : String) with Post'Class => Constructed (This); -- /** \brief The <B><i>configureService</i></B> method performs service configuration. -- * It must be invoked before calling the <B><i>initializeAndStartService</i></B>. -- * -- * @param parentOfWorkDirectory parent directory where work directory will be created -- * @param serviceXml XML configuration -- * @return true if configuration succeeds; false if configuration fails. -- */ -- bool -- configureService(const std::string& parentOfWorkDirectory, const std::string& serviceXml); procedure Configure_Service (This : in out Service_Base; Parent_Of_Work_Directory : String; ServiceXml : String; Result : out Boolean) with Pre'Class => Constructed (This), Post'Class => Configured (This); -- /** \brief The <B><i>configureService</i></B> method performs service configuration. -- * It must be invoked before calling the <B><i>initializeAndStartService</i></B>. -- * -- * @param parentOfWorkDirectory parent directory where work directory will be created -- * @param serviceXmlNode XML configuration -- * @return true if configuration succeeds; false if configuration fails. -- */ -- bool -- configureService(const std::string& parentWorkDirectory, const pugi::xml_node& serviceXmlNode); procedure Configure_Service (This : in out Service_Base; Parent_Of_Work_Directory : String; Service_XML_Node : DOM.Core.Element; Result : out Boolean) with Pre'Class => Constructed (This), Post'Class => Configured (This); -- /** \brief The <B><i>initializeAndStartService</i></B> method performs service -- * initialization and startup. It must be invoked after calling the -- * <B><i>configureService</i></B> method. Do not use for -- * <B><i>ServiceManager</i></B>, instead invoke the -- * <B><i>initializeAndStart</i></B> method. -- * -- * @return true if all initialization and startup succeeds; false if initialization or startup fails. -- */ -- bool -- initializeAndStartService(); procedure Initialize_And_Start_Service (This : in out Service_Base; Result : out Boolean) with Pre'Class => Constructed (This) and Configured (This); -- * \brief The <B><i>getUniqueNetworkClientId</i></B> returns a unique service ID. -- * It returns the ID from a call to getUniqueNetworkClientId(), which are used as service IDs -- * -- * @return unique service ID. -- */ -- static int64_t -- getUniqueServceId() -- { -- return (getUniqueNetworkClientId()); // call static routine in base class -- }; function Get_Unique_Service_Id return Int64; -- public: -- so we provide accessors rather than have a non-private record type with a private component -- /** \brief unique ID of the component. */ -- std::uint32_t m_serviceId; function Get_Service_Id (This : Service_Base) return UInt32 with Pre'Class => Constructed (This) and Configured (This); -- std::string m_serviceType; function Get_Service_Type (This : Service_Base) return String with Pre'Class => Constructed (This) and Configured (This); Service_Type_Max_Length : constant := 255; -- arbitrary -- std::string m_workDirectoryName; function Get_Work_Directory_Name (This : Service_Base) return String with Pre'Class => Constructed (This) and Configured (This); Work_Directory_Name_Max_Length : constant := 255; -- arbitrary ----------------------------------------------------------------------------------------- -- /** \brief The <B><i>instantiateService</i></B> method creates an instance -- * of a service class that inherits from <B><i>ServiceBase</i></B> -- * -- * @param serviceType type name of the service to be instantiated -- * @return instantiated service -- */ function Instantiate_Service (Type_Name : String) return Any_Service; function Configured (This : Service_Base) return Boolean; function Constructed (This : Service_Base) return Boolean; Service_Type_Name_Max_Length : constant := 255; -- arbitrary subtype Service_Type_Name is Dynamic_String (Service_Type_Name_Max_Length); type Service_Type_Names_List is array (Positive range <>) of Service_Type_Name; private Work_Directory_Path_Max_Length : constant := 255; -- arbitrary type Service_Base is abstract new LMCP_Object_Network_Client_Base with record Is_Constructed : Boolean := False; Service_Id : UInt32; Service_Type : Service_Type_Name; Work_Directory_Name : Dynamic_String (Work_Directory_Name_Max_Length); Work_Directory_Path : Dynamic_String (Work_Directory_Path_Max_Length); -- In the C++ version these two components are declared as *private* -- for class LMCP_Object_Network_Client_Base, but then declared as -- *protected* in Service_Base. They would both be visible in Ada, -- therefore their declaration here would be illegal. We use the -- components declared in the root baseclass but with their default values -- as specified in serviceBase.h, as indicated below. -- -- Is_Configured : Boolean := False; -- Processing_Type : Receive_Processing_Type := LMCP; -- -- TODO: verify this works!! end record; -- static service creation function implemented with non-null values by subclasses. -- static -- ServiceBase* -- create() { return nullptr; }; function Create return Any_Service is (null); -- must match profile for type Service_Creation_Function_Pointer type Service_Creation_Function_Pointer is access function return Any_Service; -- to designate static function Create in each subclass's package, which when -- called, allocates an instance of the packages's subclass type -- registers service type name, alias type names and it's create() function for a subclass. -- -- registerServiceCreationFunctionPointers procedure Register_Service_Creation_Function_Pointers (Service_Type_Names : Service_Type_Names_List; Associated_Creator : Service_Creation_Function_Pointer); -- Every concrete subclass's package MUST call Register_Service_Creation_Function_Pointers -- during their package body executable part, corresponding to this effect in C++ : -- -- template <typename T> -- struct CreationRegistrar -- { -- explicit -- CreationRegistrar(const std::vector<std::string>& registryServiceTypeNames) -- { -- ServiceBase::registerServiceCreationFunctionPointers(registryServiceTypeNames, &T::create); -- } -- }; end UxAS.Comms.LMCP_Net_Client.Service;
----------------------------------------------------------------------- -- babel-files-signatures -- Signatures calculation -- Copyright (C) 2014 , 2015, 2016 Stephane.Carrez -- Written by Stephane.Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; package body Babel.Files.Signatures is -- ------------------------------ -- Compute the SHA1 signature of the data stored in the buffer. -- ------------------------------ procedure Sha1 (Buffer : in Babel.Files.Buffers.Buffer; Result : out Util.Encoders.SHA1.Hash_Array) is Ctx : Util.Encoders.SHA1.Context; begin Util.Encoders.SHA1.Update (Ctx, Buffer.Data (Buffer.Data'First .. Buffer.Last)); Util.Encoders.SHA1.Finish (Ctx, Result); end Sha1; -- ------------------------------ -- Compute the SHA1 signature of the file stream. -- ------------------------------ procedure Sha1 (Stream : in Babel.Streams.Refs.Stream_Ref; Result : out Util.Encoders.SHA1.Hash_Array) is use type Babel.Files.Buffers.Buffer_Access; From_Stream : constant Babel.Streams.Stream_Access := Stream.Value; Buffer : Babel.Files.Buffers.Buffer_Access; Ctx : Util.Encoders.SHA1.Context; begin From_Stream.Rewind; loop From_Stream.Read (Buffer); exit when Buffer = null; Util.Encoders.SHA1.Update (Ctx, Buffer.Data (Buffer.Data'First .. Buffer.Last)); end loop; Util.Encoders.SHA1.Finish (Ctx, Result); end Sha1; -- ------------------------------ -- Write the SHA1 checksum for the files stored in the map. -- ------------------------------ procedure Save_Checksum (Path : in String; Files : in Babel.Files.Maps.File_Map) is Checksum : Ada.Text_IO.File_Type; procedure Write_Checksum (Position : in Babel.Files.Maps.File_Cursor) is File : constant Babel.Files.File_Type := Babel.Files.Maps.File_Maps.Element (Position); SHA1 : constant String := Babel.Files.Get_SHA1 (File); Path : constant String := Babel.Files.Get_Path (File); begin Ada.Text_IO.Put (Checksum, Path); Ada.Text_IO.Put (Checksum, ": "); Ada.Text_IO.Put_Line (Checksum, SHA1); end Write_Checksum; begin Ada.Text_IO.Create (File => Checksum, Name => Path); Files.Iterate (Write_Checksum'Access); Ada.Text_IO.Close (File => Checksum); end Save_Checksum; end Babel.Files.Signatures;
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ stream manipulation package -- -- |___/_|\_\_|_|____| by: Timm Felden, Dennis Przytarski -- -- -- pragma Ada_2012; with Interfaces.C; with Interfaces.C.Pointers; with Skill.Types; with Skill.Streams.Reader; with Skill.Streams.Writer; with Ada.Unchecked_Conversion; package body Skill.Streams is function Input (Path : Skill.Types.String_Access) return Skill.Streams.Reader.Input_Stream is begin return Skill.Streams.Reader.Open (Path); end Input; function Write (Path : Skill.Types.String_Access) return Skill.Streams.Writer.Output_Stream is (Streams.Writer.Open(Path, "w+")); function Append (Path : Skill.Types.String_Access) return Skill.Streams.Writer.Output_Stream is (Streams.Writer.Open (Path, "a+")); function Invalid_Pointer return Map_Pointer is pragma Warnings (Off); function Cast is new Ada.Unchecked_Conversion (Integer, Map_Pointer); begin return Cast (-1); end; end Skill.Streams;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Gprslaves.DB; with Gprslaves.DB.JSON; with GNATCOLL.JSON; with GNAT.Command_Line; use GNAT.Command_Line; with GNAT.String_Split; with GNAT.Spitbol; use GNAT.Spitbol; with GNAT.Spitbol.Table_VString; use GNAT.Spitbol.Table_VString; with Gprslaves.Configuration; use Gprslaves.Configuration; procedure GPR_Tools.Gprslaves.Get is use GNAT.String_Split; use DB; procedure Put (Self : GNAT.Spitbol.Table_VString.Table) is J : GNATCOLL.JSON.JSON_Array; V : constant GNATCOLL.JSON.JSON_Value := GNATCOLL.JSON.Create (J); begin Ada.Text_IO.Put_Line (GNATCOLL.JSON.Write (V, False)); end Put; Keys : GNAT.Spitbol.Table_VString.Table (32); procedure Help is begin Put_Line (Configuration.Command & " " & VERSION & "-v --version displa"); end Help; begin Set (Keys, V ("GNAT"), V (Get_Gnat_Version)); loop case Getopt ("D! -help h ? " & "-version " & "n= -nameserver= " & "v") is when ASCII.NUL => exit; when '-' => if Full_Switch = "-version" then Put_Line (VERSION); elsif Full_Switch = "-nameserver" then Configuration.Nameserver := V (Parameter); end if; when 'D' => declare S : GNAT.String_Split.Slice_Set; begin Create (S, Parameter, "="); if Slice_Count (S) = 2 then Set (Keys, V (Slice (S, 1)), V (Slice (S, 2))); end if; end; when 'v' => Configuration.Verbosity := Configuration.Verbosity + 1; when 'n' => Configuration.Nameserver := V (Parameter); when 'h' | '?' => Help; return; when others => null; end case; end loop; Put_Line (S (Configuration.Nameserver)); Put (Keys); end Gprslaves.Get;
------------------------------------------------------------------------------- -- DEpendency PLOtter for ada packages (DePlo) -- -- -- -- Copyright (C) 2012, Riccardo Bernardini -- -- -- -- This file is part of DePlo. -- -- -- -- DePlo is free software: you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation, either version 2 of the License, or -- -- (at your option) any later version. -- -- -- -- DePlo is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- -- GNU General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with DePlo. If not, see <http://www.gnu.org/licenses/>. -- ------------------------------------------------------------------------------- -- -- This package provides method for working with "arrays of line." -- Nothing georgious, really, just a place where few handy routines -- are kept. -- with Ada.Containers.Indefinite_Vectors; with Ada.Sequential_IO; package Line_Arrays is package Character_IO is new Ada.Sequential_IO (Character); package Line_Containers is new Ada.Containers.Indefinite_Vectors (Index_Type => Positive, Element_Type => String); subtype Line_Array is Line_Containers.Vector; type Line_Terminator is -- Which caracters sequence ends the line? ( CR, -- Only Carriage Return ends the line LF, -- Only Line Feed ends the line CRLF, -- Only the sequence CR + LF ends the line Any -- Any of the above combination is admitted ); subtype Valid_Line_Terminator is Line_Terminator range CR .. CRLF; function Split (Input : String; Terminator : Line_Terminator := Any) return Line_Array; -- Split a string into an array of lines, splitting at the specified -- line terminator function Read (Filename : String; Terminator : Line_Terminator := Any) return Line_Array; -- Read a file and split its content a string into an array of lines, -- splitting at the specified line terminator function Read (Input : Character_IO.File_Type; Terminator : Line_Terminator := Any) return Line_Array; -- Read a file and split its content a string into an array of lines, -- splitting at the specified line terminator function Join (Input : Line_Array; Terminator : Valid_Line_Terminator := CR) return String; -- Inverse of split: take an array of line and join them together -- with the specified terminator function Join (Input : Line_Array; Terminator : String) return String; -- Generalization of the other Join; in this case the terminator -- can be any string. Quite similar to the join in many script languages. function "=" (Left, Right : Line_Array) return Boolean; end Line_Arrays;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . F O R M A L _ O R D E R E D _ M A P S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-2019, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- ------------------------------------------------------------------------------ -- This spec is derived from package Ada.Containers.Bounded_Ordered_Maps in -- the Ada 2012 RM. The modifications are meant to facilitate formal proofs by -- making it easier to express properties, and by making the specification of -- this unit compatible with SPARK 2014. Note that the API of this unit may be -- subject to incompatible changes as SPARK 2014 evolves. -- The modifications are: -- A parameter for the container is added to every function reading the -- content of a container: Key, Element, Next, Query_Element, Previous, -- Has_Element, Iterate, Reverse_Iterate. This change is motivated by the -- need to have cursors which are valid on different containers (typically a -- container C and its previous version C'Old) for expressing properties, -- which is not possible if cursors encapsulate an access to the underlying -- container. The operators "<" and ">" that could not be modified that way -- have been removed. -- Iteration over maps is done using the Iterable aspect, which is SPARK -- compatible. "For of" iteration ranges over keys instead of elements. with Ada.Containers.Functional_Vectors; with Ada.Containers.Functional_Maps; private with Ada.Containers.Red_Black_Trees; generic type Key_Type is private; type Element_Type is private; with function "<" (Left, Right : Key_Type) return Boolean is <>; package Ada.Containers.Formal_Ordered_Maps with SPARK_Mode is pragma Annotate (CodePeer, Skip_Analysis); function Equivalent_Keys (Left, Right : Key_Type) return Boolean with Global => null, Post => Equivalent_Keys'Result = (not (Left < Right) and not (Right < Left)); pragma Annotate (GNATprove, Inline_For_Proof, Equivalent_Keys); type Map (Capacity : Count_Type) is private with Iterable => (First => First, Next => Next, Has_Element => Has_Element, Element => Key), Default_Initial_Condition => Is_Empty (Map); pragma Preelaborable_Initialization (Map); type Cursor is record Node : Count_Type; end record; No_Element : constant Cursor := (Node => 0); Empty_Map : constant Map; function Length (Container : Map) return Count_Type with Global => null, Post => Length'Result <= Container.Capacity; pragma Unevaluated_Use_Of_Old (Allow); package Formal_Model with Ghost is subtype Positive_Count_Type is Count_Type range 1 .. Count_Type'Last; package M is new Ada.Containers.Functional_Maps (Element_Type => Element_Type, Key_Type => Key_Type, Equivalent_Keys => Equivalent_Keys); function "=" (Left : M.Map; Right : M.Map) return Boolean renames M."="; function "<=" (Left : M.Map; Right : M.Map) return Boolean renames M."<="; package K is new Ada.Containers.Functional_Vectors (Element_Type => Key_Type, Index_Type => Positive_Count_Type); function "=" (Left : K.Sequence; Right : K.Sequence) return Boolean renames K."="; function "<" (Left : K.Sequence; Right : K.Sequence) return Boolean renames K."<"; function "<=" (Left : K.Sequence; Right : K.Sequence) return Boolean renames K."<="; function K_Bigger_Than_Range (Container : K.Sequence; Fst : Positive_Count_Type; Lst : Count_Type; Key : Key_Type) return Boolean with Global => null, Pre => Lst <= K.Length (Container), Post => K_Bigger_Than_Range'Result = (for all I in Fst .. Lst => K.Get (Container, I) < Key); pragma Annotate (GNATprove, Inline_For_Proof, K_Bigger_Than_Range); function K_Smaller_Than_Range (Container : K.Sequence; Fst : Positive_Count_Type; Lst : Count_Type; Key : Key_Type) return Boolean with Global => null, Pre => Lst <= K.Length (Container), Post => K_Smaller_Than_Range'Result = (for all I in Fst .. Lst => Key < K.Get (Container, I)); pragma Annotate (GNATprove, Inline_For_Proof, K_Smaller_Than_Range); function K_Is_Find (Container : K.Sequence; Key : Key_Type; Position : Count_Type) return Boolean with Global => null, Pre => Position - 1 <= K.Length (Container), Post => K_Is_Find'Result = ((if Position > 0 then K_Bigger_Than_Range (Container, 1, Position - 1, Key)) and (if Position < K.Length (Container) then K_Smaller_Than_Range (Container, Position + 1, K.Length (Container), Key))); pragma Annotate (GNATprove, Inline_For_Proof, K_Is_Find); function Find (Container : K.Sequence; Key : Key_Type) return Count_Type -- Search for Key in Container with Global => null, Post => (if Find'Result > 0 then Find'Result <= K.Length (Container) and Equivalent_Keys (Key, K.Get (Container, Find'Result))); package P is new Ada.Containers.Functional_Maps (Key_Type => Cursor, Element_Type => Positive_Count_Type, Equivalent_Keys => "=", Enable_Handling_Of_Equivalence => False); function "=" (Left : P.Map; Right : P.Map) return Boolean renames P."="; function "<=" (Left : P.Map; Right : P.Map) return Boolean renames P."<="; function P_Positions_Shifted (Small : P.Map; Big : P.Map; Cut : Positive_Count_Type; Count : Count_Type := 1) return Boolean with Global => null, Post => P_Positions_Shifted'Result = -- Big contains all cursors of Small (P.Keys_Included (Small, Big) -- Cursors located before Cut are not moved, cursors located -- after are shifted by Count. and (for all I of Small => (if P.Get (Small, I) < Cut then P.Get (Big, I) = P.Get (Small, I) else P.Get (Big, I) - Count = P.Get (Small, I))) -- New cursors of Big (if any) are between Cut and Cut - 1 + -- Count. and (for all I of Big => P.Has_Key (Small, I) or P.Get (Big, I) - Count in Cut - Count .. Cut - 1)); function Model (Container : Map) return M.Map with -- The high-level model of a map is a map from keys to elements. Neither -- cursors nor order of elements are represented in this model. Keys are -- modeled up to equivalence. Ghost, Global => null; function Keys (Container : Map) return K.Sequence with -- The Keys sequence represents the underlying list structure of maps -- that is used for iteration. It stores the actual values of keys in -- the map. It does not model cursors nor elements. Ghost, Global => null, Post => K.Length (Keys'Result) = Length (Container) -- It only contains keys contained in Model and (for all Key of Keys'Result => M.Has_Key (Model (Container), Key)) -- It contains all the keys contained in Model and (for all Key of Model (Container) => (Find (Keys'Result, Key) > 0 and then Equivalent_Keys (K.Get (Keys'Result, Find (Keys'Result, Key)), Key))) -- It is sorted in increasing order and (for all I in 1 .. Length (Container) => Find (Keys'Result, K.Get (Keys'Result, I)) = I and K_Is_Find (Keys'Result, K.Get (Keys'Result, I), I)); pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Keys); function Positions (Container : Map) return P.Map with -- The Positions map is used to model cursors. It only contains valid -- cursors and maps them to their position in the container. Ghost, Global => null, Post => not P.Has_Key (Positions'Result, No_Element) -- Positions of cursors are smaller than the container's length. and then (for all I of Positions'Result => P.Get (Positions'Result, I) in 1 .. Length (Container) -- No two cursors have the same position. Note that we do not -- state that there is a cursor in the map for each position, as -- it is rarely needed. and then (for all J of Positions'Result => (if P.Get (Positions'Result, I) = P.Get (Positions'Result, J) then I = J))); procedure Lift_Abstraction_Level (Container : Map) with -- Lift_Abstraction_Level is a ghost procedure that does nothing but -- assume that we can access the same elements by iterating over -- positions or cursors. -- This information is not generally useful except when switching from -- a low-level, cursor-aware view of a container, to a high-level, -- position-based view. Ghost, Global => null, Post => (for all Key of Keys (Container) => (for some I of Positions (Container) => K.Get (Keys (Container), P.Get (Positions (Container), I)) = Key)); function Contains (C : M.Map; K : Key_Type) return Boolean renames M.Has_Key; -- To improve readability of contracts, we rename the function used to -- search for a key in the model to Contains. function Element (C : M.Map; K : Key_Type) return Element_Type renames M.Get; -- To improve readability of contracts, we rename the function used to -- access an element in the model to Element. end Formal_Model; use Formal_Model; function "=" (Left, Right : Map) return Boolean with Global => null, Post => "="'Result = (Model (Left) = Model (Right)); function Is_Empty (Container : Map) return Boolean with Global => null, Post => Is_Empty'Result = (Length (Container) = 0); procedure Clear (Container : in out Map) with Global => null, Post => Length (Container) = 0 and M.Is_Empty (Model (Container)); procedure Assign (Target : in out Map; Source : Map) with Global => null, Pre => Target.Capacity >= Length (Source), Post => Model (Target) = Model (Source) and Keys (Target) = Keys (Source) and Length (Source) = Length (Target); function Copy (Source : Map; Capacity : Count_Type := 0) return Map with Global => null, Pre => Capacity = 0 or else Capacity >= Source.Capacity, Post => Model (Copy'Result) = Model (Source) and Keys (Copy'Result) = Keys (Source) and Positions (Copy'Result) = Positions (Source) and (if Capacity = 0 then Copy'Result.Capacity = Source.Capacity else Copy'Result.Capacity = Capacity); function Key (Container : Map; Position : Cursor) return Key_Type with Global => null, Pre => Has_Element (Container, Position), Post => Key'Result = K.Get (Keys (Container), P.Get (Positions (Container), Position)); pragma Annotate (GNATprove, Inline_For_Proof, Key); function Element (Container : Map; Position : Cursor) return Element_Type with Global => null, Pre => Has_Element (Container, Position), Post => Element'Result = Element (Model (Container), Key (Container, Position)); pragma Annotate (GNATprove, Inline_For_Proof, Element); procedure Replace_Element (Container : in out Map; Position : Cursor; New_Item : Element_Type) with Global => null, Pre => Has_Element (Container, Position), Post => -- Order of keys and cursors is preserved Keys (Container) = Keys (Container)'Old and Positions (Container) = Positions (Container)'Old -- New_Item is now associated with the key at position Position in -- Container. and Element (Container, Position) = New_Item -- Elements associated with other keys are preserved and M.Same_Keys (Model (Container), Model (Container)'Old) and M.Elements_Equal_Except (Model (Container), Model (Container)'Old, Key (Container, Position)); procedure Move (Target : in out Map; Source : in out Map) with Global => null, Pre => Target.Capacity >= Length (Source), Post => Model (Target) = Model (Source)'Old and Keys (Target) = Keys (Source)'Old and Length (Source)'Old = Length (Target) and Length (Source) = 0; procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean) with Global => null, Pre => Length (Container) < Container.Capacity or Contains (Container, Key), Post => Contains (Container, Key) and Has_Element (Container, Position) and Equivalent_Keys (Formal_Ordered_Maps.Key (Container, Position), Key) and K_Is_Find (Keys (Container), Key, P.Get (Positions (Container), Position)), Contract_Cases => -- If Key is already in Container, it is not modified and Inserted is -- set to False. (Contains (Container, Key) => not Inserted and Model (Container) = Model (Container)'Old and Keys (Container) = Keys (Container)'Old and Positions (Container) = Positions (Container)'Old, -- Otherwise, Key is inserted in Container and Inserted is set to True others => Inserted and Length (Container) = Length (Container)'Old + 1 -- Key now maps to New_Item and Formal_Ordered_Maps.Key (Container, Position) = Key and Element (Model (Container), Key) = New_Item -- Other mappings are preserved and Model (Container)'Old <= Model (Container) and M.Keys_Included_Except (Model (Container), Model (Container)'Old, Key) -- The keys of Container located before Position are preserved and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => P.Get (Positions (Container), Position) - 1) -- Other keys are shifted by 1 and K.Range_Shifted (Left => Keys (Container)'Old, Right => Keys (Container), Fst => P.Get (Positions (Container), Position), Lst => Length (Container)'Old, Offset => 1) -- A new cursor has been inserted at position Position in -- Container. and P_Positions_Shifted (Positions (Container)'Old, Positions (Container), Cut => P.Get (Positions (Container), Position))); procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Type) with Global => null, Pre => Length (Container) < Container.Capacity and then (not Contains (Container, Key)), Post => Length (Container) = Length (Container)'Old + 1 and Contains (Container, Key) -- Key now maps to New_Item and K.Get (Keys (Container), Find (Keys (Container), Key)) = Key and Element (Model (Container), Key) = New_Item -- Other mappings are preserved and Model (Container)'Old <= Model (Container) and M.Keys_Included_Except (Model (Container), Model (Container)'Old, Key) -- The keys of Container located before Key are preserved and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => Find (Keys (Container), Key) - 1) -- Other keys are shifted by 1 and K.Range_Shifted (Left => Keys (Container)'Old, Right => Keys (Container), Fst => Find (Keys (Container), Key), Lst => Length (Container)'Old, Offset => 1) -- A new cursor has been inserted in Container and P_Positions_Shifted (Positions (Container)'Old, Positions (Container), Cut => Find (Keys (Container), Key)); procedure Include (Container : in out Map; Key : Key_Type; New_Item : Element_Type) with Global => null, Pre => Length (Container) < Container.Capacity or Contains (Container, Key), Post => Contains (Container, Key) and Element (Container, Key) = New_Item, Contract_Cases => -- If Key is already in Container, Key is mapped to New_Item (Contains (Container, Key) => -- Cursors are preserved Positions (Container) = Positions (Container)'Old -- The key equivalent to Key in Container is replaced by Key and K.Get (Keys (Container), Find (Keys (Container), Key)) = Key and K.Equal_Except (Keys (Container)'Old, Keys (Container), Find (Keys (Container), Key)) -- Elements associated with other keys are preserved and M.Same_Keys (Model (Container), Model (Container)'Old) and M.Elements_Equal_Except (Model (Container), Model (Container)'Old, Key), -- Otherwise, Key is inserted in Container others => Length (Container) = Length (Container)'Old + 1 -- Other mappings are preserved and Model (Container)'Old <= Model (Container) and M.Keys_Included_Except (Model (Container), Model (Container)'Old, Key) -- Key is inserted in Container and K.Get (Keys (Container), Find (Keys (Container), Key)) = Key -- The keys of Container located before Key are preserved and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => Find (Keys (Container), Key) - 1) -- Other keys are shifted by 1 and K.Range_Shifted (Left => Keys (Container)'Old, Right => Keys (Container), Fst => Find (Keys (Container), Key), Lst => Length (Container)'Old, Offset => 1) -- A new cursor has been inserted in Container and P_Positions_Shifted (Positions (Container)'Old, Positions (Container), Cut => Find (Keys (Container), Key))); procedure Replace (Container : in out Map; Key : Key_Type; New_Item : Element_Type) with Global => null, Pre => Contains (Container, Key), Post => -- Cursors are preserved Positions (Container) = Positions (Container)'Old -- The key equivalent to Key in Container is replaced by Key and K.Get (Keys (Container), Find (Keys (Container), Key)) = Key and K.Equal_Except (Keys (Container)'Old, Keys (Container), Find (Keys (Container), Key)) -- New_Item is now associated with the Key in Container and Element (Model (Container), Key) = New_Item -- Elements associated with other keys are preserved and M.Same_Keys (Model (Container), Model (Container)'Old) and M.Elements_Equal_Except (Model (Container), Model (Container)'Old, Key); procedure Exclude (Container : in out Map; Key : Key_Type) with Global => null, Post => not Contains (Container, Key), Contract_Cases => -- If Key is not in Container, nothing is changed (not Contains (Container, Key) => Model (Container) = Model (Container)'Old and Keys (Container) = Keys (Container)'Old and Positions (Container) = Positions (Container)'Old, -- Otherwise, Key is removed from Container others => Length (Container) = Length (Container)'Old - 1 -- Other mappings are preserved and Model (Container) <= Model (Container)'Old and M.Keys_Included_Except (Model (Container)'Old, Model (Container), Key) -- The keys of Container located before Key are preserved and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => Find (Keys (Container), Key)'Old - 1) -- The keys located after Key are shifted by 1 and K.Range_Shifted (Left => Keys (Container), Right => Keys (Container)'Old, Fst => Find (Keys (Container), Key)'Old, Lst => Length (Container), Offset => 1) -- A cursor has been removed from Container and P_Positions_Shifted (Positions (Container), Positions (Container)'Old, Cut => Find (Keys (Container), Key)'Old)); procedure Delete (Container : in out Map; Key : Key_Type) with Global => null, Pre => Contains (Container, Key), Post => Length (Container) = Length (Container)'Old - 1 -- Key is no longer in Container and not Contains (Container, Key) -- Other mappings are preserved and Model (Container) <= Model (Container)'Old and M.Keys_Included_Except (Model (Container)'Old, Model (Container), Key) -- The keys of Container located before Key are preserved and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => Find (Keys (Container), Key)'Old - 1) -- The keys located after Key are shifted by 1 and K.Range_Shifted (Left => Keys (Container), Right => Keys (Container)'Old, Fst => Find (Keys (Container), Key)'Old, Lst => Length (Container), Offset => 1) -- A cursor has been removed from Container and P_Positions_Shifted (Positions (Container), Positions (Container)'Old, Cut => Find (Keys (Container), Key)'Old); procedure Delete (Container : in out Map; Position : in out Cursor) with Global => null, Pre => Has_Element (Container, Position), Post => Position = No_Element and Length (Container) = Length (Container)'Old - 1 -- The key at position Position is no longer in Container and not Contains (Container, Key (Container, Position)'Old) and not P.Has_Key (Positions (Container), Position'Old) -- Other mappings are preserved and Model (Container) <= Model (Container)'Old and M.Keys_Included_Except (Model (Container)'Old, Model (Container), Key (Container, Position)'Old) -- The keys of Container located before Position are preserved. and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => P.Get (Positions (Container)'Old, Position'Old) - 1) -- The keys located after Position are shifted by 1 and K.Range_Shifted (Left => Keys (Container), Right => Keys (Container)'Old, Fst => P.Get (Positions (Container)'Old, Position'Old), Lst => Length (Container), Offset => 1) -- Position has been removed from Container and P_Positions_Shifted (Positions (Container), Positions (Container)'Old, Cut => P.Get (Positions (Container)'Old, Position'Old)); procedure Delete_First (Container : in out Map) with Global => null, Contract_Cases => (Length (Container) = 0 => Length (Container) = 0, others => Length (Container) = Length (Container)'Old - 1 -- The first key has been removed from Container and not Contains (Container, First_Key (Container)'Old) -- Other mappings are preserved and Model (Container) <= Model (Container)'Old and M.Keys_Included_Except (Model (Container)'Old, Model (Container), First_Key (Container)'Old) -- Other keys are shifted by 1 and K.Range_Shifted (Left => Keys (Container), Right => Keys (Container)'Old, Fst => 1, Lst => Length (Container), Offset => 1) -- First has been removed from Container and P_Positions_Shifted (Positions (Container), Positions (Container)'Old, Cut => 1)); procedure Delete_Last (Container : in out Map) with Global => null, Contract_Cases => (Length (Container) = 0 => Length (Container) = 0, others => Length (Container) = Length (Container)'Old - 1 -- The last key has been removed from Container and not Contains (Container, Last_Key (Container)'Old) -- Other mappings are preserved and Model (Container) <= Model (Container)'Old and M.Keys_Included_Except (Model (Container)'Old, Model (Container), Last_Key (Container)'Old) -- Others keys of Container are preserved and K.Range_Equal (Left => Keys (Container)'Old, Right => Keys (Container), Fst => 1, Lst => Length (Container)) -- Last cursor has been removed from Container and Positions (Container) <= Positions (Container)'Old); function First (Container : Map) return Cursor with Global => null, Contract_Cases => (Length (Container) = 0 => First'Result = No_Element, others => Has_Element (Container, First'Result) and P.Get (Positions (Container), First'Result) = 1); function First_Element (Container : Map) return Element_Type with Global => null, Pre => not Is_Empty (Container), Post => First_Element'Result = Element (Model (Container), First_Key (Container)); function First_Key (Container : Map) return Key_Type with Global => null, Pre => not Is_Empty (Container), Post => First_Key'Result = K.Get (Keys (Container), 1) and K_Smaller_Than_Range (Keys (Container), 2, Length (Container), First_Key'Result); function Last (Container : Map) return Cursor with Global => null, Contract_Cases => (Length (Container) = 0 => Last'Result = No_Element, others => Has_Element (Container, Last'Result) and P.Get (Positions (Container), Last'Result) = Length (Container)); function Last_Element (Container : Map) return Element_Type with Global => null, Pre => not Is_Empty (Container), Post => Last_Element'Result = Element (Model (Container), Last_Key (Container)); function Last_Key (Container : Map) return Key_Type with Global => null, Pre => not Is_Empty (Container), Post => Last_Key'Result = K.Get (Keys (Container), Length (Container)) and K_Bigger_Than_Range (Keys (Container), 1, Length (Container) - 1, Last_Key'Result); function Next (Container : Map; Position : Cursor) return Cursor with Global => null, Pre => Has_Element (Container, Position) or else Position = No_Element, Contract_Cases => (Position = No_Element or else P.Get (Positions (Container), Position) = Length (Container) => Next'Result = No_Element, others => Has_Element (Container, Next'Result) and then P.Get (Positions (Container), Next'Result) = P.Get (Positions (Container), Position) + 1); procedure Next (Container : Map; Position : in out Cursor) with Global => null, Pre => Has_Element (Container, Position) or else Position = No_Element, Contract_Cases => (Position = No_Element or else P.Get (Positions (Container), Position) = Length (Container) => Position = No_Element, others => Has_Element (Container, Position) and then P.Get (Positions (Container), Position) = P.Get (Positions (Container), Position'Old) + 1); function Previous (Container : Map; Position : Cursor) return Cursor with Global => null, Pre => Has_Element (Container, Position) or else Position = No_Element, Contract_Cases => (Position = No_Element or else P.Get (Positions (Container), Position) = 1 => Previous'Result = No_Element, others => Has_Element (Container, Previous'Result) and then P.Get (Positions (Container), Previous'Result) = P.Get (Positions (Container), Position) - 1); procedure Previous (Container : Map; Position : in out Cursor) with Global => null, Pre => Has_Element (Container, Position) or else Position = No_Element, Contract_Cases => (Position = No_Element or else P.Get (Positions (Container), Position) = 1 => Position = No_Element, others => Has_Element (Container, Position) and then P.Get (Positions (Container), Position) = P.Get (Positions (Container), Position'Old) - 1); function Find (Container : Map; Key : Key_Type) return Cursor with Global => null, Contract_Cases => -- If Key is not contained in Container, Find returns No_Element (not Contains (Model (Container), Key) => not P.Has_Key (Positions (Container), Find'Result) and Find'Result = No_Element, -- Otherwise, Find returns a valid cursor in Container others => P.Has_Key (Positions (Container), Find'Result) and P.Get (Positions (Container), Find'Result) = Find (Keys (Container), Key) -- The key designated by the result of Find is Key and Equivalent_Keys (Formal_Ordered_Maps.Key (Container, Find'Result), Key)); function Element (Container : Map; Key : Key_Type) return Element_Type with Global => null, Pre => Contains (Container, Key), Post => Element'Result = Element (Model (Container), Key); pragma Annotate (GNATprove, Inline_For_Proof, Element); function Floor (Container : Map; Key : Key_Type) return Cursor with Global => null, Contract_Cases => (Length (Container) = 0 or else Key < First_Key (Container) => Floor'Result = No_Element, others => Has_Element (Container, Floor'Result) and not (Key < K.Get (Keys (Container), P.Get (Positions (Container), Floor'Result))) and K_Is_Find (Keys (Container), Key, P.Get (Positions (Container), Floor'Result))); function Ceiling (Container : Map; Key : Key_Type) return Cursor with Global => null, Contract_Cases => (Length (Container) = 0 or else Last_Key (Container) < Key => Ceiling'Result = No_Element, others => Has_Element (Container, Ceiling'Result) and not (K.Get (Keys (Container), P.Get (Positions (Container), Ceiling'Result)) < Key) and K_Is_Find (Keys (Container), Key, P.Get (Positions (Container), Ceiling'Result))); function Contains (Container : Map; Key : Key_Type) return Boolean with Global => null, Post => Contains'Result = Contains (Model (Container), Key); pragma Annotate (GNATprove, Inline_For_Proof, Contains); function Has_Element (Container : Map; Position : Cursor) return Boolean with Global => null, Post => Has_Element'Result = P.Has_Key (Positions (Container), Position); pragma Annotate (GNATprove, Inline_For_Proof, Has_Element); private pragma SPARK_Mode (Off); pragma Inline (Next); pragma Inline (Previous); subtype Node_Access is Count_Type; use Red_Black_Trees; type Node_Type is record Has_Element : Boolean := False; Parent : Node_Access := 0; Left : Node_Access := 0; Right : Node_Access := 0; Color : Red_Black_Trees.Color_Type := Red; Key : Key_Type; Element : Element_Type; end record; package Tree_Types is new Ada.Containers.Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type); type Map (Capacity : Count_Type) is new Tree_Types.Tree_Type (Capacity) with null record; Empty_Map : constant Map := (Capacity => 0, others => <>); end Ada.Containers.Formal_Ordered_Maps;
pragma License (Unrestricted); -- implementation unit required by compiler package System.Parameters is pragma Pure; -- required for task by compiler (s-parame.ads) type Size_Type is new Integer; Unspecified_Size : constant := Size_Type'First; -- required for 'Storage_Size by compiler (s-parame.ads) function Adjust_Storage_Size (Size : Size_Type) return Size_Type renames "+"; -- no effect -- required by compiler ??? (s-parame.ads) -- function Default_Stack_Size return Size_Type; -- Garbage_Collected : constant Boolean := False; end System.Parameters;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <denkpadje@gmail.com> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with System.Multiprocessors; with Orka.Jobs.Executors; with Orka.Jobs.Queues; with Orka.Jobs.Workers; generic Maximum_Queued_Jobs : Positive; -- Maximum number of jobs that can be enqueued -- -- Should be no less than the largest width (number of jobs at a -- particular level) of any job graph. Maximum_Job_Graphs : Positive; -- Maximum number of separate job graphs -- -- For each job graph, a Future object is acquired. The number of -- concurrent acquired objects is bounded by this number. package Orka.Jobs.System is package Queues is new Jobs.Queues (Maximum_Graphs => Maximum_Job_Graphs, Capacity => Maximum_Queued_Jobs); Queue : aliased Queues.Queue; Number_Of_Workers : constant Standard.System.Multiprocessors.CPU; procedure Execute_GPU_Jobs; -- Dequeue and execute GPU jobs in the calling task procedure Shutdown; private package SM renames Standard.System.Multiprocessors; use type SM.CPU; Number_Of_Workers : constant SM.CPU := SM.Number_Of_CPUs - 1; -- For n logical CPU's we spawn n - 1 workers (1 CPU is dedicated -- to rendering) package Executors is new Jobs.Executors (Queues, Maximum_Enqueued_By_Job => Maximum_Queued_Jobs); package Workers is new Jobs.Workers (Executors, Queue'Access, "Worker", Number_Of_Workers); procedure Shutdown renames Workers.Shutdown; end Orka.Jobs.System;
----------------------------------------------------------------------- -- Util-texts-formats -- Text Format ala Java MessageFormat -- Copyright (C) 2001, 2002, 2003, 2009, 2010 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Texts.Formats is type Code is mod 2**32; -- ------------------------------ -- Format the message and replace occurrences of argument patterns by -- their associated value. -- Returns the formatted message in the stream -- ------------------------------ procedure Format (Message : in Input; Arguments : in Value_List; Into : in out Stream) is C : Code; Old_Pos : Natural; N : Natural; Pos : Natural := Message'First; begin while Pos <= Message'Last loop C := Char'Pos (Message (Pos)); if C = Character'Pos ('{') then N := 0; Pos := Pos + 1; Old_Pos := Pos; while Pos <= Message'Last loop C := Char'Pos (Message (Pos)); if C >= Character'Pos ('0') and C <= Character'Pos ('9') then N := N * 10 + Natural (C - Character'Pos ('0')); Pos := Pos + 1; elsif C = Character'Pos ('}') then if N >= Arguments'Length then Put (Into, '{'); Pos := Old_Pos; else Format (Arguments (N + Arguments'First), Into); Pos := Pos + 1; end if; exit; else Put (Into, '{'); Pos := Old_Pos; exit; end if; end loop; else Put (Into, Character'Val (C)); Pos := Pos + 1; end if; end loop; end Format; procedure Format (Argument : in Value; Into : in out Stream) is Content : constant Input := To_Input (Argument); C : Code; begin for I in Content'Range loop C := Char'Pos (Content (I)); Put (Into, Character'Val (C)); end loop; end Format; end Util.Texts.Formats;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . C P P _ E X C E P T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2013-2019, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System; with System.Storage_Elements; with Interfaces.C; use Interfaces.C; with Ada.Unchecked_Conversion; with System.Standard_Library; use System.Standard_Library; package body GNAT.CPP_Exceptions is -- Note: all functions prefixed by __cxa are part of the c++ ABI for -- exception handling. As they are provided by the c++ library, there -- must be no dependencies on it in the compiled code of this unit, but -- there can be dependencies in instances. This is required to be able -- to build the shared library without the c++ library. function To_Exception_Data_Ptr is new Ada.Unchecked_Conversion (Exception_Id, Exception_Data_Ptr); -- Convert an Exception_Id to its non-private type. This is used to get -- the RTTI of a C++ exception function Get_Exception_Machine_Occurrence (X : Exception_Occurrence) return System.Address; pragma Import (Ada, Get_Exception_Machine_Occurrence, "__gnat_get_exception_machine_occurrence"); -- Imported function (from Ada.Exceptions) that returns the machine -- occurrence from an exception occurrence. ------------------------- -- Raise_Cpp_Exception -- ------------------------- procedure Raise_Cpp_Exception (Id : Exception_Id; Value : T) is Id_Data : constant Exception_Data_Ptr := To_Exception_Data_Ptr (Id); -- Get a non-private view on the exception type T_Acc is access all T; pragma Convention (C, T_Acc); -- Access type to the object compatible with C Occ : T_Acc; -- The occurrence to propagate function cxa_allocate_exception (Size : size_t) return T_Acc; pragma Import (C, cxa_allocate_exception, "__cxa_allocate_exception"); -- The C++ function to allocate an occurrence procedure cxa_throw (Obj : T_Acc; Tinfo : System.Address; Dest : System.Address); pragma Import (C, cxa_throw, "__cxa_throw"); pragma No_Return (cxa_throw); -- The C++ function to raise an exception begin -- Check the exception was imported from C++ if Id_Data.Lang /= 'C' then raise Constraint_Error; end if; -- Allocate the C++ occurrence Occ := cxa_allocate_exception (T'Size / System.Storage_Unit); -- Set the object Occ.all := Value; -- Throw the exception cxa_throw (Occ, Id_Data.Foreign_Data, System.Null_Address); end Raise_Cpp_Exception; ---------------- -- Get_Object -- ---------------- function Get_Object (X : Exception_Occurrence) return T is use System; use System.Storage_Elements; Unwind_Exception_Size : Natural; pragma Import (C, Unwind_Exception_Size, "__gnat_unwind_exception_size"); -- Size in bytes of _Unwind_Exception Exception_Addr : constant Address := Get_Exception_Machine_Occurrence (X); -- Machine occurrence of X begin -- Check the machine occurrence exists if Exception_Addr = Null_Address then raise Constraint_Error; end if; declare -- Import the object from the occurrence Result : T; pragma Import (Ada, Result); for Result'Address use Exception_Addr + Storage_Offset (Unwind_Exception_Size); begin -- And return it return Result; end; end Get_Object; end GNAT.CPP_Exceptions;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C A L E N D A R . C O N V E R S I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2008-2019, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Interfaces.C; use Interfaces.C; with Interfaces.C.Extensions; use Interfaces.C.Extensions; package body Ada.Calendar.Conversions is ----------------- -- To_Ada_Time -- ----------------- function To_Ada_Time (Unix_Time : long) return Time is Val : constant Long_Integer := Long_Integer (Unix_Time); begin return Conversion_Operations.To_Ada_Time (Val); end To_Ada_Time; ----------------- -- To_Ada_Time -- ----------------- function To_Ada_Time (tm_year : int; tm_mon : int; tm_day : int; tm_hour : int; tm_min : int; tm_sec : int; tm_isdst : int) return Time is Year : constant Integer := Integer (tm_year); Month : constant Integer := Integer (tm_mon); Day : constant Integer := Integer (tm_day); Hour : constant Integer := Integer (tm_hour); Minute : constant Integer := Integer (tm_min); Second : constant Integer := Integer (tm_sec); DST : constant Integer := Integer (tm_isdst); begin return Conversion_Operations.To_Ada_Time (Year, Month, Day, Hour, Minute, Second, DST); end To_Ada_Time; ----------------- -- To_Duration -- ----------------- function To_Duration (tv_sec : long; tv_nsec : long) return Duration is Secs : constant Long_Integer := Long_Integer (tv_sec); Nano_Secs : constant Long_Integer := Long_Integer (tv_nsec); begin return Conversion_Operations.To_Duration (Secs, Nano_Secs); end To_Duration; ------------------------ -- To_Struct_Timespec -- ------------------------ procedure To_Struct_Timespec (D : Duration; tv_sec : out long; tv_nsec : out long) is Secs : Long_Integer; Nano_Secs : Long_Integer; begin Conversion_Operations.To_Struct_Timespec (D, Secs, Nano_Secs); tv_sec := long (Secs); tv_nsec := long (Nano_Secs); end To_Struct_Timespec; ------------------ -- To_Struct_Tm -- ------------------ procedure To_Struct_Tm (T : Time; tm_year : out int; tm_mon : out int; tm_day : out int; tm_hour : out int; tm_min : out int; tm_sec : out int) is Year : Integer; Month : Integer; Day : Integer; Hour : Integer; Minute : Integer; Second : Integer; begin Conversion_Operations.To_Struct_Tm (T, Year, Month, Day, Hour, Minute, Second); tm_year := int (Year); tm_mon := int (Month); tm_day := int (Day); tm_hour := int (Hour); tm_min := int (Minute); tm_sec := int (Second); end To_Struct_Tm; ------------------ -- To_Unix_Time -- ------------------ function To_Unix_Time (Ada_Time : Time) return long is Val : constant Long_Integer := Conversion_Operations.To_Unix_Time (Ada_Time); begin return long (Val); end To_Unix_Time; ----------------------- -- To_Unix_Nano_Time -- ----------------------- function To_Unix_Nano_Time (Ada_Time : Time) return long_long is pragma Unsuppress (Overflow_Check); Ada_Rep : constant Time_Rep := Time_Rep (Ada_Time); begin return long_long (Ada_Rep + Epoch_Offset); exception when Constraint_Error => raise Time_Error; end To_Unix_Nano_Time; end Ada.Calendar.Conversions;
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 All Rights Reserved. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This program is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with Ada.Command_Line; with Ada.Exceptions; with Ada.IO_Exceptions; with Ada.Real_Time; with Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with GNAT.Traceback.Symbolic; with WisiToken.Lexer; with WisiToken.Text_IO_Trace; procedure Gen_Run_Wisi_Parse_Packrat is use WisiToken; -- Token_ID, "+", "-" Unbounded_string Trace : aliased WisiToken.Text_IO_Trace.Trace (Descriptor'Access); Parser : WisiToken.Parse.Packrat.Parser; Parse_Data : aliased Parse_Data_Type (Parser.Line_Begin_Token'Access); procedure Put_Usage is begin Put_Line ("usage: " & Name & "_wisi_parse <file_name> <parse_action> [options]"); Put_Line ("parse_action: {Navigate | Face | Indent}"); Put_Line ("options:"); Put_Line ("--verbosity n m l:"); Put_Line (" n: parser; m: mckenzie; l: action"); Put_Line (" 0 - only report parse errors"); Put_Line (" 1 - shows spawn/terminate parallel parsers, error recovery enter/exit"); Put_Line (" 2 - add each parser cycle, error recovery enqueue/check"); Put_Line (" 3 - parse stack in each cycle, error recovery parse actions"); Put_Line (" 4 - add lexer debug"); Put_Line ("--lang_params <language-specific params>"); Put_Line ("--lexer_only : only run lexer, for profiling"); Put_Line ("--repeat_count n : repeat parse count times, for profiling; default 1"); Put_Line ("--pause : when repeating, prompt for <enter> after each parse; allows seeing memory leaks"); New_Line; end Put_Usage; Source_File_Name : Ada.Strings.Unbounded.Unbounded_String; Post_Parse_Action : WisiToken.Wisi_Runtime.Post_Parse_Action_Type; Line_Count : WisiToken.Line_Number_Type := 1; Lexer_Only : Boolean := False; Repeat_Count : Integer := 1; Pause : Boolean := False; Arg : Integer; Lang_Params : Ada.Strings.Unbounded.Unbounded_String; Start : Ada.Real_Time.Time; begin Create_Parser (Parser, Trace'Unrestricted_Access, Parse_Data'Unchecked_Access); declare use Ada.Command_Line; begin if Argument_Count < 1 then Put_Usage; Set_Exit_Status (Failure); return; end if; Source_File_Name := +Ada.Command_Line.Argument (1); Post_Parse_Action := WisiToken.Wisi_Runtime.Post_Parse_Action_Type'Value (Ada.Command_Line.Argument (2)); Arg := 3; loop exit when Arg > Argument_Count; if Argument (Arg) = "--verbosity" then WisiToken.Trace_Parse := Integer'Value (Argument (Arg + 1)); WisiToken.Trace_McKenzie := Integer'Value (Argument (Arg + 2)); WisiToken.Trace_Action := Integer'Value (Argument (Arg + 3)); Arg := Arg + 4; elsif Argument (Arg) = "--lang_params" then Lang_Params := +Argument (Arg + 1); Arg := Arg + 2; elsif Argument (Arg) = "--lexer_only" then Lexer_Only := True; Arg := Arg + 1; elsif Argument (Arg) = "--pause" then Pause := True; Arg := Arg + 1; elsif Argument (Arg) = "--repeat_count" then Repeat_Count := Integer'Value (Argument (Arg + 1)); Arg := Arg + 2; else Put_Line ("unrecognized option: '" & Argument (Arg) & "'"); Put_Usage; return; end if; end loop; end; -- Do this after setting Trace_Parse so lexer verbosity is set begin Parser.Lexer.Reset_With_File (-Source_File_Name); exception when Ada.IO_Exceptions.Name_Error => Put_Line (Standard_Error, "'" & (-Source_File_Name) & "' cannot be opened"); return; end; -- See comment in wisi-wisi_runtime.ads for why we still need this. declare Token : Base_Token; Lexer_Error : Boolean; pragma Unreferenced (Lexer_Error); begin loop begin Lexer_Error := Parser.Lexer.Find_Next (Token); exit when Token.ID = Descriptor.EOF_ID; exception when WisiToken.Syntax_Error => Parser.Lexer.Discard_Rest_Of_Input; Parser.Put_Errors (-Source_File_Name); Put_Line ("(lexer_error)"); end; end loop; Line_Count := Token.Line; end; if WisiToken.Trace_Action > WisiToken.Outline then Put_Line ("line_count:" & Line_Number_Type'Image (Line_Count)); end if; Parse_Data.Initialize (Post_Parse_Action => Post_Parse_Action, Descriptor => Descriptor'Access, Source_File_Name => -Source_File_Name, Line_Count => Line_Count, Params => -Lang_Params); if Repeat_Count > 1 then Start := Ada.Real_Time.Clock; end if; for I in 1 .. Repeat_Count loop declare procedure Clean_Up is begin Parser.Lexer.Discard_Rest_Of_Input; if Repeat_Count = 1 then Parser.Put_Errors (-Source_File_Name); end if; end Clean_Up; begin Parse_Data.Reset; Parser.Lexer.Reset; if Lexer_Only then declare Token : Base_Token; Lexer_Error : Boolean; pragma Unreferenced (Lexer_Error); begin Parser.Lexer.Reset; loop Lexer_Error := Parser.Lexer.Find_Next (Token); exit when Token.ID = Descriptor.EOF_ID; end loop; -- We don't handle errors here; that was done in the count lines loop -- above. end; else Parser.Parse; Parser.Execute_Actions; if Repeat_Count = 1 then Parse_Data.Put; Parser.Put_Errors (-Source_File_Name); end if; end if; exception when WisiToken.Syntax_Error => Clean_Up; Put_Line ("(parse_error)"); when E : WisiToken.Parse_Error => Clean_Up; Put_Line ("(parse_error """ & Ada.Exceptions.Exception_Message (E) & """)"); when E : WisiToken.Fatal_Error => Clean_Up; Put_Line ("(error """ & Ada.Exceptions.Exception_Message (E) & """)"); end; if Pause then Put_Line ("Enter to continue:"); Flush (Standard_Output); declare Junk : constant String := Get_Line; pragma Unreferenced (Junk); begin null; end; end if; end loop; if Repeat_Count > 1 then declare use Ada.Real_Time; Finish : constant Time := Clock; begin Put_Line ("Total time:" & Duration'Image (To_Duration (Finish - Start))); Put_Line ("per iteration:" & Duration'Image (To_Duration ((Finish - Start) / Repeat_Count))); end; end if; exception when E : others => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); New_Line (2); Put_Line ("(error ""unhandled exception: " & Ada.Exceptions.Exception_Name (E) & ": " & Ada.Exceptions.Exception_Message (E) & """)"); Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); end Gen_Run_Wisi_Parse_Packrat;
----------------------------------------------------------------------- -- util-log -- Utility Log Package -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings; with Ada.Strings.Fixed; package body Util.Log is -- ------------------------------ -- Get the log level name. -- ------------------------------ function Get_Level_Name (Level : Level_Type) return String is begin if Level = FATAL_LEVEL then return "FATAL"; elsif Level = ERROR_LEVEL then return "ERROR"; elsif Level = WARN_LEVEL then return "WARN "; elsif Level = INFO_LEVEL then return "INFO "; elsif Level = DEBUG_LEVEL then return "DEBUG"; else return Level_Type'Image (Level); end if; end Get_Level_Name; -- ------------------------------ -- Get the log level from the property value -- ------------------------------ function Get_Level (Value : in String; Default : in Level_Type := INFO_LEVEL) return Level_Type is use Ada.Strings; Val : constant String := Fixed.Trim (Value, Both); Pos : constant Natural := Fixed.Index (Val, ","); begin if Pos > Val'First then return Get_Level (Val (Val'First .. Pos - 1), Default); elsif Val = "INFO" then return INFO_LEVEL; elsif Val = "DEBUG" then return DEBUG_LEVEL; elsif Val = "WARN" then return WARN_LEVEL; elsif Val = "ERROR" then return ERROR_LEVEL; elsif Val = "FATAL" then return FATAL_LEVEL; else return Default; end if; end Get_Level; end Util.Log;
package body Test_Utils.Abstract_Encoder.COBS_Stream is ------------- -- Receive -- ------------- overriding procedure Receive (This : in out Instance; Data : Storage_Element) is begin This.Encoder.Push (Data); end Receive; ------------------ -- End_Of_Frame -- ------------------ overriding procedure End_Of_Frame (This : in out Instance) is begin This.Encoder.End_Frame; for Elt of This.Encoder.Output loop This.Push_To_Frame (Elt); end loop; This.Encoder.Output.Clear; end End_Of_Frame; ------------ -- Update -- ------------ overriding procedure Update (This : in out Instance) is begin null; end Update; ----------------- -- End_Of_Test -- ----------------- overriding procedure End_Of_Test (This : in out Instance) is begin This.Save_Frame; end End_Of_Test; ----------- -- Flush -- ----------- overriding procedure Flush (This : in out Test_Instance; Data : Storage_Array) is begin for Elt of Data loop This.Output.Append (Elt); end loop; end Flush; end Test_Utils.Abstract_Encoder.COBS_Stream;
-- REST API Validation -- API to validate -- ------------ EDIT NOTE ------------ -- This file was generated with swagger-codegen. You can modify it to implement -- the server. After you modify this file, you should add the following line -- to the .swagger-codegen-ignore file: -- -- src/testapi-servers.adb -- -- Then, you can drop this edit note comment. -- ------------ EDIT NOTE ------------ with Ada.Calendar; with Util.Strings; package body TestAPI.Servers is -- Create a ticket overriding procedure Do_Create_Ticket (Server : in out Server_Type; Title : in Swagger.UString; Owner : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString; Description : in Swagger.Nullable_UString; Context : in out Swagger.Servers.Context_Type) is Id : constant Swagger.Long := Server.Last_Id + 1; T : TestAPI.Models.Ticket_Type; begin Server.Last_Id := Id; T.Id := Id; T.Title := Title; if not Description.Is_Null then T.Description := Description.Value; end if; T.Create_Date := Ada.Calendar.Clock; T.Status := Swagger.To_UString ("open"); Server.Todos.Append (T); -- Context.Set_Location ("/tickets/{id}", Id); Context.Set_Location ("/tickets/" & Util.Strings.Image (Integer (Id))); Context.Set_Status (201); end Do_Create_Ticket; -- Delete a ticket overriding procedure Do_Delete_Ticket (Server : in out Server_Type; Tid : in Swagger.Long; Context : in out Swagger.Servers.Context_Type) is Pos : Models.Ticket_Type_Vectors.Cursor := Server.Todos.First; begin while Models.Ticket_Type_Vectors.Has_Element (Pos) loop if Models.Ticket_Type_Vectors.Element (Pos).Id = Tid then Server.Todos.Delete (Pos); Context.Set_Status (204); return; end if; Models.Ticket_Type_Vectors.Next (Pos); end loop; Context.Set_Error (404, "Ticket does not exist"); end Do_Delete_Ticket; -- Update a ticket overriding procedure Do_Update_Ticket (Server : in out Server_Type; Tid : in Swagger.Long; Owner : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString; Title : in Swagger.Nullable_UString; Description : in Swagger.Nullable_UString; Result : out TestAPI.Models.Ticket_Type; Context : in out Swagger.Servers.Context_Type) is procedure Update (T : in out Models.Ticket_Type) is begin if not Title.Is_Null then T.Title := Title.Value; end if; if not Description.Is_Null then T.Description := Description.Value; end if; if not Status.Is_Null then T.Status := Status.Value; end if; end Update; Pos : Models.Ticket_Type_Vectors.Cursor := Server.Todos.First; begin while Models.Ticket_Type_Vectors.Has_Element (Pos) loop if Models.Ticket_Type_Vectors.Element (Pos).Id = Tid then Server.Todos.Update_Element (Pos, Update'Access); Result := Models.Ticket_Type_Vectors.Element (Pos); return; end if; Models.Ticket_Type_Vectors.Next (Pos); end loop; Context.Set_Error (404, "Ticket does not exist"); end Do_Update_Ticket; -- Patch a ticket procedure Do_Patch_Ticket (Server : in out Server_Type; Tid : in Swagger.Long; Owner : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString; Title : in Swagger.Nullable_UString; Description : in Swagger.Nullable_UString; Result : out TestAPI.Models.Ticket_Type; Context : in out Swagger.Servers.Context_Type) is procedure Update (T : in out Models.Ticket_Type) is begin if not Title.Is_Null then T.Title := Title.Value; end if; if not Description.Is_Null then T.Description := Description.Value; end if; if not Status.Is_Null then T.Status := Status.Value; end if; end Update; Pos : Models.Ticket_Type_Vectors.Cursor := Server.Todos.First; begin while Models.Ticket_Type_Vectors.Has_Element (Pos) loop if Models.Ticket_Type_Vectors.Element (Pos).Id = Tid then Server.Todos.Update_Element (Pos, Update'Access); Result := Models.Ticket_Type_Vectors.Element (Pos); return; end if; Models.Ticket_Type_Vectors.Next (Pos); end loop; Context.Set_Error (404, "Ticket does not exist"); end Do_Patch_Ticket; -- Get a ticket -- Get a ticket overriding procedure Do_Get_Ticket (Server : in out Server_Type; Tid : in Swagger.Long; Result : out TestAPI.Models.Ticket_Type; Context : in out Swagger.Servers.Context_Type) is begin for T of Server.Todos loop if T.Id = Tid then Result := T; return; end if; end loop; Context.Set_Error (404, "Ticket does not exist"); end Do_Get_Ticket; -- Get a ticket -- Get a ticket overriding procedure Do_Options_Ticket (Server : in out Server_Type; Tid : in Swagger.Long; Result : out TestAPI.Models.Ticket_Type; Context : in out Swagger.Servers.Context_Type) is begin for T of Server.Todos loop if T.Id = Tid then Result := T; return; end if; end loop; Context.Set_Error (404, "Ticket does not exist"); end Do_Options_Ticket; -- List the tickets overriding procedure Do_Head_Ticket (Server : in out Server_Type; Context : in out Swagger.Servers.Context_Type) is begin null; end Do_Head_Ticket; -- List the tickets -- List the tickets created for the project. overriding procedure Do_List_Tickets (Server : in out Server_Type; Status : in Swagger.Nullable_UString; Owner : in Swagger.Nullable_UString; Result : out TestAPI.Models.Ticket_Type_Vectors.Vector; Context : in out Swagger.Servers.Context_Type) is begin Result := Server.Todos; end Do_List_Tickets; -- -- Query an orchestrated service instance overriding procedure Orch_Store (Server : in out Server_Type; Body2_Type : in InlineObject3_Type; Context : in out Swagger.Servers.Context_Type) is begin null; end Orch_Store; end TestAPI.Servers;
-- A generic sorting package, with a parallel quicksort algorithm: each -- half of the partitioned array is sorted by a separate task. generic type DATA is private; type INDEX is (<>); with function "<"(X,Y: DATA) return BOOLEAN is <> ; package SORTS is type TABLE is array (INDEX range <>) of DATA; procedure QUICKSORT (TAB: in out TABLE); end SORTS; package body SORTS is procedure QUICKSORT( TAB: in out TABLE ) is task type QSORT is entry BOUNDS( L,R: in INDEX ); end QSORT; -- The name of the task cannot be used as a type mark within the -- task body. To allow recursive spawning, we make a subtype of it subtype SQSORT is QSORT; type AQSORT is access QSORT; TSORT:AQSORT; task body QSORT is TRIGHT,TLEFT: AQSORT; LEFT,RIGHT,IL,IR: INDEX; MID,TEMP: DATA; begin accept BOUNDS( L,R: in INDEX ) do -- Acquire bounds of subarray to sort. LEFT := L; RIGHT := R; end BOUNDS; IL := LEFT; IR := RIGHT; -- Pick partitioning element (arbitrarily, in the middle). MID := TAB( INDEX'VAL( (INDEX'POS(IL)+INDEX'POS(IR))/2) ); loop -- partitioning step. while TAB(IL) < MID loop IL:=INDEX'SUCC(IL); end loop; while MID < TAB(IR) loop IR:=INDEX'PRED(IR); end loop; if IL <= IR then TEMP := TAB(IL); TAB(IL) := TAB(IR); TAB(IR) := TEMP; IL:=INDEX'SUCC(IL); IR:=INDEX'PRED(IR); end if; exit when IL > IR; end loop; if LEFT < IR then -- spawn new task for left side. TLEFT := new SQSORT; TLEFT.BOUNDS(LEFT,IR); end if; if IL < RIGHT then -- ditto for right side. TRIGHT := new SQSORT; TRIGHT.BOUNDS(IL,RIGHT); end if; end QSORT; begin TSORT := new QSORT; -- Main task for whole array. TSORT.BOUNDS( TAB'FIRST, TAB'LAST ); end QUICKSORT; end SORTS; with SORTS; with TEXT_IO; use TEXT_IO; procedure MAIN is package SORT_I is new SORTS( INTEGER, INTEGER) ; package SORT_C is new SORTS( CHARACTER, INTEGER) ; use SORT_I, SORT_C ; package INT_IO is new INTEGER_IO(integer); use INT_IO; subtype VECT is SORT_I.TABLE(1..8); subtype CHRS is SORT_C.TABLE(1..8); A: VECT := (-7, 14, 1, 92, 8,-6, 3, 2); B: CHRS := "Alleluia" ; begin put_line("Sort integers") ; QUICKSORT(A); for I in A'RANGE loop PUT (A(I)); end loop; NEW_LINE; put_line("Sort characters") ; QUICKSORT(B); for I in B'RANGE loop PUT (B(I)); end loop; NEW_LINE; end MAIN;
------------------------------------------------------------------------------ -- Copyright (c) 2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Ada.Calendar.Arithmetic; package body Natools.Time_Keys is function Extract_Sub_Second (Key : String) return Duration; -- Read the end of Buffer and compute the Sub_Second part ------------------------------ -- Local Helper Subprograms -- ------------------------------ function Extract_Sub_Second (Key : String) return Duration is Sub_Second : Duration := 0.0; begin for I in reverse Key'First + 7 .. Key'Last loop Sub_Second := (Sub_Second + Duration (Value (Key (I)))) / 32; Sub_Second := (Sub_Second + Duration'Small) / 2; end loop; return Sub_Second; end Extract_Sub_Second; ----------------------- -- Publoic Interface -- ----------------------- function To_Key (Time : Ada.Calendar.Time; Max_Sub_Second_Digits : in Natural := 120) return String is Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; Hour : Ada.Calendar.Formatting.Hour_Number; Minute : Ada.Calendar.Formatting.Minute_Number; Second : Ada.Calendar.Formatting.Second_Number; Sub_Second : Ada.Calendar.Formatting.Second_Duration; Leap_Second : Boolean; begin Ada.Calendar.Formatting.Split (Time, Year, Month, Day, Hour, Minute, Second, Sub_Second, Leap_Second); return To_Key (Year, Month, Day, Hour, Minute, Second, Sub_Second, Leap_Second, Max_Sub_Second_Digits); end To_Key; function To_Key (Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; Hour : Ada.Calendar.Formatting.Hour_Number := 0; Minute : Ada.Calendar.Formatting.Minute_Number := 0; Second : Ada.Calendar.Formatting.Second_Number := 0; Sub_Second : Ada.Calendar.Formatting.Second_Duration := 0.0; Leap_Second : Boolean := False; Max_Sub_Second_Digits : Natural := 120) return String is procedure Increment_Buffer; Buffer : String (1 .. 7 + Max_Sub_Second_Digits); Last : Positive; procedure Increment_Buffer is begin while Last > 7 and then Buffer (Last) = '~' loop Last := Last - 1; end loop; if Last > 7 then Buffer (Last) := Image (Value (Buffer (Last)) + 1); return; end if; if Second <= 58 then Buffer (7) := I_Image (Second + 1); Last := 7; elsif Minute <= 58 then Buffer (6) := I_Image (Minute + 1); Last := 6; elsif Hour <= 22 then Buffer (5) := I_Image (Hour + 1); Last := 5; else Buffer (1 .. 4) := To_Key (Ada.Calendar.Arithmetic."+" (Ada.Calendar.Formatting.Time_Of (Year, Month, Day), 1)); Last := 4; end if; end Increment_Buffer; N : Natural; D, Base : Duration; begin Buffer (1) := I_Image (Year / 64); Buffer (2) := I_Image (Year mod 64); Buffer (3) := I_Image (Month); Buffer (4) := I_Image (Day); Buffer (5) := I_Image (Hour); Buffer (6) := I_Image (Minute); if Leap_Second then pragma Assert (Second = 59); Buffer (7) := I_Image (60); else Buffer (7) := I_Image (Second); end if; if Sub_Second = 0.0 then if Second = 0 then if Minute = 0 then if Hour = 0 then return Buffer (1 .. 4); else return Buffer (1 .. 5); end if; else return Buffer (1 .. 6); end if; else return Buffer (1 .. 7); end if; end if; Last := 7; D := Sub_Second * 64; Base := 1.0; loop Last := Last + 1; Base := Base / 64.0; N := Natural (D); if Last = Buffer'Last or Base = 0.0 then if N < 64 then Buffer (Last) := I_Image (N); else Last := Last - 1; Increment_Buffer; end if; exit; end if; if Duration (N) > D then N := N - 1; pragma Assert (Duration (N) <= D); end if; D := (D - Duration (N)) * 64; Buffer (Last) := I_Image (N); exit when D = 0.0; end loop; return Buffer (1 .. Last); end To_Key; function To_Time (Key : String) return Ada.Calendar.Time is Leap_Second : constant Boolean := Key'First + 6 in Key'Range and then Key (Key'First + 6) = 'x'; begin return Ada.Calendar.Formatting.Time_Of (Year => I_Value (Key (Key'First)) * 64 + I_Value (Key (Key'First + 1)), Month => I_Value (Key (Key'First + 2)), Day => I_Value (Key (Key'First + 3)), Hour => (if Key'First + 4 in Key'Range then I_Value (Key (Key'First + 4)) else 0), Minute => (if Key'First + 5 in Key'Range then I_Value (Key (Key'First + 5)) else 0), Second => (if Key'First + 6 in Key'Range then (if Leap_Second then 59 else I_Value (Key (Key'First + 6))) else 0), Sub_Second => Extract_Sub_Second (Key), Leap_Second => Leap_Second); end To_Time; end Natools.Time_Keys;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.WWDG; use STM32_SVD.WWDG; package body STM32.WWDG is --------------------------- -- Enable_Watchdog_Clock -- --------------------------- procedure Enable_Watchdog_Clock is begin RCC_Periph.APB1ENR.WWDGEN := True; end Enable_Watchdog_Clock; -------------------- -- Reset_Watchdog -- -------------------- procedure Reset_Watchdog is begin RCC_Periph.APB1RSTR.WWDGRST := True; RCC_Periph.APB1RSTR.WWDGRST := False; end Reset_Watchdog; ---------------------------- -- Set_Watchdog_Prescaler -- ---------------------------- procedure Set_Watchdog_Prescaler (Value : Prescalers) is begin -- WWDG_Periph.CFR.WDGTB.Val := Value'Enum_Rep; WWDG_Periph.CFR.WDGTB := Value'Enum_Rep; end Set_Watchdog_Prescaler; ------------------------- -- Set_Watchdog_Window -- ------------------------- procedure Set_Watchdog_Window (Window_Start_Count : Downcounter) is begin WWDG_Periph.CFR.W := Window_Start_Count; end Set_Watchdog_Window; ----------------------- -- Activate_Watchdog -- ----------------------- procedure Activate_Watchdog (New_Count : Downcounter) is begin WWDG_Periph.CR.T := New_Count; WWDG_Periph.CR.WDGA := True; end Activate_Watchdog; ------------------------------ -- Refresh_Watchdog_Counter -- ------------------------------ procedure Refresh_Watchdog_Counter (New_Count : Downcounter) is begin WWDG_Periph.CR.T := New_Count; end Refresh_Watchdog_Counter; ----------------------------------- -- Enable_Early_Wakeup_Interrupt -- ----------------------------------- procedure Enable_Early_Wakeup_Interrupt is begin WWDG_Periph.CFR.EWI := True; end Enable_Early_Wakeup_Interrupt; -------------------------------------- -- Early_Wakeup_Interrupt_Indicated -- -------------------------------------- function Early_Wakeup_Interrupt_Indicated return Boolean is (WWDG_Periph.SR.EWIF); ---------------------------------- -- Clear_Early_Wakeup_Interrupt -- ---------------------------------- procedure Clear_Early_Wakeup_Interrupt is begin WWDG_Periph.SR.EWIF := False; end Clear_Early_Wakeup_Interrupt; -------------------------- -- WWDG_Reset_Indicated -- -------------------------- function WWDG_Reset_Indicated return Boolean is (RCC_Periph.CSR.WWDGRSTF); --------------------------- -- Clear_WWDG_Reset_Flag -- --------------------------- procedure Clear_WWDG_Reset_Flag is begin RCC_Periph.CSR.RMVF := True; end Clear_WWDG_Reset_Flag; ------------------ -- Reset_System -- ------------------ procedure Reset_System is begin WWDG_Periph.CR.T := 0; WWDG_Periph.CR.WDGA := True; end Reset_System; end STM32.WWDG;
-- COMPILEMON.adb -- Programa per compilar el compilador with Ada.Text_IO, Ada.Command_Line, Decls.D_Taula_De_Noms, Decls.Dgenerals, Decls.Dtdesc, Pk_Usintactica_Tokens, Pk_Ulexica_Io, U_Lexica, Pk_Usintactica, Decls.D_Atribut, Semantica, Decls.Dtnode, Semantica.Ctipus, Semantica.Declsc3a, Semantica.Gci, Semantica.Assemblador; use Ada.Text_IO, Ada.Command_Line, Decls.D_Taula_De_Noms, Decls.Dgenerals, Decls.Dtdesc, Pk_Usintactica_Tokens, Pk_Ulexica_Io, U_Lexica, Pk_Usintactica, Decls.D_Atribut, Semantica, Decls.Dtnode, Semantica.Ctipus, Semantica.Declsc3a, Semantica.Gci, Semantica.Assemblador; procedure Compilemon is begin Open_Input(Argument(1)); Inicia_analisi(Argument(1)); yyparse; --Comprovacio de tipus Ct_Programa(Arbre); if not esem then -- Generacio de codi intermedi Inicia_Generacio(Argument(1)); Gci_Programa(Arbre); -- Generacio de codi assemblador Genera_Assemblador(Argument(1)); end if; Close_Input; exception when Syntax_Error => Put_Line("ERROR CompiLEMON: Error a la linea " &yy_line_number'img& " i columna "&yy_begin_column'img); end compilemon;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S I N P U T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the input routines used for reading the -- input source file. The actual I/O routines are in OS_Interface, -- with this module containing only the system independent processing. -- General Note: throughout the compiler, we use the term line or source -- line to refer to a physical line in the source, terminated by the end of -- physical line sequence. -- There are two distinct concepts of line terminator in GNAT -- A logical line terminator is what corresponds to the "end of a line" as -- described in RM 2.2 (13). Any of the characters FF, LF, CR or VT or any -- wide character that is a Line or Paragraph Separator acts as an end of -- logical line in this sense, and it is essentially irrelevant whether one -- or more appears in sequence (since if sequence of such characters is -- regarded as separate ends of line, then the intervening logical lines -- are null in any case). -- A physical line terminator is a sequence of format effectors that is -- treated as ending a physical line. Physical lines have no Ada semantic -- significance, but they are significant for error reporting purposes, -- since errors are identified by line and column location. -- In GNAT, a physical line is ended by any of the sequences LF, CR/LF, CR or -- LF/CR. LF is used in typical Unix systems, CR/LF in DOS systems, and CR -- alone in System 7. We don't know of any system using LF/CR, but it seems -- reasonable to include this case for consistency. In addition, we recognize -- any of these sequences in any of the operating systems, for better -- behavior in treating foreign files (e.g. a Unix file with LF terminators -- transferred to a DOS system). Finally, wide character codes in cagtegories -- Separator, Line and Separator, Paragraph are considered to be physical -- line terminators. with Alloc; with Casing; use Casing; with Table; with Types; use Types; package Sinput is type Type_Of_File is ( -- Indicates type of file being read Src, -- Normal Ada source file Config, -- Configuration pragma file Def, -- Preprocessing definition file Preproc); -- Source file with preprocessing commands to be preprocessed ---------------------------- -- Source License Control -- ---------------------------- -- The following type indicates the license state of a source if it -- is known. type License_Type is (Unknown, -- Licensing status of this source unit is unknown Restricted, -- This is a non-GPL'ed unit that is restricted from depending -- on GPL'ed units (e.g. proprietary code is in this category) GPL, -- This file is licensed under the unmodified GPL. It is not allowed -- to depend on Non_GPL units, and Non_GPL units may not depend on -- this source unit. Modified_GPL, -- This file is licensed under the GNAT modified GPL (see header of -- This file for wording of the modification). It may depend on other -- Modified_GPL units or on unrestricted units. Unrestricted); -- The license on this file is permitted to depend on any other -- units, or have other units depend on it, without violating the -- license of this unit. Examples are public domain units, and -- units defined in the RM). -- The above license status is checked when the appropriate check is -- activated and one source depends on another, and the licensing state -- of both files is known: -- The prohibited combinations are: -- Restricted file may not depend on GPL file -- GPL file may not depend on Restricted file -- Modified GPL file may not depend on Restricted file -- Modified_GPL file may not depend on GPL file -- The reason for the last restriction here is that a client depending -- on a modified GPL file must be sure that the license condition is -- correct considered transitively. -- The licensing status is determined either by the presence of a -- specific pragma License, or by scanning the header for a predefined -- file, or any file if compiling in -gnatg mode. ----------------------- -- Source File Table -- ----------------------- -- The source file table has an entry for each source file read in for -- this run of the compiler. This table is (default) initialized when -- the compiler is loaded, and simply accumulates entries as compilation -- proceeds and various routines in Sinput and its child packages are -- called to load required source files. -- Virtual entries are also created for generic templates when they are -- instantiated, as described in a separate section later on. -- In the case where there are multiple main units (e.g. in the case of -- the cross-reference tool), this table is not reset between these units, -- so that a given source file is only read once if it is used by two -- separate main units. -- The entries in the table are accessed using a Source_File_Index that -- ranges from 1 to Last_Source_File. Each entry has the following fields -- Note: fields marked read-only are set by Sinput or one of its child -- packages when a source file table entry is created, and cannot be -- subsqently modified, or alternatively are set only by very special -- circumstances, documented in the comments. -- File_Name : File_Name_Type (read-only) -- Name of the source file (simple name with no directory information) -- Full_File_Name : File_Name_Type (read-only) -- Full file name (full name with directory info), used for generation -- of error messages, etc. -- File_Type : Type_Of_File (read-only) -- Indicates type of file (source file, configuration pragmas file, -- preprocessor definition file, preprocessor input file). -- Reference_Name : File_Name_Type (read-only) -- Name to be used for source file references in error messages where -- only the simple name of the file is required. Identical to File_Name -- unless pragma Source_Reference is used to change it. Only processing -- for the Source_Reference pragma circuit may set this field. -- Full_Ref_Name : File_Name_Type (read-only) -- Name to be used for source file references in error messages where -- the full name of the file is required. Identical to Full_File_Name -- unless pragma Source_Reference is used to change it. Only processing -- for the Source_Reference pragma may set this field. -- Debug_Source_Name : File_Name_Type (read-only) -- Name to be used for source file references in debugging information -- where only the simple name of the file is required. Identical to -- Reference_Name unless the -gnatD (debug source file) switch is used. -- Only processing in Sprint that generates this file is permitted to -- set this field. -- Full_Debug_Name : File_Name_Type (read-only) -- Name to be used for source file references in debugging information -- where the full name of the file is required. This is identical to -- Full_Ref_Name unless the -gnatD (debug source file) switch is used. -- Only processing in Sprint that generates this file is permitted to -- set this field. -- License : License_Type; -- License status of source file -- Num_SRef_Pragmas : Nat; -- Number of source reference pragmas present in source file -- First_Mapped_Line : Logical_Line_Number; -- This field stores logical line number of the first line in the -- file that is not a Source_Reference pragma. If no source reference -- pragmas are used, then the value is set to No_Line_Number. -- Source_Text : Source_Buffer_Ptr (read-only) -- Text of source file. Note that every source file has a distinct set -- of non-overlapping logical bounds, so it is possible to determine -- which file is referenced from a given subscript (Source_Ptr) value. -- Source_First : Source_Ptr; (read-only) -- Subscript of first character in Source_Text. Note that this cannot -- be obtained as Source_Text'First, because we use virtual origin -- addressing. -- Source_Last : Source_Ptr; (read-only) -- Subscript of last character in Source_Text. Note that this cannot -- be obtained as Source_Text'Last, because we use virtual origin -- addressing, so this value is always Source_Ptr'Last. -- Time_Stamp : Time_Stamp_Type; (read-only) -- Time stamp of the source file -- Source_Checksum : Word; -- Computed checksum for contents of source file. See separate section -- later on in this spec for a description of the checksum algorithm. -- Last_Source_Line : Physical_Line_Number; -- Physical line number of last source line. Whlie a file is being -- read, this refers to the last line scanned. Once a file has been -- completely scanned, it is the number of the last line in the file, -- and hence also gives the number of source lines in the file. -- Keyword_Casing : Casing_Type; -- Casing style used in file for keyword casing. This is initialized -- to Unknown, and then set from the first occurrence of a keyword. -- This value is used only for formatting of error messages. -- Identifier_Casing : Casing_Type; -- Casing style used in file for identifier casing. This is initialized -- to Unknown, and then set from an identifier in the program as soon as -- one is found whose casing is sufficiently clear to make a decision. -- This value is used for formatting of error messages, and also is used -- in the detection of keywords misused as identifiers. -- Instantiation : Source_Ptr; -- Source file location of the instantiation if this source file entry -- represents a generic instantiation. Set to No_Location for the case -- of a normal non-instantiation entry. See section below for details. -- This field is read-only for clients. -- Inlined_Body : Boolean; -- This can only be set True if Instantiation has a value other than -- No_Location. If true it indicates that the instantiation is actually -- an instance of an inlined body. -- Template : Source_File_Index; (read-only) -- Source file index of the source file containing the template if this -- is a generic instantiation. Set to No_Source_File for the normal case -- of a non-instantiation entry. See Sinput-L for details. -- Unit : Unit_Number_Type; -- Identifies the unit contained in this source file. Set by -- Initialize_Scanner, must not be subsequently altered. -- The source file table is accessed by clients using the following -- subprogram interface: subtype SFI is Source_File_Index; System_Source_File_Index : SFI; -- The file system.ads is always read by the compiler to determine the -- settings of the target parameters in the private part of System. This -- variable records the source file index of system.ads. Typically this -- will be 1 since system.ads is read first. function Debug_Source_Name (S : SFI) return File_Name_Type; function File_Name (S : SFI) return File_Name_Type; function File_Type (S : SFI) return Type_Of_File; function First_Mapped_Line (S : SFI) return Logical_Line_Number; function Full_Debug_Name (S : SFI) return File_Name_Type; function Full_File_Name (S : SFI) return File_Name_Type; function Full_Ref_Name (S : SFI) return File_Name_Type; function Identifier_Casing (S : SFI) return Casing_Type; function Inlined_Body (S : SFI) return Boolean; function Instantiation (S : SFI) return Source_Ptr; function Keyword_Casing (S : SFI) return Casing_Type; function Last_Source_Line (S : SFI) return Physical_Line_Number; function License (S : SFI) return License_Type; function Num_SRef_Pragmas (S : SFI) return Nat; function Reference_Name (S : SFI) return File_Name_Type; function Source_Checksum (S : SFI) return Word; function Source_First (S : SFI) return Source_Ptr; function Source_Last (S : SFI) return Source_Ptr; function Source_Text (S : SFI) return Source_Buffer_Ptr; function Template (S : SFI) return Source_File_Index; function Unit (S : SFI) return Unit_Number_Type; function Time_Stamp (S : SFI) return Time_Stamp_Type; procedure Set_Keyword_Casing (S : SFI; C : Casing_Type); procedure Set_Identifier_Casing (S : SFI; C : Casing_Type); procedure Set_License (S : SFI; L : License_Type); procedure Set_Unit (S : SFI; U : Unit_Number_Type); function Last_Source_File return Source_File_Index; -- Index of last source file table entry function Num_Source_Files return Nat; -- Number of source file table entries procedure Initialize; -- Initialize internal tables procedure Lock; -- Lock internal tables Main_Source_File : Source_File_Index := No_Source_File; -- This is set to the source file index of the main unit ----------------------------- -- Source_File_Index_Table -- ----------------------------- -- The Get_Source_File_Index function is called very frequently. Earlier -- versions cached a single entry, but then reverted to a serial search, -- and this proved to be a significant source of inefficiency. To get -- around this, we use the following directly indexed array. The space -- of possible input values is a value of type Source_Ptr which is simply -- an Int value. The values in this space are allocated sequentially as -- new units are loaded. -- The following table has an entry for each 4K range of possible -- Source_Ptr values. The value in the table is the lowest value -- Source_File_Index whose Source_Ptr range contains value in the -- range. -- For example, the entry with index 4 in this table represents Source_Ptr -- values in the range 4*4096 .. 5*4096-1. The Source_File_Index value -- stored would be the lowest numbered source file with at least one byte -- in this range. -- The algorithm used in Get_Source_File_Index is simply to access this -- table and then do a serial search starting at the given position. This -- will almost always terminate with one or two checks. -- Note that this array is pretty large, but in most operating systems -- it will not be allocated in physical memory unless it is actually used. Chunk_Power : constant := 12; Chunk_Size : constant := 2 ** Chunk_Power; -- Change comments above if value changed. Note that Chunk_Size must -- be a power of 2 (to allow for efficient access to the table). Source_File_Index_Table : array (Int range 0 .. Int'Last / Chunk_Size) of Source_File_Index; procedure Set_Source_File_Index_Table (Xnew : Source_File_Index); -- Sets entries in the Source_File_Index_Table for the newly created -- Source_File table entry whose index is Xnew. The Source_First and -- Source_Last fields of this entry must be set before the call. ----------------------- -- Checksum Handling -- ----------------------- -- As a source file is scanned, a checksum is computed by taking all the -- non-blank characters in the file, excluding comment characters, the -- minus-minus sequence starting a comment, and all control characters -- except ESC. -- The checksum algorithm used is the standard CRC-32 algorithm, as -- implemented by System.CRC32, except that we do not bother with the -- final XOR with all 1 bits. -- This algorithm ensures that the checksum includes all semantically -- significant aspects of the program represented by the source file, -- but is insensitive to layout, presence or contents of comments, wide -- character representation method, or casing conventions outside strings. -- Scans.Checksum is initialized appropriately at the start of scanning -- a file, and copied into the Source_Checksum field of the file table -- entry when the end of file is encountered. ------------------------------------- -- Handling Generic Instantiations -- ------------------------------------- -- As described in Sem_Ch12, a generic instantiation involves making a -- copy of the tree of the generic template. The source locations in -- this tree directly reference the source of the template. However it -- is also possible to find the location of the instantiation. -- This is achieved as follows. When an instantiation occurs, a new entry -- is made in the source file table. This entry points to the same source -- text, i.e. the file that contains the instantiation, but has a distinct -- set of Source_Ptr index values. The separate range of Sloc values avoids -- confusion, and means that the Sloc values can still be used to uniquely -- identify the source file table entry. It is possible for both entries -- to point to the same text, because of the virtual origin pointers used -- in the source table. -- The Instantiation field of this source file index entry, usually set -- to No_Source_File, instead contains the Sloc of the instantiation. In -- the case of nested instantiations, this Sloc may itself refer to an -- instantiation, so the complete chain can be traced. -- Two routines are used to build these special entries in the source -- file table. Create_Instantiation_Source is first called to build -- the virtual source table entry for the instantiation, and then the -- Sloc values in the copy are adjusted using Adjust_Instantiation_Sloc. -- See child unit Sinput.L for details on these two routines. ----------------- -- Global Data -- ----------------- Current_Source_File : Source_File_Index; -- Source_File table index of source file currently being scanned Current_Source_Unit : Unit_Number_Type; -- Unit number of source file currently being scanned. The special value -- of No_Unit indicates that the configuration pragma file is currently -- being scanned (this has no entry in the unit table). Source_gnat_adc : Source_File_Index := No_Source_File; -- This is set if a gnat.adc file is present to reference this file Source : Source_Buffer_Ptr; -- Current source (copy of Source_File.Table (Current_Source_Unit).Source) Internal_Source : aliased Source_Buffer (1 .. 81); -- This buffer is used internally in the compiler when the lexical analyzer -- is used to scan a string from within the compiler. The procedure is to -- establish Internal_Source_Ptr as the value of Source, set the string to -- be scanned, appropriately terminated, in this buffer, and set Scan_Ptr -- to point to the start of the buffer. It is a fatal error if the scanner -- signals an error while scanning a token in this internal buffer. Internal_Source_Ptr : constant Source_Buffer_Ptr := Internal_Source'Unrestricted_Access; -- Pointer to internal source buffer ----------------- -- Subprograms -- ----------------- procedure Backup_Line (P : in out Source_Ptr); -- Back up the argument pointer to the start of the previous line. On -- entry, P points to the start of a physical line in the source buffer. -- On return, P is updated to point to the start of the previous line. -- The caller has checked that a Line_Terminator character precedes P so -- that there definitely is a previous line in the source buffer. procedure Build_Location_String (Loc : Source_Ptr); -- This function builds a string literal of the form "name:line", -- where name is the file name corresponding to Loc, and line is -- the line number. In the event that instantiations are involved, -- additional suffixes of the same form are appended after the -- separating string " instantiated at ". The returned string is -- stored in Name_Buffer, terminated by ASCII.Nul, with Name_Length -- indicating the length not including the terminating Nul. function Get_Column_Number (P : Source_Ptr) return Column_Number; -- The ones-origin column number of the specified Source_Ptr value is -- determined and returned. Tab characters if present are assumed to -- represent the standard 1,9,17.. spacing pattern. function Get_Logical_Line_Number (P : Source_Ptr) return Logical_Line_Number; -- The line number of the specified source position is obtained by -- doing a binary search on the source positions in the lines table -- for the unit containing the given source position. The returned -- value is the logical line number, already adjusted for the effect -- of source reference pragmas. If P refers to the line of a source -- reference pragma itself, then No_Line is returned. If no source -- reference pragmas have been encountered, the value returned is -- the same as the physical line number. function Get_Physical_Line_Number (P : Source_Ptr) return Physical_Line_Number; -- The line number of the specified source position is obtained by -- doing a binary search on the source positions in the lines table -- for the unit containing the given source position. The returned -- value is the physical line number in the source being compiled. function Get_Source_File_Index (S : Source_Ptr) return Source_File_Index; -- Return file table index of file identified by given source pointer -- value. This call must always succeed, since any valid source pointer -- value belongs to some previously loaded source file. function Instantiation_Depth (S : Source_Ptr) return Nat; -- Determine instantiation depth for given Sloc value. A value of -- zero means that the given Sloc is not in an instantiation. function Line_Start (P : Source_Ptr) return Source_Ptr; -- Finds the source position of the start of the line containing the -- given source location. function Line_Start (L : Physical_Line_Number; S : Source_File_Index) return Source_Ptr; -- Finds the source position of the start of the given line in the -- given source file, using a physical line number to identify the line. function Num_Source_Lines (S : Source_File_Index) return Nat; -- Returns the number of source lines (this is equivalent to reading -- the value of Last_Source_Line, but returns Nat rathern than a -- physical line number. procedure Register_Source_Ref_Pragma (File_Name : Name_Id; Stripped_File_Name : Name_Id; Mapped_Line : Nat; Line_After_Pragma : Physical_Line_Number); -- Register a source reference pragma, the parameter File_Name is the -- file name from the pragma, and Stripped_File_Name is this name with -- the directory information stripped. Both these parameters are set -- to No_Name if no file name parameter was given in the pragma. -- (which can only happen for the second and subsequent pragmas). -- Mapped_Line is the line number parameter from the pragma, and -- Line_After_Pragma is the physical line number of the line that -- follows the line containing the Source_Reference pragma. function Original_Location (S : Source_Ptr) return Source_Ptr; -- Given a source pointer S, returns the corresponding source pointer -- value ignoring instantiation copies. For locations that do not -- correspond to instantiation copies of templates, the argument is -- returned unchanged. For locations that do correspond to copies of -- templates from instantiations, the location within the original -- template is returned. This is useful in canonicalizing locations. function Instantiation_Location (S : Source_Ptr) return Source_Ptr; pragma Inline (Instantiation_Location); -- Given a source pointer S, returns the corresponding source pointer -- value of the instantiation if this location is within an instance. -- If S is not within an instance, then this returns No_Location. function Top_Level_Location (S : Source_Ptr) return Source_Ptr; -- Given a source pointer S, returns the argument unchanged if it is -- not in an instantiation. If S is in an instantiation, then it returns -- the location of the top level instantiation, i.e. the outer level -- instantiation in the nested case. function Physical_To_Logical (Line : Physical_Line_Number; S : Source_File_Index) return Logical_Line_Number; -- Given a physical line number in source file whose source index is S, -- return the corresponding logical line number. If the physical line -- number is one containing a Source_Reference pragma, the result will -- be No_Line_Number. procedure Skip_Line_Terminators (P : in out Source_Ptr; Physical : out Boolean); -- On entry, P points to a line terminator that has been encountered, -- which is one of FF,LF,VT,CR or a wide character sequence whose value is -- in category Separator,Line or Separator,Paragraph. The purpose of this -- P points just past the character that was scanned. The purpose of this -- routine is to distinguish physical and logical line endings. A physical -- line ending is one of: -- -- CR on its own (MAC System 7) -- LF on its own (Unix and unix-like systems) -- CR/LF (DOS, Windows) -- LF/CR (not used, but recognized in any case) -- Wide character in Separator,Line or Separator,Paragraph category -- -- A logical line ending (that is not a physical line ending) is one of: -- -- VT on its own -- FF on its own -- -- On return, P is bumped past the line ending sequence (one of the above -- seven possibilities). Physical is set to True to indicate that a -- physical end of line was encountered, in which case this routine also -- makes sure that the lines table for the current source file has an -- appropriate entry for the start of the new physical line. function Source_Offset (S : Source_Ptr) return Nat; -- Returns the zero-origin offset of the given source location from the -- start of its corresponding unit. This is used for creating canonical -- names in some situations. procedure Write_Location (P : Source_Ptr); -- Writes out a string of the form fff:nn:cc, where fff, nn, cc are the -- file name, line number and column corresponding to the given source -- location. No_Location and Standard_Location appear as the strings -- <no location> and <standard location>. If the location is within an -- instantiation, then the instance location is appended, enclosed in -- square brackets (which can nest if necessary). Note that this routine -- is used only for internal compiler debugging output purposes (which -- is why the somewhat cryptic use of brackets is acceptable). procedure wl (P : Source_Ptr); pragma Export (Ada, wl); -- Equivalent to Write_Location (P); Write_Eol; for calls from GDB procedure Write_Time_Stamp (S : Source_File_Index); -- Writes time stamp of specified file in YY-MM-DD HH:MM.SS format procedure Tree_Read; -- Initializes internal tables from current tree file using the relevant -- Table.Tree_Read routines. procedure Tree_Write; -- Writes out internal tables to current tree file using the relevant -- Table.Tree_Write routines. private pragma Inline (File_Name); pragma Inline (First_Mapped_Line); pragma Inline (Full_File_Name); pragma Inline (Identifier_Casing); pragma Inline (Instantiation); pragma Inline (Keyword_Casing); pragma Inline (Last_Source_Line); pragma Inline (Last_Source_File); pragma Inline (License); pragma Inline (Num_SRef_Pragmas); pragma Inline (Num_Source_Files); pragma Inline (Num_Source_Lines); pragma Inline (Reference_Name); pragma Inline (Set_Keyword_Casing); pragma Inline (Set_Identifier_Casing); pragma Inline (Source_First); pragma Inline (Source_Last); pragma Inline (Source_Text); pragma Inline (Template); pragma Inline (Time_Stamp); ------------------------- -- Source_Lines Tables -- ------------------------- type Lines_Table_Type is array (Physical_Line_Number) of Source_Ptr; -- Type used for lines table. The entries are indexed by physical line -- numbers. The values are the starting Source_Ptr values for the start -- of the corresponding physical line. Note that we make this a bogus -- big array, sized as required, so that we avoid the use of fat pointers. type Lines_Table_Ptr is access all Lines_Table_Type; -- Type used for pointers to line tables type Logical_Lines_Table_Type is array (Physical_Line_Number) of Logical_Line_Number; -- Type used for logical lines table. This table is used if a source -- reference pragma is present. It is indexed by physical line numbers, -- and contains the corresponding logical line numbers. An entry that -- corresponds to a source reference pragma is set to No_Line_Number. -- Note that we make this a bogus big array, sized as required, so that -- we avoid the use of fat pointers. type Logical_Lines_Table_Ptr is access all Logical_Lines_Table_Type; -- Type used for pointers to logical line tables ----------------------- -- Source_File Table -- ----------------------- -- See earlier descriptions for meanings of public fields type Source_File_Record is record File_Name : File_Name_Type; File_Type : Type_Of_File; Reference_Name : File_Name_Type; Debug_Source_Name : File_Name_Type; Full_Debug_Name : File_Name_Type; Full_File_Name : File_Name_Type; Full_Ref_Name : File_Name_Type; Inlined_Body : Boolean; License : License_Type; Num_SRef_Pragmas : Nat; First_Mapped_Line : Logical_Line_Number; Source_Text : Source_Buffer_Ptr; Source_First : Source_Ptr; Source_Last : Source_Ptr; Time_Stamp : Time_Stamp_Type; Source_Checksum : Word; Last_Source_Line : Physical_Line_Number; Keyword_Casing : Casing_Type; Identifier_Casing : Casing_Type; Instantiation : Source_Ptr; Template : Source_File_Index; Unit : Unit_Number_Type; -- The following fields are for internal use only (i.e. only in the -- body of Sinput or its children, with no direct access by clients). Sloc_Adjust : Source_Ptr; -- A value to be added to Sloc values for this file to reference the -- corresponding lines table. This is zero for the non-instantiation -- case, and set so that the adition references the ultimate template -- for the instantiation case. See Sinput-L for further details. Lines_Table : Lines_Table_Ptr; -- Pointer to lines table for this source. Updated as additional -- lines are accessed using the Skip_Line_Terminators procedure. -- Note: the lines table for an instantiation entry refers to the -- original line numbers of the template see Sinput-L for details. Logical_Lines_Table : Logical_Lines_Table_Ptr; -- Pointer to logical lines table for this source. Non-null only if -- a source reference pragma has been processed. Updated as lines -- are accessed using the Skip_Line_Terminators procedure. Lines_Table_Max : Physical_Line_Number; -- Maximum subscript values for currently allocated Lines_Table -- and (if present) the allocated Logical_Lines_Table. The value -- Max_Source_Line gives the maximum used value, this gives the -- maximum allocated value. end record; package Source_File is new Table.Table ( Table_Component_Type => Source_File_Record, Table_Index_Type => Source_File_Index, Table_Low_Bound => 1, Table_Initial => Alloc.Source_File_Initial, Table_Increment => Alloc.Source_File_Increment, Table_Name => "Source_File"); ----------------- -- Subprograms -- ----------------- procedure Alloc_Line_Tables (S : in out Source_File_Record; New_Max : Nat); -- Allocate or reallocate the lines table for the given source file so -- that it can accommodate at least New_Max lines. Also allocates or -- reallocates logical lines table if source ref pragmas are present. procedure Add_Line_Tables_Entry (S : in out Source_File_Record; P : Source_Ptr); -- Increment line table size by one (reallocating the lines table if -- needed) and set the new entry to contain the value P. Also bumps -- the Source_Line_Count field. If source reference pragmas are -- present, also increments logical lines table size by one, and -- sets new entry. procedure Trim_Lines_Table (S : Source_File_Index); -- Set lines table size for entry S in the source file table to -- correspond to the current value of Num_Source_Lines, releasing -- any unused storage. This is used by Sinput.L and Sinput.D. end Sinput;
with System; use System; with STM32GD; with STM32_SVD; use STM32_SVD; with STM32_SVD.Flash; use STM32_SVD.Flash; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.PWR; use STM32_SVD.PWR; with STM32_SVD.GPIO; use STM32_SVD.GPIO; with STM32_SVD.RTC; use STM32_SVD.RTC; with STM32GD.Board; use STM32GD.Board; with STM32GD.GPIO; package body Power is procedure Deactivate_Peripherals is begin RCC_Periph.AHBENR.IOPAEN := 1; RCC_Periph.AHBENR.IOPBEN := 1; RCC_Periph.AHBENR.IOPCEN := 1; RCC_Periph.AHBENR.IOPDEN := 1; RCC_Periph.AHBENR.IOPFEN := 1; GPIOA_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOB_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOC_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOD_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOF_Periph.MODER.Val := 16#FFFF_FFFF#; MOSI.Set_Mode (STM32GD.GPIO.Mode_In); MOSI.Set_Pull_Resistor (STM32GD.GPIO.Pull_Down); MISO.Set_Mode (STM32GD.GPIO.Mode_In); MISO.Set_Pull_Resistor (STM32GD.GPIO.Pull_Down); SCLK.Set_Mode (STM32GD.GPIO.Mode_In); SCLK.Set_Pull_Resistor (STM32GD.GPIO.Pull_Up); CSN.Set_Mode (STM32GD.GPIO.Mode_In); CSN.Set_Pull_Resistor (STM32GD.GPIO.Pull_Up); RCC_Periph.AHBENR.IOPAEN := 0; RCC_Periph.AHBENR.IOPBEN := 0; RCC_Periph.AHBENR.IOPCEN := 0; RCC_Periph.AHBENR.IOPDEN := 0; RCC_Periph.AHBENR.IOPFEN := 0; RCC_Periph.APB2ENR.USART1EN := 0; RCC_Periph.APB2ENR.SPI1EN := 0; RCC_Periph.APB1ENR.I2C1EN := 0; RCC_Periph.AHBENR.DMAEN := 0; RCC_Periph.APB2ENR.ADCEN := 0; end Deactivate_Peripherals; procedure Stop is SCB_SCR : aliased STM32_SVD.UInt32 with Address => System'To_Address (16#E000ED10#); SCR : UInt32; begin PWR_Periph.CR.CWUF := 1; PWR_Periph.CR.LPDS := 1; PWR_Periph.CR.PDDS := 0; SCR := SCB_SCR or 2#100#; SCB_SCR := SCR; STM32GD.WFE; end Stop; end Power;
-- C67002B.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT OPERATOR SYMBOLS CAN BE USED IN (OVERLOADED) -- FUNCTION SPECIFICATIONS WITH THE REQUIRED NUMBER OF PARAMETERS. -- THIS TEST CHECKS THE CASE OF CERTAIN OPERATOR SYMBOLS. -- SUBTESTS ARE: -- (A) THROUGH (E): "AND", "OR", "XOR", "MOD", "REM" -- RESPECTIVELY. ALL OF THESE HAVE TWO PARAMETERS. -- (F) AND (G): "NOT" AND "ABS", RESPECTIVELY, -- WITH ONE PARAMETER. -- CPP 6/26/84 WITH REPORT; PROCEDURE C67002B IS USE REPORT; BEGIN TEST ("C67002B", "USE OF OPERATOR SYMBOLS IN " & "(OVERLOADED) FUNCTION SPECIFICATIONS"); ------------------------------------------------- DECLARE -- (A) FUNCTION "And" (I1, I2 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 > I2 THEN RETURN 'G'; ELSE RETURN 'L'; END IF; END "And"; BEGIN -- (A) IF (IDENT_INT (10) AND 1) /= 'G' OR (5 AnD 10) /= 'L' THEN FAILED ("OVERLOADING OF ""And"" OPERATOR DEFECTIVE"); END IF; END; -- (A) ------------------------------------------------- DECLARE -- (B) FUNCTION "or" (I1, I2 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 > I2 THEN RETURN 'G'; ELSE RETURN 'L'; END IF; END "or"; BEGIN -- (B) IF (IDENT_INT (10) Or 1) /= 'G' OR (5 OR 10) /= 'L' THEN FAILED ("OVERLOADING OF ""or"" OPERATOR DEFECTIVE"); END IF; END; -- (B) ------------------------------------------------- DECLARE -- (C) FUNCTION "xOR" (I1, I2 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 > I2 THEN RETURN 'G'; ELSE RETURN 'L'; END IF; END "xOR"; BEGIN -- (C) IF (IDENT_INT (10) XoR 1) /= 'G' OR (5 xOR 10) /= 'L' THEN FAILED ("OVERLOADING OF ""xOR"" OPERATOR DEFECTIVE"); END IF; END; -- (C) ------------------------------------------------- DECLARE -- (D) FUNCTION "mOd" (I1, I2 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 > I2 THEN RETURN 'G'; ELSE RETURN 'L'; END IF; END "mOd"; BEGIN -- (D) IF (IDENT_INT (10) MoD 1) /= 'G' OR (5 moD 10) /= 'L' THEN FAILED ("OVERLOADING OF ""mOd"" OPERATOR DEFECTIVE"); END IF; END; -- (D) ------------------------------------------------- DECLARE -- (E) FUNCTION "REM" (I1, I2 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 > I2 THEN RETURN 'G'; ELSE RETURN 'L'; END IF; END "REM"; BEGIN -- (E) IF (IDENT_INT (10) rem 1) /= 'G' OR (5 Rem 10) /= 'L' THEN FAILED ("OVERLOADING OF ""REM"" OPERATOR DEFECTIVE"); END IF; END; -- (E) ------------------------------------------------- DECLARE -- (F) FUNCTION "NOT" (I1 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 < IDENT_INT (0) THEN RETURN 'N'; ELSE RETURN 'P'; END IF; END "NOT"; BEGIN -- (F) IF (Not IDENT_INT(25) /= 'P') OR (noT (0-25) /= 'N') THEN FAILED ("OVERLOADING OF ""NOT"" " & "OPERATOR (ONE OPERAND) DEFECTIVE"); END IF; END; -- (F) ------------------------------------------------- DECLARE -- (G) FUNCTION "ABS" (I1 : INTEGER) RETURN CHARACTER IS BEGIN IF I1 < IDENT_INT (0) THEN RETURN 'N'; ELSE RETURN 'P'; END IF; END "ABS"; BEGIN -- (G) IF (abs IDENT_INT(25) /= 'P') OR (Abs (0-25) /= 'N') THEN FAILED ("OVERLOADING OF ""ABS"" " & "OPERATOR (ONE OPERAND) DEFECTIVE"); END IF; END; -- (T) ------------------------------------------------- RESULT; END C67002B;
-- Copyright (C) 2008-2011 Maciej Sobczak -- Distributed under the Boost Software License, Version 1.0. -- (See accompanying file LICENSE_1_0.txt or copy at -- http://www.boost.org/LICENSE_1_0.txt) package SOCI.MySQL is -- -- Registers the MySQL backend so that it is ready for use -- by the dynamic backend loader. -- procedure Register_Factory_MySQL; pragma Import (C, Register_Factory_MySQL, "register_factory_mysql"); end SOCI.MySQL;
-- INET AURA Configuration Manifest package INET.AURA is package Configuration is Enable_TLS: constant Boolean := False; end Configuration; package Build is package External_Libraries is LibreSSL_libtls: constant String := (if Configuration.Enable_TLS then "tls" else ""); -- Users should also ensure that the libressl include directory is in -- C_INCLUDE_PATH, if not installed in the usual locations end External_libraries; package Ada is package Compiler_Options is Ignore_Unknown_Pragmas: constant String := "-gnatwG"; end Compiler_Options; end Ada; package C is package Preprocessor_Definitions is BSD: constant String := (if Platform_Flavor in "freebsd" | "openbsd" | "netbsd" then "__INET_OS_BSD" else ""); Darwin: constant String := (if Platform_Flavor = "darwin" then "__INET_OS_DARWIN" else ""); Linux: constant String := (if Platform_Flavor = "linux" then "__INET_OS_LINUX" else ""); end Preprocessor_Definitions; end C; end Build; package Codepaths is TLS: constant String := (if Configuration.Enable_TLS then "tls" else ""); OS_Dependent: constant String := (if Platform_Family = "unix" then "unix" else ""); IP_Lookup_Base: constant String := "ip_lookup/" & OS_Dependent; IP_Lookup_Addrinfo: constant String := (if Platform_Flavor in "linux" | "openbsd" | "darwin" then IP_Lookup_Base & "/addrinfo_posix" elsif Platform_Flavor in "freebsd" | "netbsd" | "solaris" | "illumos" then IP_Lookup_Base & "/addrinfo_bsd" else ""); end Codepaths; end INET.AURA;
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (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 Ada.Text_IO; use type Ada.Text_IO.File_Type; with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package; with Latin_Utils.Dictionary_Package; use Latin_Utils.Dictionary_Package; use Latin_Utils; package Support_Utils.Addons_Package is pragma Elaborate_Body; subtype Fix_Type is Stem_Type; Null_Fix_Type : constant Fix_Type := Null_Stem_Type; Max_Fix_Size : constant := Max_Stem_Size; subtype Target_Pofs_Type is Part_Of_Speech_Type range X .. V; type Target_Entry (Pofs : Target_Pofs_Type := X) is record case Pofs is when N => N : Noun_Entry; --NOUN_KIND : NOUN_KIND_TYPE; when Pron => Pron : Pronoun_Entry; --PRONOUN_KIND : PRONOUN_KIND_TYPE; when Pack => Pack : Propack_Entry; --PROPACK_KIND : PRONOUN_KIND_TYPE; when Adj => Adj : Adjective_Entry; when Num => Num : Numeral_Entry; --NUMERAL_VALUE : NUMERAL_VALUE_TYPE; when Adv => Adv : Adverb_Entry; when V => V : Verb_Entry; --VERB_KIND : VERB_KIND_TYPE; when others => null; end case; end record; Null_Target_Entry : Target_Entry; package Target_Entry_Io is Default_Width : Natural; procedure Get (F : in Ada.Text_IO.File_Type; P : out Target_Entry); procedure Get (P : out Target_Entry); procedure Put (F : in Ada.Text_IO.File_Type; P : in Target_Entry); procedure Put (P : in Target_Entry); procedure Get (S : in String; P : out Target_Entry; Last : out Integer); procedure Put (S : out String; P : in Target_Entry); end Target_Entry_Io; type Tackon_Entry is record Base : Target_Entry; end record; Null_Tackon_Entry : Tackon_Entry; package Tackon_Entry_Io is Default_Width : Natural; procedure Get (F : in Ada.Text_IO.File_Type; I : out Tackon_Entry); procedure Get (I : out Tackon_Entry); procedure Put (F : in Ada.Text_IO.File_Type; I : in Tackon_Entry); procedure Put (I : in Tackon_Entry); procedure Get (S : in String; I : out Tackon_Entry; Last : out Integer); procedure Put (S : out String; I : in Tackon_Entry); end Tackon_Entry_Io; type Prefix_Entry is record Root : Part_Of_Speech_Type := X; Target : Part_Of_Speech_Type := X; end record; Null_Prefix_Entry : Prefix_Entry; package Prefix_Entry_Io is Default_Width : Natural; procedure Get (F : in Ada.Text_IO.File_Type; P : out Prefix_Entry); procedure Get (P : out Prefix_Entry); procedure Put (F : in Ada.Text_IO.File_Type; P : in Prefix_Entry); procedure Put (P : in Prefix_Entry); procedure Get (S : in String; P : out Prefix_Entry; Last : out Integer); procedure Put (S : out String; P : in Prefix_Entry); end Prefix_Entry_Io; type Suffix_Entry is record Root : Part_Of_Speech_Type := X; Root_Key : Stem_Key_Type := 0; Target : Target_Entry := Null_Target_Entry; Target_Key : Stem_Key_Type := 0; end record; Null_Suffix_Entry : Suffix_Entry; package Suffix_Entry_Io is Default_Width : Natural; procedure Get (F : in Ada.Text_IO.File_Type; P : out Suffix_Entry); procedure Get (P : out Suffix_Entry); procedure Put (F : in Ada.Text_IO.File_Type; P : in Suffix_Entry); procedure Put (P : in Suffix_Entry); procedure Get (S : in String; P : out Suffix_Entry; Last : out Integer); procedure Put (S : out String; P : in Suffix_Entry); end Suffix_Entry_Io; type Tackon_Item is record Pofs : Part_Of_Speech_Type := Tackon; Tack : Stem_Type := Null_Stem_Type; Entr : Tackon_Entry := Null_Tackon_Entry; MNPC : Integer := 0; end record; Null_Tackon_Item : Tackon_Item; type Prefix_Item is record Pofs : Part_Of_Speech_Type := Prefix; Fix : Fix_Type := Null_Fix_Type; Connect : Character := ' '; Entr : Prefix_Entry := Null_Prefix_Entry; MNPC : Integer := 0; end record; Null_Prefix_Item : Prefix_Item; type Suffix_Item is record Pofs : Part_Of_Speech_Type := Suffix; Fix : Fix_Type := Null_Fix_Type; Connect : Character := ' '; Entr : Suffix_Entry := Null_Suffix_Entry; MNPC : Integer := 0; end record; Null_Suffix_Item : Suffix_Item; type Prefix_Array is array (Integer range <>) of Prefix_Item; type Tickon_Array is array (Integer range <>) of Prefix_Item; type Suffix_Array is array (Integer range <>) of Suffix_Item; type Tackon_Array is array (Integer range <>) of Tackon_Item; type Means_Array is array (Integer range <>) of Meaning_Type; -- To simulate a DICT_IO file, as used previously Tackons : Tackon_Array (1 .. 20); Packons : Tackon_Array (1 .. 25); Tickons : Prefix_Array (1 .. 10); Prefixes : Prefix_Array (1 .. 130); Suffixes : Suffix_Array (1 .. 185); Means : Means_Array (1 .. 370); Number_Of_Tickons : Integer := 0; Number_Of_Tackons : Integer := 0; Number_Of_Packons : Integer := 0; Number_Of_Prefixes : Integer := 0; Number_Of_Suffixes : Integer := 0; procedure Load_Addons (File_Name : in String); function Subtract_Tackon (W : String; X : Tackon_Item) return String; function Subtract_Prefix (W : String; X : Prefix_Item) return Stem_Type; function Subtract_Tickon (W : String; X : Prefix_Item) return Stem_Type renames Subtract_Prefix; function Subtract_Suffix (W : String; X : Suffix_Item) return Stem_Type; function Add_Prefix (Stem : Stem_Type; Prefix : Prefix_Item) return Stem_Type; function Add_Suffix (Stem : Stem_Type; Suffix : Suffix_Item) return Stem_Type; end Support_Utils.Addons_Package;
with Ahven.Framework, Ahven.Text_Runner; procedure JSA.Tests.Run is Suite : Ahven.Framework.Test_Suite := Tests.Suite; begin Ahven.Text_Runner.Run (Suite); end JSA.Tests.Run;
with Protypo.Api.Symbols; with Protypo.Api.Consumers; with Protypo.Api.Engine_Values.Engine_Value_Vectors; with Ada.Containers.Doubly_Linked_Lists; package Protypo.Code_Trees.Interpreter is use Protypo.Api.Engine_Values; procedure Run (Program : Parsed_Code; Symbol_Table : Api.Symbols.Table; Consumer : Api.Consumers.Consumer_Access); Bad_Iterator : exception; Bad_Field : exception; private type Symbol_Table_Access is not null access Api.Symbols.Table; type Break_Type is (Exit_Statement, Return_Statement, None); type Break_Status (Breaking_Reason : Break_Type := None) is record case Breaking_Reason is when None => null; when Exit_Statement => Loop_Label : Label_Type; when Return_Statement => Result : Api.Engine_Values.Engine_Value_Vectors.Vector; end case; end record; No_Break : constant Break_Status := (Breaking_Reason => None); use type Api.Consumers.Consumer_Access; package Consumer_Stacks is new Ada.Containers.Doubly_Linked_Lists (Api.Consumers.Consumer_Access); subtype Consumer_Stack is Consumer_Stacks.List; type Interpreter_Type is tagged limited record Break : Break_Status; Symbol_Table : Api.Symbols.Table; Saved_Consumers : Consumer_Stack; Consumer_Without_Escape_Cursor : Api.Symbols.Protypo_Tables.Cursor; Consumer_With_Escape_Cursor : Api.Symbols.Protypo_Tables.Cursor; end record; type Interpreter_Access is not null access Interpreter_Type; procedure Push_Consumer (Interpreter : Interpreter_Access; Consumer : Api.Consumers.Consumer_Access); procedure Pop_Consumer (Interpreter : Interpreter_Access); function Do_Escape (Status : Interpreter_Access; Input : String) return String; -- Apply the #...# escape expression inside Input. end Protypo.Code_Trees.Interpreter;
package Discr10 is subtype Index is Natural range 0 .. 150; type List is array (Index range <>) of Integer; type R (D1 : Boolean := True; D2 : Boolean := False; D3 : Index := 0) is record case D2 is when True => L : List (1 .. D3); case D1 is when True => I : Integer; when False => null; end case; when False => null; end case; end record; function Get (X : R) return R; end Discr10;
with P_StructuralTypes; use P_StructuralTypes; with Ada.Text_IO; use Ada.Text_IO; with Ada.Sequential_IO; with Ada.Strings.Unbounded.Text_IO; with Ada.Streams; use Ada.Streams; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; package body P_StepHandler.InputHandler is ------------------------------------------------------------------------- ------------------------- CONSTRUCTOR ----------------------------------- ------------------------------------------------------------------------- function Make (Self : in out InputHandler; File_Name : in Unbounded_String) return InputHandler is package Char_IO is new Ada.Sequential_IO (Character); use Char_IO; Input_File : Char_IO.File_Type; count : Integer := 0; Buffer : Character; begin Self.Input_Name := File_Name; Open (Input_File, In_File, To_String(Self.Input_Name)); while not (End_Of_File(Input_File)) loop count := count + 1; Char_IO.Read (File => Input_File, Item => Buffer); end loop; Close (Input_File); Self.Set_Input_Length(count); if count mod 8 = 0 then Self.Set_Input_Size(count / 8); else Self.Set_Input_Size(count / 8 + 1); end if; if Self.Input_Length mod 8 /= 0 then Self.PaddingBitsNumber := 64 - (8 * (Self.Input_Length mod 8)); else Self.PaddingBitsNumber := 0; end if; return Self; end; --------------------------------------------------------------- --- HANDLE PROCEDURE : OVERRIDEN FROM PARENT ABSTRACT CLASS --- --------------------------------------------------------------- overriding procedure Handle (Self : in out InputHandler) is package Char_IO is new Ada.Sequential_IO (Character); use Char_IO; Input : Char_IO.File_Type; Buffer : Character; TextStream : Unbounded_String; TmpBlock : T_BinaryBlock; Index : Integer := 1; begin ------------------------------------------------------------------------- -- This handler has two tasks : -- => Loop through the text to define where blocks start and stop -- => Convert these blocks into binary values and putting them in the -- array containing the whole text in BinaryBlock form ------------------------------------------------------------------------- -- We're using an unbound string to add character as we read the file -- We initialize it at null value TextStream := Null_Unbounded_String; -- Opening the input file Open (Input, In_File, To_String(Self.Input_Name)); -- As long as there is a character in the file while not (End_Of_File(Input)) loop -- Reading the character and putting it in the TextBlock Char_IO.Read (File => Input, Item => Buffer); TextStream := TextStream & Buffer; -- If the block is full (ie 8 characters) we're calling the method -- to convert the Unbound_String to Binary and emptying the TextBlock if Length (TextStream) = 8 then TmpBlock := TextBlock_To_Binary(To_String(TextStream)); Replace_Block(Self.Get_BinaryContainer,Index,TmpBlock); Index := Index + 1; TextStream := Null_Unbounded_String; end if; end loop; if Length (TextStream) /= 0 then -- We're calling the conversion function a last time if there is uncon- -- verted text (shall only happen if the size of the raw text mod 8 is -- not 0) to convert the remaining text TmpBlock := TextBlock_To_Binary(To_String(TextStream)); Replace_Block(Self.Get_BinaryContainer,Index,TmpBlock); end if; -- Closing the ressource Close (Input); if Self.NextHandler /= null then Self.NextHandler.Handle; end if; end; --------------------------------------------------------------- ------------------------- GETTER ---------------------------- --------------------------------------------------------------- function Get_Input_Size (Self : in InputHandler) return Integer is begin return Self.Input_Size; end; function Get_PaddingBitsNumber (Self : in InputHandler) return Integer is begin return Self.PaddingBitsNumber; end; procedure Set_Input_Length (Self : in out InputHandler; Length : in Integer) is begin Self.Input_Length := Length; end; procedure Set_Input_Size (Self : in out InputHandler; Size : in Integer) is begin Self.Input_Size := Size; end; end P_StepHandler.InputHandler;
package lace.Strings -- -- DSA friendly packages based on the 'ada.Strings' package family provided by FSF GCC. -- is pragma Pure; end lace.Strings;
with System; package body addr2_p is procedure Process (Blk : Block) is use type System.Address; begin if Blk'Address /= B1'Address and then Blk'Address /= B2'Address then raise Program_Error; end if; end; end;
-- SPDX-License-Identifier: MIT with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin -- NOSECHUB Put_Line ("Hello, world!"); -- END-NOSECHUB end Hello;
with Ada_SPARK_Workflow.Word_Search.Puzzle; with Ada_SPARK_Workflow.Word_Search.Dictionary; with Ada_SPARK_Workflow.Word_Search.Solution; use Ada_SPARK_Workflow.Word_Search; procedure Tests is type Dict_Access is access Dictionary.Instance; Dict : constant not null Dict_Access := new Dictionary.Instance (Dictionary.Builtin_Dict_Words); Puz : Puzzle.Instance (Width => 10, Height => 10, Max_Words => 25); begin Dict.Load (Min_Word_Len => 4, Max_Word_Len => 12); Puz.Create (Dict.all); Puz.Print; Solution.Print (Puz.Solution); end Tests;
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --< @group Vulkan Math GenMatrix -------------------------------------------------------------------------------- --< @summary --< This generic package provides constructors, getters, and setters for generic --< matrix types. --< --< @description --< The Vkm_Matrix type is a generic floating point matrix that can contain up to --< 4 rows and 4 columns. -------------------------------------------------------------------------------- generic type Base_Type is digits <>; type Base_Vector_Type (<>) is tagged private; with function Image (instance : Base_Vector_Type) return String; ---------------------------------------------------------------------------- --< @summary --< Retrieve the x-component of the vector. --< --< @description --< Retrieve the x-component of the vector. --< --< @param vec --< The vector to retrieve the x-component from. --< --< @return --< The x-component of the vector. ---------------------------------------------------------------------------- with function x (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Retrieve the y-component of the vector. --< --< @description --< Retrieve the y-component of the vector. --< --< @param vec --< The vector to retrieve the y-component from. --< --< @return --< The y-component of the vector. ---------------------------------------------------------------------------- with function y (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Retrieve the z-component of the vector. --< --< @description --< Retrieve the z-component of the vector. --< --< @param vec --< The vector to retrieve the z-component from. --< --< @return --< The z-component of the vector. ---------------------------------------------------------------------------- with function z (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Retrieve the w-component of the vector. --< --< @description --< Retrieve the w-component of the vector. --< --< @param vec --< The vector to retrieve the w-component from. --< --< @return --< The w-component of the vector. ---------------------------------------------------------------------------- with function w (vec : in Base_Vector_Type) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Set the component of the vector. --< --< @description --< Set the component of the vector. --< --< @param vec --< The vector to set the component for. --< ---------------------------------------------------------------------------- with procedure Set(vec : in out Base_Vector_Type; index : in Vkm_Indices; value : in Base_Type); with function Get(vec : in Base_Vector_Type; index : in Vkm_Indices) return Base_Type; ---------------------------------------------------------------------------- --< @summary --< Construct a Base_Vector_Type. --< --< @description --< Construct a Base_Vector_Type. --< --< @param size --< The number of components in the Base_Vector_Type. --< --< @param value1 --< The value to set for the x-component of the Base_Vector_Type. --< --< @param value2 --< The value to set for the y-component of the Base_Vector_Type. --< --< @param value3 --< The value to set for the z-component of the Base_Vector_Type. --< --< @param value4 --< The value to set for the w-component of the Base_Vector_Type. --< --< @return --< The w-component of the vector. ---------------------------------------------------------------------------- with function Make_GenType ( size : in Vkm_Length; value1, value2, value3, value4 : in Base_Type := 0.0) return Base_Vector_Type; package Vulkan.Math.GenMatrix is pragma Preelaborate; pragma Pure; INCOMPATIBLE_MATRICES : exception; ---------------------------------------------------------------------------- -- Types ---------------------------------------------------------------------------- --< The matrix type is a 2D array with indices in the range of the Vkm_Indices --< type [0 .. 3]. Because of this, the number of columns is 1-4 and the --< number of rows is 1-4. type Vkm_Matrix is array(Vkm_Indices range <>, Vkm_Indices range <>) of aliased Base_Type; pragma Convention(C,Vkm_Matrix); --< The matrix is a discriminant tagged record which encapsulates the --< Vkm_Matrix type. This allows use of "." to perform functions on an --< instance of matrix. --< --< @field last_column_index --< The discriminant, last_column_index, determines the number of columns in the --< matrix. --< --< @field last_row_index --< The discriminant, last_row_index, determines the number of rows in the matrix. --< --< @field data --< The matrix data for the record. This information is able to be --< passed to a C/C++ context. type Vkm_GenMatrix(last_column_index : Vkm_Indices; last_row_index : Vkm_Indices) is tagged record data : Vkm_Matrix(Vkm_Indices'First .. last_column_index, Vkm_Indices'First .. last_row_index); end record; --< A reference to a generic matrix type. The Vkm_GenMatrix instance is --< automatically dereferenced on use. type Vkm_GenMatrix_Reference(instance : not null access Vkm_GenMatrix) is null record with Implicit_Dereference => instance; ---------------------------------------------------------------------------- --< @summary --< The image of the matrix --< --< @description --< Generates a human readable string which contains the contents of the --< instance of Vkm_GenMatrix. For a 2x2 matrix, this appears as a list of --< the row vectors --< --< "[ " & Image(mat.r0) & ", " & Image(mat.r1) & " ]" --< --< The Image() subprogram that is supplied during generic instantiation is used --< to print the component of Base_Vector_Type. --< --< @param instance --< The instance of Vkm_GenMatrix. --< --< @return --< The human readable image of the matrix ---------------------------------------------------------------------------- function Image (instance : in Vkm_GenMatrix) return String; ---------------------------------------------------------------------------- -- Element Getters ---------------------------------------------------------------------------- --< @summary --< Vkm_GenMatrix element accessor. --< --< @description --< Gets the value of an element at the specified column and row index. --< --< @param instance --< The Vkm_GenMatrix instance to get the element value of. --< --< @param col_index --< The index of the column at which to get an element. --< --< @param row_index --< The index of the row at which to get an element. --< --< @return --< The value of the specified element. ---------------------------------------------------------------------------- function Element(instance : in Vkm_GenMatrix; col_index, row_index : in Vkm_Indices) return Base_Type; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c0r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 0, 3)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c1r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 1, 3)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c2r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 2, 3)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r0 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 0)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r1 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 1)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r2 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 2)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to retrieve the element from. --< --< @return --< The element from the matrix. function c3r3 (instance : in Vkm_GenMatrix) return Base_Type is (Element(instance, 3, 3)) with Inline; ---------------------------------------------------------------------------- -- Element Setters ---------------------------------------------------------------------------- --< @summary --< Vkm_GenMatrix element accessor. --< --< @description --< Sets the element at the specified column and row index to a value. --< --< @param instance --< The Vkm_GenMatrix instance to set the element of. --< --< @param col_index --< The index of the column at which to set an element. --< --< @param row_index --< The index of the row at which to set an element. --< --< @param value --< The value to set the specified element. ---------------------------------------------------------------------------- procedure Element( instance : in out Vkm_GenMatrix; col_index, row_index : in Vkm_Indices; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c0r3( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c1r3( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c2r3( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r0( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r1( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r2( instance : in out Vkm_GenMatrix; value : in Base_Type); --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. procedure c3r3( instance : in out Vkm_GenMatrix; value : in Base_Type); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenMatrix element accessor. --< --< @description --< Sets the element at the specified column and row index to a value. A --< reference to the matrix is returned upon completion. --< --< @param instance --< The Vkm_GenMatrix instance to set the element of. --< --< @param col_index --< The index of the column at which to set an element. --< --< @param row_index --< The index of the row at which to set an element. --< --< @param value --< The value to set the specified element. --< --< @return --< A reference to the Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Element( instance : in out Vkm_GenMatrix; col_index, row_index : in Vkm_Indices ; value : in Base_Type ) return Vkm_GenMatrix_Reference; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c0r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 0, 3, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c1r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 1, 3, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c2r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 2, 3, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r0 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 0, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r1 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 1, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r2 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 2, value)) with Inline; --< @private --< This is a named accessor for an element of an instance of Vkm_GenMatrix. --< --< @param instance --< The Instance of Vkm_GenMatrix to set the element for. --< --< @param value --< The value to set for the matrix element. --< --< @return --< A reference to the modified matrix instance. function c3r3 ( instance : in out Vkm_GenMatrix; value : in Base_Type ) return Vkm_GenMatrix_Reference is (Element(instance, 3, 3, value)) with Inline; ---------------------------------------------------------------------------- -- Column Accessors ---------------------------------------------------------------------------- --< @summary --< Get the indicated column of the matrix as a vector. --< --< @description --< Retrieve the indicated column of the matrix as a vector: --< --< cI := [ instance.cIr0 instance.cIr1 ... instance.cIrN ] --< --< @param instance --< The instance of Vkm_GenMatrix from which the column is retrieved. --< --< @param col_index --< The index of the column to retrieve from the matrix. --< --< @return --< The vector that contains all elements in the indicated column. ---------------------------------------------------------------------------- function Column ( instance : in Vkm_GenMatrix; col_index : in Vkm_Indices) return Base_Vector_Type is (Make_GenType( To_Vkm_Length(instance.last_row_index), instance.Element(col_index, 0), instance.Element(col_index, 1), instance.Element(col_index, 2), instance.Element(col_index, 3))) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c0 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 0)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c1 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 1)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c2 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 2)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a column. --< --< @return --< The indicated column from the matrix. function c3 ( instance : in Vkm_GenMatrix) return Base_Vector_Type is (Column(instance, 3)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Set the indicated column of the matrix given a vector. --< --< @description --< Sets the indicated column of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the column is set. --< --< @param col_index --< The index of the column to set for the matrix. --< --< @param col_val --< The vector value to set the column to. ---------------------------------------------------------------------------- procedure Column ( instance : in out Vkm_GenMatrix; col_index : in Vkm_Indices; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c0 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c1 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c2 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. procedure c3 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type); ---------------------------------------------------------------------------- --< @summary --< Set the indicated column of the matrix given a vector. --< --< @description --< Sets the indicated column of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the column is set. --< --< @param col_index --< The index of the column to set for the matrix. --< --< @param col_val --< The vector value to set the column to. --< --< @return --< A reference to the Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Column( instance : in out Vkm_GenMatrix; col_index : in Vkm_Indices ; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c0 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 0, col_val)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c1 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 1, col_val)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c2 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 2, col_val)) with Inline; --< @private --< This is a named accessor for a column of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a column. --< --< @param col_val --< The vector to set the column equal to. --< --< @return --< A reference to the instance of Vkm_GenMatrix. function c3 ( instance : in out Vkm_GenMatrix; col_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Column(instance, 3, col_val)) with Inline; ---------------------------------------------------------------------------- -- Row Accessors ---------------------------------------------------------------------------- --< @summary --< Get the indicated row of the matrix as a vector. --< --< @description --< Retrieve the indicated row of the matrix as a vector: --< --< rI := [ instance.c0rI instance.c1rI ... instance.cNrI ] --< --< @param instance --< The instance of Vkm_GenMatrix from which the row is retrieved. --< --< @param row_index --< The index of the row to retrieve from the matrix. --< --< @return --< The vector that contains all elements in the indicated row. ---------------------------------------------------------------------------- function Row ( instance : in Vkm_GenMatrix; row_index : in Vkm_Indices) return Base_Vector_Type is (Make_GenType( To_Vkm_Length(instance.last_column_index), instance.Element(0, row_index), instance.Element(1, row_index), instance.Element(2, row_index), instance.Element(3, row_index))) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r0 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 0)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r1 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 1)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r2 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 2)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix from which to retrieve a row. --< --< @return --< The indicated row from the matrix. function r3 (instance : in Vkm_GenMatrix) return Base_Vector_Type is (Row(instance, 3)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Set the indicated row of the matrix given a vector. --< --< @description --< Sets the indicated row of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the row is set. --< --< @param row_index --< The index of the row to set for the matrix. --< --< @param row_val --< The vector value to set the row to. ---------------------------------------------------------------------------- procedure Row ( instance : in out Vkm_GenMatrix; row_index : in Vkm_Indices; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r0 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r1 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r2 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. procedure r3 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type); ---------------------------------------------------------------------------- --< @summary --< Set the indicated row of the matrix given a vector. --< --< @description --< Sets the indicated row of the matrix to the specified value. --< --< @param instance --< The instance of Vkm_GenMatrix for which the row is set. --< --< @param row_index --< The index of the row to set for the matrix. --< --< @param row_val --< The vector value to set the row to. --< --< @return --< A reference to the Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Row ( instance : in out Vkm_GenMatrix; row_index : in Vkm_Indices; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r0 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 0, row_val)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r1 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 1, row_val)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r2 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 2, row_val)) with Inline; --< @private --< This is a named accessor for a row of an instance of Vkm_GenMatrix. --< --< @param instance --< The instance of Vkm_GenMatrix for which to set a row. --< --< @param row_val --< The the value to set a row of the matrix to. --< --< @return --< A reference to the modified matrix. function r3 ( instance : in out Vkm_GenMatrix; row_val : in Base_Vector_Type) return Vkm_GenMatrix_Reference is (Row(instance, 3, row_val)) with Inline; ---------------------------------------------------------------------------- -- Operations ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \ c0 c1 c2 c3 cN --< r0 | c0r0_val c1r0_val c2r0_val c3r0_val | --< r1 | c0r1_val c1r1_val c2r1_val c3r1_val | --< r2 | c0r2_val c1r2_val c2r2_val c3r2_val | --< r3 | c0r3_val c1r3_val c2r3_val c3r3_val | --< rN --< --< If no value is supplied for an element a default value of 0.0 is used. --< If the indices in the element name are not within matrix bounds, value --< specifiedis ignored. --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param c0r0_val --< The value to set for the element at column 0 and row 0. --< --< @param c0r1_val --< The value to set for the element at column 0 and row 1. --< --< @param c0r2_val --< The value to set for the element at column 0 and row 2. --< --< @param c0r3_val --< The value to set for the element at column 0 and row 3. --< --< @param c1r0_val --< The value to set for the element at column 1 and row 0. --< --< @param c1r1_val --< The value to set for the element at column 1 and row 1. --< --< @param c1r2_val --< The value to set for the element at column 1 and row 2. --< --< @param c1r3_val --< The value to set for the element at column 1 and row 3. --< --< @param c2r0_val --< The value to set for the element at column 2 and row 0. --< --< @param c2r1_val --< The value to set for the element at column 2 and row 1. --< --< @param c2r2_val --< The value to set for the element at column 2 and row 2. --< --< @param c2r3_val --< The value to set for the element at column 2 and row 3. --< --< @param c3r0_val --< The value to set for the element at column 3 and row 0. --< --< @param c3r1_val --< The value to set for the element at column 3 and row 1. --< --< @param c3r2_val --< The value to set for the element at column 3 and row 2. --< --< @param c3r3_val --< The value to set for the element at column 3 and row 3. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; c0r0_val, c0r1_val, c0r2_val, c0r3_val, c1r0_val, c1r1_val, c1r2_val, c1r3_val, c2r0_val, c2r1_val, c2r2_val, c2r3_val, c3r0_val, c3r1_val, c3r2_val, c3r3_val : in Base_Type := 0.0) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \ c0 c1 c2 c3 cN --< r0 | diag 0.0 0.0 0.0 | --< r1 | 0.0 diag 0.0 0.0 | --< r2 | 0.0 0.0 diag 0.0 | --< r3 | 0.0 0.0 0.0 diag | --< rN --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param diag --< The value to set on the diagonal. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; diag : in Base_Type) return Vkm_GenMatrix is (Make_GenMatrix( cN => cN, rN => rN, c0r0_val => diag, c1r1_val => diag, c2r2_val => diag, c3r3_val => diag)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \ c0 c1 c2 c3 cN --< r0 | sub.c0r0 sub.c1r0 sub.c2r0 sub.c3r0 | --< r1 | sub.c0r1 sub.c1r1 sub.c2r1 sub.c3r1 | --< r2 | sub.c0r2 sub.c1r2 sub.c2r2 sub.c3r2 | --< r3 | sub.c0r3 sub.c1r3 sub.c2r3 sub.c3r3 | --< rN --< --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param sub --< The submatrix used to initialize elements of the new instance of matrix. --< If an element is out of bounds for the submatrix, the corresponding value --< of the identity matrix is used instead. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; sub : in Vkm_GenMatrix) return Vkm_GenMatrix is (Make_GenMatrix( cN => cN, rN => rN, c0r0_val => sub.c0r0, c0r1_val => sub.c0r1, c0r2_val => sub.c0r2, c0r3_val => sub.c0r3, c1r0_val => sub.c1r0, c1r1_val => sub.c1r1, c1r2_val => sub.c1r2, c1r3_val => sub.c1r3, c2r0_val => sub.c2r0, c2r1_val => sub.c2r1, c2r2_val => sub.c2r2, c2r3_val => sub.c2r3, c3r0_val => sub.c3r0, c3r1_val => sub.c3r1, c3r2_val => sub.c3r2, c3r3_val => sub.c3r3)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Constructor for Vkm_GenMatrix type. --< --< @description --< Creates a new instance of Vkm_GenMatrix with the indicated number of rows --< and columns. Each element is initialized as specified: --< --< \ c0 c1 c2 c3 cN --< r0 | diag.x 0.0 0.0 0.0 | --< r1 | 0.0 diag.y 0.0 0.0 | --< r2 | 0.0 0.0 diag.z 0.0 | --< r3 | 0.0 0.0 0.0 diag.w | --< rN --< --< @param cN --< The last index that can be used for accessing columns in the matrix. --< --< @param rN --< The last index that can be used for accessing rows in the matrix. --< --< @param diag --< The value to set on the diagonal. --< --< @return --< The new Vkm_GenMatrix instance. ---------------------------------------------------------------------------- function Make_GenMatrix( cN, rN : in Vkm_Indices; diag : in Base_Vector_Type) return Vkm_GenMatrix is (Make_GenMatrix( cN => cN, rN => rN, c0r0_val => x(diag), c1r1_val => y(diag), c2r2_val => z(diag), c3r3_val => w(diag))) with Inline; ---------------------------------------------------------------------------- --< @summary --< Determine whether two matrices are equal to each other. --< --< @description --< Determines whether every element of the two matrices are equal to each --< other. --< --< @param left --< The variable that is to the left of the equality operator. --< --< @param right --< The variable that is to the right of the equality operator. --< --< @return --< True if the matrices are equal to each other. Otherwise, false. ---------------------------------------------------------------------------- function Op_Is_Equal( left, right : in Vkm_GenMatrix) return Vkm_Bool; ---------------------------------------------------------------------------- --< @summary --< Linear algebraic matrix multiplication --< --< @description --< Perform linear algebraic matrix multiplication for the two matrices. --< --< @param left --< The left matrix in the computation. --< --< @param right --< The right matrix in the computation. --< --< The result of linear algebraic multiplication for the two matrices. ---------------------------------------------------------------------------- function Op_Matrix_Mult_Matrix ( left, right : in Vkm_GenMatrix) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Multiplication operator for a Vkm_GenMatrix matrix and a Vkm_GenFType value. --< --< @description --< Perform Multiplication component-wise on the matrix and vector. --< --< @param left --< The matrix that is multiplied with the vector. --< --< @param right --< The vector that is multiplied by the matrix. --< --< @return --< The product of the matrix with the vector. ---------------------------------------------------------------------------- function Op_Matrix_Mult_Vector ( left : in Vkm_GenMatrix; right : in Base_Vector_Type ) return Base_Vector_Type; ---------------------------------------------------------------------------- --< @summary --< Multiplication operator for a Vkm_GenMatrix matrix and a Vkm_GenFType value. --< --< @description --< Perform Multiplication component-wise on the matrix and vector. --< --< @param left --< The vector that is multiplied with the matrix. --< --< @param right --< The matrix that is multiplied by the vector. --< --< @return --< The product of the vector with the matrix. ---------------------------------------------------------------------------- function Op_Vector_Mult_Matrix ( left : in Base_Vector_Type; right : in Vkm_GenMatrix) return Base_Vector_Type; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on a matrix --< --< @description --< Applies function component-wise on a matrix, yielding the following --< matrix: --< --< | Func(im1.c0r0) ... Func(im1.cNr0) | --< | ... ... | --< | Func(im1.c0rN) ... Func(im1.cNrN) | --< --< @param im1 --< The input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on a --< matrix. ---------------------------------------------------------------------------- generic with function Func (is1 : in Base_Type) return Base_Type; function Apply_Func_IM_RM (im1 : in Vkm_GenMatrix) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on two matrices. --< --< @description --< Applies function component-wise on two matrices, yielding the following --< matrix: --< --< | Func(im1.c0r0, im2.c0r0) ... Func(im1.cNr0, im2.cNr0) | --< | ... ... | --< | Func(im1.c0rN, im2.c0rN) ... Func(im1.cNrN, im2.cNrN) | --< --< @param im1 --< The first input Vkm_GenMatrix parameter. --< --< @param im2 --< The second input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on both --< matrices. ---------------------------------------------------------------------------- generic with function Func (is1, is2 : in Base_Type) return Base_Type; function Apply_Func_IM_IM_RM (im1, im2 : in Vkm_GenMatrix) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on a matrix and a scalar. --< --< @description --< Applies function component-wise on a matrix and a scalar, yielding the --< following matrix: --< --< | Func(im1.c0r0, is1) ... Func(im1.cNr0, is1) | --< | ... ... | --< | Func(im1.c0rN, is1) ... Func(im1.cNrN, is1) | --< --< @param im1 --< The first input Vkm_GenMatrix parameter. --< --< @param is1 --< The second input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on both --< matrices. ---------------------------------------------------------------------------- generic with function Func (is1, is2 : in Base_Type) return Base_Type; function Apply_Func_IM_IS_RM ( im1 : in Vkm_GenMatrix; is1 : in Base_Type ) return Vkm_GenMatrix; ---------------------------------------------------------------------------- --< @summary --< Apply function component-wise on a matrix and a scalar. --< --< @description --< Applies function component-wise on a matrix and a scalar, yielding the --< following matrix: --< --< | Func(is1, im1.c0r0) ... Func(is1, im1.cNr0) | --< | ... ... | --< | Func(is1, im1.c0rN) ... Func(is1, im1.cNrN) | --< --< @param is1 --< The first input Vkm_GenMatrix parameter. --< --< @param im1 --< The second input Vkm_GenMatrix parameter. --< --< @return --< The result from applying the generic function Func component-wise on both --< matrices. ---------------------------------------------------------------------------- generic with function Func (is1, is2 : in Base_Type) return Base_Type; function Apply_Func_IS_IM_RM ( is1 : in Base_Type; im1 : in Vkm_GenMatrix) return Vkm_GenMatrix; end Vulkan.Math.GenMatrix;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Classifiers; with AMF.String_Collections; with AMF.UML.Actors; with AMF.UML.Behaviors.Collections; with AMF.UML.Classifier_Template_Parameters; with AMF.UML.Classifiers.Collections; with AMF.UML.Collaboration_Uses.Collections; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Element_Imports.Collections; with AMF.UML.Features.Collections; with AMF.UML.Generalization_Sets.Collections; with AMF.UML.Generalizations.Collections; with AMF.UML.Interface_Realizations.Collections; with AMF.UML.Named_Elements.Collections; with AMF.UML.Namespaces; with AMF.UML.Package_Imports.Collections; with AMF.UML.Packageable_Elements.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements.Collections; with AMF.UML.Properties.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.Redefinable_Template_Signatures; with AMF.UML.String_Expressions; with AMF.UML.Substitutions.Collections; with AMF.UML.Template_Bindings.Collections; with AMF.UML.Template_Parameters; with AMF.UML.Template_Signatures; with AMF.UML.Types; with AMF.UML.Use_Cases.Collections; with AMF.Visitors; package AMF.Internals.UML_Actors is type UML_Actor_Proxy is limited new AMF.Internals.UML_Classifiers.UML_Classifier_Proxy and AMF.UML.Actors.UML_Actor with null record; overriding function Get_Classifier_Behavior (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Behaviors.UML_Behavior_Access; -- Getter of BehavioredClassifier::classifierBehavior. -- -- A behavior specification that specifies the behavior of the classifier -- itself. overriding procedure Set_Classifier_Behavior (Self : not null access UML_Actor_Proxy; To : AMF.UML.Behaviors.UML_Behavior_Access); -- Setter of BehavioredClassifier::classifierBehavior. -- -- A behavior specification that specifies the behavior of the classifier -- itself. overriding function Get_Interface_Realization (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Interface_Realizations.Collections.Set_Of_UML_Interface_Realization; -- Getter of BehavioredClassifier::interfaceRealization. -- -- The set of InterfaceRealizations owned by the BehavioredClassifier. -- Interface realizations reference the Interfaces of which the -- BehavioredClassifier is an implementation. overriding function Get_Owned_Behavior (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior; -- Getter of BehavioredClassifier::ownedBehavior. -- -- References behavior specifications owned by a classifier. overriding function Get_Attribute (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property; -- Getter of Classifier::attribute. -- -- Refers to all of the Properties that are direct (i.e. not inherited or -- imported) attributes of the classifier. overriding function Get_Collaboration_Use (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use; -- Getter of Classifier::collaborationUse. -- -- References the collaboration uses owned by the classifier. overriding function Get_Feature (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature; -- Getter of Classifier::feature. -- -- Specifies each feature defined in the classifier. -- Note that there may be members of the Classifier that are of the type -- Feature but are not included in this association, e.g. inherited -- features. overriding function Get_General (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of Classifier::general. -- -- Specifies the general Classifiers for this Classifier. -- References the general classifier in the Generalization relationship. overriding function Get_Generalization (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization; -- Getter of Classifier::generalization. -- -- Specifies the Generalization relationships for this Classifier. These -- Generalizations navigaten to more general classifiers in the -- generalization hierarchy. overriding function Get_Inherited_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Classifier::inheritedMember. -- -- Specifies all elements inherited by this classifier from the general -- classifiers. overriding function Get_Is_Abstract (Self : not null access constant UML_Actor_Proxy) return Boolean; -- Getter of Classifier::isAbstract. -- -- If true, the Classifier does not provide a complete declaration and can -- typically not be instantiated. An abstract classifier is intended to be -- used by other classifiers e.g. as the target of general -- metarelationships or generalization relationships. overriding function Get_Is_Final_Specialization (Self : not null access constant UML_Actor_Proxy) return Boolean; -- Getter of Classifier::isFinalSpecialization. -- -- If true, the Classifier cannot be specialized by generalization. Note -- that this property is preserved through package merge operations; that -- is, the capability to specialize a Classifier (i.e., -- isFinalSpecialization =false) must be preserved in the resulting -- Classifier of a package merge operation where a Classifier with -- isFinalSpecialization =false is merged with a matching Classifier with -- isFinalSpecialization =true: the resulting Classifier will have -- isFinalSpecialization =false. overriding procedure Set_Is_Final_Specialization (Self : not null access UML_Actor_Proxy; To : Boolean); -- Setter of Classifier::isFinalSpecialization. -- -- If true, the Classifier cannot be specialized by generalization. Note -- that this property is preserved through package merge operations; that -- is, the capability to specialize a Classifier (i.e., -- isFinalSpecialization =false) must be preserved in the resulting -- Classifier of a package merge operation where a Classifier with -- isFinalSpecialization =false is merged with a matching Classifier with -- isFinalSpecialization =true: the resulting Classifier will have -- isFinalSpecialization =false. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access; -- Getter of Classifier::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Actor_Proxy; To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access); -- Setter of Classifier::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Owned_Use_Case (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case; -- Getter of Classifier::ownedUseCase. -- -- References the use cases owned by this classifier. overriding function Get_Powertype_Extent (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set; -- Getter of Classifier::powertypeExtent. -- -- Designates the GeneralizationSet of which the associated Classifier is -- a power type. overriding function Get_Redefined_Classifier (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of Classifier::redefinedClassifier. -- -- References the Classifiers that are redefined by this Classifier. overriding function Get_Representation (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access; -- Getter of Classifier::representation. -- -- References a collaboration use which indicates the collaboration that -- represents this classifier. overriding procedure Set_Representation (Self : not null access UML_Actor_Proxy; To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access); -- Setter of Classifier::representation. -- -- References a collaboration use which indicates the collaboration that -- represents this classifier. overriding function Get_Substitution (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution; -- Getter of Classifier::substitution. -- -- References the substitutions that are owned by this Classifier. overriding function Get_Template_Parameter (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access; -- Getter of Classifier::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Actor_Proxy; To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access); -- Setter of Classifier::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Use_Case (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case; -- Getter of Classifier::useCase. -- -- The set of use cases for which this Classifier is the subject. overriding function Get_Element_Import (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import; -- Getter of Namespace::elementImport. -- -- References the ElementImports owned by the Namespace. overriding function Get_Imported_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Getter of Namespace::importedMember. -- -- References the PackageableElements that are members of this Namespace -- as a result of either PackageImports or ElementImports. overriding function Get_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::member. -- -- A collection of NamedElements identifiable within the Namespace, either -- by being owned or by being introduced by importing or inheritance. overriding function Get_Owned_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::ownedMember. -- -- A collection of NamedElements owned by the Namespace. overriding function Get_Owned_Rule (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Namespace::ownedRule. -- -- Specifies a set of Constraints owned by this Namespace. overriding function Get_Package_Import (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import; -- Getter of Namespace::packageImport. -- -- References the PackageImports owned by the Namespace. overriding function Get_Client_Dependency (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Actor_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Actor_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Actor_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Package (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Packages.UML_Package_Access; -- Getter of Type::package. -- -- Specifies the owning package of this classifier, if any. overriding procedure Set_Package (Self : not null access UML_Actor_Proxy; To : AMF.UML.Packages.UML_Package_Access); -- Setter of Type::package. -- -- Specifies the owning package of this classifier, if any. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Actor_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Actor_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Template_Signatures.UML_Template_Signature_Access; -- Getter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Actor_Proxy; To : AMF.UML.Template_Signatures.UML_Template_Signature_Access); -- Setter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Template_Binding (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding; -- Getter of TemplateableElement::templateBinding. -- -- The optional bindings from this element to templates. overriding function Get_Is_Leaf (Self : not null access constant UML_Actor_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Actor_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function All_Features (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature; -- Operation Classifier::allFeatures. -- -- The query allFeatures() gives all of the features in the namespace of -- the classifier. In general, through mechanisms such as inheritance, -- this will be a larger set than feature. overriding function Conforms_To (Self : not null access constant UML_Actor_Proxy; Other : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean; -- Operation Classifier::conformsTo. -- -- The query conformsTo() gives true for a classifier that defines a type -- that conforms to another. This is used, for example, in the -- specification of signature conformance for operations. overriding function General (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Operation Classifier::general. -- -- The general classifiers are the classifiers referenced by the -- generalization relationships. overriding function Has_Visibility_Of (Self : not null access constant UML_Actor_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access) return Boolean; -- Operation Classifier::hasVisibilityOf. -- -- The query hasVisibilityOf() determines whether a named element is -- visible in the classifier. By default all are visible. It is only -- called when the argument is something owned by a parent. overriding function Inherit (Self : not null access constant UML_Actor_Proxy; Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inherit. -- -- The query inherit() defines how to inherit a set of elements. Here the -- operation is defined to inherit them all. It is intended to be -- redefined in circumstances where inheritance is affected by -- redefinition. -- The inherit operation is overridden to exclude redefined properties. overriding function Inheritable_Members (Self : not null access constant UML_Actor_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inheritableMembers. -- -- The query inheritableMembers() gives all of the members of a classifier -- that may be inherited in one of its descendants, subject to whatever -- visibility restrictions apply. overriding function Inherited_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inheritedMember. -- -- The inheritedMember association is derived by inheriting the -- inheritable members of the parents. -- The inheritedMember association is derived by inheriting the -- inheritable members of the parents. overriding function Is_Template (Self : not null access constant UML_Actor_Proxy) return Boolean; -- Operation Classifier::isTemplate. -- -- The query isTemplate() returns whether this templateable element is -- actually a template. overriding function May_Specialize_Type (Self : not null access constant UML_Actor_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean; -- Operation Classifier::maySpecializeType. -- -- The query maySpecializeType() determines whether this classifier may -- have a generalization relationship to classifiers of the specified -- type. By default a classifier may specialize classifiers of the same or -- a more general type. It is intended to be redefined by classifiers that -- have different specialization constraints. overriding function Exclude_Collisions (Self : not null access constant UML_Actor_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::excludeCollisions. -- -- The query excludeCollisions() excludes from a set of -- PackageableElements any that would not be distinguishable from each -- other in this namespace. overriding function Get_Names_Of_Member (Self : not null access constant UML_Actor_Proxy; Element : AMF.UML.Named_Elements.UML_Named_Element_Access) return AMF.String_Collections.Set_Of_String; -- Operation Namespace::getNamesOfMember. -- -- The query getNamesOfMember() takes importing into account. It gives -- back the set of names that an element would have in an importing -- namespace, either because it is owned, or if not owned then imported -- individually, or if not individually then from a package. -- The query getNamesOfMember() gives a set of all of the names that a -- member would have in a Namespace. In general a member can have multiple -- names in a Namespace if it is imported more than once with different -- aliases. The query takes account of importing. It gives back the set of -- names that an element would have in an importing namespace, either -- because it is owned, or if not owned then imported individually, or if -- not individually then from a package. overriding function Import_Members (Self : not null access constant UML_Actor_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importMembers. -- -- The query importMembers() defines which of a set of PackageableElements -- are actually imported into the namespace. This excludes hidden ones, -- i.e., those which have names that conflict with names of owned members, -- and also excludes elements which would have the same name when imported. overriding function Imported_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importedMember. -- -- The importedMember property is derived from the ElementImports and the -- PackageImports. References the PackageableElements that are members of -- this Namespace as a result of either PackageImports or ElementImports. overriding function Members_Are_Distinguishable (Self : not null access constant UML_Actor_Proxy) return Boolean; -- Operation Namespace::membersAreDistinguishable. -- -- The Boolean query membersAreDistinguishable() determines whether all of -- the namespace's members are distinguishable within it. overriding function Owned_Member (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Namespace::ownedMember. -- -- Missing derivation for Namespace::/ownedMember : NamedElement overriding function All_Owning_Packages (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Actor_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Conforms_To (Self : not null access constant UML_Actor_Proxy; Other : AMF.UML.Types.UML_Type_Access) return Boolean; -- Operation Type::conformsTo. -- -- The query conformsTo() gives true for a type that conforms to another. -- By default, two types do not conform to each other. This query is -- intended to be redefined for specific conformance situations. overriding function Is_Compatible_With (Self : not null access constant UML_Actor_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Actor_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding function Parameterable_Elements (Self : not null access constant UML_Actor_Proxy) return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element; -- Operation TemplateableElement::parameterableElements. -- -- The query parameterableElements() returns the set of elements that may -- be used as the parametered elements for a template parameter of this -- templateable element. By default, this set includes all the owned -- elements. Subclasses may override this operation if they choose to -- restrict the set of parameterable elements. overriding function Is_Consistent_With (Self : not null access constant UML_Actor_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two RedefinableElements -- in a context in which redefinition is possible, whether redefinition -- would be logically consistent. By default, this is false; this -- operation must be overridden for subclasses of RedefinableElement to -- define the consistency conditions. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Actor_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding procedure Enter_Element (Self : not null access constant UML_Actor_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Actor_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Actor_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Actors;
----------------------------------------------------------------------- -- AWA tests - AWA Tests Framework -- Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Task_Termination; with Ada.Task_Identification; with Ada.Exceptions; with Ada.Unchecked_Deallocation; with ASF.Server.Tests; with Util.Log.Loggers; with ASF.Tests; with AWA.Applications.Factory; with AWA.Tests.Helpers.Users; package body AWA.Tests is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Tests"); protected Shutdown is procedure Termination (Cause : in Ada.Task_Termination.Cause_Of_Termination; Id : in Ada.Task_Identification.Task_Id; Ex : in Ada.Exceptions.Exception_Occurrence); end Shutdown; Application_Created : Boolean := False; Application : AWA.Applications.Application_Access := null; Factory : AWA.Applications.Factory.Application_Factory; Service_Filter : aliased AWA.Services.Filters.Service_Filter; protected body Shutdown is procedure Termination (Cause : in Ada.Task_Termination.Cause_Of_Termination; Id : in Ada.Task_Identification.Task_Id; Ex : in Ada.Exceptions.Exception_Occurrence) is pragma Unreferenced (Cause, Id, Ex); procedure Free is new Ada.Unchecked_Deallocation (Object => AWA.Applications.Application'Class, Name => AWA.Applications.Application_Access); begin Free (Application); end Termination; end Shutdown; -- ------------------------------ -- Setup the service context before executing the test. -- ------------------------------ overriding procedure Set_Up (T : in out Test) is pragma Unreferenced (T); begin ASF.Server.Tests.Set_Context (Application.all'Access); end Set_Up; -- ------------------------------ -- Cleanup after the test execution. -- ------------------------------ overriding procedure Tear_Down (T : in out Test) is pragma Unreferenced (T); begin AWA.Tests.Helpers.Users.Tear_Down; end Tear_Down; procedure Initialize (Props : in Util.Properties.Manager) is begin Initialize (null, Props, True); end Initialize; -- ------------------------------ -- Called when the testsuite execution has finished. -- ------------------------------ procedure Finish (Status : in Util.XUnit.Status) is procedure Free is new Ada.Unchecked_Deallocation (Object => AWA.Applications.Application'Class, Name => AWA.Applications.Application_Access); begin if Application_Created then Application.Close; Free (Application); end if; ASF.Tests.Finish (Status); end Finish; -- ------------------------------ -- Initialize the AWA test framework mockup. -- ------------------------------ procedure Initialize (App : in AWA.Applications.Application_Access; Props : in Util.Properties.Manager; Add_Modules : in Boolean) is pragma Unreferenced (Add_Modules); use AWA.Applications; begin -- Create the application unless it is specified as argument. -- Install a shutdown hook to delete the application when the primary task exits. -- This allows to stop the event threads if any. if App = null then Application_Created := True; Application := new Test_Application; Ada.Task_Termination.Set_Specific_Handler (Ada.Task_Identification.Current_Task, Shutdown.Termination'Access); else Application := App; end if; ASF.Tests.Initialize (Props, Application.all'Access, Factory); Application.Add_Filter ("service", Service_Filter'Access); Application.Add_Filter_Mapping (Name => "service", Pattern => "*.html"); Application.Start; end Initialize; -- ------------------------------ -- Get the test application. -- ------------------------------ function Get_Application return AWA.Applications.Application_Access is begin return Application; end Get_Application; -- ------------------------------ -- Set the application context to simulate a web request context. -- ------------------------------ procedure Set_Application_Context is begin ASF.Server.Tests.Set_Context (Application.all'Access); end Set_Application_Context; -- ------------------------------ -- Initialize the servlets provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application servlets. -- ------------------------------ overriding procedure Initialize_Servlets (App : in out Test_Application) is begin Log.Info ("Initializing application servlets..."); AWA.Applications.Application (App).Initialize_Servlets; App.Add_Servlet (Name => "faces", Server => App.Faces'Unchecked_Access); App.Add_Servlet (Name => "files", Server => App.Files'Unchecked_Access); App.Add_Servlet (Name => "ajax", Server => App.Ajax'Unchecked_Access); App.Add_Servlet (Name => "measures", Server => App.Measures'Unchecked_Access); -- App.Add_Servlet (Name => "auth", Server => App.Auth'Unchecked_Access); -- App.Add_Servlet (Name => "verify-auth", Server => App.Self.Verify_Auth'Access); end Initialize_Servlets; -- ------------------------------ -- Initialize the filters provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application filters. -- ------------------------------ overriding procedure Initialize_Filters (App : in out Test_Application) is begin Log.Info ("Initializing application filters..."); AWA.Applications.Application (App).Initialize_Filters; App.Add_Filter (Name => "dump", Filter => App.Dump'Unchecked_Access); App.Add_Filter (Name => "measures", Filter => App.Measures'Unchecked_Access); App.Add_Filter (Name => "service", Filter => App.Service_Filter'Unchecked_Access); end Initialize_Filters; end AWA.Tests;
-- Copyright 2015,2016,2017 Steven Stewart-Gallus -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http ://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied. See the License for the specific language governing -- permissions and limitations under the License. private with Ada.Command_Line; private with Ada.Real_Time; private with Linted.Controls_Reader; private with Linted.Errors; private with Linted.KOs; private with Linted.Timer; private with Linted.Update_Writer; private with Linted.Update; private with Linted.Simulate; private with Linted.Triggers; private with Linted.Types; package body Linted.Simulator with Spark_Mode => Off is package Command_Line renames Ada.Command_Line; package Real_Time renames Ada.Real_Time; use type Errors.Error; use type Types.Int; use type Real_Time.Time; task Main_Task; package My_Trigger is new Triggers.Handle; task body Main_Task is Controller_KO : KOs.KO; Updater_KO : KOs.KO; My_State : Simulate.State := (Max_Objects => 2, Objects => (1 => ((0, 0), (10 * 1024, 10 * 1024), (0, 0)), 2 => ((0, 0), (0, 0), (-1000, -1000))), Z_Rotation => Types.Sim_Angles.To_Angle (0, 1), X_Rotation => Types.Sim_Angles.To_Angle (3, 16), Controls => (Z_Tilt => 0, X_Tilt => 0, Back => False, Forward => False, Left => False, Right => False, Jumping => False), Counter => 750110405); Next_Time : Real_Time.Time; Read_Future : Controls_Reader.Future; Read_Future_Live : Boolean := False; Write_Future : Update_Writer.Future; Write_Future_Live : Boolean := False; Remind_Me_Future : Timer.Future; Remind_Me_Future_Live : Boolean := False; Update_Pending : Boolean := False; begin if Command_Line.Argument_Count < 2 then raise Constraint_Error with "At least two arguments"; end if; declare Maybe_Controller_KO : constant KOs.KO_Results.Result := KOs.Open (Command_Line.Argument (1), KOs.Read_Write); begin if Maybe_Controller_KO.Erroneous then raise Constraint_Error with "Erroneous controller path"; end if; Controller_KO := Maybe_Controller_KO.Data; end; declare Maybe_Updater_KO : constant KOs.KO_Results.Result := KOs.Open (Command_Line.Argument (2), KOs.Read_Write); begin if Maybe_Updater_KO.Erroneous then raise Constraint_Error with "Erroneous updater path"; end if; Updater_KO := Maybe_Updater_KO.Data; end; Controls_Reader.Read (Controller_KO, My_Trigger.Signal_Handle, Read_Future); Read_Future_Live := True; Next_Time := Real_Time.Clock; Timer.Remind_Me (Next_Time, My_Trigger.Signal_Handle, Remind_Me_Future); Remind_Me_Future_Live := True; loop Triggers.Wait (My_Trigger.Wait_Handle); if Read_Future_Live then declare Event : Controls_Reader.Event; Init : Boolean; begin Controls_Reader.Read_Poll (Read_Future, Event, Init); if Init then Read_Future_Live := False; My_State.Controls := Event.Data; Controls_Reader.Read (Controller_KO, My_Trigger.Signal_Handle, Read_Future); Read_Future_Live := True; end if; end; end if; if Write_Future_Live then declare Err : Errors.Error; Init : Boolean; begin Update_Writer.Write_Poll (Write_Future, Err, Init); if Init then Write_Future_Live := False; end if; end; end if; if Remind_Me_Future_Live then declare Event : Timer.Event; Success : Boolean; begin Timer.Remind_Me_Poll (Remind_Me_Future, Event, Success); if Success then Remind_Me_Future_Live := False; Simulate.Tick (My_State); Update_Pending := True; Next_Time := Next_Time + Real_Time.Nanoseconds ((1000000000 / 60) / 2); Timer.Remind_Me (Next_Time, My_Trigger.Signal_Handle, Remind_Me_Future); Remind_Me_Future_Live := True; end if; end; end if; if Update_Pending and not Write_Future_Live then Update_Writer.Write (Updater_KO, (X_Position => Update.Int (My_State.Objects (1) (Types.X).Value), Y_Position => Update.Int (My_State.Objects (1) (Types.Y).Value), Z_Position => Update.Int (My_State.Objects (1) (Types.Z).Value), MX_Position => Update.Int (My_State.Objects (2) (Types.X).Value), MY_Position => Update.Int (My_State.Objects (2) (Types.Y).Value), MZ_Position => Update.Int (My_State.Objects (2) (Types.Z).Value), Z_Rotation => Update.Nat (Types.Sim_Angles.From_Angle (My_State.Z_Rotation)), X_Rotation => Update.Nat (Types.Sim_Angles.From_Angle (My_State.X_Rotation))), My_Trigger.Signal_Handle, Write_Future); Write_Future_Live := True; Update_Pending := False; end if; end loop; end Main_Task; end Linted.Simulator;
-- SipHash -- an Ada implementation of the algorithm described in -- "SipHash: a fast short-input PRF" -- by Jean-Philippe Aumasson and Daniel J. Bernstein -- Copyright (c) 2015, James Humphry - see LICENSE file for details with Interfaces; with System.Storage_Elements; use type System.Storage_Elements.Storage_Offset; generic c_rounds, d_rounds : Positive; k0 : Interfaces.Unsigned_64 := 16#0706050403020100#; k1 : Interfaces.Unsigned_64 := 16#0f0e0d0c0b0a0908#; package SipHash with SPARK_Mode, Abstract_State => (Initial_Hash_State), Initializes => (Initial_Hash_State) is subtype U64 is Interfaces.Unsigned_64; subtype SipHash_Key is System.Storage_Elements.Storage_Array(1..16); procedure Set_Key (k0, k1 : U64) with Global => (Output => Initial_Hash_State); -- SetKey changes the key used by the package to generate hash values. It is -- particularly useful if you want to avoid dynamic elaboration. procedure Set_Key (k : SipHash_Key) with Pre => (k'Length = 16), Global => (Output => Initial_Hash_State); -- SetKey changes the key used by the package to generate hash values. It is -- particularly useful if you want to avoid dynamic elaboration. function SipHash (m : System.Storage_Elements.Storage_Array) return U64 with Pre => (if m'First <= 0 then (Long_Long_Integer (m'Last) < Long_Long_Integer'Last + Long_Long_Integer (m'First)) ), Global => (Input => Initial_Hash_State); -- This is the full implementation of SipHash, intended to exactly match -- the original paper. The precondition looks odd, but it is because -- Storage_Array is defined with an unconstrained index across -- Storage_Offset, which is a signed value. This means that an array from -- Storage_Offset'First to Storage_Offset'Last would have too long a length -- for calculations to be done in a Storage_Offset variable. private use all type Interfaces.Unsigned_64; -- The state array of the SipHash function type SipHash_State is array (Integer range 0..3) of U64; function Get_Initial_State return SipHash_State with Inline, Global => (Input => Initial_Hash_State); subtype SArray is System.Storage_Elements.Storage_Array; subtype SArray_8 is System.Storage_Elements.Storage_Array(0..7); function SArray8_to_U64_LE (S : in SArray_8) return U64 with Inline; function SArray_Tail_to_U64_LE (S : in SArray) return U64 with Inline, Pre => (if S'First <= 0 then ( (Long_Long_Integer (S'Last) < Long_Long_Integer'Last + Long_Long_Integer (S'First)) and then S'Length in 1..7 ) else S'Length in 1..7 ); procedure Sip_Round (v : in out SipHash_State) with Inline; function Sip_Finalization (v : in SipHash_State) return U64 with Inline; end SipHash;