content
stringlengths
23
1.05M
with Ada.Containers.Vectors; with Ada.Finalization; with GNAT.Strings; -- https://adventofcode.com/2020/day/2 -- ========================================================================== -- --- Day 2: Password Philosophy --- -- -- Your flight departs in a few days from the coastal airport; -- the easiest way down to the coast from here is via toboggan. -- -- The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. -- "Something's wrong with our computers; we can't log in!" You ask if you can take a look. -- -- Their password database seems to be a little corrupted: some of the passwords -- wouldn't have been allowed by the Official Toboggan Corporate Policy that was in effect when they were chosen. -- -- To try to debug the problem, they have created a list (your puzzle input) -- of passwords (according to the corrupted database) and the corporate policy when that password was set. -- -- For example, suppose you have the following list: -- -- 1-3 a: abcde -- 1-3 b: cdefg -- 2-9 c: ccccccccc -- -- Each line gives the password policy and then the password. -- The password policy indicates the lowest and highest number of times a given letter -- must appear for the password to be valid. -- For example, 1-3 a means that the password must contain a at least 1 time and at most 3 times. -- -- In the above example, 2 passwords are valid. -- The middle password, cdefg, is not; -- it contains no instances of b, but needs at least 1. -- The first and third passwords are valid: they contain one a or nine c, -- both within the limits of their respective policies. -- -- How many passwords are valid according to their policies? -- ========================================================================== --- Part Two --- -- While it appears you validated the passwords correctly, -- they don't seem to be what the Official Toboggan Corporate Authentication System is expecting. -- -- The shopkeeper suddenly realizes that he just accidentally explained the password policy rules -- from his old job at the sled rental place down the street! -- The Official Toboggan Corporate Policy actually works a little differently. -- -- Each policy actually describes two positions in the password, -- where 1 means the first character, -- 2 means the second character, and so on. -- (Be careful; Toboggan Corporate Policies have no concept of "index zero"!) -- Exactly one of these positions must contain the given letter. -- Other occurrences of the letter are irrelevant for the purposes of policy enforcement. -- -- Given the same example list from above: -- -- 1-3 a: abcde is valid: position 1 contains a and position 3 does not. -- 1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b. -- 2-9 c: ccccccccc is invalid: both position 2 and position 9 contain c. package Adventofcode.Day_2 is use type GNAT.Strings.String_Access; type Password_Entry is new Ada.Finalization.Controlled with record Min, Max : Natural; Key : Character; Password : GNAT.Strings.String_Access; end record; function Image (Self : Password_Entry) return String is ("Min => " & Self.Min'Img & ", Max => " & Self.Max'Img & ", Key => '" & Self.Key & "'" & ", Password => " & (if Self.Password = null then "<null>" else '"' & Self.Password.all & '"')); overriding procedure Finalize (Object : in out Password_Entry); overriding procedure Adjust (Object : in out Password_Entry); function Valid (Self : Password_Entry) return Boolean; function Valid2 (Self : Password_Entry) return Boolean; function Parse (Line : String) return Password_Entry; package Password_Entrys is new Ada.Containers.Vectors (Natural, Password_Entry); end Adventofcode.Day_2;
with System.Native_Credentials; package body Ada.Credentials is function User_Name return String is begin -- User_Name has a default parameter in Darwin, but not in Windows return System.Native_Credentials.User_Name; end User_Name; end Ada.Credentials;
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; use Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; use Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; use Aws, Ada.Strings.Unbounded, Input_Sources.Strings; use Ada.Text_IO, Ada.Command_Line; procedure Not_Coded is package Members_Vectors is new Ada.Containers.Vectors ( Index_Type => Positive, Element_Type => Unbounded_String); use Members_Vectors; All_Tasks, Language_Members : Vector; procedure Get_Vector (Category : in String; Mbr_Vector : in out Vector) is Reader : Tree_Reader; Doc : Document; List : Node_List; N : Node; A : Attr; Page : Aws.Response.Data; S : Messages.Status_Code; -- Query has cmlimit value of 100, so we need 5 calls to -- retrieve the complete list of Programming_category Uri_Xml : constant String := "http://rosettacode.org/mw/api.php?action=query&list=categorymembers" & "&format=xml&cmlimit=100&cmtitle=Category:"; Cmcontinue : Unbounded_String := Null_Unbounded_String; begin loop Page := Aws.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue))); S := Response.Status_Code (Page); if S not in Messages.Success then Put_Line ("Unable to retrieve data => Status Code :" & Image (S) & " Reason :" & Reason_Phrase (S)); raise Connection_Error; end if; declare Xml : constant String := Message_Body (Page); Source : String_Input; begin Open (Xml'Unrestricted_Access, Unicode.Ces.Utf8.Utf8_Encoding, Source); Parse (Reader, Source); Close (Source); end; Doc := Get_Tree (Reader); List := Get_Elements_By_Tag_Name (Doc, "cm"); for Index in 1 .. Length (List) loop N := Item (List, Index - 1); A := Get_Named_Item (Attributes (N), "title"); Members_Vectors.Append (Mbr_Vector, To_Unbounded_String (Value (A))); end loop; Free (List); List := Get_Elements_By_Tag_Name (Doc, "query-continue"); if Length (List) = 0 then -- we are done Free (List); Free (Reader); exit; end if; N := First_Child (Item (List, 0)); A := Get_Named_Item (Attributes (N), "cmcontinue"); Cmcontinue := To_Unbounded_String ("&cmcontinue=" & Aws.Url.Encode (Value (A))); Free (List); Free (Reader); end loop; end Get_Vector; procedure Quick_Diff (From : in out Vector; Substract : in Vector) is Beginning, Position : Extended_Index; begin -- take adavantage that both lists are already sorted Beginning := First_Index (From); for I in First_Index (Substract) .. Last_Index (Substract) loop Position := Find_Index (Container => From, Item => Members_Vectors.Element (Substract, I), Index => Beginning); if not (Position = No_Index) then Delete (From, Position); Beginning := Position; end if; end loop; end Quick_Diff; begin if Argument_Count = 0 then Put_Line ("Can't process : No language given!"); return; else Get_Vector (Argument (1), Language_Members); end if; Get_Vector ("Programming_Tasks", All_Tasks); Quick_Diff (All_Tasks, Language_Members); for I in First_Index (All_Tasks) .. Last_Index (All_Tasks) loop Put_Line (To_String (Members_Vectors.Element (All_Tasks, I))); end loop; Put_Line ("Numbers of tasks not implemented :=" & Integer'Image (Last_Index ((All_Tasks)))); end Not_Coded;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Incr.Lexers.Incremental is procedure Apply_Marking (Node : Nodes.Node_Access; Previous : Version_Trees.Version; Reference : Version_Trees.Version); procedure Mark_From (Token : Nodes.Tokens.Token_Access; Reference : Version_Trees.Version); procedure Lexing_Phase (Self : in out Incremental_Lexer); pragma Unreferenced (Lexing_Phase); function Find_Next_Region (Self : access Nodes.Node'Class) return Nodes.Tokens.Token_Access; ------------------- -- Apply_Marking -- ------------------- procedure Apply_Marking (Node : Nodes.Node_Access; Previous : Version_Trees.Version; Reference : Version_Trees.Version) is begin if Node.Is_Token and then Node.Local_Changes (Reference, Previous) then declare use type League.Strings.Universal_String; Token : constant Nodes.Tokens.Token_Access := Nodes.Tokens.Token_Access (Node); Current : constant League.Strings.Universal_String := Token.Text (Previous); Before : constant League.Strings.Universal_String := Token.Text (Reference); begin -- Handle textual changes. if Current /= Before then Mark_From (Token, Reference); end if; end; else -- Handle structural changes. for J in 1 .. Node.Arity loop declare use type Nodes.Node_Access; Now : constant Nodes.Node_Access := Node.Child (J, Previous); Before : constant Nodes.Node_Access := Node.Child (J, Reference); Token : Nodes.Tokens.Token_Access; begin if Now /= Before and Before /= null then Token := Before.First_Token (Reference); Mark_From (Token, Reference); Token := Before.Last_Token (Reference) .Next_Token (Reference); Mark_From (Token, Reference); end if; end; end loop; -- Recursively process any edits within this subtree. if Node.Nested_Changes (Reference, Previous) then for J in 1 .. Node.Arity loop declare use type Nodes.Node_Access; Now : constant Nodes.Node_Access := Node.Child (J, Previous); begin if Now /= null then Apply_Marking (Now, Previous, Reference); end if; end; end loop; end if; end if; end Apply_Marking; ---------------------- -- Find_Next_Region -- ---------------------- function Find_Next_Region (Self : access Nodes.Node'Class) return Nodes.Tokens.Token_Access is use type Nodes.Tokens.Token_Access; Now : constant Version_Trees.Version := Self.Document.History.Changing; begin if Self.Is_Token then if Self.Document.End_Of_Stream = Self or else Self.Get_Flag (Nodes.Need_Analysis) then return Nodes.Tokens.Token_Access (Self); end if; elsif Self.Nested_Changes (From => Now, To => Now) then return Find_Next_Region (Self.Child (1, Now)); end if; return Find_Next_Region (Self.Next_Subtree (Now)); end Find_Next_Region; --------------------- -- First_New_Token -- --------------------- function First_New_Token (Self : in out Incremental_Lexer; Token : Nodes.Tokens.Token_Access) return Nodes.Tokens.Token_Access is use type Nodes.Tokens.Token_Access; Ref : constant Version_Trees.Version := Self.Reference; begin -- Reset internal state of batch lexer by setting new source Self.Batch.Set_Source (Self'Unchecked_Access); if Token = Token.Document.Start_Of_Stream then Self.State := Lexers.Batch_Lexers.INITIAL; else Self.State := Token.Previous_Token (Ref).State (Ref); end if; Self.Batch.Set_Start_Condition (Self.State); -- Self.New_State defined in Next_New_Token Self.Prev_Token := (null, null); Self.Token := Token; Self.Count := 0; Self.Text := Self.Token.Text (Self.Previous); Self.Cursor.First (Self.Text); return Next_New_Token (Self); end First_New_Token; -------------- -- Get_Next -- -------------- overriding function Get_Next (Self : not null access Incremental_Lexer) return Wide_Wide_Character is use type Nodes.Tokens.Token_Access; Token : Nodes.Tokens.Token_Access; begin while not Self.Cursor.Has_Element loop Self.Count := Self.Count + Self.Token.Text (Self.Previous).Length; Self.State := Self.Token.State (Self.Previous); Token := Self.Token.Next_Token (Self.Previous); if Token = null then return Batch_Lexers.End_Of_Input; end if; if not Self.Token.Get_Flag (Nodes.Bottom_Up_Reused) then Self.Prev_Token (1) := Self.Prev_Token (2); Self.Prev_Token (2) := Self.Token; end if; Self.Token := Token; Self.Text := Self.Token.Text (Self.Previous); Self.Cursor.First (Self.Text); end loop; return Result : Wide_Wide_Character do Result := Self.Cursor.Element; Self.Cursor.Next; end return; end Get_Next; --------------------- -- Is_Synchronized -- --------------------- function Is_Synchronized (Self : Incremental_Lexer) return Boolean is use type Batch_Lexers.State; use type Nodes.Tokens.Token_Access; Token : constant Nodes.Tokens.Token_Access := Self.Token; begin if Self.Count /= 0 or Self.State /= Self.New_State then return False; end if; if Token = null then return True; end if; if Token.Get_Flag (Nodes.Need_Analysis) then return False; end if; if Token.Get_Flag (Nodes.Bottom_Up_Reused) then return False; end if; return True; end Is_Synchronized; ------------------ -- Lexing_Phase -- ------------------ procedure Lexing_Phase (Self : in out Incremental_Lexer) is use type Nodes.Tokens.Token_Access; Token : Nodes.Tokens.Token_Access := Find_Next_Region (Self.Document.Ultra_Root); begin while Token /= Self.Document.End_Of_Stream loop Token := First_New_Token (Self, Token); while not Is_Synchronized (Self) loop Token := Next_New_Token (Self); end loop; Token := Find_Next_Region (Self.Token); end loop; end Lexing_Phase; --------------- -- Mark_From -- --------------- procedure Mark_From (Token : Nodes.Tokens.Token_Access; Reference : Version_Trees.Version) is Next : Nodes.Tokens.Token_Access := Token; begin if Token.Exists (Reference) then for J in 0 .. Token.Lookback (Reference) loop Next.Set_Flag (Nodes.Need_Analysis); Next := Next.Previous_Token (Reference); end loop; else Token.Set_Flag (Nodes.Need_Analysis); end if; end Mark_From; -------------------- -- Next_New_Token -- -------------------- function Next_New_Token (Self : in out Incremental_Lexer) return Nodes.Tokens.Token_Access is function Could_Be_Reused (Token : Nodes.Tokens.Token_Access; Rule : Batch_Lexers.Rule_Index) return Boolean; --------------------- -- Could_Be_Reused -- --------------------- function Could_Be_Reused (Token : Nodes.Tokens.Token_Access; Rule : Batch_Lexers.Rule_Index) return Boolean is use type Nodes.Token_Kind; use type Nodes.Tokens.Token_Access; begin return Token /= null and then Token.Kind = Nodes.Token_Kind (Rule) and then not Token.Get_Flag (Nodes.Bottom_Up_Reused); end Could_Be_Reused; Value : League.Strings.Universal_String; Rule : Batch_Lexers.Rule_Index; Result : Nodes.Tokens.Token_Access; begin Self.Batch.Get_Token (Rule); Value := Self.Batch.Get_Text; Self.Count := Self.Count - Value.Length; Self.New_State := Self.Batch.Get_Start_Condition; if Could_Be_Reused (Self.Prev_Token (1), Rule) then Result := Self.Prev_Token (1); Result.Set_Text (Value); Result.Set_Local_Errors (False); -- Result.Set_State (Self.New_State); -- Result.Set_Lookahead (Self.Batch.Get_Token_Lookahead); Self.Prev_Token (1) := null; Result.Set_Flag (Nodes.Bottom_Up_Reused); elsif Could_Be_Reused (Self.Prev_Token (2), Rule) then Result := Self.Prev_Token (2); Result.Set_Text (Value); Result.Set_Local_Errors (False); -- Result.Set_State (Self.New_State); -- Result.Set_Lookahead (Self.Batch.Get_Token_Lookahead); Self.Prev_Token := (null, null); Result.Set_Flag (Nodes.Bottom_Up_Reused); elsif Could_Be_Reused (Self.Token, Rule) then Result := Self.Token; Result.Set_Text (Value); Result.Set_Local_Errors (False); -- Result.Set_State (Self.New_State); -- Result.Set_Lookahead (Self.Batch.Get_Token_Lookahead); Result.Set_Flag (Nodes.Bottom_Up_Reused); else Result := new Nodes.Tokens.Token (Self.Document); Nodes.Tokens.Constructors.Initialize (Result.all, Nodes.Token_Kind (Rule), Value, Self.New_State, Self.Batch.Get_Token_Lookahead); end if; return Result; end Next_New_Token; ---------------------- -- Prepare_Document -- ---------------------- not overriding procedure Prepare_Document (Self : in out Incremental_Lexer; Document : Documents.Document_Access; Reference : Version_Trees.Version) is Now : constant Version_Trees.Version := Document.History.Changing; begin Self.Document := Document; Self.Reference := Reference; Self.Previous := Document.History.Parent (Now); Apply_Marking (Self.Document.Ultra_Root, Previous => Self.Previous, Reference => Self.Reference); end Prepare_Document; --------------------- -- Set_Batch_Lexer -- --------------------- not overriding procedure Set_Batch_Lexer (Self : in out Incremental_Lexer; Lexer : Batch_Lexers.Batch_Lexer_Access) is begin Self.Batch := Lexer; end Set_Batch_Lexer; ------------------------ -- Synchronized_Token -- ------------------------ not overriding function Synchronized_Token (Self : Incremental_Lexer) return Nodes.Tokens.Token_Access is begin return Self.Token; end Synchronized_Token; end Incr.Lexers.Incremental;
------------------------------------------------------------------------------ -- Copyright (c) 2017, 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. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Web.ACL provides a simple interface for access control to data. -- -- -- -- Currently the backend is responsible for whatever method of user -- -- authentication (e.g. a random token stored in a cookie), and returns the -- -- current user and the groups to which they belong. -- ------------------------------------------------------------------------------ with Natools.References; with Natools.S_Expressions.Lockable; with Natools.Storage_Pools; with Natools.Web.Containers; with Natools.Web.Exchanges; package Natools.Web.ACL is procedure Match (Id : in Containers.Identity; Expression : in out S_Expressions.Lockable.Descriptor'Class; Result : in out Boolean); -- Update Result according to whether Id matches the given Expression type Backend is interface; procedure Authenticate (Self : in Backend; Exchange : in out Exchanges.Exchange) is abstract; -- Look up the identity associated with the given exchange -- (e.g. using a cookie) and store it there. -- Note that it can be called concurrently from several tasks. package Backend_Refs is new Natools.References (Backend'Class, Storage_Pools.Access_In_Default_Pool'Storage_Pool, Storage_Pools.Access_In_Default_Pool'Storage_Pool); end Natools.Web.ACL;
-- -- Nice little HTTP 1.x request parser. Uses a state machine. -- Operates by cutting up the incoming request string into sections. -- package HTTP with SPARK_Mode => On is type Version is delta 0.1 range 1.0 .. 9.9; type Indexes is record First : Natural := 1; Last : Natural := 0; end record; end HTTP;
with P_StepHandler; use P_StepHandler; package P_StepHandler.InputHandler is type T_InputHandler is new T_StepHandler with private; PROCEDURE Initialize (Object : in out T_InputHandler) ; end P_StepHandler.InputHandler;
with RTCH.Colours; use RTCH.Colours; package RTCH.Colours.Steps is -- @given ^c ← color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Given_Colour_C (Red, Green, Blue : Float); -- @then ^c.red = ([-+]?\d+\.?\d*)$ procedure Then_C_Red_Is (Red : Float); -- @and ^c.green = ([-+]?\d+\.?\d*)$ procedure And_C_Green_Is (Green : Float); -- @and ^c.blue = ([-+]?\d+\.?\d*)$ procedure And_C_Blue_Is (Blue : Float); -- @given ^c1 ← color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Given_Colour_C1 (Red, Green, Blue : Float); -- @given ^c2 ← color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Given_Colour_C2 (Red, Green, Blue : Float); -- @then ^c1 \+ c2 = color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Then_C1_Add_C2_Is_Colour (Red, Green, Blue : Float); -- @then ^c1 - c2 = color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Then_C1_Sub_C2_Is_Colour (Red, Green, Blue : Float); -- @then ^c \* ([-+]?\d+\.?\d*) = color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Then_C_Times_Scalar_Is_Colour (Scalar, Red, Green, Blue : Float); -- @then ^c1 \* c2 = color\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$ procedure Then_C1_Times_C2_Is_Colour (Red, Green, Blue : Float); private C : Colour; C1 : Colour; C2 : Colour; end RTCH.Colours.Steps;
------------------------------------------------------------------------------- -- Copyright (c) 2019 Daniel King -- -- 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. ------------------------------------------------------------------------------- package body IEEE802154.MAC with SPARK_Mode => On is ---------------------------- -- Encode_PAN_ID (spec) -- ---------------------------- procedure Encode_PAN_ID (PAN_ID : in Variant_PAN_ID; Buffer : in out DW1000.Types.Byte_Array; Offset : in out Natural) with Inline, Global => null, Depends => (Buffer =>+ (Offset, PAN_ID), Offset =>+ PAN_ID), Pre => (Buffer'Length >= 2 and then Offset <= Buffer'Length - 2), Contract_Cases => (PAN_ID.Present => Offset = Offset'Old + 2, others => (Offset = Offset'Old and Buffer = Buffer'Old)); ----------------------------- -- Encode_Address (spec) -- ----------------------------- procedure Encode_Address (Address : in Variant_Address; Buffer : in out DW1000.Types.Byte_Array; Offset : in out Natural) with Inline, Global => null, Depends => (Buffer =>+ (Offset, Address), Offset =>+ (Offset, Address)), Pre => (Buffer'Length >= 8 and then Offset <= Buffer'Length - 8 and then Address.Mode /= Reserved), Contract_Cases => (Address.Mode = Extended => Offset = Offset'Old + 8, Address.Mode = Short => Offset = Offset'Old + 2, others => (Offset = Offset'Old and Buffer = Buffer'Old)); ----------------------------------------- -- Encode_Aux_Security_Header (spec) -- ----------------------------------------- procedure Encode_Aux_Security_Header (ASH : in Variant_Aux_Security_Header; Buffer : in out DW1000.Types.Byte_Array; Offset : in out Natural) with Inline, Global => null, Depends => (Buffer =>+ (Offset, ASH), Offset =>+ (Offset, ASH)), Pre => (Buffer'Length >= Max_Aux_Security_Header_Length and then Offset <= Buffer'Length - Max_Aux_Security_Header_Length), Post => (Offset in Offset'Old .. Offset'Old + Max_Aux_Security_Header_Length); ----------------------------------------- -- Decode_Frame_Control_Field (spec) -- ----------------------------------------- procedure Decode_Frame_Control_Field (Buffer : in DW1000.Types.Byte_Array; Frame_Control : out Frame_Control_Field; Result : out Decode_Result) with Inline, Global => null, Depends => (Frame_Control => Buffer, Result => Buffer), Post => (if Result = Success then (Frame_Control.Frame_Version /= Reserved and Frame_Control.Dest_Address_Mode /= Reserved and Frame_Control.Src_Address_Mode /= Reserved and Buffer'Length >= 2)); ------------------------------------------- -- Decode_Sequence_Number_Field (spec) -- ------------------------------------------- procedure Decode_Sequence_Number_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; Sequence_Number : out Variant_Sequence_Number; Result : out Decode_Result) with Inline, Global => null, Depends => (Sequence_Number => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Pre => not Sequence_Number'Constrained, Post => (if Result = Success then (Offset = Offset'Old + 1 and Offset <= Buffer'Length) else Offset = Offset'Old); ---------------------------------- -- Decode_PAN_ID_Field (spec) -- ---------------------------------- procedure Decode_PAN_ID_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; PAN_ID : out Variant_PAN_ID; Result : out Decode_Result) with Inline, Global => null, Depends => (PAN_ID => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Pre => not PAN_ID'Constrained, Post => (if Result = Success then (Offset = Offset'Old + 2 and Offset <= Buffer'Length and PAN_ID.Present) else Offset = Offset'Old); -------------------------------------------- -- Decode_Extended_Address_Field (spec) -- -------------------------------------------- procedure Decode_Extended_Address_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; Address : out Variant_Address; Result : out Decode_Result) with Inline, Global => null, Depends => (Address => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Pre => not Address'Constrained, Post => (if Result = Success then (Offset = Offset'Old + 8 and Offset <= Buffer'Length and Address.Mode = Extended) else Offset = Offset'Old); ----------------------------------------- -- Decode_Short_Address_Field (spec) -- ----------------------------------------- procedure Decode_Short_Address_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; Address : out Variant_Address; Result : out Decode_Result) with Inline, Global => null, Depends => (Address => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Pre => not Address'Constrained, Post => (if Result = Success then (Offset = Offset'Old + 2 and Offset <= Buffer'Length and Address.Mode = Short) else Offset = Offset'Old); ----------------------------------------- -- Decode_Aux_Security_Header (spec) -- ----------------------------------------- procedure Decode_Aux_Security_Header (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; ASH : out Variant_Aux_Security_Header; Result : out Decode_Result) with Inline, Global => null, Depends => (ASH => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Pre => not ASH'Constrained, Post => (if Result = Success then (Offset > Offset'Old and Offset - Offset'Old <= Max_Aux_Security_Header_Length and Offset <= Buffer'Length and ASH.Security_Enabled = Enabled)); -------------------------------------------- -- Decode_Security_Control_Field (spec) -- -------------------------------------------- procedure Decode_Security_Control_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; SC : out Security_Control_Field; Result : out Decode_Result) with Inline, Global => null, Depends => (SC => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Post => (if Result = Success then (Offset = Offset'Old + 1 and Offset <= Buffer'Length) else Offset = Offset'Old); ----------------------------------------- -- Decode_Frame_Counter_Field (spec) -- ----------------------------------------- procedure Decode_Frame_Counter_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; FC : out Variant_Frame_Counter; Result : out Decode_Result) with Inline, Global => null, Depends => (FC => (Buffer, Offset), Result => (Buffer, Offset), Offset =>+ Buffer), Pre => not FC'Constrained, Post => (if Result = Success then (Offset = Offset'Old + 4 and Offset <= Buffer'Length and FC.Suppression = Not_Suppressed) else Offset = Offset'Old and FC.Suppression = Suppressed); ---------------------------------- -- Decode_Key_ID_Field (spec) -- ---------------------------------- procedure Decode_Key_ID_Field (Buffer : in DW1000.Types.Byte_Array; Mode : in Key_ID_Mode_Field; Offset : in out Natural; Key_ID : out Variant_Key_ID; Result : out Decode_Result) with Inline, Global => null, Depends => (Key_ID => (Buffer, Mode, Offset), Result => (Buffer, Mode, Offset), Offset =>+ (Buffer, Mode)), Pre => not Key_ID'Constrained, Post => (if Result = Success then Key_ID.Mode = Mode and Offset <= Buffer'Length else Offset = Offset'Old), Contract_Cases => (Mode = 0 => Offset = Offset'Old, Mode = 1 => (if Result = Success then Offset = Offset'Old + 1), Mode = 2 => (if Result = Success then Offset = Offset'Old + 5), Mode = 3 => (if Result = Success then Offset = Offset'Old + 9)); -------------- -- Encode -- -------------- procedure Encode (MHR : in MAC_Header; Buffer : in out DW1000.Types.Byte_Array; Length : out Natural) is PAN_ID_Compression : PAN_ID_Compression_Field; Include_Source_PAN_ID : Boolean := MHR.Source_PAN_ID.Present; begin -- Determine whether or not the PAN ID compression field needs to be -- set. Refer to Section 7.2.1.5 of IEEE 802.15.4-2015 for a description -- of the rules. case MHR.Frame_Version is when IEEE_802_15_4_2003 | IEEE_802_15_4_2006 => -- If both destination and source addressing information is present, -- the MAC sublayer shall compare the destination and source PAN -- identifiers. If the PAN IDs are identical, the PAN ID Compression -- field shall be set to one, and the Source PAN ID field shall be -- omitted from the transmitted frame. If the PAN IDs are different, -- the PAN ID Compression field shall be set to zero, and both -- Destination PAN ID field and Source PAN ID fields shall be -- included in the transmitted frame. if (MHR.Destination_PAN_ID.Present and MHR.Source_PAN_ID.Present and MHR.Destination_Address.Mode /= Not_Present and MHR.Source_Address.Mode /= Not_Present) then if MHR.Source_PAN_ID.PAN_ID = MHR.Destination_PAN_ID.PAN_ID then PAN_ID_Compression := Compressed; Include_Source_PAN_ID := False; else PAN_ID_Compression := Not_Compressed; end if; else PAN_ID_Compression := Not_Compressed; end if; when IEEE_802_15_4 => PAN_ID_Compression := Get_PAN_ID_Compression (Destination_Address_Mode => MHR.Destination_Address.Mode, Source_Address_Mode => MHR.Source_Address.Mode, Destination_PAN_ID_Present => MHR.Destination_PAN_ID.Present, Source_PAN_ID_Present => MHR.Source_PAN_ID.Present); when Reserved => -- Unreachable (unless precondition is violated) raise Program_Error; end case; -- Encode the Frame Control field Buffer (Buffer'First .. Buffer'First + 1) := Convert (Frame_Control_Field' (Frame_Type => MHR.Frame_Type, Security_Enabled => MHR.Aux_Security_Header.Security_Enabled, Frame_Pending => MHR.Frame_Pending, AR => MHR.AR, PAN_ID_Compression => PAN_ID_Compression, Reserved => 0, SN_Suppression => MHR.Sequence_Number.Suppression, IE_Present => MHR.IE_Present, Dest_Address_Mode => MHR.Destination_Address.Mode, Frame_Version => MHR.Frame_Version, Src_Address_Mode => MHR.Source_Address.Mode)); Length := 2; pragma Assert (Length = 2); -- Encode the sequence number if MHR.Sequence_Number.Suppression = Not_Suppressed then Buffer (Buffer'First + Length) := Bits_8 (MHR.Sequence_Number.Number); Length := Length + 1; end if; pragma Assert (Length in 2 .. 3); -- Encode the destination PAN ID Encode_PAN_ID (PAN_ID => MHR.Destination_PAN_ID, Buffer => Buffer, Offset => Length); pragma Assert (Length in 2 .. 5); -- Encode the destination address Encode_Address (Address => MHR.Destination_Address, Buffer => Buffer, Offset => Length); pragma Assert (Length in 2 .. 13); -- Encode the source PAN ID if Include_Source_PAN_ID then Encode_PAN_ID (PAN_ID => MHR.Source_PAN_ID, Buffer => Buffer, Offset => Length); end if; pragma Assert (Length in 2 .. 15); -- Encode the source address Encode_Address (Address => MHR.Source_Address, Buffer => Buffer, Offset => Length); pragma Assert (Length in 2 .. 23); Encode_Aux_Security_Header (ASH => MHR.Aux_Security_Header, Buffer => Buffer, Offset => Length); end Encode; -------------- -- Decode -- -------------- procedure Decode (Buffer : in DW1000.Types.Byte_Array; MHR : out MAC_Header; Length : out Natural; Result : out Decode_Result) is Frame_Control : Frame_Control_Field; begin Length := 0; -- Initialise the MAC header to some default values MHR := (Frame_Type => Frame_Type_Field'First, Frame_Pending => Not_Pending, AR => Not_Required, PAN_ID_Compression => Not_Compressed, IE_Present => Not_Present, Frame_Version => Frame_Version_Field'First, Sequence_Number => (Suppression => Suppressed), Destination_PAN_ID => (Present => False), Destination_Address => (Mode => Not_Present), Source_PAN_ID => (Present => False), Source_Address => (Mode => Not_Present), Aux_Security_Header => (Security_Enabled => Disabled)); Decode_Frame_Control_Field (Buffer => Buffer, Frame_Control => Frame_Control, Result => Result); -- Decode the Sequence Number (if present) if Result = Success then MHR.Frame_Type := Frame_Control.Frame_Type; MHR.Frame_Pending := Frame_Control.Frame_Pending; MHR.AR := Frame_Control.AR; MHR.PAN_ID_Compression := Frame_Control.PAN_ID_Compression; MHR.IE_Present := Frame_Control.IE_Present; MHR.Frame_Version := Frame_Control.Frame_Version; Length := 2; pragma Assert (Length <= Buffer'Length); if Frame_Control.SN_Suppression = Not_Suppressed then Decode_Sequence_Number_Field (Buffer => Buffer, Offset => Length, Sequence_Number => MHR.Sequence_Number, Result => Result); end if; end if; pragma Assert (Length <= 3); pragma Assert (Length <= Buffer'Length); pragma Assert (if Result = Success then Length >= 2); -- Decode the Destination PAN ID field (if present) if Result = Success then if Is_Destination_PAN_ID_Present (Destination_Address_Mode => Frame_Control.Dest_Address_Mode, Source_Address_Mode => Frame_Control.Src_Address_Mode, PAN_ID_Compression => Frame_Control.PAN_ID_Compression) then Decode_PAN_ID_Field (Buffer => Buffer, Offset => Length, PAN_ID => MHR.Destination_PAN_ID, Result => Result); end if; end if; pragma Assert (Length <= 5); pragma Assert (Length <= Buffer'Length); pragma Assert (if Result = Success then Length >= 2); -- Decode the Destination Address field (if present) if Result = Success then case Frame_Control.Dest_Address_Mode is when Extended => Decode_Extended_Address_Field (Buffer => Buffer, Offset => Length, Address => MHR.Destination_Address, Result => Result); when Short => Decode_Short_Address_Field (Buffer => Buffer, Offset => Length, Address => MHR.Destination_Address, Result => Result); when Reserved => raise Program_Error; -- Unreachable when Not_Present => null; end case; pragma Assert (if Result = Success then MHR.Destination_Address.Mode = Frame_Control.Dest_Address_Mode); end if; pragma Assert (Length <= 13); pragma Assert (Length <= Buffer'Length); pragma Assert (if Result = Success then Length >= 2); -- Decode the Source PAN ID field (if present) if Result = Success then if Is_Source_PAN_ID_Present (Destination_Address_Mode => Frame_Control.Dest_Address_Mode, Source_Address_Mode => Frame_Control.Src_Address_Mode, PAN_ID_Compression => Frame_Control.PAN_ID_Compression) then Decode_PAN_ID_Field (Buffer => Buffer, Offset => Length, PAN_ID => MHR.Source_PAN_ID, Result => Result); end if; end if; pragma Assert (Length <= 15); pragma Assert (Length <= Buffer'Length); pragma Assert (if Result = Success then Length >= 2); -- Decode the Source Address field (if present) if Result = Success then case Frame_Control.Src_Address_Mode is when Extended => Decode_Extended_Address_Field (Buffer => Buffer, Offset => Length, Address => MHR.Source_Address, Result => Result); when Short => Decode_Short_Address_Field (Buffer => Buffer, Offset => Length, Address => MHR.Source_Address, Result => Result); when Reserved => raise Program_Error; -- Unreachable when Not_Present => null; end case; pragma Assert (if Result = Success then MHR.Source_Address.Mode = Frame_Control.Src_Address_Mode); end if; pragma Assert (Length <= 23); pragma Assert (Length <= Buffer'Length); pragma Assert (if Result = Success then Length >= 2); end Decode; ---------------------------- -- Encode_PAN_ID (body) -- ---------------------------- procedure Encode_PAN_ID (PAN_ID : in Variant_PAN_ID; Buffer : in out DW1000.Types.Byte_Array; Offset : in out Natural) is Pos : constant DW1000.Types.Index := Buffer'First + Offset; begin if PAN_ID.Present then Buffer (Pos .. Pos + 1) := Convert (PAN_ID.PAN_ID); Offset := Offset + 2; end if; end Encode_PAN_ID; ----------------------------- -- Encode_Address (body) -- ----------------------------- procedure Encode_Address (Address : in Variant_Address; Buffer : in out DW1000.Types.Byte_Array; Offset : in out Natural) is Pos : constant DW1000.Types.Index := Buffer'First + Offset; begin case Address.Mode is when Extended => Buffer (Pos .. Pos + 7) := Convert (Address.Extended_Address); Offset := Offset + 8; when Short => Buffer (Pos .. Pos + 1) := Convert (Address.Short_Address); Offset := Offset + 2; when Reserved => -- Unreachable (unless precondition is violated) raise Program_Error; when Not_Present => null; end case; end Encode_Address; ----------------------------------------- -- Encode_Aux_Security_Header (body) -- ----------------------------------------- procedure Encode_Aux_Security_Header (ASH : in Variant_Aux_Security_Header; Buffer : in out DW1000.Types.Byte_Array; Offset : in out Natural) is Pos : DW1000.Types.Index := Buffer'First + Offset; begin if ASH.Security_Enabled = Enabled then -- Encode the Security Control field Buffer (Pos) := Convert (Security_Control_Field' (Security_Level => ASH.Security_Level, Key_ID_Mode => ASH.Key_ID.Mode, FC_Suppression => ASH.Frame_Counter.Suppression, Nonce_Source => ASH.ASN_In_Nonce, Reserved => 0)); Pos := Pos + 1; Offset := Offset + 1; -- Encode the Frame Counter (if not suppressed) if ASH.Frame_Counter.Suppression = Not_Suppressed then Buffer (Pos .. Pos + 3) := Convert (ASH.Frame_Counter.Frame_Counter); Pos := Pos + 4; Offset := Offset + 4; end if; -- Encode the Key ID field (variable length) case ASH.Key_ID.Mode is when 0 => null; when 1 => Buffer (Pos) := Bits_8 (ASH.Key_ID.Key_Index); Offset := Offset + 1; when 2 => Buffer (Pos) := Bits_8 (ASH.Key_ID.Key_Index); Buffer (Pos .. Pos + 3) := Byte_Array (ASH.Key_ID.Key_Source_4); Offset := Offset + 5; when 3 => Buffer (Pos) := Bits_8 (ASH.Key_ID.Key_Index); Buffer (Pos .. Pos + 7) := Byte_Array (ASH.Key_ID.Key_Source_8); Offset := Offset + 9; end case; end if; end Encode_Aux_Security_Header; ----------------------------------------- -- Decode_Frame_Control_Field (body) -- ----------------------------------------- Null_Frame_Control : constant Frame_Control_Field := (Frame_Type => Frame_Type_Field'First, Security_Enabled => Disabled, Frame_Pending => Not_Pending, AR => Not_Required, PAN_ID_Compression => Not_Compressed, Reserved => 0, SN_Suppression => Not_Suppressed, IE_Present => Not_Present, Dest_Address_Mode => Not_Present, Frame_Version => Frame_Version_Field'First, Src_Address_Mode => Not_Present); procedure Decode_Frame_Control_Field (Buffer : in DW1000.Types.Byte_Array; Frame_Control : out Frame_Control_Field; Result : out Decode_Result) is begin if Buffer'Length < 2 then Frame_Control := Null_Frame_Control; Result := End_Of_Buffer; else Frame_Control := Convert (Buffer (Buffer'First .. Buffer'First + 1)); if (Frame_Control.Frame_Version = Reserved or Frame_Control.Dest_Address_Mode = Reserved or Frame_Control.Src_Address_Mode = Reserved) then Result := Reserved_Field; else Result := Success; end if; end if; end Decode_Frame_Control_Field; ------------------------------------------- -- Decode_Sequence_Number_Field (body) -- ------------------------------------------- procedure Decode_Sequence_Number_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; Sequence_Number : out Variant_Sequence_Number; Result : out Decode_Result) is begin if Offset >= Buffer'Length then Sequence_Number := (Suppression => Suppressed); Result := End_Of_Buffer; else Sequence_Number := (Suppression => Not_Suppressed, Number => Sequence_Number_Field (Buffer (Buffer'First + Offset))); Offset := Offset + 1; Result := Success; end if; end Decode_Sequence_Number_Field; ---------------------------------- -- Decode_PAN_ID_Field (body) -- ---------------------------------- procedure Decode_PAN_ID_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; PAN_ID : out Variant_PAN_ID; Result : out Decode_Result) is Pos : DW1000.Types.Index; begin if Buffer'Length < 2 or else Offset > Buffer'Length - 2 then PAN_ID := (Present => False); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; PAN_ID := (Present => True, PAN_ID => Convert (Buffer (Pos .. Pos + 1))); Offset := Offset + 2; Result := Success; end if; end Decode_PAN_ID_Field; -------------------------------------------- -- Decode_Extended_Address_Field (body) -- -------------------------------------------- procedure Decode_Extended_Address_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; Address : out Variant_Address; Result : out Decode_Result) is Pos : DW1000.Types.Index; begin if Buffer'Length < 8 or else Offset > Buffer'Length - 8 then Address := (Mode => Not_Present); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; Address := (Mode => Extended, Extended_Address => Convert (Buffer (Pos .. Pos + 7))); Offset := Offset + 8; Result := Success; end if; end Decode_Extended_Address_Field; ----------------------------------------- -- Decode_Short_Address_Field (body) -- ----------------------------------------- procedure Decode_Short_Address_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; Address : out Variant_Address; Result : out Decode_Result) is Pos : DW1000.Types.Index; begin if Buffer'Length < 2 or else Offset > Buffer'Length - 2 then Address := (Mode => Not_Present); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; Address := (Mode => Short, Short_Address => Convert (Buffer (Pos .. Pos + 1))); Offset := Offset + 2; Result := Success; end if; end Decode_Short_Address_Field; ----------------------------------------- -- Decode_Aux_Security_Header (body) -- ----------------------------------------- procedure Decode_Aux_Security_Header (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; ASH : out Variant_Aux_Security_Header; Result : out Decode_Result) is Initial_Offset : constant Natural := Offset with Ghost; Security_Control : Security_Control_Field; begin Decode_Security_Control_Field (Buffer => Buffer, Offset => Offset, SC => Security_Control, Result => Result); if Result = Success then pragma Assert (Offset = Initial_Offset + 1); ASH := (Security_Enabled => Enabled, Security_Level => Security_Control.Security_Level, ASN_In_Nonce => Security_Control.Nonce_Source, Frame_Counter => (Suppression => Suppressed), Key_ID => (Mode => 0)); if Security_Control.FC_Suppression = Not_Suppressed then Decode_Frame_Counter_Field (Buffer => Buffer, Offset => Offset, FC => ASH.Frame_Counter, Result => Result); end if; else ASH := (Security_Enabled => Disabled); end if; pragma Assert (Offset >= Initial_Offset); pragma Assert (if Result = Success then Offset - Initial_Offset in 1 .. 5); pragma Assert (if Result = Success then Offset <= Buffer'Length); if Result = Success then Decode_Key_ID_Field (Buffer => Buffer, Mode => Security_Control.Key_ID_Mode, Offset => Offset, Key_ID => ASH.Key_ID, Result => Result); end if; pragma Assert (Offset >= Initial_Offset); pragma Assert (if Result = Success then Offset - Initial_Offset in 1 .. 14); pragma Assert (if Result = Success then Offset <= Buffer'Length); end Decode_Aux_Security_Header; -------------------------------------------- -- Decode_Security_Control_Field (body) -- -------------------------------------------- procedure Decode_Security_Control_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; SC : out Security_Control_Field; Result : out Decode_Result) is begin if Buffer'Length < 1 or else Offset > Buffer'Length - 1 then SC := (Security_Level => 0, Key_ID_Mode => 0, FC_Suppression => Not_Suppressed, Nonce_Source => From_Frame_Counter, Reserved => 0); Result := End_Of_Buffer; else SC := Convert (Buffer (Buffer'First)); Offset := Offset + 1; Result := Success; end if; end Decode_Security_Control_Field; ----------------------------------------- -- Decode_Frame_Counter_Field (body) -- ----------------------------------------- procedure Decode_Frame_Counter_Field (Buffer : in DW1000.Types.Byte_Array; Offset : in out Natural; FC : out Variant_Frame_Counter; Result : out Decode_Result) is Pos : DW1000.Types.Index; begin if Buffer'Length < 4 or else Offset > Buffer'Length - 4 then FC := (Suppression => Suppressed); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; FC := (Suppression => Not_Suppressed, Frame_Counter => Convert (Buffer (Pos .. Pos + 3))); Offset := Offset + 4; Result := Success; end if; end Decode_Frame_Counter_Field; ---------------------------------- -- Decode_Key_ID_Field (body) -- ---------------------------------- procedure Decode_Key_ID_Field (Buffer : in DW1000.Types.Byte_Array; Mode : in Key_ID_Mode_Field; Offset : in out Natural; Key_ID : out Variant_Key_ID; Result : out Decode_Result) is Pos : DW1000.Types.Index; begin case Mode is when 0 => Key_ID := (Mode => 0); if Offset > Buffer'Length then Result := End_Of_Buffer; else Result := Success; end if; when 1 => if Buffer'Length < 1 or else Offset > Buffer'Length - 1 then Key_ID := (Mode => 0); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; Key_ID := (Mode => 1, Key_Index => Key_Index_Field (Buffer (Pos))); Offset := Offset + 1; Result := Success; end if; when 2 => if Buffer'Length < 5 or else Offset > Buffer'Length - 5 then Key_ID := (Mode => 0); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; Key_ID := (Mode => 2, Key_Index => Key_Index_Field (Buffer (Pos)), Key_Source_4 => Key_Source_Field (Buffer (Pos + 1 .. Pos + 4))); Offset := Offset + 5; Result := Success; end if; when 3 => if Buffer'Length < 9 or else Offset > Buffer'Length - 9 then Key_ID := (Mode => 0); Result := End_Of_Buffer; else Pos := Buffer'First + Offset; Key_ID := (Mode => 3, Key_Index => Key_Index_Field (Buffer (Pos)), Key_Source_8 => Key_Source_Field (Buffer (Pos + 1 .. Pos + 8))); Offset := Offset + 9; Result := Success; end if; end case; end Decode_Key_ID_Field; end IEEE802154.MAC;
with MSP430_SVD; use MSP430_SVD; package MSPGD.UART is pragma Preelaborate; type Clock_Source_Type is (UCLK, ACLK, SMCLK); end MSPGD.UART;
generic type Element is (<>); with function Image(E: Element) return String; package Set_Cons is type Set is private; -- constructor and manipulation functions for type Set function "+"(E: Element) return Set; function "+"(Left, Right: Element) return Set; function "+"(Left: Set; Right: Element) return Set; function "-"(Left: Set; Right: Element) return Set; -- compare, unite or output a Set function Nonempty_Intersection(Left, Right: Set) return Boolean; function Union(Left, Right: Set) return Set; function Image(S: Set) return String; type Set_Vec is array(Positive range <>) of Set; -- output a Set_Vec function Image(V: Set_Vec) return String; private type Set is array(Element) of Boolean; end Set_Cons;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- 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 ewok.tasks_shared; use ewok.tasks_shared; with ewok.devices_shared; with ewok.ipc; with ewok.exported.dma; with ewok.dma_shared; with ewok.mpu; with soc; with soc.layout; package ewok.tasks with spark_mode => off is subtype t_task_name is string (1 .. 10); type t_task_state is ( -- No task in this slot TASK_STATE_EMPTY, -- Task can be elected by the scheduler with its standard priority -- or an ISR is ready for execution TASK_STATE_RUNNABLE, -- Force the scheduler to choose that task TASK_STATE_FORCED, -- Pending syscall. Task can't be scheduled. TASK_STATE_SVC_BLOCKED, -- An ISR is finished TASK_STATE_ISR_DONE, -- Task currently has nothing to do, not schedulable TASK_STATE_IDLE, -- Task is sleeping TASK_STATE_SLEEPING, -- Task is deeply sleeping TASK_STATE_SLEEPING_DEEP, -- Task has generated an exception (memory fault, etc.), not -- schedulable anymore TASK_STATE_FAULT, -- Task has return from its main() function. Yet its ISR handlers can -- still be executed if needed TASK_STATE_FINISHED, -- Task has emitted a blocking send(target) and is waiting for that -- the EndPoint shared with the receiver gets ready TASK_STATE_IPC_SEND_BLOCKED, -- Task has emitted a blocking recv(target) and is waiting for a -- send() TASK_STATE_IPC_RECV_BLOCKED, -- Task has emitted a blocking send(target) and is waiting recv() -- acknowledgement from the target task TASK_STATE_IPC_WAIT_ACK, -- Task has entered in a critical section. Related ISRs can't be executed TASK_STATE_LOCKED); type t_task_type is (-- Kernel task TASK_TYPE_KERNEL, -- User task, being executed in user mode, with restricted access TASK_TYPE_USER); type t_main_context is record frame_a : ewok.t_stack_frame_access; end record; type t_isr_context is record entry_point : system_address; device_id : ewok.devices_shared.t_device_id; sched_policy : ewok.tasks_shared.t_scheduling_post_isr; frame_a : ewok.t_stack_frame_access; end record; -- -- Tasks -- MAX_DEVS_PER_TASK : constant := 10; MAX_DMAS_PER_TASK : constant := 8; MAX_INTERRUPTS_PER_TASK : constant := 8; MAX_DMA_SHM_PER_TASK : constant := 4; type t_registered_dma_index_list is array (unsigned_32 range <>) of ewok.dma_shared.t_user_dma_index; type t_dma_shm_info_list is array (unsigned_32 range <>) of ewok.exported.dma.t_dma_shm_info; type t_device_id_list is array (unsigned_8 range <>) of ewok.devices_shared.t_device_id; type t_task is record name : t_task_name; entry_point : system_address; ttype : t_task_type; mode : t_task_mode; id : ewok.tasks_shared.t_task_id; slot : unsigned_8; -- 1: first slot (0: unused) num_slots : unsigned_8; prio : unsigned_8; #if CONFIG_KERNEL_DOMAIN domain : unsigned_8; #end if; #if CONFIG_KERNEL_SCHED_DEBUG count : unsigned_32; force_count : unsigned_32; isr_count : unsigned_32; #end if; #if CONFIG_KERNEL_DMA_ENABLE num_dma_shms : unsigned_32 range 0 .. MAX_DMA_SHM_PER_TASK; dma_shm : t_dma_shm_info_list (1 .. MAX_DMA_SHM_PER_TASK); num_dma_id : unsigned_32 range 0 .. MAX_DMAS_PER_TASK; dma_id : t_registered_dma_index_list (1 .. MAX_DMAS_PER_TASK); #end if; num_devs : unsigned_8 range 0 .. MAX_DEVS_PER_TASK; num_devs_mounted : unsigned_8 range 0 .. ewok.mpu.MAX_DEVICE_REGIONS; device_id : t_device_id_list (1 .. MAX_DEVS_PER_TASK); mounted_device : t_device_id_list (ewok.mpu.device_regions'range); init_done : boolean; data_slot_start : system_address; data_slot_end : system_address; txt_slot_start : system_address; txt_slot_end : system_address; stack_bottom : system_address; stack_top : system_address; stack_size : unsigned_16; state : t_task_state; isr_state : t_task_state; ipc_endpoints : ewok.ipc.t_endpoints (ewok.tasks_shared.t_task_id'range); ctx : aliased t_main_context; isr_ctx : aliased t_isr_context; end record; type t_task_access is access all t_task; type t_task_array is array (t_task_id range <>) of aliased t_task; ------------- -- Globals -- ------------- -- The list of the running tasks tasks_list : t_task_array (ID_APP1 .. ID_KERNEL); softirq_task_name : aliased t_task_name := "SOFTIRQ" & " "; idle_task_name : aliased t_task_name := "IDLE" & " "; --------------- -- Functions -- --------------- pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE); procedure idle_task with no_return; procedure finished_task with no_return; -- create various task's stack -- preconditions : -- Here we check that generated headers, defining stack address and -- program counter of various stack are valid for the currently -- supported SoC. This is a sanitizing function for generated files. procedure create_stack (sp : in system_address; pc : in system_address; params : in ewok.t_parameters; frame_a : out ewok.t_stack_frame_access) with -- precondition 1 : stack pointer must be in RAM pre => ( (sp >= soc.layout.USER_RAM_BASE and sp <= (soc.layout.USER_RAM_BASE + soc.layout.USER_RAM_SIZE)) or (sp >= soc.layout.KERNEL_RAM_BASE and sp <= (soc.layout.KERNEL_RAM_BASE + soc.layout.KERNEL_RAM_SIZE)) ) and ( -- precondition 2 : program counter must be in flash pc >= soc.layout.FLASH_BASE and pc <= soc.layout.FLASH_BASE + soc.layout.FLASH_SIZE ), global => ( in_out => tasks_list ); procedure set_default_values (tsk : out t_task); procedure init_softirq_task; procedure init_idle_task; procedure init_apps; function is_real_user (id : ewok.tasks_shared.t_task_id) return boolean; function get_task (id : ewok.tasks_shared.t_task_id) return t_task_access with inline; #if CONFIG_KERNEL_DOMAIN function get_domain (id : in ewok.tasks_shared.t_task_id) return unsigned_8 with inline; #end if; function get_task_id (name : t_task_name) return ewok.tasks_shared.t_task_id; procedure set_state (id : ewok.tasks_shared.t_task_id; mode : t_task_mode; state : t_task_state) with inline; function get_state (id : ewok.tasks_shared.t_task_id; mode : t_task_mode) return t_task_state with inline; function get_mode (id : in ewok.tasks_shared.t_task_id) return t_task_mode with inline, global => null; procedure set_mode (id : in ewok.tasks_shared.t_task_id; mode : in ewok.tasks_shared.t_task_mode) with inline, global => ( in_out => tasks_list ); function is_ipc_waiting (id : in ewok.tasks_shared.t_task_id) return boolean; -- Set return value inside a syscall -- Note: mode must be defined as a task can do a syscall while in ISR mode -- or in THREAD mode procedure set_return_value (id : in ewok.tasks_shared.t_task_id; mode : in t_task_mode; val : in unsigned_32) with inline; procedure task_init with convention => c, export => true, external_name => "task_init", global => null; function is_init_done (id : ewok.tasks_shared.t_task_id) return boolean; procedure append_device (id : in ewok.tasks_shared.t_task_id; dev_id : in ewok.devices_shared.t_device_id; descriptor : out unsigned_8; success : out boolean) with post => (if success = false then descriptor = 0 else descriptor > 0 and descriptor < tasks_list(id).device_id'last ); procedure remove_device (id : in ewok.tasks_shared.t_task_id; dev_id : in ewok.devices_shared.t_device_id; success : out boolean); function is_mounted (id : in ewok.tasks_shared.t_task_id; dev_id : in ewok.devices_shared.t_device_id) return boolean; procedure mount_device (id : in ewok.tasks_shared.t_task_id; dev_id : in ewok.devices_shared.t_device_id; success : out boolean); procedure unmount_device (id : in ewok.tasks_shared.t_task_id; dev_id : in ewok.devices_shared.t_device_id; success : out boolean); end ewok.tasks;
-- -- Standard Ada packages -- with Ada.Text_IO; with Ada.Integer_Text_IO; with Ada.Float_Text_IO; with Ada.Calendar; -- -- Other packages -- with BBS.BBB.i2c; with BBS.BBB.i2c.PCA9685; with BBS.BBB.i2c.BME280; with BBS.units; with WeatherCommon; procedure weather is port : BBS.BBB.i2c.i2c_interface := BBS.BBB.i2c.i2c_new; servo : BBS.BBB.i2c.PCA9685.PS9685_ptr := BBS.BBB.i2c.PCA9685.i2c_new; sensor : BBS.BBB.i2c.BME280.BME280_ptr := BBS.BBB.i2c.BME280.i2c_new; error : integer; debug : constant boolean := false; press : BBS.units.press_p; temp : BBS.units.temp_c; hum : float; state : boolean := false; begin BBS.BBB.i2c.debug := false; if (debug) then Ada.Text_IO.Put_Line("Test and calibration program"); Ada.Text_IO.Put_Line("Configuring the i2c interface"); end if; port.configure("/dev/i2c-1"); servo.configure(port, BBS.BBB.i2c.PCA9685.addr_0, error); sensor.configure(port, BBS.BBB.i2c.BME280.addr, error); for channel in BBS.BBB.i2c.PCA9685.channel loop servo.set_servo_range(channel, WeatherCommon.servo_min, WeatherCommon.servo_max); end loop; loop if (debug) then Ada.Text_IO.Put_Line("Processing loop"); end if; sensor.start_conversion(error); loop exit when sensor.data_ready(error); end loop; sensor.read_data(error); temp := sensor.get_temp; press := sensor.get_press; hum := sensor.get_hum; if (debug) then Ada.Text_IO.Put("Temperature: "); Ada.Float_Text_IO.Put(float(temp), fore => 3, aft => 2, exp => 0); Ada.Text_IO.Put_Line("C"); Ada.Text_IO.Put("Pressure: "); Ada.Float_Text_IO.Put(float(press), fore => 6, aft => 2, exp => 0); Ada.Text_IO.Put_Line("Pa"); Ada.Text_IO.Put("Humidity: "); Ada.Float_Text_IO.Put(float(hum), fore => 3, aft => 2, exp => 0); Ada.Text_IO.Put_Line("%"); end if; WeatherCommon.show_temp(servo, temp); WeatherCommon.show_press(servo, press); WeatherCommon.show_hum(servo, hum); if (state) then servo.set_full_on(WeatherCommon.act_1, error); servo.set_full_off(WeatherCommon.act_2, error); state := false; else servo.set_full_on(WeatherCommon.act_2, error); servo.set_full_off(WeatherCommon.act_1, error); state := true; end if; delay 1.0; end loop; end;
---------------------------------------- -- Copyright (C) 2019 Dmitriy Shadrin -- -- All rights reserved. -- ---------------------------------------- with Pal; use Pal; with Interfaces.C; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; -------------------------------------------------------------------------------- package TimeStamp is procedure SetTimeCorrectValue (val : in Long_Integer) with inline; ----------------------------------------------------------------------------- type timespec is record tv_sec : Interfaces.C.long; tv_nsec : Interfaces.C.long; end record; function "<" (lhd : in Interfaces.C.long; rhd : in Interfaces.C.long) return bool is (Long_Integer (lhd) < Long_Integer (rhd)) with inline; function "=" (lhd : in Interfaces.C.long; rhd : in Interfaces.C.long) return bool is (Long_Integer (lhd) = Long_Integer (rhd)) with inline; function "<" (lhd : in timespec; rhd : in timespec) return bool with inline; ----------------------------------------------------------------------------- type tm is record tm_year : Interfaces.C.int; tm_mon : Interfaces.C.int; tm_day : Interfaces.C.int; tm_hour : Interfaces.C.int; tm_min : Interfaces.C.int; tm_sec : Interfaces.C.int; tm_isdst : Interfaces.C.int; end record; ----------------------------------------------------------------------------- procedure TimestampAdjust (tv : in out timespec; deltaMicrosec : Integer); procedure ConvertTimestamp (tv : in timespec; tmStruct : out tm; us : out Long_Integer; deltaMicrosec : Integer := 0); function GetTimestamp return timespec; function GetTimestampStr (tmStruct : in tm; us : in Long_Integer) return String with inline; function GetTimestampStr (tv : in timespec) return String; function GetTimestampStr return String with inline; function FormatDateTime(fmt : in String; tmStruct : in tm; us : in Long_Integer) return String; private TIME_CORRECT_VALUE : Long_Integer; end TimeStamp;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T 1 D R V -- -- -- -- B o d y -- -- -- -- 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. -- -- -- -- 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 Back_End; use Back_End; with Comperr; with Csets; use Csets; with Debug; use Debug; with Elists; with Errout; use Errout; with Fmap; with Fname; use Fname; with Fname.UF; use Fname.UF; with Frontend; with Gnatvsn; use Gnatvsn; with Hostparm; with Inline; with Lib; use Lib; with Lib.Writ; use Lib.Writ; with Lib.Xref; with Namet; use Namet; with Nlists; with Opt; use Opt; with Osint; use Osint; with Output; use Output; with Prepcomp; with Repinfo; use Repinfo; with Restrict; with Sem; with Sem_Ch8; with Sem_Ch12; with Sem_Ch13; with Sem_Elim; with Sem_Eval; with Sem_Type; with Sinfo; use Sinfo; with Sinput.L; use Sinput.L; with Snames; with Sprint; use Sprint; with Stringt; with Targparm; with Tree_Gen; with Treepr; use Treepr; with Ttypes; with Types; use Types; with Uintp; use Uintp; with Uname; use Uname; with Urealp; with Usage; with System.Assertions; procedure Gnat1drv is Main_Unit_Node : Node_Id; -- Compilation unit node for main unit Main_Kind : Node_Kind; -- Kind of main compilation unit node Back_End_Mode : Back_End.Back_End_Mode_Type; -- Record back end mode begin -- This inner block is set up to catch assertion errors and constraint -- errors. Since the code for handling these errors can cause another -- exception to be raised (namely Unrecoverable_Error), we need two -- nested blocks, so that the outer one handles unrecoverable error. begin -- Lib.Initialize need to be called before Scan_Compiler_Arguments, -- because it initialize a table that is filled by -- Scan_Compiler_Arguments. Osint.Initialize; Fmap.Reset_Tables; Lib.Initialize; Lib.Xref.Initialize; Scan_Compiler_Arguments; Osint.Add_Default_Search_Dirs; Nlists.Initialize; Sinput.Initialize; Sem.Initialize; Csets.Initialize; Uintp.Initialize; Urealp.Initialize; Errout.Initialize; Namet.Initialize; Snames.Initialize; Stringt.Initialize; Inline.Initialize; Sem_Ch8.Initialize; Sem_Ch12.Initialize; Sem_Ch13.Initialize; Sem_Elim.Initialize; Sem_Eval.Initialize; Sem_Type.Init_Interp_Tables; -- Acquire target parameters from system.ads (source of package System) declare use Sinput; S : Source_File_Index; N : Name_Id; begin Name_Buffer (1 .. 10) := "system.ads"; Name_Len := 10; N := Name_Find; S := Load_Source_File (N); if S = No_Source_File then Write_Line ("fatal error, run-time library not installed correctly"); Write_Line ("cannot locate file system.ads"); raise Unrecoverable_Error; -- Remember source index of system.ads (which was read successfully) else System_Source_File_Index := S; end if; Targparm.Get_Target_Parameters (System_Text => Source_Text (S), Source_First => Source_First (S), Source_Last => Source_Last (S)); -- Acquire configuration pragma information from Targparm Restrict.Restrictions := Targparm.Restrictions_On_Target; end; -- Set Configurable_Run_Time mode if system.ads flag set if Targparm.Configurable_Run_Time_On_Target or Debug_Flag_YY then Configurable_Run_Time_Mode := True; end if; -- Set -gnatR3m mode if debug flag A set if Debug_Flag_AA then Back_Annotate_Rep_Info := True; List_Representation_Info := 1; List_Representation_Info_Mechanisms := True; end if; -- Output copyright notice if full list mode if (Verbose_Mode or Full_List) and then (not Debug_Flag_7) then Write_Eol; Write_Str ("GNAT "); Write_Str (Gnat_Version_String); Write_Eol; Write_Str ("Copyright 1992-" & Current_Year & ", Free Software Foundation, Inc."); Write_Eol; end if; -- Before we do anything else, adjust certain global values for -- debug switches which modify their normal natural settings. if Debug_Flag_8 then Ttypes.Bytes_Big_Endian := not Ttypes.Bytes_Big_Endian; end if; if Debug_Flag_M then Targparm.OpenVMS_On_Target := True; Hostparm.OpenVMS := True; end if; if Debug_Flag_FF then Targparm.Frontend_Layout_On_Target := True; end if; -- We take the default exception mechanism into account if Targparm.ZCX_By_Default_On_Target then if Targparm.GCC_ZCX_Support_On_Target then Exception_Mechanism := Back_End_Exceptions; else Osint.Fail ("Zero Cost Exceptions not supported on this target"); end if; end if; -- Set proper status for overflow checks. We turn on overflow checks -- if -gnatp was not specified, and either -gnato is set or the back -- end takes care of overflow checks. Otherwise we suppress overflow -- checks by default (since front end checks are expensive). if not Opt.Suppress_Checks and then (Opt.Enable_Overflow_Checks or else (Targparm.Backend_Divide_Checks_On_Target and Targparm.Backend_Overflow_Checks_On_Target)) then Suppress_Options (Overflow_Check) := False; else Suppress_Options (Overflow_Check) := True; end if; -- Check we have exactly one source file, this happens only in the case -- where the driver is called directly, it cannot happen when gnat1 is -- invoked from gcc in the normal case. if Osint.Number_Of_Files /= 1 then Usage; Write_Eol; Osint.Fail ("you must provide one source file"); elsif Usage_Requested then Usage; end if; Original_Operating_Mode := Operating_Mode; Frontend; Main_Unit_Node := Cunit (Main_Unit); Main_Kind := Nkind (Unit (Main_Unit_Node)); -- Check for suspicious or incorrect body present if we are doing -- semantic checking. We omit this check in syntax only mode, because -- in that case we do not know if we need a body or not. if Operating_Mode /= Check_Syntax and then ((Main_Kind = N_Package_Declaration and then not Body_Required (Main_Unit_Node)) or else (Main_Kind = N_Generic_Package_Declaration and then not Body_Required (Main_Unit_Node)) or else Main_Kind = N_Package_Renaming_Declaration or else Main_Kind = N_Subprogram_Renaming_Declaration or else Nkind (Original_Node (Unit (Main_Unit_Node))) in N_Generic_Instantiation) then Bad_Body : declare Sname : Unit_Name_Type := Unit_Name (Main_Unit); Src_Ind : Source_File_Index; Fname : File_Name_Type; procedure Bad_Body_Error (Msg : String); -- Issue message for bad body found -------------------- -- Bad_Body_Error -- -------------------- procedure Bad_Body_Error (Msg : String) is begin Error_Msg_N (Msg, Main_Unit_Node); Error_Msg_Name_1 := Fname; Error_Msg_N ("remove incorrect body in file{!", Main_Unit_Node); end Bad_Body_Error; -- Start of processing for Bad_Body begin Sname := Unit_Name (Main_Unit); -- If we do not already have a body name, then get the body name -- (but how can we have a body name here ???) if not Is_Body_Name (Sname) then Sname := Get_Body_Name (Sname); end if; Fname := Get_File_Name (Sname, Subunit => False); Src_Ind := Load_Source_File (Fname); -- Case where body is present and it is not a subunit. Exclude -- the subunit case, because it has nothing to do with the -- package we are compiling. It is illegal for a child unit and a -- subunit with the same expanded name (RM 10.2(9)) to appear -- together in a partition, but there is nothing to stop a -- compilation environment from having both, and the test here -- simply allows that. If there is an attempt to include both in -- a partition, this is diagnosed at bind time. In Ada 83 mode -- this is not a warning case. -- Note: if weird file names are being used, we can have -- situation where the file name that supposedly contains body, -- in fact contains a spec, or we can't tell what it contains. -- Skip the error message in these cases. if Src_Ind /= No_Source_File and then Get_Expected_Unit_Type (Fname) = Expect_Body and then not Source_File_Is_Subunit (Src_Ind) then Error_Msg_Name_1 := Sname; -- Ada 83 case of a package body being ignored. This is not an -- error as far as the Ada 83 RM is concerned, but it is -- almost certainly not what is wanted so output a warning. -- Give this message only if there were no errors, since -- otherwise it may be incorrect (we may have misinterpreted a -- junk spec as not needing a body when it really does). if Main_Kind = N_Package_Declaration and then Ada_Version = Ada_83 and then Operating_Mode = Generate_Code and then Distribution_Stub_Mode /= Generate_Caller_Stub_Body and then not Compilation_Errors then Error_Msg_N ("package % does not require a body?", Main_Unit_Node); Error_Msg_Name_1 := Fname; Error_Msg_N ("body in file{? will be ignored", Main_Unit_Node); -- Ada 95 cases of a body file present when no body is -- permitted. This we consider to be an error. else -- For generic instantiations, we never allow a body if Nkind (Original_Node (Unit (Main_Unit_Node))) in N_Generic_Instantiation then Bad_Body_Error ("generic instantiation for % does not allow a body"); -- A library unit that is a renaming never allows a body elsif Main_Kind in N_Renaming_Declaration then Bad_Body_Error ("renaming declaration for % does not allow a body!"); -- Remaining cases are packages and generic packages. Here -- we only do the test if there are no previous errors, -- because if there are errors, they may lead us to -- incorrectly believe that a package does not allow a body -- when in fact it does. elsif not Compilation_Errors then if Main_Kind = N_Package_Declaration then Bad_Body_Error ("package % does not allow a body!"); elsif Main_Kind = N_Generic_Package_Declaration then Bad_Body_Error ("generic package % does not allow a body!"); end if; end if; end if; end if; end Bad_Body; end if; -- Exit if compilation errors detected if Compilation_Errors then Treepr.Tree_Dump; Sem_Ch13.Validate_Unchecked_Conversions; Errout.Finalize; Namet.Finalize; -- Generate ALI file if specially requested if Opt.Force_ALI_Tree_File then Write_ALI (Object => False); Tree_Gen; end if; Exit_Program (E_Errors); end if; -- Set Generate_Code on main unit and its spec. We do this even if are -- not generating code, since Lib-Writ uses this to determine which -- units get written in the ali file. Set_Generate_Code (Main_Unit); -- If we have a corresponding spec, then we need object -- code for the spec unit as well if Nkind (Unit (Main_Unit_Node)) in N_Unit_Body and then not Acts_As_Spec (Main_Unit_Node) then Set_Generate_Code (Get_Cunit_Unit_Number (Library_Unit (Main_Unit_Node))); end if; -- Case of no code required to be generated, exit indicating no error if Original_Operating_Mode = Check_Syntax then Treepr.Tree_Dump; Errout.Finalize; Tree_Gen; Namet.Finalize; -- Use a goto instead of calling Exit_Program so that finalization -- occurs normally. goto End_Of_Program; elsif Original_Operating_Mode = Check_Semantics then Back_End_Mode := Declarations_Only; -- All remaining cases are cases in which the user requested that code -- be generated (i.e. no -gnatc or -gnats switch was used). Check if -- we can in fact satisfy this request. -- Cannot generate code if someone has turned off code generation for -- any reason at all. We will try to figure out a reason below. elsif Operating_Mode /= Generate_Code then Back_End_Mode := Skip; -- We can generate code for a subprogram body unless there were missing -- subunits. Note that we always generate code for all generic units (a -- change from some previous versions of GNAT). elsif Main_Kind = N_Subprogram_Body and then not Subunits_Missing then Back_End_Mode := Generate_Object; -- We can generate code for a package body unless there are subunits -- missing (note that we always generate code for generic units, which -- is a change from some earlier versions of GNAT). elsif Main_Kind = N_Package_Body and then not Subunits_Missing then Back_End_Mode := Generate_Object; -- We can generate code for a package declaration or a subprogram -- declaration only if it does not required a body. elsif (Main_Kind = N_Package_Declaration or else Main_Kind = N_Subprogram_Declaration) and then (not Body_Required (Main_Unit_Node) or else Distribution_Stub_Mode = Generate_Caller_Stub_Body) then Back_End_Mode := Generate_Object; -- We can generate code for a generic package declaration of a generic -- subprogram declaration only if does not require a body. elsif (Main_Kind = N_Generic_Package_Declaration or else Main_Kind = N_Generic_Subprogram_Declaration) and then not Body_Required (Main_Unit_Node) then Back_End_Mode := Generate_Object; -- Compilation units that are renamings do not require bodies, -- so we can generate code for them. elsif Main_Kind = N_Package_Renaming_Declaration or else Main_Kind = N_Subprogram_Renaming_Declaration then Back_End_Mode := Generate_Object; -- Compilation units that are generic renamings do not require bodies -- so we can generate code for them. elsif Main_Kind in N_Generic_Renaming_Declaration then Back_End_Mode := Generate_Object; -- In all other cases (specs which have bodies, generics, and bodies -- where subunits are missing), we cannot generate code and we generate -- a warning message. Note that generic instantiations are gone at this -- stage since they have been replaced by their instances. else Back_End_Mode := Skip; end if; -- At this stage Call_Back_End is set to indicate if the backend should -- be called to generate code. If it is not set, then code generation -- has been turned off, even though code was requested by the original -- command. This is not an error from the user point of view, but it is -- an error from the point of view of the gcc driver, so we must exit -- with an error status. -- We generate an informative message (from the gcc point of view, it -- is an error message, but from the users point of view this is not an -- error, just a consequence of compiling something that cannot -- generate code). if Back_End_Mode = Skip then Write_Str ("cannot generate code for "); Write_Str ("file "); Write_Name (Unit_File_Name (Main_Unit)); if Subunits_Missing then Write_Str (" (missing subunits)"); Write_Eol; Write_Str ("to check parent unit"); elsif Main_Kind = N_Subunit then Write_Str (" (subunit)"); Write_Eol; Write_Str ("to check subunit"); elsif Main_Kind = N_Subprogram_Declaration then Write_Str (" (subprogram spec)"); Write_Eol; Write_Str ("to check subprogram spec"); -- Generic package body in GNAT implementation mode elsif Main_Kind = N_Package_Body and then GNAT_Mode then Write_Str (" (predefined generic)"); Write_Eol; Write_Str ("to check predefined generic"); -- Only other case is a package spec else Write_Str (" (package spec)"); Write_Eol; Write_Str ("to check package spec"); end if; Write_Str (" for errors, use "); if Hostparm.OpenVMS then Write_Str ("/NOLOAD"); else Write_Str ("-gnatc"); end if; Write_Eol; Sem_Ch13.Validate_Unchecked_Conversions; Errout.Finalize; Treepr.Tree_Dump; Tree_Gen; Write_ALI (Object => False); Namet.Finalize; -- Exit program with error indication, to kill object file Exit_Program (E_No_Code); end if; -- In -gnatc mode, we only do annotation if -gnatt or -gnatR is also -- set as indicated by Back_Annotate_Rep_Info being set to True. -- We don't call for annotations on a subunit, because to process those -- the back-end requires that the parent(s) be properly compiled. -- Annotation is suppressed for targets where front-end layout is -- enabled, because the front end determines representations. -- Annotation is also suppressed in the case of compiling for -- the Java VM, since representations are largely symbolic there. if Back_End_Mode = Declarations_Only and then (not Back_Annotate_Rep_Info or else Main_Kind = N_Subunit or else Targparm.Frontend_Layout_On_Target or else Hostparm.Java_VM) then Sem_Ch13.Validate_Unchecked_Conversions; Errout.Finalize; Write_ALI (Object => False); Tree_Dump; Tree_Gen; Namet.Finalize; return; end if; -- Ensure that we properly register a dependency on system.ads, since -- even if we do not semantically depend on this, Targparm has read -- system parameters from the system.ads file. Lib.Writ.Ensure_System_Dependency; -- Add dependencies, if any, on preprocessing data file and on -- preprocessing definition file(s). Prepcomp.Add_Dependencies; -- Back end needs to explicitly unlock tables it needs to touch Atree.Lock; Elists.Lock; Fname.UF.Lock; Inline.Lock; Lib.Lock; Nlists.Lock; Sem.Lock; Sinput.Lock; Namet.Lock; Stringt.Lock; -- Here we call the back end to generate the output code Back_End.Call_Back_End (Back_End_Mode); -- Once the backend is complete, we unlock the names table. This call -- allows a few extra entries, needed for example for the file name for -- the library file output. Namet.Unlock; -- Validate unchecked conversions (using the values for size and -- alignment annotated by the backend where possible). Sem_Ch13.Validate_Unchecked_Conversions; -- Now we complete output of errors, rep info and the tree info. These -- are delayed till now, since it is perfectly possible for gigi to -- generate errors, modify the tree (in particular by setting flags -- indicating that elaboration is required, and also to back annotate -- representation information for List_Rep_Info. Errout.Finalize; List_Rep_Info; -- Only write the library if the backend did not generate any error -- messages. Otherwise signal errors to the driver program so that -- there will be no attempt to generate an object file. if Compilation_Errors then Treepr.Tree_Dump; Exit_Program (E_Errors); end if; Write_ALI (Object => (Back_End_Mode = Generate_Object)); -- Generate the ASIS tree after writing the ALI file, since in ASIS -- mode, Write_ALI may in fact result in further tree decoration from -- the original tree file. Note that we dump the tree just before -- generating it, so that the dump will exactly reflect what is written -- out. Treepr.Tree_Dump; Tree_Gen; -- Finalize name table and we are all done Namet.Finalize; exception -- Handle fatal internal compiler errors when System.Assertions.Assert_Failure => Comperr.Compiler_Abort ("Assert_Failure"); when Constraint_Error => Comperr.Compiler_Abort ("Constraint_Error"); when Program_Error => Comperr.Compiler_Abort ("Program_Error"); when Storage_Error => -- Assume this is a bug. If it is real, the message will in any case -- say Storage_Error, giving a strong hint! Comperr.Compiler_Abort ("Storage_Error"); end; <<End_Of_Program>> null; -- The outer exception handles an unrecoverable error exception when Unrecoverable_Error => Errout.Finalize; Set_Standard_Error; Write_Str ("compilation abandoned"); Write_Eol; Set_Standard_Output; Source_Dump; Tree_Dump; Exit_Program (E_Errors); end Gnat1drv;
------------------------------------------------------------------------------- -- Copyright (c) 2016 Daniel King -- -- 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. ------------------------------------------------------------------------------- with DW1000.Register_Types; use DW1000.Register_Types; with DW1000.Types; use DW1000.Types; -- @summary -- Utility functions for measuring the quality of received frames. package DW1000.Reception_Quality with SPARK_Mode => On is function Adjust_RXPACC (RXPACC : in RX_FINFO_RXPACC_Field; RXPACC_NOSAT : in RXPACC_NOSAT_Field; RXBR : in RX_FINFO_RXBR_Field; SFD_LENGTH : in Bits_8; Non_Standard_SFD : in Boolean) return RX_FINFO_RXPACC_Field with Pre => (RXBR /= Reserved and (if Non_Standard_SFD then SFD_LENGTH in 8 | 16)); -- Apply the correction to the RXPACC value. -- -- The preamble accumulation count (RXPACC) value may include SFD symbols -- in the count. This function removes SFD symbols from the preamble -- symbol count in RXPACC, and returns the adjusted RXPACC value. -- -- Note: This function does not support user-defined SFD sequences. It only -- supports the standard and DecaWave defined SFD sequences. The specific -- SFD sequence used is determined from the RXBR, SFD_LENGTH, and -- Non_Standard_SFD parameters. -- -- @param RXPACC The value of the RXPACC field from the RX_FINFO register. -- This is the value which is to be adjusted. -- -- @param RXPACC_NOSAT The value of the RXPACC_NOSAT register. -- -- @param RXBR The value of the RXBR field from the RX_FINFO register. -- This value determines the data rate of the received frame (110 kbps, -- 850 kbps, or 6.8 Mbps). -- -- @param SFD_LENGTH The value of the SFD_LENGTH field from the USR_SFD -- register. This value must be 8 or 16 symbols and is used only if -- Non_Standard_SFD is True. Otherwise, the value does not matter. -- -- @param Non_Standard_SFD Determines whether or not the standards-defined -- SFD sequence is used, or the DecaWave defined sequence is used. function Receive_Signal_Power (Use_16MHz_PRF : in Boolean; RXPACC : in RX_FINFO_RXPACC_Field; CIR_PWR : in RX_FQUAL_CIR_PWR_Field) return Float with Post => Receive_Signal_Power'Result in -142.81 .. -14.43; -- Compute the estimated receive signal power in dBm. -- -- @param Use_16MHz_PRF Set to True if a 16 MHz PRF is used, otherwise set -- to False to indicate a 64 MHz PRF. -- -- @param RXPACC The value of the RXPACC field from the RX_FINFO register. -- Note that this value should be corrected before calling this function -- if it is equal to the RXPACC_NOSAT register. See the description for -- the RXPACC field in the DW1000 User Manual in Section 7.2.18 for more -- information on correcting the RXPACC. -- -- @param CIR_PWR The value of the CIR_PWR field from the RX_FQUAL register -- -- @return The estimated receive signal power in dBm. The theoretical range -- is -166.90 dBm to -14.43 dBm. function First_Path_Signal_Power (Use_16MHz_PRF : in Boolean; F1 : in RX_TIME_FP_AMPL1_Field; F2 : in RX_FQUAL_FP_AMPL2_Field; F3 : in RX_FQUAL_FP_AMPL3_Field; RXPACC : in RX_FINFO_RXPACC_Field) return Float with Post => First_Path_Signal_Power'Result in -193.99 .. -17.44; -- Compute the estimated first path power level in dBm. -- -- @param Use_16MHz_PRF Set to True if a 16 MHz PRF is used, otherwise set -- to False to indicate a 64 MHz PRF. -- -- @param F1 The value of the FP_AMPL1 field from the RX_TIME register. -- -- @param F2 The value of the FP_AMPL2 field from the RX_FQUAL register. -- -- @param F3 The value of the FP_AMPL3 field from the RX_FQUAL register. -- -- @param RXPACC The value of the RXPACC field from the RX_FINFO register. -- Note that this value should be corrected before calling this function -- if it is equal to the RXPACC_NOSAT register. See the description for -- the RXPACC field in the DW1000 User Manual in Section 7.2.18 for more -- information on correcting the RXPACC. -- -- @return The estimated first path power in dBm. The theoretical range -- is -218.07 dBm to -12.67 dBm. function Transmitter_Clock_Offset (RXTOFS : in RX_TTCKO_RXTOFS_Field; RXTTCKI : in RX_TTCKI_RXTTCKI_Field) return Long_Float with Post => Transmitter_Clock_Offset'Result in -1.0 .. 1.0; -- Calculate the clock offset between the receiver's and transmitter's -- clocks. -- -- Since the transmitter and receiver radios are clocked by their own -- crystals, there can be a slight variation between the crystals' -- frequencies. This function provides a measure of the offset -- between this receiver and the remote transmitter clocks. -- -- @param RXTOFS The value of the RXTOFS field from the RX_TTCKO register. -- -- @param RXTTCKI The value of the RXTTCKI field from the RX_TTCKI -- register. -- -- @return The computed clock offset. A positive value indicates that the -- transmitter's clock is running faster than the receiver's clock, and -- a negative value indicates that the transmitter's clock is running -- slower than the receiver's clock. For example, a value of 7.014E-06 -- indicates that the transmitter is faster by 7 ppm. Likewise, a value -- of -5.045E-06 indicates that the transmitter's clock is slower by -- 5 ppm. end DW1000.Reception_Quality;
package body Ada.Streams.Naked_Stream_IO.Standard_Files is begin System.Native_IO.Initialize ( Standard_Input_Stream.Handle, Standard_Output_Stream.Handle, Standard_Error_Stream.Handle); end Ada.Streams.Naked_Stream_IO.Standard_Files;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- -- -- This specification is derived from the Ada Semantic Interface -- -- Specification Standard (ISO/IEC 15291) and ASIS 1999 Issues. -- -- -- -- The copyright notice and the license provisions that follow apply to the -- -- part following the private keyword. -- -- -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 19 package Asis.Clauses ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package Asis.Clauses is pragma Preelaborate; ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Asis.Clauses -- -- This package encapsulates a set of queries that operate on A_Clause -- elements. -- -- |ER----------------------------------------------------------------------- -- |ER A_Use_Package_Clause - 8.4 -- |ER A_Use_Type_Clause - 8.4 -- |ER A_With_Clause - 10.1.2 -- |CR -- |CR Child elements returned by: -- |CR function Clause_Names -- |CR ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 19.1 function Clause_Names ------------------------------------------------------------------------------ function Clause_Names (Clause : in Asis.Element) return Asis.Name_List; ------------------------------------------------------------------------------ -- Clause - Specifies the with_clause or use_clause to query -- -- Returns a list of the names that appear in the given clause. -- The names in the list should be in their order of appearance in the -- original clauses from the compilation text. -- -- Results of this query may vary across ASIS implementations. Some -- implementations normalize all clauses containing multiple names -- into an equivalent sequence of corresponding single clauses. -- Similarly, an implementation may keep a name only once even though that -- name can appear more than once in a clause. -- -- Appropriate Element_Kinds: -- A_Use_Package_Clause -- A_Use_Type_Clause -- A_With_Clause -- -- Returns Expression_Kinds: -- An_Identifier -- A_Selected_Component -- An_Attribute_Reference -- -- |ER----------------------------------------------------------------------- -- |ER A_Representation_Clause - 13.1 -- |ER----------------------------------------------------------------------- -- |ER An_Attribute_Definition_Clause - 13.3 -- |ER An_Enumeration_Representation_Clause - 13.4 -- |ER An_At_Clause - J.7 -- |CR -- |CR Child elements returned by: -- |CR function Representation_Clause_Name -- |CR function Representation_Clause_Expression -- ------------------------------------------------------------------------------ -- 19.2 function Representation_Clause_Name ------------------------------------------------------------------------------ function Representation_Clause_Name (Clause : in Asis.Clause) return Asis.Name; ------------------------------------------------------------------------------ -- Clause - Specifies the representation_clause to query -- -- Returns the direct_name expression following the reserved word "for". -- -- Appropriate Clause_Kinds: -- A_Representation_Clause -- A_Component_Clause -- -- Returns Expression_Kinds: -- An_Identifier -- An_Attribute_Reference -- ------------------------------------------------------------------------------ -- 19.3 function Representation_Clause_Expression ------------------------------------------------------------------------------ function Representation_Clause_Expression (Clause : in Asis.Representation_Clause) return Asis.Expression; ------------------------------------------------------------------------------ -- Clause - Specifies the representation_clause to query -- -- Returns the expression following the reserved word "use" or the reserved -- words "use at". -- -- Appropriate Representation_Clause_Kinds: -- An_Attribute_Definition_Clause -- An_Enumeration_Representation_Clause -- An_At_Clause -- -- Returns Element_Kinds: -- An_Expression -- -- |ER----------------------------------------------------------------------- -- |ER A_Record_Representation_Clause - 13.5.1 -- |CR -- |CR Child elements returned by: -- |CR function Representation_Clause_Name -- |CR function Mod_Clause_Expression -- |CR function Component_Clauses -- ------------------------------------------------------------------------------ -- 19.4 function Mod_Clause_Expression ------------------------------------------------------------------------------ function Mod_Clause_Expression (Clause : in Asis.Representation_Clause) return Asis.Expression; ------------------------------------------------------------------------------ -- Clause - Specifies the record representation clause to query -- -- Returns the static_expression appearing after the reserved words "at mod". -- -- Returns a Nil_Element if a mod_clause is not present. -- -- Appropriate Representation_Clause_Kinds: -- A_Record_Representation_Clause -- -- Returns Element_Kinds: -- Not_An_Element -- An_Expression -- ------------------------------------------------------------------------------ -- 19.5 function Component_Clauses ------------------------------------------------------------------------------ function Component_Clauses (Clause : in Asis.Representation_Clause; Include_Pragmas : in Boolean := False) return Asis.Component_Clause_List; ------------------------------------------------------------------------------ -- Clause - Specifies the record representation clause to query -- Include_Pragmas - Specifies whether pragmas are to be returned -- -- Returns the component_clause and pragma elements from the -- record_representation_clause, in their order of appearance. -- -- Returns a Nil_Element_List if the record_representation_clause has no -- component_clause or pragma elements. -- -- Appropriate Representation_Clause_Kinds: -- A_Record_Representation_Clause -- -- Returns Element_Kinds: -- A_Clause -- A_Pragma -- -- Returns Clause_Kinds: -- A_Component_Clause -- -- |ER----------------------------------------------------------------------- -- |ER A_Component_Clause - 13.5.1 -- |CR -- |CR Child elements returned by: -- |CR function Representation_Clause_Name -- |CR function Component_Clause_Position -- |CR function Component_Clause_Range -- ------------------------------------------------------------------------------ -- 19.6 function Component_Clause_Position ------------------------------------------------------------------------------ function Component_Clause_Position (Clause : in Asis.Component_Clause) return Asis.Expression; ------------------------------------------------------------------------------ -- Clause - Specifies the component_clause to query -- -- Returns the position expression for the component_clause. -- -- Appropriate Clause_Kinds: -- A_Component_Clause -- -- Returns Element_Kinds: -- An_Expression -- ------------------------------------------------------------------------------ -- 19.7 function Component_Clause_Range ------------------------------------------------------------------------------ function Component_Clause_Range (Clause : in Asis.Component_Clause) return Asis.Discrete_Range; ------------------------------------------------------------------------------ -- Clause - Specifies the component_clause to query -- -- Returns the first_bit .. last_bit range for the component_clause. -- -- Appropriate Clause_Kinds: -- A_Component_Clause -- -- Returns Discrete_Range_Kinds: -- A_Discrete_Simple_Expression_Range -- ------------------------------------------------------------------------------ end Asis.Clauses; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- 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 Maxim Reznik, 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 OWNER 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. ------------------------------------------------------------------------------
-- { dg-do compile } with ext1; use ext1; procedure test_ext1 is X : Regular_Smiley; begin X.Set_Mood; end;
with gel.World.server; package gel_demo_Server -- -- Provides the server. -- is the_server_World : gel.World.server.view; task Item is entry start; entry stop; end Item; end gel_demo_Server;
-- CD2A21C.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. --* -- OBJECTIVE: -- CHECK THAT A SIZE SPECIFICATION CAN BE GIVEN FOR AN ENUMERATION -- TYPE: -- IN THE VISIBLE OR PRIVATE PART OF A PACKAGE FOR A TYPE -- DECLARED IN THE VISIBLE PART; -- FOR A DERIVED ENUMERATION TYPE; -- FOR A DERIVED PRIVATE TYPE WHOSE FULL DECLARATION IS AS -- AN ENUMERATION TYPE. -- HISTORY: -- PWB 06/17/87 CREATED ORIGINAL TEST. -- DHH 04/17/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA', CHANGED -- OPERATORS ON 'SIZE TESTS, AND ADDED CHECK ON -- REPRESENTATION CLAUSE. -- JRL 03/26/92 REMOVED TESTING OF NONOBJECTIVE TYPES. WITH REPORT; USE REPORT; WITH LENGTH_CHECK; -- CONTAINS A CALL TO 'FAILED'. PROCEDURE CD2A21C IS TYPE BASIC_ENUM IS (A, B, C, D, E); SPECIFIED_SIZE : CONSTANT := BASIC_ENUM'SIZE; MINIMUM_SIZE : INTEGER := IDENT_INT(SPECIFIED_SIZE); TYPE DERIVED_ENUM IS NEW BASIC_ENUM; FOR DERIVED_ENUM'SIZE USE SPECIFIED_SIZE; PACKAGE P IS TYPE ENUM_IN_P IS (A1, B1, C1, D1, E1, F1, G1); FOR ENUM_IN_P'SIZE USE SPECIFIED_SIZE; TYPE PRIVATE_ENUM IS PRIVATE; TYPE ALT_ENUM_IN_P IS (A2, B2, C2, D2, E2, F2, G2); PRIVATE TYPE PRIVATE_ENUM IS (A3, B3, C3, D3, E3, F3, G3); FOR ALT_ENUM_IN_P'SIZE USE SPECIFIED_SIZE; END P; TYPE DERIVED_PRIVATE_ENUM IS NEW P.PRIVATE_ENUM; FOR DERIVED_PRIVATE_ENUM'SIZE USE SPECIFIED_SIZE; USE P; PROCEDURE CHECK_1 IS NEW LENGTH_CHECK (DERIVED_ENUM); PROCEDURE CHECK_2 IS NEW LENGTH_CHECK (ENUM_IN_P); PROCEDURE CHECK_3 IS NEW LENGTH_CHECK (ALT_ENUM_IN_P); BEGIN TEST("CD2A21C", "CHECK THAT 'SIZE SPECIFICATIONS CAN BE GIVEN " & "IN THE VISIBLE OR PRIVATE PART OF A PACKAGE " & "FOR ENUMERATION TYPES DECLARED IN THE VISIBLE " & "PART, AND FOR DERIVED ENUMERATION " & "TYPES AND DERIVED PRIVATE TYPES WHOSE FULL " & "DECLARATIONS ARE AS ENUMERATION TYPES"); CHECK_1 (C, SPECIFIED_SIZE, "DERIVED_ENUM"); CHECK_2 (C1, SPECIFIED_SIZE, "ENUM_IN_P"); CHECK_3 (C2, SPECIFIED_SIZE, "ALT_ENUM_IN_P"); IF DERIVED_ENUM'SIZE /= MINIMUM_SIZE THEN FAILED ("DERIVED_ENUM'SIZE SHOULD NOT BE GREATER THAN" & INTEGER'IMAGE(MINIMUM_SIZE) & ". ACTUAL SIZE IS" & INTEGER'IMAGE(DERIVED_ENUM'SIZE)); END IF; IF ENUM_IN_P'SIZE /= MINIMUM_SIZE THEN FAILED ("ENUM_IN_P'SIZE SHOULD NOT BE GREATER THAN" & INTEGER'IMAGE(MINIMUM_SIZE) & ". ACTUAL SIZE IS" & INTEGER'IMAGE(ENUM_IN_P'SIZE)); END IF; IF ALT_ENUM_IN_P'SIZE /= MINIMUM_SIZE THEN FAILED ("ALT_ENUM_IN_P'SIZE SHOULD NOT BE GREATER THAN" & INTEGER'IMAGE(MINIMUM_SIZE) & ". ACTUAL SIZE IS" & INTEGER'IMAGE(ALT_ENUM_IN_P'SIZE)); END IF; IF DERIVED_PRIVATE_ENUM'SIZE /= MINIMUM_SIZE THEN FAILED ("DERIVED_PRIVATE_ENUM'SIZE SHOULD NOT BE GREATER " & "THAN " & INTEGER'IMAGE(MINIMUM_SIZE) & ". ACTUAL SIZE IS" & INTEGER'IMAGE(DERIVED_PRIVATE_ENUM'SIZE)); END IF; RESULT; END CD2A21C;
with Ada.Text_IO; with GNAT.Source_Info; with GNAT.Current_Exception; with Ada.Text_IO; with Ada.Unchecked_Conversion; with GNAT.OS_Lib; package body Emulator_8080.Processor is procedure Print_Exception(Throwing_Function, Exception_Cause : in String) is begin Ada.Text_IO.Put(Throwing_Function & " threw exception -> "); Ada.Text_IO.Put_Line(Exception_Cause); end Print_Exception; function Initialize(Rom : in Byte_Array_Type) return Processor_Type is Processor : Processor_Type; begin for I in Rom'Range loop Processor.Memory(Address_Type(I)) := Rom(I); end loop; return Processor; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); return Processor; end Initialize; procedure Set_Zero_Flag_If_Applicable(Value : in Interfaces.Unsigned_16; Processor : in out Processor_Type) is use Interfaces; begin if (Value and 16#ff#) = 0 then Processor.Zero_Flag := Set; else Processor.Zero_Flag := Not_Set; end if; end Set_Zero_Flag_If_Applicable; procedure Set_Sign_Flag_If_Applicable(Value : in Interfaces.Unsigned_16; Processor : in out Processor_Type) is use Interfaces; begin if (Value and 16#80#) = 16#80# then Processor.Sign_Flag := Set; else Processor.Sign_Flag := Not_Set; end if; end Set_Sign_Flag_If_Applicable; procedure Set_Carry_Flag_If_Applicable(Value : in Interfaces.Unsigned_16; Processor : in out Processor_Type) is use Interfaces; begin if Value > 16#ff# then Processor.Carry_Flag := Set; else Processor.Carry_Flag := Not_Set; end if; end Set_Carry_Flag_If_Applicable; procedure Add(Summand : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_16 := Unsigned_16(Processor.A) + Unsigned_16(Summand); begin Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end Add; procedure Add_With_Carry(Summand : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : Unsigned_16 := Unsigned_16(Processor.A) + Unsigned_16(Summand); Carry_Summand : Unsigned_16 := 0; begin if(Processor.Carry_Flag = Set) then Carry_Summand := 1; end if; Result := Result + Carry_Summand; Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end Add_With_Carry; procedure Sub(Subtrahend : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_16 := Unsigned_16(Processor.A) - Unsigned_16(Subtrahend); begin Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end Sub; procedure Sub(Subtrahend : in Byte_Type; Register : in out Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_16 := Unsigned_16(Register) - Unsigned_16(Subtrahend); begin Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Register := Register_Type(Result and 16#ff#); end Sub; procedure Sub_With_Carry(Subtrahend : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : Unsigned_16 := Unsigned_16(Processor.A) - Unsigned_16(Subtrahend); Carry_Subtrahend : Unsigned_16 := 0; begin if(Processor.Carry_Flag = Set) then Carry_Subtrahend := 1; end if; Result := Result - Carry_Subtrahend; Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end Sub_With_Carry; procedure And_A(Value : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_16 := Unsigned_16(Processor.A) and Unsigned_16(Value); begin Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end And_A; procedure Xor_A(Value : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_16 := Unsigned_16(Processor.A) xor Unsigned_16(Value); begin Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end Xor_A; procedure Or_A(Value : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_16 := Unsigned_16(Processor.A) or Unsigned_16(Value); begin Set_Zero_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Sign_Flag_If_Applicable(Value => Result, Processor => Processor); Set_Carry_Flag_If_Applicable(Value => Result, Processor => Processor); Processor.A := Register_Type(Result and 16#ff#); end Or_A; procedure Compare_A(Value : in Register_Type; Processor : in out Processor_Type) is use Interfaces; Result : constant Unsigned_8 := Unsigned_8(Processor.A) - Unsigned_8(Value); begin if Result = 0 then Processor.Zero_Flag := Set; end if; if (16#80# = (Result and 16#80#)) then Processor.Sign_Flag := Set; end if; --TODO PARITY CHECK if Processor.A < Value then Processor.Carry_Flag := Set; end if; end Compare_A; procedure Inx(V1, V2 : in out Register_Type) is begin V1 := V1 + 1; V2 := V2 + 1; end Inx; procedure NOP(Processor : in out Processor_Type) is begin Processor.Program_Counter := Processor.Program_Counter + 1; end NOP; procedure LXI_BxD16(Byte_2, Byte_3 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.B := Byte_3; Processor.C := Byte_2; Processor.Program_Counter:= Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LXI_BxD16; procedure STAX_B(Processor : in out Processor_Type) is C : constant Byte_Pair_Type := (High_Order_Byte => Processor.C, Low_Order_Byte => Processor.B); BC : constant Address_Type := Convert_To_Address(C); begin Processor.Memory(BC) := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end Stax_B; procedure INX_B(Processor : in out Processor_Type) is begin Inx(V1 => Processor.B, V2 => Processor.C); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INX_B; procedure INR_B(Processor : in out Processor_Type) is begin Processor.B := Processor.B + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_B; procedure DCR_B(Processor : in out Processor_Type) is Result : Register_Type := Processor.B; begin Sub(Subtrahend => 1, Register => Result, Processor => Processor); Processor.B := Result; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_B; procedure MVI_BxD8(Byte_2 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.B := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_BxD8; procedure RLC(Processor : in out Processor_Type) is use Interfaces; Tmp : constant Unsigned_8 := Unsigned_8(Processor.A); Prev_Bit_7 : constant Unsigned_8 := Shift_Right(Tmp, 7); Result : constant Unsigned_8 := Shift_Left(Tmp, 1) or Prev_Bit_7; begin --TODO SET CARRY? Processor.A := Register_Type(Tmp); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RLC; procedure DAD_B(Processor : in out Processor_Type) is use Interfaces; HL : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); BC : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.B, Low_Order_Byte => Processor.C)); Result : constant Concatenated_Register_Type := HL + BC; Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(Result); begin Processor.H := Converted_Result.High_Order_Byte; Processor.L := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DAD_B; procedure LDAX_B(Processor : in out Processor_Type) is Adress_Byte_Pair : constant Byte_Pair_Type := (High_Order_Byte => Processor.B, Low_Order_Byte => Processor.C); Adress : constant Address_Type := Convert_To_Address(Adress_Byte_Pair); Value : constant Byte_Type := Processor.Memory(Adress); --Adress : constant Address_Type := Convert begin Processor.A := Value; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LDAX_B; procedure DCX_B(Processor : in out Processor_Type) is use Interfaces; BC : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.B, Low_Order_Byte => Processor.C)); Result : constant Concatenated_Register_Type := BC - 1; Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(Result); begin Processor.B := Converted_Result.High_Order_Byte; Processor.C := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCX_B; procedure INR_C(Processor : in out Processor_Type) is begin Processor.C := Processor.C + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_C; procedure DCR_C(Processor : in out Processor_Type) is begin Processor.C := Processor.C - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_C; procedure MVI_CxD8(Byte_2 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.C := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_CxD8; procedure RRC(Processor : in out Processor_Type) is use Interfaces; Tmp : constant Unsigned_8 := Unsigned_8(Processor.A); Prev_Bit_0 : constant Unsigned_8 := Shift_Right(Shift_Left(Tmp, 7), 7); Result : constant Unsigned_8 := Shift_Left(Tmp, 1) or Prev_Bit_0; begin --TODO SET CARRY? Processor.A := Register_Type(Tmp); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RRC; procedure LXI_DxD16(Byte_2, Byte_3 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.D := Byte_3; Processor.E := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LXI_DxD16; procedure STAX_D(Processor : in out Processor_Type) is C : constant Byte_Pair_Type := (High_Order_Byte => Processor.D, Low_Order_Byte => Processor.E); DE : constant Address_Type := Convert_To_Address(C); begin Processor.Memory(DE) := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end Stax_D; procedure INX_D(Processor : in out Processor_Type) is begin Inx(V1 => Processor.D, V2 => Processor.E); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INX_D; procedure INR_D(Processor : in out Processor_Type) is begin Processor.D := Processor.D + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_D; procedure DCR_D(Processor : in out Processor_Type) is begin Processor.D := Processor.D - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_D; procedure MVI_DxD8(Byte_2 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.D := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_DxD8; procedure RAL(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("Procedure RAL not yet implemented"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RAL; procedure DAD_D(Processor : in out Processor_Type) is use Interfaces; HL : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); DE : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.D, Low_Order_Byte => Processor.E)); Result : constant Concatenated_Register_Type := HL + DE; Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(Result); begin Processor.H := Converted_Result.High_Order_Byte; Processor.L := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DAD_D; procedure LDAX_D(Processor : in out Processor_Type) is Adress_Byte_Pair : constant Byte_Pair_Type := (High_Order_Byte => Processor.D, Low_Order_Byte => Processor.E); Adress : constant Address_Type := Convert_To_Address(Adress_Byte_Pair); Value : constant Byte_Type := Processor.Memory(Adress); --Adress : constant Address_Type := Convert begin Processor.A := Value; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LDAX_D; procedure DCX_D(Processor : in out Processor_Type) is use Interfaces; DE : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.D, Low_Order_Byte => Processor.E)); Result : constant Concatenated_Register_Type := DE - 1; Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(Result); begin Processor.D := Converted_Result.High_Order_Byte; Processor.E := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCX_D; procedure INR_E(Processor : in out Processor_Type) is begin Processor.E := Processor.E + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_E; procedure DCR_E(Processor : in out Processor_Type) is begin Processor.E := Processor.E - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_E; procedure MVI_ExD8(Byte_2 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.E := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_ExD8; procedure RAR(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("Procedure RAR not yet implemented"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RAR; procedure LXI_HxD16(Byte_2, Byte_3 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.H := Byte_3; Processor.L := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LXI_HxD16; procedure SHLD_Adr(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("Procedure SHLD_Adr not yet implemented"); Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SHLD_Adr; procedure INX_H(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line(Processor.H'Img); Ada.Text_IO.Put_Line(Processor.L'Img); Inx(V1 => Processor.H, V2 => Processor.L); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INX_H; procedure INR_H(Processor : in out Processor_Type) is begin Processor.H := Processor.H + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_H; procedure DCR_H(Processor : in out Processor_Type) is begin Processor.H := Processor.H - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_H; procedure MVI_HxD8(Byte_2 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.H := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_HxD8; procedure DAA(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("Special function DAA"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DAA; procedure DAD_H(Processor : in out Processor_Type) is use Interfaces; HL : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); Result : constant Concatenated_Register_Type := HL + HL; Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(HL); begin Processor.H := Converted_Result.High_Order_Byte; Processor.L := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DAD_H; procedure LHLD(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Byte_2, Low_Order_Byte => Byte_3)); L_Value : constant Byte_Type := Processor.Memory(Address); H_Value : constant Byte_Type := Processor.Memory(Address + 1); begin Processor.L := L_Value; Processor.H := H_Value; Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LHLD; procedure DCX_H(Processor : in out Processor_Type) is use Interfaces; HL : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); Result : constant Concatenated_Register_Type := HL - 1; Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(Result); begin Processor.H := Converted_Result.High_Order_Byte; Processor.L := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCX_H; procedure INR_L(Processor : in out Processor_Type) is begin Processor.L := Processor.L + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_L; procedure DCR_L(Processor : in out Processor_Type) is begin Processor.L := Processor.L - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_L; procedure MVI_LxD8(Byte_2 : in Emulator_8080.Byte_Type; Processor : in out Processor_Type) is begin Processor.L := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_LxD8; procedure CMA(Processor : in out Processor_Type) is use Interfaces; A : constant Interfaces.Unsigned_8 := Interfaces.Unsigned_8(Processor.A); begin Processor.A := Byte_Type(A xor A); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMA; procedure LXI_SPxD16(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin Processor.Stack_Pointer := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Byte_3, Low_Order_Byte => Byte_2)); Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LXI_SPxD16; procedure STA(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Byte_3, Low_Order_Byte => Byte_2)); begin Processor.Memory(Address) := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end STA; procedure INX_SP(Processor : in out Processor_Type) is use Interfaces; begin Processor.Stack_Pointer := Processor.Stack_Pointer + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INX_SP; procedure INR_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.Memory(Address) + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_M; procedure DCR_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.Memory(Address) - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_M; procedure MVI_MxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_MxD8; procedure STC(Processor : in out Processor_Type) is begin Processor.Carry_Flag := Set; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end STC; procedure DAD_SP(Processor : in out Processor_Type) is use Interfaces; HL : constant Concatenated_Register_Type := Convert_To_Concatenated_Register(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); Result : constant Concatenated_Register_Type := HL + Unsigned_16(Processor.Stack_Pointer); Converted_Result : constant Byte_Pair_Type := Convert_To_Byte_Pair(Result); begin Processor.H := Converted_Result.High_Order_Byte; Processor.L := Converted_Result.Low_Order_Byte; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DAD_SP; procedure LDA(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Byte_3, Low_Order_Byte => Byte_2)); begin Processor.A := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end LDA; procedure DCX_SP(Processor : in out Processor_Type) is begin Processor.Stack_Pointer := Processor.Stack_Pointer - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCX_SP; procedure INR_A(Processor : in out Processor_Type) is begin Processor.A := Processor.A + 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end INR_A; procedure DCR_A(Processor : in out Processor_Type) is begin Processor.A := Processor.A - 1; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DCR_A; procedure MVI_AxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Processor.A := Byte_2; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MVI_AxD8; procedure CMC(Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Set then Processor.Carry_Flag := Not_Set; else Processor.Carry_Flag := Set; end if; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMC; procedure MOV_BxB(Processor : in out Processor_Type) is begin Processor.B := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxB; procedure MOV_BxC(Processor : in out Processor_Type) is begin Processor.B := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxC; procedure MOV_BxD(Processor : in out Processor_Type) is begin Processor.B := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxD; procedure MOV_BxE(Processor : in out Processor_Type) is begin Processor.B := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxE; procedure MOV_BxH(Processor : in out Processor_Type) is begin Processor.B := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxH; procedure MOV_BxL(Processor : in out Processor_Type) is begin Processor.B := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxL; procedure MOV_BxM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.B := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxM; procedure MOV_BxA(Processor : in out Processor_Type) is begin Processor.B := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_BxA; procedure MOV_CxB(Processor : in out Processor_Type) is begin Processor.C := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxB; procedure MOV_CxC(Processor : in out Processor_Type) is begin Processor.C := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxC; procedure MOV_CxD(Processor : in out Processor_Type) is begin Processor.C := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxD; procedure MOV_CxE(Processor : in out Processor_Type) is begin Processor.C := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxE; procedure MOV_CxH(Processor : in out Processor_Type) is begin Processor.C := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxH; procedure MOV_CxL(Processor : in out Processor_Type) is begin Processor.C := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxL; procedure MOV_CxM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.C := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxM; procedure MOV_CxA(Processor : in out Processor_Type) is begin Processor.C := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_CxA; procedure MOV_DxB(Processor : in out Processor_Type) is begin Processor.D := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxB; procedure MOV_DxC(Processor : in out Processor_Type) is begin Processor.D := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxC; procedure MOV_DxD(Processor : in out Processor_Type) is begin Processor.D := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxD; procedure MOV_DxE(Processor : in out Processor_Type) is begin Processor.D := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxE; procedure MOV_DxH(Processor : in out Processor_Type) is begin Processor.D := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxH; procedure MOV_DxL(Processor : in out Processor_Type) is begin Processor.D := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxL; procedure MOV_DxM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.D := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxM; procedure MOV_DxA(Processor : in out Processor_Type) is begin Processor.D := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_DxA; procedure MOV_ExB(Processor : in out Processor_Type) is begin Processor.E := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExB; procedure MOV_ExC(Processor : in out Processor_Type) is begin Processor.E := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExC; procedure MOV_ExD(Processor : in out Processor_Type) is begin Processor.E := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExD; procedure MOV_ExE(Processor : in out Processor_Type) is begin Processor.E := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExE; procedure MOV_ExH(Processor : in out Processor_Type) is begin Processor.E := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExH; procedure MOV_ExL(Processor : in out Processor_Type) is begin Processor.E := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExL; procedure MOV_ExM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.E := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExM; procedure MOV_ExA(Processor : in out Processor_Type) is begin Processor.E := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_ExA; procedure MOV_HxB(Processor : in out Processor_Type) is begin Processor.H := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxB; procedure MOV_HxC(Processor : in out Processor_Type) is begin Processor.H := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxC; procedure MOV_HxD(Processor : in out Processor_Type) is begin Processor.H := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxD; procedure MOV_HxE(Processor : in out Processor_Type) is begin Processor.H := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxE; procedure MOV_HxH(Processor : in out Processor_Type) is begin Processor.H := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxH; procedure MOV_HxL(Processor : in out Processor_Type) is begin Processor.H := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxL; procedure MOV_HxM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.H := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxM; procedure MOV_HxA(Processor : in out Processor_Type) is begin Processor.H := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_HxA; procedure MOV_LxB(Processor : in out Processor_Type) is begin Processor.L := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxB; procedure MOV_LxC(Processor : in out Processor_Type) is begin Processor.L := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxC; procedure MOV_LxD(Processor : in out Processor_Type) is begin Processor.L := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxD; procedure MOV_LxE(Processor : in out Processor_Type) is begin Processor.L := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxE; procedure MOV_LxH(Processor : in out Processor_Type) is begin Processor.L := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxH; procedure MOV_LxL(Processor : in out Processor_Type) is begin Processor.L := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxL; procedure MOV_LxM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.L := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxM; procedure MOV_LxA(Processor : in out Processor_Type) is begin Processor.L := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_LxA; procedure MOV_MxB(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxB; procedure MOV_MxC(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxC; procedure MOV_MxD(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxD; procedure MOV_MxE(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxE; procedure MOV_MxH(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxH; procedure MOV_MxL(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxL; procedure HLT(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("Special function HLT"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end HLT; procedure MOV_MxA(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.Memory(Address) := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_MxA; procedure MOV_AxB(Processor : in out Processor_Type) is begin Processor.A := Processor.B; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxB; procedure MOV_AxC(Processor : in out Processor_Type) is begin Processor.A := Processor.C; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxC; procedure MOV_AxD(Processor : in out Processor_Type) is begin Processor.A := Processor.D; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxD; procedure MOV_AxE(Processor : in out Processor_Type) is begin Processor.A := Processor.E; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxE; procedure MOV_AxH(Processor : in out Processor_Type) is begin Processor.A := Processor.H; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxH; procedure MOV_AxL(Processor : in out Processor_Type) is begin Processor.A := Processor.L; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxL; procedure MOV_AxM(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Processor.A := Processor.Memory(Address); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxM; procedure MOV_AxA(Processor : in out Processor_Type) is begin Processor.A := Processor.A; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end MOV_AxA; procedure ADD_B(Processor : in out Processor_Type) is begin Add(Summand => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_B; procedure ADD_C(Processor : in out Processor_Type) is begin Add(Summand => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_C; procedure ADD_D(Processor : in out Processor_Type) is begin Add(Summand => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_D; procedure ADD_E(Processor : in out Processor_Type) is begin Add(Summand => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_E; procedure ADD_H(Processor : in out Processor_Type) is begin Add(Summand => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_H; procedure ADD_L(Processor : in out Processor_Type) is begin Add(Summand => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_L; procedure ADD_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Add(Summand => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_M; procedure ADD_A(Processor : in out Processor_Type) is begin Add(Summand => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADD_A; procedure ADC_B(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_B; procedure ADC_C(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_C; procedure ADC_D(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_D; procedure ADC_E(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_E; procedure ADC_H(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_H; procedure ADC_L(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_L; procedure ADC_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Add_With_Carry(Summand => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_M; procedure ADC_A(Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADC_A; procedure SUB_B(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_B; procedure SUB_C(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_C; procedure SUB_D(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_D; procedure SUB_E(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_E; procedure SUB_H(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_H; procedure SUB_L(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_L; procedure SUB_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Sub(Subtrahend => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_M; procedure SUB_A(Processor : in out Processor_Type) is begin Sub(Subtrahend => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUB_A; procedure SBB_B(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_B; procedure SBB_C(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_C; procedure SBB_D(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_D; procedure SBB_E(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_E; procedure SBB_H(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_H; procedure SBB_L(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_L; procedure SBB_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Sub_With_Carry(Subtrahend => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_M; procedure SBB_A(Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBB_A; procedure ANA_B(Processor : in out Processor_Type) is begin And_A(Value => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_B; procedure ANA_C(Processor : in out Processor_Type) is begin And_A(Value => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_C; procedure ANA_D(Processor : in out Processor_Type) is begin And_A(Value => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_D; procedure ANA_E(Processor : in out Processor_Type) is begin And_A(Value => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_E; procedure ANA_H(Processor : in out Processor_Type) is begin And_A(Value => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_H; procedure ANA_L(Processor : in out Processor_Type) is begin And_A(Value => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_L; procedure ANA_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin And_A(Value => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_M; procedure ANA_A(Processor : in out Processor_Type) is begin And_A(Value => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANA_A; procedure XRA_B(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_B; procedure XRA_C(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_C; procedure XRA_D(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_D; procedure XRA_E(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_E; procedure XRA_H(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_H; procedure XRA_L(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_L; procedure XRA_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Xor_A(Value => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_M; procedure XRA_A(Processor : in out Processor_Type) is begin Xor_A(Value => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRA_A; procedure ORA_B(Processor : in out Processor_Type) is begin Or_A(Value => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_B; procedure ORA_C(Processor : in out Processor_Type) is begin Or_A(Value => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_C; procedure ORA_D(Processor : in out Processor_Type) is begin Or_A(Value => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_D; procedure ORA_E(Processor : in out Processor_Type) is begin Or_A(Value => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_E; procedure ORA_H(Processor : in out Processor_Type) is begin Or_A(Value => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_H; procedure ORA_L(Processor : in out Processor_Type) is begin Or_A(Value => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_L; procedure ORA_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Or_A(Value => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_M; procedure ORA_A(Processor : in out Processor_Type) is begin Or_A(Value => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORA_A; procedure CMP_B(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.B, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_B; procedure CMP_C(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.C, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_C; procedure CMP_D(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.D, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_D; procedure CMP_E(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.E, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_E; procedure CMP_H(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.H, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_H; procedure CMP_L(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.L, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_L; procedure CMP_M(Processor : in out Processor_Type) is Address : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Processor.H, Low_Order_Byte => Processor.L)); begin Or_A(Value => Processor.Memory(Address), Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_M; procedure CMP_A(Processor : in out Processor_Type) is begin Compare_A(Value => Processor.A, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CMP_A; procedure RNZ(Processor : in out Processor_Type) is begin if Processor.Zero_Flag = Not_Set then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RNZ; procedure POP_B(Processor : in out Processor_Type) is begin Processor.C := Processor.Memory(Processor.Stack_Pointer); Processor.B := Processor.Memory(Processor.Stack_Pointer + 1); Processor.Stack_Pointer := Processor.Stack_Pointer + 2; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end POP_B; procedure JNZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Zero_Flag = Not_Set then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JNZ; procedure JMP(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is PC : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => Byte_3, Low_Order_Byte => Byte_2)); begin Processor.Program_Counter := PC; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JMP; procedure CNZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Zero_Flag = Not_Set then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CNZ; procedure PUSH_B(Processor : in out Processor_Type) is begin Processor.Memory(Processor.Stack_Pointer - 2) := Processor.C; Processor.Memory(Processor.Stack_Pointer - 1) := Processor.B; Processor.Stack_Pointer := Processor.Stack_Pointer - 2; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end PUSH_B; procedure ADI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Add(Summand => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ADI_D8; procedure RST_0(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 0"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_0; procedure RZ(Processor : in out Processor_Type) is begin if Processor.Zero_Flag = Set then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RZ; procedure RET(Processor : in out Processor_Type) is use Interfaces; High_Order_Byte : constant Byte_Type := Processor.Memory(Processor.Stack_Pointer + 1); Low_Order_Byte : constant Byte_Type := Processor.Memory(Processor.Stack_Pointer); PC : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(High_Order_Byte => High_Order_Byte, Low_Order_Byte =>Low_Order_Byte)); begin Processor.Program_Counter := PC + 1; Processor.Stack_Pointer := Processor.Stack_Pointer + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RET; procedure JZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Zero_Flag = Set then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JZ; procedure CZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Zero_Flag = Set then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CZ; procedure CALL(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is PC_Byte_Pair : constant Byte_Pair_Type := Convert_To_Byte_Pair(Processor.Program_Counter); Next_PC : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(Low_Order_Byte => Byte_2, High_Order_Byte => Byte_3)); begin Processor.Memory(Processor.Stack_Pointer - 1) := PC_Byte_Pair.High_Order_Byte; Processor.Memory(Processor.Stack_Pointer - 2) := PC_Byte_Pair.Low_Order_Byte; Processor.Stack_Pointer := Processor.Stack_Pointer - 2; Processor.Program_Counter := Next_PC; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CALL; procedure ACI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Add_With_Carry(Summand => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ACI_D8; procedure RST_1(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 1"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_1; procedure RNC(Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Not_Set then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RNC; procedure POP_D(Processor : in out Processor_Type) is begin Processor.E := Processor.Memory(Processor.Stack_Pointer); Processor.D := Processor.Memory(Processor.Stack_Pointer + 1); Processor.Stack_Pointer := Processor.Stack_Pointer + 2; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end POP_D; procedure JNC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Not_Set then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JNC; procedure OUT_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is subtype Out_Ports_Type is Byte_Type range 2 .. 6; Port : constant Out_Ports_Type := Byte_2; begin case Port is when 2 => Ada.Text_IO.Put_Line("NOT IMPLEMENTED: OUT_D8 4 (Shift amount[3 bits])"); GNAT.OS_Lib.OS_Exit (0); when 3 => null; -- sound bits when 4 => Ada.Text_IO.Put_Line("NOT IMPLEMENTED: OUT_D8 4 (Shift data)"); GNAT.OS_Lib.OS_Exit (0); when 5 => null; -- sound bits when 6 => Ada.Text_IO.Put_Line("NOT IMPLEMENTED: OUT_D8 6. Not an issue for space invaders"); -- watchdog end case; Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end OUT_D8; procedure CNC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Not_Set then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CNC; procedure PUSH_D(Processor : in out Processor_Type) is begin Processor.Memory(Processor.Stack_Pointer - 2) := Processor.E; Processor.Memory(Processor.Stack_Pointer - 1) := Processor.D; Processor.Stack_Pointer := Processor.Stack_Pointer - 2; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end PUSH_D; procedure SUI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Sub(Subtrahend => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SUI_D8; procedure RST_2(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 2"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_2; procedure RC(Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Set then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RC; procedure JC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Set then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JC; procedure IN_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("NOT IMPLEMENTED IN_D8"); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end IN_D8; procedure CC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Carry_Flag = Set then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CC; procedure SBI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Sub_With_Carry(Subtrahend => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SBI_D8; procedure RST_3(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 3"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_3; procedure RPO(Processor : in out Processor_Type) is begin if Processor.Parity = Odd then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RPO; procedure POP_H(Processor : in out Processor_Type) is begin Processor.L := Processor.Memory(Processor.Stack_Pointer); Processor.H := Processor.Memory(Processor.Stack_Pointer + 1); Processor.Stack_Pointer := Processor.Stack_Pointer + 2; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end POP_H; procedure JPO(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Parity = Odd then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JPO; procedure XTHL(Processor : in out Processor_Type) is L_Value_Before : constant Byte_Type := Processor.L; H_Value_Before : constant Byte_Type := Processor.H; L_Stack_Value : constant Byte_Type := Processor.Memory(Processor.Stack_Pointer); H_Stack_Value : constant Byte_Type := Processor.Memory(Processor.Stack_Pointer + 1); Stack_Pointer_Values : constant Byte_Pair_Type := Convert_To_Byte_Pair(Processor.Stack_Pointer); begin Processor.L := L_Stack_Value; Processor.H := H_Stack_Value; Processor.Memory(Processor.Stack_Pointer) := L_Value_Before; Processor.Memory(Processor.Stack_Pointer + 1) := H_Value_Before; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XTHL; procedure CPO(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Parity = Odd then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CPO; procedure PUSH_H(Processor : in out Processor_Type) is begin Processor.Memory(Processor.Stack_Pointer - 2) := Processor.L; Processor.Memory(Processor.Stack_Pointer - 1) := Processor.H; Processor.Stack_Pointer := Processor.Stack_Pointer - 2; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end PUSH_H; procedure ANI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin And_A(Value => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ANI_D8; procedure RST_4(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 4"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_4; procedure RPE(Processor : in out Processor_Type) is begin if Processor.Parity = Even then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RPE; procedure PCHL(Processor : in out Processor_Type) is New_Address : constant Byte_Pair_Type := Byte_Pair_Type'(Low_Order_Byte => Processor.L, High_Order_Byte => Processor.H); begin Processor.Program_Counter := Convert_To_Address(New_Address); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end PCHL; procedure JPE(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Parity = Even then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JPE; procedure XCHG(Processor : in out Processor_Type) is L_Value_Before : constant Byte_Type := Processor.L; H_Value_Before : constant Byte_Type := Processor.H; E_Value_Before : constant Byte_Type := Processor.E; D_Value_Before : constant Byte_Type := Processor.D; begin Processor.L := E_Value_Before; Processor.E := L_Value_Before; Processor.H := D_Value_Before; Processor.D := H_Value_Before; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XCHG; procedure CPE(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Parity = Even then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CPE; procedure XRI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Xor_A(Value => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end XRI_D8; procedure RST_5(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 5"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_5; procedure RP(Processor : in out Processor_Type) is begin if Processor.Sign_Flag = Not_Set then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RP; procedure POP_PSW(Processor : in out Processor_Type) is Flag_Storage : constant Flag_Storage_Type := Convert_To_Flag_Storage(Processor.Memory(Processor.Stack_Pointer)); begin Processor.Sign_Flag := Flag_Storage.Sign_Flag; Processor.Zero_Flag := Flag_Storage.Zero_Flag; Processor.Carry_Flag := Flag_Storage.Carry_Flag; Processor.Auxillary_Carry := Flag_Storage.Auxillary_Carry; Processor.Parity := Flag_Storage.Parity; Processor.A := Processor.Memory(Processor.Stack_Pointer + 1); Processor.Stack_Pointer := Processor.Stack_Pointer + 2; Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end POP_PSW; procedure JP(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Sign_Flag = Not_Set then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JP; procedure DI(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("DISABLE INTERRUPT!"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end DI; procedure CP(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is Next_PC : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(Low_Order_Byte => Byte_2, High_Order_Byte => Byte_3)); begin if Processor.Sign_Flag = Not_Set then PRocessor.Program_Counter := Next_PC; else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CP; procedure PUSH_PSW(Processor : in out Processor_Type) is Flag_Storage : Flag_Storage_Type := Flag_Storage_Type'(Sign_Flag => Processor.Sign_Flag, Zero_Flag => Processor.Zero_Flag, Carry_Flag => Processor.Carry_Flag, Auxillary_Carry => Processor.Auxillary_Carry, Parity => Processor.Parity, Spare => 0); begin Processor.Memory(Processor.Stack_Pointer - 2) := Convert_To_Byte(Flag_Storage); Processor.Memory(Processor.Stack_Pointer - 1) := Processor.A; Processor.Stack_Pointer := Processor.Stack_Pointer - 2; Processor.Program_Counter := Processor.Program_Counter + 3; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end PUSH_PSW; procedure ORI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Or_A(Value => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end ORI_D8; procedure RST_6(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 6"); GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_6; procedure RM(Processor : in out Processor_Type) is begin if Processor.Sign_Flag = Set then RET(Processor); else Processor.Program_Counter := Processor.Program_Counter + 1; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RM; procedure SPHL(Processor : in out Processor_Type) is Next_SP : constant Address_Type := Convert_To_Address(Byte_Pair_Type'(Low_Order_Byte => Processor.L, High_Order_Byte => Processor.H)); begin Processor.Stack_Pointer := Next_SP; Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end SPHL; procedure JM(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Sign_Flag = Set then JMP(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end JM; procedure EI(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("ENABLE INTERRUPT!"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end EI; procedure CM(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type) is begin if Processor.Sign_Flag = Set then CALL(Byte_2 => Byte_2, Byte_3 => Byte_3, Processor => Processor); else Processor.Program_Counter := Processor.Program_Counter + 3; end if; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CM; procedure CPI(Byte_2 : in Byte_Type; Processor : in out Processor_Type) is begin Compare_A(Value => Byte_2, Processor => Processor); Processor.Program_Counter := Processor.Program_Counter + 2; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end CPI; procedure RST_7(Processor : in out Processor_Type) is begin Ada.Text_IO.Put_Line("RST 7"); --GNAT.OS_Lib.OS_Exit (0); exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end RST_7; procedure Unimplemented_Instruction(Processor : in out Processor_Type) is begin --Ada.Text_IO.Put_Line("Not yet implemented"); Processor.Program_Counter := Processor.Program_Counter + 1; exception when others => Print_Exception(Throwing_Function => GNAT.Source_Info.Enclosing_Entity, Exception_Cause => GNAT.Current_Exception.Exception_Information); end Unimplemented_Instruction; end Emulator_8080.Processor;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T N A M E -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-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. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Gnatvsn; use Gnatvsn; with Hostparm; with Opt; with Osint; use Osint; with Output; use Output; with Prj.Makr; with Table; with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; with GNAT.Command_Line; use GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; procedure Gnatname is Usage_Output : Boolean := False; -- Set to True when usage is output, to avoid multiple output Usage_Needed : Boolean := False; -- Set to True by -h switch Version_Output : Boolean := False; -- Set to True when version is output, to avoid multiple output Very_Verbose : Boolean := False; -- Set to True with -v -v Create_Project : Boolean := False; -- Set to True with a -P switch File_Path : String_Access := new String'("gnat.adc"); -- Path name of the file specified by -c or -P switch File_Set : Boolean := False; -- Set to True by -c or -P switch. -- Used to detect multiple -c/-P switches. package Excluded_Patterns is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Natural, Table_Low_Bound => 0, Table_Initial => 10, Table_Increment => 10, Table_Name => "Gnatname.Excluded_Patterns"); -- Table to accumulate the negative patterns package Foreign_Patterns is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Natural, Table_Low_Bound => 0, Table_Initial => 10, Table_Increment => 10, Table_Name => "Gnatname.Foreign_Patterns"); -- Table to accumulate the foreign patterns package Patterns is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Natural, Table_Low_Bound => 0, Table_Initial => 10, Table_Increment => 10, Table_Name => "Gnatname.Patterns"); -- Table to accumulate the name patterns package Source_Directories is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Natural, Table_Low_Bound => 0, Table_Initial => 10, Table_Increment => 10, Table_Name => "Gnatname.Source_Directories"); -- Table to accumulate the source directories specified directly with -d -- or indirectly with -D. package Preprocessor_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Natural, Table_Low_Bound => 0, Table_Initial => 2, Table_Increment => 50, Table_Name => "Gnatname.Preprocessor_Switches"); -- Table to store the preprocessor switches to be used in the call -- to the compiler. procedure Output_Version; -- Print name and version procedure Usage; -- Print usage procedure Scan_Args; -- Scan the command line arguments procedure Add_Source_Directory (S : String); -- Add S in the Source_Directories table procedure Get_Directories (From_File : String); -- Read a source directory text file -------------------------- -- Add_Source_Directory -- -------------------------- procedure Add_Source_Directory (S : String) is begin Source_Directories.Increment_Last; Source_Directories.Table (Source_Directories.Last) := new String'(S); end Add_Source_Directory; --------------------- -- Get_Directories -- --------------------- procedure Get_Directories (From_File : String) is File : Ada.Text_IO.File_Type; Line : String (1 .. 2_000); Last : Natural; begin Open (File, In_File, From_File); while not End_Of_File (File) loop Get_Line (File, Line, Last); if Last /= 0 then Add_Source_Directory (Line (1 .. Last)); end if; end loop; Close (File); exception when Name_Error => Fail ("cannot open source directory """ & From_File & '"'); end Get_Directories; -------------------- -- Output_Version -- -------------------- procedure Output_Version is begin if not Version_Output then Version_Output := True; Output.Write_Eol; Output.Write_Str ("GNATNAME "); Output.Write_Line (Gnatvsn.Gnat_Version_String); Output.Write_Line ("Copyright 2001-" & Current_Year & ", Free Software Foundation, Inc."); end if; end Output_Version; --------------- -- Scan_Args -- --------------- procedure Scan_Args is begin Initialize_Option_Scan; -- Scan options first loop case Getopt ("c: d: gnatep=! gnatep! gnateD! D: h P: v x: f:") is when ASCII.NUL => exit; when 'c' => if File_Set then Fail ("only one -P or -c switch may be specified"); end if; File_Set := True; File_Path := new String'(Parameter); Create_Project := False; when 'd' => Add_Source_Directory (Parameter); when 'D' => Get_Directories (Parameter); when 'f' => Foreign_Patterns.Increment_Last; Foreign_Patterns.Table (Foreign_Patterns.Last) := new String'(Parameter); when 'g' => Preprocessor_Switches.Increment_Last; Preprocessor_Switches.Table (Preprocessor_Switches.Last) := new String'('-' & Full_Switch & Parameter); when 'h' => Usage_Needed := True; when 'P' => if File_Set then Fail ("only one -c or -P switch may be specified"); end if; File_Set := True; File_Path := new String'(Parameter); Create_Project := True; when 'v' => if Opt.Verbose_Mode then Very_Verbose := True; else Opt.Verbose_Mode := True; end if; when 'x' => Excluded_Patterns.Increment_Last; Excluded_Patterns.Table (Excluded_Patterns.Last) := new String'(Parameter); when others => null; end case; end loop; -- Now, get the name patterns, if any loop declare S : String := Get_Argument (Do_Expansion => False); begin exit when S = ""; Canonical_Case_File_Name (S); Patterns.Increment_Last; Patterns.Table (Patterns.Last) := new String'(S); end; end loop; exception when Invalid_Switch => Fail ("invalid switch " & Full_Switch); end Scan_Args; ----------- -- Usage -- ----------- procedure Usage is begin if not Usage_Output then Usage_Needed := False; Usage_Output := True; Write_Str ("Usage: "); Osint.Write_Program_Name; Write_Line (" [switches] naming-pattern [naming-patterns]"); Write_Eol; Write_Line ("switches:"); Write_Line (" -cfile create configuration pragmas file"); Write_Line (" -ddir use dir as one of the source " & "directories"); Write_Line (" -Dfile get source directories from file"); Write_Line (" -fpat foreign pattern"); Write_Line (" -gnateDsym=v preprocess with symbol definition"); Write_Line (" -gnatep=data preprocess files with data file"); Write_Line (" -h output this help message"); Write_Line (" -Pproj update or create project file proj"); Write_Line (" -v verbose output"); Write_Line (" -v -v very verbose output"); Write_Line (" -xpat exclude pattern pat"); end if; end Usage; -- Start of processing for Gnatname begin -- Add the directory where gnatname is invoked in front of the -- path, if gnatname is invoked with directory information. -- Only do this if the platform is not VMS, where the notion of path -- does not really exist. if not Hostparm.OpenVMS then declare Command : constant String := Command_Name; begin for Index in reverse Command'Range loop if Command (Index) = Directory_Separator then declare Absolute_Dir : constant String := Normalize_Pathname (Command (Command'First .. Index)); PATH : constant String := Absolute_Dir & Path_Separator & Getenv ("PATH").all; begin Setenv ("PATH", PATH); end; exit; end if; end loop; end; end if; -- Initialize tables Excluded_Patterns.Set_Last (0); Foreign_Patterns.Set_Last (0); Patterns.Set_Last (0); Source_Directories.Set_Last (0); Preprocessor_Switches.Set_Last (0); -- Get the arguments Scan_Args; if Opt.Verbose_Mode then Output_Version; end if; if Usage_Needed then Usage; end if; -- If no pattern was specified, print the usage and return if Patterns.Last = 0 and Foreign_Patterns.Last = 0 then Usage; return; end if; -- If no source directory was specified, use the current directory as the -- unique directory. Note that if a file was specified with directory -- information, the current directory is the directory of the specified -- file. if Source_Directories.Last = 0 then Source_Directories.Increment_Last; Source_Directories.Table (Source_Directories.Last) := new String'("."); end if; declare Directories : Argument_List (1 .. Integer (Source_Directories.Last)); Name_Patterns : Argument_List (1 .. Integer (Patterns.Last)); Excl_Patterns : Argument_List (1 .. Integer (Excluded_Patterns.Last)); Frgn_Patterns : Argument_List (1 .. Integer (Foreign_Patterns.Last)); Prep_Switches : Argument_List (1 .. Integer (Preprocessor_Switches.Last)); begin -- Build the Directories and Name_Patterns arguments for Index in Directories'Range loop Directories (Index) := Source_Directories.Table (Index); end loop; for Index in Name_Patterns'Range loop Name_Patterns (Index) := Patterns.Table (Index); end loop; for Index in Excl_Patterns'Range loop Excl_Patterns (Index) := Excluded_Patterns.Table (Index); end loop; for Index in Frgn_Patterns'Range loop Frgn_Patterns (Index) := Foreign_Patterns.Table (Index); end loop; for Index in Prep_Switches'Range loop Prep_Switches (Index) := Preprocessor_Switches.Table (Index); end loop; -- Call Prj.Makr.Make where the real work is done Prj.Makr.Make (File_Path => File_Path.all, Project_File => Create_Project, Directories => Directories, Name_Patterns => Name_Patterns, Excluded_Patterns => Excl_Patterns, Foreign_Patterns => Frgn_Patterns, Preproc_Switches => Prep_Switches, Very_Verbose => Very_Verbose); end; if Opt.Verbose_Mode then Write_Eol; end if; end Gnatname;
package body T67XX_I2C_IO is ---------- -- Read -- ---------- procedure Read (This : Any_IO_Port; Func : UInt8; Register : UInt16; Nxfer : UInt16; Response : out I2C_Data) is Result : I2C_Status; Frame : T67XX_Frame; Buf : I2C_Data (1 .. 5); for Frame'Address use Buf'Address; begin Frame.Func := Func; Frame.RegNum := Register; Frame.NReg := Nxfer; Swap (Frame.RegNum); Swap (Frame.NReg); Master_Transmit (This.Port.all, This.Device, Buf, Result); if Result /= Ok then raise Program_Error with "I2C read pt1 error:" & Result'Img; end if; This.Ptr.all; -- Delay_Milliseconds (10); Master_Receive (This.Port.all, This.Device, Response, Result); if Result /= Ok then raise Program_Error with "I2C read pt2 error:" & Result'Img; end if; end Read; procedure Swap (X : in out UInt16) is Result : UInt16 := X; begin Result := Shift_Left (X, 8) or (Shift_Right (X, 8)); X := Result; end Swap; end T67XX_I2C_IO;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Source_Buffers; private with Ada.Containers.Hashed_Maps; package Program.Symbols.Tables is pragma Preelaborate; type Symbol_Table is tagged limited private; procedure Initialize (Self : in out Symbol_Table); -- Initialize given symbol table with predefinced symbols function Find (Self : Symbol_Table'Class; Value : Program.Text) return Symbol; -- Return symbol for given Text or No_Symbol if no such value in the table procedure Find_Or_Create (Self : in out Symbol_Table'Class; Buffer : not null Program.Source_Buffers.Source_Buffer_Access; Span : Program.Source_Buffers.Span; Result : out Symbol); private type Symbol_Reference is record Buffer : not null Program.Source_Buffers.Source_Buffer_Access; Span : Program.Source_Buffers.Span; end record; function Equal (Left, Right : Symbol_Reference) return S.Boolean; function Hash (Value : Symbol_Reference) return Ada.Containers.Hash_Type; package Symbol_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Symbol_Reference, Element_Type => Program.Symbols.Symbol, Hash => Hash, Equivalent_Keys => Equal, "=" => Program.Symbols."="); type Predefined_Source_Buffer is new Program.Source_Buffers.Source_Buffer with null record; overriding function Text (Self : Predefined_Source_Buffer; Span : Program.Source_Buffers.Span) return Program.Text; overriding procedure Read (Self : in out Predefined_Source_Buffer; Data : out Program.Source_Buffers.Character_Info_Array; Last : out Natural) is null; overriding procedure Rewind (Self : in out Predefined_Source_Buffer) is null; type Symbol_Table is tagged limited record Map : Symbol_Maps.Map; Buffer : aliased Predefined_Source_Buffer; Last_Symbol : Program.Symbols.Symbol := Program.Symbols.X_Symbol'Last; end record; end Program.Symbols.Tables;
----------------------------------------------------------------------- -- mgrep -- Mail grep command -- Copyright (C) 2020 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.Command_Line; with Ada.Directories; with Ada.Text_IO; with Ada.IO_Exceptions; with Ada.Exceptions; with GNAT.Command_Line; with GNAT.Regpat; with Util.Log.Loggers; with Util.Commands; with Mgrep.Matcher; with Mgrep.Scanner; with Mgrep.Printer; procedure Mgrep.Main is use Ada.Text_IO; use Ada.Directories; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Mgrep.Main"); Printer : aliased Mgrep.Printer.Printer_Type; Rule : aliased Mgrep.Matcher.Mail_Rule; Count : constant Natural := Ada.Command_Line.Argument_Count; begin Rule.Collector := Printer'Unchecked_Access; if Count < 2 then Put_Line ("Usage: mgrep <pattern> {file|directory}"); return; end if; Configure_Logs (False, False, False); GNAT.Regpat.Compile (Rule.Pattern, Ada.Command_Line.Argument (1)); declare Scanner : Mgrep.Scanner.Scanner_Type (8, Rule'Access); Done : Boolean; begin Scanner.Start; for I in 2 .. Ada.Command_Line.Argument_Count loop declare Path : constant String := Ada.Command_Line.Argument (I); Kind : constant File_Kind := Ada.Directories.Kind (Path); begin if Kind /= Ada.Directories.Directory then Scanner.Add_File (Path); else Scanner.Add_Directory (Path); end if; end; end loop; loop Scanner.Process (Done); Printer.Report; exit when Done; end loop; Scanner.Stop; Put_Line ("Directories :" & Natural'Image (Scanner.Get_Directory_Count)); Put_Line ("Files :" & Natural'Image (Scanner.Get_File_Count)); exception when E : others => Log.Error ("Internal error", E); Scanner.Stop; end; exception when GNAT.Command_Line.Exit_From_Command_Line | GNAT.Command_Line.Invalid_Switch => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when GNAT.Regpat.Expression_Error => Log.Error (-("Invalid pattern")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Util.Commands.Not_Found => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : Ada.IO_Exceptions.Name_Error => Log.Error (-("Cannot access file: {0}"), Ada.Exceptions.Exception_Message (E)); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : others => Log.Error (-("Some internal error occurred"), E); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); end Mgrep.Main;
procedure poulet_au() is poulet : integer; begin couper(poulet); revenir(poulet); servir(poulet); end; procedure poulet_au(recette : access procedure (poulet : integer)) is poulet : integer; begin couper(poulet); revenir(poulet); recette(poulet); servir(poulet); end; procedure flamber(poulet : integer) is begin -- poulet on fire end; procedure salerpoivrerpaprika(poulet : integer) is begin -- spp end; procedure rien(poulet : integer) is begin null; end; poulet_au(salerpoivrerpaprika'access);
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S T Y L E S W -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, 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 Hostparm; use Hostparm; with Opt; use Opt; with Output; use Output; package body Stylesw is -- The following constant defines the default style options for -gnaty Default_Style : constant String := "3" & -- indentation level is 3 "a" & -- check attribute casing "A" & -- check array attribute indexes "b" & -- check no blanks at end of lines "c" & -- check comment formats "e" & -- check end/exit labels present "f" & -- check no form/feeds vertical tabs in source "h" & -- check no horizontal tabs in source "i" & -- check if-then layout "k" & -- check casing rules for keywords "l" & -- check reference manual layout "m" & -- check line length <= 79 characters "n" & -- check casing of package Standard idents "p" & -- check pragma casing "r" & -- check casing for identifier references "s" & -- check separate subprogram specs present "t"; -- check token separation rules -- The following constant defines the GNAT style options, showing them -- as additions to the standard default style check options. GNAT_Style : constant String := Default_Style & "d" & -- check no DOS line terminators "I" & -- check mode IN "S" & -- check separate lines after THEN or ELSE "u" & -- check no unnecessary blank lines "x"; -- check extra parentheses around conditionals -- Note: we intend GNAT_Style to also include the following, but we do -- not yet have the whole tool suite clean with respect to this. -- "B" & -- check boolean operators ------------------------------- -- Reset_Style_Check_Options -- ------------------------------- procedure Reset_Style_Check_Options is begin Style_Check_Indentation := 0; Style_Check_Array_Attribute_Index := False; Style_Check_Attribute_Casing := False; Style_Check_Blanks_At_End := False; Style_Check_Blank_Lines := False; Style_Check_Boolean_And_Or := False; Style_Check_Comments := False; Style_Check_DOS_Line_Terminator := False; Style_Check_End_Labels := False; Style_Check_Form_Feeds := False; Style_Check_Horizontal_Tabs := False; Style_Check_If_Then_Layout := False; Style_Check_Keyword_Casing := False; Style_Check_Layout := False; Style_Check_Max_Line_Length := False; Style_Check_Max_Nesting_Level := False; Style_Check_Missing_Overriding := False; Style_Check_Mode_In := False; Style_Check_Order_Subprograms := False; Style_Check_Pragma_Casing := False; Style_Check_References := False; Style_Check_Separate_Stmt_Lines := False; Style_Check_Specs := False; Style_Check_Standard := False; Style_Check_Tokens := False; Style_Check_Xtra_Parens := False; end Reset_Style_Check_Options; --------------------- -- RM_Column_Check -- --------------------- function RM_Column_Check return Boolean is begin return Style_Check and Style_Check_Layout; end RM_Column_Check; ------------------------------ -- Save_Style_Check_Options -- ------------------------------ procedure Save_Style_Check_Options (Options : out Style_Check_Options) is P : Natural := 0; procedure Add (C : Character; S : Boolean); -- Add given character C to string if switch S is true procedure Add_Nat (N : Nat); -- Add given natural number to string --------- -- Add -- --------- procedure Add (C : Character; S : Boolean) is begin if S then P := P + 1; Options (P) := C; end if; end Add; ------------- -- Add_Nat -- ------------- procedure Add_Nat (N : Nat) is begin if N > 9 then Add_Nat (N / 10); end if; P := P + 1; Options (P) := Character'Val (Character'Pos ('0') + N mod 10); end Add_Nat; -- Start of processing for Save_Style_Check_Options begin for K in Options'Range loop Options (K) := ' '; end loop; Add (Character'Val (Style_Check_Indentation + Character'Pos ('0')), Style_Check_Indentation /= 0); Add ('a', Style_Check_Attribute_Casing); Add ('A', Style_Check_Array_Attribute_Index); Add ('b', Style_Check_Blanks_At_End); Add ('B', Style_Check_Boolean_And_Or); if Style_Check_Comments then if Style_Check_Comments_Spacing = 2 then Add ('c', Style_Check_Comments); elsif Style_Check_Comments_Spacing = 1 then Add ('C', Style_Check_Comments); end if; end if; Add ('d', Style_Check_DOS_Line_Terminator); Add ('e', Style_Check_End_Labels); Add ('f', Style_Check_Form_Feeds); Add ('h', Style_Check_Horizontal_Tabs); Add ('i', Style_Check_If_Then_Layout); Add ('I', Style_Check_Mode_In); Add ('k', Style_Check_Keyword_Casing); Add ('l', Style_Check_Layout); Add ('n', Style_Check_Standard); Add ('o', Style_Check_Order_Subprograms); Add ('O', Style_Check_Missing_Overriding); Add ('p', Style_Check_Pragma_Casing); Add ('r', Style_Check_References); Add ('s', Style_Check_Specs); Add ('S', Style_Check_Separate_Stmt_Lines); Add ('t', Style_Check_Tokens); Add ('u', Style_Check_Blank_Lines); Add ('x', Style_Check_Xtra_Parens); if Style_Check_Max_Line_Length then P := P + 1; Options (P) := 'M'; Add_Nat (Style_Max_Line_Length); end if; if Style_Check_Max_Nesting_Level then P := P + 1; Options (P) := 'L'; Add_Nat (Style_Max_Nesting_Level); end if; pragma Assert (P <= Options'Last); while P < Options'Last loop P := P + 1; Options (P) := ' '; end loop; end Save_Style_Check_Options; ------------------------------------- -- Set_Default_Style_Check_Options -- ------------------------------------- procedure Set_Default_Style_Check_Options is begin Reset_Style_Check_Options; Set_Style_Check_Options (Default_Style); end Set_Default_Style_Check_Options; ---------------------------------- -- Set_GNAT_Style_Check_Options -- ---------------------------------- procedure Set_GNAT_Style_Check_Options is begin Reset_Style_Check_Options; Set_Style_Check_Options (GNAT_Style); end Set_GNAT_Style_Check_Options; ----------------------------- -- Set_Style_Check_Options -- ----------------------------- -- Version used when no error checking is required procedure Set_Style_Check_Options (Options : String) is OK : Boolean; EC : Natural; pragma Warnings (Off, EC); begin Set_Style_Check_Options (Options, OK, EC); pragma Assert (OK); end Set_Style_Check_Options; -- Normal version with error checking procedure Set_Style_Check_Options (Options : String; OK : out Boolean; Err_Col : out Natural) is C : Character; On : Boolean := True; -- Set to False if minus encountered -- Set to True if plus encountered Last_Option : Character := ' '; -- Set to last character encountered procedure Add_Img (N : Natural); -- Concatenates image of N at end of Style_Msg_Buf procedure Bad_Style_Switch (Msg : String); -- Called if bad style switch found. Msg is set in Style_Msg_Buf and -- Style_Msg_Len. OK is set False. ------------- -- Add_Img -- ------------- procedure Add_Img (N : Natural) is begin if N >= 10 then Add_Img (N / 10); end if; Style_Msg_Len := Style_Msg_Len + 1; Style_Msg_Buf (Style_Msg_Len) := Character'Val (N mod 10 + Character'Pos ('0')); end Add_Img; ---------------------- -- Bad_Style_Switch -- ---------------------- procedure Bad_Style_Switch (Msg : String) is begin OK := False; Style_Msg_Len := Msg'Length; Style_Msg_Buf (1 .. Style_Msg_Len) := Msg; end Bad_Style_Switch; -- Start of processing for Set_Style_Check_Options begin Err_Col := Options'First; while Err_Col <= Options'Last loop C := Options (Err_Col); Last_Option := C; Err_Col := Err_Col + 1; -- Turning switches on if On then case C is when '+' => null; when '-' => On := False; when '0' .. '9' => Style_Check_Indentation := Character'Pos (C) - Character'Pos ('0'); when 'a' => Style_Check_Attribute_Casing := True; when 'A' => Style_Check_Array_Attribute_Index := True; when 'b' => Style_Check_Blanks_At_End := True; when 'B' => Style_Check_Boolean_And_Or := True; when 'c' => Style_Check_Comments := True; Style_Check_Comments_Spacing := 2; when 'C' => Style_Check_Comments := True; Style_Check_Comments_Spacing := 1; when 'd' => Style_Check_DOS_Line_Terminator := True; when 'e' => Style_Check_End_Labels := True; when 'f' => Style_Check_Form_Feeds := True; when 'g' => Set_GNAT_Style_Check_Options; when 'h' => Style_Check_Horizontal_Tabs := True; when 'i' => Style_Check_If_Then_Layout := True; when 'I' => Style_Check_Mode_In := True; when 'k' => Style_Check_Keyword_Casing := True; when 'l' => Style_Check_Layout := True; when 'L' => Style_Max_Nesting_Level := 0; if Err_Col > Options'Last or else Options (Err_Col) not in '0' .. '9' then Bad_Style_Switch ("invalid nesting level"); return; end if; loop Style_Max_Nesting_Level := Style_Max_Nesting_Level * 10 + Character'Pos (Options (Err_Col)) - Character'Pos ('0'); if Style_Max_Nesting_Level > 999 then Bad_Style_Switch ("max nesting level (999) exceeded in style check"); return; end if; Err_Col := Err_Col + 1; exit when Err_Col > Options'Last or else Options (Err_Col) not in '0' .. '9'; end loop; Style_Check_Max_Nesting_Level := Style_Max_Nesting_Level /= 0; when 'm' => Style_Check_Max_Line_Length := True; Style_Max_Line_Length := 79; when 'M' => Style_Max_Line_Length := 0; if Err_Col > Options'Last or else Options (Err_Col) not in '0' .. '9' then Bad_Style_Switch ("invalid line length in style check"); return; end if; loop Style_Max_Line_Length := Style_Max_Line_Length * 10 + Character'Pos (Options (Err_Col)) - Character'Pos ('0'); if Style_Max_Line_Length > Int (Max_Line_Length) then OK := False; Style_Msg_Buf (1 .. 27) := "max line length allowed is "; Style_Msg_Len := 27; Add_Img (Natural (Max_Line_Length)); return; end if; Err_Col := Err_Col + 1; exit when Err_Col > Options'Last or else Options (Err_Col) not in '0' .. '9'; end loop; Style_Check_Max_Line_Length := Style_Max_Line_Length /= 0; when 'n' => Style_Check_Standard := True; when 'N' => Reset_Style_Check_Options; when 'o' => Style_Check_Order_Subprograms := True; when 'O' => Style_Check_Missing_Overriding := True; when 'p' => Style_Check_Pragma_Casing := True; when 'r' => Style_Check_References := True; when 's' => Style_Check_Specs := True; when 'S' => Style_Check_Separate_Stmt_Lines := True; when 't' => Style_Check_Tokens := True; when 'u' => Style_Check_Blank_Lines := True; when 'x' => Style_Check_Xtra_Parens := True; when 'y' => Set_Default_Style_Check_Options; when ' ' => null; when others => if Ignore_Unrecognized_VWY_Switches then Write_Line ("unrecognized switch -gnaty" & C & " ignored"); else Err_Col := Err_Col - 1; Bad_Style_Switch ("invalid style switch"); return; end if; end case; -- Turning switches off else case C is when '+' => On := True; when '-' => null; when '0' .. '9' => Style_Check_Indentation := 0; when 'a' => Style_Check_Attribute_Casing := False; when 'A' => Style_Check_Array_Attribute_Index := False; when 'b' => Style_Check_Blanks_At_End := False; when 'B' => Style_Check_Boolean_And_Or := False; when 'c' | 'C' => Style_Check_Comments := False; when 'd' => Style_Check_DOS_Line_Terminator := False; when 'e' => Style_Check_End_Labels := False; when 'f' => Style_Check_Form_Feeds := False; when 'g' => Reset_Style_Check_Options; when 'h' => Style_Check_Horizontal_Tabs := False; when 'i' => Style_Check_If_Then_Layout := False; when 'I' => Style_Check_Mode_In := False; when 'k' => Style_Check_Keyword_Casing := False; when 'l' => Style_Check_Layout := False; when 'L' => Style_Max_Nesting_Level := 0; when 'm' => Style_Check_Max_Line_Length := False; when 'M' => Style_Max_Line_Length := 0; Style_Check_Max_Line_Length := False; when 'n' => Style_Check_Standard := False; when 'o' => Style_Check_Order_Subprograms := False; when 'O' => Style_Check_Missing_Overriding := False; when 'p' => Style_Check_Pragma_Casing := False; when 'r' => Style_Check_References := False; when 's' => Style_Check_Specs := False; when 'S' => Style_Check_Separate_Stmt_Lines := False; when 't' => Style_Check_Tokens := False; when 'u' => Style_Check_Blank_Lines := False; when 'x' => Style_Check_Xtra_Parens := False; when ' ' => null; when others => if Ignore_Unrecognized_VWY_Switches then Write_Line ("unrecognized switch -gnaty-" & C & " ignored"); else Err_Col := Err_Col - 1; Bad_Style_Switch ("invalid style switch"); return; end if; end case; end if; end loop; -- Turn on style checking if other than N at end of string Style_Check := (Last_Option /= 'N'); OK := True; end Set_Style_Check_Options; end Stylesw;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . R E S P O N S E _ F I L E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007-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. -- -- -- ------------------------------------------------------------------------------ -- This package provides facilities for getting command-line arguments from -- a text file, called a "response file". -- -- Using a response file allow passing a set of arguments to an executable -- longer than the maximum allowed by the system on the command line. pragma Compiler_Unit_Warning; with System.Strings; package System.Response_File is subtype String_Access is System.Strings.String_Access; -- type String_Access is access all String; procedure Free (S : in out String_Access) renames System.Strings.Free; -- To deallocate a String subtype Argument_List is System.Strings.String_List; -- type String_List is array (Positive range <>) of String_Access; Max_Line_Length : constant := 4096; -- The maximum length of lines in a response file File_Does_Not_Exist : exception; -- Raise by Arguments_From when a response file cannot be found Line_Too_Long : exception; -- Raise by Arguments_From when a line in the response file is longer than -- Max_Line_Length. No_Closing_Quote : exception; -- Raise by Arguments_From when a quoted string does not end before the -- end of the line. Circularity_Detected : exception; -- Raise by Arguments_From when Recursive is True and the same response -- file is reading itself, either directly or indirectly. function Arguments_From (Response_File_Name : String; Recursive : Boolean := False; Ignore_Non_Existing_Files : Boolean := False) return Argument_List; -- Read response file with name Response_File_Name and return the argument -- it contains as an Argument_List. It is the responsibility of the caller -- to deallocate the strings in the Argument_List if desired. When -- Recursive is True, any argument of the form @file_name indicates the -- name of another response file and is replaced by the arguments in this -- response file. -- -- Each nonempty line of the response file contains one or several -- arguments separated by white space. Empty lines or lines containing only -- white space are ignored. Arguments containing white space or a double -- quote ('"')must be quoted. A double quote inside a quote string is -- indicated by two consecutive double quotes. Example: "-Idir with quote -- "" and spaces". Non-white-space characters immediately before or after a -- quoted string are part of the same argument. Ex: -Idir" with "spaces -- -- When a response file cannot be found, exception File_Does_Not_Exist is -- raised if Ignore_Non_Existing_Files is False, otherwise the response -- file is ignored. Exception Line_Too_Long is raised when a line of a -- response file is longer than Max_Line_Length. Exception No_Closing_Quote -- is raised when a quoted argument is not closed before the end of the -- line. Exception Circularity_Detected is raised when a Recursive is True -- and a response file is reading itself, either directly or indirectly. end System.Response_File;
with Ada.Text_IO; use Ada.Text_IO; procedure Main is --Conversion_Functions type Digit_T is range 0 .. 9; type Digit_Name_T is (Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine); -- functions to convert between Digit_T, Digit_Name_T, and input values -- function Convert ( ? -- functions to compare across types -- function "=" ( ? Last_Entry : Digit_T := 0; begin loop Put ("Input: "); declare Str : constant String := Get_Line; begin exit when Str'length = 0; -- If the string is a number -- Convert the entry to a name and print it -- if this input has the same value as the previous value, say so -- Else (this is a name) -- Convert the entry to a number and print it -- if this input has the same value as the previous value, say so end; end loop; end Main; --Main
-- Implantation du module Piles. with Ada.Text_IO; use Ada.Text_IO; --! Ce module est nécessaire parce qu'on a ajouté le SP Afficher. package body Piles is procedure Initialiser (Pile : out T_Pile) is begin Pile.Taille := 0; end Initialiser; function Est_Vide (Pile : in T_Pile) return Boolean is begin return Pile.Taille = 0; end Est_Vide; function Est_Pleine (Pile : in T_Pile) return Boolean is begin return Pile.Taille >= Capacite; end Est_Pleine; function Sommet (Pile : in T_Pile) return T_Element is begin return Pile.Elements (Pile.Taille); end Sommet; procedure Empiler (Pile : in out T_Pile; Element : in T_Element) is begin Pile.Taille := Pile.Taille + 1; Pile.Elements (Pile.Taille) := Element; end Empiler; procedure Depiler (Pile : in out T_Pile) is begin Pile.Taille := Pile.Taille - 1; end Depiler; procedure Afficher (Pile : in T_Pile) is begin Put ('['); if not Est_Vide (Pile) then Put (' '); Afficher_Element (Pile.Elements (1)); for I in 2..Pile.Taille loop Put (", "); Afficher_Element (Pile.Elements (I)); end loop; else Null; end if; Put (" >"); end Afficher; end Piles;
with Ada.Text_IO; use Ada.Text_IO; package body Prime_Ada is procedure Get_Prime (n : Integer) is prime : array (1 .. n) of Integer; is_prime : array (1 .. n) of Boolean := (False, others => True); begin cnt := 0; for i in 2 .. n loop if is_prime (i) then cnt := cnt + 1; prime (cnt) := i; end if; for j in 1 .. cnt loop if i * prime (j) > n then exit; end if; is_prime (i * prime (j)) := False; if i mod prime (j) = 0 then exit; end if; end loop; end loop; end Get_Prime; end Prime_Ada;
with Commands.Generate; with Commands.Create; with Commands.Init; with Commands.Destroy; with Commands.Publish; with Commands.Import; with Commands.Deploy; with Commands.Announce; with CLIC.User_Input; with Commands.Topics.Issues; with Commands.Topics.Contribute; package body Commands is ------------------------- -- Set_Global_Switches -- ------------------------- procedure Set_Global_Switches (Config : in out CLIC.Subcommand.Switches_Configuration) is use CLIC.Subcommand; Help_Switch : aliased Boolean := False; -- Catches the -h/--help help switch begin Define_Switch (Config, Help_Switch'Access, "-h", "--help", "Display general or command-specific help"); end Set_Global_Switches; ------------- -- Execute -- ------------- procedure Execute is begin Sub_Cmd.Parse_Global_Switches; CLIC.TTY.Enable_Color (Force => False); begin Sub_Cmd.Execute; exception when Child_Failed | Command_Failed | Wrong_Command_Arguments => GNAT.OS_Lib.OS_Exit (1); when CLIC.User_Input.User_Interrupt => GNAT.OS_Lib.OS_Exit (1); end; end Execute; begin -- Commands -- Sub_Cmd.Register ("General", new Sub_Cmd.Builtin_Help); Sub_Cmd.Register ("General", new Create.Instance); Sub_Cmd.Register ("General", new Init.Instance); Sub_Cmd.Register ("General", new Generate.Instance); Sub_Cmd.Register ("General", new Destroy.Instance); Sub_Cmd.Register ("General", new Publish.Instance); Sub_Cmd.Register ("General", new Import.Instance); Sub_Cmd.Register ("General", new Deploy.Instance); Sub_Cmd.Register ("General", new Announce.Instance); -- Help topics -- Sub_Cmd.Register (new Topics.Issues.Topic); Sub_Cmd.Register (new Topics.Contribute.Topic); end Commands;
-- This spec has been automatically generated from STM32L5x2.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.RNG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype RNG_CR_RNG_CONFIG3_Field is HAL.UInt4; subtype RNG_CR_RNG_CONFIG2_Field is HAL.UInt3; subtype RNG_CR_CLKDIV_Field is HAL.UInt4; subtype RNG_CR_RNG_CONFIG1_Field is HAL.UInt6; -- RNG control register type RNG_CR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Random number generator enable RNGEN : Boolean := False; -- Interrupt enable IE : Boolean := False; -- unspecified Reserved_4_4 : HAL.Bit := 16#0#; -- Clock error detection Note: The clock error detection can be used -- only when ck_rc48 or ck_pll1_q (ck_pll1_q = 48MHz) source is selected -- otherwise, CED bit must be equal to 1. The clock error detection -- cannot be enabled nor disabled on the fly when RNG peripheral is -- enabled, to enable or disable CED the RNG must be disabled. CED : Boolean := False; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- RNG configuration 3 RNG_CONFIG3 : RNG_CR_RNG_CONFIG3_Field := 16#0#; -- Non NIST compliant NISTC : Boolean := False; -- RNG configuration 2 RNG_CONFIG2 : RNG_CR_RNG_CONFIG2_Field := 16#0#; -- Clock divider factor CLKDIV : RNG_CR_CLKDIV_Field := 16#0#; -- RNG configuration 1 RNG_CONFIG1 : RNG_CR_RNG_CONFIG1_Field := 16#0#; -- unspecified Reserved_26_29 : HAL.UInt4 := 16#0#; -- Conditioning soft reset CONDRST : Boolean := False; -- RNG Config Lock CONFIGLOCK : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RNG_CR_Register use record Reserved_0_1 at 0 range 0 .. 1; RNGEN at 0 range 2 .. 2; IE at 0 range 3 .. 3; Reserved_4_4 at 0 range 4 .. 4; CED at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; RNG_CONFIG3 at 0 range 8 .. 11; NISTC at 0 range 12 .. 12; RNG_CONFIG2 at 0 range 13 .. 15; CLKDIV at 0 range 16 .. 19; RNG_CONFIG1 at 0 range 20 .. 25; Reserved_26_29 at 0 range 26 .. 29; CONDRST at 0 range 30 .. 30; CONFIGLOCK at 0 range 31 .. 31; end record; -- RNG status register type RNG_SR_Register is record -- Read-only. Data ready Note: If IE=1 in RNG_CR, an interrupt is -- generated when DRDY=1. It can rise when the peripheral is disabled. -- When the output buffer becomes empty (after reading RNG_DR), this bit -- returns to 0 until a new random value is generated. DRDY : Boolean := False; -- Read-only. Clock error current status Note: This bit is meaningless -- if CED (Clock error detection) bit in RNG_CR is equal to 1. CECS : Boolean := False; -- Read-only. Seed error current status ** More than 64 consecutive bits -- at the same value (0 or 1) ** More than 32 consecutive alternances of -- 0 and 1 (0101010101...01) SECS : Boolean := False; -- unspecified Reserved_3_4 : HAL.UInt2 := 16#0#; -- Clock error interrupt status This bit is set at the same time as -- CECS. It is cleared by writing it to 0. An interrupt is pending if IE -- = 1 in the RNG_CR register. Note: This bit is meaningless if CED -- (Clock error detection) bit in RNG_CR is equal to 1. CEIS : Boolean := False; -- Seed error interrupt status This bit is set at the same time as SECS. -- It is cleared by writing it to 0. ** More than 64 consecutive bits at -- the same value (0 or 1) ** More than 32 consecutive alternances of 0 -- and 1 (0101010101...01) An interrupt is pending if IE = 1 in the -- RNG_CR register. SEIS : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RNG_SR_Register use record DRDY at 0 range 0 .. 0; CECS at 0 range 1 .. 1; SECS at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; CEIS at 0 range 5 .. 5; SEIS at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- RNG type RNG_Peripheral is record -- RNG control register RNG_CR : aliased RNG_CR_Register; -- RNG status register RNG_SR : aliased RNG_SR_Register; -- The RNG_DR register is a read-only register that delivers a 32-bit -- random value when read. The content of this register is valid when -- DRDY= 1, even if RNGEN=0. RNG_DR : aliased HAL.UInt32; -- The RNG_DR register is a read-only register that delivers a 32-bit -- random value when read. The content of this register is valid when -- DRDY= 1, even if RNGEN=0. RNG_HTCR : aliased HAL.UInt32; end record with Volatile; for RNG_Peripheral use record RNG_CR at 16#0# range 0 .. 31; RNG_SR at 16#4# range 0 .. 31; RNG_DR at 16#8# range 0 .. 31; RNG_HTCR at 16#10# range 0 .. 31; end record; -- RNG RNG_Periph : aliased RNG_Peripheral with Import, Address => System'To_Address (16#420C0800#); -- RNG SEC_RNG_Periph : aliased RNG_Peripheral with Import, Address => System'To_Address (16#520C0800#); end STM32_SVD.RNG;
with Instruction; use Instruction; with Machine; use Machine; with Debug; use Debug; procedure Driver with SPARK_Mode is Prog : Program := (others => (Op => NOP)); Code : ReturnCode; Result : Integer; HasInvalidBehaviour : Boolean; begin -- initialise the random number generators used to generate -- random instructions. Commenting this out may yield predictable -- (i.e. non-random) output Instruction.Init; -- generate a random program Put_Line("Generating Random Program..."); for I in Prog'Range loop GenerateRandomInstr(Prog(I)); end loop; Put_Line("Analysing Program for Invalid Behaviour..."); HasInvalidBehaviour := DetectInvalidBehaviour(Prog,MAX_PROGRAM_LENGTH); Put("Analysis Result: "); Put(HasInvalidBehaviour'Image); New_Line; -- run the program Put_Line("Executing program..."); ExecuteProgram(Prog,MAX_PROGRAM_LENGTH,Code,Result); Put("Return Code: "); Put(Code'Image); if Code = Success then Put(" Result: "); Put(Result); end if; New_Line; end Driver;
----------------------------------------------------------------------- -- wiki-filters-variables -- Expand variables in text and links -- Copyright (C) 2020 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 with Ada.Containers.Indefinite_Ordered_Maps; -- === Variables Filters === -- The `Wiki.Filters.Variables` package defines a filter that replaces variables -- in the text, links, quotes. Variables are represented as `$name`, `$(name)` -- or `${name}`. When a variable is not found, the original string is not modified. -- The list of variables is either configured programatically through the -- `Add_Variable` procedures but it can also be set from the Wiki text by using -- the `Wiki.Plugins.Variables` plugin. -- -- The variable filter must be configured with the plugin by declaring the instance: -- -- F : aliased Wiki.Filters.Html.Html_Filter_Type; -- -- Engine.Add_Filter (F'Unchecked_Access); -- -- And variables can be inserted by using the `Add_Variable` procedure: -- -- F.Add_Variable ("username", "gandalf"); -- package Wiki.Filters.Variables is pragma Preelaborate; type Variable_Filter is new Filter_Type with private; type Variable_Filter_Access is access all Variable_Filter'Class; -- Add a variable to replace the given name by its value. procedure Add_Variable (Filter : in out Variable_Filter; Name : in Wiki.Strings.WString; Value : in Wiki.Strings.WString); procedure Add_Variable (Filter : in out Variable_Filter; Name : in String; Value : in Wiki.Strings.WString); procedure Add_Variable (Chain : in Wiki.Filters.Filter_Chain; Name : in Wiki.Strings.WString; Value : in Wiki.Strings.WString); -- Add a section header with the given level in the document. overriding procedure Add_Header (Filter : in out Variable_Filter; Document : in out Wiki.Documents.Document; Header : in Wiki.Strings.WString; Level : in Natural); -- Add a text content with the given format to the document. Replace variables -- that are contained in the text. overriding procedure Add_Text (Filter : in out Variable_Filter; Document : in out Wiki.Documents.Document; Text : in Wiki.Strings.WString; Format : in Wiki.Format_Map); -- Add a link. overriding procedure Add_Link (Filter : in out Variable_Filter; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Add a quote. overriding procedure Add_Quote (Filter : in out Variable_Filter; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Expand the variables contained in the text. function Expand (Filter : in Variable_Filter; Text : in Wiki.Strings.WString) return Wiki.Strings.WString; -- Iterate over the filter variables. procedure Iterate (Filter : in Variable_Filter; Process : not null access procedure (Name, Value : in Strings.WString)); procedure Iterate (Chain : in Wiki.Filters.Filter_Chain; Process : not null access procedure (Name, Value : in Strings.WString)); private package Variable_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Strings.WString, Element_Type => Strings.WString); subtype Variable_Map is Variable_Maps.Map; subtype Variable_Cursor is Variable_Maps.Cursor; type Variable_Filter is new Filter_Type with record Variables : Variable_Map; end record; end Wiki.Filters.Variables;
with AUnit; use AUnit; with AUnit.Run; with AUnit.Reporter.Text; with GNAT.OS_Lib; with Tests; with Tests.Device.HID; with Tests.Utils; procedure Run_Tests is function Runner is new AUnit.Run.Test_Runner_With_Status (Tests.Get_Suite); Reporter : AUnit.Reporter.Text.Text_Reporter; begin Reporter.Set_Use_ANSI_Colors (True); if Runner (Reporter, (Global_Timer => True, Test_Case_Timer => True, Report_Successes => True, others => <>)) /= AUnit.Success then GNAT.OS_Lib.OS_Exit (1); end if; end Run_Tests;
package Unknown_Discriminant is type Type_1 (<>) is private; private type Type_1 (Size : Natural) is null record; end Unknown_Discriminant;
with System.Storage_Elements; with System.Debug; -- assertions with C.sys.syscall; with C.unistd; package body System.Stack is pragma Suppress (All_Checks); use type Storage_Elements.Storage_Offset; use type C.signed_int; procedure Get ( Thread : C.pthread.pthread_t := C.pthread.pthread_self; Top, Bottom : out Address) is begin Bottom := Address (C.pthread.pthread_get_stackaddr_np (Thread)); Top := Bottom - Storage_Elements.Storage_Offset ( C.pthread.pthread_get_stacksize_np (Thread)); end Get; procedure Fake_Return_From_Signal_Handler is UC_RESET_ALT_STACK : constant := 16#80000000#; -- ??? R : C.signed_int; begin -- emulate normal return R := C.unistd.syscall ( C.sys.syscall.SYS_sigreturn, C.void_ptr (Null_Address), UC_RESET_ALT_STACK); pragma Check (Debug, Check => not (R < 0) or else Debug.Runtime_Error ( "syscall (SYS_sigreturn, ...) failed")); end Fake_Return_From_Signal_Handler; function Fault_Address (Info : C.signal.siginfo_t) return Address is begin return Address (Info.si_addr); end Fault_Address; end System.Stack;
------------------------------------------------------------------------------- -- package body Disorderly.Basic_Rand, Linear Random Number Generator -- Copyright (C) 1995-2018 Jonathan S. Parker -- -- 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 Text_Utilities; with XOR_Shift; with LCG_Rand; package body Disorderly.Basic_Rand with Spark_Mode => On is package Text_Handling is new Text_Utilities (No_Of_Seeds, Parent_Random_Int); use Text_Handling; package MWC is new LCG_Rand (Parent_Random_Int); use MWC; package Xor_Rand is new XOR_Shift (Parent_Random_Int); use Xor_Rand; -- The state (composed of 3 x 64 bits) is contained in an array of 3 -- 64 bit ints indexed by the following 3 ints: LCG_id_0 : constant State_Index := 0; LCG_id_1 : constant State_Index := 1; Xor_Shift_id : constant State_Index := 2; ---------------- -- Get_Random -- ---------------- -- Get_Random is a combination generator: 2 component generators x, and y -- are combined to produce a generator z whose period is the product of -- the periods of x, and y. z is generated by z = (x + y) mod p, -- where y is full period in range 0..p-1, and the periods of the -- generators for x and y have no prime factors in common. -- Only one of the two generators x and y -- needs to be full-period to guarantee a full-period z. procedure Get_Random (Random_x : out Random_Int; S : in out State) is X1, X2 : Parent_Random_Int; S0, S1 : Parent_Random_Int; begin S0 := S.X(LCG_id_0); S1 := S.X(LCG_id_1); Get_Random_LCG_64_Combined (S0, S1, X1); S.X(LCG_id_0) := S0; S.X(LCG_id_1) := S1; X2 := S.X(XOR_Shift_Id); Get_Random_XOR_Shift_61 (X2); S.X(XOR_Shift_Id) := X2; Random_x := Random_Int ((X1 + X2) mod 2**61); end Get_Random; --subtype Valid_LCG_0_Range is Parent_Random_Int range 1 .. m0 - 1; --subtype Valid_LCG_1_Range is Parent_Random_Int range 1 .. m1 - 1; --subtype Valid_XOR_Shift_Range is Parent_Random_Int range 1 .. 2**61 - 1; function Valid_State (S : in State) return Boolean is Result : constant Boolean := (S.X(LCG_id_0) in Valid_LCG_0_Range) and (S.X(LCG_id_1) in Valid_LCG_1_Range) and (S.X(Xor_Shift_id) in Valid_Xor_Shift_Range); begin return Result; end Valid_State; procedure Make_Correct (S : in out State) is begin if S.X(LCG_id_0) > Valid_LCG_0_Range'Last then S.X(LCG_id_0) := Valid_LCG_0_Range'Last; end if; if S.X(LCG_id_0) < Valid_LCG_0_Range'First then -- Period=1 if = 0 S.X(LCG_id_0) := Valid_LCG_0_Range'First; end if; if S.X(LCG_id_1) > Valid_LCG_1_Range'Last then S.X(LCG_id_1) := Valid_LCG_1_Range'Last; end if; if S.X(LCG_id_1) < Valid_LCG_1_Range'First then -- Period=1 if = 0 S.X(LCG_id_1) := Valid_LCG_1_Range'First; end if; if S.X(Xor_Shift_id) > Valid_Xor_Shift_Range'Last then S.X(Xor_Shift_id) := Valid_Xor_Shift_Range'Last; end if; if S.X(Xor_Shift_id) < Valid_Xor_Shift_Range'First then S.X(Xor_Shift_id) := Valid_Xor_Shift_Range'First; end if; end Make_Correct; ----------- -- Reset -- ----------- -- Step 1. Guarantee that each unique and valid choice -- of the Initiators (Initiator1, Initiator2, .. ) -- produces a unique and valid initial state S: S.X(0), S.X(1), ... -- -- Step 2. Guarantee that a change of 1 bit or more in any one Initiator -- will cause changes in all elements of the initial state S: S.X(0), S.X(1), ... -- procedure Reset (S : out State; Initiator1 : in Seed_Random_Int := 1111; Initiator2 : in Seed_Random_Int := 2222; Initiator3 : in Seed_Random_Int := 3333) is Seeds : Vals := (Initiator1, Initiator2, Initiator3); Cut, Seed : Parent_Random_Int; Cut_Shift_Length : constant Integer := (1 + Bits_per_Random_Number / S.X'Length); -- the transpose requires: pragma Assert (State_Index'First = 0); pragma Assert (S.X'Length < 9); pragma Assert (Bits_per_Random_Number = 61); pragma Assert (Random_Int'Last = 2**Bits_per_Random_Number-1); begin for Keep_Trying in 1 .. 17 loop -- arbitrary loop limit. More is good. -- Step 1: -- Start by transforming each seed with a function -- that is a 1-1 mapping between all elements of 0..2**61-1. -- (0 maps to 0, but is weeded out). for i in State_Index loop Get_Random_XOR_Shift_61_b (Seeds(i)); end loop; -- Step 2: -- Make an N x N matrix out of the N elements of array Seed -- (by breaking each element into N Parts), and transpose it; -- write it to to the state S.X: S.X := (others => 0); for j in State_Index loop Seed := Seeds(j); for i in State_Index loop Cut := Seed mod 2**Cut_Shift_Length; S.X(i) := S.X(i) + Cut * 2**(j*Cut_Shift_Length); Seed := Seed / 2**Cut_Shift_Length; end loop; end loop; -- Scramble the state S.X again: for i in State_Index loop Get_Random_XOR_Shift_61_b (S.X(i)); end loop; Seeds := S.X; -- use the new seeds and scramble again. end loop; -- Notice each S.X is in 0..2^61-1, so have S.X < a0 * b0 - 1 etc. -- Still may have S.X = 0, which gives period of 1 to component generators. -- Step 3: Error Correction. if not Valid_State (S) then Make_Correct (S); end if; end Reset; ----------- -- Value -- ----------- function Value (Coded_State : in State_String) return State is S : State; Seed_1_1st : constant Positive := Coded_State'First; Seed_j_1st : Positive; begin for j in State_Index loop Seed_j_1st := Seed_1_1st + (j-State_Index'First) * Rand_Image_Width; S.X(j) := Value (Coded_State(Seed_j_1st .. Seed_j_1st + Rand_Image_Width - 1)); end loop; return S; end Value; ----------- -- Image -- ----------- function Image (Of_State : State) return State_String is Result : State_String := (others => '0'); Y : Random_Int_String; Seed_1_1st : constant Positive := Result'First; Seed_j_1st : Positive; begin for j in State_Index loop Y := Image (Of_State.X (j)); Seed_j_1st := Seed_1_1st + (j-State_Index'First) * Rand_Image_Width; Result(Seed_j_1st .. Seed_j_1st+Rand_Image_Width-1) := Y; end loop; return Result; end Image; -- Puts a ' ' in front of each 20 digit number. function Formatted_Image_Of (Of_State : State_String) return Formatted_State_String is Result : Formatted_State_String := (others => ' '); Seed_1_1st : constant Positive := Result'First; Seed_y_1st, Seed_j_1st : Positive; Y : Random_Int_String; begin for j in State_Index loop Seed_j_1st := Seed_1_1st + (j-State_Index'First) * (Rand_Image_Width + Leading_Spaces); Seed_y_1st := Seed_1_1st + (j-State_Index'First) * Rand_Image_Width; Y := Of_State(Seed_y_1st .. Seed_y_1st+Rand_Image_Width-1); Result(Seed_j_1st .. Seed_j_1st+Rand_Image_Width-1) := Y; end loop; return Result; end Formatted_Image_Of; function Formatted_Image (Of_State : State) return Formatted_State_String is begin return Formatted_Image_Of (Image (Of_State)); end Formatted_Image; function Are_Equal (State_1, State_2 : State) return Boolean is Result : Boolean := True; begin for i in State_1.X'Range loop if State_1.X(i) /= State_2.X(i) then Result := False; end if; end loop; return Result; end Are_Equal; end Disorderly.Basic_Rand;
-- C36172A.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 CONSTRAINT_ERROR IS RAISED APPROPRIATELY -- ON DISCRETE_RANGES USED AS INDEX_CONSTRAINTS. -- DAT 2/9/81 -- SPS 4/7/82 -- JBG 6/5/85 WITH REPORT; PROCEDURE C36172A IS USE REPORT; SUBTYPE INT_10 IS INTEGER RANGE 1 .. 10; TYPE A IS ARRAY (INT_10 RANGE <> ) OF INTEGER; SUBTYPE INT_11 IS INTEGER RANGE 0 .. 11; SUBTYPE NULL_6_4 IS INTEGER RANGE 6 .. 4; SUBTYPE NULL_11_10 IS INTEGER RANGE 11 .. 10; SUBTYPE INT_9_11 IS INTEGER RANGE 9 .. 11; TYPE A_9_11 IS ARRAY (9..11) OF BOOLEAN; TYPE A_11_10 IS ARRAY (11 .. 10) OF INTEGER; SUBTYPE A_1_10 IS A(INT_10); BEGIN TEST ("C36172A", "CONSTRAINT_ERROR IS RAISED APPROPRIATELY" & " FOR INDEX_RANGES"); BEGIN DECLARE V : A (9 .. 11); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN FAILED ("OUT-OF-BOUNDS INDEX_RANGE 1"); ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION 1"); END; BEGIN DECLARE V : A (11 .. 10); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 2"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 2"); END; BEGIN DECLARE V : A (6 .. 4); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 3"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 3"); END; BEGIN DECLARE V : A (INT_9_11); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN FAILED ("OUT-OF-BOUNDS INDEX RANGE 4"); ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION 4"); END; BEGIN DECLARE V : A (NULL_11_10); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 5"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 5"); END; BEGIN DECLARE V : A (NULL_6_4); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 6"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 6"); END; BEGIN DECLARE V : A (INT_9_11 RANGE 10 .. 11); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN FAILED ("BAD NON-NULL INDEX RANGE 7"); ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION 7"); END; BEGIN DECLARE V : A (NULL_11_10 RANGE 11 .. 10); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 8"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 8"); END; BEGIN DECLARE V : A (NULL_6_4 RANGE 6 .. 4); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 9"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 9"); END; BEGIN DECLARE V : A (A_9_11'RANGE); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN FAILED ("BAD INDEX RANGE 10"); ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("WRONG EXCEPTION 10"); END; BEGIN DECLARE V : A (A_11_10'RANGE); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 11"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 11"); END; BEGIN DECLARE V : A (6 .. 4); BEGIN IF EQUAL (V'FIRST, V'FIRST) THEN NULL; ELSE FAILED ("IMPOSSIBLE"); END IF; END; EXCEPTION WHEN CONSTRAINT_ERROR => FAILED ("CONSTRAINT_ERROR " & "RAISED INAPPROPRIATELY 12"); WHEN OTHERS => FAILED ("EXCEPTION RAISED WHEN NONE " & "SHOULD BE 12"); END; RESULT; END C36172A;
-- { dg-do run } with System; use System; procedure SSO3 is Rev_SSO : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (Default_Bit_Order)); type R (D : Integer) is record Common : Integer; case D is when 0 => V1 : Integer; when others => V2 : Integer; end case; end record; for R use record D at 0 range 0 .. 31; V1 at 4 range 0 .. 31; V2 at 4 range 0 .. 31; Common at 8 range 0 .. 31; end record; for R'Scalar_Storage_Order use Rev_SSO; for R'Bit_Order use Rev_SSO; procedure Check (Common, V : Integer; X : R) is begin if Common /= X.Common then raise Program_Error; end if; case X.D is when 0 => if V /= X.V1 then raise Program_Error; end if; when others => if V /= X.V2 then raise Program_Error; end if; end case; end Check; X0 : R := (D => 0, Common => 1111, V1 => 1234); X1 : R := (D => 31337, Common => 2222, V2 => 5678); begin Check (1111, 1234, X0); Check (2222, 5678, X1); end;
-- { dg-do run { target i?86-*-* x86_64-*-* } } -- { dg-options "-O1 -msse" } -- { dg-require-effective-target sse_runtime } with Ada.Unchecked_Conversion; procedure SSE_Nolib is -- Base vector type definitions package SSE_Types is VECTOR_ALIGN : constant := 16; VECTOR_BYTES : constant := 16; type m128 is private; private type m128 is array (1 .. 4) of Float; for m128'Alignment use VECTOR_ALIGN; pragma Machine_Attribute (m128, "vector_type"); pragma Machine_Attribute (m128, "may_alias"); end SSE_Types; use SSE_Types; -- Core operations function mm_add_ss (A, B : m128) return m128; pragma Import (Intrinsic, mm_add_ss, "__builtin_ia32_addss"); -- User views / conversions or overlays type Vf32_View is array (1 .. 4) of Float; for Vf32_View'Alignment use VECTOR_ALIGN; function To_m128 is new Ada.Unchecked_Conversion (Vf32_View, m128); function To_m128 is new Ada.Unchecked_Conversion (m128, Vf32_View); X, Y, Z : M128; Vz : Vf32_View; for Vz'Address use Z'Address; begin X := To_m128 ((1.0, 1.0, 2.0, 2.0)); Y := To_m128 ((2.0, 2.0, 1.0, 1.0)); Z := mm_add_ss (X, Y); if Vz /= (3.0, 1.0, 2.0, 2.0) then raise Program_Error; end if; end SSE_Nolib;
with Ada.Text_IO; use Ada.Text_IO; procedure Oups is V : Integer := 0; begin if 1 / V = 1 then New_Line; end if; end;
----------------------------------------------------------------------- -- Security-oayth-jwt-tests - Unit tests for JSON Web Token -- Copyright (C) 2013, 2015 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.Calendar.Formatting; with Util.Test_Caller; package body Security.OAuth.JWT.Tests is package Caller is new Util.Test_Caller (Test, "Security.OAuth.JWT"); -- A JWT token returned by Google+. K : constant String := "eyJhbGciOiJSUzI1NiIsImtpZCI6IjVmOTBlMWExMGE4YzgwZWJhZWNmYzM4NzBjZDl" & "lMGVhMGI3ZDVmZGMifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXRfaGFzaCI6Im9Ka19EYnFvb1" & "FVc0FhY3k2cnkxeHciLCJhdWQiOiI4NzI2NTU5OTQwMTQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJz" & "dWIiOiIxMDgzNjA3MDMwOTk3MDg5Nzg4NzAiLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJhenAiOiI4NzI2NT" & "U5OTQwMTQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJlbWFpbCI6InN0ZXBoYW5lLmNhcnJlekBnbWFp" & "bC5jb20iLCJpYXQiOjEzNjg5NjgyMzMsImV4cCI6MTM2ODk3MjEzM30.UL1qp2wmleV-ED2A_hlqgDLIGgJB3f" & "_N7fiz1CgttJcwbmMVwhag3ox2WE9C1KwXhrjwT8eigZ0WkDys5WO1dYs2G1QbDZPnsYYMyHK9XpycaDMEKtVZ" & "C4C6DkB1SrBHbN0Tv6ExWpszzp1JEL8nZnHd3T_AA3paqONnkvQw_yo"; procedure Test_Operation (T : in out Test) is R : Token; begin R := Decode (K); Util.Tests.Assert_Equals (T, Value, Get (R), "Extraction failed"); end Test_Operation; procedure Test_Time_Operation (T : in out Test) is R : Token; begin R := Decode (K); Util.Tests.Assert_Equals (T, Value, Ada.Calendar.Formatting.Image (Get (R)), "Extraction failed"); end Test_Time_Operation; procedure Test_Get_Issuer is new Test_Operation (Get_Issuer, "accounts.google.com"); procedure Test_Get_Audience is new Test_Operation (Get_Audience, "872655994014.apps.googleusercontent.com"); procedure Test_Get_Subject is new Test_Operation (Get_Subject, "108360703099708978870"); procedure Test_Get_Authorized_Presenters is new Test_Operation (Get_Authorized_Presenters, "872655994014.apps.googleusercontent.com"); procedure Test_Get_Expiration is new Test_Time_Operation (Get_Expiration, "2013-05-19 14:02:13"); procedure Test_Get_Issued_At is new Test_Time_Operation (Get_Issued_At, "2013-05-19 12:57:13"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Decode", Test_Get_Issuer'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Get_Issuer", Test_Get_Issuer'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Get_Audience", Test_Get_Audience'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Get_Subject", Test_Get_Subject'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Get_Authorized_Presenters", Test_Get_Authorized_Presenters'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Get_Expiration", Test_Get_Expiration'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Get_Authentication_Time", Test_Get_Issued_At'Access); Caller.Add_Test (Suite, "Test Security.OAuth.JWT.Decode (error)", Test_Decode_Error'Access); end Add_Tests; -- ------------------------------ -- Test Decode operation with errors. -- ------------------------------ procedure Test_Decode_Error (T : in out Test) is K : constant String := "eyJhbxGciOiJSUzI1NiIsImtpZCI6IjVmOTBlMWExMGE4YzgwZWJhZWNmYzM4NzBjZDl" & "lMGVhMGI3ZDVmZGMifQ.eyJpc3xMiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXRfaGFzaCI6Im9Ka19EYnFvb1" & "FVc0FhY3k2cnkxeHciLCJhdWQiOiI4NzI2NTU5OTQwMTQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJz" & "dWIiOiIxMDgzNjA3MDMwOTk3MDg5Nzg4NzAiLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJhenAiOiI4NzI2NT" & "U5OTQwMTQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJlbWFpbCI6InN0ZXBoYW5lLmNhcnJlekBnbWFp" & "bC5jb20iLCJpYXQiOjEzNjg5NjgyMzMsImV4cCI6MTM2ODk3MjEzM30.UL1qp2wmleV-ED2A_hlqgDLIGgJB3f" & "_N7fiz1CgttJcwbmMVwhag3ox2WE9C1KwXhrjwT8eigZ0WkDys5WO1dYs2G1QbDZPnsYYMyHK9XpycaDMEKtVZ" & "C4C6DkB1SrBHbN0Tv6ExWpszzp1JEL8nZnHd3T_AA3paqONnkvQw_yx"; R : Token; pragma Unreferenced (R); begin R := Decode (K); T.Fail ("No exception raised"); T.Assert (False, "Bad"); exception when Invalid_Token => null; end Test_Decode_Error; end Security.OAuth.JWT.Tests;
generic type Real is digits <>; package Generic_Quaternions is type Quaternion is record W : Real; X : Real; Y : Real; Z : Real; end record; function "-" (Q : Quaternion) return Quaternion; function "+" (L, R : Quaternion) return Quaternion; function "-" (L, R : Quaternion) return Quaternion; function "*" (L : Quaternion; R : Real) return Quaternion; function "*" (L : Real; R : Quaternion) return Quaternion; function "*" (L : Quaternion; R : Quaternion) return Quaternion; function "/" (L : Quaternion; R : Real) return Quaternion; function Conjugate (Q : Quaternion) return Quaternion; function Norm (Q : Quaternion) return Real; function Normalize (Q : Quaternion) return Quaternion; end Generic_Quaternions;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ R E S -- -- -- -- 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 Checks; use Checks; with Debug; use Debug; with Debug_A; use Debug_A; with Einfo; use Einfo; with Errout; use Errout; with Expander; use Expander; with Exp_Ch7; use Exp_Ch7; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; with Namet; use Namet; with Nmake; use Nmake; with Nlists; use Nlists; with Opt; use Opt; with Output; use Output; with Restrict; use Restrict; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aggr; use Sem_Aggr; with Sem_Attr; use Sem_Attr; with Sem_Cat; use Sem_Cat; with Sem_Ch4; use Sem_Ch4; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; with Sem_Disp; use Sem_Disp; with Sem_Dist; use Sem_Dist; with Sem_Elab; use Sem_Elab; with Sem_Eval; use Sem_Eval; with Sem_Intr; use Sem_Intr; with Sem_Util; use Sem_Util; with Sem_Type; use Sem_Type; with Sem_Warn; use Sem_Warn; with Sinfo; use Sinfo; with Stand; use Stand; with Stringt; use Stringt; with Targparm; use Targparm; with Tbuild; use Tbuild; with Uintp; use Uintp; with Urealp; use Urealp; package body Sem_Res is ----------------------- -- Local Subprograms -- ----------------------- -- Second pass (top-down) type checking and overload resolution procedures -- Typ is the type required by context. These procedures propagate the -- type information recursively to the descendants of N. If the node -- is not overloaded, its Etype is established in the first pass. If -- overloaded, the Resolve routines set the correct type. For arith. -- operators, the Etype is the base type of the context. -- Note that Resolve_Attribute is separated off in Sem_Attr procedure Ambiguous_Character (C : Node_Id); -- Give list of candidate interpretations when a character literal cannot -- be resolved. procedure Check_Discriminant_Use (N : Node_Id); -- Enforce the restrictions on the use of discriminants when constraining -- a component of a discriminated type (record or concurrent type). procedure Check_For_Visible_Operator (N : Node_Id; T : Entity_Id); -- Given a node for an operator associated with type T, check that -- the operator is visible. Operators all of whose operands are -- universal must be checked for visibility during resolution -- because their type is not determinable based on their operands. function Check_Infinite_Recursion (N : Node_Id) return Boolean; -- Given a call node, N, which is known to occur immediately within the -- subprogram being called, determines whether it is a detectable case of -- an infinite recursion, and if so, outputs appropriate messages. Returns -- True if an infinite recursion is detected, and False otherwise. procedure Check_Initialization_Call (N : Entity_Id; Nam : Entity_Id); -- If the type of the object being initialized uses the secondary stack -- directly or indirectly, create a transient scope for the call to the -- Init_Proc. This is because we do not create transient scopes for the -- initialization of individual components within the init_proc itself. -- Could be optimized away perhaps? function Is_Predefined_Op (Nam : Entity_Id) return Boolean; -- Utility to check whether the name in the call is a predefined -- operator, in which case the call is made into an operator node. -- An instance of an intrinsic conversion operation may be given -- an operator name, but is not treated like an operator. procedure Replace_Actual_Discriminants (N : Node_Id; Default : Node_Id); -- If a default expression in entry call N depends on the discriminants -- of the task, it must be replaced with a reference to the discriminant -- of the task being called. procedure Resolve_Allocator (N : Node_Id; Typ : Entity_Id); procedure Resolve_Arithmetic_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Call (N : Node_Id; Typ : Entity_Id); procedure Resolve_Character_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Comparison_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Conditional_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Equality_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Explicit_Dereference (N : Node_Id; Typ : Entity_Id); procedure Resolve_Entity_Name (N : Node_Id; Typ : Entity_Id); procedure Resolve_Indexed_Component (N : Node_Id; Typ : Entity_Id); procedure Resolve_Integer_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Logical_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Membership_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Null (N : Node_Id; Typ : Entity_Id); procedure Resolve_Operator_Symbol (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Concat (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Expon (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Not (N : Node_Id; Typ : Entity_Id); procedure Resolve_Qualified_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Range (N : Node_Id; Typ : Entity_Id); procedure Resolve_Real_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Reference (N : Node_Id; Typ : Entity_Id); procedure Resolve_Selected_Component (N : Node_Id; Typ : Entity_Id); procedure Resolve_Shift (N : Node_Id; Typ : Entity_Id); procedure Resolve_Short_Circuit (N : Node_Id; Typ : Entity_Id); procedure Resolve_Slice (N : Node_Id; Typ : Entity_Id); procedure Resolve_String_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Subprogram_Info (N : Node_Id; Typ : Entity_Id); procedure Resolve_Type_Conversion (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unary_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unchecked_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unchecked_Type_Conversion (N : Node_Id; Typ : Entity_Id); function Operator_Kind (Op_Name : Name_Id; Is_Binary : Boolean) return Node_Kind; -- Utility to map the name of an operator into the corresponding Node. Used -- by other node rewriting procedures. procedure Resolve_Actuals (N : Node_Id; Nam : Entity_Id); -- Resolve actuals of call, and add default expressions for missing ones. procedure Resolve_Entry_Call (N : Node_Id; Typ : Entity_Id); -- Called from Resolve_Call, when the prefix denotes an entry or element -- of entry family. Actuals are resolved as for subprograms, and the node -- is rebuilt as an entry call. Also called for protected operations. Typ -- is the context type, which is used when the operation is a protected -- function with no arguments, and the return value is indexed. procedure Resolve_Intrinsic_Operator (N : Node_Id; Typ : Entity_Id); -- A call to a user-defined intrinsic operator is rewritten as a call -- to the corresponding predefined operator, with suitable conversions. procedure Rewrite_Operator_As_Call (N : Node_Id; Nam : Entity_Id); -- If an operator node resolves to a call to a user-defined operator, -- rewrite the node as a function call. procedure Make_Call_Into_Operator (N : Node_Id; Typ : Entity_Id; Op_Id : Entity_Id); -- Inverse transformation: if an operator is given in functional notation, -- then after resolving the node, transform into an operator node, so -- that operands are resolved properly. Recall that predefined operators -- do not have a full signature and special resolution rules apply. procedure Rewrite_Renamed_Operator (N : Node_Id; Op : Entity_Id); -- An operator can rename another, e.g. in an instantiation. In that -- case, the proper operator node must be constructed. procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id); -- The String_Literal_Subtype is built for all strings that are not -- operands of a static concatenation operation. If the argument is not -- a String the function is a no-op. procedure Set_Slice_Subtype (N : Node_Id); -- Build subtype of array type, with the range specified by the slice. function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id; -- A universal_fixed expression in an universal context is unambiguous if -- there is only one applicable fixed point type. Determining whether -- there is only one requires a search over all visible entities, and -- happens only in very pathological cases (see 6115-006). function Valid_Conversion (N : Node_Id; Target : Entity_Id; Operand : Node_Id) return Boolean; -- Verify legality rules given in 4.6 (8-23). Target is the target -- type of the conversion, which may be an implicit conversion of -- an actual parameter to an anonymous access type (in which case -- N denotes the actual parameter and N = Operand). ------------------------- -- Ambiguous_Character -- ------------------------- procedure Ambiguous_Character (C : Node_Id) is E : Entity_Id; begin if Nkind (C) = N_Character_Literal then Error_Msg_N ("ambiguous character literal", C); Error_Msg_N ("\possible interpretations: Character, Wide_Character!", C); E := Current_Entity (C); if Present (E) then while Present (E) loop Error_Msg_NE ("\possible interpretation:}!", C, Etype (E)); E := Homonym (E); end loop; end if; end if; end Ambiguous_Character; ------------------------- -- Analyze_And_Resolve -- ------------------------- procedure Analyze_And_Resolve (N : Node_Id) is begin Analyze (N); Resolve (N, Etype (N)); end Analyze_And_Resolve; procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id) is begin Analyze (N); Resolve (N, Typ); end Analyze_And_Resolve; -- Version withs check(s) suppressed procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id) is Scop : Entity_Id := Current_Scope; begin if Suppress = All_Checks then declare Svg : constant Suppress_Record := Scope_Suppress; begin Scope_Suppress := (others => True); Analyze_And_Resolve (N, Typ); Scope_Suppress := Svg; end; else declare Svg : constant Boolean := Get_Scope_Suppress (Suppress); begin Set_Scope_Suppress (Suppress, True); Analyze_And_Resolve (N, Typ); Set_Scope_Suppress (Suppress, Svg); end; end if; if Current_Scope /= Scop and then Scope_Is_Transient then -- This can only happen if a transient scope was created -- for an inner expression, which will be removed upon -- completion of the analysis of an enclosing construct. -- The transient scope must have the suppress status of -- the enclosing environment, not of this Analyze call. Scope_Stack.Table (Scope_Stack.Last).Save_Scope_Suppress := Scope_Suppress; end if; end Analyze_And_Resolve; procedure Analyze_And_Resolve (N : Node_Id; Suppress : Check_Id) is Scop : Entity_Id := Current_Scope; begin if Suppress = All_Checks then declare Svg : constant Suppress_Record := Scope_Suppress; begin Scope_Suppress := (others => True); Analyze_And_Resolve (N); Scope_Suppress := Svg; end; else declare Svg : constant Boolean := Get_Scope_Suppress (Suppress); begin Set_Scope_Suppress (Suppress, True); Analyze_And_Resolve (N); Set_Scope_Suppress (Suppress, Svg); end; end if; if Current_Scope /= Scop and then Scope_Is_Transient then Scope_Stack.Table (Scope_Stack.Last).Save_Scope_Suppress := Scope_Suppress; end if; end Analyze_And_Resolve; ---------------------------- -- Check_Discriminant_Use -- ---------------------------- procedure Check_Discriminant_Use (N : Node_Id) is PN : constant Node_Id := Parent (N); Disc : constant Entity_Id := Entity (N); P : Node_Id; D : Node_Id; begin -- Any use in a default expression is legal. if In_Default_Expression then null; elsif Nkind (PN) = N_Range then -- Discriminant cannot be used to constrain a scalar type. P := Parent (PN); if Nkind (P) = N_Range_Constraint and then Nkind (Parent (P)) = N_Subtype_Indication and then Nkind (Parent (Parent (P))) = N_Component_Declaration then Error_Msg_N ("discriminant cannot constrain scalar type", N); elsif Nkind (P) = N_Index_Or_Discriminant_Constraint then -- The following check catches the unusual case where -- a discriminant appears within an index constraint -- that is part of a larger expression within a constraint -- on a component, e.g. "C : Int range 1 .. F (new A(1 .. D))". -- For now we only check case of record components, and -- note that a similar check should also apply in the -- case of discriminant constraints below. ??? -- Note that the check for N_Subtype_Declaration below is to -- detect the valid use of discriminants in the constraints of a -- subtype declaration when this subtype declaration appears -- inside the scope of a record type (which is syntactically -- illegal, but which may be created as part of derived type -- processing for records). See Sem_Ch3.Build_Derived_Record_Type -- for more info. if Ekind (Current_Scope) = E_Record_Type and then Scope (Disc) = Current_Scope and then not (Nkind (Parent (P)) = N_Subtype_Indication and then (Nkind (Parent (Parent (P))) = N_Component_Declaration or else Nkind (Parent (Parent (P))) = N_Subtype_Declaration) and then Paren_Count (N) = 0) then Error_Msg_N ("discriminant must appear alone in component constraint", N); return; end if; -- Detect a common beginner error: -- type R (D : Positive := 100) is record -- Name: String (1 .. D); -- end record; -- The default value causes an object of type R to be -- allocated with room for Positive'Last characters. declare SI : Node_Id; T : Entity_Id; TB : Node_Id; CB : Entity_Id; function Large_Storage_Type (T : Entity_Id) return Boolean; -- Return True if type T has a large enough range that -- any array whose index type covered the whole range of -- the type would likely raise Storage_Error. function Large_Storage_Type (T : Entity_Id) return Boolean is begin return T = Standard_Integer or else T = Standard_Positive or else T = Standard_Natural; end Large_Storage_Type; begin -- Check that the Disc has a large range if not Large_Storage_Type (Etype (Disc)) then goto No_Danger; end if; -- If the enclosing type is limited, we allocate only the -- default value, not the maximum, and there is no need for -- a warning. if Is_Limited_Type (Scope (Disc)) then goto No_Danger; end if; -- Check that it is the high bound if N /= High_Bound (PN) or else not Present (Discriminant_Default_Value (Disc)) then goto No_Danger; end if; -- Check the array allows a large range at this bound. -- First find the array SI := Parent (P); if Nkind (SI) /= N_Subtype_Indication then goto No_Danger; end if; T := Entity (Subtype_Mark (SI)); if not Is_Array_Type (T) then goto No_Danger; end if; -- Next, find the dimension TB := First_Index (T); CB := First (Constraints (P)); while True and then Present (TB) and then Present (CB) and then CB /= PN loop Next_Index (TB); Next (CB); end loop; if CB /= PN then goto No_Danger; end if; -- Now, check the dimension has a large range if not Large_Storage_Type (Etype (TB)) then goto No_Danger; end if; -- Warn about the danger Error_Msg_N ("creation of object of this type may raise Storage_Error?", N); <<No_Danger>> null; end; end if; -- Legal case is in index or discriminant constraint elsif Nkind (PN) = N_Index_Or_Discriminant_Constraint or else Nkind (PN) = N_Discriminant_Association then if Paren_Count (N) > 0 then Error_Msg_N ("discriminant in constraint must appear alone", N); end if; return; -- Otherwise, context is an expression. It should not be within -- (i.e. a subexpression of) a constraint for a component. else D := PN; P := Parent (PN); while Nkind (P) /= N_Component_Declaration and then Nkind (P) /= N_Subtype_Indication and then Nkind (P) /= N_Entry_Declaration loop D := P; P := Parent (P); exit when No (P); end loop; -- If the discriminant is used in an expression that is a bound -- of a scalar type, an Itype is created and the bounds are attached -- to its range, not to the original subtype indication. Such use -- is of course a double fault. if (Nkind (P) = N_Subtype_Indication and then (Nkind (Parent (P)) = N_Component_Declaration or else Nkind (Parent (P)) = N_Derived_Type_Definition) and then D = Constraint (P)) -- The constraint itself may be given by a subtype indication, -- rather than by a more common discrete range. or else (Nkind (P) = N_Subtype_Indication and then Nkind (Parent (P)) = N_Index_Or_Discriminant_Constraint) or else Nkind (P) = N_Entry_Declaration or else Nkind (D) = N_Defining_Identifier then Error_Msg_N ("discriminant in constraint must appear alone", N); end if; end if; end Check_Discriminant_Use; -------------------------------- -- Check_For_Visible_Operator -- -------------------------------- procedure Check_For_Visible_Operator (N : Node_Id; T : Entity_Id) is Orig_Node : Node_Id := Original_Node (N); begin if Comes_From_Source (Orig_Node) and then not In_Open_Scopes (Scope (T)) and then not Is_Potentially_Use_Visible (T) and then not In_Use (T) and then not In_Use (Scope (T)) and then (not Present (Entity (N)) or else Ekind (Entity (N)) /= E_Function) and then (Nkind (Orig_Node) /= N_Function_Call or else Nkind (Name (Orig_Node)) /= N_Expanded_Name or else Entity (Prefix (Name (Orig_Node))) /= Scope (T)) and then not In_Instance then Error_Msg_NE ("operator for} is not directly visible!", N, First_Subtype (T)); Error_Msg_N ("use clause would make operation legal!", N); end if; end Check_For_Visible_Operator; ------------------------------ -- Check_Infinite_Recursion -- ------------------------------ function Check_Infinite_Recursion (N : Node_Id) return Boolean is P : Node_Id; C : Node_Id; begin -- Loop moving up tree, quitting if something tells us we are -- definitely not in an infinite recursion situation. C := N; loop P := Parent (C); exit when Nkind (P) = N_Subprogram_Body; if Nkind (P) = N_Or_Else or else Nkind (P) = N_And_Then or else Nkind (P) = N_If_Statement or else Nkind (P) = N_Case_Statement then return False; elsif Nkind (P) = N_Handled_Sequence_Of_Statements and then C /= First (Statements (P)) then return False; else C := P; end if; end loop; Warn_On_Instance := True; Error_Msg_N ("possible infinite recursion?", N); Error_Msg_N ("\Storage_Error may be raised at run time?", N); Warn_On_Instance := False; return True; end Check_Infinite_Recursion; ------------------------------- -- Check_Initialization_Call -- ------------------------------- procedure Check_Initialization_Call (N : Entity_Id; Nam : Entity_Id) is Typ : Entity_Id := Etype (First_Formal (Nam)); function Uses_SS (T : Entity_Id) return Boolean; function Uses_SS (T : Entity_Id) return Boolean is Comp : Entity_Id; Expr : Node_Id; begin if Is_Controlled (T) or else Has_Controlled_Component (T) or else Functions_Return_By_DSP_On_Target then return False; elsif Is_Array_Type (T) then return Uses_SS (Component_Type (T)); elsif Is_Record_Type (T) then Comp := First_Component (T); while Present (Comp) loop if Ekind (Comp) = E_Component and then Nkind (Parent (Comp)) = N_Component_Declaration then Expr := Expression (Parent (Comp)); if Nkind (Expr) = N_Function_Call and then Requires_Transient_Scope (Etype (Expr)) then return True; elsif Uses_SS (Etype (Comp)) then return True; end if; end if; Next_Component (Comp); end loop; return False; else return False; end if; end Uses_SS; begin if Uses_SS (Typ) then Establish_Transient_Scope (First_Actual (N), Sec_Stack => True); end if; end Check_Initialization_Call; ------------------------------ -- Check_Parameterless_Call -- ------------------------------ procedure Check_Parameterless_Call (N : Node_Id) is Nam : Node_Id; begin if Nkind (N) in N_Has_Etype and then Etype (N) = Any_Type then return; end if; -- Rewrite as call if overloadable entity that is (or could be, in -- the overloaded case) a function call. If we know for sure that -- the entity is an enumeration literal, we do not rewrite it. if (Is_Entity_Name (N) and then Is_Overloadable (Entity (N)) and then (Ekind (Entity (N)) /= E_Enumeration_Literal or else Is_Overloaded (N))) -- Rewrite as call if it is an explicit deference of an expression of -- a subprogram access type, and the suprogram type is not that of a -- procedure or entry. or else (Nkind (N) = N_Explicit_Dereference and then Ekind (Etype (N)) = E_Subprogram_Type and then Base_Type (Etype (Etype (N))) /= Standard_Void_Type) -- Rewrite as call if it is a selected component which is a function, -- this is the case of a call to a protected function (which may be -- overloaded with other protected operations). or else (Nkind (N) = N_Selected_Component and then (Ekind (Entity (Selector_Name (N))) = E_Function or else ((Ekind (Entity (Selector_Name (N))) = E_Entry or else Ekind (Entity (Selector_Name (N))) = E_Procedure) and then Is_Overloaded (Selector_Name (N))))) -- If one of the above three conditions is met, rewrite as call. -- Apply the rewriting only once. then if Nkind (Parent (N)) /= N_Function_Call or else N /= Name (Parent (N)) then Nam := New_Copy (N); -- If overloaded, overload set belongs to new copy. Save_Interps (N, Nam); -- Change node to parameterless function call (note that the -- Parameter_Associations associations field is left set to Empty, -- its normal default value since there are no parameters) Change_Node (N, N_Function_Call); Set_Name (N, Nam); Set_Sloc (N, Sloc (Nam)); Analyze_Call (N); end if; elsif Nkind (N) = N_Parameter_Association then Check_Parameterless_Call (Explicit_Actual_Parameter (N)); end if; end Check_Parameterless_Call; ---------------------- -- Is_Predefined_Op -- ---------------------- function Is_Predefined_Op (Nam : Entity_Id) return Boolean is begin return Is_Intrinsic_Subprogram (Nam) and then not Is_Generic_Instance (Nam) and then Chars (Nam) in Any_Operator_Name and then (No (Alias (Nam)) or else Is_Predefined_Op (Alias (Nam))); end Is_Predefined_Op; ----------------------------- -- Make_Call_Into_Operator -- ----------------------------- procedure Make_Call_Into_Operator (N : Node_Id; Typ : Entity_Id; Op_Id : Entity_Id) is Op_Name : constant Name_Id := Chars (Op_Id); Act1 : Node_Id := First_Actual (N); Act2 : Node_Id := Next_Actual (Act1); Error : Boolean := False; Is_Binary : constant Boolean := Present (Act2); Op_Node : Node_Id; Opnd_Type : Entity_Id; Orig_Type : Entity_Id := Empty; Pack : Entity_Id; type Kind_Test is access function (E : Entity_Id) return Boolean; function Is_Definite_Access_Type (E : Entity_Id) return Boolean; -- Determine whether E is an access type declared by an access decla- -- ration, and not an (anonymous) allocator type. function Operand_Type_In_Scope (S : Entity_Id) return Boolean; -- If the operand is not universal, and the operator is given by a -- expanded name, verify that the operand has an interpretation with -- a type defined in the given scope of the operator. function Type_In_P (Test : Kind_Test) return Entity_Id; -- Find a type of the given class in the package Pack that contains -- the operator. ----------------------------- -- Is_Definite_Access_Type -- ----------------------------- function Is_Definite_Access_Type (E : Entity_Id) return Boolean is Btyp : constant Entity_Id := Base_Type (E); begin return Ekind (Btyp) = E_Access_Type or else (Ekind (Btyp) = E_Access_Subprogram_Type and then Comes_From_Source (Btyp)); end Is_Definite_Access_Type; --------------------------- -- Operand_Type_In_Scope -- --------------------------- function Operand_Type_In_Scope (S : Entity_Id) return Boolean is Nod : constant Node_Id := Right_Opnd (Op_Node); I : Interp_Index; It : Interp; begin if not Is_Overloaded (Nod) then return Scope (Base_Type (Etype (Nod))) = S; else Get_First_Interp (Nod, I, It); while Present (It.Typ) loop if Scope (Base_Type (It.Typ)) = S then return True; end if; Get_Next_Interp (I, It); end loop; return False; end if; end Operand_Type_In_Scope; --------------- -- Type_In_P -- --------------- function Type_In_P (Test : Kind_Test) return Entity_Id is E : Entity_Id; function In_Decl return Boolean; -- Verify that node is not part of the type declaration for the -- candidate type, which would otherwise be invisible. ------------- -- In_Decl -- ------------- function In_Decl return Boolean is Decl_Node : constant Node_Id := Parent (E); N2 : Node_Id; begin N2 := N; if Etype (E) = Any_Type then return True; elsif No (Decl_Node) then return False; else while Present (N2) and then Nkind (N2) /= N_Compilation_Unit loop if N2 = Decl_Node then return True; else N2 := Parent (N2); end if; end loop; return False; end if; end In_Decl; -- Start of processing for Type_In_P begin -- If the context type is declared in the prefix package, this -- is the desired base type. if Scope (Base_Type (Typ)) = Pack and then Test (Typ) then return Base_Type (Typ); else E := First_Entity (Pack); while Present (E) loop if Test (E) and then not In_Decl then return E; end if; Next_Entity (E); end loop; return Empty; end if; end Type_In_P; --------------------------- -- Operand_Type_In_Scope -- --------------------------- -- Start of processing for Make_Call_Into_Operator begin Op_Node := New_Node (Operator_Kind (Op_Name, Is_Binary), Sloc (N)); -- Binary operator if Is_Binary then Set_Left_Opnd (Op_Node, Relocate_Node (Act1)); Set_Right_Opnd (Op_Node, Relocate_Node (Act2)); Save_Interps (Act1, Left_Opnd (Op_Node)); Save_Interps (Act2, Right_Opnd (Op_Node)); Act1 := Left_Opnd (Op_Node); Act2 := Right_Opnd (Op_Node); -- Unary operator else Set_Right_Opnd (Op_Node, Relocate_Node (Act1)); Save_Interps (Act1, Right_Opnd (Op_Node)); Act1 := Right_Opnd (Op_Node); end if; -- If the operator is denoted by an expanded name, and the prefix is -- not Standard, but the operator is a predefined one whose scope is -- Standard, then this is an implicit_operator, inserted as an -- interpretation by the procedure of the same name. This procedure -- overestimates the presence of implicit operators, because it does -- not examine the type of the operands. Verify now that the operand -- type appears in the given scope. If right operand is universal, -- check the other operand. In the case of concatenation, either -- argument can be the component type, so check the type of the result. -- If both arguments are literals, look for a type of the right kind -- defined in the given scope. This elaborate nonsense is brought to -- you courtesy of b33302a. The type itself must be frozen, so we must -- find the type of the proper class in the given scope. -- A final wrinkle is the multiplication operator for fixed point -- types, which is defined in Standard only, and not in the scope of -- the fixed_point type itself. if Nkind (Name (N)) = N_Expanded_Name then Pack := Entity (Prefix (Name (N))); -- If the entity being called is defined in the given package, -- it is a renaming of a predefined operator, and known to be -- legal. if Scope (Entity (Name (N))) = Pack and then Pack /= Standard_Standard then null; elsif (Op_Name = Name_Op_Multiply or else Op_Name = Name_Op_Divide) and then Is_Fixed_Point_Type (Etype (Left_Opnd (Op_Node))) and then Is_Fixed_Point_Type (Etype (Right_Opnd (Op_Node))) then if Pack /= Standard_Standard then Error := True; end if; else Opnd_Type := Base_Type (Etype (Right_Opnd (Op_Node))); if Op_Name = Name_Op_Concat then Opnd_Type := Base_Type (Typ); elsif (Scope (Opnd_Type) = Standard_Standard and then Is_Binary) or else (Nkind (Right_Opnd (Op_Node)) = N_Attribute_Reference and then Is_Binary and then not Comes_From_Source (Opnd_Type)) then Opnd_Type := Base_Type (Etype (Left_Opnd (Op_Node))); end if; if Scope (Opnd_Type) = Standard_Standard then -- Verify that the scope contains a type that corresponds to -- the given literal. Optimize the case where Pack is Standard. if Pack /= Standard_Standard then if Opnd_Type = Universal_Integer then Orig_Type := Type_In_P (Is_Integer_Type'Access); elsif Opnd_Type = Universal_Real then Orig_Type := Type_In_P (Is_Real_Type'Access); elsif Opnd_Type = Any_String then Orig_Type := Type_In_P (Is_String_Type'Access); elsif Opnd_Type = Any_Access then Orig_Type := Type_In_P (Is_Definite_Access_Type'Access); elsif Opnd_Type = Any_Composite then Orig_Type := Type_In_P (Is_Composite_Type'Access); if Present (Orig_Type) then if Has_Private_Component (Orig_Type) then Orig_Type := Empty; else Set_Etype (Act1, Orig_Type); if Is_Binary then Set_Etype (Act2, Orig_Type); end if; end if; end if; else Orig_Type := Empty; end if; Error := No (Orig_Type); end if; elsif Ekind (Opnd_Type) = E_Allocator_Type and then No (Type_In_P (Is_Definite_Access_Type'Access)) then Error := True; -- If the type is defined elsewhere, and the operator is not -- defined in the given scope (by a renaming declaration, e.g.) -- then this is an error as well. If an extension of System is -- present, and the type may be defined there, Pack must be -- System itself. elsif Scope (Opnd_Type) /= Pack and then Scope (Op_Id) /= Pack and then (No (System_Aux_Id) or else Scope (Opnd_Type) /= System_Aux_Id or else Pack /= Scope (System_Aux_Id)) then Error := True; elsif Pack = Standard_Standard and then not Operand_Type_In_Scope (Standard_Standard) then Error := True; end if; end if; if Error then Error_Msg_Node_2 := Pack; Error_Msg_NE ("& not declared in&", N, Selector_Name (Name (N))); Set_Etype (N, Any_Type); return; end if; end if; Set_Chars (Op_Node, Op_Name); Set_Etype (Op_Node, Base_Type (Etype (N))); Set_Entity (Op_Node, Op_Id); Generate_Reference (Op_Id, N, ' '); Rewrite (N, Op_Node); Resolve (N, Typ); -- For predefined operators on literals, the operation freezes -- their type. if Present (Orig_Type) then Set_Etype (Act1, Orig_Type); Freeze_Expression (Act1); end if; end Make_Call_Into_Operator; ------------------- -- Operator_Kind -- ------------------- function Operator_Kind (Op_Name : Name_Id; Is_Binary : Boolean) return Node_Kind is Kind : Node_Kind; begin if Is_Binary then if Op_Name = Name_Op_And then Kind := N_Op_And; elsif Op_Name = Name_Op_Or then Kind := N_Op_Or; elsif Op_Name = Name_Op_Xor then Kind := N_Op_Xor; elsif Op_Name = Name_Op_Eq then Kind := N_Op_Eq; elsif Op_Name = Name_Op_Ne then Kind := N_Op_Ne; elsif Op_Name = Name_Op_Lt then Kind := N_Op_Lt; elsif Op_Name = Name_Op_Le then Kind := N_Op_Le; elsif Op_Name = Name_Op_Gt then Kind := N_Op_Gt; elsif Op_Name = Name_Op_Ge then Kind := N_Op_Ge; elsif Op_Name = Name_Op_Add then Kind := N_Op_Add; elsif Op_Name = Name_Op_Subtract then Kind := N_Op_Subtract; elsif Op_Name = Name_Op_Concat then Kind := N_Op_Concat; elsif Op_Name = Name_Op_Multiply then Kind := N_Op_Multiply; elsif Op_Name = Name_Op_Divide then Kind := N_Op_Divide; elsif Op_Name = Name_Op_Mod then Kind := N_Op_Mod; elsif Op_Name = Name_Op_Rem then Kind := N_Op_Rem; elsif Op_Name = Name_Op_Expon then Kind := N_Op_Expon; else raise Program_Error; end if; -- Unary operators else if Op_Name = Name_Op_Add then Kind := N_Op_Plus; elsif Op_Name = Name_Op_Subtract then Kind := N_Op_Minus; elsif Op_Name = Name_Op_Abs then Kind := N_Op_Abs; elsif Op_Name = Name_Op_Not then Kind := N_Op_Not; else raise Program_Error; end if; end if; return Kind; end Operator_Kind; ----------------------------- -- Pre_Analyze_And_Resolve -- ----------------------------- procedure Pre_Analyze_And_Resolve (N : Node_Id; T : Entity_Id) is Save_Full_Analysis : constant Boolean := Full_Analysis; begin Full_Analysis := False; Expander_Mode_Save_And_Set (False); -- We suppress all checks for this analysis, since the checks will -- be applied properly, and in the right location, when the default -- expression is reanalyzed and reexpanded later on. Analyze_And_Resolve (N, T, Suppress => All_Checks); Expander_Mode_Restore; Full_Analysis := Save_Full_Analysis; end Pre_Analyze_And_Resolve; -- Version without context type. procedure Pre_Analyze_And_Resolve (N : Node_Id) is Save_Full_Analysis : constant Boolean := Full_Analysis; begin Full_Analysis := False; Expander_Mode_Save_And_Set (False); Analyze (N); Resolve (N, Etype (N), Suppress => All_Checks); Expander_Mode_Restore; Full_Analysis := Save_Full_Analysis; end Pre_Analyze_And_Resolve; ---------------------------------- -- Replace_Actual_Discriminants -- ---------------------------------- procedure Replace_Actual_Discriminants (N : Node_Id; Default : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Tsk : Node_Id := Empty; function Process_Discr (Nod : Node_Id) return Traverse_Result; ------------------- -- Process_Discr -- ------------------- function Process_Discr (Nod : Node_Id) return Traverse_Result is Ent : Entity_Id; begin if Nkind (Nod) = N_Identifier then Ent := Entity (Nod); if Present (Ent) and then Ekind (Ent) = E_Discriminant then Rewrite (Nod, Make_Selected_Component (Loc, Prefix => New_Copy_Tree (Tsk, New_Sloc => Loc), Selector_Name => Make_Identifier (Loc, Chars (Ent)))); Set_Etype (Nod, Etype (Ent)); end if; end if; return OK; end Process_Discr; procedure Replace_Discrs is new Traverse_Proc (Process_Discr); -- Start of processing for Replace_Actual_Discriminants begin if not Expander_Active then return; end if; if Nkind (Name (N)) = N_Selected_Component then Tsk := Prefix (Name (N)); elsif Nkind (Name (N)) = N_Indexed_Component then Tsk := Prefix (Prefix (Name (N))); end if; if No (Tsk) then return; else Replace_Discrs (Default); end if; end Replace_Actual_Discriminants; ------------- -- Resolve -- ------------- procedure Resolve (N : Node_Id; Typ : Entity_Id) is I : Interp_Index; I1 : Interp_Index := 0; -- prevent junk warning It : Interp; It1 : Interp; Found : Boolean := False; Seen : Entity_Id := Empty; -- prevent junk warning Ctx_Type : Entity_Id := Typ; Expr_Type : Entity_Id := Empty; -- prevent junk warning Ambiguous : Boolean := False; procedure Patch_Up_Value (N : Node_Id; Typ : Entity_Id); -- Try and fix up a literal so that it matches its expected type. New -- literals are manufactured if necessary to avoid cascaded errors. procedure Resolution_Failed; -- Called when attempt at resolving current expression fails -------------------- -- Patch_Up_Value -- -------------------- procedure Patch_Up_Value (N : Node_Id; Typ : Entity_Id) is begin if Nkind (N) = N_Integer_Literal and then Is_Real_Type (Typ) then Rewrite (N, Make_Real_Literal (Sloc (N), Realval => UR_From_Uint (Intval (N)))); Set_Etype (N, Universal_Real); Set_Is_Static_Expression (N); elsif Nkind (N) = N_Real_Literal and then Is_Integer_Type (Typ) then Rewrite (N, Make_Integer_Literal (Sloc (N), Intval => UR_To_Uint (Realval (N)))); Set_Etype (N, Universal_Integer); Set_Is_Static_Expression (N); elsif Nkind (N) = N_String_Literal and then Is_Character_Type (Typ) then Set_Character_Literal_Name (Char_Code (Character'Pos ('A'))); Rewrite (N, Make_Character_Literal (Sloc (N), Chars => Name_Find, Char_Literal_Value => Char_Code (Character'Pos ('A')))); Set_Etype (N, Any_Character); Set_Is_Static_Expression (N); elsif Nkind (N) /= N_String_Literal and then Is_String_Type (Typ) then Rewrite (N, Make_String_Literal (Sloc (N), Strval => End_String)); elsif Nkind (N) = N_Range then Patch_Up_Value (Low_Bound (N), Typ); Patch_Up_Value (High_Bound (N), Typ); end if; end Patch_Up_Value; ----------------------- -- Resolution_Failed -- ----------------------- procedure Resolution_Failed is begin Patch_Up_Value (N, Typ); Set_Etype (N, Typ); Debug_A_Exit ("resolving ", N, " (done, resolution failed)"); Set_Is_Overloaded (N, False); -- The caller will return without calling the expander, so we need -- to set the analyzed flag. Note that it is fine to set Analyzed -- to True even if we are in the middle of a shallow analysis, -- (see the spec of sem for more details) since this is an error -- situation anyway, and there is no point in repeating the -- analysis later (indeed it won't work to repeat it later, since -- we haven't got a clear resolution of which entity is being -- referenced.) Set_Analyzed (N, True); return; end Resolution_Failed; -- Start of processing for Resolve begin if N = Error then return; end if; -- Access attribute on remote subprogram cannot be used for -- a non-remote access-to-subprogram type. if Nkind (N) = N_Attribute_Reference and then (Attribute_Name (N) = Name_Access or else Attribute_Name (N) = Name_Unrestricted_Access or else Attribute_Name (N) = Name_Unchecked_Access) and then Comes_From_Source (N) and then Is_Entity_Name (Prefix (N)) and then Is_Subprogram (Entity (Prefix (N))) and then Is_Remote_Call_Interface (Entity (Prefix (N))) and then not Is_Remote_Access_To_Subprogram_Type (Typ) then Error_Msg_N ("prefix must statically denote a non-remote subprogram", N); end if; -- If the context is a Remote_Access_To_Subprogram, access attributes -- must be resolved with the corresponding fat pointer. There is no need -- to check for the attribute name since the return type of an -- attribute is never a remote type. if Nkind (N) = N_Attribute_Reference and then Comes_From_Source (N) and then (Is_Remote_Call_Interface (Typ) or else Is_Remote_Types (Typ)) then declare Attr : constant Attribute_Id := Get_Attribute_Id (Attribute_Name (N)); Pref : constant Node_Id := Prefix (N); Decl : Node_Id; Spec : Node_Id; Is_Remote : Boolean := True; begin -- Check that Typ is a fat pointer with a reference to a RAS as -- original access type. if (Ekind (Typ) = E_Access_Subprogram_Type and then Present (Equivalent_Type (Typ))) or else (Ekind (Typ) = E_Record_Type and then Present (Corresponding_Remote_Type (Typ))) then -- Prefix (N) must statically denote a remote subprogram -- declared in a package specification. if Attr = Attribute_Access then Decl := Unit_Declaration_Node (Entity (Pref)); if Nkind (Decl) = N_Subprogram_Body then Spec := Corresponding_Spec (Decl); if not No (Spec) then Decl := Unit_Declaration_Node (Spec); end if; end if; Spec := Parent (Decl); if not Is_Entity_Name (Prefix (N)) or else Nkind (Spec) /= N_Package_Specification or else not Is_Remote_Call_Interface (Defining_Entity (Spec)) then Is_Remote := False; Error_Msg_N ("prefix must statically denote a remote subprogram ", N); end if; end if; if Attr = Attribute_Access or else Attr = Attribute_Unchecked_Access or else Attr = Attribute_Unrestricted_Access then Check_Subtype_Conformant (New_Id => Entity (Prefix (N)), Old_Id => Designated_Type (Corresponding_Remote_Type (Typ)), Err_Loc => N); if Is_Remote then Process_Remote_AST_Attribute (N, Typ); end if; end if; end if; end; end if; Debug_A_Entry ("resolving ", N); if Is_Fixed_Point_Type (Typ) then Check_Restriction (No_Fixed_Point, N); elsif Is_Floating_Point_Type (Typ) and then Typ /= Universal_Real and then Typ /= Any_Real then Check_Restriction (No_Floating_Point, N); end if; -- Return if already analyzed if Analyzed (N) then Debug_A_Exit ("resolving ", N, " (done, already analyzed)"); return; -- Return if type = Any_Type (previous error encountered) elsif Etype (N) = Any_Type then Debug_A_Exit ("resolving ", N, " (done, Etype = Any_Type)"); return; end if; Check_Parameterless_Call (N); -- If not overloaded, then we know the type, and all that needs doing -- is to check that this type is compatible with the context. if not Is_Overloaded (N) then Found := Covers (Typ, Etype (N)); Expr_Type := Etype (N); -- In the overloaded case, we must select the interpretation that -- is compatible with the context (i.e. the type passed to Resolve) else Get_First_Interp (N, I, It); -- Loop through possible interpretations Interp_Loop : while Present (It.Typ) loop -- We are only interested in interpretations that are compatible -- with the expected type, any other interpretations are ignored if Covers (Typ, It.Typ) then -- First matching interpretation if not Found then Found := True; I1 := I; Seen := It.Nam; Expr_Type := It.Typ; -- Matching intepretation that is not the first, maybe an -- error, but there are some cases where preference rules are -- used to choose between the two possibilities. These and -- some more obscure cases are handled in Disambiguate. else Error_Msg_Sloc := Sloc (Seen); It1 := Disambiguate (N, I1, I, Typ); if It1 = No_Interp then -- Before we issue an ambiguity complaint, check for -- the case of a subprogram call where at least one -- of the arguments is Any_Type, and if so, suppress -- the message, since it is a cascaded error. if Nkind (N) = N_Function_Call or else Nkind (N) = N_Procedure_Call_Statement then declare A : Node_Id := First_Actual (N); E : Node_Id; begin while Present (A) loop E := A; if Nkind (E) = N_Parameter_Association then E := Explicit_Actual_Parameter (E); end if; if Etype (E) = Any_Type then if Debug_Flag_V then Write_Str ("Any_Type in call"); Write_Eol; end if; exit Interp_Loop; end if; Next_Actual (A); end loop; end; elsif Nkind (N) in N_Binary_Op and then (Etype (Left_Opnd (N)) = Any_Type or else Etype (Right_Opnd (N)) = Any_Type) then exit Interp_Loop; elsif Nkind (N) in N_Unary_Op and then Etype (Right_Opnd (N)) = Any_Type then exit Interp_Loop; end if; -- Not that special case, so issue message using the -- flag Ambiguous to control printing of the header -- message only at the start of an ambiguous set. if not Ambiguous then Error_Msg_NE ("ambiguous expression (cannot resolve&)!", N, It.Nam); Error_Msg_N ("possible interpretation#!", N); Ambiguous := True; end if; Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_N ("possible interpretation#!", N); -- Disambiguation has succeeded. Skip the remaining -- interpretations. else Seen := It1.Nam; Expr_Type := It1.Typ; while Present (It.Typ) loop Get_Next_Interp (I, It); end loop; end if; end if; -- We have a matching interpretation, Expr_Type is the -- type from this interpretation, and Seen is the entity. -- For an operator, just set the entity name. The type will -- be set by the specific operator resolution routine. if Nkind (N) in N_Op then Set_Entity (N, Seen); Generate_Reference (Seen, N); elsif Nkind (N) = N_Character_Literal then Set_Etype (N, Expr_Type); -- For an explicit dereference, attribute reference, range, -- short-circuit form (which is not an operator node), -- or a call with a name that is an explicit dereference, -- there is nothing to be done at this point. elsif Nkind (N) = N_Explicit_Dereference or else Nkind (N) = N_Attribute_Reference or else Nkind (N) = N_And_Then or else Nkind (N) = N_Indexed_Component or else Nkind (N) = N_Or_Else or else Nkind (N) = N_Range or else Nkind (N) = N_Selected_Component or else Nkind (N) = N_Slice or else Nkind (Name (N)) = N_Explicit_Dereference then null; -- For procedure or function calls, set the type of the -- name, and also the entity pointer for the prefix elsif (Nkind (N) = N_Procedure_Call_Statement or else Nkind (N) = N_Function_Call) and then (Is_Entity_Name (Name (N)) or else Nkind (Name (N)) = N_Operator_Symbol) then Set_Etype (Name (N), Expr_Type); Set_Entity (Name (N), Seen); Generate_Reference (Seen, Name (N)); elsif Nkind (N) = N_Function_Call and then Nkind (Name (N)) = N_Selected_Component then Set_Etype (Name (N), Expr_Type); Set_Entity (Selector_Name (Name (N)), Seen); Generate_Reference (Seen, Selector_Name (Name (N))); -- For all other cases, just set the type of the Name else Set_Etype (Name (N), Expr_Type); end if; -- Here if interpetation is incompatible with context type else if Debug_Flag_V then Write_Str (" intepretation incompatible with context"); Write_Eol; end if; end if; -- Move to next interpretation exit Interp_Loop when not Present (It.Typ); Get_Next_Interp (I, It); end loop Interp_Loop; end if; -- At this stage Found indicates whether or not an acceptable -- interpretation exists. If not, then we have an error, except -- that if the context is Any_Type as a result of some other error, -- then we suppress the error report. if not Found then if Typ /= Any_Type then -- If type we are looking for is Void, then this is the -- procedure call case, and the error is simply that what -- we gave is not a procedure name (we think of procedure -- calls as expressions with types internally, but the user -- doesn't think of them this way!) if Typ = Standard_Void_Type then Error_Msg_N ("expect procedure name in procedure call", N); Found := True; -- Otherwise we do have a subexpression with the wrong type -- Check for the case of an allocator which uses an access -- type instead of the designated type. This is a common -- error and we specialize the message, posting an error -- on the operand of the allocator, complaining that we -- expected the designated type of the allocator. elsif Nkind (N) = N_Allocator and then Ekind (Typ) in Access_Kind and then Ekind (Etype (N)) in Access_Kind and then Designated_Type (Etype (N)) = Typ then Wrong_Type (Expression (N), Designated_Type (Typ)); Found := True; -- Check for view mismatch on Null in instances, for -- which the view-swapping mechanism has no identifier. elsif (In_Instance or else In_Inlined_Body) and then (Nkind (N) = N_Null) and then Is_Private_Type (Typ) and then Is_Access_Type (Full_View (Typ)) then Resolve (N, Full_View (Typ)); Set_Etype (N, Typ); return; -- Check for an aggregate. Sometimes we can get bogus -- aggregates from misuse of parentheses, and we are -- about to complain about the aggregate without even -- looking inside it. -- Instead, if we have an aggregate of type Any_Composite, -- then analyze and resolve the component fields, and then -- only issue another message if we get no errors doing -- this (otherwise assume that the errors in the aggregate -- caused the problem). elsif Nkind (N) = N_Aggregate and then Etype (N) = Any_Composite then -- Disable expansion in any case. If there is a type mismatch -- it may be fatal to try to expand the aggregate. The flag -- would otherwise be set to false when the error is posted. Expander_Active := False; declare procedure Check_Aggr (Aggr : Node_Id); -- Check one aggregate, and set Found to True if we -- have a definite error in any of its elements procedure Check_Elmt (Aelmt : Node_Id); -- Check one element of aggregate and set Found to -- True if we definitely have an error in the element. procedure Check_Aggr (Aggr : Node_Id) is Elmt : Node_Id; begin if Present (Expressions (Aggr)) then Elmt := First (Expressions (Aggr)); while Present (Elmt) loop Check_Elmt (Elmt); Next (Elmt); end loop; end if; if Present (Component_Associations (Aggr)) then Elmt := First (Component_Associations (Aggr)); while Present (Elmt) loop Check_Elmt (Expression (Elmt)); Next (Elmt); end loop; end if; end Check_Aggr; procedure Check_Elmt (Aelmt : Node_Id) is begin -- If we have a nested aggregate, go inside it (to -- attempt a naked analyze-resolve of the aggregate -- can cause undesirable cascaded errors). Do not -- resolve expression if it needs a type from context, -- as for integer * fixed expression. if Nkind (Aelmt) = N_Aggregate then Check_Aggr (Aelmt); else Analyze (Aelmt); if not Is_Overloaded (Aelmt) and then Etype (Aelmt) /= Any_Fixed then Resolve (Aelmt, Etype (Aelmt)); end if; if Etype (Aelmt) = Any_Type then Found := True; end if; end if; end Check_Elmt; begin Check_Aggr (N); end; end if; -- If an error message was issued already, Found got reset -- to True, so if it is still False, issue the standard -- Wrong_Type message. if not Found then if Is_Overloaded (N) and then Nkind (N) = N_Function_Call then Error_Msg_Node_2 := Typ; Error_Msg_NE ("no visible interpretation of&" & " matches expected type&", N, Name (N)); if All_Errors_Mode then declare Index : Interp_Index; It : Interp; begin Error_Msg_N ("\possible interpretations:", N); Get_First_Interp (Name (N), Index, It); while Present (It.Nam) loop Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_Node_2 := It.Typ; Error_Msg_NE ("\& declared#, type&", N, It.Nam); Get_Next_Interp (Index, It); end loop; end; else Error_Msg_N ("\use -gnatf for details", N); end if; else Wrong_Type (N, Typ); end if; end if; end if; Resolution_Failed; return; -- Test if we have more than one interpretation for the context elsif Ambiguous then Resolution_Failed; return; -- Here we have an acceptable interpretation for the context else -- A user-defined operator is tranformed into a function call at -- this point, so that further processing knows that operators are -- really operators (i.e. are predefined operators). User-defined -- operators that are intrinsic are just renamings of the predefined -- ones, and need not be turned into calls either, but if they rename -- a different operator, we must transform the node accordingly. -- Instantiations of Unchecked_Conversion are intrinsic but are -- treated as functions, even if given an operator designator. if Nkind (N) in N_Op and then Present (Entity (N)) and then Ekind (Entity (N)) /= E_Operator then if not Is_Predefined_Op (Entity (N)) then Rewrite_Operator_As_Call (N, Entity (N)); elsif Present (Alias (Entity (N))) then Rewrite_Renamed_Operator (N, Alias (Entity (N))); end if; end if; -- Propagate type information and normalize tree for various -- predefined operations. If the context only imposes a class of -- types, rather than a specific type, propagate the actual type -- downward. if Typ = Any_Integer or else Typ = Any_Boolean or else Typ = Any_Modular or else Typ = Any_Real or else Typ = Any_Discrete then Ctx_Type := Expr_Type; -- Any_Fixed is legal in a real context only if a specific -- fixed point type is imposed. If Norman Cohen can be -- confused by this, it deserves a separate message. if Typ = Any_Real and then Expr_Type = Any_Fixed then Error_Msg_N ("Illegal context for mixed mode operation", N); Set_Etype (N, Universal_Real); Ctx_Type := Universal_Real; end if; end if; case N_Subexpr'(Nkind (N)) is when N_Aggregate => Resolve_Aggregate (N, Ctx_Type); when N_Allocator => Resolve_Allocator (N, Ctx_Type); when N_And_Then | N_Or_Else => Resolve_Short_Circuit (N, Ctx_Type); when N_Attribute_Reference => Resolve_Attribute (N, Ctx_Type); when N_Character_Literal => Resolve_Character_Literal (N, Ctx_Type); when N_Conditional_Expression => Resolve_Conditional_Expression (N, Ctx_Type); when N_Expanded_Name => Resolve_Entity_Name (N, Ctx_Type); when N_Extension_Aggregate => Resolve_Extension_Aggregate (N, Ctx_Type); when N_Explicit_Dereference => Resolve_Explicit_Dereference (N, Ctx_Type); when N_Function_Call => Resolve_Call (N, Ctx_Type); when N_Identifier => Resolve_Entity_Name (N, Ctx_Type); when N_In | N_Not_In => Resolve_Membership_Op (N, Ctx_Type); when N_Indexed_Component => Resolve_Indexed_Component (N, Ctx_Type); when N_Integer_Literal => Resolve_Integer_Literal (N, Ctx_Type); when N_Null => Resolve_Null (N, Ctx_Type); when N_Op_And | N_Op_Or | N_Op_Xor => Resolve_Logical_Op (N, Ctx_Type); when N_Op_Eq | N_Op_Ne => Resolve_Equality_Op (N, Ctx_Type); when N_Op_Lt | N_Op_Le | N_Op_Gt | N_Op_Ge => Resolve_Comparison_Op (N, Ctx_Type); when N_Op_Not => Resolve_Op_Not (N, Ctx_Type); when N_Op_Add | N_Op_Subtract | N_Op_Multiply | N_Op_Divide | N_Op_Mod | N_Op_Rem => Resolve_Arithmetic_Op (N, Ctx_Type); when N_Op_Concat => Resolve_Op_Concat (N, Ctx_Type); when N_Op_Expon => Resolve_Op_Expon (N, Ctx_Type); when N_Op_Plus | N_Op_Minus | N_Op_Abs => Resolve_Unary_Op (N, Ctx_Type); when N_Op_Shift => Resolve_Shift (N, Ctx_Type); when N_Procedure_Call_Statement => Resolve_Call (N, Ctx_Type); when N_Operator_Symbol => Resolve_Operator_Symbol (N, Ctx_Type); when N_Qualified_Expression => Resolve_Qualified_Expression (N, Ctx_Type); when N_Raise_xxx_Error => Set_Etype (N, Ctx_Type); when N_Range => Resolve_Range (N, Ctx_Type); when N_Real_Literal => Resolve_Real_Literal (N, Ctx_Type); when N_Reference => Resolve_Reference (N, Ctx_Type); when N_Selected_Component => Resolve_Selected_Component (N, Ctx_Type); when N_Slice => Resolve_Slice (N, Ctx_Type); when N_String_Literal => Resolve_String_Literal (N, Ctx_Type); when N_Subprogram_Info => Resolve_Subprogram_Info (N, Ctx_Type); when N_Type_Conversion => Resolve_Type_Conversion (N, Ctx_Type); when N_Unchecked_Expression => Resolve_Unchecked_Expression (N, Ctx_Type); when N_Unchecked_Type_Conversion => Resolve_Unchecked_Type_Conversion (N, Ctx_Type); end case; -- If the subexpression was replaced by a non-subexpression, then -- all we do is to expand it. The only legitimate case we know of -- is converting procedure call statement to entry call statements, -- but there may be others, so we are making this test general. if Nkind (N) not in N_Subexpr then Debug_A_Exit ("resolving ", N, " (done)"); Expand (N); return; end if; -- The expression is definitely NOT overloaded at this point, so -- we reset the Is_Overloaded flag to avoid any confusion when -- reanalyzing the node. Set_Is_Overloaded (N, False); -- Freeze expression type, entity if it is a name, and designated -- type if it is an allocator (RM 13.14(9,10)). -- Now that the resolution of the type of the node is complete, -- and we did not detect an error, we can expand this node. We -- skip the expand call if we are in a default expression, see -- section "Handling of Default Expressions" in Sem spec. Debug_A_Exit ("resolving ", N, " (done)"); -- We unconditionally freeze the expression, even if we are in -- default expression mode (the Freeze_Expression routine tests -- this flag and only freezes static types if it is set). Freeze_Expression (N); -- Now we can do the expansion Expand (N); end if; end Resolve; -- Version with check(s) suppressed procedure Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id) is begin if Suppress = All_Checks then declare Svg : constant Suppress_Record := Scope_Suppress; begin Scope_Suppress := (others => True); Resolve (N, Typ); Scope_Suppress := Svg; end; else declare Svg : constant Boolean := Get_Scope_Suppress (Suppress); begin Set_Scope_Suppress (Suppress, True); Resolve (N, Typ); Set_Scope_Suppress (Suppress, Svg); end; end if; end Resolve; --------------------- -- Resolve_Actuals -- --------------------- procedure Resolve_Actuals (N : Node_Id; Nam : Entity_Id) is Loc : constant Source_Ptr := Sloc (N); A : Node_Id; F : Entity_Id; A_Typ : Entity_Id; F_Typ : Entity_Id; Prev : Node_Id := Empty; procedure Insert_Default; -- If the actual is missing in a call, insert in the actuals list -- an instance of the default expression. The insertion is always -- a named association. -------------------- -- Insert_Default -- -------------------- procedure Insert_Default is Actval : Node_Id; Assoc : Node_Id; begin -- Note that we do a full New_Copy_Tree, so that any associated -- Itypes are properly copied. This may not be needed any more, -- but it does no harm as a safety measure! Defaults of a generic -- formal may be out of bounds of the corresponding actual (see -- cc1311b) and an additional check may be required. if Present (Default_Value (F)) then Actval := New_Copy_Tree (Default_Value (F), New_Scope => Current_Scope, New_Sloc => Loc); if Is_Concurrent_Type (Scope (Nam)) and then Has_Discriminants (Scope (Nam)) then Replace_Actual_Discriminants (N, Actval); end if; if Is_Overloadable (Nam) and then Present (Alias (Nam)) then if Base_Type (Etype (F)) /= Base_Type (Etype (Actval)) and then not Is_Tagged_Type (Etype (F)) then -- If default is a real literal, do not introduce a -- conversion whose effect may depend on the run-time -- size of universal real. if Nkind (Actval) = N_Real_Literal then Set_Etype (Actval, Base_Type (Etype (F))); else Actval := Unchecked_Convert_To (Etype (F), Actval); end if; end if; if Is_Scalar_Type (Etype (F)) then Enable_Range_Check (Actval); end if; Set_Parent (Actval, N); Analyze_And_Resolve (Actval, Etype (Actval)); else Set_Parent (Actval, N); -- Resolve aggregates with their base type, to avoid scope -- anomalies: the subtype was first built in the suprogram -- declaration, and the current call may be nested. if Nkind (Actval) = N_Aggregate and then Has_Discriminants (Etype (Actval)) then Analyze_And_Resolve (Actval, Base_Type (Etype (Actval))); else Analyze_And_Resolve (Actval, Etype (Actval)); end if; end if; -- If default is a tag indeterminate function call, propagate -- tag to obtain proper dispatching. if Is_Controlling_Formal (F) and then Nkind (Default_Value (F)) = N_Function_Call then Set_Is_Controlling_Actual (Actval); end if; else -- Missing argument in call, nothing to insert. return; end if; -- If the default expression raises constraint error, then just -- silently replace it with an N_Raise_Constraint_Error node, -- since we already gave the warning on the subprogram spec. if Raises_Constraint_Error (Actval) then Rewrite (Actval, Make_Raise_Constraint_Error (Loc)); Set_Raises_Constraint_Error (Actval); Set_Etype (Actval, Etype (F)); end if; Assoc := Make_Parameter_Association (Loc, Explicit_Actual_Parameter => Actval, Selector_Name => Make_Identifier (Loc, Chars (F))); -- Case of insertion is first named actual if No (Prev) or else Nkind (Parent (Prev)) /= N_Parameter_Association then Set_Next_Named_Actual (Assoc, First_Named_Actual (N)); Set_First_Named_Actual (N, Actval); if No (Prev) then if not Present (Parameter_Associations (N)) then Set_Parameter_Associations (N, New_List (Assoc)); else Append (Assoc, Parameter_Associations (N)); end if; else Insert_After (Prev, Assoc); end if; -- Case of insertion is not first named actual else Set_Next_Named_Actual (Assoc, Next_Named_Actual (Parent (Prev))); Set_Next_Named_Actual (Parent (Prev), Actval); Append (Assoc, Parameter_Associations (N)); end if; Mark_Rewrite_Insertion (Assoc); Mark_Rewrite_Insertion (Actval); Prev := Actval; end Insert_Default; -- Start of processing for Resolve_Actuals begin A := First_Actual (N); F := First_Formal (Nam); while Present (F) loop if Present (A) and then (Nkind (Parent (A)) /= N_Parameter_Association or else Chars (Selector_Name (Parent (A))) = Chars (F)) then -- If the formal is Out or In_Out, do not resolve and expand the -- conversion, because it is subsequently expanded into explicit -- temporaries and assignments. However, the object of the -- conversion can be resolved. An exception is the case of -- a tagged type conversion with a class-wide actual. In that -- case we want the tag check to occur and no temporary will -- will be needed (no representation change can occur) and -- the parameter is passed by reference, so we go ahead and -- resolve the type conversion. if Ekind (F) /= E_In_Parameter and then Nkind (A) = N_Type_Conversion and then not Is_Class_Wide_Type (Etype (Expression (A))) then if Conversion_OK (A) or else Valid_Conversion (A, Etype (A), Expression (A)) then Resolve (Expression (A), Etype (Expression (A))); end if; else Resolve (A, Etype (F)); end if; A_Typ := Etype (A); F_Typ := Etype (F); if Ekind (F) /= E_In_Parameter and then not Is_OK_Variable_For_Out_Formal (A) then -- Specialize error message for protected procedure call -- within function call of the same protected object. if Is_Entity_Name (A) and then Chars (Entity (A)) = Name_uObject and then Ekind (Current_Scope) = E_Function and then Convention (Current_Scope) = Convention_Protected and then Ekind (Nam) /= E_Function then Error_Msg_N ("within protected function, protected " & "object is constant", A); Error_Msg_N ("\cannot call operation that may modify it", A); else Error_Msg_NE ("actual for& must be a variable", A, F); end if; end if; if Ekind (F) /= E_Out_Parameter then Check_Unset_Reference (A); if Ada_83 and then Is_Entity_Name (A) and then Ekind (Entity (A)) = E_Out_Parameter then Error_Msg_N ("(Ada 83) illegal reading of out parameter", A); end if; end if; -- Apply appropriate range checks for in, out, and in-out -- parameters. Out and in-out parameters also need a separate -- check, if there is a type conversion, to make sure the return -- value meets the constraints of the variable before the -- conversion. -- Gigi looks at the check flag and uses the appropriate types. -- For now since one flag is used there is an optimization which -- might not be done in the In Out case since Gigi does not do -- any analysis. More thought required about this ??? if Ekind (F) = E_In_Parameter or else Ekind (F) = E_In_Out_Parameter then if Is_Scalar_Type (Etype (A)) then Apply_Scalar_Range_Check (A, F_Typ); elsif Is_Array_Type (Etype (A)) then Apply_Length_Check (A, F_Typ); elsif Is_Record_Type (F_Typ) and then Has_Discriminants (F_Typ) and then Is_Constrained (F_Typ) and then (not Is_Derived_Type (F_Typ) or else Comes_From_Source (Nam)) then Apply_Discriminant_Check (A, F_Typ); elsif Is_Access_Type (F_Typ) and then Is_Array_Type (Designated_Type (F_Typ)) and then Is_Constrained (Designated_Type (F_Typ)) then Apply_Length_Check (A, F_Typ); elsif Is_Access_Type (F_Typ) and then Has_Discriminants (Designated_Type (F_Typ)) and then Is_Constrained (Designated_Type (F_Typ)) then Apply_Discriminant_Check (A, F_Typ); else Apply_Range_Check (A, F_Typ); end if; end if; if Ekind (F) = E_Out_Parameter or else Ekind (F) = E_In_Out_Parameter then if Nkind (A) = N_Type_Conversion then if Is_Scalar_Type (A_Typ) then Apply_Scalar_Range_Check (Expression (A), Etype (Expression (A)), A_Typ); else Apply_Range_Check (Expression (A), Etype (Expression (A)), A_Typ); end if; else if Is_Scalar_Type (F_Typ) then Apply_Scalar_Range_Check (A, A_Typ, F_Typ); elsif Is_Array_Type (F_Typ) and then Ekind (F) = E_Out_Parameter then Apply_Length_Check (A, F_Typ); else Apply_Range_Check (A, A_Typ, F_Typ); end if; end if; end if; -- An actual associated with an access parameter is implicitly -- converted to the anonymous access type of the formal and -- must satisfy the legality checks for access conversions. if Ekind (F_Typ) = E_Anonymous_Access_Type then if not Valid_Conversion (A, F_Typ, A) then Error_Msg_N ("invalid implicit conversion for access parameter", A); end if; end if; -- Check bad case of atomic/volatile argument (RM C.6(12)) if Is_By_Reference_Type (Etype (F)) and then Comes_From_Source (N) then if Is_Atomic_Object (A) and then not Is_Atomic (Etype (F)) then Error_Msg_N ("cannot pass atomic argument to non-atomic formal", N); elsif Is_Volatile_Object (A) and then not Is_Volatile (Etype (F)) then Error_Msg_N ("cannot pass volatile argument to non-volatile formal", N); end if; end if; -- Check that subprograms don't have improper controlling -- arguments (RM 3.9.2 (9)) if Is_Controlling_Formal (F) then Set_Is_Controlling_Actual (A); elsif Nkind (A) = N_Explicit_Dereference then Validate_Remote_Access_To_Class_Wide_Type (A); end if; if (Is_Class_Wide_Type (A_Typ) or else Is_Dynamically_Tagged (A)) and then not Is_Class_Wide_Type (F_Typ) and then not Is_Controlling_Formal (F) then Error_Msg_N ("class-wide argument not allowed here!", A); if Is_Subprogram (Nam) then Error_Msg_Node_2 := F_Typ; Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); end if; elsif Is_Access_Type (A_Typ) and then Is_Access_Type (F_Typ) and then Ekind (F_Typ) /= E_Access_Subprogram_Type and then (Is_Class_Wide_Type (Designated_Type (A_Typ)) or else (Nkind (A) = N_Attribute_Reference and then Is_Class_Wide_Type (Etype (Prefix (A))))) and then not Is_Class_Wide_Type (Designated_Type (F_Typ)) and then not Is_Controlling_Formal (F) then Error_Msg_N ("access to class-wide argument not allowed here!", A); if Is_Subprogram (Nam) then Error_Msg_Node_2 := Designated_Type (F_Typ); Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); end if; end if; Eval_Actual (A); -- If it is a named association, treat the selector_name as -- a proper identifier, and mark the corresponding entity. if Nkind (Parent (A)) = N_Parameter_Association then Set_Entity (Selector_Name (Parent (A)), F); Generate_Reference (F, Selector_Name (Parent (A))); Set_Etype (Selector_Name (Parent (A)), F_Typ); Generate_Reference (F_Typ, N, ' '); end if; Prev := A; Next_Actual (A); else Insert_Default; end if; Next_Formal (F); end loop; end Resolve_Actuals; ----------------------- -- Resolve_Allocator -- ----------------------- procedure Resolve_Allocator (N : Node_Id; Typ : Entity_Id) is E : constant Node_Id := Expression (N); Subtyp : Entity_Id; Discrim : Entity_Id; Constr : Node_Id; Disc_Exp : Node_Id; begin -- Replace general access with specific type if Ekind (Etype (N)) = E_Allocator_Type then Set_Etype (N, Base_Type (Typ)); end if; if Is_Abstract (Typ) then Error_Msg_N ("type of allocator cannot be abstract", N); end if; -- For qualified expression, resolve the expression using the -- given subtype (nothing to do for type mark, subtype indication) if Nkind (E) = N_Qualified_Expression then if Is_Class_Wide_Type (Etype (E)) and then not Is_Class_Wide_Type (Designated_Type (Typ)) then Error_Msg_N ("class-wide allocator not allowed for this access type", N); end if; Resolve (Expression (E), Etype (E)); Check_Unset_Reference (Expression (E)); -- For a subtype mark or subtype indication, freeze the subtype else Freeze_Expression (E); if Is_Access_Constant (Typ) and then not No_Initialization (N) then Error_Msg_N ("initialization required for access-to-constant allocator", N); end if; -- A special accessibility check is needed for allocators that -- constrain access discriminants. The level of the type of the -- expression used to contrain an access discriminant cannot be -- deeper than the type of the allocator (in constrast to access -- parameters, where the level of the actual can be arbitrary). -- We can't use Valid_Conversion to perform this check because -- in general the type of the allocator is unrelated to the type -- of the access discriminant. Note that specialized checks are -- needed for the cases of a constraint expression which is an -- access attribute or an access discriminant. if Nkind (Original_Node (E)) = N_Subtype_Indication and then Ekind (Typ) /= E_Anonymous_Access_Type then Subtyp := Entity (Subtype_Mark (Original_Node (E))); if Has_Discriminants (Subtyp) then Discrim := First_Discriminant (Base_Type (Subtyp)); Constr := First (Constraints (Constraint (Original_Node (E)))); while Present (Discrim) and then Present (Constr) loop if Ekind (Etype (Discrim)) = E_Anonymous_Access_Type then if Nkind (Constr) = N_Discriminant_Association then Disc_Exp := Original_Node (Expression (Constr)); else Disc_Exp := Original_Node (Constr); end if; if Type_Access_Level (Etype (Disc_Exp)) > Type_Access_Level (Typ) then Error_Msg_N ("operand type has deeper level than allocator type", Disc_Exp); elsif Nkind (Disc_Exp) = N_Attribute_Reference and then Get_Attribute_Id (Attribute_Name (Disc_Exp)) = Attribute_Access and then Object_Access_Level (Prefix (Disc_Exp)) > Type_Access_Level (Typ) then Error_Msg_N ("prefix of attribute has deeper level than" & " allocator type", Disc_Exp); -- When the operand is an access discriminant the check -- is against the level of the prefix object. elsif Ekind (Etype (Disc_Exp)) = E_Anonymous_Access_Type and then Nkind (Disc_Exp) = N_Selected_Component and then Object_Access_Level (Prefix (Disc_Exp)) > Type_Access_Level (Typ) then Error_Msg_N ("access discriminant has deeper level than" & " allocator type", Disc_Exp); end if; end if; Next_Discriminant (Discrim); Next (Constr); end loop; end if; end if; end if; -- Check for allocation from an empty storage pool if No_Pool_Assigned (Typ) then declare Loc : constant Source_Ptr := Sloc (N); begin Error_Msg_N ("?allocation from empty storage pool!", N); Error_Msg_N ("?Storage_Error will be raised at run time!", N); Insert_Action (N, Make_Raise_Storage_Error (Loc)); end; end if; end Resolve_Allocator; --------------------------- -- Resolve_Arithmetic_Op -- --------------------------- -- Used for resolving all arithmetic operators except exponentiation procedure Resolve_Arithmetic_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; TL : Entity_Id := Base_Type (Etype (L)); TR : Entity_Id := Base_Type (Etype (R)); B_Typ : constant Entity_Id := Base_Type (Typ); -- We do the resolution using the base type, because intermediate values -- in expressions always are of the base type, not a subtype of it. function Is_Integer_Or_Universal (N : Node_Id) return Boolean; -- Return True iff given type is Integer or universal real/integer procedure Set_Mixed_Mode_Operand (N : Node_Id; T : Entity_Id); -- Choose type of integer literal in fixed-point operation to conform -- to available fixed-point type. T is the type of the other operand, -- which is needed to determine the expected type of N. procedure Set_Operand_Type (N : Node_Id); -- Set operand type to T if universal function Universal_Interpretation (N : Node_Id) return Entity_Id; -- Find universal type of operand, if any. ----------------------------- -- Is_Integer_Or_Universal -- ----------------------------- function Is_Integer_Or_Universal (N : Node_Id) return Boolean is T : Entity_Id; Index : Interp_Index; It : Interp; begin if not Is_Overloaded (N) then T := Etype (N); return Base_Type (T) = Base_Type (Standard_Integer) or else T = Universal_Integer or else T = Universal_Real; else Get_First_Interp (N, Index, It); while Present (It.Typ) loop if Base_Type (It.Typ) = Base_Type (Standard_Integer) or else It.Typ = Universal_Integer or else It.Typ = Universal_Real then return True; end if; Get_Next_Interp (Index, It); end loop; end if; return False; end Is_Integer_Or_Universal; ---------------------------- -- Set_Mixed_Mode_Operand -- ---------------------------- procedure Set_Mixed_Mode_Operand (N : Node_Id; T : Entity_Id) is Index : Interp_Index; It : Interp; begin if Universal_Interpretation (N) = Universal_Integer then -- A universal integer literal is resolved as standard integer -- except in the case of a fixed-point result, where we leave -- it as universal (to be handled by Exp_Fixd later on) if Is_Fixed_Point_Type (T) then Resolve (N, Universal_Integer); else Resolve (N, Standard_Integer); end if; elsif Universal_Interpretation (N) = Universal_Real and then (T = Base_Type (Standard_Integer) or else T = Universal_Integer or else T = Universal_Real) then -- A universal real can appear in a fixed-type context. We resolve -- the literal with that context, even though this might raise an -- exception prematurely (the other operand may be zero). Resolve (N, B_Typ); elsif Etype (N) = Base_Type (Standard_Integer) and then T = Universal_Real and then Is_Overloaded (N) then -- Integer arg in mixed-mode operation. Resolve with universal -- type, in case preference rule must be applied. Resolve (N, Universal_Integer); elsif Etype (N) = T and then B_Typ /= Universal_Fixed then -- Not a mixed-mode operation. Resolve with context. Resolve (N, B_Typ); elsif Etype (N) = Any_Fixed then -- N may itself be a mixed-mode operation, so use context type. Resolve (N, B_Typ); elsif Is_Fixed_Point_Type (T) and then B_Typ = Universal_Fixed and then Is_Overloaded (N) then -- Must be (fixed * fixed) operation, operand must have one -- compatible interpretation. Resolve (N, Any_Fixed); elsif Is_Fixed_Point_Type (B_Typ) and then (T = Universal_Real or else Is_Fixed_Point_Type (T)) and then Is_Overloaded (N) then -- C * F(X) in a fixed context, where C is a real literal or a -- fixed-point expression. F must have either a fixed type -- interpretation or an integer interpretation, but not both. Get_First_Interp (N, Index, It); while Present (It.Typ) loop if Base_Type (It.Typ) = Base_Type (Standard_Integer) then if Analyzed (N) then Error_Msg_N ("ambiguous operand in fixed operation", N); else Resolve (N, Standard_Integer); end if; elsif Is_Fixed_Point_Type (It.Typ) then if Analyzed (N) then Error_Msg_N ("ambiguous operand in fixed operation", N); else Resolve (N, It.Typ); end if; end if; Get_Next_Interp (Index, It); end loop; -- Reanalyze the literal with the fixed type of the context. if N = L then Set_Analyzed (R, False); Resolve (R, B_Typ); else Set_Analyzed (L, False); Resolve (L, B_Typ); end if; else Resolve (N, Etype (N)); end if; end Set_Mixed_Mode_Operand; ---------------------- -- Set_Operand_Type -- ---------------------- procedure Set_Operand_Type (N : Node_Id) is begin if Etype (N) = Universal_Integer or else Etype (N) = Universal_Real then Set_Etype (N, T); end if; end Set_Operand_Type; ------------------------------ -- Universal_Interpretation -- ------------------------------ function Universal_Interpretation (N : Node_Id) return Entity_Id is Index : Interp_Index; It : Interp; begin if not Is_Overloaded (N) then if Etype (N) = Universal_Integer or else Etype (N) = Universal_Real then return Etype (N); else return Empty; end if; else Get_First_Interp (N, Index, It); while Present (It.Typ) loop if It.Typ = Universal_Integer or else It.Typ = Universal_Real then return It.Typ; end if; Get_Next_Interp (Index, It); end loop; return Empty; end if; end Universal_Interpretation; -- Start of processing for Resolve_Arithmetic_Op begin if Comes_From_Source (N) and then Ekind (Entity (N)) = E_Function and then Is_Imported (Entity (N)) and then Present (First_Rep_Item (Entity (N))) then Resolve_Intrinsic_Operator (N, Typ); return; -- Special-case for mixed-mode universal expressions or fixed point -- type operation: each argument is resolved separately. The same -- treatment is required if one of the operands of a fixed point -- operation is universal real, since in this case we don't do a -- conversion to a specific fixed-point type (instead the expander -- takes care of the case). elsif (B_Typ = Universal_Integer or else B_Typ = Universal_Real) and then Present (Universal_Interpretation (L)) and then Present (Universal_Interpretation (R)) then Resolve (L, Universal_Interpretation (L)); Resolve (R, Universal_Interpretation (R)); Set_Etype (N, B_Typ); elsif (B_Typ = Universal_Real or else Etype (N) = Universal_Fixed or else (Etype (N) = Any_Fixed and then Is_Fixed_Point_Type (B_Typ)) or else (Is_Fixed_Point_Type (B_Typ) and then (Is_Integer_Or_Universal (L) or else Is_Integer_Or_Universal (R)))) and then (Nkind (N) = N_Op_Multiply or else Nkind (N) = N_Op_Divide) then if TL = Universal_Integer or else TR = Universal_Integer then Check_For_Visible_Operator (N, B_Typ); end if; -- If context is a fixed type and one operand is integer, the -- other is resolved with the type of the context. if Is_Fixed_Point_Type (B_Typ) and then (Base_Type (TL) = Base_Type (Standard_Integer) or else TL = Universal_Integer) then Resolve (R, B_Typ); Resolve (L, TL); elsif Is_Fixed_Point_Type (B_Typ) and then (Base_Type (TR) = Base_Type (Standard_Integer) or else TR = Universal_Integer) then Resolve (L, B_Typ); Resolve (R, TR); else Set_Mixed_Mode_Operand (L, TR); Set_Mixed_Mode_Operand (R, TL); end if; if Etype (N) = Universal_Fixed or else Etype (N) = Any_Fixed then if B_Typ = Universal_Fixed and then Nkind (Parent (N)) /= N_Type_Conversion and then Nkind (Parent (N)) /= N_Unchecked_Type_Conversion then Error_Msg_N ("type cannot be determined from context!", N); Error_Msg_N ("\explicit conversion to result type required", N); Set_Etype (L, Any_Type); Set_Etype (R, Any_Type); else if Ada_83 and then Etype (N) = Universal_Fixed and then Nkind (Parent (N)) /= N_Type_Conversion and then Nkind (Parent (N)) /= N_Unchecked_Type_Conversion then Error_Msg_N ("(Ada 83) fixed-point operation " & "needs explicit conversion", N); end if; Set_Etype (N, B_Typ); end if; elsif Is_Fixed_Point_Type (B_Typ) and then (Is_Integer_Or_Universal (L) or else Nkind (L) = N_Real_Literal or else Nkind (R) = N_Real_Literal or else Is_Integer_Or_Universal (R)) then Set_Etype (N, B_Typ); elsif Etype (N) = Any_Fixed then -- If no previous errors, this is only possible if one operand -- is overloaded and the context is universal. Resolve as such. Set_Etype (N, B_Typ); end if; else if (TL = Universal_Integer or else TL = Universal_Real) and then (TR = Universal_Integer or else TR = Universal_Real) then Check_For_Visible_Operator (N, B_Typ); end if; -- If the context is Universal_Fixed and the operands are also -- universal fixed, this is an error, unless there is only one -- applicable fixed_point type (usually duration). if B_Typ = Universal_Fixed and then Etype (L) = Universal_Fixed then T := Unique_Fixed_Point_Type (N); if T = Any_Type then Set_Etype (N, T); return; else Resolve (L, T); Resolve (R, T); end if; else Resolve (L, B_Typ); Resolve (R, B_Typ); end if; -- If one of the arguments was resolved to a non-universal type. -- label the result of the operation itself with the same type. -- Do the same for the universal argument, if any. T := Intersect_Types (L, R); Set_Etype (N, Base_Type (T)); Set_Operand_Type (L); Set_Operand_Type (R); end if; Generate_Operator_Reference (N); Eval_Arithmetic_Op (N); -- Set overflow and division checking bit. Much cleverer code needed -- here eventually and perhaps the Resolve routines should be separated -- for the various arithmetic operations, since they will need -- different processing. ??? if Nkind (N) in N_Op then if not Overflow_Checks_Suppressed (Etype (N)) then Set_Do_Overflow_Check (N); end if; if (Nkind (N) = N_Op_Divide or else Nkind (N) = N_Op_Rem or else Nkind (N) = N_Op_Mod) and then not Division_Checks_Suppressed (Etype (N)) then Set_Do_Division_Check (N); end if; end if; Check_Unset_Reference (L); Check_Unset_Reference (R); end Resolve_Arithmetic_Op; ------------------ -- Resolve_Call -- ------------------ procedure Resolve_Call (N : Node_Id; Typ : Entity_Id) is Loc : constant Source_Ptr := Sloc (N); Subp : constant Node_Id := Name (N); Nam : Entity_Id; I : Interp_Index; It : Interp; Norm_OK : Boolean; Scop : Entity_Id; begin -- The context imposes a unique interpretation with type Typ on -- a procedure or function call. Find the entity of the subprogram -- that yields the expected type, and propagate the corresponding -- formal constraints on the actuals. The caller has established -- that an interpretation exists, and emitted an error if not unique. -- First deal with the case of a call to an access-to-subprogram, -- dereference made explicit in Analyze_Call. if Ekind (Etype (Subp)) = E_Subprogram_Type then if not Is_Overloaded (Subp) then Nam := Etype (Subp); else -- Find the interpretation whose type (a subprogram type) -- has a return type that is compatible with the context. -- Analysis of the node has established that one exists. Get_First_Interp (Subp, I, It); Nam := Empty; while Present (It.Typ) loop if Covers (Typ, Etype (It.Typ)) then Nam := It.Typ; exit; end if; Get_Next_Interp (I, It); end loop; if No (Nam) then raise Program_Error; end if; end if; -- If the prefix is not an entity, then resolve it if not Is_Entity_Name (Subp) then Resolve (Subp, Nam); end if; -- If this is a procedure call which is really an entry call, do -- the conversion of the procedure call to an entry call. Protected -- operations use the same circuitry because the name in the call -- can be an arbitrary expression with special resolution rules. elsif Nkind (Subp) = N_Selected_Component or else Nkind (Subp) = N_Indexed_Component or else (Is_Entity_Name (Subp) and then Ekind (Entity (Subp)) = E_Entry) then Resolve_Entry_Call (N, Typ); Check_Elab_Call (N); return; -- Normal subprogram call with name established in Resolve elsif not (Is_Type (Entity (Subp))) then Nam := Entity (Subp); Set_Entity_With_Style_Check (Subp, Nam); Generate_Reference (Nam, Subp); -- Otherwise we must have the case of an overloaded call else pragma Assert (Is_Overloaded (Subp)); Nam := Empty; -- We know that it will be assigned in loop below. Get_First_Interp (Subp, I, It); while Present (It.Typ) loop if Covers (Typ, It.Typ) then Nam := It.Nam; Set_Entity_With_Style_Check (Subp, Nam); Generate_Reference (Nam, Subp); exit; end if; Get_Next_Interp (I, It); end loop; end if; -- Check that a call to Current_Task does not occur in an entry body if Is_RTE (Nam, RE_Current_Task) then declare P : Node_Id; begin P := N; loop P := Parent (P); exit when No (P); if Nkind (P) = N_Entry_Body then Error_Msg_NE ("& should not be used in entry body ('R'M C.7(17))", N, Nam); exit; end if; end loop; end; end if; -- Check that a procedure call does not occur in the context -- of the entry call statement of a conditional or timed -- entry call. Note that the case of a call to a subprogram -- renaming of an entry will also be rejected. The test -- for N not being an N_Entry_Call_Statement is defensive, -- covering the possibility that the processing of entry -- calls might reach this point due to later modifications -- of the code above. if Nkind (Parent (N)) = N_Entry_Call_Alternative and then Nkind (N) /= N_Entry_Call_Statement and then Entry_Call_Statement (Parent (N)) = N then Error_Msg_N ("entry call required in select statement", N); end if; -- Freeze the subprogram name if not in default expression. Note -- that we freeze procedure calls as well as function calls. -- Procedure calls are not frozen according to the rules (RM -- 13.14(14)) because it is impossible to have a procedure call to -- a non-frozen procedure in pure Ada, but in the code that we -- generate in the expander, this rule needs extending because we -- can generate procedure calls that need freezing. if Is_Entity_Name (Subp) and then not In_Default_Expression then Freeze_Expression (Subp); end if; -- For a predefined operator, the type of the result is the type -- imposed by context, except for a predefined operation on universal -- fixed. Otherwise The type of the call is the type returned by the -- subprogram being called. if Is_Predefined_Op (Nam) then if Etype (N) /= Universal_Fixed then Set_Etype (N, Typ); end if; -- If the subprogram returns an array type, and the context -- requires the component type of that array type, the node is -- really an indexing of the parameterless call. Resolve as such. elsif Needs_No_Actuals (Nam) and then ((Is_Array_Type (Etype (Nam)) and then Covers (Typ, Component_Type (Etype (Nam)))) or else (Is_Access_Type (Etype (Nam)) and then Is_Array_Type (Designated_Type (Etype (Nam))) and then Covers (Typ, Component_Type (Designated_Type (Etype (Nam)))))) then declare Index_Node : Node_Id; begin if Component_Type (Etype (Nam)) /= Any_Type then Index_Node := Make_Indexed_Component (Loc, Prefix => Make_Function_Call (Loc, Name => New_Occurrence_Of (Nam, Loc)), Expressions => Parameter_Associations (N)); -- Since we are correcting a node classification error made by -- the parser, we call Replace rather than Rewrite. Replace (N, Index_Node); Set_Etype (Prefix (N), Etype (Nam)); Set_Etype (N, Typ); Resolve_Indexed_Component (N, Typ); Check_Elab_Call (Prefix (N)); end if; return; end; else Set_Etype (N, Etype (Nam)); end if; -- In the case where the call is to an overloaded subprogram, Analyze -- calls Normalize_Actuals once per overloaded subprogram. Therefore in -- such a case Normalize_Actuals needs to be called once more to order -- the actuals correctly. Otherwise the call will have the ordering -- given by the last overloaded subprogram whether this is the correct -- one being called or not. if Is_Overloaded (Subp) then Normalize_Actuals (N, Nam, False, Norm_OK); pragma Assert (Norm_OK); end if; -- In any case, call is fully resolved now. Reset Overload flag, to -- prevent subsequent overload resolution if node is analyzed again Set_Is_Overloaded (Subp, False); Set_Is_Overloaded (N, False); -- If we are calling the current subprogram from immediately within -- its body, then that is the case where we can sometimes detect -- cases of infinite recursion statically. Do not try this in case -- restriction No_Recursion is in effect anyway. Scop := Current_Scope; if Nam = Scop and then not Restrictions (No_Recursion) and then Check_Infinite_Recursion (N) then -- Here we detected and flagged an infinite recursion, so we do -- not need to test the case below for further warnings. null; -- If call is to immediately containing subprogram, then check for -- the case of a possible run-time detectable infinite recursion. else while Scop /= Standard_Standard loop if Nam = Scop then -- Although in general recursion is not statically checkable, -- the case of calling an immediately containing subprogram -- is easy to catch. Check_Restriction (No_Recursion, N); -- If the recursive call is to a parameterless procedure, then -- even if we can't statically detect infinite recursion, this -- is pretty suspicious, and we output a warning. Furthermore, -- we will try later to detect some cases here at run time by -- expanding checking code (see Detect_Infinite_Recursion in -- package Exp_Ch6). -- If the recursive call is within a handler we do not emit a -- warning, because this is a common idiom: loop until input -- is correct, catch illegal input in handler and restart. if No (First_Formal (Nam)) and then Etype (Nam) = Standard_Void_Type and then not Error_Posted (N) and then Nkind (Parent (N)) /= N_Exception_Handler then Set_Has_Recursive_Call (Nam); Error_Msg_N ("possible infinite recursion?", N); Error_Msg_N ("Storage_Error may be raised at run time?", N); end if; exit; end if; Scop := Scope (Scop); end loop; end if; -- If subprogram name is a predefined operator, it was given in -- functional notation. Replace call node with operator node, so -- that actuals can be resolved appropriately. if Is_Predefined_Op (Nam) or else Ekind (Nam) = E_Operator then Make_Call_Into_Operator (N, Typ, Entity (Name (N))); return; elsif Present (Alias (Nam)) and then Is_Predefined_Op (Alias (Nam)) then Resolve_Actuals (N, Nam); Make_Call_Into_Operator (N, Typ, Alias (Nam)); return; end if; -- Create a transient scope if the resulting type requires it. -- There are 3 notable exceptions: in init_procs, the transient scope -- overhead is not needed and even incorrect due to the actual expansion -- of adjust calls; the second case is enumeration literal pseudo calls, -- the other case is intrinsic subprograms (Unchecked_Conversion and -- source information functions) that do not use the secondary stack -- even though the return type is unconstrained. -- If this is an initialization call for a type whose initialization -- uses the secondary stack, we also need to create a transient scope -- for it, precisely because we will not do it within the init_proc -- itself. if Expander_Active and then Is_Type (Etype (Nam)) and then Requires_Transient_Scope (Etype (Nam)) and then Ekind (Nam) /= E_Enumeration_Literal and then not Within_Init_Proc and then not Is_Intrinsic_Subprogram (Nam) then Establish_Transient_Scope (N, Sec_Stack => not Functions_Return_By_DSP_On_Target); elsif Chars (Nam) = Name_uInit_Proc and then not Within_Init_Proc then Check_Initialization_Call (N, Nam); end if; -- A protected function cannot be called within the definition of the -- enclosing protected type. if Is_Protected_Type (Scope (Nam)) and then In_Open_Scopes (Scope (Nam)) and then not Has_Completion (Scope (Nam)) then Error_Msg_NE ("& cannot be called before end of protected definition", N, Nam); end if; -- Propagate interpretation to actuals, and add default expressions -- where needed. if Present (First_Formal (Nam)) then Resolve_Actuals (N, Nam); -- Overloaded literals are rewritten as function calls, for -- purpose of resolution. After resolution, we can replace -- the call with the literal itself. elsif Ekind (Nam) = E_Enumeration_Literal then Copy_Node (Subp, N); Resolve_Entity_Name (N, Typ); -- Avoid validation, since it is a static function call. return; end if; -- If the subprogram is a primitive operation, check whether or not -- it is a correct dispatching call. if Is_Overloadable (Nam) and then Is_Dispatching_Operation (Nam) then Check_Dispatching_Call (N); -- If the subprogram is abstract, check that the call has a -- controlling argument (i.e. is dispatching) or is disptaching on -- result if Is_Abstract (Nam) and then No (Controlling_Argument (N)) and then not Is_Class_Wide_Type (Typ) and then not Is_Tag_Indeterminate (N) then Error_Msg_N ("call to abstract subprogram must be dispatching", N); end if; elsif Is_Abstract (Nam) and then not In_Instance then Error_Msg_NE ("cannot call abstract subprogram &!", N, Nam); end if; if Is_Intrinsic_Subprogram (Nam) then Check_Intrinsic_Call (N); end if; -- If we fall through we definitely have a non-static call Check_Elab_Call (N); end Resolve_Call; ------------------------------- -- Resolve_Character_Literal -- ------------------------------- procedure Resolve_Character_Literal (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); C : Entity_Id; begin -- Verify that the character does belong to the type of the context Set_Etype (N, B_Typ); Eval_Character_Literal (N); -- Wide_Character literals must always be defined, since the set of -- wide character literals is complete, i.e. if a character literal -- is accepted by the parser, then it is OK for wide character. if Root_Type (B_Typ) = Standard_Wide_Character then return; -- Always accept character literal for type Any_Character, which -- occurs in error situations and in comparisons of literals, both -- of which should accept all literals. elsif B_Typ = Any_Character then return; -- For Standard.Character or a type derived from it, check that -- the literal is in range elsif Root_Type (B_Typ) = Standard_Character then if In_Character_Range (Char_Literal_Value (N)) then return; end if; -- If the entity is already set, this has already been resolved in -- a generic context, or comes from expansion. Nothing else to do. elsif Present (Entity (N)) then return; -- Otherwise we have a user defined character type, and we can use -- the standard visibility mechanisms to locate the referenced entity else C := Current_Entity (N); while Present (C) loop if Etype (C) = B_Typ then Set_Entity_With_Style_Check (N, C); Generate_Reference (C, N); return; end if; C := Homonym (C); end loop; end if; -- If we fall through, then the literal does not match any of the -- entries of the enumeration type. This isn't just a constraint -- error situation, it is an illegality (see RM 4.2). Error_Msg_NE ("character not defined for }", N, First_Subtype (B_Typ)); end Resolve_Character_Literal; --------------------------- -- Resolve_Comparison_Op -- --------------------------- -- Context requires a boolean type, and plays no role in resolution. -- Processing identical to that for equality operators. procedure Resolve_Comparison_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; begin -- If this is an intrinsic operation which is not predefined, use -- the types of its declared arguments to resolve the possibly -- overloaded operands. Otherwise the operands are unambiguous and -- specify the expected type. if Scope (Entity (N)) /= Standard_Standard then T := Etype (First_Entity (Entity (N))); else T := Find_Unique_Type (L, R); if T = Any_Fixed then T := Unique_Fixed_Point_Type (L); end if; end if; Set_Etype (N, Typ); Generate_Reference (T, N, ' '); if T /= Any_Type then if T = Any_String or else T = Any_Composite or else T = Any_Character then if T = Any_Character then Ambiguous_Character (L); else Error_Msg_N ("ambiguous operands for comparison", N); end if; Set_Etype (N, Any_Type); return; else if Comes_From_Source (N) and then Has_Unchecked_Union (T) then Error_Msg_N ("cannot compare Unchecked_Union values", N); end if; Resolve (L, T); Resolve (R, T); Check_Unset_Reference (L); Check_Unset_Reference (R); Generate_Operator_Reference (N); Eval_Relational_Op (N); end if; end if; end Resolve_Comparison_Op; ------------------------------------ -- Resolve_Conditional_Expression -- ------------------------------------ procedure Resolve_Conditional_Expression (N : Node_Id; Typ : Entity_Id) is Condition : constant Node_Id := First (Expressions (N)); Then_Expr : constant Node_Id := Next (Condition); Else_Expr : constant Node_Id := Next (Then_Expr); begin Resolve (Condition, Standard_Boolean); Resolve (Then_Expr, Typ); Resolve (Else_Expr, Typ); Set_Etype (N, Typ); Eval_Conditional_Expression (N); end Resolve_Conditional_Expression; ----------------------------------------- -- Resolve_Discrete_Subtype_Indication -- ----------------------------------------- procedure Resolve_Discrete_Subtype_Indication (N : Node_Id; Typ : Entity_Id) is R : Node_Id; S : Entity_Id; begin Analyze (Subtype_Mark (N)); S := Entity (Subtype_Mark (N)); if Nkind (Constraint (N)) /= N_Range_Constraint then Error_Msg_N ("expect range constraint for discrete type", N); Set_Etype (N, Any_Type); else R := Range_Expression (Constraint (N)); if R = Error then return; end if; Analyze (R); if Base_Type (S) /= Base_Type (Typ) then Error_Msg_NE ("expect subtype of }", N, First_Subtype (Typ)); -- Rewrite the constraint as a range of Typ -- to allow compilation to proceed further. Set_Etype (N, Typ); Rewrite (Low_Bound (R), Make_Attribute_Reference (Sloc (Low_Bound (R)), Prefix => New_Occurrence_Of (Typ, Sloc (R)), Attribute_Name => Name_First)); Rewrite (High_Bound (R), Make_Attribute_Reference (Sloc (High_Bound (R)), Prefix => New_Occurrence_Of (Typ, Sloc (R)), Attribute_Name => Name_First)); else Resolve (R, Typ); Set_Etype (N, Etype (R)); -- Additionally, we must check that the bounds are compatible -- with the given subtype, which might be different from the -- type of the context. Apply_Range_Check (R, S); -- ??? If the above check statically detects a Constraint_Error -- it replaces the offending bound(s) of the range R with a -- Constraint_Error node. When the itype which uses these bounds -- is frozen the resulting call to Duplicate_Subexpr generates -- a new temporary for the bounds. -- Unfortunately there are other itypes that are also made depend -- on these bounds, so when Duplicate_Subexpr is called they get -- a forward reference to the newly created temporaries and Gigi -- aborts on such forward references. This is probably sign of a -- more fundamental problem somewhere else in either the order of -- itype freezing or the way certain itypes are constructed. -- To get around this problem we call Remove_Side_Effects right -- away if either bounds of R are a Constraint_Error. declare L : Node_Id := Low_Bound (R); H : Node_Id := High_Bound (R); begin if Nkind (L) = N_Raise_Constraint_Error then Remove_Side_Effects (L); end if; if Nkind (H) = N_Raise_Constraint_Error then Remove_Side_Effects (H); end if; end; Check_Unset_Reference (Low_Bound (R)); Check_Unset_Reference (High_Bound (R)); end if; end if; end Resolve_Discrete_Subtype_Indication; ------------------------- -- Resolve_Entity_Name -- ------------------------- -- Used to resolve identifiers and expanded names procedure Resolve_Entity_Name (N : Node_Id; Typ : Entity_Id) is E : constant Entity_Id := Entity (N); begin -- Replace named numbers by corresponding literals. Note that this is -- the one case where Resolve_Entity_Name must reset the Etype, since -- it is currently marked as universal. if Ekind (E) = E_Named_Integer then Set_Etype (N, Typ); Eval_Named_Integer (N); elsif Ekind (E) = E_Named_Real then Set_Etype (N, Typ); Eval_Named_Real (N); -- Allow use of subtype only if it is a concurrent type where we are -- currently inside the body. This will eventually be expanded -- into a call to Self (for tasks) or _object (for protected -- objects). Any other use of a subtype is invalid. elsif Is_Type (E) then if Is_Concurrent_Type (E) and then In_Open_Scopes (E) then null; else Error_Msg_N ("Invalid use of subtype mark in expression or call", N); end if; -- Check discriminant use if entity is discriminant in current scope, -- i.e. discriminant of record or concurrent type currently being -- analyzed. Uses in corresponding body are unrestricted. elsif Ekind (E) = E_Discriminant and then Scope (E) = Current_Scope and then not Has_Completion (Current_Scope) then Check_Discriminant_Use (N); -- A parameterless generic function cannot appear in a context that -- requires resolution. elsif Ekind (E) = E_Generic_Function then Error_Msg_N ("illegal use of generic function", N); elsif Ekind (E) = E_Out_Parameter and then Ada_83 and then (Nkind (Parent (N)) in N_Op or else (Nkind (Parent (N)) = N_Assignment_Statement and then N = Expression (Parent (N))) or else Nkind (Parent (N)) = N_Explicit_Dereference) then Error_Msg_N ("(Ada 83) illegal reading of out parameter", N); -- In all other cases, just do the possible static evaluation else -- A deferred constant that appears in an expression must have -- a completion, unless it has been removed by in-place expansion -- of an aggregate. if Ekind (E) = E_Constant and then Comes_From_Source (E) and then No (Constant_Value (E)) and then Is_Frozen (Etype (E)) and then not In_Default_Expression and then not Is_Imported (E) then if No_Initialization (Parent (E)) or else (Present (Full_View (E)) and then No_Initialization (Parent (Full_View (E)))) then null; else Error_Msg_N ( "deferred constant is frozen before completion", N); end if; end if; Eval_Entity_Name (N); end if; end Resolve_Entity_Name; ------------------- -- Resolve_Entry -- ------------------- procedure Resolve_Entry (Entry_Name : Node_Id) is Loc : constant Source_Ptr := Sloc (Entry_Name); Nam : Entity_Id; New_N : Node_Id; S : Entity_Id; Tsk : Entity_Id; E_Name : Node_Id; Index : Node_Id; function Actual_Index_Type (E : Entity_Id) return Entity_Id; -- If the bounds of the entry family being called depend on task -- discriminants, build a new index subtype where a discriminant is -- replaced with the value of the discriminant of the target task. -- The target task is the prefix of the entry name in the call. ----------------------- -- Actual_Index_Type -- ----------------------- function Actual_Index_Type (E : Entity_Id) return Entity_Id is Typ : Entity_Id := Entry_Index_Type (E); Tsk : Entity_Id := Scope (E); Lo : Node_Id := Type_Low_Bound (Typ); Hi : Node_Id := Type_High_Bound (Typ); New_T : Entity_Id; function Actual_Discriminant_Ref (Bound : Node_Id) return Node_Id; -- If the bound is given by a discriminant, replace with a reference -- to the discriminant of the same name in the target task. -- If the entry name is the target of a requeue statement and the -- entry is in the current protected object, the bound to be used -- is the discriminal of the object (see apply_range_checks for -- details of the transformation). ----------------------------- -- Actual_Discriminant_Ref -- ----------------------------- function Actual_Discriminant_Ref (Bound : Node_Id) return Node_Id is Typ : Entity_Id := Etype (Bound); Ref : Node_Id; begin Remove_Side_Effects (Bound); if not Is_Entity_Name (Bound) or else Ekind (Entity (Bound)) /= E_Discriminant then return Bound; elsif Is_Protected_Type (Tsk) and then In_Open_Scopes (Tsk) and then Nkind (Parent (Entry_Name)) = N_Requeue_Statement then return New_Occurrence_Of (Discriminal (Entity (Bound)), Loc); else Ref := Make_Selected_Component (Loc, Prefix => New_Copy_Tree (Prefix (Prefix (Entry_Name))), Selector_Name => New_Occurrence_Of (Entity (Bound), Loc)); Analyze (Ref); Resolve (Ref, Typ); return Ref; end if; end Actual_Discriminant_Ref; -- Start of processing for Actual_Index_Type begin if not Has_Discriminants (Tsk) or else (not Is_Entity_Name (Lo) and then not Is_Entity_Name (Hi)) then return Entry_Index_Type (E); else New_T := Create_Itype (Ekind (Typ), Parent (Entry_Name)); Set_Etype (New_T, Base_Type (Typ)); Set_Size_Info (New_T, Typ); Set_RM_Size (New_T, RM_Size (Typ)); Set_Scalar_Range (New_T, Make_Range (Sloc (Entry_Name), Low_Bound => Actual_Discriminant_Ref (Lo), High_Bound => Actual_Discriminant_Ref (Hi))); return New_T; end if; end Actual_Index_Type; -- Start of processing of Resolve_Entry begin -- Find name of entry being called, and resolve prefix of name -- with its own type. The prefix can be overloaded, and the name -- and signature of the entry must be taken into account. if Nkind (Entry_Name) = N_Indexed_Component then -- Case of dealing with entry family within the current tasks E_Name := Prefix (Entry_Name); else E_Name := Entry_Name; end if; if Is_Entity_Name (E_Name) then -- Entry call to an entry (or entry family) in the current task. -- This is legal even though the task will deadlock. Rewrite as -- call to current task. -- This can also be a call to an entry in an enclosing task. -- If this is a single task, we have to retrieve its name, -- because the scope of the entry is the task type, not the -- object. If the enclosing task is a task type, the identity -- of the task is given by its own self variable. -- Finally this can be a requeue on an entry of the same task -- or protected object. S := Scope (Entity (E_Name)); for J in reverse 0 .. Scope_Stack.Last loop if Is_Task_Type (Scope_Stack.Table (J).Entity) and then not Comes_From_Source (S) then -- S is an enclosing task or protected object. The concurrent -- declaration has been converted into a type declaration, and -- the object itself has an object declaration that follows -- the type in the same declarative part. Tsk := Next_Entity (S); while Etype (Tsk) /= S loop Next_Entity (Tsk); end loop; S := Tsk; exit; elsif S = Scope_Stack.Table (J).Entity then -- Call to current task. Will be transformed into call to Self exit; end if; end loop; New_N := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (S, Loc), Selector_Name => New_Occurrence_Of (Entity (E_Name), Loc)); Rewrite (E_Name, New_N); Analyze (E_Name); elsif Nkind (Entry_Name) = N_Selected_Component and then Is_Overloaded (Prefix (Entry_Name)) then -- Use the entry name (which must be unique at this point) to -- find the prefix that returns the corresponding task type or -- protected type. declare Pref : Node_Id := Prefix (Entry_Name); I : Interp_Index; It : Interp; Ent : Entity_Id := Entity (Selector_Name (Entry_Name)); begin Get_First_Interp (Pref, I, It); while Present (It.Typ) loop if Scope (Ent) = It.Typ then Set_Etype (Pref, It.Typ); exit; end if; Get_Next_Interp (I, It); end loop; end; end if; if Nkind (Entry_Name) = N_Selected_Component then Resolve (Prefix (Entry_Name), Etype (Prefix (Entry_Name))); else pragma Assert (Nkind (Entry_Name) = N_Indexed_Component); Nam := Entity (Selector_Name (Prefix (Entry_Name))); Resolve (Prefix (Prefix (Entry_Name)), Etype (Prefix (Prefix (Entry_Name)))); Index := First (Expressions (Entry_Name)); Resolve (Index, Entry_Index_Type (Nam)); -- Up to this point the expression could have been the actual -- in a simple entry call, and be given by a named association. if Nkind (Index) = N_Parameter_Association then Error_Msg_N ("expect expression for entry index", Index); else Apply_Range_Check (Index, Actual_Index_Type (Nam)); end if; end if; end Resolve_Entry; ------------------------ -- Resolve_Entry_Call -- ------------------------ procedure Resolve_Entry_Call (N : Node_Id; Typ : Entity_Id) is Entry_Name : constant Node_Id := Name (N); Loc : constant Source_Ptr := Sloc (Entry_Name); Actuals : List_Id; First_Named : Node_Id; Nam : Entity_Id; Norm_OK : Boolean; Obj : Node_Id; Was_Over : Boolean; begin -- Processing of the name is similar for entry calls and protected -- operation calls. Once the entity is determined, we can complete -- the resolution of the actuals. -- The selector may be overloaded, in the case of a protected object -- with overloaded functions. The type of the context is used for -- resolution. if Nkind (Entry_Name) = N_Selected_Component and then Is_Overloaded (Selector_Name (Entry_Name)) and then Typ /= Standard_Void_Type then declare I : Interp_Index; It : Interp; begin Get_First_Interp (Selector_Name (Entry_Name), I, It); while Present (It.Typ) loop if Covers (Typ, It.Typ) then Set_Entity (Selector_Name (Entry_Name), It.Nam); Set_Etype (Entry_Name, It.Typ); Generate_Reference (It.Typ, N, ' '); end if; Get_Next_Interp (I, It); end loop; end; end if; Resolve_Entry (Entry_Name); if Nkind (Entry_Name) = N_Selected_Component then -- Simple entry call. Nam := Entity (Selector_Name (Entry_Name)); Obj := Prefix (Entry_Name); Was_Over := Is_Overloaded (Selector_Name (Entry_Name)); else pragma Assert (Nkind (Entry_Name) = N_Indexed_Component); -- Call to member of entry family. Nam := Entity (Selector_Name (Prefix (Entry_Name))); Obj := Prefix (Prefix (Entry_Name)); Was_Over := Is_Overloaded (Selector_Name (Prefix (Entry_Name))); end if; -- Use context type to disambiguate a protected function that can be -- called without actuals and that returns an array type, and where -- the argument list may be an indexing of the returned value. if Ekind (Nam) = E_Function and then Needs_No_Actuals (Nam) and then Present (Parameter_Associations (N)) and then ((Is_Array_Type (Etype (Nam)) and then Covers (Typ, Component_Type (Etype (Nam)))) or else (Is_Access_Type (Etype (Nam)) and then Is_Array_Type (Designated_Type (Etype (Nam))) and then Covers (Typ, Component_Type (Designated_Type (Etype (Nam)))))) then declare Index_Node : Node_Id; begin Index_Node := Make_Indexed_Component (Loc, Prefix => Make_Function_Call (Loc, Name => Relocate_Node (Entry_Name)), Expressions => Parameter_Associations (N)); -- Since we are correcting a node classification error made by -- the parser, we call Replace rather than Rewrite. Replace (N, Index_Node); Set_Etype (Prefix (N), Etype (Nam)); Set_Etype (N, Typ); Resolve_Indexed_Component (N, Typ); return; end; end if; -- The operation name may have been overloaded. Order the actuals -- according to the formals of the resolved entity. if Was_Over then Normalize_Actuals (N, Nam, False, Norm_OK); pragma Assert (Norm_OK); end if; Resolve_Actuals (N, Nam); Generate_Reference (Nam, Entry_Name); if Ekind (Nam) = E_Entry or else Ekind (Nam) = E_Entry_Family then Check_Potentially_Blocking_Operation (N); end if; -- Verify that a procedure call cannot masquerade as an entry -- call where an entry call is expected. if Ekind (Nam) = E_Procedure then if Nkind (Parent (N)) = N_Entry_Call_Alternative and then N = Entry_Call_Statement (Parent (N)) then Error_Msg_N ("entry call required in select statement", N); elsif Nkind (Parent (N)) = N_Triggering_Alternative and then N = Triggering_Statement (Parent (N)) then Error_Msg_N ("triggering statement cannot be procedure call", N); elsif Ekind (Scope (Nam)) = E_Task_Type and then not In_Open_Scopes (Scope (Nam)) then Error_Msg_N ("Task has no entry with this name", Entry_Name); end if; end if; -- After resolution, entry calls and protected procedure calls -- are changed into entry calls, for expansion. The structure -- of the node does not change, so it can safely be done in place. -- Protected function calls must keep their structure because they -- are subexpressions. if Ekind (Nam) /= E_Function then -- A protected operation that is not a function may modify the -- corresponding object, and cannot apply to a constant. -- If this is an internal call, the prefix is the type itself. if Is_Protected_Type (Scope (Nam)) and then not Is_Variable (Obj) and then (not Is_Entity_Name (Obj) or else not Is_Type (Entity (Obj))) then Error_Msg_N ("prefix of protected procedure or entry call must be variable", Entry_Name); end if; Actuals := Parameter_Associations (N); First_Named := First_Named_Actual (N); Rewrite (N, Make_Entry_Call_Statement (Loc, Name => Entry_Name, Parameter_Associations => Actuals)); Set_First_Named_Actual (N, First_Named); Set_Analyzed (N, True); -- Protected functions can return on the secondary stack, in which -- case we must trigger the transient scope mechanism elsif Expander_Active and then Requires_Transient_Scope (Etype (Nam)) then Establish_Transient_Scope (N, Sec_Stack => not Functions_Return_By_DSP_On_Target); end if; end Resolve_Entry_Call; ------------------------- -- Resolve_Equality_Op -- ------------------------- -- Both arguments must have the same type, and the boolean context -- does not participate in the resolution. The first pass verifies -- that the interpretation is not ambiguous, and the type of the left -- argument is correctly set, or is Any_Type in case of ambiguity. -- If both arguments are strings or aggregates, allocators, or Null, -- they are ambiguous even though they carry a single (universal) type. -- Diagnose this case here. procedure Resolve_Equality_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id := Find_Unique_Type (L, R); function Find_Unique_Access_Type return Entity_Id; -- In the case of allocators, make a last-ditch attempt to find a single -- access type with the right designated type. This is semantically -- dubious, and of no interest to any real code, but c48008a makes it -- all worthwhile. ----------------------------- -- Find_Unique_Access_Type -- ----------------------------- function Find_Unique_Access_Type return Entity_Id is Acc : Entity_Id; E : Entity_Id; S : Entity_Id := Current_Scope; begin if Ekind (Etype (R)) = E_Allocator_Type then Acc := Designated_Type (Etype (R)); elsif Ekind (Etype (L)) = E_Allocator_Type then Acc := Designated_Type (Etype (L)); else return Empty; end if; while S /= Standard_Standard loop E := First_Entity (S); while Present (E) loop if Is_Type (E) and then Is_Access_Type (E) and then Ekind (E) /= E_Allocator_Type and then Designated_Type (E) = Base_Type (Acc) then return E; end if; Next_Entity (E); end loop; S := Scope (S); end loop; return Empty; end Find_Unique_Access_Type; -- Start of processing for Resolve_Equality_Op begin Set_Etype (N, Base_Type (Typ)); Generate_Reference (T, N, ' '); if T = Any_Fixed then T := Unique_Fixed_Point_Type (L); end if; if T /= Any_Type then if T = Any_String or else T = Any_Composite or else T = Any_Character then if T = Any_Character then Ambiguous_Character (L); else Error_Msg_N ("ambiguous operands for equality", N); end if; Set_Etype (N, Any_Type); return; elsif T = Any_Access or else Ekind (T) = E_Allocator_Type then T := Find_Unique_Access_Type; if No (T) then Error_Msg_N ("ambiguous operands for equality", N); Set_Etype (N, Any_Type); return; end if; end if; if Comes_From_Source (N) and then Has_Unchecked_Union (T) then Error_Msg_N ("cannot compare Unchecked_Union values", N); end if; Resolve (L, T); Resolve (R, T); Check_Unset_Reference (L); Check_Unset_Reference (R); Generate_Operator_Reference (N); -- If this is an inequality, it may be the implicit inequality -- created for a user-defined operation, in which case the corres- -- ponding equality operation is not intrinsic, and the operation -- cannot be constant-folded. Else fold. if Nkind (N) = N_Op_Eq or else Comes_From_Source (Entity (N)) or else Ekind (Entity (N)) = E_Operator or else Is_Intrinsic_Subprogram (Corresponding_Equality (Entity (N))) then Eval_Relational_Op (N); elsif Nkind (N) = N_Op_Ne and then Is_Abstract (Entity (N)) then Error_Msg_NE ("cannot call abstract subprogram &!", N, Entity (N)); end if; end if; end Resolve_Equality_Op; ---------------------------------- -- Resolve_Explicit_Dereference -- ---------------------------------- procedure Resolve_Explicit_Dereference (N : Node_Id; Typ : Entity_Id) is P : constant Node_Id := Prefix (N); I : Interp_Index; It : Interp; begin -- Now that we know the type, check that this is not a -- dereference of an uncompleted type. Note that this -- is not entirely correct, because dereferences of -- private types are legal in default expressions. -- This consideration also applies to similar checks -- for allocators, qualified expressions, and type -- conversions. ??? Check_Fully_Declared (Typ, N); if Is_Overloaded (P) then -- Use the context type to select the prefix that has the -- correct designated type. Get_First_Interp (P, I, It); while Present (It.Typ) loop exit when Is_Access_Type (It.Typ) and then Covers (Typ, Designated_Type (It.Typ)); Get_Next_Interp (I, It); end loop; Resolve (P, It.Typ); Set_Etype (N, Designated_Type (It.Typ)); else Resolve (P, Etype (P)); end if; if Is_Access_Type (Etype (P)) then Apply_Access_Check (N); end if; -- If the designated type is a packed unconstrained array type, -- and the explicit dereference is not in the context of an -- attribute reference, then we must compute and set the actual -- subtype, since it is needed by Gigi. The reason we exclude -- the attribute case is that this is handled fine by Gigi, and -- in fact we use such attributes to build the actual subtype. -- We also exclude generated code (which builds actual subtypes -- directly if they are needed). if Is_Array_Type (Etype (N)) and then Is_Packed (Etype (N)) and then not Is_Constrained (Etype (N)) and then Nkind (Parent (N)) /= N_Attribute_Reference and then Comes_From_Source (N) then Set_Etype (N, Get_Actual_Subtype (N)); end if; -- Note: there is no Eval processing required for an explicit -- deference, because the type is known to be an allocators, and -- allocator expressions can never be static. end Resolve_Explicit_Dereference; ------------------------------- -- Resolve_Indexed_Component -- ------------------------------- procedure Resolve_Indexed_Component (N : Node_Id; Typ : Entity_Id) is Name : constant Node_Id := Prefix (N); Expr : Node_Id; Array_Type : Entity_Id := Empty; -- to prevent junk warning Index : Node_Id; begin if Is_Overloaded (Name) then -- Use the context type to select the prefix that yields the -- correct component type. declare I : Interp_Index; It : Interp; I1 : Interp_Index := 0; P : constant Node_Id := Prefix (N); Found : Boolean := False; begin Get_First_Interp (P, I, It); while Present (It.Typ) loop if (Is_Array_Type (It.Typ) and then Covers (Typ, Component_Type (It.Typ))) or else (Is_Access_Type (It.Typ) and then Is_Array_Type (Designated_Type (It.Typ)) and then Covers (Typ, Component_Type (Designated_Type (It.Typ)))) then if Found then It := Disambiguate (P, I1, I, Any_Type); if It = No_Interp then Error_Msg_N ("ambiguous prefix for indexing", N); Set_Etype (N, Typ); return; else Found := True; Array_Type := It.Typ; I1 := I; end if; else Found := True; Array_Type := It.Typ; I1 := I; end if; end if; Get_Next_Interp (I, It); end loop; end; else Array_Type := Etype (Name); end if; Resolve (Name, Array_Type); Array_Type := Get_Actual_Subtype_If_Available (Name); -- If prefix is access type, dereference to get real array type. -- Note: we do not apply an access check because the expander always -- introduces an explicit dereference, and the check will happen there. if Is_Access_Type (Array_Type) then Array_Type := Designated_Type (Array_Type); end if; -- If name was overloaded, set component type correctly now. Set_Etype (N, Component_Type (Array_Type)); Index := First_Index (Array_Type); Expr := First (Expressions (N)); -- The prefix may have resolved to a string literal, in which case -- its etype has a special representation. This is only possible -- currently if the prefix is a static concatenation, written in -- functional notation. if Ekind (Array_Type) = E_String_Literal_Subtype then Resolve (Expr, Standard_Positive); else while Present (Index) and Present (Expr) loop Resolve (Expr, Etype (Index)); Check_Unset_Reference (Expr); if Is_Scalar_Type (Etype (Expr)) then Apply_Scalar_Range_Check (Expr, Etype (Index)); else Apply_Range_Check (Expr, Get_Actual_Subtype (Index)); end if; Next_Index (Index); Next (Expr); end loop; end if; Eval_Indexed_Component (N); end Resolve_Indexed_Component; ----------------------------- -- Resolve_Integer_Literal -- ----------------------------- procedure Resolve_Integer_Literal (N : Node_Id; Typ : Entity_Id) is begin Set_Etype (N, Typ); Eval_Integer_Literal (N); end Resolve_Integer_Literal; --------------------------------- -- Resolve_Intrinsic_Operator -- --------------------------------- procedure Resolve_Intrinsic_Operator (N : Node_Id; Typ : Entity_Id) is Op : Entity_Id; Arg1 : Node_Id := Left_Opnd (N); Arg2 : Node_Id := Right_Opnd (N); begin Op := Entity (N); while Scope (Op) /= Standard_Standard loop Op := Homonym (Op); pragma Assert (Present (Op)); end loop; Set_Entity (N, Op); if Typ /= Etype (Arg1) or else Typ = Etype (Arg2) then Rewrite (Left_Opnd (N), Convert_To (Typ, Arg1)); Rewrite (Right_Opnd (N), Convert_To (Typ, Arg2)); Analyze (Left_Opnd (N)); Analyze (Right_Opnd (N)); end if; Resolve_Arithmetic_Op (N, Typ); end Resolve_Intrinsic_Operator; ------------------------ -- Resolve_Logical_Op -- ------------------------ procedure Resolve_Logical_Op (N : Node_Id; Typ : Entity_Id) is B_Typ : Entity_Id; begin -- Predefined operations on scalar types yield the base type. On -- the other hand, logical operations on arrays yield the type of -- the arguments (and the context). if Is_Array_Type (Typ) then B_Typ := Typ; else B_Typ := Base_Type (Typ); end if; -- The following test is required because the operands of the operation -- may be literals, in which case the resulting type appears to be -- compatible with a signed integer type, when in fact it is compatible -- only with modular types. If the context itself is universal, the -- operation is illegal. if not Valid_Boolean_Arg (Typ) then Error_Msg_N ("invalid context for logical operation", N); Set_Etype (N, Any_Type); return; elsif Typ = Any_Modular then Error_Msg_N ("no modular type available in this context", N); Set_Etype (N, Any_Type); return; end if; Resolve (Left_Opnd (N), B_Typ); Resolve (Right_Opnd (N), B_Typ); Check_Unset_Reference (Left_Opnd (N)); Check_Unset_Reference (Right_Opnd (N)); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Logical_Op (N); end Resolve_Logical_Op; --------------------------- -- Resolve_Membership_Op -- --------------------------- -- The context can only be a boolean type, and does not determine -- the arguments. Arguments should be unambiguous, but the preference -- rule for universal types applies. procedure Resolve_Membership_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; begin if L = Error or else R = Error then return; end if; if not Is_Overloaded (R) and then (Etype (R) = Universal_Integer or else Etype (R) = Universal_Real) and then Is_Overloaded (L) then T := Etype (R); else T := Intersect_Types (L, R); end if; Resolve (L, T); Check_Unset_Reference (L); if Nkind (R) = N_Range and then not Is_Scalar_Type (T) then Error_Msg_N ("scalar type required for range", R); end if; if Is_Entity_Name (R) then Freeze_Expression (R); else Resolve (R, T); Check_Unset_Reference (R); end if; Eval_Membership_Op (N); end Resolve_Membership_Op; ------------------ -- Resolve_Null -- ------------------ procedure Resolve_Null (N : Node_Id; Typ : Entity_Id) is begin -- For now allow circumvention of the restriction against -- anonymous null access values via a debug switch to allow -- for easier transition. if not Debug_Flag_J and then Ekind (Typ) = E_Anonymous_Access_Type and then Comes_From_Source (N) then -- In the common case of a call which uses an explicitly null -- value for an access parameter, give specialized error msg if Nkind (Parent (N)) = N_Procedure_Call_Statement or else Nkind (Parent (N)) = N_Function_Call then Error_Msg_N ("null is not allowed as argument for an access parameter", N); -- Standard message for all other cases (are there any?) else Error_Msg_N ("null cannot be of an anonymous access type", N); end if; end if; -- In a distributed context, null for a remote access to subprogram -- may need to be replaced with a special record aggregate. In this -- case, return after having done the transformation. if (Ekind (Typ) = E_Record_Type or else Is_Remote_Access_To_Subprogram_Type (Typ)) and then Remote_AST_Null_Value (N, Typ) then return; end if; -- The null literal takes its type from the context. Set_Etype (N, Typ); end Resolve_Null; ----------------------- -- Resolve_Op_Concat -- ----------------------- procedure Resolve_Op_Concat (N : Node_Id; Typ : Entity_Id) is Btyp : constant Entity_Id := Base_Type (Typ); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); procedure Resolve_Concatenation_Arg (Arg : Node_Id; Is_Comp : Boolean); -- Internal procedure to resolve one operand of concatenation operator. -- The operand is either of the array type or of the component type. -- If the operand is an aggregate, and the component type is composite, -- this is ambiguous if component type has aggregates. ------------------------------- -- Resolve_Concatenation_Arg -- ------------------------------- procedure Resolve_Concatenation_Arg (Arg : Node_Id; Is_Comp : Boolean) is begin if In_Instance then if Is_Comp or else (not Is_Overloaded (Arg) and then Etype (Arg) /= Any_Composite and then Covers (Component_Type (Typ), Etype (Arg))) then Resolve (Arg, Component_Type (Typ)); else Resolve (Arg, Btyp); end if; elsif Has_Compatible_Type (Arg, Component_Type (Typ)) then if Nkind (Arg) = N_Aggregate and then Is_Composite_Type (Component_Type (Typ)) then if Is_Private_Type (Component_Type (Typ)) then Resolve (Arg, Btyp); else Error_Msg_N ("ambiguous aggregate must be qualified", Arg); Set_Etype (Arg, Any_Type); end if; else if Is_Overloaded (Arg) and then Has_Compatible_Type (Arg, Typ) and then Etype (Arg) /= Any_Type then Error_Msg_N ("ambiguous operand for concatenation!", Arg); declare I : Interp_Index; It : Interp; begin Get_First_Interp (Arg, I, It); while Present (It.Nam) loop if Base_Type (Etype (It.Nam)) = Base_Type (Typ) or else Base_Type (Etype (It.Nam)) = Base_Type (Component_Type (Typ)) then Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_N ("\possible interpretation#", Arg); end if; Get_Next_Interp (I, It); end loop; end; end if; Resolve (Arg, Component_Type (Typ)); if Arg = Left_Opnd (N) then Set_Is_Component_Left_Opnd (N); else Set_Is_Component_Right_Opnd (N); end if; end if; else Resolve (Arg, Btyp); end if; Check_Unset_Reference (Arg); end Resolve_Concatenation_Arg; -- Start of processing for Resolve_Op_Concat begin Set_Etype (N, Btyp); if Is_Limited_Composite (Btyp) then Error_Msg_N ("concatenation not available for limited array", N); end if; -- If the operands are themselves concatenations, resolve them as -- such directly. This removes several layers of recursion and allows -- GNAT to handle larger multiple concatenations. if Nkind (Op1) = N_Op_Concat and then not Is_Array_Type (Component_Type (Typ)) and then Entity (Op1) = Entity (N) then Resolve_Op_Concat (Op1, Typ); else Resolve_Concatenation_Arg (Op1, Is_Component_Left_Opnd (N)); end if; if Nkind (Op2) = N_Op_Concat and then not Is_Array_Type (Component_Type (Typ)) and then Entity (Op2) = Entity (N) then Resolve_Op_Concat (Op2, Typ); else Resolve_Concatenation_Arg (Op2, Is_Component_Right_Opnd (N)); end if; Generate_Operator_Reference (N); if Is_String_Type (Typ) then Eval_Concatenation (N); end if; -- If this is not a static concatenation, but the result is a -- string type (and not an array of strings) insure that static -- string operands have their subtypes properly constructed. if Nkind (N) /= N_String_Literal and then Is_Character_Type (Component_Type (Typ)) then Set_String_Literal_Subtype (Op1, Typ); Set_String_Literal_Subtype (Op2, Typ); end if; end Resolve_Op_Concat; ---------------------- -- Resolve_Op_Expon -- ---------------------- procedure Resolve_Op_Expon (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); begin -- Catch attempts to do fixed-point exponentation with universal -- operands, which is a case where the illegality is not caught -- during normal operator analysis. if Is_Fixed_Point_Type (Typ) and then Comes_From_Source (N) then Error_Msg_N ("exponentiation not available for fixed point", N); return; end if; if Etype (Left_Opnd (N)) = Universal_Integer or else Etype (Left_Opnd (N)) = Universal_Real then Check_For_Visible_Operator (N, B_Typ); end if; -- We do the resolution using the base type, because intermediate values -- in expressions always are of the base type, not a subtype of it. Resolve (Left_Opnd (N), B_Typ); Resolve (Right_Opnd (N), Standard_Integer); Check_Unset_Reference (Left_Opnd (N)); Check_Unset_Reference (Right_Opnd (N)); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Op_Expon (N); -- Set overflow checking bit. Much cleverer code needed here eventually -- and perhaps the Resolve routines should be separated for the various -- arithmetic operations, since they will need different processing. ??? if Nkind (N) in N_Op then if not Overflow_Checks_Suppressed (Etype (N)) then Set_Do_Overflow_Check (N, True); end if; end if; end Resolve_Op_Expon; -------------------- -- Resolve_Op_Not -- -------------------- procedure Resolve_Op_Not (N : Node_Id; Typ : Entity_Id) is B_Typ : Entity_Id; function Parent_Is_Boolean return Boolean; -- This function determines if the parent node is a boolean operator -- or operation (comparison op, membership test, or short circuit form) -- and the not in question is the left operand of this operation. -- Note that if the not is in parens, then false is returned. function Parent_Is_Boolean return Boolean is begin if Paren_Count (N) /= 0 then return False; else case Nkind (Parent (N)) is when N_Op_And | N_Op_Eq | N_Op_Ge | N_Op_Gt | N_Op_Le | N_Op_Lt | N_Op_Ne | N_Op_Or | N_Op_Xor | N_In | N_Not_In | N_And_Then | N_Or_Else => return Left_Opnd (Parent (N)) = N; when others => return False; end case; end if; end Parent_Is_Boolean; -- Start of processing for Resolve_Op_Not begin -- Predefined operations on scalar types yield the base type. On -- the other hand, logical operations on arrays yield the type of -- the arguments (and the context). if Is_Array_Type (Typ) then B_Typ := Typ; else B_Typ := Base_Type (Typ); end if; if not Valid_Boolean_Arg (Typ) then Error_Msg_N ("invalid operand type for operator&", N); Set_Etype (N, Any_Type); return; elsif (Typ = Universal_Integer or else Typ = Any_Modular) then if Parent_Is_Boolean then Error_Msg_N ("operand of not must be enclosed in parentheses", Right_Opnd (N)); else Error_Msg_N ("no modular type available in this context", N); end if; Set_Etype (N, Any_Type); return; else if not Is_Boolean_Type (Typ) and then Parent_Is_Boolean then Error_Msg_N ("?not expression should be parenthesized here", N); end if; Resolve (Right_Opnd (N), B_Typ); Check_Unset_Reference (Right_Opnd (N)); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Op_Not (N); end if; end Resolve_Op_Not; ----------------------------- -- Resolve_Operator_Symbol -- ----------------------------- -- Nothing to be done, all resolved already procedure Resolve_Operator_Symbol (N : Node_Id; Typ : Entity_Id) is begin null; end Resolve_Operator_Symbol; ---------------------------------- -- Resolve_Qualified_Expression -- ---------------------------------- procedure Resolve_Qualified_Expression (N : Node_Id; Typ : Entity_Id) is Target_Typ : constant Entity_Id := Entity (Subtype_Mark (N)); Expr : constant Node_Id := Expression (N); begin Resolve (Expr, Target_Typ); -- A qualified expression requires an exact match of the type, -- class-wide matching is not allowed. if Is_Class_Wide_Type (Target_Typ) and then Base_Type (Etype (Expr)) /= Base_Type (Target_Typ) then Wrong_Type (Expr, Target_Typ); end if; -- If the target type is unconstrained, then we reset the type of -- the result from the type of the expression. For other cases, the -- actual subtype of the expression is the target type. if Is_Composite_Type (Target_Typ) and then not Is_Constrained (Target_Typ) then Set_Etype (N, Etype (Expr)); end if; Eval_Qualified_Expression (N); end Resolve_Qualified_Expression; ------------------- -- Resolve_Range -- ------------------- procedure Resolve_Range (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Low_Bound (N); H : constant Node_Id := High_Bound (N); begin Set_Etype (N, Typ); Resolve (L, Typ); Resolve (H, Typ); Check_Unset_Reference (L); Check_Unset_Reference (H); -- We have to check the bounds for being within the base range as -- required for a non-static context. Normally this is automatic -- and done as part of evaluating expressions, but the N_Range -- node is an exception, since in GNAT we consider this node to -- be a subexpression, even though in Ada it is not. The circuit -- in Sem_Eval could check for this, but that would put the test -- on the main evaluation path for expressions. Check_Non_Static_Context (L); Check_Non_Static_Context (H); end Resolve_Range; -------------------------- -- Resolve_Real_Literal -- -------------------------- procedure Resolve_Real_Literal (N : Node_Id; Typ : Entity_Id) is Actual_Typ : constant Entity_Id := Etype (N); begin -- Special processing for fixed-point literals to make sure that the -- value is an exact multiple of small where this is required. We -- skip this for the universal real case, and also for generic types. if Is_Fixed_Point_Type (Typ) and then Typ /= Universal_Fixed and then Typ /= Any_Fixed and then not Is_Generic_Type (Typ) then declare Val : constant Ureal := Realval (N); Cintr : constant Ureal := Val / Small_Value (Typ); Cint : constant Uint := UR_Trunc (Cintr); Den : constant Uint := Norm_Den (Cintr); Stat : Boolean; begin -- Case of literal is not an exact multiple of the Small if Den /= 1 then -- For a source program literal for a decimal fixed-point -- type, this is statically illegal (RM 4.9(36)). if Is_Decimal_Fixed_Point_Type (Typ) and then Actual_Typ = Universal_Real and then Comes_From_Source (N) then Error_Msg_N ("value has extraneous low order digits", N); end if; -- Replace literal by a value that is the exact representation -- of a value of the type, i.e. a multiple of the small value, -- by truncation, since Machine_Rounds is false for all GNAT -- fixed-point types (RM 4.9(38)). Stat := Is_Static_Expression (N); Rewrite (N, Make_Real_Literal (Sloc (N), Realval => Small_Value (Typ) * Cint)); Set_Is_Static_Expression (N, Stat); end if; -- In all cases, set the corresponding integer field Set_Corresponding_Integer_Value (N, Cint); end; end if; -- Now replace the actual type by the expected type as usual Set_Etype (N, Typ); Eval_Real_Literal (N); end Resolve_Real_Literal; ----------------------- -- Resolve_Reference -- ----------------------- procedure Resolve_Reference (N : Node_Id; Typ : Entity_Id) is P : constant Node_Id := Prefix (N); begin -- Replace general access with specific type if Ekind (Etype (N)) = E_Allocator_Type then Set_Etype (N, Base_Type (Typ)); end if; Resolve (P, Designated_Type (Etype (N))); -- If we are taking the reference of a volatile entity, then treat -- it as a potential modification of this entity. This is much too -- conservative, but is necessary because remove side effects can -- result in transformations of normal assignments into reference -- sequences that otherwise fail to notice the modification. if Is_Entity_Name (P) and then Is_Volatile (Entity (P)) then Note_Possible_Modification (P); end if; end Resolve_Reference; -------------------------------- -- Resolve_Selected_Component -- -------------------------------- procedure Resolve_Selected_Component (N : Node_Id; Typ : Entity_Id) is Comp : Entity_Id; Comp1 : Entity_Id := Empty; -- prevent junk warning P : constant Node_Id := Prefix (N); S : constant Node_Id := Selector_Name (N); T : Entity_Id := Etype (P); I : Interp_Index; I1 : Interp_Index := 0; -- prevent junk warning It : Interp; It1 : Interp; Found : Boolean; function Init_Component return Boolean; -- Check whether this is the initialization of a component within an -- init_proc (by assignment or call to another init_proc). If true, -- there is no need for a discriminant check. -------------------- -- Init_Component -- -------------------- function Init_Component return Boolean is begin return Inside_Init_Proc and then Nkind (Prefix (N)) = N_Identifier and then Chars (Prefix (N)) = Name_uInit and then Nkind (Parent (Parent (N))) = N_Case_Statement_Alternative; end Init_Component; -- Start of processing for Resolve_Selected_Component begin if Is_Overloaded (P) then -- Use the context type to select the prefix that has a selector -- of the correct name and type. Found := False; Get_First_Interp (P, I, It); Search : while Present (It.Typ) loop if Is_Access_Type (It.Typ) then T := Designated_Type (It.Typ); else T := It.Typ; end if; if Is_Record_Type (T) then Comp := First_Entity (T); while Present (Comp) loop if Chars (Comp) = Chars (S) and then Covers (Etype (Comp), Typ) then if not Found then Found := True; I1 := I; It1 := It; Comp1 := Comp; else It := Disambiguate (P, I1, I, Any_Type); if It = No_Interp then Error_Msg_N ("ambiguous prefix for selected component", N); Set_Etype (N, Typ); return; else It1 := It; if Scope (Comp1) /= It1.Typ then -- Resolution chooses the new interpretation. -- Find the component with the right name. Comp1 := First_Entity (It1.Typ); while Present (Comp1) and then Chars (Comp1) /= Chars (S) loop Comp1 := Next_Entity (Comp1); end loop; end if; exit Search; end if; end if; end if; Comp := Next_Entity (Comp); end loop; end if; Get_Next_Interp (I, It); end loop Search; Resolve (P, It1.Typ); Set_Etype (N, Typ); Set_Entity (S, Comp1); else -- Resolve prefix with its type. Resolve (P, T); end if; -- Deal with access type case if Is_Access_Type (Etype (P)) then Apply_Access_Check (N); T := Designated_Type (Etype (P)); else T := Etype (P); end if; if Has_Discriminants (T) and then Present (Original_Record_Component (Entity (S))) and then Ekind (Original_Record_Component (Entity (S))) = E_Component and then Present (Discriminant_Checking_Func (Original_Record_Component (Entity (S)))) and then not Discriminant_Checks_Suppressed (T) and then not Init_Component then Set_Do_Discriminant_Check (N); end if; if Ekind (Entity (S)) = E_Void then Error_Msg_N ("premature use of component", S); end if; -- If the prefix is a record conversion, this may be a renamed -- discriminant whose bounds differ from those of the original -- one, so we must ensure that a range check is performed. if Nkind (P) = N_Type_Conversion and then Ekind (Entity (S)) = E_Discriminant then Set_Etype (N, Base_Type (Typ)); end if; -- Note: No Eval processing is required, because the prefix is of a -- record type, or protected type, and neither can possibly be static. end Resolve_Selected_Component; ------------------- -- Resolve_Shift -- ------------------- procedure Resolve_Shift (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); begin -- We do the resolution using the base type, because intermediate values -- in expressions always are of the base type, not a subtype of it. Resolve (L, B_Typ); Resolve (R, Standard_Natural); Check_Unset_Reference (L); Check_Unset_Reference (R); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Shift (N); end Resolve_Shift; --------------------------- -- Resolve_Short_Circuit -- --------------------------- procedure Resolve_Short_Circuit (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); begin Resolve (L, B_Typ); Resolve (R, B_Typ); Check_Unset_Reference (L); Check_Unset_Reference (R); Set_Etype (N, B_Typ); Eval_Short_Circuit (N); end Resolve_Short_Circuit; ------------------- -- Resolve_Slice -- ------------------- procedure Resolve_Slice (N : Node_Id; Typ : Entity_Id) is Name : constant Node_Id := Prefix (N); Drange : constant Node_Id := Discrete_Range (N); Array_Type : Entity_Id := Empty; Index : Node_Id; begin if Is_Overloaded (Name) then -- Use the context type to select the prefix that yields the -- correct array type. declare I : Interp_Index; I1 : Interp_Index := 0; It : Interp; P : constant Node_Id := Prefix (N); Found : Boolean := False; begin Get_First_Interp (P, I, It); while Present (It.Typ) loop if (Is_Array_Type (It.Typ) and then Covers (Typ, It.Typ)) or else (Is_Access_Type (It.Typ) and then Is_Array_Type (Designated_Type (It.Typ)) and then Covers (Typ, Designated_Type (It.Typ))) then if Found then It := Disambiguate (P, I1, I, Any_Type); if It = No_Interp then Error_Msg_N ("ambiguous prefix for slicing", N); Set_Etype (N, Typ); return; else Found := True; Array_Type := It.Typ; I1 := I; end if; else Found := True; Array_Type := It.Typ; I1 := I; end if; end if; Get_Next_Interp (I, It); end loop; end; else Array_Type := Etype (Name); end if; Resolve (Name, Array_Type); if Is_Access_Type (Array_Type) then Apply_Access_Check (N); Array_Type := Designated_Type (Array_Type); elsif Is_Entity_Name (Name) or else (Nkind (Name) = N_Function_Call and then not Is_Constrained (Etype (Name))) then Array_Type := Get_Actual_Subtype (Name); end if; -- If name was overloaded, set slice type correctly now Set_Etype (N, Array_Type); -- If the range is specified by a subtype mark, no resolution -- is necessary. if not Is_Entity_Name (Drange) then Index := First_Index (Array_Type); Resolve (Drange, Base_Type (Etype (Index))); if Nkind (Drange) = N_Range then Apply_Range_Check (Drange, Etype (Index)); end if; end if; Set_Slice_Subtype (N); Eval_Slice (N); end Resolve_Slice; ---------------------------- -- Resolve_String_Literal -- ---------------------------- procedure Resolve_String_Literal (N : Node_Id; Typ : Entity_Id) is C_Typ : constant Entity_Id := Component_Type (Typ); R_Typ : constant Entity_Id := Root_Type (C_Typ); Loc : constant Source_Ptr := Sloc (N); Str : constant String_Id := Strval (N); Strlen : constant Nat := String_Length (Str); Subtype_Id : Entity_Id; Need_Check : Boolean; begin -- For a string appearing in a concatenation, defer creation of the -- string_literal_subtype until the end of the resolution of the -- concatenation, because the literal may be constant-folded away. -- This is a useful optimization for long concatenation expressions. -- If the string is an aggregate built for a single character (which -- happens in a non-static context) or a is null string to which special -- checks may apply, we build the subtype. Wide strings must also get -- a string subtype if they come from a one character aggregate. Strings -- generated by attributes might be static, but it is often hard to -- determine whether the enclosing context is static, so we generate -- subtypes for them as well, thus losing some rarer optimizations ??? -- Same for strings that come from a static conversion. Need_Check := (Strlen = 0 and then Typ /= Standard_String) or else Nkind (Parent (N)) /= N_Op_Concat or else (N /= Left_Opnd (Parent (N)) and then N /= Right_Opnd (Parent (N))) or else (Typ = Standard_Wide_String and then Nkind (Original_Node (N)) /= N_String_Literal); -- If the resolving type is itself a string literal subtype, we -- can just reuse it, since there is no point in creating another. if Ekind (Typ) = E_String_Literal_Subtype then Subtype_Id := Typ; elsif Nkind (Parent (N)) = N_Op_Concat and then not Need_Check and then Nkind (Original_Node (N)) /= N_Character_Literal and then Nkind (Original_Node (N)) /= N_Attribute_Reference and then Nkind (Original_Node (N)) /= N_Qualified_Expression and then Nkind (Original_Node (N)) /= N_Type_Conversion then Subtype_Id := Typ; -- Otherwise we must create a string literal subtype. Note that the -- whole idea of string literal subtypes is simply to avoid the need -- for building a full fledged array subtype for each literal. else Set_String_Literal_Subtype (N, Typ); Subtype_Id := Etype (N); end if; if Nkind (Parent (N)) /= N_Op_Concat or else Need_Check then Set_Etype (N, Subtype_Id); Eval_String_Literal (N); end if; if Is_Limited_Composite (Typ) or else Is_Private_Composite (Typ) then Error_Msg_N ("string literal not available for private array", N); Set_Etype (N, Any_Type); return; end if; -- The validity of a null string has been checked in the -- call to Eval_String_Literal. if Strlen = 0 then return; -- Always accept string literal with component type Any_Character, -- which occurs in error situations and in comparisons of literals, -- both of which should accept all literals. elsif R_Typ = Any_Character then return; -- If the type is bit-packed, then we always tranform the string -- literal into a full fledged aggregate. elsif Is_Bit_Packed_Array (Typ) then null; -- Deal with cases of Wide_String and String else -- For Standard.Wide_String, or any other type whose component -- type is Standard.Wide_Character, we know that all the -- characters in the string must be acceptable, since the parser -- accepted the characters as valid character literals. if R_Typ = Standard_Wide_Character then null; -- For the case of Standard.String, or any other type whose -- component type is Standard.Character, we must make sure that -- there are no wide characters in the string, i.e. that it is -- entirely composed of characters in range of type String. -- If the string literal is the result of a static concatenation, -- the test has already been performed on the components, and need -- not be repeated. elsif R_Typ = Standard_Character and then Nkind (Original_Node (N)) /= N_Op_Concat then for J in 1 .. Strlen loop if not In_Character_Range (Get_String_Char (Str, J)) then -- If we are out of range, post error. This is one of the -- very few places that we place the flag in the middle of -- a token, right under the offending wide character. Error_Msg ("literal out of range of type Character", Source_Ptr (Int (Loc) + J)); return; end if; end loop; -- If the root type is not a standard character, then we will convert -- the string into an aggregate and will let the aggregate code do -- the checking. else null; end if; -- See if the component type of the array corresponding to the -- string has compile time known bounds. If yes we can directly -- check whether the evaluation of the string will raise constraint -- error. Otherwise we need to transform the string literal into -- the corresponding character aggregate and let the aggregate -- code do the checking. if R_Typ = Standard_Wide_Character or else R_Typ = Standard_Character then -- Check for the case of full range, where we are definitely OK if Component_Type (Typ) = Base_Type (Component_Type (Typ)) then return; end if; -- Here the range is not the complete base type range, so check declare Comp_Typ_Lo : constant Node_Id := Type_Low_Bound (Component_Type (Typ)); Comp_Typ_Hi : constant Node_Id := Type_High_Bound (Component_Type (Typ)); Char_Val : Uint; begin if Compile_Time_Known_Value (Comp_Typ_Lo) and then Compile_Time_Known_Value (Comp_Typ_Hi) then for J in 1 .. Strlen loop Char_Val := UI_From_Int (Int (Get_String_Char (Str, J))); if Char_Val < Expr_Value (Comp_Typ_Lo) or else Char_Val > Expr_Value (Comp_Typ_Hi) then Apply_Compile_Time_Constraint_Error (N, "character out of range?", Loc => Source_Ptr (Int (Loc) + J)); end if; end loop; return; end if; end; end if; end if; -- If we got here we meed to transform the string literal into the -- equivalent qualified positional array aggregate. This is rather -- heavy artillery for this situation, but it is hard work to avoid. declare Lits : List_Id := New_List; P : Source_Ptr := Loc + 1; C : Char_Code; begin -- Build the character literals, we give them source locations -- that correspond to the string positions, which is a bit tricky -- given the possible presence of wide character escape sequences. for J in 1 .. Strlen loop C := Get_String_Char (Str, J); Set_Character_Literal_Name (C); Append_To (Lits, Make_Character_Literal (P, Name_Find, C)); if In_Character_Range (C) then P := P + 1; -- Should we have a call to Skip_Wide here ??? -- ??? else -- Skip_Wide (P); end if; end loop; Rewrite (N, Make_Qualified_Expression (Loc, Subtype_Mark => New_Reference_To (Typ, Loc), Expression => Make_Aggregate (Loc, Expressions => Lits))); Analyze_And_Resolve (N, Typ); end; end Resolve_String_Literal; ----------------------------- -- Resolve_Subprogram_Info -- ----------------------------- procedure Resolve_Subprogram_Info (N : Node_Id; Typ : Entity_Id) is begin Set_Etype (N, Typ); end Resolve_Subprogram_Info; ----------------------------- -- Resolve_Type_Conversion -- ----------------------------- procedure Resolve_Type_Conversion (N : Node_Id; Typ : Entity_Id) is Target_Type : constant Entity_Id := Etype (N); Conv_OK : constant Boolean := Conversion_OK (N); Operand : Node_Id; Opnd_Type : Entity_Id; Rop : Node_Id; begin Operand := Expression (N); if not Conv_OK and then not Valid_Conversion (N, Target_Type, Operand) then return; end if; if Etype (Operand) = Any_Fixed then -- Mixed-mode operation involving a literal. Context must be a fixed -- type which is applied to the literal subsequently. if Is_Fixed_Point_Type (Typ) then Set_Etype (Operand, Universal_Real); elsif Is_Numeric_Type (Typ) and then (Nkind (Operand) = N_Op_Multiply or else Nkind (Operand) = N_Op_Divide) and then (Etype (Right_Opnd (Operand)) = Universal_Real or else Etype (Left_Opnd (Operand)) = Universal_Real) then if Unique_Fixed_Point_Type (N) = Any_Type then return; -- expression is ambiguous. else Set_Etype (Operand, Standard_Duration); end if; if Etype (Right_Opnd (Operand)) = Universal_Real then Rop := New_Copy_Tree (Right_Opnd (Operand)); else Rop := New_Copy_Tree (Left_Opnd (Operand)); end if; Resolve (Rop, Standard_Long_Long_Float); if Realval (Rop) /= Ureal_0 and then abs (Realval (Rop)) < Delta_Value (Standard_Duration) then Error_Msg_N ("universal real operand can only be interpreted?", Rop); Error_Msg_N ("\as Duration, and will lose precision?", Rop); end if; else Error_Msg_N ("invalid context for mixed mode operation", N); Set_Etype (Operand, Any_Type); return; end if; end if; Opnd_Type := Etype (Operand); Resolve (Operand, Opnd_Type); -- Note: we do the Eval_Type_Conversion call before applying the -- required checks for a subtype conversion. This is important, -- since both are prepared under certain circumstances to change -- the type conversion to a constraint error node, but in the case -- of Eval_Type_Conversion this may reflect an illegality in the -- static case, and we would miss the illegality (getting only a -- warning message), if we applied the type conversion checks first. Eval_Type_Conversion (N); -- If after evaluation, we still have a type conversion, then we -- may need to apply checks required for a subtype conversion. -- Skip these type conversion checks if universal fixed operands -- operands involved, since range checks are handled separately for -- these cases (in the appropriate Expand routines in unit Exp_Fixd). if Nkind (N) = N_Type_Conversion and then not Is_Generic_Type (Root_Type (Target_Type)) and then Target_Type /= Universal_Fixed and then Opnd_Type /= Universal_Fixed then Apply_Type_Conversion_Checks (N); end if; -- Issue warning for conversion of simple object to its own type if Warn_On_Redundant_Constructs and then Comes_From_Source (N) and then Nkind (N) = N_Type_Conversion and then Is_Entity_Name (Expression (N)) and then Etype (Entity (Expression (N))) = Target_Type then Error_Msg_NE ("?useless conversion, & has this type", N, Entity (Expression (N))); end if; end Resolve_Type_Conversion; ---------------------- -- Resolve_Unary_Op -- ---------------------- procedure Resolve_Unary_Op (N : Node_Id; Typ : Entity_Id) is B_Typ : Entity_Id := Base_Type (Typ); R : constant Node_Id := Right_Opnd (N); begin -- Generate warning for expressions like -5 mod 3 if Paren_Count (N) = 0 and then Nkind (N) = N_Op_Minus and then Nkind (Right_Opnd (N)) = N_Op_Mod then Error_Msg_N ("?unary minus expression should be parenthesized here", N); end if; if Etype (R) = Universal_Integer or else Etype (R) = Universal_Real then Check_For_Visible_Operator (N, B_Typ); end if; Set_Etype (N, B_Typ); Resolve (R, B_Typ); Check_Unset_Reference (R); Generate_Operator_Reference (N); Eval_Unary_Op (N); -- Set overflow checking bit. Much cleverer code needed here eventually -- and perhaps the Resolve routines should be separated for the various -- arithmetic operations, since they will need different processing ??? if Nkind (N) in N_Op then if not Overflow_Checks_Suppressed (Etype (N)) then Set_Do_Overflow_Check (N, True); end if; end if; end Resolve_Unary_Op; ---------------------------------- -- Resolve_Unchecked_Expression -- ---------------------------------- procedure Resolve_Unchecked_Expression (N : Node_Id; Typ : Entity_Id) is begin Resolve (Expression (N), Typ, Suppress => All_Checks); Set_Etype (N, Typ); end Resolve_Unchecked_Expression; --------------------------------------- -- Resolve_Unchecked_Type_Conversion -- --------------------------------------- procedure Resolve_Unchecked_Type_Conversion (N : Node_Id; Typ : Entity_Id) is Operand : constant Node_Id := Expression (N); Opnd_Type : constant Entity_Id := Etype (Operand); begin -- Resolve operand using its own type. Resolve (Operand, Opnd_Type); Eval_Unchecked_Conversion (N); end Resolve_Unchecked_Type_Conversion; ------------------------------ -- Rewrite_Operator_As_Call -- ------------------------------ procedure Rewrite_Operator_As_Call (N : Node_Id; Nam : Entity_Id) is Loc : Source_Ptr := Sloc (N); Actuals : List_Id := New_List; New_N : Node_Id; begin if Nkind (N) in N_Binary_Op then Append (Left_Opnd (N), Actuals); end if; Append (Right_Opnd (N), Actuals); New_N := Make_Function_Call (Sloc => Loc, Name => New_Occurrence_Of (Nam, Loc), Parameter_Associations => Actuals); Preserve_Comes_From_Source (New_N, N); Preserve_Comes_From_Source (Name (New_N), N); Rewrite (N, New_N); Set_Etype (N, Etype (Nam)); end Rewrite_Operator_As_Call; ------------------------------ -- Rewrite_Renamed_Operator -- ------------------------------ procedure Rewrite_Renamed_Operator (N : Node_Id; Op : Entity_Id) is Nam : constant Name_Id := Chars (Op); Is_Binary : constant Boolean := Nkind (N) in N_Binary_Op; Op_Node : Node_Id; begin if Chars (N) /= Nam then -- Rewrite the operator node using the real operator, not its -- renaming. Op_Node := New_Node (Operator_Kind (Nam, Is_Binary), Sloc (N)); Set_Chars (Op_Node, Nam); Set_Etype (Op_Node, Etype (N)); Set_Entity (Op_Node, Op); Set_Right_Opnd (Op_Node, Right_Opnd (N)); Generate_Reference (Op, N); if Is_Binary then Set_Left_Opnd (Op_Node, Left_Opnd (N)); end if; Rewrite (N, Op_Node); end if; end Rewrite_Renamed_Operator; ----------------------- -- Set_Slice_Subtype -- ----------------------- -- Build an implicit subtype declaration to represent the type delivered -- by the slice. This is an abbreviated version of an array subtype. We -- define an index subtype for the slice, using either the subtype name -- or the discrete range of the slice. To be consistent with index usage -- elsewhere, we create a list header to hold the single index. This list -- is not otherwise attached to the syntax tree. procedure Set_Slice_Subtype (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Index : Node_Id; Index_List : List_Id := New_List; Index_Subtype : Entity_Id; Index_Type : Entity_Id; Slice_Subtype : Entity_Id; Drange : constant Node_Id := Discrete_Range (N); begin if Is_Entity_Name (Drange) then Index_Subtype := Entity (Drange); else -- We force the evaluation of a range. This is definitely needed in -- the renamed case, and seems safer to do unconditionally. Note in -- any case that since we will create and insert an Itype referring -- to this range, we must make sure any side effect removal actions -- are inserted before the Itype definition. if Nkind (Drange) = N_Range then Force_Evaluation (Low_Bound (Drange)); Force_Evaluation (High_Bound (Drange)); end if; Index_Type := Base_Type (Etype (Drange)); Index_Subtype := Create_Itype (Subtype_Kind (Ekind (Index_Type)), N); Set_Scalar_Range (Index_Subtype, Drange); Set_Etype (Index_Subtype, Index_Type); Set_Size_Info (Index_Subtype, Index_Type); Set_RM_Size (Index_Subtype, RM_Size (Index_Type)); end if; Slice_Subtype := Create_Itype (E_Array_Subtype, N); Index := New_Occurrence_Of (Index_Subtype, Loc); Set_Etype (Index, Index_Subtype); Append (Index, Index_List); Set_Component_Type (Slice_Subtype, Component_Type (Etype (N))); Set_First_Index (Slice_Subtype, Index); Set_Etype (Slice_Subtype, Base_Type (Etype (N))); Set_Is_Constrained (Slice_Subtype, True); Init_Size_Align (Slice_Subtype); Check_Compile_Time_Size (Slice_Subtype); -- The Etype of the existing Slice node is reset to this slice -- subtype. Its bounds are obtained from its first index. Set_Etype (N, Slice_Subtype); -- In the packed case, this must be immediately frozen -- Couldn't we always freeze here??? and if we did, then the above -- call to Check_Compile_Time_Size could be eliminated, which would -- be nice, because then that routine could be made private to Freeze. if Is_Packed (Slice_Subtype) and not In_Default_Expression then Freeze_Itype (Slice_Subtype, N); end if; end Set_Slice_Subtype; -------------------------------- -- Set_String_Literal_Subtype -- -------------------------------- procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id) is Subtype_Id : Entity_Id; begin if Nkind (N) /= N_String_Literal then return; else Subtype_Id := Create_Itype (E_String_Literal_Subtype, N); end if; Set_Component_Type (Subtype_Id, Component_Type (Typ)); Set_String_Literal_Length (Subtype_Id, UI_From_Int (String_Length (Strval (N)))); Set_Etype (Subtype_Id, Base_Type (Typ)); Set_Is_Constrained (Subtype_Id); -- The low bound is set from the low bound of the corresponding -- index type. Note that we do not store the high bound in the -- string literal subtype, but it can be deduced if necssary -- from the length and the low bound. Set_String_Literal_Low_Bound (Subtype_Id, Type_Low_Bound (Etype (First_Index (Typ)))); Set_Etype (N, Subtype_Id); end Set_String_Literal_Subtype; ----------------------------- -- Unique_Fixed_Point_Type -- ----------------------------- function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id is T1 : Entity_Id := Empty; T2 : Entity_Id; Item : Node_Id; Scop : Entity_Id; procedure Fixed_Point_Error; -- If true ambiguity, give details. procedure Fixed_Point_Error is begin Error_Msg_N ("ambiguous universal_fixed_expression", N); Error_Msg_NE ("\possible interpretation as}", N, T1); Error_Msg_NE ("\possible interpretation as}", N, T2); end Fixed_Point_Error; begin -- The operations on Duration are visible, so Duration is always a -- possible interpretation. T1 := Standard_Duration; Scop := Current_Scope; -- Look for fixed-point types in enclosing scopes. while Scop /= Standard_Standard loop T2 := First_Entity (Scop); while Present (T2) loop if Is_Fixed_Point_Type (T2) and then Current_Entity (T2) = T2 and then Scope (Base_Type (T2)) = Scop then if Present (T1) then Fixed_Point_Error; return Any_Type; else T1 := T2; end if; end if; Next_Entity (T2); end loop; Scop := Scope (Scop); end loop; -- Look for visible fixed type declarations in the context. Item := First (Context_Items (Cunit (Current_Sem_Unit))); while Present (Item) loop if Nkind (Item) = N_With_Clause then Scop := Entity (Name (Item)); T2 := First_Entity (Scop); while Present (T2) loop if Is_Fixed_Point_Type (T2) and then Scope (Base_Type (T2)) = Scop and then (Is_Potentially_Use_Visible (T2) or else In_Use (T2)) then if Present (T1) then Fixed_Point_Error; return Any_Type; else T1 := T2; end if; end if; Next_Entity (T2); end loop; end if; Next (Item); end loop; if Nkind (N) = N_Real_Literal then Error_Msg_NE ("real literal interpreted as }?", N, T1); else Error_Msg_NE ("universal_fixed expression interpreted as }?", N, T1); end if; return T1; end Unique_Fixed_Point_Type; ---------------------- -- Valid_Conversion -- ---------------------- function Valid_Conversion (N : Node_Id; Target : Entity_Id; Operand : Node_Id) return Boolean is Target_Type : Entity_Id := Base_Type (Target); Opnd_Type : Entity_Id := Etype (Operand); function Conversion_Check (Valid : Boolean; Msg : String) return Boolean; -- Little routine to post Msg if Valid is False, returns Valid value function Valid_Tagged_Conversion (Target_Type : Entity_Id; Opnd_Type : Entity_Id) return Boolean; -- Specifically test for validity of tagged conversions ---------------------- -- Conversion_Check -- ---------------------- function Conversion_Check (Valid : Boolean; Msg : String) return Boolean is begin if not Valid then Error_Msg_N (Msg, Operand); end if; return Valid; end Conversion_Check; ----------------------------- -- Valid_Tagged_Conversion -- ----------------------------- function Valid_Tagged_Conversion (Target_Type : Entity_Id; Opnd_Type : Entity_Id) return Boolean is begin -- Upward conversions are allowed (RM 4.6(22)). if Covers (Target_Type, Opnd_Type) or else Is_Ancestor (Target_Type, Opnd_Type) then return True; -- Downward conversion are allowed if the operand is -- is class-wide (RM 4.6(23)). elsif Is_Class_Wide_Type (Opnd_Type) and then Covers (Opnd_Type, Target_Type) then return True; elsif Covers (Opnd_Type, Target_Type) or else Is_Ancestor (Opnd_Type, Target_Type) then return Conversion_Check (False, "downward conversion of tagged objects not allowed"); else Error_Msg_NE ("invalid tagged conversion, not compatible with}", N, First_Subtype (Opnd_Type)); return False; end if; end Valid_Tagged_Conversion; -- Start of processing for Valid_Conversion begin Check_Parameterless_Call (Operand); if Is_Overloaded (Operand) then declare I : Interp_Index; I1 : Interp_Index; It : Interp; It1 : Interp; N1 : Entity_Id; begin -- Remove procedure calls, which syntactically cannot appear -- in this context, but which cannot be removed by type checking, -- because the context does not impose a type. Get_First_Interp (Operand, I, It); while Present (It.Typ) loop if It.Typ = Standard_Void_Type then Remove_Interp (I); end if; Get_Next_Interp (I, It); end loop; Get_First_Interp (Operand, I, It); I1 := I; It1 := It; if No (It.Typ) then Error_Msg_N ("illegal operand in conversion", Operand); return False; end if; Get_Next_Interp (I, It); if Present (It.Typ) then N1 := It1.Nam; It1 := Disambiguate (Operand, I1, I, Any_Type); if It1 = No_Interp then Error_Msg_N ("ambiguous operand in conversion", Operand); Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_N ("possible interpretation#!", Operand); Error_Msg_Sloc := Sloc (N1); Error_Msg_N ("possible interpretation#!", Operand); return False; end if; end if; Set_Etype (Operand, It1.Typ); Opnd_Type := It1.Typ; end; end if; if Chars (Current_Scope) = Name_Unchecked_Conversion then -- This check is dubious, what if there were a user defined -- scope whose name was Unchecked_Conversion ??? return True; elsif Is_Numeric_Type (Target_Type) then if Opnd_Type = Universal_Fixed then return True; else return Conversion_Check (Is_Numeric_Type (Opnd_Type), "illegal operand for numeric conversion"); end if; elsif Is_Array_Type (Target_Type) then if not Is_Array_Type (Opnd_Type) or else Opnd_Type = Any_Composite or else Opnd_Type = Any_String then Error_Msg_N ("illegal operand for array conversion", Operand); return False; elsif Number_Dimensions (Target_Type) /= Number_Dimensions (Opnd_Type) then Error_Msg_N ("incompatible number of dimensions for conversion", Operand); return False; else declare Target_Index : Node_Id := First_Index (Target_Type); Opnd_Index : Node_Id := First_Index (Opnd_Type); Target_Index_Type : Entity_Id; Opnd_Index_Type : Entity_Id; Target_Comp_Type : Entity_Id := Component_Type (Target_Type); Opnd_Comp_Type : Entity_Id := Component_Type (Opnd_Type); begin while Present (Target_Index) and then Present (Opnd_Index) loop Target_Index_Type := Etype (Target_Index); Opnd_Index_Type := Etype (Opnd_Index); if not (Is_Integer_Type (Target_Index_Type) and then Is_Integer_Type (Opnd_Index_Type)) and then (Root_Type (Target_Index_Type) /= Root_Type (Opnd_Index_Type)) then Error_Msg_N ("incompatible index types for array conversion", Operand); return False; end if; Next_Index (Target_Index); Next_Index (Opnd_Index); end loop; if Base_Type (Target_Comp_Type) /= Base_Type (Opnd_Comp_Type) then Error_Msg_N ("incompatible component types for array conversion", Operand); return False; elsif Is_Constrained (Target_Comp_Type) /= Is_Constrained (Opnd_Comp_Type) or else not Subtypes_Statically_Match (Target_Comp_Type, Opnd_Comp_Type) then Error_Msg_N ("component subtypes must statically match", Operand); return False; end if; end; end if; return True; elsif (Ekind (Target_Type) = E_General_Access_Type or else Ekind (Target_Type) = E_Anonymous_Access_Type) and then Conversion_Check (Is_Access_Type (Opnd_Type) and then Ekind (Opnd_Type) /= E_Access_Subprogram_Type and then Ekind (Opnd_Type) /= E_Access_Protected_Subprogram_Type, "must be an access-to-object type") then if Is_Access_Constant (Opnd_Type) and then not Is_Access_Constant (Target_Type) then Error_Msg_N ("access-to-constant operand type not allowed", Operand); return False; end if; -- Check the static accessibility rule of 4.6(17). Note that -- the check is not enforced when within an instance body, since -- the RM requires such cases to be caught at run time. if Ekind (Target_Type) /= E_Anonymous_Access_Type then if Type_Access_Level (Opnd_Type) > Type_Access_Level (Target_Type) then -- In an instance, this is a run-time check, but one we -- know will fail, so generate an appropriate warning. -- The raise will be generated by Expand_N_Type_Conversion. if In_Instance_Body then Error_Msg_N ("?cannot convert local pointer to non-local access type", Operand); Error_Msg_N ("?Program_Error will be raised at run time", Operand); else Error_Msg_N ("cannot convert local pointer to non-local access type", Operand); return False; end if; elsif Ekind (Opnd_Type) = E_Anonymous_Access_Type then -- When the operand is a selected access discriminant -- the check needs to be made against the level of the -- object denoted by the prefix of the selected name. -- (Object_Access_Level handles checking the prefix -- of the operand for this case.) if Nkind (Operand) = N_Selected_Component and then Object_Access_Level (Operand) > Type_Access_Level (Target_Type) then -- In an instance, this is a run-time check, but one we -- know will fail, so generate an appropriate warning. -- The raise will be generated by Expand_N_Type_Conversion. if In_Instance_Body then Error_Msg_N ("?cannot convert access discriminant to non-local" & " access type", Operand); Error_Msg_N ("?Program_Error will be raised at run time", Operand); else Error_Msg_N ("cannot convert access discriminant to non-local" & " access type", Operand); return False; end if; end if; -- The case of a reference to an access discriminant -- from within a type declaration (which will appear -- as a discriminal) is always illegal because the -- level of the discriminant is considered to be -- deeper than any (namable) access type. if Is_Entity_Name (Operand) and then (Ekind (Entity (Operand)) = E_In_Parameter or else Ekind (Entity (Operand)) = E_Constant) and then Present (Discriminal_Link (Entity (Operand))) then Error_Msg_N ("discriminant has deeper accessibility level than target", Operand); return False; end if; end if; end if; declare Target : constant Entity_Id := Designated_Type (Target_Type); Opnd : constant Entity_Id := Designated_Type (Opnd_Type); begin if Is_Tagged_Type (Target) then return Valid_Tagged_Conversion (Target, Opnd); else if Base_Type (Target) /= Base_Type (Opnd) then Error_Msg_NE ("target designated type not compatible with }", N, Base_Type (Opnd)); return False; elsif not Subtypes_Statically_Match (Target, Opnd) and then (not Has_Discriminants (Target) or else Is_Constrained (Target)) then Error_Msg_NE ("target designated subtype not compatible with }", N, Opnd); return False; else return True; end if; end if; end; elsif Ekind (Target_Type) = E_Access_Subprogram_Type and then Conversion_Check (Ekind (Base_Type (Opnd_Type)) = E_Access_Subprogram_Type, "illegal operand for access subprogram conversion") then -- Check that the designated types are subtype conformant if not Subtype_Conformant (Designated_Type (Opnd_Type), Designated_Type (Target_Type)) then Error_Msg_N ("operand type is not subtype conformant with target type", Operand); end if; -- Check the static accessibility rule of 4.6(20) if Type_Access_Level (Opnd_Type) > Type_Access_Level (Target_Type) then Error_Msg_N ("operand type has deeper accessibility level than target", Operand); -- Check that if the operand type is declared in a generic body, -- then the target type must be declared within that same body -- (enforces last sentence of 4.6(20)). elsif Present (Enclosing_Generic_Body (Opnd_Type)) then declare O_Gen : constant Node_Id := Enclosing_Generic_Body (Opnd_Type); T_Gen : Node_Id := Enclosing_Generic_Body (Target_Type); begin while Present (T_Gen) and then T_Gen /= O_Gen loop T_Gen := Enclosing_Generic_Body (T_Gen); end loop; if T_Gen /= O_Gen then Error_Msg_N ("target type must be declared in same generic body" & " as operand type", N); end if; end; end if; return True; elsif Is_Remote_Access_To_Subprogram_Type (Target_Type) and then Is_Remote_Access_To_Subprogram_Type (Opnd_Type) then -- It is valid to convert from one RAS type to another provided -- that their specification statically match. Check_Subtype_Conformant (New_Id => Designated_Type (Corresponding_Remote_Type (Target_Type)), Old_Id => Designated_Type (Corresponding_Remote_Type (Opnd_Type)), Err_Loc => N); return True; elsif Is_Tagged_Type (Target_Type) then return Valid_Tagged_Conversion (Target_Type, Opnd_Type); -- Types derived from the same root type are convertible. elsif Root_Type (Target_Type) = Root_Type (Opnd_Type) then return True; -- In an instance, there may be inconsistent views of the same -- type, or types derived from the same type. elsif In_Instance and then Underlying_Type (Target_Type) = Underlying_Type (Opnd_Type) then return True; -- Special check for common access type error case elsif Ekind (Target_Type) = E_Access_Type and then Is_Access_Type (Opnd_Type) then Error_Msg_N ("target type must be general access type!", N); Error_Msg_NE ("add ALL to }!", N, Target_Type); return False; else Error_Msg_NE ("invalid conversion, not compatible with }", N, Opnd_Type); return False; end if; end Valid_Conversion; end Sem_Res;
package body Ada.Strings.Generic_Unbounded.Generic_Functions is function Index ( Source : Unbounded_String; Pattern : String_Type; From : Positive; Going : Direction := Forward) return Natural is pragma Suppress (Access_Check); begin return Fixed_Functions.Index ( Source.Data.Items (1 .. Source.Length), Pattern, From, Going); end Index; function Index ( Source : Unbounded_String; Pattern : String_Type; Going : Direction := Forward) return Natural is pragma Suppress (Access_Check); begin return Fixed_Functions.Index ( Source.Data.Items (1 .. Source.Length), Pattern, Going); end Index; function Index_Non_Blank ( Source : Unbounded_String; From : Positive; Going : Direction := Forward) return Natural is pragma Suppress (Access_Check); begin return Fixed_Functions.Index_Non_Blank ( Source.Data.Items (1 .. Source.Length), From, Going); end Index_Non_Blank; function Index_Non_Blank ( Source : Unbounded_String; Going : Direction := Forward) return Natural is pragma Suppress (Access_Check); begin return Fixed_Functions.Index_Non_Blank ( Source.Data.Items (1 .. Source.Length), Going); end Index_Non_Blank; function Count (Source : Unbounded_String; Pattern : String_Type) return Natural is pragma Suppress (Access_Check); begin return Fixed_Functions.Count ( Source.Data.Items (1 .. Source.Length), Pattern); end Count; function Replace_Slice ( Source : Unbounded_String; Low : Positive; High : Natural; By : String_Type) return Unbounded_String is pragma Check (Pre, Check => (Low <= Source.Length + 1 and then High <= Source.Length) or else raise Index_Error); pragma Suppress (Access_Check); begin return Result : Unbounded_String do if By'Length > 0 or else Low <= High then if By'Length = 0 and then High = Source.Length then Assign (Result, Source); -- shared Set_Length (Result, Low - 1); elsif Low > Source.Length then Assign (Result, Source); -- shared Append (Result, By); else Set_Length ( Result, Source.Length + By'Length - Integer'Max (High - Low + 1, 0)); declare Dummy_Last : Natural; begin Fixed_Functions.Replace_Slice ( Source.Data.Items (1 .. Source.Length), Low, High, By, Target => Result.Data.Items.all, Target_Last => Dummy_Last); end; end if; else Assign (Result, Source); -- shared end if; end return; end Replace_Slice; procedure Replace_Slice ( Source : in out Unbounded_String; Low : Positive; High : Natural; By : String_Type) is pragma Check (Pre, Check => (Low <= Source.Length + 1 and then High <= Source.Length) or else raise Index_Error); -- CXA4032 pragma Suppress (Access_Check); begin if By'Length > 0 or else Low <= High then if By'Length = 0 and then High = Source.Length then Set_Length (Source, Low - 1); elsif Low > Source.Length then Append (Source, By); else declare Old_Length : constant Natural := Source.Length; New_Length : Natural; begin Unique_And_Set_Length ( Source, Old_Length + Integer'Max ( By'Length - Integer'Max (High - Low + 1, 0), 0)); New_Length := Old_Length; Fixed_Functions.Replace_Slice ( Source.Data.Items.all, -- (1 .. Source.Length) New_Length, Low, High, By); Set_Length (Source, New_Length); end; end if; end if; end Replace_Slice; function Insert ( Source : Unbounded_String; Before : Positive; New_Item : String_Type) return Unbounded_String is pragma Check (Pre, Check => Before <= Source.Length + 1 or else raise Index_Error); pragma Suppress (Access_Check); begin return Result : Unbounded_String do if New_Item'Length > 0 then if Before > Source.Length then Assign (Result, Source); -- shared Append (Result, New_Item); else Set_Length (Result, Source.Length + New_Item'Length); declare Dummy_Last : Natural; begin Fixed_Functions.Insert ( Source.Data.Items (1 .. Source.Length), Before, New_Item, Target => Result.Data.Items.all, Target_Last => Dummy_Last); end; end if; else Assign (Result, Source); -- shared end if; end return; end Insert; procedure Insert ( Source : in out Unbounded_String; Before : Positive; New_Item : String_Type) is pragma Check (Pre, Check => Before <= Source.Length + 1 or else raise Index_Error); -- CXA4032 pragma Suppress (Access_Check); begin if New_Item'Length > 0 then if Before > Source.Length then Append (Source, New_Item); else declare Old_Length : constant Natural := Source.Length; New_Length : Natural; begin Unique_And_Set_Length (Source, Old_Length + New_Item'Length); New_Length := Old_Length; Fixed_Functions.Insert ( Source.Data.Items.all, -- (1 .. Source.Length) New_Length, Before, New_Item); Set_Length (Source, New_Length); end; end if; end if; end Insert; function Overwrite ( Source : Unbounded_String; Position : Positive; New_Item : String_Type) return Unbounded_String is begin return Replace_Slice ( Source, Position, -- checking Index_Error Integer'Min (Position + New_Item'Length - 1, Source.Length), New_Item); end Overwrite; procedure Overwrite ( Source : in out Unbounded_String; Position : Positive; New_Item : String_Type) is begin Replace_Slice ( Source, Position, -- checking Index_Error, CXA4032 Integer'Min (Position + New_Item'Length - 1, Source.Length), New_Item); end Overwrite; function Delete ( Source : Unbounded_String; From : Positive; Through : Natural) return Unbounded_String is pragma Check (Pre, Check => (From <= Source.Length + 1 and then Through <= Source.Length) or else raise Index_Error); pragma Suppress (Access_Check); begin return Result : Unbounded_String do if From <= Through then if Through >= Source.Length then Assign (Result, Source); -- shared Set_Length (Result, From - 1); else Set_Length (Result, Source.Length - (Through - From + 1)); declare Dummy_Last : Natural; begin Fixed_Functions.Delete ( Source.Data.Items (1 .. Source.Length), From, Through, Target => Result.Data.Items.all, Target_Last => Dummy_Last); end; end if; else Assign (Result, Source); -- shared end if; end return; end Delete; procedure Delete ( Source : in out Unbounded_String; From : Positive; Through : Natural) is pragma Check (Pre, Check => (From <= Source.Length + 1 and then Through <= Source.Length) or else raise Index_Error); pragma Suppress (Access_Check); begin if From <= Through then declare Old_Length : constant Natural := Source.Length; New_Length : Natural; begin if Through >= Old_Length then New_Length := From - 1; else New_Length := Old_Length; Unique (Source); -- for overwriting Fixed_Functions.Delete ( Source.Data.Items.all, -- (1 .. Old_Length) New_Length, From, Through); end if; Set_Length (Source, New_Length); end; end if; end Delete; function Trim ( Source : Unbounded_String; Side : Trim_End; Blank : Character_Type := Fixed_Functions.Space) return Unbounded_String is pragma Suppress (Access_Check); First : Positive; Last : Natural; begin Fixed_Functions.Trim ( Source.Data.Items (1 .. Source.Length), Side, Blank, First, Last); return Unbounded_Slice (Source, First, Last); end Trim; procedure Trim ( Source : in out Unbounded_String; Side : Trim_End; Blank : Character_Type := Fixed_Functions.Space) is pragma Suppress (Access_Check); First : Positive; Last : Natural; begin Fixed_Functions.Trim ( Source.Data.Items (1 .. Source.Length), Side, Blank, First, Last); Unbounded_Slice (Source, Source, First, Last); end Trim; function Head ( Source : Unbounded_String; Count : Natural; Pad : Character_Type := Fixed_Functions.Space) return Unbounded_String is pragma Suppress (Access_Check); begin return Result : Unbounded_String do if Count > Source.Length then Set_Length (Result, Count); declare Dummy_Last : Natural; begin Fixed_Functions.Head ( Source.Data.Items (1 .. Source.Length), Count, Pad, Target => Result.Data.Items.all, Target_Last => Dummy_Last); end; else Assign (Result, Source); -- shared Set_Length (Result, Count); end if; end return; end Head; procedure Head ( Source : in out Unbounded_String; Count : Natural; Pad : Character_Type := Fixed_Functions.Space) is pragma Suppress (Access_Check); begin if Count > Source.Length then declare New_Last : Natural := Source.Length; begin Set_Length (Source, Count); Fixed_Functions.Head ( Source.Data.Items.all, -- (1 .. Count) New_Last, Count, Pad); end; else Set_Length (Source, Count); end if; end Head; function Tail ( Source : Unbounded_String; Count : Natural; Pad : Character_Type := Fixed_Functions.Space) return Unbounded_String is pragma Suppress (Access_Check); begin return Result : Unbounded_String do if Count /= Source.Length then Set_Length (Result, Count); declare Dummy_Last : Natural; begin Fixed_Functions.Tail ( Source.Data.Items (1 .. Source.Length), Count, Pad, Target => Result.Data.Items.all, Target_Last => Dummy_Last); end; else Assign (Result, Source); -- shared end if; end return; end Tail; procedure Tail ( Source : in out Unbounded_String; Count : Natural; Pad : Character_Type := Fixed_Functions.Space) is pragma Suppress (Access_Check); begin if Count /= Source.Length then if Count > 0 then declare Old_Length : constant Natural := Source.Length; Dummy_Last : Natural; begin Unique_And_Set_Length (Source, Integer'Max (Count, Old_Length)); Fixed_Functions.Tail ( Source.Data.Items (1 .. Old_Length), Count, Pad, Target => Source.Data.Items.all, -- copying Target_Last => Dummy_Last); end; end if; Set_Length (Source, Count); end if; end Tail; function "*" (Left : Natural; Right : Character_Type) return Unbounded_String is pragma Suppress (Access_Check); begin return Result : Unbounded_String do Set_Length (Result, Left); for I in 1 .. Left loop Result.Data.Items (I) := Right; end loop; end return; end "*"; function "*" (Left : Natural; Right : String_Type) return Unbounded_String is pragma Suppress (Access_Check); Right_Length : constant Natural := Right'Length; begin return Result : Unbounded_String do Set_Length (Result, Left * Right_Length); declare Last : Natural := 0; begin for I in 1 .. Left loop Result.Data.Items (Last + 1 .. Last + Right_Length) := Right; Last := Last + Right_Length; end loop; end; end return; end "*"; function "*" (Left : Natural; Right : Unbounded_String) return Unbounded_String is pragma Suppress (Access_Check); begin return Left * Right.Data.Items (1 .. Right.Length); end "*"; package body Generic_Maps is function Index ( Source : Unbounded_String; Pattern : String_Type; From : Positive; Going : Direction := Forward; Mapping : Fixed_Maps.Character_Mapping) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index ( Source.Data.Items (1 .. Source.Length), Pattern, From, Going, Mapping); end Index; function Index ( Source : Unbounded_String; Pattern : String_Type; Going : Direction := Forward; Mapping : Fixed_Maps.Character_Mapping) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index ( Source.Data.Items (1 .. Source.Length), Pattern, Going, Mapping); end Index; function Index ( Source : Unbounded_String; Pattern : String_Type; From : Positive; Going : Direction := Forward; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index ( Source.Data.Items (1 .. Source.Length), Pattern, From, Going, Mapping); end Index; function Index ( Source : Unbounded_String; Pattern : String_Type; Going : Direction := Forward; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index ( Source.Data.Items (1 .. Source.Length), Pattern, Going, Mapping); end Index; function Index_Element ( Source : Unbounded_String; Pattern : String_Type; From : Positive; Going : Direction := Forward; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index_Element ( Source.Data.Items (1 .. Source.Length), Pattern, From, Going, Mapping); end Index_Element; function Index_Element ( Source : Unbounded_String; Pattern : String_Type; Going : Direction := Forward; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index_Element ( Source.Data.Items (1 .. Source.Length), Pattern, Going, Mapping); end Index_Element; function Index ( Source : Unbounded_String; Set : Fixed_Maps.Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index ( Source.Data.Items (1 .. Source.Length), Set, From, Test, Going); end Index; function Index ( Source : Unbounded_String; Set : Fixed_Maps.Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Index ( Source.Data.Items (1 .. Source.Length), Set, Test, Going); end Index; function Count ( Source : Unbounded_String; Pattern : String_Type; Mapping : Fixed_Maps.Character_Mapping) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Count ( Source.Data.Items (1 .. Source.Length), Pattern, Mapping); end Count; function Count ( Source : Unbounded_String; Pattern : String_Type; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Count ( Source.Data.Items (1 .. Source.Length), Pattern, Mapping); end Count; function Count_Element ( Source : Unbounded_String; Pattern : String_Type; Mapping : not null access function (From : Character_Type) return Character_Type) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Count_Element ( Source.Data.Items (1 .. Source.Length), Pattern, Mapping); end Count_Element; function Count ( Source : Unbounded_String; Set : Fixed_Maps.Character_Set) return Natural is pragma Suppress (Access_Check); begin return Fixed_Maps.Count (Source.Data.Items (1 .. Source.Length), Set); end Count; procedure Find_Token ( Source : Unbounded_String; Set : Fixed_Maps.Character_Set; From : Positive; Test : Membership; First : out Positive; Last : out Natural) is pragma Suppress (Access_Check); begin Fixed_Maps.Find_Token ( Source.Data.Items (1 .. Source.Length), Set, From, Test, First, Last); end Find_Token; procedure Find_Token ( Source : Unbounded_String; Set : Fixed_Maps.Character_Set; Test : Membership; First : out Positive; Last : out Natural) is pragma Suppress (Access_Check); begin Fixed_Maps.Find_Token ( Source.Data.Items (1 .. Source.Length), Set, Test, First, Last); end Find_Token; function Translate ( Source : Unbounded_String; Mapping : Fixed_Maps.Character_Mapping) return Unbounded_String is pragma Suppress (Access_Check); begin return Result : Unbounded_String do Set_Length (Result, Source.Length * Fixed_Maps.Expanding); declare New_Length : Natural; begin Fixed_Maps.Translate ( Source.Data.Items (1 .. Source.Length), Mapping, Target => Result.Data.Items.all, Target_Last => New_Length); Set_Length (Result, New_Length); end; end return; end Translate; procedure Translate ( Source : in out Unbounded_String; Mapping : Fixed_Maps.Character_Mapping) is pragma Suppress (Access_Check); -- finalizer begin -- Translate can not update destructively. Assign (Source, Translate (Source, Mapping)); end Translate; function Translate ( Source : Unbounded_String; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) return Unbounded_String is pragma Suppress (Access_Check); begin return Result : Unbounded_String do Set_Length (Result, Source.Length * Fixed_Maps.Expanding); declare New_Length : Natural; begin Fixed_Maps.Translate ( Source.Data.Items (1 .. Source.Length), Mapping, Target => Result.Data.Items.all, Target_Last => New_Length); Set_Length (Result, New_Length); end; end return; end Translate; procedure Translate ( Source : in out Unbounded_String; Mapping : not null access function (From : Wide_Wide_Character) return Wide_Wide_Character) is pragma Suppress (Access_Check); -- finalizer begin -- Translate can not update destructively. Assign (Source, Translate (Source, Mapping)); end Translate; function Translate_Element ( Source : Unbounded_String; Mapping : not null access function (From : Character_Type) return Character_Type) return Unbounded_String is pragma Suppress (Access_Check); begin return Result : Unbounded_String do Set_Length (Result, Source.Length); Fixed_Maps.Translate_Element ( Source.Data.Items (1 .. Source.Length), Mapping, Target => Result.Data.Items (1 .. Source.Length)); end return; end Translate_Element; procedure Translate_Element ( Source : in out Unbounded_String; Mapping : not null access function (From : Character_Type) return Character_Type) is pragma Suppress (Access_Check); begin Unique (Source); Fixed_Maps.Translate_Element ( Source.Data.Items (1 .. Source.Length), Mapping); end Translate_Element; function Trim ( Source : Unbounded_String; Left : Fixed_Maps.Character_Set; Right : Fixed_Maps.Character_Set) return Unbounded_String is pragma Suppress (Access_Check); First : Positive; Last : Natural; begin Fixed_Maps.Trim ( Source.Data.Items (1 .. Source.Length), Left, Right, First, Last); return Unbounded_Slice (Source, First, Last); end Trim; procedure Trim ( Source : in out Unbounded_String; Left : Fixed_Maps.Character_Set; Right : Fixed_Maps.Character_Set) is pragma Suppress (Access_Check); First : Positive; Last : Natural; begin Fixed_Maps.Trim ( Source.Data.Items (1 .. Source.Length), Left, Right, First, Last); Unbounded_Slice (Source, Source, First, Last); end Trim; end Generic_Maps; end Ada.Strings.Generic_Unbounded.Generic_Functions;
-- DECLS-D_ATRIBUT.ads -- Paquet de declaracions d'atributs with Decls.Dgenerals, Decls.D_Taula_De_Noms, Decls.Dtnode, Decls.Dtdesc; use Decls.Dgenerals, Decls.D_Taula_De_Noms, Decls.Dtnode, Decls.Dtdesc; package Decls.D_Atribut is type Atribut (T : Tipus_Atribut := Atom) is record Lin, Col : Natural; case T is when Atom => null; when A_Ident => Idn : Id_Nom; when A_Lit_C | A_Lit_N | A_Lit_S => Val : Valor; when others => A : Pnode; end case; end record; end Decls.D_Atribut;
with AFRL.CMASI.AutomationResponse.SPARK_Boundary; use AFRL.CMASI.AutomationResponse.SPARK_Boundary; with AFRL.CMASI.MissionCommand; use AFRL.CMASI.MissionCommand; with AVTAS.LMCP.Object.SPARK_Boundary; use AVTAS.LMCP.Object.SPARK_Boundary; with UxAS.Comms.LMCP_Net_Client.Service.Example_Spark_Service.SPARK; with AFRL.CMASI.AutomationResponse; use AFRL.CMASI.AutomationResponse; package body UxAS.comms.LMCP_net_client.service.Example_Spark_Service is --------------- -- Configure -- --------------- overriding procedure Configure (This : in out Example_Spark_Service; XML_Node : DOM.Core.Element; Result : out Boolean) is pragma Unreferenced (XML_Node); Unused : Boolean; begin This.Add_Subscription_Address (AFRL.CMASI.AutomationResponse.Subscription, Unused); This.Add_Subscription_Address (AFRL.CMASI.MissionCommand.Subscription, Unused); Result := True; end Configure; --------------- -- Construct -- --------------- procedure Construct (This : in out Example_Spark_Service) is begin This.Construct_Service (Service_Type => Type_Name, Work_Directory_Name => Directory_Name); end Construct; ------------ -- Create -- ------------ function Create return Any_Service is Result : Example_Spark_Service_Ref; begin Result := new Example_Spark_Service; Result.Construct; -- Specific to Ada version return Any_Service (Result); end Create; ----------------------------------- -- Handle_AutomationResponse_Msg -- ----------------------------------- procedure Handle_AutomationResponse_Msg (This : in out Example_Spark_Service; Response : Object_Any) is begin This.Configs.AutomationIds := Int64_Sets.Union (This.Configs.AutomationIds, Get_WaypointEntity_Set (AutomationResponse (Response.all))); end Handle_AutomationResponse_Msg; ------------------------------- -- Handle_MissionCommand_Msg -- ------------------------------- procedure Handle_MissionCommand_Msg (This : in out Example_Spark_Service; Command : Object_Any) is Result : Boolean; begin SPARK.Handle_MissionCommand (This, Wrap (Command), Result); end Handle_MissionCommand_Msg; ---------------- -- Initialize -- ---------------- overriding procedure Initialize (This : in out Example_Spark_Service; Result : out Boolean) is pragma Unreferenced (This); -- since not doing the Timers begin Result := True; end Initialize; ----------------------------------- -- Process_Received_LMCP_Message -- ----------------------------------- overriding procedure Process_Received_LMCP_Message (This : in out Example_Spark_Service; Received_Message : not null Any_LMCP_Message; Should_Terminate : out Boolean) is begin if Received_Message.Payload.all in AutomationResponse'Class then This.Handle_AutomationResponse_Msg (Received_Message.Payload); end if; if Received_Message.Payload.all in MissionCommand'Class then This.Handle_MissionCommand_Msg (Received_Message.Payload); end if; Should_Terminate := False; end Process_Received_LMCP_Message; --------------------------------- -- Registry_Service_Type_Names -- --------------------------------- function Registry_Service_Type_Names return Service_Type_Names_List is (Service_Type_Names_List'(1 => Instance (Service_Type_Name_Max_Length, Content => Type_Name))); ----------------------------- -- Package Executable Part -- ----------------------------- -- This is the executable part for the package, invoked automatically and only once. begin -- All concrete service subclasses must call this procedure in their -- own package like this, with their own params. Register_Service_Creation_Function_Pointers (Registry_Service_Type_Names, Create'Access); end UxAS.Comms.LMCP_Net_Client.Service.Example_Spark_Service;
package Inline11_Pkg is procedure Trace (I : Integer); pragma Inline (Trace); end Inline11_Pkg;
-- Copyright 2016-2019 NXP -- All rights reserved.SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from LPC55S6x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NXP_SVD.USBHSH is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CAPLENGTH_CHIPID_CAPLENGTH_Field is HAL.UInt8; subtype CAPLENGTH_CHIPID_CHIPID_Field is HAL.UInt16; -- This register contains the offset value towards the start of the -- operational register space and the version number of the IP block type CAPLENGTH_CHIPID_Register is record -- Read-only. Capability Length: This is used as an offset. CAPLENGTH : CAPLENGTH_CHIPID_CAPLENGTH_Field; -- unspecified Reserved_8_15 : HAL.UInt8; -- Read-only. Chip identification: indicates major and minor revision of -- the IP: [31:24] = Major revision [23:16] = Minor revision Major -- revisions used: 0x01: USB2. CHIPID : CAPLENGTH_CHIPID_CHIPID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CAPLENGTH_CHIPID_Register use record CAPLENGTH at 0 range 0 .. 7; Reserved_8_15 at 0 range 8 .. 15; CHIPID at 0 range 16 .. 31; end record; subtype HCSPARAMS_N_PORTS_Field is HAL.UInt4; -- Host Controller Structural Parameters type HCSPARAMS_Register is record -- Read-only. This register specifies the number of physical downstream -- ports implemented on this host controller. N_PORTS : HCSPARAMS_N_PORTS_Field; -- Read-only. This field indicates whether the host controller -- implementation includes port power control. PPC : Boolean; -- unspecified Reserved_5_15 : HAL.UInt11; -- Read-only. This bit indicates whether the ports support port -- indicator control. P_INDICATOR : Boolean; -- unspecified Reserved_17_31 : HAL.UInt15; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HCSPARAMS_Register use record N_PORTS at 0 range 0 .. 3; PPC at 0 range 4 .. 4; Reserved_5_15 at 0 range 5 .. 15; P_INDICATOR at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype FLADJ_FRINDEX_FLADJ_Field is HAL.UInt6; subtype FLADJ_FRINDEX_FRINDEX_Field is HAL.UInt14; -- Frame Length Adjustment type FLADJ_FRINDEX_Register is record -- Frame Length Timing Value. FLADJ : FLADJ_FRINDEX_FLADJ_Field := 16#20#; -- unspecified Reserved_6_15 : HAL.UInt10 := 16#0#; -- Frame Index: Bits 29 to16 in this register are used for the frame -- number field in the SOF packet. FRINDEX : FLADJ_FRINDEX_FRINDEX_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FLADJ_FRINDEX_Register use record FLADJ at 0 range 0 .. 5; Reserved_6_15 at 0 range 6 .. 15; FRINDEX at 0 range 16 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype ATLPTD_ATL_CUR_Field is HAL.UInt5; subtype ATLPTD_ATL_BASE_Field is HAL.UInt23; -- Memory base address where ATL PTD0 is stored type ATLPTD_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- This indicates the current PTD that is used by the hardware when it -- is processing the ATL list. ATL_CUR : ATLPTD_ATL_CUR_Field := 16#0#; -- Base address to be used by the hardware to find the start of the ATL -- list. ATL_BASE : ATLPTD_ATL_BASE_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ATLPTD_Register use record Reserved_0_3 at 0 range 0 .. 3; ATL_CUR at 0 range 4 .. 8; ATL_BASE at 0 range 9 .. 31; end record; subtype ISOPTD_ISO_FIRST_Field is HAL.UInt5; subtype ISOPTD_ISO_BASE_Field is HAL.UInt22; -- Memory base address where ISO PTD0 is stored type ISOPTD_Register is record -- unspecified Reserved_0_4 : HAL.UInt5 := 16#0#; -- This indicates the first PTD that is used by the hardware when it is -- processing the ISO list. ISO_FIRST : ISOPTD_ISO_FIRST_Field := 16#0#; -- Base address to be used by the hardware to find the start of the ISO -- list. ISO_BASE : ISOPTD_ISO_BASE_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ISOPTD_Register use record Reserved_0_4 at 0 range 0 .. 4; ISO_FIRST at 0 range 5 .. 9; ISO_BASE at 0 range 10 .. 31; end record; subtype INTPTD_INT_FIRST_Field is HAL.UInt5; subtype INTPTD_INT_BASE_Field is HAL.UInt22; -- Memory base address where INT PTD0 is stored type INTPTD_Register is record -- unspecified Reserved_0_4 : HAL.UInt5 := 16#0#; -- This indicates the first PTD that is used by the hardware when it is -- processing the INT list. INT_FIRST : INTPTD_INT_FIRST_Field := 16#0#; -- Base address to be used by the hardware to find the start of the INT -- list. INT_BASE : INTPTD_INT_BASE_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INTPTD_Register use record Reserved_0_4 at 0 range 0 .. 4; INT_FIRST at 0 range 5 .. 9; INT_BASE at 0 range 10 .. 31; end record; subtype DATAPAYLOAD_DAT_BASE_Field is HAL.UInt16; -- Memory base address that indicates the start of the data payload buffers type DATAPAYLOAD_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Base address to be used by the hardware to find the start of the data -- payload section. DAT_BASE : DATAPAYLOAD_DAT_BASE_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DATAPAYLOAD_Register use record Reserved_0_15 at 0 range 0 .. 15; DAT_BASE at 0 range 16 .. 31; end record; subtype USBCMD_FLS_Field is HAL.UInt2; -- USB Command register type USBCMD_Register is record -- Run/Stop: 1b = Run. RS : Boolean := False; -- Host Controller Reset: This control bit is used by the software to -- reset the host controller. HCRESET : Boolean := False; -- Frame List Size: This field specifies the size of the frame list. FLS : USBCMD_FLS_Field := 16#0#; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Light Host Controller Reset: This bit allows the driver software to -- reset the host controller without affecting the state of the ports. LHCR : Boolean := False; -- ATL List enabled. ATL_EN : Boolean := False; -- ISO List enabled. ISO_EN : Boolean := False; -- INT List enabled. INT_EN : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for USBCMD_Register use record RS at 0 range 0 .. 0; HCRESET at 0 range 1 .. 1; FLS at 0 range 2 .. 3; Reserved_4_6 at 0 range 4 .. 6; LHCR at 0 range 7 .. 7; ATL_EN at 0 range 8 .. 8; ISO_EN at 0 range 9 .. 9; INT_EN at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; -- USB Interrupt Status register type USBSTS_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Port Change Detect: The host controller sets this bit to logic 1 when -- any port has a change bit transition from a 0 to a one or a Force -- Port Resume bit transition from a 0 to a 1 as a result of a J-K -- transition detected on a suspended port. PCD : Boolean := False; -- Frame List Rollover: The host controller sets this bit to logic 1 -- when the frame list index rolls over its maximum value to 0. FLR : Boolean := False; -- unspecified Reserved_4_15 : HAL.UInt12 := 16#0#; -- ATL IRQ: Indicates that an ATL PTD (with I-bit set) was completed. ATL_IRQ : Boolean := False; -- ISO IRQ: Indicates that an ISO PTD (with I-bit set) was completed. ISO_IRQ : Boolean := False; -- INT IRQ: Indicates that an INT PTD (with I-bit set) was completed. INT_IRQ : Boolean := False; -- SOF interrupt: Every time when the host sends a Start of Frame token -- on the USB bus, this bit is set. SOF_IRQ : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for USBSTS_Register use record Reserved_0_1 at 0 range 0 .. 1; PCD at 0 range 2 .. 2; FLR at 0 range 3 .. 3; Reserved_4_15 at 0 range 4 .. 15; ATL_IRQ at 0 range 16 .. 16; ISO_IRQ at 0 range 17 .. 17; INT_IRQ at 0 range 18 .. 18; SOF_IRQ at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- USB Interrupt Enable register type USBINTR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Port Change Detect Interrupt Enable: 1: enable 0: disable. PCDE : Boolean := False; -- Frame List Rollover Interrupt Enable: 1: enable 0: disable. FLRE : Boolean := False; -- unspecified Reserved_4_15 : HAL.UInt12 := 16#0#; -- ATL IRQ Enable bit: 1: enable 0: disable. ATL_IRQ_E : Boolean := False; -- ISO IRQ Enable bit: 1: enable 0: disable. ISO_IRQ_E : Boolean := False; -- INT IRQ Enable bit: 1: enable 0: disable. INT_IRQ_E : Boolean := False; -- SOF Interrupt Enable bit: 1: enable 0: disable. SOF_E : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for USBINTR_Register use record Reserved_0_1 at 0 range 0 .. 1; PCDE at 0 range 2 .. 2; FLRE at 0 range 3 .. 3; Reserved_4_15 at 0 range 4 .. 15; ATL_IRQ_E at 0 range 16 .. 16; ISO_IRQ_E at 0 range 17 .. 17; INT_IRQ_E at 0 range 18 .. 18; SOF_E at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; subtype PORTSC1_LS_Field is HAL.UInt2; subtype PORTSC1_PIC_Field is HAL.UInt2; subtype PORTSC1_PTC_Field is HAL.UInt4; subtype PORTSC1_PSPD_Field is HAL.UInt2; -- Port Status and Control register type PORTSC1_Register is record -- Current Connect Status: Logic 1 indicates a device is present on the -- port. CCS : Boolean := False; -- Connect Status Change: Logic 1 means that the value of CCS has -- changed. CSC : Boolean := False; -- Port Enabled/Disabled. PED : Boolean := False; -- Port Enabled/Disabled Change: Logic 1 means that the value of PED has -- changed. PEDC : Boolean := False; -- Over-current active: Logic 1 means that this port has an over-current -- condition. OCA : Boolean := False; -- Over-current change: Logic 1 means that the value of OCA has changed. OCC : Boolean := False; -- Force Port Resume: Logic 1 means resume (K-state) detected or driven -- on the port. FPR : Boolean := False; -- Suspend: Logic 1 means port is in the suspend state. SUSP : Boolean := False; -- Port Reset: Logic 1 means the port is in the reset state. PR : Boolean := False; -- unspecified Reserved_9_9 : HAL.Bit := 16#0#; -- Read-only. Line Status: This field reflects the current logical -- levels of the DP (bit 11) and DM (bit 10) signal lines. LS : PORTSC1_LS_Field := 16#0#; -- Port Power: The function of this bit depends on the value of the Port -- Power Control (PPC) bit in the HCSPARAMS register. PP : Boolean := False; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- Port Indicator Control : Writing to this field has no effect if the -- P_INDICATOR bit in the HCSPARAMS register is logic 0. PIC : PORTSC1_PIC_Field := 16#0#; -- Port Test Control: A non-zero value indicates that the port is -- operating in the test mode as indicated by the value. PTC : PORTSC1_PTC_Field := 16#0#; -- Port Speed: 00b: Low-speed 01b: Full-speed 10b: High-speed 11b: -- Reserved. PSPD : PORTSC1_PSPD_Field := 16#0#; -- Wake on overcurrent enable: Writing this bit to a one enables the -- port to be sensitive to overcurrent conditions as wake-up events. WOO : Boolean := False; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PORTSC1_Register use record CCS at 0 range 0 .. 0; CSC at 0 range 1 .. 1; PED at 0 range 2 .. 2; PEDC at 0 range 3 .. 3; OCA at 0 range 4 .. 4; OCC at 0 range 5 .. 5; FPR at 0 range 6 .. 6; SUSP at 0 range 7 .. 7; PR at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; LS at 0 range 10 .. 11; PP at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; PIC at 0 range 14 .. 15; PTC at 0 range 16 .. 19; PSPD at 0 range 20 .. 21; WOO at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype LASTPTD_ATL_LAST_Field is HAL.UInt5; subtype LASTPTD_ISO_LAST_Field is HAL.UInt5; subtype LASTPTD_INT_LAST_Field is HAL.UInt5; -- Marks the last PTD in the list for ISO, INT and ATL type LASTPTD_Register is record -- If hardware has reached this PTD and the J bit is not set, it will go -- to PTD0 as the next PTD to be processed. ATL_LAST : LASTPTD_ATL_LAST_Field := 16#0#; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- This indicates the last PTD in the ISO list. ISO_LAST : LASTPTD_ISO_LAST_Field := 16#0#; -- unspecified Reserved_13_15 : HAL.UInt3 := 16#0#; -- This indicates the last PTD in the INT list. INT_LAST : LASTPTD_INT_LAST_Field := 16#0#; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LASTPTD_Register use record ATL_LAST at 0 range 0 .. 4; Reserved_5_7 at 0 range 5 .. 7; ISO_LAST at 0 range 8 .. 12; Reserved_13_15 at 0 range 13 .. 15; INT_LAST at 0 range 16 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; -- Controls the port if it is attached to the host block or the device -- block type PORTMODE_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- If this bit is set to one, one of the ports will behave as a USB -- device. DEV_ENABLE : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- This bit indicates if the PHY power-down input is controlled by -- software or by hardware. SW_CTRL_PDCOM : Boolean := True; -- This bit is only used when SW_CTRL_PDCOM is set to 1b. SW_PDCOM : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PORTMODE_Register use record Reserved_0_15 at 0 range 0 .. 15; DEV_ENABLE at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; SW_CTRL_PDCOM at 0 range 18 .. 18; SW_PDCOM at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- USB1 High-speed Host Controller type USBHSH_Peripheral is record -- This register contains the offset value towards the start of the -- operational register space and the version number of the IP block CAPLENGTH_CHIPID : aliased CAPLENGTH_CHIPID_Register; -- Host Controller Structural Parameters HCSPARAMS : aliased HCSPARAMS_Register; -- Frame Length Adjustment FLADJ_FRINDEX : aliased FLADJ_FRINDEX_Register; -- Memory base address where ATL PTD0 is stored ATLPTD : aliased ATLPTD_Register; -- Memory base address where ISO PTD0 is stored ISOPTD : aliased ISOPTD_Register; -- Memory base address where INT PTD0 is stored INTPTD : aliased INTPTD_Register; -- Memory base address that indicates the start of the data payload -- buffers DATAPAYLOAD : aliased DATAPAYLOAD_Register; -- USB Command register USBCMD : aliased USBCMD_Register; -- USB Interrupt Status register USBSTS : aliased USBSTS_Register; -- USB Interrupt Enable register USBINTR : aliased USBINTR_Register; -- Port Status and Control register PORTSC1 : aliased PORTSC1_Register; -- Done map for each ATL PTD ATLPTDD : aliased HAL.UInt32; -- Skip map for each ATL PTD ATLPTDS : aliased HAL.UInt32; -- Done map for each ISO PTD ISOPTDD : aliased HAL.UInt32; -- Skip map for each ISO PTD ISOPTDS : aliased HAL.UInt32; -- Done map for each INT PTD INTPTDD : aliased HAL.UInt32; -- Skip map for each INT PTD INTPTDS : aliased HAL.UInt32; -- Marks the last PTD in the list for ISO, INT and ATL LASTPTD : aliased LASTPTD_Register; -- Controls the port if it is attached to the host block or the device -- block PORTMODE : aliased PORTMODE_Register; end record with Volatile; for USBHSH_Peripheral use record CAPLENGTH_CHIPID at 16#0# range 0 .. 31; HCSPARAMS at 16#4# range 0 .. 31; FLADJ_FRINDEX at 16#C# range 0 .. 31; ATLPTD at 16#10# range 0 .. 31; ISOPTD at 16#14# range 0 .. 31; INTPTD at 16#18# range 0 .. 31; DATAPAYLOAD at 16#1C# range 0 .. 31; USBCMD at 16#20# range 0 .. 31; USBSTS at 16#24# range 0 .. 31; USBINTR at 16#28# range 0 .. 31; PORTSC1 at 16#2C# range 0 .. 31; ATLPTDD at 16#30# range 0 .. 31; ATLPTDS at 16#34# range 0 .. 31; ISOPTDD at 16#38# range 0 .. 31; ISOPTDS at 16#3C# range 0 .. 31; INTPTDD at 16#40# range 0 .. 31; INTPTDS at 16#44# range 0 .. 31; LASTPTD at 16#48# range 0 .. 31; PORTMODE at 16#50# range 0 .. 31; end record; -- USB1 High-speed Host Controller USBHSH_Periph : aliased USBHSH_Peripheral with Import, Address => System'To_Address (16#400A3000#); end NXP_SVD.USBHSH;
-- { dg-do compile } package tag1 is type T is tagged limited record Y : access T'Class; -- OK X : access Tag1.T'Class; -- Problem end record; end tag1;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Units.Declarations is ------------------ -- Append_Child -- ------------------ procedure Append_Child (Self : in out Unit_Declaration; Value : Program.Compilation_Units.Compilation_Unit_Access) is begin Self.Childern.Append (Value); end Append_Child; ------------------------ -- Corresponding_Body -- ------------------------ overriding function Corresponding_Body (Self : access Unit_Declaration) return Program.Library_Unit_Bodies.Library_Unit_Body_Access is begin return Self.Impl; end Corresponding_Body; ---------------------------- -- Corresponding_Childern -- ---------------------------- overriding function Corresponding_Childern (Self : access Unit_Declaration) return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access is begin if Self.Childern.Is_Empty then return null; else return Self.Childern'Access; end if; end Corresponding_Childern; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Unit_Declaration; Compilation : Program.Compilations.Compilation_Access; Full_Name : Text; Context_Clause : Program.Element_Vectors.Element_Vector_Access; Declaration : not null Program.Elements.Element_Access; Parent : Program.Library_Unit_Declarations .Library_Unit_Declaration_Access) is begin Self.Initialize (Compilation => Compilation, Full_Name => Full_Name, Context_Clause => Context_Clause, Unit_Declaration => Declaration); Self.Parent := Parent; if Parent not in null then Unit_Declaration (Parent.all).Append_Child (Self'Unchecked_Access); end if; Self.Childern.Clear; end Initialize; -------------- -- Set_Body -- -------------- procedure Set_Body (Self : in out Unit_Declaration; Value : Program.Library_Unit_Bodies.Library_Unit_Body_Access) is begin Self.Impl := Value; end Set_Body; ------------ -- Parent -- ------------ overriding function Parent (Self : access Unit_Declaration) return Program.Library_Unit_Declarations.Library_Unit_Declaration_Access is begin return Self.Parent; end Parent; end Program.Units.Declarations;
with Ada.Numerics.Generic_Elementary_Functions; with Giza.Colors; use Giza.Colors; with Ada.Text_IO; use Ada.Text_IO; with Engine_Control_Events; use Engine_Control_Events; package body Power_Phase_Widget is package Float_Functions is new Ada.Numerics.Generic_Elementary_Functions (Float); use Float_Functions; ---------- -- Draw -- ---------- overriding procedure Draw (This : in out PP_Widget; Ctx : in out Context'Class; Force : Boolean := True) is Pt : Point_T; Radius : Integer; Angle : Float; From, To : Float; begin if not This.Dirty and then not Force then return; end if; Draw (Gframe (This), Ctx, True); Ctx.Set_Color (Black); Pt := Center (((0, 0), This.Get_Size)); Radius := (if This.Get_Size.H > This.Get_Size.W then This.Get_Size.W else This.Get_Size.H) / 2; -- remove a margin Radius := Radius - (Radius / 6); Ctx.Set_Font_Size (0.5); Ctx.Move_To (Pt + (Radius / 2, -Radius)); Ctx.Print ("- TDC"); Ctx.Move_To (Pt + (Radius / 2, Radius)); Ctx.Print ("- BDC"); Ctx.Circle (Pt, Radius); Ctx.Set_Color (Red); Angle := Ada.Numerics.Pi / 2.0; From := Angle + (Float (This.Ignition) / 100.0) * Ada.Numerics.Pi; To := From + Float (This.Duration) / 100.0 * Ada.Numerics.Pi; Put_Line ("From angle:" & From'Img); Put_Line ("To angle:" & To'Img); Ctx.Fill_Arc (Pt, Radius, From, To); end Draw; -------------- -- On_Event -- -------------- function On_Event (This : in out PP_Widget; Evt : Event_Not_Null_Ref) return Boolean is begin if Evt.all in Set_PP_Event'Class then declare Set_Pulse_Evt : constant Set_PP_Event_Ref := Set_PP_Event_Ref (Evt); begin if Set_Pulse_Evt.Ignition < PP_Range'First then This.Ignition := PP_Range'First; elsif Set_Pulse_Evt.Ignition > PP_Range'Last then This.Ignition := PP_Range'Last; else This.Ignition := Set_Pulse_Evt.Ignition; end if; if Set_Pulse_Evt.Duration < PP_Range'First then This.Duration := PP_Range'First; elsif Set_Pulse_Evt.Duration > PP_Range'Last then This.Duration := PP_Range'Last; else This.Duration := Set_Pulse_Evt.Duration; end if; This.Set_Dirty; return True; end; end if; return False; end On_Event; ------------------ -- Set_Ignition -- ------------------ procedure Set_Ignition (This : in out PP_Widget; Val : PP_Range) is begin This.Ignition := Val; This.Set_Dirty; end Set_Ignition; ------------------ -- Set_Duration -- ------------------ procedure Set_Duration (This : in out PP_Widget; Val : PP_Range) is begin This.Duration := Val; This.Set_Dirty; end Set_Duration; end Power_Phase_Widget;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . A L T I V E C . L O W _ L E V E L _ V E C T O R S -- -- -- -- B o d y -- -- (Soft Binding Version) -- -- -- -- Copyright (C) 2004-2015, 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. -- -- -- ------------------------------------------------------------------------------ -- ??? What is exactly needed for the soft case is still a bit unclear on -- some accounts. The expected functional equivalence with the Hard binding -- might require tricky things to be done on some targets. -- Examples that come to mind are endianness variations or differences in the -- base FP model while we need the operation results to be the same as what -- the real AltiVec instructions would do on a PowerPC. with Ada.Numerics.Generic_Elementary_Functions; with Interfaces; use Interfaces; with System.Storage_Elements; use System.Storage_Elements; with GNAT.Altivec.Conversions; use GNAT.Altivec.Conversions; with GNAT.Altivec.Low_Level_Interface; use GNAT.Altivec.Low_Level_Interface; package body GNAT.Altivec.Low_Level_Vectors is -- Pixel types. As defined in [PIM-2.1 Data types]: -- A 16-bit pixel is 1/5/5/5; -- A 32-bit pixel is 8/8/8/8. -- We use the following records as an intermediate representation, to -- ease computation. type Unsigned_1 is mod 2 ** 1; type Unsigned_5 is mod 2 ** 5; type Pixel_16 is record T : Unsigned_1; R : Unsigned_5; G : Unsigned_5; B : Unsigned_5; end record; type Pixel_32 is record T : unsigned_char; R : unsigned_char; G : unsigned_char; B : unsigned_char; end record; -- Conversions to/from the pixel records to the integer types that are -- actually stored into the pixel vectors: function To_Pixel (Source : unsigned_short) return Pixel_16; function To_unsigned_short (Source : Pixel_16) return unsigned_short; function To_Pixel (Source : unsigned_int) return Pixel_32; function To_unsigned_int (Source : Pixel_32) return unsigned_int; package C_float_Operations is new Ada.Numerics.Generic_Elementary_Functions (C_float); -- Model of the Vector Status and Control Register (VSCR), as -- defined in [PIM-4.1 Vector Status and Control Register]: VSCR : unsigned_int; -- Positions of the flags in VSCR(0 .. 31): NJ_POS : constant := 15; SAT_POS : constant := 31; -- To control overflows, integer operations are done on 64-bit types: SINT64_MIN : constant := -2 ** 63; SINT64_MAX : constant := 2 ** 63 - 1; UINT64_MAX : constant := 2 ** 64 - 1; type SI64 is range SINT64_MIN .. SINT64_MAX; type UI64 is mod UINT64_MAX + 1; type F64 is digits 15 range -16#0.FFFF_FFFF_FFFF_F8#E+256 .. 16#0.FFFF_FFFF_FFFF_F8#E+256; function Bits (X : unsigned_int; Low : Natural; High : Natural) return unsigned_int; function Bits (X : unsigned_short; Low : Natural; High : Natural) return unsigned_short; function Bits (X : unsigned_char; Low : Natural; High : Natural) return unsigned_char; function Write_Bit (X : unsigned_int; Where : Natural; Value : Unsigned_1) return unsigned_int; function Write_Bit (X : unsigned_short; Where : Natural; Value : Unsigned_1) return unsigned_short; function Write_Bit (X : unsigned_char; Where : Natural; Value : Unsigned_1) return unsigned_char; function NJ_Truncate (X : C_float) return C_float; -- If NJ and A is a denormalized number, return zero function Bound_Align (X : Integer_Address; Y : Integer_Address) return Integer_Address; -- [PIM-4.3 Notations and Conventions] -- Align X in a y-byte boundary and return the result function Rnd_To_FP_Nearest (X : F64) return C_float; -- [PIM-4.3 Notations and Conventions] function Rnd_To_FPI_Near (X : F64) return F64; function Rnd_To_FPI_Trunc (X : F64) return F64; function FP_Recip_Est (X : C_float) return C_float; -- [PIM-4.3 Notations and Conventions] -- 12-bit accurate floating-point estimate of 1/x function ROTL (Value : unsigned_char; Amount : Natural) return unsigned_char; -- [PIM-4.3 Notations and Conventions] -- Rotate left function ROTL (Value : unsigned_short; Amount : Natural) return unsigned_short; function ROTL (Value : unsigned_int; Amount : Natural) return unsigned_int; function Recip_SQRT_Est (X : C_float) return C_float; function Shift_Left (Value : unsigned_char; Amount : Natural) return unsigned_char; -- [PIM-4.3 Notations and Conventions] -- Shift left function Shift_Left (Value : unsigned_short; Amount : Natural) return unsigned_short; function Shift_Left (Value : unsigned_int; Amount : Natural) return unsigned_int; function Shift_Right (Value : unsigned_char; Amount : Natural) return unsigned_char; -- [PIM-4.3 Notations and Conventions] -- Shift Right function Shift_Right (Value : unsigned_short; Amount : Natural) return unsigned_short; function Shift_Right (Value : unsigned_int; Amount : Natural) return unsigned_int; Signed_Bool_False : constant := 0; Signed_Bool_True : constant := -1; ------------------------------ -- Signed_Operations (spec) -- ------------------------------ generic type Component_Type is range <>; type Index_Type is range <>; type Varray_Type is array (Index_Type) of Component_Type; package Signed_Operations is function Modular_Result (X : SI64) return Component_Type; function Saturate (X : SI64) return Component_Type; function Saturate (X : F64) return Component_Type; function Sign_Extend (X : c_int) return Component_Type; -- [PIM-4.3 Notations and Conventions] -- Sign-extend X function abs_vxi (A : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, abs_vxi); function abss_vxi (A : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, abss_vxi); function vaddsxs (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vaddsxs); function vavgsx (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vavgsx); function vcmpgtsx (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vcmpgtsx); function lvexx (A : c_long; B : c_ptr) return Varray_Type; pragma Convention (LL_Altivec, lvexx); function vmaxsx (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vmaxsx); function vmrghx (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vmrghx); function vmrglx (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vmrglx); function vminsx (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vminsx); function vspltx (A : Varray_Type; B : c_int) return Varray_Type; pragma Convention (LL_Altivec, vspltx); function vspltisx (A : c_int) return Varray_Type; pragma Convention (LL_Altivec, vspltisx); type Bit_Operation is access function (Value : Component_Type; Amount : Natural) return Component_Type; function vsrax (A : Varray_Type; B : Varray_Type; Shift_Func : Bit_Operation) return Varray_Type; procedure stvexx (A : Varray_Type; B : c_int; C : c_ptr); pragma Convention (LL_Altivec, stvexx); function vsubsxs (A : Varray_Type; B : Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vsubsxs); function Check_CR6 (A : c_int; D : Varray_Type) return c_int; -- If D is the result of a vcmp operation and A the flag for -- the kind of operation (e.g CR6_LT), check the predicate -- that corresponds to this flag. end Signed_Operations; ------------------------------ -- Signed_Operations (body) -- ------------------------------ package body Signed_Operations is Bool_True : constant Component_Type := Signed_Bool_True; Bool_False : constant Component_Type := Signed_Bool_False; Number_Of_Elements : constant Integer := VECTOR_BIT / Component_Type'Size; -------------------- -- Modular_Result -- -------------------- function Modular_Result (X : SI64) return Component_Type is D : Component_Type; begin if X > 0 then D := Component_Type (UI64 (X) mod (UI64 (Component_Type'Last) + 1)); else D := Component_Type ((-(UI64 (-X) mod (UI64 (Component_Type'Last) + 1)))); end if; return D; end Modular_Result; -------------- -- Saturate -- -------------- function Saturate (X : SI64) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (SI64'Max (SI64 (Component_Type'First), SI64'Min (SI64 (Component_Type'Last), X))); if SI64 (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; function Saturate (X : F64) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (F64'Max (F64 (Component_Type'First), F64'Min (F64 (Component_Type'Last), X))); if F64 (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; ----------------- -- Sign_Extend -- ----------------- function Sign_Extend (X : c_int) return Component_Type is begin -- X is usually a 5-bits literal. In the case of the simulator, -- it is an integral parameter, so sign extension is straightforward. return Component_Type (X); end Sign_Extend; ------------- -- abs_vxi -- ------------- function abs_vxi (A : Varray_Type) return Varray_Type is D : Varray_Type; begin for K in Varray_Type'Range loop D (K) := (if A (K) /= Component_Type'First then abs (A (K)) else Component_Type'First); end loop; return D; end abs_vxi; -------------- -- abss_vxi -- -------------- function abss_vxi (A : Varray_Type) return Varray_Type is D : Varray_Type; begin for K in Varray_Type'Range loop D (K) := Saturate (abs (SI64 (A (K)))); end loop; return D; end abss_vxi; ------------- -- vaddsxs -- ------------- function vaddsxs (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Saturate (SI64 (A (J)) + SI64 (B (J))); end loop; return D; end vaddsxs; ------------ -- vavgsx -- ------------ function vavgsx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Component_Type ((SI64 (A (J)) + SI64 (B (J)) + 1) / 2); end loop; return D; end vavgsx; -------------- -- vcmpgtsx -- -------------- function vcmpgtsx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) > B (J) then Bool_True else Bool_False); end loop; return D; end vcmpgtsx; ----------- -- lvexx -- ----------- function lvexx (A : c_long; B : c_ptr) return Varray_Type is D : Varray_Type; S : Integer; EA : Integer_Address; J : Index_Type; begin S := 16 / Number_Of_Elements; EA := Bound_Align (Integer_Address (A) + To_Integer (B), Integer_Address (S)); J := Index_Type (((EA mod 16) / Integer_Address (S)) + Integer_Address (Index_Type'First)); declare Component : Component_Type; for Component'Address use To_Address (EA); begin D (J) := Component; end; return D; end lvexx; ------------ -- vmaxsx -- ------------ function vmaxsx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) > B (J) then A (J) else B (J)); end loop; return D; end vmaxsx; ------------ -- vmrghx -- ------------ function vmrghx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; Offset : constant Integer := Integer (Index_Type'First); M : constant Integer := Number_Of_Elements / 2; begin for J in 0 .. M - 1 loop D (Index_Type (2 * J + Offset)) := A (Index_Type (J + Offset)); D (Index_Type (2 * J + Offset + 1)) := B (Index_Type (J + Offset)); end loop; return D; end vmrghx; ------------ -- vmrglx -- ------------ function vmrglx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; Offset : constant Integer := Integer (Index_Type'First); M : constant Integer := Number_Of_Elements / 2; begin for J in 0 .. M - 1 loop D (Index_Type (2 * J + Offset)) := A (Index_Type (J + Offset + M)); D (Index_Type (2 * J + Offset + 1)) := B (Index_Type (J + Offset + M)); end loop; return D; end vmrglx; ------------ -- vminsx -- ------------ function vminsx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) < B (J) then A (J) else B (J)); end loop; return D; end vminsx; ------------ -- vspltx -- ------------ function vspltx (A : Varray_Type; B : c_int) return Varray_Type is J : constant Integer := Integer (B) mod Number_Of_Elements + Integer (Varray_Type'First); D : Varray_Type; begin for K in Varray_Type'Range loop D (K) := A (Index_Type (J)); end loop; return D; end vspltx; -------------- -- vspltisx -- -------------- function vspltisx (A : c_int) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Sign_Extend (A); end loop; return D; end vspltisx; ----------- -- vsrax -- ----------- function vsrax (A : Varray_Type; B : Varray_Type; Shift_Func : Bit_Operation) return Varray_Type is D : Varray_Type; S : constant Component_Type := Component_Type (128 / Number_Of_Elements); begin for J in Varray_Type'Range loop D (J) := Shift_Func (A (J), Natural (B (J) mod S)); end loop; return D; end vsrax; ------------ -- stvexx -- ------------ procedure stvexx (A : Varray_Type; B : c_int; C : c_ptr) is S : Integer; EA : Integer_Address; J : Index_Type; begin S := 16 / Number_Of_Elements; EA := Bound_Align (Integer_Address (B) + To_Integer (C), Integer_Address (S)); J := Index_Type ((EA mod 16) / Integer_Address (S) + Integer_Address (Index_Type'First)); declare Component : Component_Type; for Component'Address use To_Address (EA); begin Component := A (J); end; end stvexx; ------------- -- vsubsxs -- ------------- function vsubsxs (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Saturate (SI64 (A (J)) - SI64 (B (J))); end loop; return D; end vsubsxs; --------------- -- Check_CR6 -- --------------- function Check_CR6 (A : c_int; D : Varray_Type) return c_int is All_Element : Boolean := True; Any_Element : Boolean := False; begin for J in Varray_Type'Range loop All_Element := All_Element and then (D (J) = Bool_True); Any_Element := Any_Element or else (D (J) = Bool_True); end loop; if A = CR6_LT then if All_Element then return 1; else return 0; end if; elsif A = CR6_EQ then if not Any_Element then return 1; else return 0; end if; elsif A = CR6_EQ_REV then if Any_Element then return 1; else return 0; end if; elsif A = CR6_LT_REV then if not All_Element then return 1; else return 0; end if; end if; return 0; end Check_CR6; end Signed_Operations; -------------------------------- -- Unsigned_Operations (spec) -- -------------------------------- generic type Component_Type is mod <>; type Index_Type is range <>; type Varray_Type is array (Index_Type) of Component_Type; package Unsigned_Operations is function Bits (X : Component_Type; Low : Natural; High : Natural) return Component_Type; -- Return X [Low:High] as defined in [PIM-4.3 Notations and Conventions] -- using big endian bit ordering. function Write_Bit (X : Component_Type; Where : Natural; Value : Unsigned_1) return Component_Type; -- Write Value into X[Where:Where] (if it fits in) and return the result -- (big endian bit ordering). function Modular_Result (X : UI64) return Component_Type; function Saturate (X : UI64) return Component_Type; function Saturate (X : F64) return Component_Type; function Saturate (X : SI64) return Component_Type; function vadduxm (A : Varray_Type; B : Varray_Type) return Varray_Type; function vadduxs (A : Varray_Type; B : Varray_Type) return Varray_Type; function vavgux (A : Varray_Type; B : Varray_Type) return Varray_Type; function vcmpequx (A : Varray_Type; B : Varray_Type) return Varray_Type; function vcmpgtux (A : Varray_Type; B : Varray_Type) return Varray_Type; function vmaxux (A : Varray_Type; B : Varray_Type) return Varray_Type; function vminux (A : Varray_Type; B : Varray_Type) return Varray_Type; type Bit_Operation is access function (Value : Component_Type; Amount : Natural) return Component_Type; function vrlx (A : Varray_Type; B : Varray_Type; ROTL : Bit_Operation) return Varray_Type; function vsxx (A : Varray_Type; B : Varray_Type; Shift_Func : Bit_Operation) return Varray_Type; -- Vector shift (left or right, depending on Shift_Func) function vsubuxm (A : Varray_Type; B : Varray_Type) return Varray_Type; function vsubuxs (A : Varray_Type; B : Varray_Type) return Varray_Type; function Check_CR6 (A : c_int; D : Varray_Type) return c_int; -- If D is the result of a vcmp operation and A the flag for -- the kind of operation (e.g CR6_LT), check the predicate -- that corresponds to this flag. end Unsigned_Operations; -------------------------------- -- Unsigned_Operations (body) -- -------------------------------- package body Unsigned_Operations is Number_Of_Elements : constant Integer := VECTOR_BIT / Component_Type'Size; Bool_True : constant Component_Type := Component_Type'Last; Bool_False : constant Component_Type := 0; -------------------- -- Modular_Result -- -------------------- function Modular_Result (X : UI64) return Component_Type is D : Component_Type; begin D := Component_Type (X mod (UI64 (Component_Type'Last) + 1)); return D; end Modular_Result; -------------- -- Saturate -- -------------- function Saturate (X : UI64) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (UI64'Max (UI64 (Component_Type'First), UI64'Min (UI64 (Component_Type'Last), X))); if UI64 (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; function Saturate (X : SI64) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (SI64'Max (SI64 (Component_Type'First), SI64'Min (SI64 (Component_Type'Last), X))); if SI64 (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; function Saturate (X : F64) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (F64'Max (F64 (Component_Type'First), F64'Min (F64 (Component_Type'Last), X))); if F64 (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; ---------- -- Bits -- ---------- function Bits (X : Component_Type; Low : Natural; High : Natural) return Component_Type is Mask : Component_Type := 0; -- The Altivec ABI uses a big endian bit ordering, and we are -- using little endian bit ordering for extracting bits: Low_LE : constant Natural := Component_Type'Size - 1 - High; High_LE : constant Natural := Component_Type'Size - 1 - Low; begin pragma Assert (Low <= Component_Type'Size); pragma Assert (High <= Component_Type'Size); for J in Low_LE .. High_LE loop Mask := Mask or 2 ** J; end loop; return (X and Mask) / 2 ** Low_LE; end Bits; --------------- -- Write_Bit -- --------------- function Write_Bit (X : Component_Type; Where : Natural; Value : Unsigned_1) return Component_Type is Result : Component_Type := 0; -- The Altivec ABI uses a big endian bit ordering, and we are -- using little endian bit ordering for extracting bits: Where_LE : constant Natural := Component_Type'Size - 1 - Where; begin pragma Assert (Where < Component_Type'Size); case Value is when 1 => Result := X or 2 ** Where_LE; when 0 => Result := X and not (2 ** Where_LE); end case; return Result; end Write_Bit; ------------- -- vadduxm -- ------------- function vadduxm (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := A (J) + B (J); end loop; return D; end vadduxm; ------------- -- vadduxs -- ------------- function vadduxs (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Saturate (UI64 (A (J)) + UI64 (B (J))); end loop; return D; end vadduxs; ------------ -- vavgux -- ------------ function vavgux (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Component_Type ((UI64 (A (J)) + UI64 (B (J)) + 1) / 2); end loop; return D; end vavgux; -------------- -- vcmpequx -- -------------- function vcmpequx (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) = B (J) then Bool_True else Bool_False); end loop; return D; end vcmpequx; -------------- -- vcmpgtux -- -------------- function vcmpgtux (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) > B (J) then Bool_True else Bool_False); end loop; return D; end vcmpgtux; ------------ -- vmaxux -- ------------ function vmaxux (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) > B (J) then A (J) else B (J)); end loop; return D; end vmaxux; ------------ -- vminux -- ------------ function vminux (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := (if A (J) < B (J) then A (J) else B (J)); end loop; return D; end vminux; ---------- -- vrlx -- ---------- function vrlx (A : Varray_Type; B : Varray_Type; ROTL : Bit_Operation) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := ROTL (A (J), Natural (B (J))); end loop; return D; end vrlx; ---------- -- vsxx -- ---------- function vsxx (A : Varray_Type; B : Varray_Type; Shift_Func : Bit_Operation) return Varray_Type is D : Varray_Type; S : constant Component_Type := Component_Type (128 / Number_Of_Elements); begin for J in Varray_Type'Range loop D (J) := Shift_Func (A (J), Natural (B (J) mod S)); end loop; return D; end vsxx; ------------- -- vsubuxm -- ------------- function vsubuxm (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := A (J) - B (J); end loop; return D; end vsubuxm; ------------- -- vsubuxs -- ------------- function vsubuxs (A : Varray_Type; B : Varray_Type) return Varray_Type is D : Varray_Type; begin for J in Varray_Type'Range loop D (J) := Saturate (SI64 (A (J)) - SI64 (B (J))); end loop; return D; end vsubuxs; --------------- -- Check_CR6 -- --------------- function Check_CR6 (A : c_int; D : Varray_Type) return c_int is All_Element : Boolean := True; Any_Element : Boolean := False; begin for J in Varray_Type'Range loop All_Element := All_Element and then (D (J) = Bool_True); Any_Element := Any_Element or else (D (J) = Bool_True); end loop; if A = CR6_LT then if All_Element then return 1; else return 0; end if; elsif A = CR6_EQ then if not Any_Element then return 1; else return 0; end if; elsif A = CR6_EQ_REV then if Any_Element then return 1; else return 0; end if; elsif A = CR6_LT_REV then if not All_Element then return 1; else return 0; end if; end if; return 0; end Check_CR6; end Unsigned_Operations; -------------------------------------- -- Signed_Merging_Operations (spec) -- -------------------------------------- generic type Component_Type is range <>; type Index_Type is range <>; type Varray_Type is array (Index_Type) of Component_Type; type Double_Component_Type is range <>; type Double_Index_Type is range <>; type Double_Varray_Type is array (Double_Index_Type) of Double_Component_Type; package Signed_Merging_Operations is pragma Assert (Integer (Varray_Type'First) = Integer (Double_Varray_Type'First)); pragma Assert (Varray_Type'Length = 2 * Double_Varray_Type'Length); pragma Assert (2 * Component_Type'Size = Double_Component_Type'Size); function Saturate (X : Double_Component_Type) return Component_Type; function vmulxsx (Use_Even_Components : Boolean; A : Varray_Type; B : Varray_Type) return Double_Varray_Type; function vpksxss (A : Double_Varray_Type; B : Double_Varray_Type) return Varray_Type; pragma Convention (LL_Altivec, vpksxss); function vupkxsx (A : Varray_Type; Offset : Natural) return Double_Varray_Type; end Signed_Merging_Operations; -------------------------------------- -- Signed_Merging_Operations (body) -- -------------------------------------- package body Signed_Merging_Operations is -------------- -- Saturate -- -------------- function Saturate (X : Double_Component_Type) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (Double_Component_Type'Max (Double_Component_Type (Component_Type'First), Double_Component_Type'Min (Double_Component_Type (Component_Type'Last), X))); if Double_Component_Type (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; ------------- -- vmulsxs -- ------------- function vmulxsx (Use_Even_Components : Boolean; A : Varray_Type; B : Varray_Type) return Double_Varray_Type is Double_Offset : Double_Index_Type; Offset : Index_Type; D : Double_Varray_Type; N : constant Integer := Integer (Double_Index_Type'Last) - Integer (Double_Index_Type'First) + 1; begin for J in 0 .. N - 1 loop Offset := Index_Type ((if Use_Even_Components then 2 * J else 2 * J + 1) + Integer (Index_Type'First)); Double_Offset := Double_Index_Type (J + Integer (Double_Index_Type'First)); D (Double_Offset) := Double_Component_Type (A (Offset)) * Double_Component_Type (B (Offset)); end loop; return D; end vmulxsx; ------------- -- vpksxss -- ------------- function vpksxss (A : Double_Varray_Type; B : Double_Varray_Type) return Varray_Type is N : constant Index_Type := Index_Type (Double_Index_Type'Last); D : Varray_Type; Offset : Index_Type; Double_Offset : Double_Index_Type; begin for J in 0 .. N - 1 loop Offset := Index_Type (Integer (J) + Integer (Index_Type'First)); Double_Offset := Double_Index_Type (Integer (J) + Integer (Double_Index_Type'First)); D (Offset) := Saturate (A (Double_Offset)); D (Offset + N) := Saturate (B (Double_Offset)); end loop; return D; end vpksxss; ------------- -- vupkxsx -- ------------- function vupkxsx (A : Varray_Type; Offset : Natural) return Double_Varray_Type is K : Index_Type; D : Double_Varray_Type; begin for J in Double_Varray_Type'Range loop K := Index_Type (Integer (J) - Integer (Double_Index_Type'First) + Integer (Index_Type'First) + Offset); D (J) := Double_Component_Type (A (K)); end loop; return D; end vupkxsx; end Signed_Merging_Operations; ---------------------------------------- -- Unsigned_Merging_Operations (spec) -- ---------------------------------------- generic type Component_Type is mod <>; type Index_Type is range <>; type Varray_Type is array (Index_Type) of Component_Type; type Double_Component_Type is mod <>; type Double_Index_Type is range <>; type Double_Varray_Type is array (Double_Index_Type) of Double_Component_Type; package Unsigned_Merging_Operations is pragma Assert (Integer (Varray_Type'First) = Integer (Double_Varray_Type'First)); pragma Assert (Varray_Type'Length = 2 * Double_Varray_Type'Length); pragma Assert (2 * Component_Type'Size = Double_Component_Type'Size); function UI_To_UI_Mod (X : Double_Component_Type; Y : Natural) return Component_Type; function Saturate (X : Double_Component_Type) return Component_Type; function vmulxux (Use_Even_Components : Boolean; A : Varray_Type; B : Varray_Type) return Double_Varray_Type; function vpkuxum (A : Double_Varray_Type; B : Double_Varray_Type) return Varray_Type; function vpkuxus (A : Double_Varray_Type; B : Double_Varray_Type) return Varray_Type; end Unsigned_Merging_Operations; ---------------------------------------- -- Unsigned_Merging_Operations (body) -- ---------------------------------------- package body Unsigned_Merging_Operations is ------------------ -- UI_To_UI_Mod -- ------------------ function UI_To_UI_Mod (X : Double_Component_Type; Y : Natural) return Component_Type is Z : Component_Type; begin Z := Component_Type (X mod 2 ** Y); return Z; end UI_To_UI_Mod; -------------- -- Saturate -- -------------- function Saturate (X : Double_Component_Type) return Component_Type is D : Component_Type; begin -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] D := Component_Type (Double_Component_Type'Max (Double_Component_Type (Component_Type'First), Double_Component_Type'Min (Double_Component_Type (Component_Type'Last), X))); if Double_Component_Type (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; ------------- -- vmulxux -- ------------- function vmulxux (Use_Even_Components : Boolean; A : Varray_Type; B : Varray_Type) return Double_Varray_Type is Double_Offset : Double_Index_Type; Offset : Index_Type; D : Double_Varray_Type; N : constant Integer := Integer (Double_Index_Type'Last) - Integer (Double_Index_Type'First) + 1; begin for J in 0 .. N - 1 loop Offset := Index_Type ((if Use_Even_Components then 2 * J else 2 * J + 1) + Integer (Index_Type'First)); Double_Offset := Double_Index_Type (J + Integer (Double_Index_Type'First)); D (Double_Offset) := Double_Component_Type (A (Offset)) * Double_Component_Type (B (Offset)); end loop; return D; end vmulxux; ------------- -- vpkuxum -- ------------- function vpkuxum (A : Double_Varray_Type; B : Double_Varray_Type) return Varray_Type is S : constant Natural := Double_Component_Type'Size / 2; N : constant Index_Type := Index_Type (Double_Index_Type'Last); D : Varray_Type; Offset : Index_Type; Double_Offset : Double_Index_Type; begin for J in 0 .. N - 1 loop Offset := Index_Type (Integer (J) + Integer (Index_Type'First)); Double_Offset := Double_Index_Type (Integer (J) + Integer (Double_Index_Type'First)); D (Offset) := UI_To_UI_Mod (A (Double_Offset), S); D (Offset + N) := UI_To_UI_Mod (B (Double_Offset), S); end loop; return D; end vpkuxum; ------------- -- vpkuxus -- ------------- function vpkuxus (A : Double_Varray_Type; B : Double_Varray_Type) return Varray_Type is N : constant Index_Type := Index_Type (Double_Index_Type'Last); D : Varray_Type; Offset : Index_Type; Double_Offset : Double_Index_Type; begin for J in 0 .. N - 1 loop Offset := Index_Type (Integer (J) + Integer (Index_Type'First)); Double_Offset := Double_Index_Type (Integer (J) + Integer (Double_Index_Type'First)); D (Offset) := Saturate (A (Double_Offset)); D (Offset + N) := Saturate (B (Double_Offset)); end loop; return D; end vpkuxus; end Unsigned_Merging_Operations; package LL_VSC_Operations is new Signed_Operations (signed_char, Vchar_Range, Varray_signed_char); package LL_VSS_Operations is new Signed_Operations (signed_short, Vshort_Range, Varray_signed_short); package LL_VSI_Operations is new Signed_Operations (signed_int, Vint_Range, Varray_signed_int); package LL_VUC_Operations is new Unsigned_Operations (unsigned_char, Vchar_Range, Varray_unsigned_char); package LL_VUS_Operations is new Unsigned_Operations (unsigned_short, Vshort_Range, Varray_unsigned_short); package LL_VUI_Operations is new Unsigned_Operations (unsigned_int, Vint_Range, Varray_unsigned_int); package LL_VSC_LL_VSS_Operations is new Signed_Merging_Operations (signed_char, Vchar_Range, Varray_signed_char, signed_short, Vshort_Range, Varray_signed_short); package LL_VSS_LL_VSI_Operations is new Signed_Merging_Operations (signed_short, Vshort_Range, Varray_signed_short, signed_int, Vint_Range, Varray_signed_int); package LL_VUC_LL_VUS_Operations is new Unsigned_Merging_Operations (unsigned_char, Vchar_Range, Varray_unsigned_char, unsigned_short, Vshort_Range, Varray_unsigned_short); package LL_VUS_LL_VUI_Operations is new Unsigned_Merging_Operations (unsigned_short, Vshort_Range, Varray_unsigned_short, unsigned_int, Vint_Range, Varray_unsigned_int); ---------- -- Bits -- ---------- function Bits (X : unsigned_int; Low : Natural; High : Natural) return unsigned_int renames LL_VUI_Operations.Bits; function Bits (X : unsigned_short; Low : Natural; High : Natural) return unsigned_short renames LL_VUS_Operations.Bits; function Bits (X : unsigned_char; Low : Natural; High : Natural) return unsigned_char renames LL_VUC_Operations.Bits; --------------- -- Write_Bit -- --------------- function Write_Bit (X : unsigned_int; Where : Natural; Value : Unsigned_1) return unsigned_int renames LL_VUI_Operations.Write_Bit; function Write_Bit (X : unsigned_short; Where : Natural; Value : Unsigned_1) return unsigned_short renames LL_VUS_Operations.Write_Bit; function Write_Bit (X : unsigned_char; Where : Natural; Value : Unsigned_1) return unsigned_char renames LL_VUC_Operations.Write_Bit; ----------------- -- Bound_Align -- ----------------- function Bound_Align (X : Integer_Address; Y : Integer_Address) return Integer_Address is D : Integer_Address; begin D := X - X mod Y; return D; end Bound_Align; ----------------- -- NJ_Truncate -- ----------------- function NJ_Truncate (X : C_float) return C_float is D : C_float; begin if (Bits (VSCR, NJ_POS, NJ_POS) = 1) and then abs (X) < 2.0 ** (-126) then D := (if X < 0.0 then -0.0 else +0.0); else D := X; end if; return D; end NJ_Truncate; ----------------------- -- Rnd_To_FP_Nearest -- ----------------------- function Rnd_To_FP_Nearest (X : F64) return C_float is begin return C_float (X); end Rnd_To_FP_Nearest; --------------------- -- Rnd_To_FPI_Near -- --------------------- function Rnd_To_FPI_Near (X : F64) return F64 is Result : F64; Ceiling : F64; begin Result := F64 (SI64 (X)); if (F64'Ceiling (X) - X) = (X + 1.0 - F64'Ceiling (X)) then -- Round to even Ceiling := F64'Ceiling (X); Result := (if Rnd_To_FPI_Trunc (Ceiling / 2.0) * 2.0 = Ceiling then Ceiling else Ceiling - 1.0); end if; return Result; end Rnd_To_FPI_Near; ---------------------- -- Rnd_To_FPI_Trunc -- ---------------------- function Rnd_To_FPI_Trunc (X : F64) return F64 is Result : F64; begin Result := F64'Ceiling (X); -- Rnd_To_FPI_Trunc rounds toward 0, 'Ceiling rounds toward -- +Infinity if X > 0.0 and then Result /= X then Result := Result - 1.0; end if; return Result; end Rnd_To_FPI_Trunc; ------------------ -- FP_Recip_Est -- ------------------ function FP_Recip_Est (X : C_float) return C_float is begin -- ??? [PIM-4.4 vec_re] "For result that are not +0, -0, +Inf, -- -Inf, or QNaN, the estimate has a relative error no greater -- than one part in 4096, that is: -- Abs ((estimate - 1 / x) / (1 / x)) < = 1/4096" return NJ_Truncate (1.0 / NJ_Truncate (X)); end FP_Recip_Est; ---------- -- ROTL -- ---------- function ROTL (Value : unsigned_char; Amount : Natural) return unsigned_char is Result : Unsigned_8; begin Result := Rotate_Left (Unsigned_8 (Value), Amount); return unsigned_char (Result); end ROTL; function ROTL (Value : unsigned_short; Amount : Natural) return unsigned_short is Result : Unsigned_16; begin Result := Rotate_Left (Unsigned_16 (Value), Amount); return unsigned_short (Result); end ROTL; function ROTL (Value : unsigned_int; Amount : Natural) return unsigned_int is Result : Unsigned_32; begin Result := Rotate_Left (Unsigned_32 (Value), Amount); return unsigned_int (Result); end ROTL; -------------------- -- Recip_SQRT_Est -- -------------------- function Recip_SQRT_Est (X : C_float) return C_float is Result : C_float; begin -- ??? -- [PIM-4.4 vec_rsqrte] the estimate has a relative error in precision -- no greater than one part in 4096, that is: -- abs ((estimate - 1 / sqrt (x)) / (1 / sqrt (x)) <= 1 / 4096" Result := 1.0 / NJ_Truncate (C_float_Operations.Sqrt (NJ_Truncate (X))); return NJ_Truncate (Result); end Recip_SQRT_Est; ---------------- -- Shift_Left -- ---------------- function Shift_Left (Value : unsigned_char; Amount : Natural) return unsigned_char is Result : Unsigned_8; begin Result := Shift_Left (Unsigned_8 (Value), Amount); return unsigned_char (Result); end Shift_Left; function Shift_Left (Value : unsigned_short; Amount : Natural) return unsigned_short is Result : Unsigned_16; begin Result := Shift_Left (Unsigned_16 (Value), Amount); return unsigned_short (Result); end Shift_Left; function Shift_Left (Value : unsigned_int; Amount : Natural) return unsigned_int is Result : Unsigned_32; begin Result := Shift_Left (Unsigned_32 (Value), Amount); return unsigned_int (Result); end Shift_Left; ----------------- -- Shift_Right -- ----------------- function Shift_Right (Value : unsigned_char; Amount : Natural) return unsigned_char is Result : Unsigned_8; begin Result := Shift_Right (Unsigned_8 (Value), Amount); return unsigned_char (Result); end Shift_Right; function Shift_Right (Value : unsigned_short; Amount : Natural) return unsigned_short is Result : Unsigned_16; begin Result := Shift_Right (Unsigned_16 (Value), Amount); return unsigned_short (Result); end Shift_Right; function Shift_Right (Value : unsigned_int; Amount : Natural) return unsigned_int is Result : Unsigned_32; begin Result := Shift_Right (Unsigned_32 (Value), Amount); return unsigned_int (Result); end Shift_Right; ------------------- -- Shift_Right_A -- ------------------- generic type Signed_Type is range <>; type Unsigned_Type is mod <>; with function Shift_Right (Value : Unsigned_Type; Amount : Natural) return Unsigned_Type; function Shift_Right_Arithmetic (Value : Signed_Type; Amount : Natural) return Signed_Type; function Shift_Right_Arithmetic (Value : Signed_Type; Amount : Natural) return Signed_Type is begin if Value > 0 then return Signed_Type (Shift_Right (Unsigned_Type (Value), Amount)); else return -Signed_Type (Shift_Right (Unsigned_Type (-Value - 1), Amount) + 1); end if; end Shift_Right_Arithmetic; function Shift_Right_A is new Shift_Right_Arithmetic (signed_int, Unsigned_32, Shift_Right); function Shift_Right_A is new Shift_Right_Arithmetic (signed_short, Unsigned_16, Shift_Right); function Shift_Right_A is new Shift_Right_Arithmetic (signed_char, Unsigned_8, Shift_Right); -------------- -- To_Pixel -- -------------- function To_Pixel (Source : unsigned_short) return Pixel_16 is -- This conversion should not depend on the host endianness; -- therefore, we cannot use an unchecked conversion. Target : Pixel_16; begin Target.T := Unsigned_1 (Bits (Source, 0, 0) mod 2 ** 1); Target.R := Unsigned_5 (Bits (Source, 1, 5) mod 2 ** 5); Target.G := Unsigned_5 (Bits (Source, 6, 10) mod 2 ** 5); Target.B := Unsigned_5 (Bits (Source, 11, 15) mod 2 ** 5); return Target; end To_Pixel; function To_Pixel (Source : unsigned_int) return Pixel_32 is -- This conversion should not depend on the host endianness; -- therefore, we cannot use an unchecked conversion. Target : Pixel_32; begin Target.T := unsigned_char (Bits (Source, 0, 7)); Target.R := unsigned_char (Bits (Source, 8, 15)); Target.G := unsigned_char (Bits (Source, 16, 23)); Target.B := unsigned_char (Bits (Source, 24, 31)); return Target; end To_Pixel; --------------------- -- To_unsigned_int -- --------------------- function To_unsigned_int (Source : Pixel_32) return unsigned_int is -- This conversion should not depend on the host endianness; -- therefore, we cannot use an unchecked conversion. -- It should also be the same result, value-wise, on two hosts -- with the same endianness. Target : unsigned_int := 0; begin -- In big endian bit ordering, Pixel_32 looks like: -- ------------------------------------- -- | T | R | G | B | -- ------------------------------------- -- 0 (MSB) 7 15 23 32 -- -- Sizes of the components: (8/8/8/8) -- Target := Target or unsigned_int (Source.T); Target := Shift_Left (Target, 8); Target := Target or unsigned_int (Source.R); Target := Shift_Left (Target, 8); Target := Target or unsigned_int (Source.G); Target := Shift_Left (Target, 8); Target := Target or unsigned_int (Source.B); return Target; end To_unsigned_int; ----------------------- -- To_unsigned_short -- ----------------------- function To_unsigned_short (Source : Pixel_16) return unsigned_short is -- This conversion should not depend on the host endianness; -- therefore, we cannot use an unchecked conversion. -- It should also be the same result, value-wise, on two hosts -- with the same endianness. Target : unsigned_short := 0; begin -- In big endian bit ordering, Pixel_16 looks like: -- ------------------------------------- -- | T | R | G | B | -- ------------------------------------- -- 0 (MSB) 1 5 11 15 -- -- Sizes of the components: (1/5/5/5) -- Target := Target or unsigned_short (Source.T); Target := Shift_Left (Target, 5); Target := Target or unsigned_short (Source.R); Target := Shift_Left (Target, 5); Target := Target or unsigned_short (Source.G); Target := Shift_Left (Target, 5); Target := Target or unsigned_short (Source.B); return Target; end To_unsigned_short; --------------- -- abs_v16qi -- --------------- function abs_v16qi (A : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); begin return To_Vector ((Values => LL_VSC_Operations.abs_vxi (VA.Values))); end abs_v16qi; -------------- -- abs_v8hi -- -------------- function abs_v8hi (A : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); begin return To_Vector ((Values => LL_VSS_Operations.abs_vxi (VA.Values))); end abs_v8hi; -------------- -- abs_v4si -- -------------- function abs_v4si (A : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); begin return To_Vector ((Values => LL_VSI_Operations.abs_vxi (VA.Values))); end abs_v4si; -------------- -- abs_v4sf -- -------------- function abs_v4sf (A : LL_VF) return LL_VF is D : Varray_float; VA : constant VF_View := To_View (A); begin for J in Varray_float'Range loop D (J) := abs (VA.Values (J)); end loop; return To_Vector ((Values => D)); end abs_v4sf; ---------------- -- abss_v16qi -- ---------------- function abss_v16qi (A : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); begin return To_Vector ((Values => LL_VSC_Operations.abss_vxi (VA.Values))); end abss_v16qi; --------------- -- abss_v8hi -- --------------- function abss_v8hi (A : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); begin return To_Vector ((Values => LL_VSS_Operations.abss_vxi (VA.Values))); end abss_v8hi; --------------- -- abss_v4si -- --------------- function abss_v4si (A : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); begin return To_Vector ((Values => LL_VSI_Operations.abss_vxi (VA.Values))); end abss_v4si; ------------- -- vaddubm -- ------------- function vaddubm (A : LL_VSC; B : LL_VSC) return LL_VSC is UC : constant GNAT.Altivec.Low_Level_Vectors.LL_VUC := To_LL_VUC (A); VA : constant VUC_View := To_View (UC); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : Varray_unsigned_char; begin D := LL_VUC_Operations.vadduxm (VA.Values, VB.Values); return To_LL_VSC (To_Vector (VUC_View'(Values => D))); end vaddubm; ------------- -- vadduhm -- ------------- function vadduhm (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : Varray_unsigned_short; begin D := LL_VUS_Operations.vadduxm (VA.Values, VB.Values); return To_LL_VSS (To_Vector (VUS_View'(Values => D))); end vadduhm; ------------- -- vadduwm -- ------------- function vadduwm (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : Varray_unsigned_int; begin D := LL_VUI_Operations.vadduxm (VA.Values, VB.Values); return To_LL_VSI (To_Vector (VUI_View'(Values => D))); end vadduwm; ------------ -- vaddfp -- ------------ function vaddfp (A : LL_VF; B : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : Varray_float; begin for J in Varray_float'Range loop D (J) := NJ_Truncate (NJ_Truncate (VA.Values (J)) + NJ_Truncate (VB.Values (J))); end loop; return To_Vector (VF_View'(Values => D)); end vaddfp; ------------- -- vaddcuw -- ------------- function vaddcuw (A : LL_VSI; B : LL_VSI) return LL_VSI is Addition_Result : UI64; D : VUI_View; VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); begin for J in Varray_unsigned_int'Range loop Addition_Result := UI64 (VA.Values (J)) + UI64 (VB.Values (J)); D.Values (J) := (if Addition_Result > UI64 (unsigned_int'Last) then 1 else 0); end loop; return To_LL_VSI (To_Vector (D)); end vaddcuw; ------------- -- vaddubs -- ------------- function vaddubs (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); begin return To_LL_VSC (To_Vector (VUC_View'(Values => (LL_VUC_Operations.vadduxs (VA.Values, VB.Values))))); end vaddubs; ------------- -- vaddsbs -- ------------- function vaddsbs (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vaddsxs (VA.Values, VB.Values); return To_Vector (D); end vaddsbs; ------------- -- vadduhs -- ------------- function vadduhs (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vadduxs (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vadduhs; ------------- -- vaddshs -- ------------- function vaddshs (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vaddsxs (VA.Values, VB.Values); return To_Vector (D); end vaddshs; ------------- -- vadduws -- ------------- function vadduws (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vadduxs (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vadduws; ------------- -- vaddsws -- ------------- function vaddsws (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vaddsxs (VA.Values, VB.Values); return To_Vector (D); end vaddsws; ---------- -- vand -- ---------- function vand (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin for J in Varray_unsigned_int'Range loop D.Values (J) := VA.Values (J) and VB.Values (J); end loop; return To_LL_VSI (To_Vector (D)); end vand; ----------- -- vandc -- ----------- function vandc (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin for J in Varray_unsigned_int'Range loop D.Values (J) := VA.Values (J) and not VB.Values (J); end loop; return To_LL_VSI (To_Vector (D)); end vandc; ------------ -- vavgub -- ------------ function vavgub (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vavgux (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vavgub; ------------ -- vavgsb -- ------------ function vavgsb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vavgsx (VA.Values, VB.Values); return To_Vector (D); end vavgsb; ------------ -- vavguh -- ------------ function vavguh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vavgux (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vavguh; ------------ -- vavgsh -- ------------ function vavgsh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vavgsx (VA.Values, VB.Values); return To_Vector (D); end vavgsh; ------------ -- vavguw -- ------------ function vavguw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vavgux (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vavguw; ------------ -- vavgsw -- ------------ function vavgsw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vavgsx (VA.Values, VB.Values); return To_Vector (D); end vavgsw; ----------- -- vrfip -- ----------- function vrfip (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Varray_float'Range loop -- If A (J) is infinite, D (J) should be infinite; With -- IEEE floating points, we can use 'Ceiling for that purpose. D.Values (J) := C_float'Ceiling (NJ_Truncate (VA.Values (J))); end loop; return To_Vector (D); end vrfip; ------------- -- vcmpbfp -- ------------- function vcmpbfp (A : LL_VF; B : LL_VF) return LL_VSI is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VUI_View; K : Vint_Range; begin for J in Varray_float'Range loop K := Vint_Range (J); D.Values (K) := 0; if NJ_Truncate (VB.Values (J)) < 0.0 then -- [PIM-4.4 vec_cmpb] "If any single-precision floating-point -- word element in B is negative; the corresponding element in A -- is out of bounds. D.Values (K) := Write_Bit (D.Values (K), 0, 1); D.Values (K) := Write_Bit (D.Values (K), 1, 1); else D.Values (K) := (if NJ_Truncate (VA.Values (J)) <= NJ_Truncate (VB.Values (J)) then Write_Bit (D.Values (K), 0, 0) else Write_Bit (D.Values (K), 0, 1)); D.Values (K) := (if NJ_Truncate (VA.Values (J)) >= -NJ_Truncate (VB.Values (J)) then Write_Bit (D.Values (K), 1, 0) else Write_Bit (D.Values (K), 1, 1)); end if; end loop; return To_LL_VSI (To_Vector (D)); end vcmpbfp; -------------- -- vcmpequb -- -------------- function vcmpequb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vcmpequx (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vcmpequb; -------------- -- vcmpequh -- -------------- function vcmpequh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vcmpequx (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vcmpequh; -------------- -- vcmpequw -- -------------- function vcmpequw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vcmpequx (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vcmpequw; -------------- -- vcmpeqfp -- -------------- function vcmpeqfp (A : LL_VF; B : LL_VF) return LL_VSI is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VUI_View; begin for J in Varray_float'Range loop D.Values (Vint_Range (J)) := (if VA.Values (J) = VB.Values (J) then unsigned_int'Last else 0); end loop; return To_LL_VSI (To_Vector (D)); end vcmpeqfp; -------------- -- vcmpgefp -- -------------- function vcmpgefp (A : LL_VF; B : LL_VF) return LL_VSI is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VSI_View; begin for J in Varray_float'Range loop D.Values (Vint_Range (J)) := (if VA.Values (J) >= VB.Values (J) then Signed_Bool_True else Signed_Bool_False); end loop; return To_Vector (D); end vcmpgefp; -------------- -- vcmpgtub -- -------------- function vcmpgtub (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vcmpgtux (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vcmpgtub; -------------- -- vcmpgtsb -- -------------- function vcmpgtsb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vcmpgtsx (VA.Values, VB.Values); return To_Vector (D); end vcmpgtsb; -------------- -- vcmpgtuh -- -------------- function vcmpgtuh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vcmpgtux (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vcmpgtuh; -------------- -- vcmpgtsh -- -------------- function vcmpgtsh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vcmpgtsx (VA.Values, VB.Values); return To_Vector (D); end vcmpgtsh; -------------- -- vcmpgtuw -- -------------- function vcmpgtuw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vcmpgtux (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vcmpgtuw; -------------- -- vcmpgtsw -- -------------- function vcmpgtsw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vcmpgtsx (VA.Values, VB.Values); return To_Vector (D); end vcmpgtsw; -------------- -- vcmpgtfp -- -------------- function vcmpgtfp (A : LL_VF; B : LL_VF) return LL_VSI is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VSI_View; begin for J in Varray_float'Range loop D.Values (Vint_Range (J)) := (if NJ_Truncate (VA.Values (J)) > NJ_Truncate (VB.Values (J)) then Signed_Bool_True else Signed_Bool_False); end loop; return To_Vector (D); end vcmpgtfp; ----------- -- vcfux -- ----------- function vcfux (A : LL_VUI; B : c_int) return LL_VF is VA : constant VUI_View := To_View (A); D : VF_View; K : Vfloat_Range; begin for J in Varray_signed_int'Range loop K := Vfloat_Range (J); -- Note: The conversion to Integer is safe, as Integers are required -- to include the range -2 ** 15 + 1 .. 2 ** 15 + 1 and therefore -- include the range of B (should be 0 .. 255). D.Values (K) := C_float (VA.Values (J)) / (2.0 ** Integer (B)); end loop; return To_Vector (D); end vcfux; ----------- -- vcfsx -- ----------- function vcfsx (A : LL_VSI; B : c_int) return LL_VF is VA : constant VSI_View := To_View (A); D : VF_View; K : Vfloat_Range; begin for J in Varray_signed_int'Range loop K := Vfloat_Range (J); D.Values (K) := C_float (VA.Values (J)) / (2.0 ** Integer (B)); end loop; return To_Vector (D); end vcfsx; ------------ -- vctsxs -- ------------ function vctsxs (A : LL_VF; B : c_int) return LL_VSI is VA : constant VF_View := To_View (A); D : VSI_View; K : Vfloat_Range; begin for J in Varray_signed_int'Range loop K := Vfloat_Range (J); D.Values (J) := LL_VSI_Operations.Saturate (F64 (NJ_Truncate (VA.Values (K))) * F64 (2.0 ** Integer (B))); end loop; return To_Vector (D); end vctsxs; ------------ -- vctuxs -- ------------ function vctuxs (A : LL_VF; B : c_int) return LL_VUI is VA : constant VF_View := To_View (A); D : VUI_View; K : Vfloat_Range; begin for J in Varray_unsigned_int'Range loop K := Vfloat_Range (J); D.Values (J) := LL_VUI_Operations.Saturate (F64 (NJ_Truncate (VA.Values (K))) * F64 (2.0 ** Integer (B))); end loop; return To_Vector (D); end vctuxs; --------- -- dss -- --------- -- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]: procedure dss (A : c_int) is pragma Unreferenced (A); begin null; end dss; ------------ -- dssall -- ------------ -- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]: procedure dssall is begin null; end dssall; --------- -- dst -- --------- -- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]: procedure dst (A : c_ptr; B : c_int; C : c_int) is pragma Unreferenced (A); pragma Unreferenced (B); pragma Unreferenced (C); begin null; end dst; ----------- -- dstst -- ----------- -- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]: procedure dstst (A : c_ptr; B : c_int; C : c_int) is pragma Unreferenced (A); pragma Unreferenced (B); pragma Unreferenced (C); begin null; end dstst; ------------ -- dststt -- ------------ -- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]: procedure dststt (A : c_ptr; B : c_int; C : c_int) is pragma Unreferenced (A); pragma Unreferenced (B); pragma Unreferenced (C); begin null; end dststt; ---------- -- dstt -- ---------- -- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]: procedure dstt (A : c_ptr; B : c_int; C : c_int) is pragma Unreferenced (A); pragma Unreferenced (B); pragma Unreferenced (C); begin null; end dstt; -------------- -- vexptefp -- -------------- function vexptefp (A : LL_VF) return LL_VF is use C_float_Operations; VA : constant VF_View := To_View (A); D : VF_View; begin for J in Varray_float'Range loop -- ??? Check the precision of the operation. -- As described in [PEM-6 vexptefp]: -- If theoretical_result is equal to 2 at the power of A (J) with -- infinite precision, we should have: -- abs ((D (J) - theoretical_result) / theoretical_result) <= 1/16 D.Values (J) := 2.0 ** NJ_Truncate (VA.Values (J)); end loop; return To_Vector (D); end vexptefp; ----------- -- vrfim -- ----------- function vrfim (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Varray_float'Range loop -- If A (J) is infinite, D (J) should be infinite; With -- IEEE floating point, we can use 'Ceiling for that purpose. D.Values (J) := C_float'Ceiling (NJ_Truncate (VA.Values (J))); -- Vrfim rounds toward -Infinity, whereas 'Ceiling rounds toward -- +Infinity: if D.Values (J) /= VA.Values (J) then D.Values (J) := D.Values (J) - 1.0; end if; end loop; return To_Vector (D); end vrfim; --------- -- lvx -- --------- function lvx (A : c_long; B : c_ptr) return LL_VSI is -- Simulate the altivec unit behavior regarding what Effective Address -- is accessed, stripping off the input address least significant bits -- wrt to vector alignment. -- On targets where VECTOR_ALIGNMENT is less than the vector size (16), -- an address within a vector is not necessarily rounded back at the -- vector start address. Besides, rounding on 16 makes no sense on such -- targets because the address of a properly aligned vector (that is, -- a proper multiple of VECTOR_ALIGNMENT) could be affected, which we -- want never to happen. EA : constant System.Address := To_Address (Bound_Align (Integer_Address (A) + To_Integer (B), VECTOR_ALIGNMENT)); D : LL_VSI; for D'Address use EA; begin return D; end lvx; ----------- -- lvebx -- ----------- function lvebx (A : c_long; B : c_ptr) return LL_VSC is D : VSC_View; begin D.Values := LL_VSC_Operations.lvexx (A, B); return To_Vector (D); end lvebx; ----------- -- lvehx -- ----------- function lvehx (A : c_long; B : c_ptr) return LL_VSS is D : VSS_View; begin D.Values := LL_VSS_Operations.lvexx (A, B); return To_Vector (D); end lvehx; ----------- -- lvewx -- ----------- function lvewx (A : c_long; B : c_ptr) return LL_VSI is D : VSI_View; begin D.Values := LL_VSI_Operations.lvexx (A, B); return To_Vector (D); end lvewx; ---------- -- lvxl -- ---------- function lvxl (A : c_long; B : c_ptr) return LL_VSI renames lvx; ------------- -- vlogefp -- ------------- function vlogefp (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Varray_float'Range loop -- ??? Check the precision of the operation. -- As described in [PEM-6 vlogefp]: -- If theorical_result is equal to the log2 of A (J) with -- infinite precision, we should have: -- abs (D (J) - theorical_result) <= 1/32, -- unless abs(D(J) - 1) <= 1/8. D.Values (J) := C_float_Operations.Log (NJ_Truncate (VA.Values (J)), 2.0); end loop; return To_Vector (D); end vlogefp; ---------- -- lvsl -- ---------- function lvsl (A : c_long; B : c_ptr) return LL_VSC is type bit4_type is mod 16#F# + 1; for bit4_type'Alignment use 1; EA : Integer_Address; D : VUC_View; SH : bit4_type; begin EA := Integer_Address (A) + To_Integer (B); SH := bit4_type (EA mod 2 ** 4); for J in D.Values'Range loop D.Values (J) := unsigned_char (SH) + unsigned_char (J) - unsigned_char (D.Values'First); end loop; return To_LL_VSC (To_Vector (D)); end lvsl; ---------- -- lvsr -- ---------- function lvsr (A : c_long; B : c_ptr) return LL_VSC is type bit4_type is mod 16#F# + 1; for bit4_type'Alignment use 1; EA : Integer_Address; D : VUC_View; SH : bit4_type; begin EA := Integer_Address (A) + To_Integer (B); SH := bit4_type (EA mod 2 ** 4); for J in D.Values'Range loop D.Values (J) := (16#F# - unsigned_char (SH)) + unsigned_char (J); end loop; return To_LL_VSC (To_Vector (D)); end lvsr; ------------- -- vmaddfp -- ------------- function vmaddfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); VC : constant VF_View := To_View (C); D : VF_View; begin for J in Varray_float'Range loop D.Values (J) := Rnd_To_FP_Nearest (F64 (VA.Values (J)) * F64 (VB.Values (J)) + F64 (VC.Values (J))); end loop; return To_Vector (D); end vmaddfp; --------------- -- vmhaddshs -- --------------- function vmhaddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); VC : constant VSS_View := To_View (C); D : VSS_View; begin for J in Varray_signed_short'Range loop D.Values (J) := LL_VSS_Operations.Saturate ((SI64 (VA.Values (J)) * SI64 (VB.Values (J))) / SI64 (2 ** 15) + SI64 (VC.Values (J))); end loop; return To_Vector (D); end vmhaddshs; ------------ -- vmaxub -- ------------ function vmaxub (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vmaxux (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vmaxub; ------------ -- vmaxsb -- ------------ function vmaxsb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vmaxsx (VA.Values, VB.Values); return To_Vector (D); end vmaxsb; ------------ -- vmaxuh -- ------------ function vmaxuh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vmaxux (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vmaxuh; ------------ -- vmaxsh -- ------------ function vmaxsh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vmaxsx (VA.Values, VB.Values); return To_Vector (D); end vmaxsh; ------------ -- vmaxuw -- ------------ function vmaxuw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vmaxux (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vmaxuw; ------------ -- vmaxsw -- ------------ function vmaxsw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vmaxsx (VA.Values, VB.Values); return To_Vector (D); end vmaxsw; -------------- -- vmaxsxfp -- -------------- function vmaxfp (A : LL_VF; B : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VF_View; begin for J in Varray_float'Range loop D.Values (J) := (if VA.Values (J) > VB.Values (J) then VA.Values (J) else VB.Values (J)); end loop; return To_Vector (D); end vmaxfp; ------------ -- vmrghb -- ------------ function vmrghb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vmrghx (VA.Values, VB.Values); return To_Vector (D); end vmrghb; ------------ -- vmrghh -- ------------ function vmrghh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vmrghx (VA.Values, VB.Values); return To_Vector (D); end vmrghh; ------------ -- vmrghw -- ------------ function vmrghw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vmrghx (VA.Values, VB.Values); return To_Vector (D); end vmrghw; ------------ -- vmrglb -- ------------ function vmrglb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vmrglx (VA.Values, VB.Values); return To_Vector (D); end vmrglb; ------------ -- vmrglh -- ------------ function vmrglh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vmrglx (VA.Values, VB.Values); return To_Vector (D); end vmrglh; ------------ -- vmrglw -- ------------ function vmrglw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vmrglx (VA.Values, VB.Values); return To_Vector (D); end vmrglw; ------------ -- mfvscr -- ------------ function mfvscr return LL_VSS is D : VUS_View; begin for J in Varray_unsigned_short'Range loop D.Values (J) := 0; end loop; D.Values (Varray_unsigned_short'Last) := unsigned_short (VSCR mod 2 ** unsigned_short'Size); D.Values (Varray_unsigned_short'Last - 1) := unsigned_short (VSCR / 2 ** unsigned_short'Size); return To_LL_VSS (To_Vector (D)); end mfvscr; ------------ -- vminfp -- ------------ function vminfp (A : LL_VF; B : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VF_View; begin for J in Varray_float'Range loop D.Values (J) := (if VA.Values (J) < VB.Values (J) then VA.Values (J) else VB.Values (J)); end loop; return To_Vector (D); end vminfp; ------------ -- vminsb -- ------------ function vminsb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vminsx (VA.Values, VB.Values); return To_Vector (D); end vminsb; ------------ -- vminub -- ------------ function vminub (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vminux (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vminub; ------------ -- vminsh -- ------------ function vminsh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vminsx (VA.Values, VB.Values); return To_Vector (D); end vminsh; ------------ -- vminuh -- ------------ function vminuh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vminux (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vminuh; ------------ -- vminsw -- ------------ function vminsw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vminsx (VA.Values, VB.Values); return To_Vector (D); end vminsw; ------------ -- vminuw -- ------------ function vminuw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vminux (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vminuw; --------------- -- vmladduhm -- --------------- function vmladduhm (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); VC : constant VUS_View := To_View (To_LL_VUS (C)); D : VUS_View; begin for J in Varray_unsigned_short'Range loop D.Values (J) := VA.Values (J) * VB.Values (J) + VC.Values (J); end loop; return To_LL_VSS (To_Vector (D)); end vmladduhm; ---------------- -- vmhraddshs -- ---------------- function vmhraddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); VC : constant VSS_View := To_View (C); D : VSS_View; begin for J in Varray_signed_short'Range loop D.Values (J) := LL_VSS_Operations.Saturate (((SI64 (VA.Values (J)) * SI64 (VB.Values (J)) + 2 ** 14) / 2 ** 15 + SI64 (VC.Values (J)))); end loop; return To_Vector (D); end vmhraddshs; -------------- -- vmsumubm -- -------------- function vmsumubm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI is Offset : Vchar_Range; VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); VC : constant VUI_View := To_View (To_LL_VUI (C)); D : VUI_View; begin for J in 0 .. 3 loop Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First)); D.Values (Vint_Range (J + Integer (Vint_Range'First))) := (unsigned_int (VA.Values (Offset)) * unsigned_int (VB.Values (Offset))) + (unsigned_int (VA.Values (Offset + 1)) * unsigned_int (VB.Values (1 + Offset))) + (unsigned_int (VA.Values (2 + Offset)) * unsigned_int (VB.Values (2 + Offset))) + (unsigned_int (VA.Values (3 + Offset)) * unsigned_int (VB.Values (3 + Offset))) + VC.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))); end loop; return To_LL_VSI (To_Vector (D)); end vmsumubm; -------------- -- vmsumumbm -- -------------- function vmsummbm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI is Offset : Vchar_Range; VA : constant VSC_View := To_View (A); VB : constant VUC_View := To_View (To_LL_VUC (B)); VC : constant VSI_View := To_View (C); D : VSI_View; begin for J in 0 .. 3 loop Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First)); D.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))) := 0 + LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset)) * SI64 (VB.Values (Offset))) + LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset + 1)) * SI64 (VB.Values (1 + Offset))) + LL_VSI_Operations.Modular_Result (SI64 (VA.Values (2 + Offset)) * SI64 (VB.Values (2 + Offset))) + LL_VSI_Operations.Modular_Result (SI64 (VA.Values (3 + Offset)) * SI64 (VB.Values (3 + Offset))) + VC.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))); end loop; return To_Vector (D); end vmsummbm; -------------- -- vmsumuhm -- -------------- function vmsumuhm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is Offset : Vshort_Range; VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); VC : constant VUI_View := To_View (To_LL_VUI (C)); D : VUI_View; begin for J in 0 .. 3 loop Offset := Vshort_Range (2 * J + Integer (Vshort_Range'First)); D.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))) := (unsigned_int (VA.Values (Offset)) * unsigned_int (VB.Values (Offset))) + (unsigned_int (VA.Values (Offset + 1)) * unsigned_int (VB.Values (1 + Offset))) + VC.Values (Vint_Range (J + Integer (Vint_Range'First))); end loop; return To_LL_VSI (To_Vector (D)); end vmsumuhm; -------------- -- vmsumshm -- -------------- function vmsumshm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); VC : constant VSI_View := To_View (C); Offset : Vshort_Range; D : VSI_View; begin for J in 0 .. 3 loop Offset := Vshort_Range (2 * J + Integer (Varray_signed_char'First)); D.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))) := 0 + LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset)) * SI64 (VB.Values (Offset))) + LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset + 1)) * SI64 (VB.Values (1 + Offset))) + VC.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))); end loop; return To_Vector (D); end vmsumshm; -------------- -- vmsumuhs -- -------------- function vmsumuhs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is Offset : Vshort_Range; VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); VC : constant VUI_View := To_View (To_LL_VUI (C)); D : VUI_View; begin for J in 0 .. 3 loop Offset := Vshort_Range (2 * J + Integer (Varray_signed_short'First)); D.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))) := LL_VUI_Operations.Saturate (UI64 (VA.Values (Offset)) * UI64 (VB.Values (Offset)) + UI64 (VA.Values (Offset + 1)) * UI64 (VB.Values (1 + Offset)) + UI64 (VC.Values (Vint_Range (J + Integer (Varray_unsigned_int'First))))); end loop; return To_LL_VSI (To_Vector (D)); end vmsumuhs; -------------- -- vmsumshs -- -------------- function vmsumshs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); VC : constant VSI_View := To_View (C); Offset : Vshort_Range; D : VSI_View; begin for J in 0 .. 3 loop Offset := Vshort_Range (2 * J + Integer (Varray_signed_short'First)); D.Values (Vint_Range (J + Integer (Varray_signed_int'First))) := LL_VSI_Operations.Saturate (SI64 (VA.Values (Offset)) * SI64 (VB.Values (Offset)) + SI64 (VA.Values (Offset + 1)) * SI64 (VB.Values (1 + Offset)) + SI64 (VC.Values (Vint_Range (J + Integer (Varray_signed_int'First))))); end loop; return To_Vector (D); end vmsumshs; ------------ -- mtvscr -- ------------ procedure mtvscr (A : LL_VSI) is VA : constant VUI_View := To_View (To_LL_VUI (A)); begin VSCR := VA.Values (Varray_unsigned_int'Last); end mtvscr; ------------- -- vmuleub -- ------------- function vmuleub (A : LL_VSC; B : LL_VSC) return LL_VSS is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUS_View; begin D.Values := LL_VUC_LL_VUS_Operations.vmulxux (True, VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vmuleub; ------------- -- vmuleuh -- ------------- function vmuleuh (A : LL_VSS; B : LL_VSS) return LL_VSI is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUI_View; begin D.Values := LL_VUS_LL_VUI_Operations.vmulxux (True, VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vmuleuh; ------------- -- vmulesb -- ------------- function vmulesb (A : LL_VSC; B : LL_VSC) return LL_VSS is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSS_View; begin D.Values := LL_VSC_LL_VSS_Operations.vmulxsx (True, VA.Values, VB.Values); return To_Vector (D); end vmulesb; ------------- -- vmulesh -- ------------- function vmulesh (A : LL_VSS; B : LL_VSS) return LL_VSI is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSI_View; begin D.Values := LL_VSS_LL_VSI_Operations.vmulxsx (True, VA.Values, VB.Values); return To_Vector (D); end vmulesh; ------------- -- vmuloub -- ------------- function vmuloub (A : LL_VSC; B : LL_VSC) return LL_VSS is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUS_View; begin D.Values := LL_VUC_LL_VUS_Operations.vmulxux (False, VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vmuloub; ------------- -- vmulouh -- ------------- function vmulouh (A : LL_VSS; B : LL_VSS) return LL_VSI is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUI_View; begin D.Values := LL_VUS_LL_VUI_Operations.vmulxux (False, VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vmulouh; ------------- -- vmulosb -- ------------- function vmulosb (A : LL_VSC; B : LL_VSC) return LL_VSS is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSS_View; begin D.Values := LL_VSC_LL_VSS_Operations.vmulxsx (False, VA.Values, VB.Values); return To_Vector (D); end vmulosb; ------------- -- vmulosh -- ------------- function vmulosh (A : LL_VSS; B : LL_VSS) return LL_VSI is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSI_View; begin D.Values := LL_VSS_LL_VSI_Operations.vmulxsx (False, VA.Values, VB.Values); return To_Vector (D); end vmulosh; -------------- -- vnmsubfp -- -------------- function vnmsubfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); VC : constant VF_View := To_View (C); D : VF_View; begin for J in Vfloat_Range'Range loop D.Values (J) := -Rnd_To_FP_Nearest (F64 (VA.Values (J)) * F64 (VB.Values (J)) - F64 (VC.Values (J))); end loop; return To_Vector (D); end vnmsubfp; ---------- -- vnor -- ---------- function vnor (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin for J in Vint_Range'Range loop D.Values (J) := not (VA.Values (J) or VB.Values (J)); end loop; return To_LL_VSI (To_Vector (D)); end vnor; ---------- -- vor -- ---------- function vor (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin for J in Vint_Range'Range loop D.Values (J) := VA.Values (J) or VB.Values (J); end loop; return To_LL_VSI (To_Vector (D)); end vor; ------------- -- vpkuhum -- ------------- function vpkuhum (A : LL_VSS; B : LL_VSS) return LL_VSC is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUC_View; begin D.Values := LL_VUC_LL_VUS_Operations.vpkuxum (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vpkuhum; ------------- -- vpkuwum -- ------------- function vpkuwum (A : LL_VSI; B : LL_VSI) return LL_VSS is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUS_View; begin D.Values := LL_VUS_LL_VUI_Operations.vpkuxum (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vpkuwum; ----------- -- vpkpx -- ----------- function vpkpx (A : LL_VSI; B : LL_VSI) return LL_VSS is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUS_View; Offset : Vint_Range; P16 : Pixel_16; P32 : Pixel_32; begin for J in 0 .. 3 loop Offset := Vint_Range (J + Integer (Vshort_Range'First)); P32 := To_Pixel (VA.Values (Offset)); P16.T := Unsigned_1 (P32.T mod 2 ** 1); P16.R := Unsigned_5 (Shift_Right (P32.R, 3) mod 2 ** 5); P16.G := Unsigned_5 (Shift_Right (P32.G, 3) mod 2 ** 5); P16.B := Unsigned_5 (Shift_Right (P32.B, 3) mod 2 ** 5); D.Values (Vshort_Range (Offset)) := To_unsigned_short (P16); P32 := To_Pixel (VB.Values (Offset)); P16.T := Unsigned_1 (P32.T mod 2 ** 1); P16.R := Unsigned_5 (Shift_Right (P32.R, 3) mod 2 ** 5); P16.G := Unsigned_5 (Shift_Right (P32.G, 3) mod 2 ** 5); P16.B := Unsigned_5 (Shift_Right (P32.B, 3) mod 2 ** 5); D.Values (Vshort_Range (Offset) + 4) := To_unsigned_short (P16); end loop; return To_LL_VSS (To_Vector (D)); end vpkpx; ------------- -- vpkuhus -- ------------- function vpkuhus (A : LL_VSS; B : LL_VSS) return LL_VSC is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUC_View; begin D.Values := LL_VUC_LL_VUS_Operations.vpkuxus (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vpkuhus; ------------- -- vpkuwus -- ------------- function vpkuwus (A : LL_VSI; B : LL_VSI) return LL_VSS is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUS_View; begin D.Values := LL_VUS_LL_VUI_Operations.vpkuxus (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vpkuwus; ------------- -- vpkshss -- ------------- function vpkshss (A : LL_VSS; B : LL_VSS) return LL_VSC is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_LL_VSS_Operations.vpksxss (VA.Values, VB.Values); return To_Vector (D); end vpkshss; ------------- -- vpkswss -- ------------- function vpkswss (A : LL_VSI; B : LL_VSI) return LL_VSS is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_LL_VSI_Operations.vpksxss (VA.Values, VB.Values); return To_Vector (D); end vpkswss; ------------- -- vpksxus -- ------------- generic type Signed_Component_Type is range <>; type Signed_Index_Type is range <>; type Signed_Varray_Type is array (Signed_Index_Type) of Signed_Component_Type; type Unsigned_Component_Type is mod <>; type Unsigned_Index_Type is range <>; type Unsigned_Varray_Type is array (Unsigned_Index_Type) of Unsigned_Component_Type; function vpksxus (A : Signed_Varray_Type; B : Signed_Varray_Type) return Unsigned_Varray_Type; function vpksxus (A : Signed_Varray_Type; B : Signed_Varray_Type) return Unsigned_Varray_Type is N : constant Unsigned_Index_Type := Unsigned_Index_Type (Signed_Index_Type'Last); Offset : Unsigned_Index_Type; Signed_Offset : Signed_Index_Type; D : Unsigned_Varray_Type; function Saturate (X : Signed_Component_Type) return Unsigned_Component_Type; -- Saturation, as defined in -- [PIM-4.1 Vector Status and Control Register] -------------- -- Saturate -- -------------- function Saturate (X : Signed_Component_Type) return Unsigned_Component_Type is D : Unsigned_Component_Type; begin D := Unsigned_Component_Type (Signed_Component_Type'Max (Signed_Component_Type (Unsigned_Component_Type'First), Signed_Component_Type'Min (Signed_Component_Type (Unsigned_Component_Type'Last), X))); if Signed_Component_Type (D) /= X then VSCR := Write_Bit (VSCR, SAT_POS, 1); end if; return D; end Saturate; -- Start of processing for vpksxus begin for J in 0 .. N - 1 loop Offset := Unsigned_Index_Type (Integer (J) + Integer (Unsigned_Index_Type'First)); Signed_Offset := Signed_Index_Type (Integer (J) + Integer (Signed_Index_Type'First)); D (Offset) := Saturate (A (Signed_Offset)); D (Offset + N) := Saturate (B (Signed_Offset)); end loop; return D; end vpksxus; ------------- -- vpkshus -- ------------- function vpkshus (A : LL_VSS; B : LL_VSS) return LL_VSC is function vpkshus_Instance is new vpksxus (signed_short, Vshort_Range, Varray_signed_short, unsigned_char, Vchar_Range, Varray_unsigned_char); VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VUC_View; begin D.Values := vpkshus_Instance (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vpkshus; ------------- -- vpkswus -- ------------- function vpkswus (A : LL_VSI; B : LL_VSI) return LL_VSS is function vpkswus_Instance is new vpksxus (signed_int, Vint_Range, Varray_signed_int, unsigned_short, Vshort_Range, Varray_unsigned_short); VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VUS_View; begin D.Values := vpkswus_Instance (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vpkswus; --------------- -- vperm_4si -- --------------- function vperm_4si (A : LL_VSI; B : LL_VSI; C : LL_VSC) return LL_VSI is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); VC : constant VUC_View := To_View (To_LL_VUC (C)); J : Vchar_Range; D : VUC_View; begin for N in Vchar_Range'Range loop J := Vchar_Range (Integer (Bits (VC.Values (N), 4, 7)) + Integer (Vchar_Range'First)); D.Values (N) := (if Bits (VC.Values (N), 3, 3) = 0 then VA.Values (J) else VB.Values (J)); end loop; return To_LL_VSI (To_Vector (D)); end vperm_4si; ----------- -- vrefp -- ----------- function vrefp (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Vfloat_Range'Range loop D.Values (J) := FP_Recip_Est (VA.Values (J)); end loop; return To_Vector (D); end vrefp; ---------- -- vrlb -- ---------- function vrlb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vrlx (VA.Values, VB.Values, ROTL'Access); return To_LL_VSC (To_Vector (D)); end vrlb; ---------- -- vrlh -- ---------- function vrlh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vrlx (VA.Values, VB.Values, ROTL'Access); return To_LL_VSS (To_Vector (D)); end vrlh; ---------- -- vrlw -- ---------- function vrlw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vrlx (VA.Values, VB.Values, ROTL'Access); return To_LL_VSI (To_Vector (D)); end vrlw; ----------- -- vrfin -- ----------- function vrfin (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Vfloat_Range'Range loop D.Values (J) := C_float (Rnd_To_FPI_Near (F64 (VA.Values (J)))); end loop; return To_Vector (D); end vrfin; --------------- -- vrsqrtefp -- --------------- function vrsqrtefp (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Vfloat_Range'Range loop D.Values (J) := Recip_SQRT_Est (VA.Values (J)); end loop; return To_Vector (D); end vrsqrtefp; -------------- -- vsel_4si -- -------------- function vsel_4si (A : LL_VSI; B : LL_VSI; C : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); VC : constant VUI_View := To_View (To_LL_VUI (C)); D : VUI_View; begin for J in Vint_Range'Range loop D.Values (J) := ((not VC.Values (J)) and VA.Values (J)) or (VC.Values (J) and VB.Values (J)); end loop; return To_LL_VSI (To_Vector (D)); end vsel_4si; ---------- -- vslb -- ---------- function vslb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vsxx (VA.Values, VB.Values, Shift_Left'Access); return To_LL_VSC (To_Vector (D)); end vslb; ---------- -- vslh -- ---------- function vslh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vsxx (VA.Values, VB.Values, Shift_Left'Access); return To_LL_VSS (To_Vector (D)); end vslh; ---------- -- vslw -- ---------- function vslw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vsxx (VA.Values, VB.Values, Shift_Left'Access); return To_LL_VSI (To_Vector (D)); end vslw; ---------------- -- vsldoi_4si -- ---------------- function vsldoi_4si (A : LL_VSI; B : LL_VSI; C : c_int) return LL_VSI is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); Offset : c_int; Bound : c_int; D : VUC_View; begin for J in Vchar_Range'Range loop Offset := c_int (J) + C; Bound := c_int (Vchar_Range'First) + c_int (Varray_unsigned_char'Length); if Offset < Bound then D.Values (J) := VA.Values (Vchar_Range (Offset)); else D.Values (J) := VB.Values (Vchar_Range (Offset - Bound + c_int (Vchar_Range'First))); end if; end loop; return To_LL_VSI (To_Vector (D)); end vsldoi_4si; ---------------- -- vsldoi_8hi -- ---------------- function vsldoi_8hi (A : LL_VSS; B : LL_VSS; C : c_int) return LL_VSS is begin return To_LL_VSS (vsldoi_4si (To_LL_VSI (A), To_LL_VSI (B), C)); end vsldoi_8hi; ----------------- -- vsldoi_16qi -- ----------------- function vsldoi_16qi (A : LL_VSC; B : LL_VSC; C : c_int) return LL_VSC is begin return To_LL_VSC (vsldoi_4si (To_LL_VSI (A), To_LL_VSI (B), C)); end vsldoi_16qi; ---------------- -- vsldoi_4sf -- ---------------- function vsldoi_4sf (A : LL_VF; B : LL_VF; C : c_int) return LL_VF is begin return To_LL_VF (vsldoi_4si (To_LL_VSI (A), To_LL_VSI (B), C)); end vsldoi_4sf; --------- -- vsl -- --------- function vsl (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; M : constant Natural := Natural (Bits (VB.Values (Vint_Range'Last), 29, 31)); -- [PIM-4.4 vec_sll] "Note that the three low-order byte elements in B -- must be the same. Otherwise the value placed into D is undefined." -- ??? Shall we add a optional check for B? begin for J in Vint_Range'Range loop D.Values (J) := 0; D.Values (J) := D.Values (J) + Shift_Left (VA.Values (J), M); if J /= Vint_Range'Last then D.Values (J) := D.Values (J) + Shift_Right (VA.Values (J + 1), signed_int'Size - M); end if; end loop; return To_LL_VSI (To_Vector (D)); end vsl; ---------- -- vslo -- ---------- function vslo (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; M : constant Natural := Natural (Bits (VB.Values (Vchar_Range'Last), 1, 4)); J : Natural; begin for N in Vchar_Range'Range loop J := Natural (N) + M; D.Values (N) := (if J <= Natural (Vchar_Range'Last) then VA.Values (Vchar_Range (J)) else 0); end loop; return To_LL_VSI (To_Vector (D)); end vslo; ------------ -- vspltb -- ------------ function vspltb (A : LL_VSC; B : c_int) return LL_VSC is VA : constant VSC_View := To_View (A); D : VSC_View; begin D.Values := LL_VSC_Operations.vspltx (VA.Values, B); return To_Vector (D); end vspltb; ------------ -- vsplth -- ------------ function vsplth (A : LL_VSS; B : c_int) return LL_VSS is VA : constant VSS_View := To_View (A); D : VSS_View; begin D.Values := LL_VSS_Operations.vspltx (VA.Values, B); return To_Vector (D); end vsplth; ------------ -- vspltw -- ------------ function vspltw (A : LL_VSI; B : c_int) return LL_VSI is VA : constant VSI_View := To_View (A); D : VSI_View; begin D.Values := LL_VSI_Operations.vspltx (VA.Values, B); return To_Vector (D); end vspltw; -------------- -- vspltisb -- -------------- function vspltisb (A : c_int) return LL_VSC is D : VSC_View; begin D.Values := LL_VSC_Operations.vspltisx (A); return To_Vector (D); end vspltisb; -------------- -- vspltish -- -------------- function vspltish (A : c_int) return LL_VSS is D : VSS_View; begin D.Values := LL_VSS_Operations.vspltisx (A); return To_Vector (D); end vspltish; -------------- -- vspltisw -- -------------- function vspltisw (A : c_int) return LL_VSI is D : VSI_View; begin D.Values := LL_VSI_Operations.vspltisx (A); return To_Vector (D); end vspltisw; ---------- -- vsrb -- ---------- function vsrb (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vsxx (VA.Values, VB.Values, Shift_Right'Access); return To_LL_VSC (To_Vector (D)); end vsrb; ---------- -- vsrh -- ---------- function vsrh (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vsxx (VA.Values, VB.Values, Shift_Right'Access); return To_LL_VSS (To_Vector (D)); end vsrh; ---------- -- vsrw -- ---------- function vsrw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vsxx (VA.Values, VB.Values, Shift_Right'Access); return To_LL_VSI (To_Vector (D)); end vsrw; ----------- -- vsrab -- ----------- function vsrab (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vsrax (VA.Values, VB.Values, Shift_Right_A'Access); return To_Vector (D); end vsrab; ----------- -- vsrah -- ----------- function vsrah (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vsrax (VA.Values, VB.Values, Shift_Right_A'Access); return To_Vector (D); end vsrah; ----------- -- vsraw -- ----------- function vsraw (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vsrax (VA.Values, VB.Values, Shift_Right_A'Access); return To_Vector (D); end vsraw; --------- -- vsr -- --------- function vsr (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); M : constant Natural := Natural (Bits (VB.Values (Vint_Range'Last), 29, 31)); D : VUI_View; begin for J in Vint_Range'Range loop D.Values (J) := 0; D.Values (J) := D.Values (J) + Shift_Right (VA.Values (J), M); if J /= Vint_Range'First then D.Values (J) := D.Values (J) + Shift_Left (VA.Values (J - 1), signed_int'Size - M); end if; end loop; return To_LL_VSI (To_Vector (D)); end vsr; ---------- -- vsro -- ---------- function vsro (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); M : constant Natural := Natural (Bits (VB.Values (Vchar_Range'Last), 1, 4)); J : Natural; D : VUC_View; begin for N in Vchar_Range'Range loop J := Natural (N) - M; if J >= Natural (Vchar_Range'First) then D.Values (N) := VA.Values (Vchar_Range (J)); else D.Values (N) := 0; end if; end loop; return To_LL_VSI (To_Vector (D)); end vsro; ---------- -- stvx -- ---------- procedure stvx (A : LL_VSI; B : c_int; C : c_ptr) is -- Simulate the altivec unit behavior regarding what Effective Address -- is accessed, stripping off the input address least significant bits -- wrt to vector alignment (see comment in lvx for further details). EA : constant System.Address := To_Address (Bound_Align (Integer_Address (B) + To_Integer (C), VECTOR_ALIGNMENT)); D : LL_VSI; for D'Address use EA; begin D := A; end stvx; ------------ -- stvewx -- ------------ procedure stvebx (A : LL_VSC; B : c_int; C : c_ptr) is VA : constant VSC_View := To_View (A); begin LL_VSC_Operations.stvexx (VA.Values, B, C); end stvebx; ------------ -- stvehx -- ------------ procedure stvehx (A : LL_VSS; B : c_int; C : c_ptr) is VA : constant VSS_View := To_View (A); begin LL_VSS_Operations.stvexx (VA.Values, B, C); end stvehx; ------------ -- stvewx -- ------------ procedure stvewx (A : LL_VSI; B : c_int; C : c_ptr) is VA : constant VSI_View := To_View (A); begin LL_VSI_Operations.stvexx (VA.Values, B, C); end stvewx; ----------- -- stvxl -- ----------- procedure stvxl (A : LL_VSI; B : c_int; C : c_ptr) renames stvx; ------------- -- vsububm -- ------------- function vsububm (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vsubuxm (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vsububm; ------------- -- vsubuhm -- ------------- function vsubuhm (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vsubuxm (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vsubuhm; ------------- -- vsubuwm -- ------------- function vsubuwm (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vsubuxm (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vsubuwm; ------------ -- vsubfp -- ------------ function vsubfp (A : LL_VF; B : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); VB : constant VF_View := To_View (B); D : VF_View; begin for J in Vfloat_Range'Range loop D.Values (J) := NJ_Truncate (NJ_Truncate (VA.Values (J)) - NJ_Truncate (VB.Values (J))); end loop; return To_Vector (D); end vsubfp; ------------- -- vsubcuw -- ------------- function vsubcuw (A : LL_VSI; B : LL_VSI) return LL_VSI is Subst_Result : SI64; VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin for J in Vint_Range'Range loop Subst_Result := SI64 (VA.Values (J)) - SI64 (VB.Values (J)); D.Values (J) := (if Subst_Result < SI64 (unsigned_int'First) then 0 else 1); end loop; return To_LL_VSI (To_Vector (D)); end vsubcuw; ------------- -- vsububs -- ------------- function vsububs (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUC_View := To_View (To_LL_VUC (B)); D : VUC_View; begin D.Values := LL_VUC_Operations.vsubuxs (VA.Values, VB.Values); return To_LL_VSC (To_Vector (D)); end vsububs; ------------- -- vsubsbs -- ------------- function vsubsbs (A : LL_VSC; B : LL_VSC) return LL_VSC is VA : constant VSC_View := To_View (A); VB : constant VSC_View := To_View (B); D : VSC_View; begin D.Values := LL_VSC_Operations.vsubsxs (VA.Values, VB.Values); return To_Vector (D); end vsubsbs; ------------- -- vsubuhs -- ------------- function vsubuhs (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VUS_View := To_View (To_LL_VUS (A)); VB : constant VUS_View := To_View (To_LL_VUS (B)); D : VUS_View; begin D.Values := LL_VUS_Operations.vsubuxs (VA.Values, VB.Values); return To_LL_VSS (To_Vector (D)); end vsubuhs; ------------- -- vsubshs -- ------------- function vsubshs (A : LL_VSS; B : LL_VSS) return LL_VSS is VA : constant VSS_View := To_View (A); VB : constant VSS_View := To_View (B); D : VSS_View; begin D.Values := LL_VSS_Operations.vsubsxs (VA.Values, VB.Values); return To_Vector (D); end vsubshs; ------------- -- vsubuws -- ------------- function vsubuws (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin D.Values := LL_VUI_Operations.vsubuxs (VA.Values, VB.Values); return To_LL_VSI (To_Vector (D)); end vsubuws; ------------- -- vsubsws -- ------------- function vsubsws (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; begin D.Values := LL_VSI_Operations.vsubsxs (VA.Values, VB.Values); return To_Vector (D); end vsubsws; -------------- -- vsum4ubs -- -------------- function vsum4ubs (A : LL_VSC; B : LL_VSI) return LL_VSI is VA : constant VUC_View := To_View (To_LL_VUC (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); Offset : Vchar_Range; D : VUI_View; begin for J in 0 .. 3 loop Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First)); D.Values (Vint_Range (J + Integer (Vint_Range'First))) := LL_VUI_Operations.Saturate (UI64 (VA.Values (Offset)) + UI64 (VA.Values (Offset + 1)) + UI64 (VA.Values (Offset + 2)) + UI64 (VA.Values (Offset + 3)) + UI64 (VB.Values (Vint_Range (J + Integer (Vint_Range'First))))); end loop; return To_LL_VSI (To_Vector (D)); end vsum4ubs; -------------- -- vsum4sbs -- -------------- function vsum4sbs (A : LL_VSC; B : LL_VSI) return LL_VSI is VA : constant VSC_View := To_View (A); VB : constant VSI_View := To_View (B); Offset : Vchar_Range; D : VSI_View; begin for J in 0 .. 3 loop Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First)); D.Values (Vint_Range (J + Integer (Vint_Range'First))) := LL_VSI_Operations.Saturate (SI64 (VA.Values (Offset)) + SI64 (VA.Values (Offset + 1)) + SI64 (VA.Values (Offset + 2)) + SI64 (VA.Values (Offset + 3)) + SI64 (VB.Values (Vint_Range (J + Integer (Vint_Range'First))))); end loop; return To_Vector (D); end vsum4sbs; -------------- -- vsum4shs -- -------------- function vsum4shs (A : LL_VSS; B : LL_VSI) return LL_VSI is VA : constant VSS_View := To_View (A); VB : constant VSI_View := To_View (B); Offset : Vshort_Range; D : VSI_View; begin for J in 0 .. 3 loop Offset := Vshort_Range (2 * J + Integer (Vchar_Range'First)); D.Values (Vint_Range (J + Integer (Vint_Range'First))) := LL_VSI_Operations.Saturate (SI64 (VA.Values (Offset)) + SI64 (VA.Values (Offset + 1)) + SI64 (VB.Values (Vint_Range (J + Integer (Vint_Range'First))))); end loop; return To_Vector (D); end vsum4shs; -------------- -- vsum2sws -- -------------- function vsum2sws (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); Offset : Vint_Range; D : VSI_View; begin for J in 0 .. 1 loop Offset := Vint_Range (2 * J + Integer (Vchar_Range'First)); D.Values (Offset) := 0; D.Values (Offset + 1) := LL_VSI_Operations.Saturate (SI64 (VA.Values (Offset)) + SI64 (VA.Values (Offset + 1)) + SI64 (VB.Values (Vint_Range (Offset + 1)))); end loop; return To_Vector (D); end vsum2sws; ------------- -- vsumsws -- ------------- function vsumsws (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VSI_View := To_View (A); VB : constant VSI_View := To_View (B); D : VSI_View; Sum_Buffer : SI64 := 0; begin for J in Vint_Range'Range loop D.Values (J) := 0; Sum_Buffer := Sum_Buffer + SI64 (VA.Values (J)); end loop; Sum_Buffer := Sum_Buffer + SI64 (VB.Values (Vint_Range'Last)); D.Values (Vint_Range'Last) := LL_VSI_Operations.Saturate (Sum_Buffer); return To_Vector (D); end vsumsws; ----------- -- vrfiz -- ----------- function vrfiz (A : LL_VF) return LL_VF is VA : constant VF_View := To_View (A); D : VF_View; begin for J in Vfloat_Range'Range loop D.Values (J) := C_float (Rnd_To_FPI_Trunc (F64 (VA.Values (J)))); end loop; return To_Vector (D); end vrfiz; ------------- -- vupkhsb -- ------------- function vupkhsb (A : LL_VSC) return LL_VSS is VA : constant VSC_View := To_View (A); D : VSS_View; begin D.Values := LL_VSC_LL_VSS_Operations.vupkxsx (VA.Values, 0); return To_Vector (D); end vupkhsb; ------------- -- vupkhsh -- ------------- function vupkhsh (A : LL_VSS) return LL_VSI is VA : constant VSS_View := To_View (A); D : VSI_View; begin D.Values := LL_VSS_LL_VSI_Operations.vupkxsx (VA.Values, 0); return To_Vector (D); end vupkhsh; ------------- -- vupkxpx -- ------------- function vupkxpx (A : LL_VSS; Offset : Natural) return LL_VSI; -- For vupkhpx and vupklpx (depending on Offset) function vupkxpx (A : LL_VSS; Offset : Natural) return LL_VSI is VA : constant VUS_View := To_View (To_LL_VUS (A)); K : Vshort_Range; D : VUI_View; P16 : Pixel_16; P32 : Pixel_32; function Sign_Extend (X : Unsigned_1) return unsigned_char; function Sign_Extend (X : Unsigned_1) return unsigned_char is begin if X = 1 then return 16#FF#; else return 16#00#; end if; end Sign_Extend; begin for J in Vint_Range'Range loop K := Vshort_Range (Integer (J) - Integer (Vint_Range'First) + Integer (Vshort_Range'First) + Offset); P16 := To_Pixel (VA.Values (K)); P32.T := Sign_Extend (P16.T); P32.R := unsigned_char (P16.R); P32.G := unsigned_char (P16.G); P32.B := unsigned_char (P16.B); D.Values (J) := To_unsigned_int (P32); end loop; return To_LL_VSI (To_Vector (D)); end vupkxpx; ------------- -- vupkhpx -- ------------- function vupkhpx (A : LL_VSS) return LL_VSI is begin return vupkxpx (A, 0); end vupkhpx; ------------- -- vupklsb -- ------------- function vupklsb (A : LL_VSC) return LL_VSS is VA : constant VSC_View := To_View (A); D : VSS_View; begin D.Values := LL_VSC_LL_VSS_Operations.vupkxsx (VA.Values, Varray_signed_short'Length); return To_Vector (D); end vupklsb; ------------- -- vupklsh -- ------------- function vupklsh (A : LL_VSS) return LL_VSI is VA : constant VSS_View := To_View (A); D : VSI_View; begin D.Values := LL_VSS_LL_VSI_Operations.vupkxsx (VA.Values, Varray_signed_int'Length); return To_Vector (D); end vupklsh; ------------- -- vupklpx -- ------------- function vupklpx (A : LL_VSS) return LL_VSI is begin return vupkxpx (A, Varray_signed_int'Length); end vupklpx; ---------- -- vxor -- ---------- function vxor (A : LL_VSI; B : LL_VSI) return LL_VSI is VA : constant VUI_View := To_View (To_LL_VUI (A)); VB : constant VUI_View := To_View (To_LL_VUI (B)); D : VUI_View; begin for J in Vint_Range'Range loop D.Values (J) := VA.Values (J) xor VB.Values (J); end loop; return To_LL_VSI (To_Vector (D)); end vxor; ---------------- -- vcmpequb_p -- ---------------- function vcmpequb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int is D : LL_VSC; begin D := vcmpequb (B, C); return LL_VSC_Operations.Check_CR6 (A, To_View (D).Values); end vcmpequb_p; ---------------- -- vcmpequh_p -- ---------------- function vcmpequh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int is D : LL_VSS; begin D := vcmpequh (B, C); return LL_VSS_Operations.Check_CR6 (A, To_View (D).Values); end vcmpequh_p; ---------------- -- vcmpequw_p -- ---------------- function vcmpequw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int is D : LL_VSI; begin D := vcmpequw (B, C); return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values); end vcmpequw_p; ---------------- -- vcmpeqfp_p -- ---------------- function vcmpeqfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is D : LL_VSI; begin D := vcmpeqfp (B, C); return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values); end vcmpeqfp_p; ---------------- -- vcmpgtub_p -- ---------------- function vcmpgtub_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int is D : LL_VSC; begin D := vcmpgtub (B, C); return LL_VSC_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtub_p; ---------------- -- vcmpgtuh_p -- ---------------- function vcmpgtuh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int is D : LL_VSS; begin D := vcmpgtuh (B, C); return LL_VSS_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtuh_p; ---------------- -- vcmpgtuw_p -- ---------------- function vcmpgtuw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int is D : LL_VSI; begin D := vcmpgtuw (B, C); return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtuw_p; ---------------- -- vcmpgtsb_p -- ---------------- function vcmpgtsb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int is D : LL_VSC; begin D := vcmpgtsb (B, C); return LL_VSC_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtsb_p; ---------------- -- vcmpgtsh_p -- ---------------- function vcmpgtsh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int is D : LL_VSS; begin D := vcmpgtsh (B, C); return LL_VSS_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtsh_p; ---------------- -- vcmpgtsw_p -- ---------------- function vcmpgtsw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int is D : LL_VSI; begin D := vcmpgtsw (B, C); return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtsw_p; ---------------- -- vcmpgefp_p -- ---------------- function vcmpgefp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is D : LL_VSI; begin D := vcmpgefp (B, C); return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgefp_p; ---------------- -- vcmpgtfp_p -- ---------------- function vcmpgtfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is D : LL_VSI; begin D := vcmpgtfp (B, C); return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values); end vcmpgtfp_p; ---------------- -- vcmpbfp_p -- ---------------- function vcmpbfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is D : VSI_View; begin D := To_View (vcmpbfp (B, C)); for J in Vint_Range'Range loop -- vcmpbfp is not returning the usual bool vector; do the conversion D.Values (J) := (if D.Values (J) = 0 then Signed_Bool_False else Signed_Bool_True); end loop; return LL_VSI_Operations.Check_CR6 (A, D.Values); end vcmpbfp_p; end GNAT.Altivec.Low_Level_Vectors;
with Ada.Text_IO; package body Word_List is package IO renames Ada.Text_IO; use Word_Lists; use Pattern_Sets; function "<"(a, b: pattern) return Boolean is begin return String(a) < String(b); end "<"; function "="(a, b: pattern) return Boolean is begin return String(a) = String(b); end "="; function Make_Pattern(w : Word) return Pattern is p : Pattern := (others => ' '); seen : Array(1 .. 26) of Character; seen_max : Natural := 0; function Map_Letter(c : Character) return Character is begin for i in 1 .. seen_max loop if seen(i) = c then return Character'Val(Character'Pos('a') + i); end if; end loop; seen_max := seen_max + 1; seen(seen_max) := c; return Character'Val(Character'Pos('a') + seen_max); end Map_Letter; begin for i in w'Range loop exit when w(i) = ' '; p(i) := Map_Letter(w(i)); end loop; return p; end Make_Pattern; function Build_Word_List(filename : String; patterns : Pattern_Set) return Word_List is list : Word_List; input : IO.File_Type; w : Word; p : Pattern; last : Natural; c : Word_Lists.Cursor; inserted : Boolean; begin IO.Open(input, IO.In_File, filename); while not IO.End_Of_File(input) loop IO.Get_Line(input, w, last); if last = Word'Last then IO.Put_Line(w); raise Constraint_Error; end if; w(last + 1 .. Word'Last) := (others => ' '); p := Make_Pattern(w); if Pattern_Sets.Find(patterns, p) /= Pattern_Sets.No_Element then c := Word_Lists.Find(list, p); if c = Word_Lists.No_Element then Word_Lists.Insert(list, p, new Word_Vectors.Vector, c, inserted); end if; Word_Vectors.Append(Word_Lists.Element(c).all, w); end if; end loop; return list; end Build_Word_List; end Word_List;
-------------------------------------------------------------------- --| Package : Input_Line Version : -------------------------------------------------------------------- --| Abstract : This package handles everything concerning a user's input. --| The raw user input is converted into a command or a move. --| Command is one letter (from the list below). --| Move is four characters which specify two board positions, --| for example: B2E7 -------------------------------------------------------------------- --| Compiler/System : --| Author : John Dalbey Date : 1/93 --| References : -------------------------------------------------------------------- --| NOTES : --| : --| Version History : -------------------------------------------------------------------- PACKAGE Input_Line IS TYPE Command IS (load, save, hint, undo, help, quit); Legal_Commands : CONSTANT STRING(1..6) := "LSHU?Q"; Prompt : CONSTANT STRING(1..47) := "L)oad, S)ave, H)int, U)ndo, Q)uit, ?, or move: "; PROCEDURE Get; -- Purpose: A line of user's input (terminated by Enter) is read from keyboard. -- Assumes: At least one character must be typed. -- Exception: Constraint Error is raised if length > 80. FUNCTION IsCommand RETURN BOOLEAN; -- Purpose: Determine if the user's input was a legal command. -- Assumes: Get has been completed. -- Returns: TRUE if only a single character was entered and it's a legal command FUNCTION IsMove RETURN BOOLEAN; -- Purpose: Determine if the user's input was a move (2 board locations). -- E.g., D3H8 -- Assumes: Get has been completed. -- Returns: TRUE if user input is syntactically correct for a move. -- Returns FALSE if -- a) columns are not valid COL type -- b) rows are not valid ROW type -- c) length of user input /= 4 FUNCTION Get_Command RETURN Command; -- Purpose: Converts the user input into a value of command type. -- Assumes: Get has been completed, and Is_Command is TRUE. -- Returns: the command type value corresponding to user's input. FUNCTION Validate_Move RETURN BOOLEAN; -- Purpose: Determine if the users_input is really a valid move. I.e., the -- tiles are matching and removable. -- Assumes: Get has been completed, and Is_Move is true. -- Return: TRUE if it is a valid move. -- Otherwise, display appropriate error msg and return FALSE. -- Note: Valid move means -- 1) both locations really contain a tile -- 2) both tiles can match and can be removed -- 3) the tiles are in two different locations (they aren't -- the same tile). PROCEDURE Make_Move; -- Purpose: Process the player's move, remove the tiles from the board. -- Take the two matching tiles off the board and update the screen -- Assumes: Validate_Move is TRUE. -- Returns: nothing. The Board and screen are updated. -- PSEUDOCODE: -- Reset hints. -- Remove the matching tiles from the board. -- display the updated board. -- Decrement tiles remaining. -- add tiles to move history. -- If no tiles left, display win message. PROCEDURE Undo_Move; -- Purpose: Undo the previous move -- Assumes: nothing. -- Returns: nothing. The most recent move is "undone" and the board -- and screen restored to their previous state. -- Note: Undo can be invoked multiple times, backing up until the -- board is in it's original state. END Input_Line;
-- { dg-do run } with Derived_Type3_Pkg; use Derived_Type3_Pkg; procedure Derived_Type3 is begin Proc1; Proc2; end;
-- { dg-do compile } -- { dg-options "-fdump-tree-gimple" } with Atomic6_Pkg; use Atomic6_Pkg; procedure Atomic6_4 is procedure P (I1 : out Integer; I2 : in Integer) is begin I1 := I2; end; Temp : Integer; begin P (Integer(Counter1), Integer(Counter2)); P (Timer1, Timer2); P (Integer(Counter1), Timer1); P (Timer1, Integer(Counter1)); P (Temp, Integer(Counter1)); P (Integer(Counter1), Temp); P (Temp, Timer1); P (Timer1, Temp); end; -- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter1" 2 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter2" 1 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer1" 2 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer2" 1 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&temp" 0 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*ptr" 0 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter1" 3 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter2" 0 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer1" 3 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer2" 0 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&temp" 0 "gimple"} } -- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*ptr" 0 "gimple"} }
with Engines, Ada.Strings.Fixed; package body GUIs is use Ada.Strings; use type Console.Y_Pos; Log_X : constant := Bar_Width + 2; Message_Height : constant := Panel_Height - 1; procedure render_bar(self : in out GUI; x : Console.X_Pos; y : Console.Y_Pos; w : Width; name : String; value, max_value : Float; bar_color, bg_color : RGB_Color) is bar_w : Width := Width(Float'Rounding(value / max_value * Float(w))); begin self.screen.set_default_bg(bg_color); self.screen.rect(x, y, w, h => 1); if bar_w > 0 then self.screen.set_default_bg(bar_color); self.screen.rect(x, y, bar_w, h => 1); end if; self.screen.set_default_fg(Color.white); self.screen.print(x, y, name & " :" & Integer(value)'Image & " /" & Integer(max_value)'Image); end render_bar; function make_GUI(screen_w : Width) return GUI is begin return self : GUI := (screen => Console.make_screen(screen_w, Panel_Height), log => <>); end make_GUI; procedure render(self : in out GUI; main_screen : in out Console.Screen; engine : in out Engines.Engine) is y : Console.Y_Pos := 1; begin self.screen.set_default_bg(Color.black); self.screen.clear; self.render_bar(1, 1, Bar_Width, "HP", Float(engine.player.destructible.hp), Float(engine.player.destructible.max_hp), bar_color => Color.light_red, bg_color => Color.dark_red); for message of self.log loop self.screen.set_default_fg(message.color); self.screen.print(Log_X, y, Log_Strings.To_String(message.text)); y := y + 1; end loop; self.screen.blit(0, 0, main_screen.get_width, Panel_Height, main_screen, 0, Console.Y_Pos(main_screen.get_height-Panel_Height)); end render; procedure log(self : in out GUI; text : String; color : RGB_Color := Libtcod.Color.light_grey) is curr_pos : Positive := text'First; newline_pos : Natural; begin loop if self.log.Length = Message_Height then self.log.Delete_First; end if; newline_pos := Fixed.Index(text, ASCII.LF & "", curr_pos); if newline_pos = 0 then self.log.Append((Log_Strings.To_Bounded_String(text(curr_pos .. text'Last), Drop => Right), color)); exit; end if; self.log.Append((Log_Strings.To_Bounded_String(text(curr_pos .. newline_pos - 1), Drop => Right), color)); curr_pos := newline_pos + 1; exit when curr_pos > text'Last; end loop; end log; end GUIs;
with System; use System; package body Deferred_Const3_Pkg is procedure Dummy is begin null; end; begin if C1'Address /= C'Address then raise Program_Error; end if; if C2'Address /= C'Address then raise Program_Error; end if; if C3'Address /= C'Address then raise Program_Error; end if; end Deferred_Const3_Pkg;
with AUnit.Test_Suites; with AUnit.Test_Fixtures; with AUnit.Test_Caller; package Tests is function Get_Suite return AUnit.Test_Suites.Access_Test_Suite; private type Null_Fixture is new AUnit.Test_Fixtures.Test_Fixture with null record; package Null_Caller is new AUnit.Test_Caller (Null_Fixture); Suite : aliased AUnit.Test_Suites.Test_Suite; end Tests;
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- 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 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 -- -- OWNER 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 Ada.Strings.Fixed; with Ada.Assertions; with Registrar.Source_Files; package body Specification_Scanner is ------------------- -- Parse_Toolkit -- ------------------- generic Buffer: in out Ada_Lexical_Parser.Source_Buffer; package Parse_Toolkit is use Ada_Lexical_Parser; Current_Element: Lexical_Element; Category: Lexical_Category renames Current_Element.Category; function Content return Wide_Wide_String is (WWU.To_Wide_Wide_String (Current_Element.Content)); procedure Next_Element; -- Advance to next element, skipping comments, and updating -- Current_Element function Current_Position return String; -- Return a string of format "Line:Col" procedure Assert_Syntax (Check: Boolean); -- Executes Ada.Assertions.Assert with the message : -- "Line:Col: Syntax Error. procedure Load_Identifier (Name: out WWU.Unbounded_Wide_Wide_String); procedure Skip_To_Semicolon; end Parse_Toolkit; -------------------------------------------------- package body Parse_Toolkit is procedure Next_Element is begin loop Current_Element := Next_Element (Buffer); exit when Category /= Comment; end loop; end Next_Element; function Current_Position return String is use Ada.Strings; use Ada.Strings.Fixed; Pos: constant Source_Position := Last_Position (Buffer); begin return Trim (Source => Positive'Image (Pos.Line), Side => Both) & ':' & Trim (Source => Positive'Image (Pos.Column), Side => Both); end Current_Position; procedure Assert_Syntax (Check: Boolean) is begin Ada.Assertions.Assert (Check => Check, Message => Current_Position & ": Syntax error"); end Assert_Syntax; procedure Load_Identifier (Name: out WWU.Unbounded_Wide_Wide_String) is use type WWU.Unbounded_Wide_Wide_String; -- Should be called when Current_Element is an Identifier begin Name := Current_Element.Content; -- Copy the Unbounded_Wide_Wide_String directly loop Next_Element; exit when Category not in Identifier | Delimiter; exit when Category = Delimiter and then Content /= "."; Name := Name & Current_Element.Content; end loop; end Load_Identifier; procedure Skip_To_Semicolon is begin Next_Element; while not (Category = Delimiter and then Content = ";") loop Next_Element; end loop; end Skip_To_Semicolon; end Parse_Toolkit; -- -- Process Subprograms -- procedure Scan_Subprogram (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree : in out Declaration_Trees.Tree; Subprogram_Node: in Declaration_Trees.Cursor); -- Scan_Subprogram shall be called immediately after encountering -- the reserved word "function or procedure". A new node for the -- subprogram declaration shall be provided by Subprogram_Node. -- -- Scan_Subprogram will set the name, add child declared entities -- for each parameter, the type of function returns, and the expression -- of expression functions procedure Scan_Object (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Entity : in out Declared_Entity); -- Shall be called immediately after an identifier followed by a ':' -- delimiter. Node.Name shall be set to the value of the identifier before -- calling. Scan_Value_Declaration will set Kind, Expression, Is_Constant, -- Is_Renamed, Is_Anon_Access, Subtype_Mark, and Renamed_Entity_Name as -- appropriate -- -- This procedure covers: -- * object_declaration -- * number_declaration -- * exception_declaration -- * renaming_declaration (for any of the above) procedure Scan_Generic (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree: in out Declaration_Trees.Tree; Root : in Declaration_Trees.Cursor); -- Shall be called immediate after encountering the reserved word "generic". -- Scan_Generic appends generic parameters to the subtree rooted at Root, -- and then dispatches to Scan_Specification or Scan_Subprogram as -- appropriate, passing Root to the Root/Subprogram_Node parameters. -- -- Is_Generic is set for Root procedure Scan_Specification (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree: in out Declaration_Trees.Tree; Root : in Declaration_Trees.Cursor); -- Shall be called immediately after encountering the reserved word -- package. Scan_Specifcation expects to find the completion of a -- "package_specification". The name of the package is used to set the Name -- property of the node designated by Root. All subsequent declarations are -- assigned as children to the subtree denoted by Root, including recursive -- descent into nested packages via recursive calls to Scan_Specification -- Body stubs ------------------------------------ procedure Scan_Subprogram (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree : in out Declaration_Trees.Tree; Subprogram_Node: in Declaration_Trees.Cursor) is separate; procedure Scan_Object (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Entity : in out Declared_Entity) is separate; procedure Scan_Generic (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree: in out Declaration_Trees.Tree; Root : in Declaration_Trees.Cursor) is separate; procedure Scan_Specification (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree: in out Declaration_Trees.Tree; Root : in Declaration_Trees.Cursor) is separate; ----------------------- -- Scan_Package_Spec -- ----------------------- procedure Scan_Package_Spec (Unit : in Registrar.Library_Units.Library_Unit; Unit_Tree: out Declaration_Trees.Tree) is use Registrar.Source_Files; use Ada_Lexical_Parser; Source: aliased Source_Stream := Checkout_Read_Stream (Unit.Spec_File); Buffer: Source_Buffer (Source'Access); package Toolkit is new Parse_Toolkit (Buffer); use Toolkit; Unit_Root: Declaration_Trees.Cursor; begin Unit_Tree := Declaration_Trees.Empty_Tree; Unit_Root := Unit_Tree.Root; Unit_Tree.Prepend_Child (Parent => Unit_Tree.Root, New_Item => Declared_Entity'(Kind => Package_Declaration, others => <>)); Unit_Root := Declaration_Trees.First_Child (Unit_Tree.Root); Next_Element; -- Scan up until package and then kick off Scan_Specification. Note this -- handles (ignores) private packages as well while not (Category = Reserved_Word and then Content = "package") loop if Category = Reserved_Word and then Content = "generic" then Unit_Tree(Unit_Root).Is_Generic := True; end if; Next_Element; end loop; -- Recursive decent starts Scan_Specification (Buffer => Buffer, Unit_Tree => Unit_Tree, Root => Unit_Root); end Scan_Package_Spec; end Specification_Scanner;
generic type Record_Type; package Incomplete5_Pkg is type Access_Type is access Record_Type; type Base_Object is tagged record Handle: Access_Type; end record; function Get_Handle(Object: Base_Object) return Access_Type; function From_Handle(Handle: Access_Type) return Base_Object; end Incomplete5_Pkg;
with gel.Window.setup, gel.Applet.gui_world, gel.Camera, gel.Mouse, gel.Sprite, gel.Events, gel.Forge, Physics, float_Math, lace.Response, lace.Event.utility, Ada.Calendar, Ada.Text_IO, Ada.Exceptions; pragma unreferenced (gel.Window.setup); procedure launch_mouse_Selection -- -- Places a sphere sprite in the world and registers an event repsonse to -- handle mouse clicks on the sprite. -- is use lace.Event.utility, ada.Text_IO; begin lace.Event.utility.use_text_Logger ("event.log"); lace.Event.utility.Logger.ignore (to_Kind (gel.Mouse.motion_Event'Tag)); declare use gel.Applet, ada.Calendar; the_Applet : constant gel.Applet.gui_world.view := gel.Forge.new_gui_Applet ("mouse Selection", space_Kind => physics.Bullet); the_Ball : constant gel.Sprite.view := gel.Forge.new_ball_Sprite (the_Applet.World (1), mass => 0.0); type retreat_Sprite is new lace.Response.item with record Sprite : gel.Sprite.view; end record; overriding procedure respond (Self : in out retreat_Sprite; to_Event : in lace.Event.Item'Class) is use float_Math; begin put_Line ("retreat_Sprite"); Self.Sprite.Site_is (self.Sprite.Site - the_Applet.gui_Camera.world_Rotation * (0.0, 0.0, 1.0)); end respond; retreat_Sprite_Response : aliased retreat_Sprite := (lace.Response.item with sprite => the_Ball); type advance_Sprite is new lace.Response.item with record Sprite : gel.Sprite.view; end record; overriding procedure respond (Self : in out advance_Sprite; to_Event : in lace.Event.Item'Class) is use float_Math; begin put_Line ("advance_Sprite"); Self.Sprite.Site_is (self.Sprite.Site + the_Applet.gui_Camera.world_Rotation * (0.0, 0.0, 1.0)); end respond; advance_Sprite_Response : aliased advance_Sprite := (lace.Response.Item with sprite => the_Ball); next_render_Time : ada.calendar.Time; begin the_Ball.add (advance_Sprite_Response'unchecked_access, to_Kind (gel.events.sprite_click_down_Event'Tag), the_Applet.Name); the_Ball.add (retreat_Sprite_Response'unchecked_access, to_Kind (gel.events.sprite_click_up_Event'Tag), the_Applet.Name); the_Applet.gui_world .add (the_Ball, and_Children => False); the_Applet.gui_Camera.Site_is ((0.0, 0.0, 5.0)); the_Applet.enable_simple_Dolly (in_World => 1); the_Applet.enable_Mouse (detect_Motion => False); next_render_Time := ada.calendar.Clock; while the_Applet.is_open loop the_Applet.gui_World.evolve (by => 1.0/60.0); the_Ball.respond; the_Applet.freshen; next_render_Time := next_render_Time + 1.0/60.0; delay until next_render_Time; end loop; the_Applet.destroy; end; lace.Event.utility.close; exception when E : others => lace.Event.utility.close; put_Line ("Exception detected in 'launch_mouse_Selection' ..."); put_Line (ada.Exceptions.Exception_Information (E)); end launch_mouse_Selection;
-- -- Jan & Uwe R. Zimmer, Australia, July 2011 -- with GLUT.Devices; package Keyboard is type Complete_Command_Set is ( -- Special Commands -- Move_Accelerator, Full_Screen, Reset_Camera, Screen_Shot, Toggle_Axis, Toggle_Lines, Text_Overlay, Space, -- Rotate -- Rotate_Up, Rotate_Down, Rotate_Left, Rotate_Right, Rotate_CW, Rotate_AntiCW, -- Strafe -- Strafe_Up, Strafe_Down, Strafe_Left, Strafe_Right, Strafe_Forward, Strafe_Backward, -- Swarm -- Add_Vehicle, Remove_Vehicle); type Commands_Array is array (Complete_Command_Set) of Boolean; Command_Set_Reset : constant Commands_Array := (others => False); procedure Get_Keys (Commands : in out Commands_Array; Selected_Keyboard : access GLUT.Devices.Keyboard := GLUT.Devices.default_Keyboard'Access); end Keyboard;
-- -- Copyright (C) 2014-2016 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 GNAT.Source_Info; with HW.Time; with HW.Debug; with HW.GFX.GMA.Config; with HW.GFX.GMA.Registers; with HW.GFX.GMA.Power_And_Clocks_Haswell; use type HW.Word64; package body HW.GFX.GMA.Power_And_Clocks_Skylake is type Power_Domain is (MISC_IO, PW1, PW2, DDI_AE, DDI_B, DDI_C, DDI_D); subtype Power_Well is Power_Domain range PW1 .. PW2; subtype Dynamic_Domain is Power_Domain range PW2 .. DDI_D; NDE_RSTWRN_OPT_RST_PCH_Handshake_En : constant := 1 * 2 ** 4; FUSE_STATUS_DOWNLOAD_STATUS : constant := 1 * 2 ** 31; FUSE_STATUS_PG0_DIST_STATUS : constant := 1 * 2 ** 27; type Power_Domain_Values is array (Power_Domain) of Word32; PWR_WELL_CTL_POWER_REQUEST : constant Power_Domain_Values := (MISC_IO => 1 * 2 ** 1, DDI_AE => 1 * 2 ** 3, DDI_B => 1 * 2 ** 5, DDI_C => 1 * 2 ** 7, DDI_D => 1 * 2 ** 9, PW1 => 1 * 2 ** 29, PW2 => 1 * 2 ** 31); PWR_WELL_CTL_POWER_STATE : constant Power_Domain_Values := (MISC_IO => 1 * 2 ** 0, DDI_AE => 1 * 2 ** 2, DDI_B => 1 * 2 ** 4, DDI_C => 1 * 2 ** 6, DDI_D => 1 * 2 ** 8, PW1 => 1 * 2 ** 28, PW2 => 1 * 2 ** 30); type Power_Well_Values is array (Power_Well) of Word32; FUSE_STATUS_PGx_DIST_STATUS : constant Power_Well_Values := (PW1 => 1 * 2 ** 26, PW2 => 1 * 2 ** 25); DBUF_CTL_DBUF_POWER_REQUEST : constant := 1 * 2 ** 31; DBUF_CTL_DBUF_POWER_STATE : constant := 1 * 2 ** 30; ---------------------------------------------------------------------------- DPLL_CTRL1_DPLL0_LINK_RATE_MASK : constant := 7 * 2 ** 1; DPLL_CTRL1_DPLL0_LINK_RATE_2700MHZ : constant := 0 * 2 ** 1; DPLL_CTRL1_DPLL0_LINK_RATE_1350MHZ : constant := 1 * 2 ** 1; DPLL_CTRL1_DPLL0_LINK_RATE_810MHZ : constant := 2 * 2 ** 1; DPLL_CTRL1_DPLL0_LINK_RATE_1620MHZ : constant := 3 * 2 ** 1; DPLL_CTRL1_DPLL0_LINK_RATE_1080MHZ : constant := 4 * 2 ** 1; DPLL_CTRL1_DPLL0_LINK_RATE_2160MHZ : constant := 5 * 2 ** 1; DPLL_CTRL1_DPLL0_OVERRIDE : constant := 1 * 2 ** 0; LCPLL1_CTL_PLL_ENABLE : constant := 1 * 2 ** 31; LCPLL1_CTL_PLL_LOCK : constant := 1 * 2 ** 30; ---------------------------------------------------------------------------- CDCLK_CTL_CD_FREQ_SELECT_MASK : constant := 3 * 2 ** 26; CDCLK_CTL_CD_FREQ_SELECT_450MHZ : constant := 0 * 2 ** 26; CDCLK_CTL_CD_FREQ_SELECT_540MHZ : constant := 1 * 2 ** 26; CDCLK_CTL_CD_FREQ_SELECT_337_5MHZ : constant := 2 * 2 ** 26; CDCLK_CTL_CD_FREQ_SELECT_675MHZ : constant := 3 * 2 ** 26; CDCLK_CTL_CD_FREQ_DECIMAL_MASK : constant := 16#7ff#; SKL_PCODE_CDCLK_CONTROL : constant := 7; SKL_CDCLK_PREPARE_FOR_CHANGE : constant := 3; SKL_CDCLK_READY_FOR_CHANGE : constant := 1; GT_MAILBOX_READY : constant := 1 * 2 ** 31; function CDCLK_CTL_CD_FREQ_DECIMAL (Freq : Pos16; Plus_Half : Boolean) return Word32 is begin return Word32 (2 * (Pos32 (Freq) - 1)) or (if Plus_Half then 1 else 0); end CDCLK_CTL_CD_FREQ_DECIMAL; ---------------------------------------------------------------------------- procedure GT_Mailbox_Write (MBox : Word32; Value : Word64) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY); Registers.Write (Registers.GT_MAILBOX_DATA, Word32 (Value and 16#ffff_ffff#)); Registers.Write (Registers.GT_MAILBOX_DATA_1, Word32 (Shift_Right (Value, 32))); Registers.Write (Registers.GT_MAILBOX, GT_MAILBOX_READY or MBox); Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY); end GT_Mailbox_Write; ---------------------------------------------------------------------------- procedure PD_Off (PD : Power_Domain) is Ctl1, Ctl2, Ctl3, Ctl4 : Word32; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Read (Registers.PWR_WELL_CTL_BIOS, Ctl1); Registers.Read (Registers.PWR_WELL_CTL_DRIVER, Ctl2); Registers.Read (Registers.PWR_WELL_CTL_KVMR, Ctl3); Registers.Read (Registers.PWR_WELL_CTL_DEBUG, Ctl4); pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL5)); -- Result for debugging only pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL6)); -- Result for debugging only if ((Ctl1 or Ctl2 or Ctl3 or Ctl4) and PWR_WELL_CTL_POWER_REQUEST (PD)) /= 0 then Registers.Wait_Set_Mask (Register => Registers.PWR_WELL_CTL_DRIVER, Mask => PWR_WELL_CTL_POWER_STATE (PD)); end if; if (Ctl1 and PWR_WELL_CTL_POWER_REQUEST (PD)) /= 0 then Registers.Unset_Mask (Register => Registers.PWR_WELL_CTL_BIOS, Mask => PWR_WELL_CTL_POWER_REQUEST (PD)); end if; if (Ctl2 and PWR_WELL_CTL_POWER_REQUEST (PD)) /= 0 then Registers.Unset_Mask (Register => Registers.PWR_WELL_CTL_DRIVER, Mask => PWR_WELL_CTL_POWER_REQUEST (PD)); end if; end PD_Off; procedure PD_On (PD : Power_Domain) with Pre => True is Ctl1, Ctl2, Ctl3, Ctl4 : Word32; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Read (Registers.PWR_WELL_CTL_BIOS, Ctl1); Registers.Read (Registers.PWR_WELL_CTL_DRIVER, Ctl2); Registers.Read (Registers.PWR_WELL_CTL_KVMR, Ctl3); Registers.Read (Registers.PWR_WELL_CTL_DEBUG, Ctl4); pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL5)); -- Result for debugging only pragma Debug (Registers.Posting_Read (Registers.PWR_WELL_CTL6)); -- Result for debugging only if ((Ctl1 or Ctl2 or Ctl3 or Ctl4) and PWR_WELL_CTL_POWER_REQUEST (PD)) = 0 then Registers.Wait_Unset_Mask (Register => Registers.PWR_WELL_CTL_DRIVER, Mask => PWR_WELL_CTL_POWER_STATE (PD)); end if; if (Ctl2 and PWR_WELL_CTL_POWER_REQUEST (PD)) = 0 then Registers.Set_Mask (Register => Registers.PWR_WELL_CTL_DRIVER, Mask => PWR_WELL_CTL_POWER_REQUEST (PD)); Registers.Wait_Set_Mask (Register => Registers.PWR_WELL_CTL_DRIVER, Mask => PWR_WELL_CTL_POWER_STATE (PD)); if PD in Power_Well then Registers.Wait_Set_Mask (Register => Registers.FUSE_STATUS, Mask => FUSE_STATUS_PGx_DIST_STATUS (PD)); end if; end if; end PD_On; function Need_PD (PD : Dynamic_Domain; Configs : Pipe_Configs) return Boolean is begin return (case PD is when DDI_AE => Configs (Primary).Port = Internal or Configs (Secondary).Port = Internal or Configs (Tertiary).Port = Internal, when DDI_B => Configs (Primary).Port = HDMI1 or Configs (Primary).Port = DP1 or Configs (Secondary).Port = HDMI1 or Configs (Secondary).Port = DP1 or Configs (Tertiary).Port = HDMI1 or Configs (Tertiary).Port = DP1, when DDI_C => Configs (Primary).Port = HDMI2 or Configs (Primary).Port = DP2 or Configs (Secondary).Port = HDMI2 or Configs (Secondary).Port = DP2 or Configs (Tertiary).Port = HDMI2 or Configs (Tertiary).Port = DP2, when DDI_D => Configs (Primary).Port = HDMI3 or Configs (Primary).Port = DP3 or Configs (Secondary).Port = HDMI3 or Configs (Secondary).Port = DP3 or Configs (Tertiary).Port = HDMI3 or Configs (Tertiary).Port = DP3, when PW2 => (Configs (Primary).Port /= Disabled and Configs (Primary).Port /= Internal) or Configs (Secondary).Port /= Disabled or Configs (Tertiary).Port /= Disabled); end Need_PD; ---------------------------------------------------------------------------- procedure Pre_All_Off is begin Power_And_Clocks_Haswell.PSR_Off; end Pre_All_Off; procedure Post_All_Off is begin for PD in reverse Dynamic_Domain loop PD_Off (PD); end loop; Registers.Unset_Mask (Register => Registers.DBUF_CTL, Mask => DBUF_CTL_DBUF_POWER_REQUEST); Registers.Wait_Unset_Mask (Register => Registers.DBUF_CTL, Mask => DBUF_CTL_DBUF_POWER_STATE); Registers.Unset_Mask (Register => Registers.LCPLL1_CTL, Mask => LCPLL1_CTL_PLL_ENABLE); Registers.Wait_Unset_Mask (Register => Registers.LCPLL1_CTL, Mask => LCPLL1_CTL_PLL_LOCK); PD_Off (MISC_IO); PD_Off (PW1); end Post_All_Off; procedure Initialize is CDClk_Change_Timeout : Time.T; Timed_Out : Boolean; MBox_Data0 : Word32; begin Registers.Set_Mask (Register => Registers.NDE_RSTWRN_OPT, Mask => NDE_RSTWRN_OPT_RST_PCH_Handshake_En); Registers.Wait_Set_Mask (Register => Registers.FUSE_STATUS, Mask => FUSE_STATUS_PG0_DIST_STATUS); PD_On (PW1); PD_On (MISC_IO); Registers.Write (Register => Registers.CDCLK_CTL, Value => CDCLK_CTL_CD_FREQ_SELECT_337_5MHZ or CDCLK_CTL_CD_FREQ_DECIMAL (337, True)); -- TODO: Set to preferred eDP rate: -- Registers.Unset_And_Set_Mask -- (Register => Registers.DPLL_CTRL1, -- Unset_Mask => DPLL_CTRL1_DPLL0_LINK_RATE_MASK, -- Set_Mask => DPLL_CTRL1_DPLL0_LINK_RATE_...); Registers.Set_Mask (Register => Registers.LCPLL1_CTL, Mask => LCPLL1_CTL_PLL_ENABLE); Registers.Wait_Set_Mask (Register => Registers.LCPLL1_CTL, Mask => LCPLL1_CTL_PLL_LOCK); CDClk_Change_Timeout := Time.MS_From_Now (3); Timed_Out := False; loop GT_Mailbox_Write (MBox => SKL_PCODE_CDCLK_CONTROL, Value => SKL_CDCLK_PREPARE_FOR_CHANGE); Registers.Read (Registers.GT_MAILBOX_DATA, MBox_Data0); if (MBox_Data0 and SKL_CDCLK_READY_FOR_CHANGE) /= 0 then -- Ignore timeout if we succeeded anyway. Timed_Out := False; exit; end if; exit when Timed_Out; Timed_Out := Time.Timed_Out (CDClk_Change_Timeout); end loop; pragma Debug (Timed_Out, Debug.Put_Line ("ERROR: PCODE not ready for frequency change after 3ms.")); if not Timed_Out then GT_Mailbox_Write (MBox => SKL_PCODE_CDCLK_CONTROL, Value => 16#0000_0000#); -- 0 - 337.5MHz -- 1 - 450.0MHz -- 2 - 540.0MHz -- 3 - 675.0MHz Registers.Set_Mask (Register => Registers.DBUF_CTL, Mask => DBUF_CTL_DBUF_POWER_REQUEST); Registers.Wait_Set_Mask (Register => Registers.DBUF_CTL, Mask => DBUF_CTL_DBUF_POWER_STATE); end if; Config.Raw_Clock := Config.Default_RawClk_Freq; end Initialize; procedure Power_Set_To (Configs : Pipe_Configs) is begin for PD in reverse Dynamic_Domain loop if not Need_PD (PD, Configs) then PD_Off (PD); end if; end loop; for PD in Dynamic_Domain loop if Need_PD (PD, Configs) then PD_On (PD); end if; end loop; end Power_Set_To; procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs) is begin for PD in Dynamic_Domain loop if not Need_PD (PD, Old_Configs) and Need_PD (PD, New_Configs) then PD_On (PD); end if; end loop; end Power_Up; procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs) is begin for PD in reverse Dynamic_Domain loop if (Need_PD (PD, Old_Configs) or Need_PD (PD, Tmp_Configs)) and not Need_PD (PD, New_Configs) then PD_Off (PD); end if; end loop; end Power_Down; end HW.GFX.GMA.Power_And_Clocks_Skylake;
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. (gh+flacada@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); ------------------------------------------------------------------------------ -- FLAC/Ada root package ------------------------------------------------------------------------------ package Flac with Pure => True, SPARK_Mode => On is type Main_Error_Type is (None, Open_Error, Not_A_Flac_File); -- General kind of error. type Sub_Error_Type is (None, -- No error. Header_Not_Found, -- No valid flac header Corrupt_Meta_Data, -- Unexpected length of meta data Invalid_Meta_Data, -- Meta data does not pan out Corrupt_Stream_Info, -- Expected stream info block not found Invalid_Stream_Info -- Stream info block does not pan out ); -- More specific error (if applicable). type Error_Type is record Main : Main_Error_Type; Sub : Sub_Error_Type; end record; No_Error : constant Error_Type := Error_Type'(Main => None, Sub => None); end Flac;
-- Copyright (C) 2020 Glen Cornell <glen.m.cornell@gmail.com> -- -- 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/>. package body Aof.Core.Generic_Signals is package body S0 is procedure Connect (This : in out Signal'Class; Object : in not null Access_Object; Method : in not null Access_Method) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Method, Object => Object, Method => Method)); end; procedure Connect (This : in out Signal'Class; Proc : in not null Access_Procedure) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Procedure, Proc => Proc)); end; procedure Connect (This : in out Signal'Class; Signal : in not null Access_Signal) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Signal, Signal => Signal)); end; procedure Emit (This : in Signal'Class) is procedure Emit_Helper(Cursor : in Slot_Container_Pkg.Cursor) is Item : constant Connections.Connection_Object_Type := Slot_Container_Pkg.Element(Cursor); begin case Item.Connection is when Connections.Connect_To_Nothing => null; when Connections.Connect_To_Method => Item.Method (Item.Object); when Connections.Connect_To_Procedure => Item.Proc.all; when Connections.Connect_To_Signal => Item.Signal.Emit; end case; end Emit_Helper; begin This.Slots.Iterate(Emit_Helper'Access); end; end S0; package body S1 is procedure Connect (This : in out Signal'Class; Object : in not null Access_Object; Method : in not null Access_Method) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Method, Object => Object, Method => Method)); end; procedure Connect (This : in out Signal'Class; Proc : in not null Access_Procedure) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Procedure, Proc => Proc)); end; procedure Connect (This : in out Signal'Class; Signal : in not null Access_Signal) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Signal, Signal => Signal)); end; procedure Emit (This : in Signal'Class; P1 : in Param_1) is procedure Emit_Helper(Cursor : in Slot_Container_Pkg.Cursor) is Item : constant Connections.Connection_Object_Type := Slot_Container_Pkg.Element(Cursor); begin case Item.Connection is when Connections.Connect_To_Nothing => null; when Connections.Connect_To_Method => Item.Method (Item.Object, P1); when Connections.Connect_To_Procedure => Item.Proc (P1); when Connections.Connect_To_Signal => Item.Signal.Emit (P1); end case; end Emit_Helper; begin This.Slots.Iterate(Emit_Helper'Access); end; end S1; package body S2 is procedure Connect (This : in out Signal'Class; Object : in not null Access_Object; Method : in not null Access_Method) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Method, Object => Object, Method => Method)); end; procedure Connect (This : in out Signal'Class; Proc : in not null Access_Procedure) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Procedure, Proc => Proc)); end; procedure Connect (This : in out Signal'Class; Signal : in not null Access_Signal) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Signal, Signal => Signal)); end; procedure Emit (This : in Signal'Class; P1 : in Param_1; P2 : in Param_2) is procedure Emit_Helper(Cursor : in Slot_Container_Pkg.Cursor) is Item : constant Connections.Connection_Object_Type := Slot_Container_Pkg.Element(Cursor); begin case Item.Connection is when Connections.Connect_To_Nothing => null; when Connections.Connect_To_Method => Item.Method (Item.Object, P1, P2); when Connections.Connect_To_Procedure => Item.Proc (P1, P2); when Connections.Connect_To_Signal => Item.Signal.Emit (P1, P2); end case; end Emit_Helper; begin This.Slots.Iterate(Emit_Helper'Access); end; end S2; package body S3 is procedure Connect (This : in out Signal'Class; Object : in not null Access_Object; Method : in not null Access_Method) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Method, Object => Object, Method => Method)); end; procedure Connect (This : in out Signal'Class; Proc : in not null Access_Procedure) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Procedure, Proc => Proc)); end; procedure Connect (This : in out Signal'Class; Signal : in not null Access_Signal) is begin This.Slots.Append (Connections.Connection_Object_Type' (Connection => Connections.Connect_To_Signal, Signal => Signal)); end; procedure Emit (This : in Signal'Class; P1 : in Param_1; P2 : in Param_2; P3 : in Param_3) is procedure Emit_Helper(Cursor : in Slot_Container_Pkg.Cursor) is Item : constant Connections.Connection_Object_Type := Slot_Container_Pkg.Element(Cursor); begin case Item.Connection is when Connections.Connect_To_Nothing => null; when Connections.Connect_To_Method => Item.Method (Item.Object, P1, P2, P3); when Connections.Connect_To_Procedure => Item.Proc (P1, P2, P3); when Connections.Connect_To_Signal => Item.Signal.Emit (P1, P2, P3); end case; end Emit_Helper; begin This.Slots.Iterate(Emit_Helper'Access); end; end S3; end Aof.Core.Generic_Signals;
with Peripherals; use Peripherals; package Modem is protected TX is procedure Send (Data : in Radio.Packet_Type); procedure Get_Data (Data_Available : out Boolean; Data : out Radio.Packet_Type); private Data_Available : Boolean := False; Data : Radio.Packet_Type; end TX; protected RX is procedure Receive (Data : in Radio.Packet_Type); procedure Get_Data (Data_Available : out Boolean; Data : out Radio.Packet_Type); private Data_Available : Boolean := False; Data : Radio.Packet_Type; end RX; end Modem;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J . E X T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-2013, 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. -- -- -- ------------------------------------------------------------------------------ -- Subprograms to set, get and cache external references, to be used as -- External functions in project files. with GNAT.Dynamic_HTables; package Prj.Ext is ------------------------- -- External References -- ------------------------- -- External references influence the way a project tree is processed (in -- particular they provide the values for the typed string variables that -- are then used in case constructions). -- External references are project-tree specific, so that when multiple -- trees are loaded in parallel we can have different scenarios (or even -- load the same tree twice and see different views of it). type External_References is private; No_External_Refs : constant External_References; procedure Initialize (Self : out External_References; Copy_From : External_References := No_External_Refs); -- Initialize Self, and copy all values from Copy_From if needed. -- This has no effect if Self was already initialized. procedure Free (Self : in out External_References); -- Free memory used by Self type External_Source is (From_Command_Line, From_Environment, From_External_Attribute); -- Indicates where was the value of an external reference defined. They are -- prioritized in that order, so that a user can always use the command -- line to override a value coming from his environment, or an environment -- variable to override a value defined in an aggregate project through the -- "for External()..." attribute. procedure Add (Self : External_References; External_Name : String; Value : String; Source : External_Source := External_Source'First; Silent : Boolean := False); -- Add an external reference (or modify an existing one). No overriding is -- done if the Source's priority is less than the one used to previously -- set the value of the variable. The default for Source is such that -- overriding always occurs. When Silent is True, nothing is output even -- with non default verbosity. function Value_Of (Self : External_References; External_Name : Name_Id; With_Default : Name_Id := No_Name) return Name_Id; -- Get the value of an external reference, and cache it for future uses function Check (Self : External_References; Declaration : String) return Boolean; -- Check that an external declaration <external>=<value> is correct. -- If it is correct, the external reference is Added. procedure Reset (Self : External_References); -- Clear the internal data structure that stores the external references -- and free any allocated memory. private -- Use a Static_HTable, rather than a Simple_HTable -- The issue is that we need to be able to copy the contents of the table -- (in Initialize), but this isn't doable for Simple_HTable for which -- iterators do not return the key. type Name_To_Name; type Name_To_Name_Ptr is access all Name_To_Name; type Name_To_Name is record Key : Name_Id; Value : Name_Id; Source : External_Source; Next : Name_To_Name_Ptr; end record; procedure Set_Next (E : Name_To_Name_Ptr; Next : Name_To_Name_Ptr); function Next (E : Name_To_Name_Ptr) return Name_To_Name_Ptr; function Get_Key (E : Name_To_Name_Ptr) return Name_Id; package Name_To_Name_HTable is new GNAT.Dynamic_HTables.Static_HTable (Header_Num => Header_Num, Element => Name_To_Name, Elmt_Ptr => Name_To_Name_Ptr, Null_Ptr => null, Set_Next => Set_Next, Next => Next, Key => Name_Id, Get_Key => Get_Key, Hash => Hash, Equal => "="); -- General type for htables associating name_id to name_id. This is in -- particular used to store the values of external references. type Instance_Access is access all Name_To_Name_HTable.Instance; type External_References is record Refs : Instance_Access; -- External references are stored in this hash table (and manipulated -- through subprogrames in prj-ext.ads). External references are -- project-tree specific so that one can load the same tree twice but -- have two views of it, for instance. end record; No_External_Refs : constant External_References := (Refs => null); end Prj.Ext;
-- 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.Characters.Handling; use Ada.Characters.Handling; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Ada.Containers.Generic_Array_Sort; with Ada.Exceptions; use Ada.Exceptions; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with CArgv; use CArgv; with Tcl; use Tcl; with Tcl.Ada; use Tcl.Ada; with Tcl.Tk.Ada; use Tcl.Tk.Ada; with Tcl.Tk.Ada.Busy; with Tcl.Tk.Ada.Font; use Tcl.Tk.Ada.Font; 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.Text; use Tcl.Tk.Ada.Widgets.Text; with Tcl.Tk.Ada.Widgets.Toplevel.MainWindow; use Tcl.Tk.Ada.Widgets.Toplevel.MainWindow; with Tcl.Tk.Ada.Widgets.TtkButton; use Tcl.Tk.Ada.Widgets.TtkButton; with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox; use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox; with Tcl.Tk.Ada.Widgets.TtkEntry; use Tcl.Tk.Ada.Widgets.TtkEntry; 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.TtkProgressBar; use Tcl.Tk.Ada.Widgets.TtkProgressBar; with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar; with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo; with Bases.Ship; use Bases.Ship; with Config; use Config; with CoreUI; use CoreUI; with Dialogs; use Dialogs; with Maps; use Maps; with Maps.UI; use Maps.UI; with ShipModules; use ShipModules; with Ships.Crew; use Ships.Crew; with Table; use Table; with Trades; use Trades; with Utils.UI; use Utils.UI; package body Bases.ShipyardUI is -- ****iv* ShipyardUI/ShipyardUI.InstallTable -- FUNCTION -- Table with info about the available modules -- SOURCE InstallTable: Table_Widget (5); -- **** -- ****iv* ShipyardUI/ShipyardUI.RemoveTable -- FUNCTION -- Table with info about the installed modules -- SOURCE RemoveTable: Table_Widget (5); -- **** -- ****iv* ShipyardUI/ShipyardUI.Install_Indexes -- FUNCTION -- Indexes of the available modules to install -- SOURCE Install_Indexes: UnboundedString_Container.Vector; -- **** -- ****iv* ShipyardUI/ShipyardUI.Remove_Indexes -- FUNCTION -- Indexes of the modules in the player's ship (to remove) -- SOURCE Remove_Indexes: Positive_Container.Vector; -- **** -- ****f* ShipyardUI/ShipyardUI.Show_Shipyard_Command -- FUNCTION -- Show the selected base shipyard -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. -- Argv - Values of arguments passed to the command. -- COMMAND -- ShowShipyard ?moduletype? ?modulename? -- Show the base shipyard and load all available and installed modules -- lists. Moduletype is the type of modules to show in available modules, -- modulename is the name of the module to search in available modules. -- SOURCE function Show_Shipyard_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Shipyard_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData); ShipyardFrame: Ttk_Frame := Get_Widget(Main_Paned & ".shipyardframe", Interp); ShipyardCanvas: constant Tk_Canvas := Get_Widget(ShipyardFrame & ".canvas", Interp); BaseIndex: constant Positive := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; ModuleSize: Integer; ModuleTypeBox: constant Ttk_ComboBox := Get_Widget (ShipyardCanvas & ".shipyard.install.options.modules", Interp); Cost, UsedSpace: Natural; Damage: Float; MoneyIndex2: constant Natural := FindItem(Player_Ship.Cargo, Money_Index); MaxSize, AllSpace: Positive; InstallInfo: Unbounded_String; MoneyLabel: constant Ttk_Label := Get_Widget(ShipyardCanvas & ".shipyard.moneyinfo", Interp); Page: constant Positive := (if Argc = 4 then Positive'Value(CArgv.Arg(Argv, 3)) else 1); Start_Row: constant Positive := ((Page - 1) * Game_Settings.Lists_Limit) + 1; Current_Row: Positive := 1; Arguments: constant String := (if Argc > 2 then "{" & CArgv.Arg(Argv, 1) & "} {" & CArgv.Arg(Argv, 2) & "}" elsif Argc = 2 then CArgv.Arg(Argv, 1) & " {}" else "0 {}"); SearchEntry: constant Ttk_Entry := Get_Widget(ShipyardCanvas & ".shipyard.install.options.search"); begin if Winfo_Get(ShipyardCanvas, "exists") = "0" then Tcl_EvalFile (Get_Context, To_String(Data_Directory) & "ui" & Dir_Separator & "shipyard.tcl"); Bind(ShipyardFrame, "<Configure>", "{ResizeCanvas %W.canvas %w %h}"); ShipyardFrame := Get_Widget(ShipyardCanvas & ".shipyard.install", Interp); InstallTable := CreateTable (Widget_Image(ShipyardFrame), (To_Unbounded_String("Name"), To_Unbounded_String("Type"), To_Unbounded_String("Size"), To_Unbounded_String("Materials"), To_Unbounded_String("Cost")), Get_Widget(".gameframe.paned.shipyardframe.scrolly"), "", "Press mouse button to sort the modules."); ShipyardFrame := Get_Widget(ShipyardCanvas & ".shipyard.remove", Interp); RemoveTable := CreateTable (Widget_Image(ShipyardFrame), (To_Unbounded_String("Name"), To_Unbounded_String("Type"), To_Unbounded_String("Size"), To_Unbounded_String("Materials"), To_Unbounded_String("Price")), Get_Widget(".gameframe.paned.shipyardframe.scrolly"), "SortShipyardModules remove 0 {}", "Press mouse button to sort the modules."); elsif Winfo_Get(ShipyardCanvas, "ismapped") = "1" then if Argc = 1 then Tcl.Tk.Ada.Grid.Grid_Remove(Close_Button); Entry_Configure(GameMenu, "Help", "-command {ShowHelp general}"); ShowSkyMap(True); return TCL_OK; else Current(ModuleTypeBox, CArgv.Arg(Argv, 1)); end if; elsif Winfo_Get(ShipyardCanvas, "ismapped") = "0" and Argc = 1 then Current(ModuleTypeBox, "0"); end if; Entry_Configure(GameMenu, "Help", "-command {ShowHelp ship}"); Find_Max_Module_Size_Loop : for Module of Player_Ship.Modules loop if Module.M_Type = HULL then MaxSize := Modules_List(Module.Proto_Index).Value; UsedSpace := Module.Installed_Modules; AllSpace := Module.Max_Modules; exit Find_Max_Module_Size_Loop; end if; end loop Find_Max_Module_Size_Loop; ShipyardFrame.Name := New_String(ShipyardCanvas & ".shipyard"); InstallInfo := (if MoneyIndex2 > 0 then To_Unbounded_String ("You have" & Natural'Image(Player_Ship.Cargo(MoneyIndex2).Amount) & " " & To_String(Money_Name) & ".") else To_Unbounded_String (LF & "You don't have any " & To_String(Money_Name) & " to install anything.")); Append (InstallInfo, LF & "You have used" & Natural'Image(UsedSpace) & " modules space from max" & Natural'Image(AllSpace) & " allowed."); configure(MoneyLabel, "-text {" & To_String(InstallInfo) & "}"); Tcl_Eval (Interp, "SetScrollbarBindings " & MoneyLabel & " .gameframe.paned.shipyardframe.scrolly"); if Argc < 3 then configure(SearchEntry, "-validatecommand {}"); Delete(SearchEntry, "0", "end"); configure (SearchEntry, "-validatecommand {ShowShipyard [" & ShipyardFrame & ".install.options.modules current] %P}"); end if; if Install_Indexes.Length = 0 then for I in Modules_List.Iterate loop Install_Indexes.Append(BaseModules_Container.Key(I)); end loop; end if; Update_Headers_Command (InstallTable, "SortShipyardModules install " & Arguments); ClearTable(InstallTable); Load_Install_Modules_Loop : for I of Install_Indexes loop if Modules_List(I).Price = 0 or Sky_Bases(BaseIndex).Reputation(1) < Modules_List(I).Reputation then goto End_Of_Loop; end if; if Argc > 1 and then Natural'Value(CArgv.Arg(Argv, 1)) > 0 and then Natural'Value(CArgv.Arg(Argv, 1)) /= ModuleType'Pos(Modules_List(I).MType) then goto End_Of_Loop; end if; if Argc > 2 and then CArgv.Arg(Argv, 2)'Length > 0 and then Index (To_Lower(To_String(Modules_List(I).Name)), To_Lower(CArgv.Arg(Argv, 2))) = 0 then goto End_Of_Loop; end if; if Current_Row < Start_Row then Current_Row := Current_Row + 1; goto End_Of_Loop; end if; ModuleSize := (if Modules_List(I).MType = HULL then Modules_List(I).MaxValue else Modules_List(I).Size); AddButton (InstallTable, To_String(Modules_List(I).Name), "Show available options for module", "ShowShipyardModuleMenu {" & To_String(I) & "} install", 1); AddButton (InstallTable, GetModuleType(I), "Show available options for module", "ShowShipyardModuleMenu {" & To_String(I) & "} install", 2); AddButton (InstallTable, Integer'Image(ModuleSize), "Show available options for module", "ShowShipyardModuleMenu {" & To_String(I) & "} install", 3, False, (if ModuleSize > MaxSize then "red" else "")); AddButton (InstallTable, To_String(Modules_List(I).RepairMaterial), "Show available options for module", "ShowShipyardModuleMenu {" & To_String(I) & "} install", 4); Cost := Modules_List(I).Price; Count_Price(Cost, FindMember(Talk)); AddButton (InstallTable, Natural'Image(Cost), "Show available options for module", "ShowShipyardModuleMenu {" & To_String(I) & "} install", 5, True, (if MoneyIndex2 > 0 and then Cost <= Player_Ship.Cargo(MoneyIndex2).Amount then "" else "red")); exit Load_Install_Modules_Loop when InstallTable.Row = Game_Settings.Lists_Limit + 1; <<End_Of_Loop>> end loop Load_Install_Modules_Loop; AddPagination (InstallTable, (if Page > 1 then "ShowShipyard " & Arguments & Positive'Image(Page - 1) else ""), (if InstallTable.Row < Game_Settings.Lists_Limit + 1 then "" else "ShowShipyard " & Arguments & Positive'Image(Page + 1))); UpdateTable (InstallTable, (if Focus = Widget_Image(SearchEntry) then False)); if Remove_Indexes.Length /= Player_Ship.Modules.Length then for I in Player_Ship.Modules.Iterate loop Remove_Indexes.Append(Modules_Container.To_Index(I)); end loop; end if; ClearTable(RemoveTable); Current_Row := 1; Load_Remove_Modules_Loop : for I of Remove_Indexes loop if Modules_List(Player_Ship.Modules(I).Proto_Index).MType /= HULL then if Current_Row < Start_Row then Current_Row := Current_Row + 1; goto End_Of_Remove_Loop; end if; AddButton (RemoveTable, To_String(Player_Ship.Modules(I).Name), "Show available options for module", "ShowShipyardModuleMenu {" & Positive'Image(I) & "} remove", 1); AddButton (RemoveTable, GetModuleType(Player_Ship.Modules(I).Proto_Index), "Show available options for module", "ShowShipyardModuleMenu {" & Positive'Image(I) & "} remove", 2); AddButton (RemoveTable, Integer'Image (Modules_List(Player_Ship.Modules(I).Proto_Index).Size), "Show available options for module", "ShowShipyardModuleMenu {" & Positive'Image(I) & "} remove", 3); AddButton (RemoveTable, To_String (Modules_List(Player_Ship.Modules(I).Proto_Index) .RepairMaterial), "Show available options for module", "ShowShipyardModuleMenu {" & Positive'Image(I) & "} remove", 4); Damage := 1.0 - Float(Player_Ship.Modules(I).Durability) / Float(Player_Ship.Modules(I).Max_Durability); Cost := Modules_List(Player_Ship.Modules(I).Proto_Index).Price - Integer (Float (Modules_List(Player_Ship.Modules(I).Proto_Index).Price) * Damage); if Cost = 0 then Cost := 1; end if; Count_Price(Cost, FindMember(Talk), False); AddButton (RemoveTable, Natural'Image(Cost), "Show available options for module", "ShowShipyardModuleMenu {" & Positive'Image(I) & "} remove", 5, True); exit Load_Remove_Modules_Loop when RemoveTable.Row = Game_Settings.Lists_Limit + 1; end if; <<End_Of_Remove_Loop>> end loop Load_Remove_Modules_Loop; AddPagination (RemoveTable, (if Page > 1 then "ShowShipyard " & Arguments & Positive'Image(Page - 1) else ""), (if RemoveTable.Row < Game_Settings.Lists_Limit + 1 then "" else "ShowShipyard " & Arguments & Positive'Image(Page + 1))); UpdateTable(RemoveTable); Tcl.Tk.Ada.Grid.Grid(Close_Button, "-row 0 -column 1"); configure (ShipyardCanvas, "-height [expr " & SashPos(Main_Paned, "0") & " - 20] -width " & cget(Main_Paned, "-width")); Xview_Move_To(ShipyardCanvas, "0.0"); Yview_Move_To(ShipyardCanvas, "0.0"); Show_Screen("shipyardframe"); Tcl_SetResult(Interp, "1"); Tcl_Eval(Get_Context, "ShowShipyardTab"); return TCL_OK; end Show_Shipyard_Command; -- ****iv* ShipyardUI/ShipyardUI.ModuleIndex -- SOURCE ModuleIndex: Unbounded_String; -- **** -- ****if* ShipyardUI/ShipyardUI.SetModuleInfo -- FUNCTION -- Show information about selected module -- PARAMETERS -- Installing - If true, player looking at installing modules list -- SOURCE procedure SetModuleInfo(Installing: Boolean) is -- **** use Tiny_String; MType: ModuleType; MAmount, Weight, MaxValue, Value, MaxOwners: Natural; ShipModuleIndex, Size: Positive; Speed: Integer; ModuleText: Tk_Text; Added: Boolean := False; begin if Installing then MType := Modules_List(ModuleIndex).MType; MaxValue := Modules_List(ModuleIndex).MaxValue; Value := Modules_List(ModuleIndex).Value; Size := Modules_List(ModuleIndex).Size; Weight := Modules_List(ModuleIndex).Weight; MaxOwners := Modules_List(ModuleIndex).MaxOwners; Speed := Modules_List(ModuleIndex).Speed; ModuleText := Get_Widget(".moduledialog.info"); else ShipModuleIndex := Integer'Value(To_String(ModuleIndex)); MType := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .MType; case MType is when HARPOON_GUN => MaxValue := Player_Ship.Modules(ShipModuleIndex).Duration; Value := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Value; when ENGINE => MaxValue := Player_Ship.Modules(ShipModuleIndex).Power; Value := Player_Ship.Modules(ShipModuleIndex).Fuel_Usage; when CABIN => MaxValue := Player_Ship.Modules(ShipModuleIndex).Quality; Value := Player_Ship.Modules(ShipModuleIndex).Cleanliness; when GUN => MaxValue := Player_Ship.Modules(ShipModuleIndex).Damage; Value := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Value; when ShipModules.CARGO => MaxValue := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .MaxValue; Value := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Value; when HULL => MaxValue := Player_Ship.Modules(ShipModuleIndex).Max_Modules; Value := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Value; when BATTERING_RAM => MaxValue := Player_Ship.Modules(ShipModuleIndex).Damage2; Value := 0; when others => MaxValue := 0; Value := 0; end case; Size := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index).Size; Weight := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Weight; MaxOwners := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .MaxOwners; Speed := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Speed; ModuleText := Get_Widget(".moduledialog.info"); end if; case MType is when HULL => if Installing then Insert (ModuleText, "end", "{" & LF & "Ship hull can be only replaced." & LF & "Modules space:" & Positive'Image(MaxValue) & "}"); end if; Insert (ModuleText, "end", "{" & LF & "Max module size:" & Integer'Image(Value) & "}"); when ENGINE => Insert (ModuleText, "end", "{" & LF & "Max power:" & Positive'Image(MaxValue) & "}"); if Installing then Insert (ModuleText, "end", "{" & LF & "Fuel usage:" & Positive'Image(Value) & "}"); end if; when ShipModules.CARGO => Insert (ModuleText, "end", "{" & LF & "Max cargo:" & Positive'Image(MaxValue) & " kg}"); when CABIN => Insert(ModuleText, "end", "{" & LF & "Quality: }"); if MaxValue < 30 then Insert(ModuleText, "end", "{minimal}"); elsif MaxValue < 60 then Insert(ModuleText, "end", "{basic}"); elsif MaxValue < 80 then Insert(ModuleText, "end", "{extended}"); else Insert(ModuleText, "end", "{luxury}"); end if; Insert (ModuleText, "end", "{" & LF & "Max owners:" & Natural'Image(MaxOwners) & "}"); when ALCHEMY_LAB .. GREENHOUSE => Insert (ModuleText, "end", "{" & LF & "Max workers:" & Natural'Image(MaxOwners) & "}"); when GUN | HARPOON_GUN => Insert (ModuleText, "end", "{" & LF & "Strength:" & Natural'Image(MaxValue) & LF & "Ammunition: }"); MAmount := 0; Ammunition_Info_Loop : for Item of Items_List loop if Item.IType = Items_Types(Value) then if MAmount > 0 then Insert(ModuleText, "end", "{ or }"); end if; Insert(ModuleText, "end", "{" & To_String(Item.Name) & "}"); MAmount := MAmount + 1; end if; end loop Ammunition_Info_Loop; if MType = GUN then Insert(ModuleText, "end", "{" & LF & "}"); if Speed > 0 then Insert (ModuleText, "end", "{Max fire rate:" & Positive'Image(Speed) & "/round}"); else Insert (ModuleText, "end", "{Max fire rate: 1/" & Trim(Integer'Image(abs (Speed)), Both) & " rounds}"); end if; end if; when BATTERING_RAM => Insert (ModuleText, "end", "{" & LF & "Strength:" & Natural'Image(MaxValue) & "}"); when others => null; end case; if MType not in HULL | ARMOR then Insert(ModuleText, "end", "{" & LF & "Size:}"); if Installing then Check_Module_Size_Loop : for Module of Player_Ship.Modules loop if Module.M_Type = HULL and then Size > Modules_List(Module.Proto_Index).Value then Insert (ModuleText, "end", "{" & Natural'Image(Size) & " (needs a bigger hull)} [list red]"); Added := True; exit Check_Module_Size_Loop; end if; end loop Check_Module_Size_Loop; end if; if not Added then Insert(ModuleText, "end", "{" & Natural'Image(Size) & "}"); end if; end if; if Weight > 0 then Insert (ModuleText, "end", "{" & LF & "Weight:" & Natural'Image(Weight) & " kg}"); end if; if Installing then Insert(ModuleText, "end", "{" & LF & "Repair/Upgrade material: }"); MAmount := 0; Repair_Materials_Loop : for Item of Items_List loop if Item.IType = Modules_List(ModuleIndex).RepairMaterial then if MAmount > 0 then Insert(ModuleText, "end", "{ or }"); end if; Insert(ModuleText, "end", "{" & To_String(Item.Name) & "}"); MAmount := MAmount + 1; end if; end loop Repair_Materials_Loop; Insert (ModuleText, "end", "{" & LF & "Repair/Upgrade skill: " & To_String (SkillsData_Container.Element (Skills_List, Modules_List(ModuleIndex).RepairSkill) .Name) & "/" & To_String (AttributesData_Container.Element (Attributes_List, SkillsData_Container.Element (Skills_List, Modules_List(ModuleIndex).RepairSkill) .Attribute) .Name) & "}"); if Modules_List(ModuleIndex).Description /= Null_Unbounded_String then Insert (ModuleText, "end", "{" & LF & LF & To_String(Modules_List(ModuleIndex).Description) & "}"); end if; end if; end SetModuleInfo; -- ****f* ShipyardUI/ShipyardUI.Show_Install_Info_Command -- FUNCTION -- Show information about the selected module to install -- 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. Unused -- SOURCE function Show_Install_Info_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Install_Info_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, Argv); Cost: Positive; MoneyIndex2, UsedSpace, AllSpace, MaxSize: Natural; ModuleDialog: constant Ttk_Frame := Create_Dialog (".moduledialog", To_String(Modules_List(ModuleIndex).Name)); ModuleText: constant Tk_Text := Create(ModuleDialog & ".info", "-height 10 -width 40"); Frame: constant Ttk_Frame := Create(ModuleDialog & ".buttonbox"); CloseButton: constant Ttk_Button := Create (ModuleDialog & ".buttonbox.button", "-text Close -command {CloseDialog " & ModuleDialog & "}"); InstallButton: constant Ttk_Button := Create (ModuleDialog & ".buttonbox.install", "-text Install -command {CloseDialog " & ModuleDialog & ";ManipulateModule install}"); begin Cost := Modules_List(ModuleIndex).Price; Count_Price(Cost, FindMember(Talk)); MoneyIndex2 := FindItem(Player_Ship.Cargo, Money_Index); configure(ModuleText, "-state normal"); Tag_Configure(ModuleText, "red", "-foreground red"); Delete(ModuleText, "1.0", "end"); Insert(ModuleText, "end", "{Install cost:}"); Insert (ModuleText, "end", "{" & Positive'Image(Cost) & " " & To_String(Money_Name) & "}" & (if MoneyIndex2 = 0 or else Player_Ship.Cargo(MoneyIndex2).Amount < Cost then " [list red]" else "")); Insert (ModuleText, "end", "{" & LF & "Installation time:" & Positive'Image(Modules_List(ModuleIndex).InstallTime) & " minutes}"); SetModuleInfo(True); configure (ModuleText, "-state disabled -height" & Positive'Image (Positive'Value(Count(ModuleText, "-displaylines", "0.0", "end")) / Positive'Value(Metrics("InterfaceFont", "-linespace")) + 1)); Tcl.Tk.Ada.Grid.Grid(ModuleText, "-padx 5 -pady {5 0}"); Tcl.Tk.Ada.Grid.Grid(InstallButton, "-padx {0 5}"); Find_Hull_Loop : for Module of Player_Ship.Modules loop if Module.M_Type = HULL then MaxSize := Modules_List(Module.Proto_Index).Value; UsedSpace := Module.Installed_Modules; AllSpace := Module.Max_Modules; exit Find_Hull_Loop; end if; end loop Find_Hull_Loop; if MoneyIndex2 = 0 then configure(InstallButton, "-state disabled"); else if Player_Ship.Cargo(MoneyIndex2).Amount < Cost or ((Modules_List(ModuleIndex).MType not in GUN | HARPOON_GUN | HULL) and ((AllSpace - UsedSpace) < Modules_List(ModuleIndex).Size or Modules_List(ModuleIndex).Size > MaxSize)) or (Modules_List(ModuleIndex).MType = HULL and Modules_List(ModuleIndex).MaxValue < UsedSpace) then configure(InstallButton, "-state disabled"); else configure(InstallButton, "-state !disabled"); end if; end if; Tcl.Tk.Ada.Grid.Grid(CloseButton, "-row 0 -column 1 -padx {5 0}"); Tcl.Tk.Ada.Grid.Grid(Frame, "-pady {0 5}"); Focus(CloseButton); Bind(CloseButton, "<Tab>", "{focus " & InstallButton & ";break}"); Bind(ModuleDialog, "<Escape>", "{" & CloseButton & " invoke;break}"); Bind(CloseButton, "<Escape>", "{" & CloseButton & " invoke;break}"); Show_Dialog(Dialog => ModuleDialog, Relative_Y => 0.2); return TCL_OK; end Show_Install_Info_Command; -- ****f* ShipyardUI/ShipyardUI.Manipulate_Module_Command -- FUNCTION -- Install or remove the selected module -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. Unused -- SOURCE function Manipulate_Module_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Manipulate_Module_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Argc); begin if CArgv.Arg(Argv, 1) = "install" then Bases.Ship.Upgrade_Ship(True, ModuleIndex); else Bases.Ship.Upgrade_Ship(False, ModuleIndex); end if; Update_Messages; return Show_Shipyard_Command (ClientData, Interp, 2, CArgv.Empty & "ShowShipyard" & "0"); exception when Trade_No_Money => ShowMessage (Text => "You don't have " & To_String(Money_Name) & " to pay for modules.", Title => "Can't install module"); return TCL_OK; when An_Exception : Trade_Not_Enough_Money => ShowMessage (Text => "You don't have enough " & To_String(Money_Name) & " to pay for " & Exception_Message(An_Exception) & ".", Title => "Can't install module"); return TCL_OK; when An_Exception : Bases_Ship_Unique_Module => ShowMessage (Text => "You can't install another " & Exception_Message(An_Exception) & " because you have installed one module that type. Remove old first.", Title => "Can't install module"); return TCL_OK; when An_Exception : Bases_Ship_Installation_Error | Bases_Ship_Removing_Error => ShowMessage (Text => Exception_Message(An_Exception), Title => "Can't" & (if CArgv.Arg(Argv, 1) = "install" then "install" else "remove") & " module"); return TCL_OK; when Trade_No_Free_Cargo => ShowMessage (Text => "You don't have enough free space for " & To_String(Money_Name) & " in ship cargo.", Title => "Can't remove module"); return TCL_OK; when Trade_No_Money_In_Base => ShowMessage (Text => "Base don't have enough " & To_String(Money_Name) & " for buy this module.", Title => "Can't remove module"); return TCL_OK; end Manipulate_Module_Command; -- ****f* ShipyardUI/ShipyardUI.Show_Remove_Info_Command -- FUNCTION -- Show information about the selected module to remove -- 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. Unused -- SOURCE function Show_Remove_Info_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Remove_Info_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, Argv); Cost: Natural; Damage: Float; ShipModuleIndex: constant Natural := Natural'Value(To_String(ModuleIndex)); ModuleDialog: constant Ttk_Frame := Create_Dialog (".moduledialog", To_String(Player_Ship.Modules(ShipModuleIndex).Name)); DamageBar: constant Ttk_ProgressBar := Create(ModuleDialog & ".damage"); ModuleText: constant Tk_Text := Create(ModuleDialog & ".info", "-height 10 -width 40"); Label: Ttk_Label := Create(ModuleDialog & ".damagelbl"); RemoveButton, CloseButton: Ttk_Button; Frame: constant Ttk_Frame := Create(ModuleDialog & ".buttonbox"); begin Tcl.Tk.Ada.Busy.Busy(Game_Header); Tcl.Tk.Ada.Busy.Busy(Main_Paned); Damage := 1.0 - Float(Player_Ship.Modules(ShipModuleIndex).Durability) / Float(Player_Ship.Modules(ShipModuleIndex).Max_Durability); Cost := Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index).Price - Integer (Float (Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Price) * Damage); if Cost = 0 then Cost := 1; end if; Count_Price(Cost, FindMember(Talk), False); Tcl.Tk.Ada.Grid.Grid(ModuleText, "-padx 5 -pady {5 0}"); configure(ModuleText, "-state normal"); Delete(ModuleText, "1.0", "end"); Insert (ModuleText, "end", "{Remove gain:" & Positive'Image(Cost) & LF & "Removing time:" & Positive'Image (Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .InstallTime) & " minutes}"); SetModuleInfo(False); if Damage > 0.0 then configure(DamageBar, "-value" & Float'Image(Damage)); if Damage < 0.2 then configure(Label, "-text {Damage: Slightly damaged}"); elsif Damage < 0.5 then configure(Label, "-text {Damage: Damaged}"); elsif Damage < 0.8 then configure(Label, "-text {Damage: Heavily damaged}"); elsif Damage < 1.0 then configure(Label, "-text {Damage: Almost destroyed}"); else configure(Label, "-text {Damage: Destroyed}"); end if; Tcl.Tk.Ada.Grid.Grid(Label); Tcl.Tk.Ada.Grid.Grid(DamageBar); end if; if Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Description /= Null_Unbounded_String then Label := Create (ModuleDialog & ".description", "-text {" & LF & To_String (Modules_List(Player_Ship.Modules(ShipModuleIndex).Proto_Index) .Description) & "} -wraplength 450"); Tcl.Tk.Ada.Grid.Grid(Label, "-sticky w -padx 5"); end if; configure (ModuleText, "-state disabled -height" & Positive'Image (Positive'Value(Count(ModuleText, "-displaylines", "0.0", "end")) / Positive'Value(Metrics("InterfaceFont", "-linespace")) + 1)); RemoveButton := Create (ModuleDialog & ".buttonbox.install", "-text Remove -command {CloseDialog " & ModuleDialog & ";ManipulateModule remove}"); Tcl.Tk.Ada.Grid.Grid(RemoveButton, "-padx {0 5}"); CloseButton := Create (ModuleDialog & ".buttonbox.button", "-text Close -command {CloseDialog " & ModuleDialog & "}"); Tcl.Tk.Ada.Grid.Grid(CloseButton, "-row 0 -column 1 -padx {5 0}"); Tcl.Tk.Ada.Grid.Grid(Frame, "-pady {0 5}"); Focus(CloseButton); Bind(CloseButton, "<Tab>", "{focus " & RemoveButton & ";break}"); Bind(ModuleDialog, "<Escape>", "{" & CloseButton & " invoke;break}"); Bind(CloseButton, "<Escape>", "{" & CloseButton & " invoke;break}"); Show_Dialog(Dialog => ModuleDialog, Relative_Y => 0.2); return TCL_OK; end Show_Remove_Info_Command; -- ****o* ShipyardUI/ShipyardUI.Show_Module_Menu_Command -- FUNCTION -- Show menu with actions for the selected module -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- 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 -- ShowModuleMenu moduleindex actiontype -- ModuleIndex is a index of the module which menu will be shown, -- actiontype is action related to the module. Can be install or remove. -- SOURCE function Show_Module_Menu_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Module_Menu_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Argc); ModuleMenu: Tk_Menu := Get_Widget(".modulemenu", Interp); begin ModuleIndex := To_Unbounded_String(CArgv.Arg(Argv, 1)); if Winfo_Get(ModuleMenu, "exists") = "0" then ModuleMenu := Create(".modulemenu", "-tearoff false"); end if; Delete(ModuleMenu, "0", "end"); if CArgv.Arg(Argv, 2) = "install" then Menu.Add (ModuleMenu, "command", "-label {Show module details} -command {ShowInstallInfo}"); Menu.Add (ModuleMenu, "command", "-label {Install module} -command {ManipulateModule install}"); else Menu.Add (ModuleMenu, "command", "-label {Show module details} -command {ShowRemoveInfo}"); Menu.Add (ModuleMenu, "command", "-label {Remove module} -command {ManipulateModule remove}"); end if; Tk_Popup (ModuleMenu, Winfo_Get(Get_Main_Window(Interp), "pointerx"), Winfo_Get(Get_Main_Window(Interp), "pointery")); return TCL_OK; end Show_Module_Menu_Command; -- ****o* ShipyardUI/ShipyardUI.Show_Shipyard_Tab_Command -- FUNCTION -- Show the install or remove modules options in shipyard -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. Unused -- RESULT -- This function always return TCL_OK -- COMMANDS -- ShowShipyardTab -- SOURCE function Show_Shipyard_Tab_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Shipyard_Tab_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Argc, Argv); ShipyardCanvas: constant Tk_Canvas := Get_Widget(Main_Paned & ".shipyardframe.canvas", Interp); ShipyardFrame: constant Ttk_Frame := Get_Widget(ShipyardCanvas & ".shipyard"); Frame: Ttk_Frame; begin if Tcl_GetVar(Interp, "newtab") = "install" then Frame := Get_Widget(ShipyardFrame & ".remove"); Tcl.Tk.Ada.Grid.Grid_Remove(Frame); Frame := Get_Widget(ShipyardFrame & ".install"); Tcl.Tk.Ada.Grid.Grid(Frame); else Frame := Get_Widget(ShipyardFrame & ".install"); Tcl.Tk.Ada.Grid.Grid_Remove(Frame); Frame := Get_Widget(ShipyardFrame & ".remove"); Tcl.Tk.Ada.Grid.Grid(Frame); end if; Delete(ShipyardCanvas, "all"); Canvas_Create (ShipyardCanvas, "window", "0 0 -anchor nw -window " & Widget_Image(ShipyardFrame)); Tcl_Eval(Interp, "update"); configure (ShipyardCanvas, "-scrollregion [list " & BBox(ShipyardCanvas, "all") & "]"); Tcl_SetResult(Interp, "1"); return TCL_OK; end Show_Shipyard_Tab_Command; -- ****it* ShipyardUI/ShipyardUI.Modules_Sort_Orders -- FUNCTION -- Sorting orders for the ship modules list -- OPTIONS -- NAMEASC - Sort modules by name ascending -- NAMEDESC - Sort modules by name descending -- TYPEASC - Sort modules by type ascending -- TYPEDESC - Sort modules by type descending -- SIZEASC - Sort modules by size ascending -- SIZEDESC - Sort modules by size descending -- MATERIALASC - Sort modules by material ascending -- MATERIALDESC - Sort modules by material descending -- PRICEASC - Sort modules by price ascending -- PRICEDESC - Sort modules by price descending -- NONE - No sorting modules (default) -- HISTORY -- 6.4 - Added -- SOURCE type Modules_Sort_Orders is (NAMEASC, NAMEDESC, TYPEASC, TYPEDESC, SIZEASC, SIZEDESC, MATERIALASC, MATERIALDESC, PRICEASC, PRICEDESC, NONE) with Default_Value => NONE; -- **** -- ****id* ShipyardUI/ShipyardUI.Default_Modules_Sort_Order -- FUNCTION -- Default sorting order for the player's ship's modules -- HISTORY -- 6.4 - Added -- SOURCE Default_Modules_Sort_Order: constant Modules_Sort_Orders := NONE; -- **** -- ****iv* ShipyardUI/ShipyardUI.Modules_Sort_Order -- FUNCTION -- The current sorting order for modules list -- HISTORY -- 6.4 - Added -- SOURCE Modules_Sort_Order: Modules_Sort_Orders := Default_Modules_Sort_Order; -- **** -- ****o* ShipyardUI/ShipyardUI.Sort_Modules_Command -- FUNCTION -- Sort the ship modules lists -- PARAMETERS -- ClientData - Custom data send to the command. -- Interp - Tcl interpreter in which command was executed. -- 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 -- SortShipModules x -- X is X axis coordinate where the player clicked the mouse button -- SOURCE function Sort_Modules_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_Modules_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Argc); Column: constant Positive := Get_Column_Number ((if CArgv.Arg(Argv, 1) = "install" then InstallTable else RemoveTable), Natural'Value(CArgv.Arg(Argv, 4))); type Local_Module_Data is record Name: Unbounded_String; MType: Unbounded_String; Size: Natural; Material: Unbounded_String; Price: Positive; Id: Unbounded_String; end record; type Modules_Array is array(Positive range <>) of Local_Module_Data; Local_Modules: Modules_Array (1 .. Positive ((if CArgv.Arg(Argv, 1) = "install" then Modules_List.Length else Player_Ship.Modules.Length))); Index: Positive := 1; Cost: Natural; Damage: Float; function "<"(Left, Right: Local_Module_Data) return Boolean is begin if Modules_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Modules_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Modules_Sort_Order = TYPEASC and then Left.MType < Right.MType then return True; end if; if Modules_Sort_Order = TYPEDESC and then Left.MType > Right.MType then return True; end if; if Modules_Sort_Order = SIZEASC and then Left.Size < Right.Size then return True; end if; if Modules_Sort_Order = SIZEDESC and then Left.Size > Right.Size then return True; end if; if Modules_Sort_Order = MATERIALASC and then Left.Material < Right.Material then return True; end if; if Modules_Sort_Order = MATERIALDESC and then Left.Material > Right.Material then return True; end if; if Modules_Sort_Order = PRICEASC and then Left.Price < Right.Price then return True; end if; if Modules_Sort_Order = PRICEDESC and then Left.Price > Right.Price then return True; end if; return False; end "<"; procedure Sort_Modules is new Ada.Containers.Generic_Array_Sort (Index_Type => Positive, Element_Type => Local_Module_Data, Array_Type => Modules_Array); begin case Column is when 1 => if Modules_Sort_Order = NAMEASC then Modules_Sort_Order := NAMEDESC; else Modules_Sort_Order := NAMEASC; end if; when 2 => if Modules_Sort_Order = TYPEASC then Modules_Sort_Order := TYPEDESC; else Modules_Sort_Order := TYPEASC; end if; when 3 => if Modules_Sort_Order = SIZEASC then Modules_Sort_Order := SIZEDESC; else Modules_Sort_Order := SIZEASC; end if; when 4 => if Modules_Sort_Order = MATERIALASC then Modules_Sort_Order := MATERIALDESC; else Modules_Sort_Order := MATERIALASC; end if; when 5 => if Modules_Sort_Order = PRICEASC then Modules_Sort_Order := PRICEDESC; else Modules_Sort_Order := PRICEASC; end if; when others => null; end case; if Modules_Sort_Order = NONE then return TCL_OK; end if; if CArgv.Arg(Argv, 1) = "install" then for I in Modules_List.Iterate loop Cost := Modules_List(I).Price; Count_Price(Cost, FindMember(Talk)); if Cost = 0 then Cost := 1; end if; Local_Modules(Index) := (Name => Modules_List(I).Name, MType => To_Unbounded_String (GetModuleType(BaseModules_Container.Key(I))), Size => (if Modules_List(I).MType = HULL then Modules_List(I).MaxValue else Modules_List(I).Size), Material => Modules_List(I).RepairMaterial, Price => Cost, Id => BaseModules_Container.Key(I)); Index := Index + 1; end loop; else for I in Player_Ship.Modules.Iterate loop Damage := 1.0 - Float(Player_Ship.Modules(I).Durability) / Float(Player_Ship.Modules(I).Max_Durability); Cost := Modules_List(Player_Ship.Modules(I).Proto_Index).Price - Integer (Float (Modules_List(Player_Ship.Modules(I).Proto_Index).Price) * Damage); if Cost = 0 then Cost := 1; end if; Count_Price(Cost, FindMember(Talk), False); Local_Modules(Index) := (Name => Player_Ship.Modules(I).Name, MType => To_Unbounded_String (GetModuleType(Player_Ship.Modules(I).Proto_Index)), Size => Modules_List(Player_Ship.Modules(I).Proto_Index).Size, Material => Modules_List(Player_Ship.Modules(I).Proto_Index) .RepairMaterial, Price => Cost, Id => To_Unbounded_String (Positive'Image(Modules_Container.To_Index(I)))); Index := Index + 1; end loop; end if; Sort_Modules(Local_Modules); if CArgv.Arg(Argv, 1) = "install" then Install_Indexes.Clear; for Module of Local_Modules loop Install_Indexes.Append(Module.Id); end loop; else Remove_Indexes.Clear; for Module of Local_Modules loop Remove_Indexes.Append(Positive'Value(To_String(Module.Id))); end loop; end if; return Show_Shipyard_Command (ClientData, Interp, 3, CArgv.Empty & "ShowShipyard" & CArgv.Arg(Argv, 2) & CArgv.Arg(Argv, 3)); end Sort_Modules_Command; procedure AddCommands is begin Add_Command("ShowShipyard", Show_Shipyard_Command'Access); Add_Command("ShowInstallInfo", Show_Install_Info_Command'Access); Add_Command("ManipulateModule", Manipulate_Module_Command'Access); Add_Command("ShowRemoveInfo", Show_Remove_Info_Command'Access); Add_Command("ShowShipyardModuleMenu", Show_Module_Menu_Command'Access); Add_Command("ShowShipyardTab", Show_Shipyard_Tab_Command'Access); Add_Command("SortShipyardModules", Sort_Modules_Command'Access); end AddCommands; end Bases.ShipyardUI;
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.EXTI is pragma Preelaborate; --------------- -- Registers -- --------------- -- IMR_MR array type IMR_MR_Field_Array is array (0 .. 22) of Boolean with Component_Size => 1, Size => 23; -- Type definition for IMR_MR type IMR_MR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MR as a value Val : HAL.UInt23; when True => -- MR as an array Arr : IMR_MR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for IMR_MR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- Interrupt mask register (EXTI_IMR) type IMR_Register is record -- Interrupt Mask on line 0 MR : IMR_MR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IMR_Register use record MR at 0 range 0 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; -- EMR_MR array type EMR_MR_Field_Array is array (0 .. 22) of Boolean with Component_Size => 1, Size => 23; -- Type definition for EMR_MR type EMR_MR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- MR as a value Val : HAL.UInt23; when True => -- MR as an array Arr : EMR_MR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for EMR_MR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- Event mask register (EXTI_EMR) type EMR_Register is record -- Event Mask on line 0 MR : EMR_MR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EMR_Register use record MR at 0 range 0 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; -- RTSR_TR array type RTSR_TR_Field_Array is array (0 .. 22) of Boolean with Component_Size => 1, Size => 23; -- Type definition for RTSR_TR type RTSR_TR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : HAL.UInt23; when True => -- TR as an array Arr : RTSR_TR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for RTSR_TR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- Rising Trigger selection register (EXTI_RTSR) type RTSR_Register is record -- Rising trigger event configuration of line 0 TR : RTSR_TR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RTSR_Register use record TR at 0 range 0 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; -- FTSR_TR array type FTSR_TR_Field_Array is array (0 .. 22) of Boolean with Component_Size => 1, Size => 23; -- Type definition for FTSR_TR type FTSR_TR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TR as a value Val : HAL.UInt23; when True => -- TR as an array Arr : FTSR_TR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for FTSR_TR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- Falling Trigger selection register (EXTI_FTSR) type FTSR_Register is record -- Falling trigger event configuration of line 0 TR : FTSR_TR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FTSR_Register use record TR at 0 range 0 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; -- SWIER array type SWIER_Field_Array is array (0 .. 22) of Boolean with Component_Size => 1, Size => 23; -- Type definition for SWIER type SWIER_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SWIER as a value Val : HAL.UInt23; when True => -- SWIER as an array Arr : SWIER_Field_Array; end case; end record with Unchecked_Union, Size => 23; for SWIER_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- Software interrupt event register (EXTI_SWIER) type SWIER_Register is record -- Software Interrupt on line 0 SWIER : SWIER_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SWIER_Register use record SWIER at 0 range 0 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; -- PR array type PR_Field_Array is array (0 .. 22) of Boolean with Component_Size => 1, Size => 23; -- Type definition for PR type PR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PR as a value Val : HAL.UInt23; when True => -- PR as an array Arr : PR_Field_Array; end case; end record with Unchecked_Union, Size => 23; for PR_Field use record Val at 0 range 0 .. 22; Arr at 0 range 0 .. 22; end record; -- Pending register (EXTI_PR) type PR_Register is record -- Pending bit 0 PR : PR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PR_Register use record PR at 0 range 0 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- External interrupt/event controller type EXTI_Peripheral is record -- Interrupt mask register (EXTI_IMR) IMR : aliased IMR_Register; -- Event mask register (EXTI_EMR) EMR : aliased EMR_Register; -- Rising Trigger selection register (EXTI_RTSR) RTSR : aliased RTSR_Register; -- Falling Trigger selection register (EXTI_FTSR) FTSR : aliased FTSR_Register; -- Software interrupt event register (EXTI_SWIER) SWIER : aliased SWIER_Register; -- Pending register (EXTI_PR) PR : aliased PR_Register; end record with Volatile; for EXTI_Peripheral use record IMR at 16#0# range 0 .. 31; EMR at 16#4# range 0 .. 31; RTSR at 16#8# range 0 .. 31; FTSR at 16#C# range 0 .. 31; SWIER at 16#10# range 0 .. 31; PR at 16#14# range 0 .. 31; end record; -- External interrupt/event controller EXTI_Periph : aliased EXTI_Peripheral with Import, Address => System'To_Address (16#40013C00#); end STM32_SVD.EXTI;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . T E X T _ I O -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2006 The European Space Agency -- -- Copyright (C) 2003-2013, AdaCore -- -- -- -- GNARL 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. GNARL 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ package body System.Text_IO is ----------- -- Local -- ----------- Control_Register_Address : constant System.Address := 16#1F80000#; UART_Channel_A_Rx_Tx_Register_Address : constant System.Address := 16#01F800E0#; UART_Status_Register_Address : constant System.Address := 16#01F800E8#; type Scaler_8 is mod 2 ** 8; for Scaler_8'Size use 8; -- 8-bit scaler type Reserved_8 is array (0 .. 7) of Boolean; for Reserved_8'Size use 8; pragma Pack (Reserved_8); type Reserved_24 is array (0 .. 23) of Boolean; for Reserved_24'Size use 24; pragma Pack (Reserved_24); type Control_Register is record PRD : Boolean; -- Power-down 1 : enabled (allowed) 0 : disabled r/w SWR : Boolean; -- Software reset 1 : enabled (allowed) 0 : disabled r/w BTO : Boolean; -- Bus timeout 1 : enabled 0 : disabled r/w BP : Boolean; -- Block protection instead of normal access protection -- 1 : enabled 0 : disabled r/w WDCS : Boolean; -- Watchdog clock supply -- 1 : external clock with prescaler (divide by 16) -- 0 : external clock, no prescaler r/w IUEMMSK : Boolean; -- IU Error Mode Mask 1 : Error masked (= disabled) -- 0 : Error not masked r/w RHIUEM : Boolean; -- Reset or Halt when IU error mode (ERROR*) -- 1 : Reset 0 : Halt r/w IUHEMSK : Boolean; -- IU Hardware Error Mask -- 1 : Error masked (= disabled) 0 : Error not masked r/w RHIUHE : Boolean; -- Reset or Halt when IU Hardware Error (HWERR*) -- 1 : Reset 0 : Halt r/w IUCMPMSK : Boolean; -- IU Comparison Error Mask -- 1 : Error masked (= disabled) 0 : Error not masked r/w RHIUCMP : Boolean; -- Reset or Halt when IU comparison error 1 : Reset 0 : Halt r/w FPUCMPMSK : Boolean; -- FPU Comparison Error Mask -- 1 : Error masked (= disabled) 0 : Error not masked r/w RHFPUCMP : Boolean; -- Reset or Halt when FPU comparison error -- 1 : Reset 0 : Halt r/w MECHEMSK : Boolean; -- MEC HW Error Mask -- 1 : Error masked (= disabled) 0 : Error not masked r/w RHMECHE : Boolean; -- Reset or Halt when MEC HW Error (MECHWERR) -- 1 : Reset 0 : Halt r/w RESERVED : Boolean; -- Not used r DMAE : Boolean; -- 1 DMA 1 : enabled 0 : disabled r/w DPE : Boolean; -- DMA Parity Enabled 1 : enabled 0 : disabled r/w DST : Boolean; -- DMA session timeout 1 : enabled 0 : disabled r/w UBR : Boolean; -- UART baud rate(1) -- 1 : No change of UART scaler baudrate -- 0 : Divide UART scaler baudrate by two r/w UPE : Boolean; -- UART parity enable -- 1 : parity enabled 0 : no parity r/w UP : Boolean; -- UART parity 1 : odd parity 0 : even parity r/w USB : Boolean; -- UART stop bits 1 : two stop bits 0 : one stop bit r/w UCS : Boolean; -- UART clock supply 1 : system clock 0 : external clock r/w UART_Scaler : Scaler_8; -- 1 - 255 : Divide factor (1) 0: stops the UART clock r/w end record; for Control_Register use record PRD at 0 range 31 .. 31; SWR at 0 range 30 .. 30; BTO at 0 range 29 .. 29; BP at 0 range 28 .. 28; WDCS at 0 range 27 .. 27; IUEMMSK at 0 range 26 .. 26; RHIUEM at 0 range 25 .. 25; IUHEMSK at 0 range 24 .. 24; RHIUHE at 0 range 23 .. 23; IUCMPMSK at 0 range 22 .. 22; RHIUCMP at 0 range 21 .. 21; FPUCMPMSK at 0 range 20 .. 20; RHFPUCMP at 0 range 19 .. 19; MECHEMSK at 0 range 18 .. 18; RHMECHE at 0 range 17 .. 17; RESERVED at 0 range 16 .. 16; DMAE at 0 range 15 .. 15; DPE at 0 range 14 .. 14; DST at 0 range 13 .. 13; UBR at 0 range 12 .. 12; UPE at 0 range 11 .. 11; UP at 0 range 10 .. 10; USB at 0 range 9 .. 9; UCS at 0 range 8 .. 8; UART_scaler at 0 range 0 .. 7; end record; for Control_Register'Size use 32; pragma Suppress_Initialization (Control_Register); Control : Control_Register; pragma Atomic (Control); for Control'Address use Control_Register_Address; type UART_Channel_Rx_Tx_Register is record RTD : Character; -- Rx/Tx Data r/w Reserved24 : Reserved_24; -- Not used r end record; for UART_Channel_Rx_Tx_Register use record RTD at 0 range 24 .. 31; Reserved24 at 0 range 0 .. 23; end record; for UART_Channel_Rx_Tx_Register'Size use 32; pragma Suppress_Initialization (UART_Channel_Rx_Tx_Register); UART_Channel_A : UART_Channel_Rx_Tx_Register; pragma Atomic (UART_Channel_A); for UART_Channel_A'Address use UART_Channel_A_Rx_Tx_Register_Address; type UART_Status_Register is record DRA : Boolean; -- Data Ready in channel A r TSEA : Boolean; -- Transmitter A Send register Empty (no data to send) r THEA : Boolean; -- Transmitter A Holding register Empty (ready to load data) r Reserved1A : Boolean; -- Not used r FEA : Boolean; -- Framing Error in receiver A r PEA : Boolean; -- Parity Error in receiver A r OEA : Boolean; -- Overrun Error in receiver A r CUA : Boolean; -- Clear UART A (bit read as zero) r/w Reserved8A : Reserved_8; -- Not used r DRB : Boolean; -- Data Ready in channel B r TSEB : Boolean; -- Transmitter B Send register Empty (no data to send) r THEB : Boolean; -- Transmitter B Holding register Empty (ready to load data) r Reserved1B : Boolean; -- Not used r FEB : Boolean; -- Framing Error in receiver B r PEB : Boolean; -- Parity Error in receiver B r OEB : Boolean; -- Overrun Error in receiver B r CUB : Boolean; -- Clear UART B (bit read as zero) r/w Reserved8B : Reserved_8; -- Not used r end record; for UART_Status_Register use record DRA at 0 range 31 .. 31; TSEA at 0 range 30 .. 30; THEA at 0 range 29 .. 29; Reserved1A at 0 range 28 .. 28; FEA at 0 range 27 .. 27; PEA at 0 range 26 .. 26; OEA at 0 range 25 .. 25; CUA at 0 range 24 .. 24; Reserved8A at 0 range 16 .. 23; DRB at 0 range 15 .. 15; TSEB at 0 range 14 .. 14; THEB at 0 range 13 .. 13; Reserved1B at 0 range 12 .. 12; FEB at 0 range 11 .. 11; PEB at 0 range 10 .. 10; OEB at 0 range 9 .. 9; CUB at 0 range 8 .. 8; Reserved8B at 0 range 0 .. 7; end record; for UART_Status_Register'Size use 32; pragma Suppress_Initialization (UART_Status_Register); UART_Status : UART_Status_Register; pragma Atomic (UART_Status); for UART_Status'Address use UART_Status_Register_Address; Clock_Frequency : constant Natural; -- Hertz pragma Import (Asm, Clock_Frequency, "clock_frequency"); -- Frequency of the system clock --------- -- Get -- --------- function Get return Character is begin -- Will never be called raise Program_Error; return ASCII.NUL; end Get; ---------------- -- Initialize -- ---------------- procedure Initialize is Control_Aux : Control_Register; Scaler_Aux : Scaler_8; begin -- Initialize the UART1 as output console -- Read the Control Register Control_Aux := Control; -- Set the UART scaler according to the baudrate given Scaler_Aux := Scaler_8 (Clock_Frequency / (32 * 115200 * 2)); Control_Aux.UART_Scaler := Scaler_8'Max (Scaler_Aux - 1, 1); Control_Aux.UBR := False; Control_Aux.UPE := False; Control_Aux.USB := False; Control_Aux.UCS := True; -- Write to the Control Register in the MEC Control := Control_Aux; Initialized := True; end Initialize; ----------------- -- Is_Rx_Ready -- ----------------- function Is_Rx_Ready return Boolean is begin return False; end Is_Rx_Ready; ----------------- -- Is_Tx_Ready -- ----------------- function Is_Tx_Ready return Boolean is UART_Status_Aux : constant UART_Status_Register := UART_Status; begin return UART_Status_Aux.THEA; end Is_Tx_Ready; --------- -- Put -- --------- procedure Put (C : Character) is UART_Tx : constant UART_Channel_Rx_Tx_Register := (RTD => C, Reserved24 => (others => False)); begin UART_Channel_A := UART_Tx; end Put; ---------------------------- -- Use_Cr_Lf_For_New_Line -- ---------------------------- function Use_Cr_Lf_For_New_Line return Boolean is begin return True; end Use_Cr_Lf_For_New_Line; end System.Text_IO;
-- generated parser support file. -- command line: wisitoken-bnf-generate.exe --generate LR1 Ada_Emacs re2c PROCESS text_rep ada.wy -- -- Copyright (C) 2013 - 2019 Free Software Foundation, Inc. -- 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, or (at -- your option) any later version. -- -- This software 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. with WisiToken.Syntax_Trees; with WisiToken.Lexer; with WisiToken.Semantic_Checks; package Ada_Process_Actions is Descriptor : aliased WisiToken.Descriptor := (First_Terminal => 3, Last_Terminal => 108, First_Nonterminal => 109, Last_Nonterminal => 333, EOI_ID => 108, Accept_ID => 109, Case_Insensitive => True, New_Line_ID => 1, String_1_ID => 107, String_2_ID => 106, Image => (new String'("WHITESPACE"), new String'("NEW_LINE"), new String'("COMMENT"), new String'("ABS"), new String'("ACCEPT"), new String'("ABORT"), new String'("ABSTRACT"), new String'("ACCESS"), new String'("ALIASED"), new String'("ALL"), new String'("AND"), new String'("ARRAY"), new String'("AT"), new String'("BEGIN"), new String'("BODY"), new String'("CASE"), new String'("CONSTANT"), new String'("DECLARE"), new String'("DELAY"), new String'("DELTA"), new String'("DIGITS"), new String'("DO"), new String'("ELSE"), new String'("ELSIF"), new String'("END"), new String'("ENTRY"), new String'("EXCEPTION"), new String'("EXIT"), new String'("FOR"), new String'("FUNCTION"), new String'("GENERIC"), new String'("GOTO"), new String'("IF"), new String'("IN"), new String'("INTERFACE"), new String'("IS"), new String'("LIMITED"), new String'("LOOP"), new String'("MOD"), new String'("NEW"), new String'("NOT"), new String'("NULL"), new String'("OF"), new String'("OR"), new String'("OTHERS"), new String'("OUT"), new String'("OVERRIDING"), new String'("PACKAGE"), new String'("PRAGMA"), new String'("PRIVATE"), new String'("PROCEDURE"), new String'("PROTECTED"), new String'("RAISE"), new String'("RANGE"), new String'("RECORD"), new String'("REM"), new String'("RENAMES"), new String'("REQUEUE"), new String'("RETURN"), new String'("REVERSE"), new String'("SEPARATE"), new String'("SELECT"), new String'("SOME"), new String'("SUBTYPE"), new String'("SYNCHRONIZED"), new String'("TAGGED"), new String'("TASK"), new String'("TERMINATE"), new String'("THEN"), new String'("TYPE"), new String'("UNTIL"), new String'("USE"), new String'("WHEN"), new String'("WHILE"), new String'("WITH"), new String'("XOR"), new String'("LEFT_PAREN"), new String'("RIGHT_PAREN"), new String'("AMPERSAND"), new String'("AT_SIGN"), new String'("BAR"), new String'("BOX"), new String'("COLON"), new String'("COLON_EQUAL"), new String'("COMMA"), new String'("DOT"), new String'("DOT_DOT"), new String'("EQUAL"), new String'("EQUAL_GREATER"), new String'("GREATER"), new String'("GREATER_EQUAL"), new String'("GREATER_GREATER"), new String'("LESS"), new String'("LESS_EQUAL"), new String'("LESS_LESS"), new String'("MINUS"), new String'("PLUS"), new String'("SEMICOLON"), new String'("SLASH"), new String'("SLASH_EQUAL"), new String'("STAR"), new String'("STAR_STAR"), new String'("TICK_1"), new String'("TICK_2"), new String'("NUMERIC_LITERAL"), new String'("IDENTIFIER"), new String'("STRING_LITERAL"), new String'("CHARACTER_LITERAL"), new String'("Wisi_EOI"), new String'("wisitoken_accept"), new String'("abstract_limited_synchronized_opt"), new String'("abstract_limited_opt"), new String'("abstract_tagged_limited_opt"), new String'("abstract_subprogram_declaration"), new String'("accept_statement"), new String'("access_definition"), new String'("actual_parameter_part"), new String'("actual_parameter_part_opt"), new String'("aggregate"), new String'("aliased_opt"), new String'("and_interface_list_opt"), new String'("array_type_definition"), new String'("aspect_clause"), new String'("aspect_specification_opt"), new String'("assignment_statement"), new String'("association_opt"), new String'("association_list"), new String'("asynchronous_select"), new String'("at_clause"), new String'("attribute_reference"), new String'("attribute_designator"), new String'("binary_adding_operator"), new String'("block_label"), new String'("block_label_opt"), new String'("block_statement"), new String'("body_g"), new String'("body_stub"), new String'("case_expression"), new String'("case_expression_alternative"), new String'("case_expression_alternative_list"), new String'("case_statement"), new String'("case_statement_alternative"), new String'("case_statement_alternative_list"), new String'("compilation_unit"), new String'("compilation_unit_list"), new String'("component_clause"), new String'("component_clause_list"), new String'("component_declaration"), new String'("component_definition"), new String'("component_item"), new String'("component_list"), new String'("component_list_opt"), new String'("compound_statement"), new String'("conditional_entry_call"), new String'("conditional_quantified_expression"), new String'("constant_opt"), new String'("constraint"), new String'("constraint_opt"), new String'("declaration"), new String'("declarations"), new String'("declarative_part_opt"), new String'("delay_alternative"), new String'("delay_statement"), new String'("derived_type_definition"), new String'("direct_name"), new String'("direct_name_opt"), new String'("discrete_choice"), new String'("discrete_choice_list"), new String'("discrete_subtype_definition"), new String'("discrete_subtype_definition_list"), new String'("discriminant_part_opt"), new String'("discriminant_specification_opt"), new String'("discriminant_specification_list"), new String'("elsif_expression_item"), new String'("elsif_expression_list"), new String'("elsif_statement_item"), new String'("elsif_statement_list"), new String'("entry_body"), new String'("entry_body_formal_part"), new String'("entry_call_alternative"), new String'("entry_declaration"), new String'("enumeration_literal"), new String'("enumeration_literal_list"), new String'("enumeration_representation_clause"), new String'("enumeration_type_definition"), new String'("exception_choice"), new String'("exception_choice_list"), new String'("exception_declaration"), new String'("exception_handler"), new String'("exception_handler_list"), new String'("exception_handler_list_opt"), new String'("exit_statement"), new String'("expression"), new String'("expression_opt"), new String'("expression_function_declaration"), new String'("extended_return_object_declaration"), new String'("extended_return_object_declaration_opt"), new String'("extended_return_statement"), new String'("factor"), new String'("formal_object_declaration"), new String'("formal_part"), new String'("formal_subprogram_declaration"), new String'("formal_type_declaration"), new String'("formal_type_definition"), new String'("formal_derived_type_definition"), new String'("formal_package_declaration"), new String'("formal_package_actual_part"), new String'("full_type_declaration"), new String'("function_specification"), new String'("general_access_modifier_opt"), new String'("generic_declaration"), new String'("generic_formal_part"), new String'("generic_formal_parameter_declarations"), new String'("generic_formal_parameter_declaration"), new String'("generic_instantiation"), new String'("generic_package_declaration"), new String'("generic_renaming_declaration"), new String'("generic_subprogram_declaration"), new String'("goto_label"), new String'("handled_sequence_of_statements"), new String'("identifier_list"), new String'("identifier_opt"), new String'("if_expression"), new String'("if_statement"), new String'("incomplete_type_declaration"), new String'("index_constraint"), new String'("index_subtype_definition"), new String'("index_subtype_definition_list"), new String'("interface_list"), new String'("interface_type_definition"), new String'("iteration_scheme"), new String'("iterator_specification"), new String'("iterator_specification_opt"), new String'("loop_statement"), new String'("membership_choice_list"), new String'("membership_choice"), new String'("mod_clause_opt"), new String'("mode_opt"), new String'("multiplying_operator"), new String'("name_list"), new String'("name"), new String'("name_opt"), new String'("null_exclusion_opt"), new String'("null_exclusion_opt_name_type"), new String'("null_procedure_declaration"), new String'("object_declaration"), new String'("object_renaming_declaration"), new String'("overriding_indicator_opt"), new String'("package_body"), new String'("package_body_stub"), new String'("package_declaration"), new String'("package_renaming_declaration"), new String'("package_specification"), new String'("parameter_and_result_profile"), new String'("parameter_profile_opt"), new String'("parameter_specification"), new String'("parameter_specification_list"), new String'("paren_expression"), new String'("pragma_g"), new String'("primary"), new String'("private_extension_declaration"), new String'("private_type_declaration"), new String'("procedure_call_statement"), new String'("procedure_specification"), new String'("proper_body"), new String'("protected_body"), new String'("protected_body_stub"), new String'("protected_definition"), new String'("protected_operation_item"), new String'("protected_operation_item_list"), new String'("protected_operation_item_list_opt"), new String'("protected_opt"), new String'("protected_type_declaration"), new String'("qualified_expression"), new String'("quantified_expression"), new String'("quantifier"), new String'("raise_expression"), new String'("raise_statement"), new String'("range_g"), new String'("range_list"), new String'("real_range_specification_opt"), new String'("record_definition"), new String'("record_representation_clause"), new String'("relation_and_list"), new String'("relation_and_then_list"), new String'("relation_or_list"), new String'("relation_or_else_list"), new String'("relation_xor_list"), new String'("relation"), new String'("relational_operator"), new String'("renaming_declaration"), new String'("requeue_statement"), new String'("result_profile"), new String'("return_subtype_indication"), new String'("selected_component"), new String'("selective_accept"), new String'("select_alternative"), new String'("select_alternative_list"), new String'("select_alternative_list_opt"), new String'("select_statement"), new String'("sequence_of_statements"), new String'("sequence_of_statements_opt"), new String'("simple_expression"), new String'("simple_return_statement"), new String'("simple_statement"), new String'("single_protected_declaration"), new String'("single_task_declaration"), new String'("statement"), new String'("subprogram_body"), new String'("subprogram_body_stub"), new String'("subprogram_declaration"), new String'("subprogram_default"), new String'("subprogram_renaming_declaration"), new String'("subprogram_specification"), new String'("subtype_declaration"), new String'("subtype_indication"), new String'("subunit"), new String'("task_body"), new String'("task_body_stub"), new String'("task_definition"), new String'("task_type_declaration"), new String'("term"), new String'("term_list"), new String'("tick"), new String'("timed_entry_call"), new String'("triggering_alternative"), new String'("type_declaration"), new String'("type_definition"), new String'("variant_part"), new String'("variant_list"), new String'("variant"), new String'("unary_adding_operator"), new String'("use_clause"), new String'("with_clause")), Terminal_Image_Width => 17, Image_Width => 38, Last_Lookahead => 108); type Token_Enum_ID is (WHITESPACE_ID, NEW_LINE_ID, COMMENT_ID, ABS_ID, ACCEPT_ID, ABORT_ID, ABSTRACT_ID, ACCESS_ID, ALIASED_ID, ALL_ID, AND_ID, ARRAY_ID, AT_ID, BEGIN_ID, BODY_ID, CASE_ID, CONSTANT_ID, DECLARE_ID, DELAY_ID, DELTA_ID, DIGITS_ID, DO_ID, ELSE_ID, ELSIF_ID, END_ID, ENTRY_ID, EXCEPTION_ID, EXIT_ID, FOR_ID, FUNCTION_ID, GENERIC_ID, GOTO_ID, IF_ID, IN_ID, INTERFACE_ID, IS_ID, LIMITED_ID, LOOP_ID, MOD_ID, NEW_ID, NOT_ID, NULL_ID, OF_ID, OR_ID, OTHERS_ID, OUT_ID, OVERRIDING_ID, PACKAGE_ID, PRAGMA_ID, PRIVATE_ID, PROCEDURE_ID, PROTECTED_ID, RAISE_ID, RANGE_ID, RECORD_ID, REM_ID, RENAMES_ID, REQUEUE_ID, RETURN_ID, REVERSE_ID, SEPARATE_ID, SELECT_ID, SOME_ID, SUBTYPE_ID, SYNCHRONIZED_ID, TAGGED_ID, TASK_ID, TERMINATE_ID, THEN_ID, TYPE_ID, UNTIL_ID, USE_ID, WHEN_ID, WHILE_ID, WITH_ID, XOR_ID, LEFT_PAREN_ID, RIGHT_PAREN_ID, AMPERSAND_ID, AT_SIGN_ID, BAR_ID, BOX_ID, COLON_ID, COLON_EQUAL_ID, COMMA_ID, DOT_ID, DOT_DOT_ID, EQUAL_ID, EQUAL_GREATER_ID, GREATER_ID, GREATER_EQUAL_ID, GREATER_GREATER_ID, LESS_ID, LESS_EQUAL_ID, LESS_LESS_ID, MINUS_ID, PLUS_ID, SEMICOLON_ID, SLASH_ID, SLASH_EQUAL_ID, STAR_ID, STAR_STAR_ID, TICK_1_ID, TICK_2_ID, NUMERIC_LITERAL_ID, IDENTIFIER_ID, STRING_LITERAL_ID, CHARACTER_LITERAL_ID, Wisi_EOI_ID, wisitoken_accept_ID, abstract_limited_synchronized_opt_ID, abstract_limited_opt_ID, abstract_tagged_limited_opt_ID, abstract_subprogram_declaration_ID, accept_statement_ID, access_definition_ID, actual_parameter_part_ID, actual_parameter_part_opt_ID, aggregate_ID, aliased_opt_ID, and_interface_list_opt_ID, array_type_definition_ID, aspect_clause_ID, aspect_specification_opt_ID, assignment_statement_ID, association_opt_ID, association_list_ID, asynchronous_select_ID, at_clause_ID, attribute_reference_ID, attribute_designator_ID, binary_adding_operator_ID, block_label_ID, block_label_opt_ID, block_statement_ID, body_g_ID, body_stub_ID, case_expression_ID, case_expression_alternative_ID, case_expression_alternative_list_ID, case_statement_ID, case_statement_alternative_ID, case_statement_alternative_list_ID, compilation_unit_ID, compilation_unit_list_ID, component_clause_ID, component_clause_list_ID, component_declaration_ID, component_definition_ID, component_item_ID, component_list_ID, component_list_opt_ID, compound_statement_ID, conditional_entry_call_ID, conditional_quantified_expression_ID, constant_opt_ID, constraint_ID, constraint_opt_ID, declaration_ID, declarations_ID, declarative_part_opt_ID, delay_alternative_ID, delay_statement_ID, derived_type_definition_ID, direct_name_ID, direct_name_opt_ID, discrete_choice_ID, discrete_choice_list_ID, discrete_subtype_definition_ID, discrete_subtype_definition_list_ID, discriminant_part_opt_ID, discriminant_specification_opt_ID, discriminant_specification_list_ID, elsif_expression_item_ID, elsif_expression_list_ID, elsif_statement_item_ID, elsif_statement_list_ID, entry_body_ID, entry_body_formal_part_ID, entry_call_alternative_ID, entry_declaration_ID, enumeration_literal_ID, enumeration_literal_list_ID, enumeration_representation_clause_ID, enumeration_type_definition_ID, exception_choice_ID, exception_choice_list_ID, exception_declaration_ID, exception_handler_ID, exception_handler_list_ID, exception_handler_list_opt_ID, exit_statement_ID, expression_ID, expression_opt_ID, expression_function_declaration_ID, extended_return_object_declaration_ID, extended_return_object_declaration_opt_ID, extended_return_statement_ID, factor_ID, formal_object_declaration_ID, formal_part_ID, formal_subprogram_declaration_ID, formal_type_declaration_ID, formal_type_definition_ID, formal_derived_type_definition_ID, formal_package_declaration_ID, formal_package_actual_part_ID, full_type_declaration_ID, function_specification_ID, general_access_modifier_opt_ID, generic_declaration_ID, generic_formal_part_ID, generic_formal_parameter_declarations_ID, generic_formal_parameter_declaration_ID, generic_instantiation_ID, generic_package_declaration_ID, generic_renaming_declaration_ID, generic_subprogram_declaration_ID, goto_label_ID, handled_sequence_of_statements_ID, identifier_list_ID, identifier_opt_ID, if_expression_ID, if_statement_ID, incomplete_type_declaration_ID, index_constraint_ID, index_subtype_definition_ID, index_subtype_definition_list_ID, interface_list_ID, interface_type_definition_ID, iteration_scheme_ID, iterator_specification_ID, iterator_specification_opt_ID, loop_statement_ID, membership_choice_list_ID, membership_choice_ID, mod_clause_opt_ID, mode_opt_ID, multiplying_operator_ID, name_list_ID, name_ID, name_opt_ID, null_exclusion_opt_ID, null_exclusion_opt_name_type_ID, null_procedure_declaration_ID, object_declaration_ID, object_renaming_declaration_ID, overriding_indicator_opt_ID, package_body_ID, package_body_stub_ID, package_declaration_ID, package_renaming_declaration_ID, package_specification_ID, parameter_and_result_profile_ID, parameter_profile_opt_ID, parameter_specification_ID, parameter_specification_list_ID, paren_expression_ID, pragma_g_ID, primary_ID, private_extension_declaration_ID, private_type_declaration_ID, procedure_call_statement_ID, procedure_specification_ID, proper_body_ID, protected_body_ID, protected_body_stub_ID, protected_definition_ID, protected_operation_item_ID, protected_operation_item_list_ID, protected_operation_item_list_opt_ID, protected_opt_ID, protected_type_declaration_ID, qualified_expression_ID, quantified_expression_ID, quantifier_ID, raise_expression_ID, raise_statement_ID, range_g_ID, range_list_ID, real_range_specification_opt_ID, record_definition_ID, record_representation_clause_ID, relation_and_list_ID, relation_and_then_list_ID, relation_or_list_ID, relation_or_else_list_ID, relation_xor_list_ID, relation_ID, relational_operator_ID, renaming_declaration_ID, requeue_statement_ID, result_profile_ID, return_subtype_indication_ID, selected_component_ID, selective_accept_ID, select_alternative_ID, select_alternative_list_ID, select_alternative_list_opt_ID, select_statement_ID, sequence_of_statements_ID, sequence_of_statements_opt_ID, simple_expression_ID, simple_return_statement_ID, simple_statement_ID, single_protected_declaration_ID, single_task_declaration_ID, statement_ID, subprogram_body_ID, subprogram_body_stub_ID, subprogram_declaration_ID, subprogram_default_ID, subprogram_renaming_declaration_ID, subprogram_specification_ID, subtype_declaration_ID, subtype_indication_ID, subunit_ID, task_body_ID, task_body_stub_ID, task_definition_ID, task_type_declaration_ID, term_ID, term_list_ID, tick_ID, timed_entry_call_ID, triggering_alternative_ID, type_declaration_ID, type_definition_ID, variant_part_ID, variant_list_ID, variant_ID, unary_adding_operator_ID, use_clause_ID, with_clause_ID); type Token_Enum_ID_Array is array (Positive range <>) of Token_Enum_ID; use all type WisiToken.Token_ID; function "+" (Item : in Token_Enum_ID) return WisiToken.Token_ID is (WisiToken.Token_ID'First + Token_Enum_ID'Pos (Item)); function To_Token_Enum (Item : in WisiToken.Token_ID) return Token_Enum_ID is (Token_Enum_ID'Val (Item - WisiToken.Token_ID'First)); function "-" (Item : in WisiToken.Token_ID) return Token_Enum_ID renames To_Token_Enum; procedure abstract_subprogram_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure accept_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure accept_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure access_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure access_definition_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure access_definition_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure actual_parameter_part_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure actual_parameter_part_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aggregate_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aggregate_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aggregate_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aggregate_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aggregate_5 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure array_type_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure array_type_definition_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aspect_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure aspect_specification_opt_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure assignment_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure association_opt_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure association_opt_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure association_opt_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure association_opt_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure association_opt_5 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure asynchronous_select_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure at_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure block_label_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure block_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure block_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure case_expression_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure case_expression_alternative_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure case_expression_alternative_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure case_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure case_statement_alternative_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure case_statement_alternative_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure compilation_unit_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure compilation_unit_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure compilation_unit_list_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure component_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure component_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure component_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure component_list_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure conditional_entry_call_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure declaration_9 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure delay_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure delay_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure derived_type_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure derived_type_definition_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure discriminant_part_opt_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure elsif_expression_item_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure elsif_expression_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure elsif_statement_item_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure elsif_statement_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure entry_body_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure entry_body_formal_part_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure entry_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure entry_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure enumeration_representation_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure enumeration_type_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure exception_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure exception_handler_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure exception_handler_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure exception_handler_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure exit_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure exit_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure expression_function_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure extended_return_object_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure extended_return_object_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure extended_return_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure extended_return_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_object_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_object_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_object_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_object_declaration_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_part_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_subprogram_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_subprogram_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_subprogram_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_subprogram_declaration_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_type_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_type_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_type_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_derived_type_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_derived_type_definition_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure formal_package_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure full_type_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure function_specification_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_formal_part_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_formal_part_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_instantiation_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_instantiation_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_instantiation_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_package_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_renaming_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_renaming_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_renaming_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure generic_subprogram_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure goto_label_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure handled_sequence_of_statements_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure identifier_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure identifier_list_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_expression_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_expression_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_expression_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_expression_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_statement_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure if_statement_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure incomplete_type_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure incomplete_type_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure index_constraint_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure interface_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure interface_list_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure iteration_scheme_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure iteration_scheme_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure iterator_specification_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure iterator_specification_5 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure loop_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure loop_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure name_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure name_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure name_5 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure null_exclusion_opt_name_type_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure null_exclusion_opt_name_type_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure null_exclusion_opt_name_type_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure null_exclusion_opt_name_type_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure null_procedure_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_declaration_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_declaration_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_declaration_5 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_renaming_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_renaming_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure object_renaming_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure overriding_indicator_opt_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure overriding_indicator_opt_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_body_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_body_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_body_stub_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_renaming_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_specification_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure package_specification_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure parameter_and_result_profile_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure parameter_specification_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure parameter_specification_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure parameter_specification_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure parameter_specification_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure paren_expression_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure pragma_g_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure pragma_g_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure pragma_g_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure primary_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure primary_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure primary_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure private_extension_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure private_type_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure procedure_call_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure procedure_specification_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure protected_body_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure protected_body_stub_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure protected_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure protected_definition_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure protected_type_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure protected_type_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure qualified_expression_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure quantified_expression_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure raise_expression_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure raise_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure raise_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure raise_statement_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure range_g_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure record_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure record_representation_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure requeue_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure requeue_statement_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure result_profile_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure result_profile_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure selected_component_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure selected_component_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure selected_component_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure selected_component_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure selective_accept_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure selective_accept_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure select_alternative_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure select_alternative_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure select_alternative_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure select_alternative_4 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure select_alternative_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure select_alternative_list_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure simple_return_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure simple_statement_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure simple_statement_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure simple_statement_8 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure single_protected_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure single_protected_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure single_task_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure single_task_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure single_task_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subprogram_body_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subprogram_body_stub_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subprogram_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subprogram_default_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subprogram_renaming_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subtype_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subtype_indication_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subtype_indication_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subtype_indication_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subtype_indication_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure subunit_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_body_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_body_stub_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_definition_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_definition_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_type_declaration_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_type_declaration_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure task_type_declaration_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure timed_entry_call_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure variant_part_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure variant_list_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure variant_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure use_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure use_clause_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure use_clause_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure with_clause_0 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure with_clause_1 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure with_clause_2 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); procedure with_clause_3 (User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class; Tree : in out WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array); function accept_statement_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function block_label_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function block_label_opt_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function block_statement_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function block_statement_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function compilation_unit_list_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function entry_body_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function function_specification_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function identifier_opt_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function loop_statement_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function loop_statement_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function name_2_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function name_5_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function name_7_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function name_opt_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function package_body_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function package_body_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function package_specification_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function package_specification_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function procedure_specification_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function protected_body_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function protected_definition_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function protected_definition_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function protected_type_declaration_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function protected_type_declaration_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function selected_component_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function selected_component_2_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function single_protected_declaration_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function single_protected_declaration_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function single_task_declaration_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function single_task_declaration_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function subprogram_body_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function subprogram_specification_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function subprogram_specification_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function task_body_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function task_type_declaration_0_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; function task_type_declaration_1_check (Lexer : access constant WisiToken.Lexer.Instance'Class; Nonterm : in out WisiToken.Recover_Token; Tokens : in WisiToken.Recover_Token_Array; Recover_Active : in Boolean) return WisiToken.Semantic_Checks.Check_Status; Partial_Parse_Active : Boolean := False; Partial_Parse_Byte_Goal : WisiToken.Buffer_Pos := WisiToken.Buffer_Pos'Last; end Ada_Process_Actions;
------------------------------------------------------------------------------ -- -- -- SPARK LIBRARY COMPONENTS -- -- -- -- S P A R K . -- -- F L O A T I N G _ P O I N T _ A R I T H M E T I C _ L E M M A S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- SPARK 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. SPARK 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/>. -- -- -- ------------------------------------------------------------------------------ generic type Fl is digits <>; Fl_Last_Sqrt : Fl; package SPARK.Floating_Point_Arithmetic_Lemmas with SPARK_Mode, Pure, Ghost is pragma Warnings (Off, "postcondition does not check the outcome of calling"); procedure Lemma_Add_Is_Monotonic (Val1 : Fl; Val2 : Fl; Val3 : Fl) with Global => null, Pre => (Val1 in Fl'First / 2.0 .. Fl'Last / 2.0) and then (Val2 in Fl'First / 2.0 .. Fl'Last / 2.0) and then (Val3 in Fl'First / 2.0 .. Fl'Last / 2.0) and then Val1 <= Val2, Post => Val1 + Val3 <= Val2 + Val3; procedure Lemma_Sub_Is_Monotonic (Val1 : Fl; Val2 : Fl; Val3 : Fl) with Global => null, Pre => (Val1 in Fl'First / 2.0 .. Fl'Last / 2.0) and then (Val2 in Fl'First / 2.0 .. Fl'Last / 2.0) and then (Val3 in Fl'First / 2.0 .. Fl'Last / 2.0) and then Val1 <= Val2, Post => Val1 - Val3 <= Val2 - Val3; procedure Lemma_Mul_Is_Monotonic (Val1 : Fl; Val2 : Fl; Val3 : Fl) with Global => null, Pre => (Val1 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val2 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val3 in 0.0 .. Fl_Last_Sqrt) and then Val1 <= Val2, Post => Val1 * Val3 <= Val2 * Val3; -- MANUAL PROOF procedure Lemma_Mul_Is_Antimonotonic (Val1 : Fl; Val2 : Fl; Val3 : Fl) with Global => null, Pre => (Val1 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val2 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val3 in -Fl_Last_Sqrt .. 0.0) and then Val1 <= Val2, Post => Val2 * Val3 <= Val1 * Val3; -- MANUAL PROOF procedure Lemma_Mul_Is_Contracting (Val1 : Fl; Val2 : Fl) with Global => null, Pre => (Val1 in -1.0 .. 1.0), Post => abs(Val1 * Val2) <= abs(Val2); -- Martin Becker, not proven procedure Lemma_Div_Is_Monotonic (Val1 : Fl; Val2 : Fl; Val3 : Fl) with Global => null, Pre => (Val1 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val2 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val3 in 1.0 / Fl_Last_Sqrt .. Fl'Last) and then Val1 <= Val2, Post => Val1 / Val3 <= Val2 / Val3; -- MANUAL PROOF procedure Lemma_Div_Is_Antimonotonic (Val1 : Fl; Val2 : Fl; Val3 : Fl) with Global => null, Pre => (Val1 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val2 in -Fl_Last_Sqrt .. Fl_Last_Sqrt) and then (Val3 in Fl'First .. -1.0 / Fl_Last_Sqrt) and then Val1 <= Val2, Post => Val2 / Val3 <= Val1 / Val3; -- MANUAL PROOF end SPARK.Floating_Point_Arithmetic_Lemmas;
with DDS.DomainParticipantFactory; with DDS.DomainParticipant; package DDS.Request_Reply.Tests.Simple is pragma Elaborate_Body; Domain_Id : DDS.DomainId_T := 0; Service_Name : DDS.String := To_DDS_String ("myService"); Service_Name_Octets : DDS.String := To_DDS_String ("myOctets"); Qos_Library : DDS.String := To_DDS_String ("library"); Qos_Profile : DDS.String := To_DDS_String ("profile"); DONE : DDS.String := To_DDS_String ("<DONE>"); Factory : constant DDS.DomainParticipantFactory.Ref_Access := DDS.DomainParticipantFactory.Get_Instance; Participant : DDS.DomainParticipant.Ref_Access := Factory.Create_Participant_With_Profile (Domain_Id => Domain_Id, Library_Name => Qos_Library, Profile_Name => Qos_Profile); end DDS.Request_Reply.Tests.Simple;
----------------------------------------------------------------------- -- asf-navigations-reader -- Read XML navigation files -- Copyright (C) 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 ASF.Navigations.Redirect; with ASF.Navigations.Render; package body ASF.Navigations.Mappers is use Util.Beans.Objects; Empty : constant Util.Beans.Objects.Object := To_Object (String '("")); -- ------------------------------ -- Reset the navigation config before parsing a new rule. -- ------------------------------ procedure Reset (N : in out Nav_Config) is begin N.To_View := Empty; N.Outcome := Empty; N.Action := Empty; N.Condition := Empty; N.Redirect := False; end Reset; -- ------------------------------ -- Save in the navigation config object the value associated with the given field. -- When the <b>NAVIGATION_CASE</b> field is reached, insert the new navigation rule -- that was collected in the navigation handler. -- ------------------------------ procedure Set_Member (N : in out Nav_Config; Field : in Navigation_Case_Fields; Value : in Util.Beans.Objects.Object) is use ASF.Navigations.Redirect; use ASF.Navigations.Render; begin case Field is when OUTCOME => N.Outcome := Value; when ACTION => N.Action := Value; when TO_VIEW => N.To_View := Value; when FROM_VIEW_ID => N.From_View := Value; when REDIRECT => N.Redirect := True; when CONDITION => N.Condition := Value; null; when CONTENT => N.Content := Value; when CONTENT_TYPE => N.Content_Type := Value; when NAVIGATION_CASE => declare Navigator : Navigation_Access; begin if N.Redirect then Navigator := Create_Redirect_Navigator (To_String (N.To_View), N.Context.all); else Navigator := Create_Render_Navigator (To_String (N.To_View)); end if; N.Handler.Add_Navigation_Case (Navigator => Navigator, From => To_String (N.From_View), Outcome => To_String (N.Outcome), Action => To_String (N.Action), Condition => To_String (N.Condition), Context => N.Context.all); end; Reset (N); when NAVIGATION_RULE => N.From_View := Empty; end case; end Set_Member; Mapping : aliased Navigation_Mapper.Mapper; -- ------------------------------ -- Setup the XML parser to read the navigation rules. -- ------------------------------ package body Reader_Config is begin Reader.Add_Mapping ("faces-config", Mapping'Access); Reader.Add_Mapping ("module", Mapping'Access); Reader.Add_Mapping ("web-app", Mapping'Access); Config.Handler := Handler; Config.Context := Context; Config.From_View := Empty; Reset (Config); Navigation_Mapper.Set_Context (Reader, Config'Unchecked_Access); end Reader_Config; begin -- <navigation-rule> mapping Mapping.Add_Mapping ("navigation-rule/from-view-id", FROM_VIEW_ID); Mapping.Add_Mapping ("navigation-rule/navigation-case/from-action", ACTION); Mapping.Add_Mapping ("navigation-rule/navigation-case/from-outcome", OUTCOME); Mapping.Add_Mapping ("navigation-rule/navigation-case/to-view-id", TO_VIEW); Mapping.Add_Mapping ("navigation-rule/navigation-case/if", CONDITION); -- Mapping.Add_Mapping ("navigation-case/redirect/view-param/name", VIEW_PARAM_NAME); -- Mapping.Add_Mapping ("navigation-case/redirect/view-param/value", VIEW_PARAM_VALUE); -- Mapping.Add_Mapping ("navigation-case/redirect/include-view-params", INCLUDE_VIEW_PARAMS); Mapping.Add_Mapping ("navigation-rule/navigation-case/redirect", REDIRECT); Mapping.Add_Mapping ("navigation-rule/navigation-case/content", CONTENT); Mapping.Add_Mapping ("navigation-rule/navigation-case/content/@type", CONTENT_TYPE); Mapping.Add_Mapping ("navigation-rule/navigation-case", NAVIGATION_CASE); Mapping.Add_Mapping ("navigation-rule", NAVIGATION_RULE); end ASF.Navigations.Mappers;
-- { dg-do run } with sort1; procedure sort2 is begin if Sort1 ("hello world") /= " dehllloorw" then raise Program_Error; end if; end sort2;
-- -- Copyright (C) 2022 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- with Ada.Text_IO; with Text_Format; use Text_Format; with HAL.SPI; with HAL; with RP.Clock; with RP.Device; with RP.GPIO; with RP.SPI; with Pico; with ADXL345; procedure Accel is Port : RP.SPI.SPI_Port renames RP.Device.SPI_0; MISO : RP.GPIO.GPIO_Point renames Pico.GP0; -- SDO/ALT CS : RP.GPIO.GPIO_Point renames Pico.GP1; -- ~CS SCK : RP.GPIO.GPIO_Point renames Pico.GP2; -- SCL/SCLK MOSI : RP.GPIO.GPIO_Point renames Pico.GP3; -- SDA/SDI/SDIO begin RP.Clock.Initialize (Pico.XOSC_Frequency); RP.Device.Timer.Enable; declare use RP.GPIO; use RP.SPI; Config : constant SPI_Configuration := (Baud => 1_000_000, Polarity => Active_High, -- CPOL = 1 Phase => Falling_Edge, -- CPHA = 1 others => <>); begin Pico.LED.Configure (Output); MOSI.Configure (Output, Floating, SPI); MISO.Configure (Output, Floating, SPI); SCK.Configure (Output, Floating, SPI); CS.Configure (Output, Pull_Up); CS.Set; Port.Configure (Config); end; declare use Ada.Text_IO; use HAL; Device_Id : UInt8; begin if ADXL345.DEVID.Get (Port'Access, CS'Access, Device_Id) and then Device_Id = 2#11100101# then Pico.LED.Set; Put ("DEVID "); Put (Device_Id'Image); New_Line; else Pico.LED.Clear; Put_Line ("Device Id failed"); return; end if; end; declare use Ada.Text_IO; use HAL; use ADXL345; Power : POWER_CTL_Register := POWER_CTL.Get (Port'Access, CS'Access); Format : DATA_FORMAT_Register := DATA_FORMAT.Get (Port'Access, CS'Access); M : Measurement; G : Acceleration; begin Power.Measure := True; POWER_CTL.Set (Port'Access, CS'Access, Power); Power := POWER_CTL.Get (Port'Access, CS'Access); Put_Line ("Link " & Power.Link'Image); Put_Line ("AUTO_SLEEP " & Power.AUTO_SLEEP'Image); Put_Line ("Measure " & Power.Measure'Image); Put_Line ("Sleep " & Power.Sleep'Image); Put_Line ("Wakeup " & Power.Wakeup'Image); Format.G_Range := Range_2g; Format.Justify := True; Format.FULL_RES := True; DATA_FORMAT.Set (Port'Access, CS'Access, Format); loop if DATA.Get (Port'Access, CS'Access, M) then Put ("X="); G := To_Acceleration (Range_2g, M (X)); Put (From_Float (G, Aft => 6)); Put (" Y="); G := To_Acceleration (Range_2g, M (Y)); Put (From_Float (G, Aft => 6)); Put (" Z="); G := To_Acceleration (Range_2g, M (Z)); Put (From_Float (G, Aft => 6)); New_Line; end if; RP.Device.Timer.Delay_Seconds (1); end loop; end; end Accel;
------------------------------------------------------------------------------ -- Copyright (C) 2012-2020 by Heisenbug Ltd. -- -- 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); package body Caches.Access_Patterns is ----------------------------------------------------------------------------- -- End_Of_Pattern ----------------------------------------------------------------------------- function End_Of_Pattern (This : in Pattern) return Boolean is begin return This.Length = This.Count; end End_Of_Pattern; end Caches.Access_Patterns;
with AdaBase; with Connect; with Ada.Text_IO; procedure Fruit2 is package CON renames Connect; package TIO renames Ada.Text_IO; numrows : AdaBase.Affected_Rows; -- Intentionally broken UPDATE command (calories misspelled) cmd : constant String := "UPDATE fruits set caloriesx = 14 " & "WHERE fruit = 'strawberry'"; begin CON.connect_database; CON.DR.set_trait_error_mode (trait => AdaBase.raise_exception); TIO.Put_Line ("SQL: " & cmd); declare begin numrows := CON.DR.execute (sql => cmd); TIO.Put_Line ("Result: Updated" & numrows'Img & " rows"); CON.DR.rollback; exception when others => TIO.Put_Line ("Error!"); TIO.Put_Line ("Driver message: " & CON.DR.last_driver_message); TIO.Put_Line (" Driver code: " & CON.DR.last_driver_code'Img); TIO.Put_Line (" SQL State: " & CON.DR.last_sql_state); end; CON.DR.disconnect; end Fruit2;
------------------------------------------------------------------------------ -- -- generic package Generic_Table_Text_IO (body) -- -- A package for reading data tables with column headers indicating -- which data are in which columns. -- ------------------------------------------------------------------------------ -- Update information: -- -- 2003.03.25-26 (Jacob Sparre Andersen) -- Written. -- -- 2003.06.17 (Jacob Sparre Andersen) -- Added the option of reading from Standard_Input. -- -- (Insert additional update information above this line.) ------------------------------------------------------------------------------ -- Standard packages: ------------------------------------------------------------------------------ -- Other packages: with JSA.Tabulated_Text_IO; ------------------------------------------------------------------------------ with JSA.Debugged; use JSA.Debugged; package body JSA.Generic_Table_Text_IO is --------------------------------------------------------------------------- -- procedure Close: procedure Close (File : in out File_Type) is begin Ada.Text_IO.Close (File.File); end Close; --------------------------------------------------------------------------- -- function End_Of_File: function End_Of_File (File : in File_Type) return Boolean is begin return Ada.Text_IO.End_Of_File (File.File); end End_Of_File; --------------------------------------------------------------------------- -- function End_Of_File: -- -- Works on Standard_Input: function End_Of_File return Boolean is begin return Ada.Text_IO.End_Of_File (Ada.Text_IO.Standard_Input); end End_Of_File; --------------------------------------------------------------------------- -- procedure Get: procedure Get (File : in File_Type; Item : out Row) is use Ada.Strings.Unbounded; use Tabulated_Text_IO; Data : Unbounded_String; begin for Column in 1 .. File.Last_Column loop Get (File => File.File, Field => Data); Message_Line ("Read """ & To_String (Data) & """ from column " & Column'Img & "."); for Field in Fields loop if File.Columns (Field) = Column then Item (Field) := Value (To_String (Data)); end if; end loop; end loop; Skip_Record (File => File.File); end Get; --------------------------------------------------------------------------- -- procedure Get: procedure Get (Item : out Row) is use Ada.Strings.Unbounded; use Tabulated_Text_IO; Data : Unbounded_String; begin if not Initialised_Standard_Input then Initialise_Standard_Input : declare Column : Natural := 0; Label : Unbounded_String; begin Last_Standard_Input_Column := 0; Standard_Input_Columns := (others => 0); while not Ada.Text_IO.End_Of_Line (Ada.Text_IO.Standard_Input) loop Tabulated_Text_IO.Get (File => Ada.Text_IO.Standard_Input, Field => Label); Column := Column + 1; Message_Line ("Column " & Column'Img & " is labeled """ & To_String (Label) & """."); for Field in Fields loop if Label = Labels (Field) and Standard_Input_Columns (Field) = 0 then Standard_Input_Columns (Field) := Column; Message_Line ("Will copy column " & Standard_Input_Columns (Field)'Img & " to the field " & Field'Img & "."); Last_Standard_Input_Column := Natural'Max (Last_Standard_Input_Column, Column); Message_Line ("Will read " & Last_Standard_Input_Column'Img & " columns from the file."); end if; end loop; end loop; Tabulated_Text_IO.Skip_Record (File => Ada.Text_IO.Standard_Input); Initialised_Standard_Input := True; end Initialise_Standard_Input; end if; for Column in 1 .. Last_Standard_Input_Column loop Get (File => Ada.Text_IO.Standard_Input, Field => Data); Message_Line ("Read """ & To_String (Data) & """ from column " & Column'Img & "."); for Field in Fields loop if Standard_Input_Columns (Field) = Column then Item (Field) := Value (To_String (Data)); end if; end loop; end loop; Skip_Record (File => Ada.Text_IO.Standard_Input); end Get; --------------------------------------------------------------------------- -- function Is_Open: function Is_Open (File : in File_Type) return Boolean is begin return Ada.Text_IO.Is_Open (File.File); end Is_Open; --------------------------------------------------------------------------- -- procedure Open: procedure Open (File : in out File_Type; Name : in String; Mode : in Ada.Text_IO.File_Mode) is use Ada.Strings.Unbounded; Column : Natural := 0; Label : Unbounded_String; begin -- Open Ada.Text_IO.Open (File => File.File, Name => Name, Mode => Mode); File.Last_Column := 0; File.Columns := (others => 0); while not Ada.Text_IO.End_Of_Line (File.File) loop Tabulated_Text_IO.Get (File => File.File, Field => Label); Column := Column + 1; Message_Line ("Column " & Column'Img & " is labeled """ & To_String (Label) & """."); for Field in Fields loop if Label = Labels (Field) and File.Columns (Field) = 0 then File.Columns (Field) := Column; Message_Line ("Will copy column " & File.Columns (Field)'Img & " to the field " & Field'Img & "."); File.Last_Column := Natural'Max (File.Last_Column, Column); Message_Line ("Will read " & File.Last_Column'Img & " columns from the file."); end if; end loop; end loop; Tabulated_Text_IO.Skip_Record (File => File.File); end Open; --------------------------------------------------------------------------- end JSA.Generic_Table_Text_IO;
with Ada.Containers.Vectors; package wa1 is type Repr(<>) is private; type Abstract_Base is interface; function ToRepr(AB : Abstract_Base) return Repr is abstract; procedure FromRepr(AB : in out Abstract_Base; rp : Repr) is abstract; procedure Set_Smth (AB : in out Abstract_Base'Class; smth : Integer); ----------------------------------------------- type Base is new Abstract_Base with private; overriding function ToRepr(B : Base) return Repr; overriding procedure FromRepr(B : in out Base; R : Repr); private type Smth_Array is array (Positive range <>) of Integer; type Repr(Size : Natural) is record smth : Integer; sa : Smth_Array(1..Size); end record; ---------------------------------------------------------------- package ACV is new Ada.Containers.Vectors(Positive, Integer); type Base is new Abstract_Base with record smth : Integer; sv : ACV.Vector; end record; end wa1;
with User; use User; package body Subprograms is procedure Hello_Part1 is begin User.Hello_Part1 (); end Hello_Part1; end Subprograms;
with Ada.Containers.Synchronized_Queue_Interfaces, Ada.Containers.Unbounded_Synchronized_Queues, Ada.Containers.Vectors, Ada.Execution_Time, Ada.Integer_Text_IO, Ada.Long_Long_Integer_Text_IO, Ada.Real_Time, Ada.Strings.Fixed, Ada.Strings.Unbounded, Ada.Text_IO; with Utils; procedure Main is use Ada.Execution_Time, Ada.Real_Time, Ada.Strings.Fixed, Ada.Strings.Unbounded, Ada.Text_IO; use Utils; package Character_Queue_Interfaces is new Ada.Containers.Synchronized_Queue_Interfaces (Element_Type => Character); package Character_Queues is new Ada.Containers.Unbounded_Synchronized_Queues (Queue_Interfaces => Character_Queue_Interfaces); use Character_Queues; function Pop (Q : in out Queue; N : Positive; Nb_Delete : in out Long_Long_Natural) return String; function Pop (Q : in out Queue; N : Positive; Nb_Delete : in out Long_Long_Natural) return String is Result : String (1 .. N); begin for Index in 1 .. N loop Q.Dequeue (Result (Index)); end loop; Nb_Delete := Nb_Delete + Long_Long_Natural (N); return Result; end Pop; File : File_Type; Start_Time, End_Time : CPU_Time; Execution_Duration : Time_Span; File_Is_Empty : Boolean := True; Result : Long_Long_Natural := Long_Long_Natural'First; Packet : Queue; begin Get_File (File); -- Get all values declare begin while not End_Of_File (File) loop declare Str : constant String := Get_Line (File); Value : Natural; Temp : String (1 .. 8); begin for Char of Str loop Value := Natural'Value ("16#" & Char & "#"); Ada.Integer_Text_IO.Put (Temp, Value, Base => 2); File_Is_Empty := False; declare Trimmed : constant String := Trim (Temp, Ada.Strings.Both); Formatted_Bin_Str : constant String := Tail (Trimmed (Trimmed'First + 2 .. Trimmed'Last - 1), 4, '0'); begin for Elt of Formatted_Bin_Str loop Packet.Enqueue (Elt); end loop; end; end loop; end; end loop; end; -- Exit the program if there is no values if File_Is_Empty then Close_If_Open (File); Put_Line ("The input file is empty."); return; end if; -- Do the puzzle Start_Time := Ada.Execution_Time.Clock; Solve_Puzzle : declare function Parse_Packet (Packet : in out Queue) return Long_Long_Natural; function Parse_Packet (Packet : in out Queue) return Long_Long_Natural is package Long_Long_Natural_Vectrors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Long_Long_Natural, "=" => "="); function Inner_Parse (Packet : in out Queue; Last_Index : in out Long_Long_Natural) return Long_Long_Natural; function Inner_Parse (Packet : in out Queue; Last_Index : in out Long_Long_Natural) return Long_Long_Natural is use Ada.Long_Long_Integer_Text_IO; use Long_Long_Natural_Vectrors; procedure Get (Source : String; Result : out Long_Long_Natural); procedure Get (Source : String; Result : out Long_Long_Natural) is Last : Positive; begin Get ("2#" & Source & "#", Result, Last); end Get; subtype Type_Id_Value is Long_Long_Natural range 0 .. 7; Version : Long_Long_Natural; Type_Id : Type_Id_Value; begin Get (Pop (Packet, 3, Last_Index), Version); Get (Pop (Packet, 3, Last_Index), Type_Id); if Type_Id = 4 then declare Accumulator : Unbounded_String := Null_Unbounded_String; Current : String (1 .. 1); Value : Long_Long_Natural; begin loop Current := Pop (Packet, 1, Last_Index); Accumulator := Accumulator & Pop (Packet, 4, Last_Index); exit when Current = "0"; end loop; Get (To_String (Accumulator), Value); return Value; end; else declare Values : Vector; Length_Id : Long_Long_Natural; Sub_Packet_Length : Long_Long_Natural; Number_Of_Sub_Packet : Long_Long_Natural; begin Get (Pop (Packet, 1, Last_Index), Length_Id); if Length_Id = 0 then Get (Pop (Packet, 15, Last_Index), Sub_Packet_Length); declare End_Pop : constant Long_Long_Natural := Last_Index + Sub_Packet_Length; begin while Last_Index < End_Pop loop Values.Append (Inner_Parse (Packet, Last_Index)); end loop; end; else Get (Pop (Packet, 11, Last_Index), Number_Of_Sub_Packet); for Sub_Packet_Index in 1 .. Number_Of_Sub_Packet loop Values.Append (Inner_Parse (Packet, Last_Index)); end loop; end if; return Value : Long_Long_Natural do case Type_Id is when 0 => -- Sum for Elt of Values loop Value := Value + Elt; end loop; when 1 => -- Product Value := 1; for Elt of Values loop Value := Value * Elt; end loop; when 2 => -- Minimum Value := Long_Long_Natural'Last; for Elt of Values loop if Elt < Value then Value := Elt; end if; end loop; when 3 => -- Maximum Value := Long_Long_Natural'First; for Elt of Values loop if Elt > Value then Value := Elt; end if; end loop; when 4 => raise Constraint_Error with "Unexpected Type ID 4"; when 5 => -- Greater than if Values.Element (1) > Values.Element (2) then Value := 1; else Value := 0; end if; when 6 => -- Less than if Values.Element (1) < Values.Element (2) then Value := 1; else Value := 0; end if; when 7 => -- Equal to if Values.Element (1) = Values.Element (2) then Value := 1; else Value := 0; end if; end case; end return; end; end if; end Inner_Parse; Last_Index : Long_Long_Natural := Long_Long_Natural'First; begin return Inner_Parse (Packet, Last_Index); end Parse_Packet; begin Result := Parse_Packet (Packet); end Solve_Puzzle; End_Time := Ada.Execution_Time.Clock; Execution_Duration := End_Time - Start_Time; Put ("Result: "); Ada.Long_Long_Integer_Text_IO.Put (Item => Result, Width => 0); New_Line; Put_Line ("(Took " & Duration'Image (To_Duration (Execution_Duration) * 1_000_000) & "µs)"); exception when others => Close_If_Open (File); raise; end Main;
-- { dg-do run } -- { dg-options "-O2" } with Loop_Optimization4_Pkg; use Loop_Optimization4_Pkg; procedure Loop_Optimization4 is begin Add ("Nothing"); end;
-- ----------------------------------------------------------------- -- -- AdaSDL -- -- Thin binding to Simple Direct Media Layer -- -- Copyright (C) 2000-2012 A.M.F.Vargas -- -- Antonio M. M. Ferreira Vargas -- -- Manhente - Barcelos - Portugal -- -- http://adasdl.sourceforge.net -- -- E-mail: amfvargas@gmail.com -- -- ----------------------------------------------------------------- -- -- -- -- This library 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 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 -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU 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. -- -- -- -- 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. -- -- ----------------------------------------------------------------- -- with System.Address_To_Access_Conversions; with Interfaces.C; with Interfaces.C.Strings; with Interfaces.C.Pointers; with Interfaces.C.Extensions; with UintN_PtrOps; package SDL.Types is package C renames Interfaces.C; package CE renames Interfaces.C.Extensions; -- SDL_TABLESIZE ??? type SDL_bool is new C.int; SDL_False : constant SDL_bool := 0; SDL_True : constant SDL_bool := 1; type Uint8 is new C.unsigned_char; type Uint8_ptr is access all Uint8; pragma Convention (C, Uint8_ptr); type Uint8_ptr_ptr is access all Uint8_ptr; pragma Convention (C, Uint8_ptr_ptr); package Uint8_Ptrs is new System.Address_To_Access_Conversions (Uint8); type Uint8_Array is array (C.size_t range <>) of aliased Uint8; package Uint8_PtrOps is new UintN_PtrOps ( The_Element => Uint8, The_Element_Array => Uint8_Array); procedure Copy_Array ( Source : Uint8_Ptrs.Object_Pointer; Target : Uint8_Ptrs.Object_Pointer; Lenght : Natural); pragma Inline (Copy_Array); function Increment ( Pointer : Uint8_Ptrs.Object_Pointer; Amount : Natural) return Uint8_Ptrs.Object_Pointer; pragma Inline (Increment); function Decrement ( Pointer : Uint8_Ptrs.Object_Pointer; Amount : Natural) return Uint8_Ptrs.Object_Pointer; pragma Inline (Decrement); function Shift_Left ( Value : Uint8; Amount : Integer) return Uint8; pragma Inline (Shift_Left); function Shift_Right ( Value : Uint8; Amount : Integer) return Uint8; pragma Inline (Shift_Right); type Sint8 is new C.char; type Sint8_ptr is access all Sint8; pragma Convention (C, Sint8_ptr); type Sint8_ptr_ptr is access all Sint8_ptr; pragma Convention (C, Sint8_ptr_ptr); type Uint16 is new C.unsigned_short; type Uint16_ptr is access all Uint16; pragma Convention (C, Uint16_ptr); type Uint16_ptr_ptr is access all Uint16_ptr; pragma Convention (C, Uint16_ptr_ptr); package Uint16_Ptrs is new System.Address_To_Access_Conversions (Uint16); type Uint16_Array is array (C.size_t range <>) of aliased Uint16; package Uint16_PtrOps is new UintN_PtrOps ( The_Element => Uint16, The_Element_Array => Uint16_Array); function Increment ( Pointer : Uint16_Ptrs.Object_Pointer; Amount : Natural) return Uint16_Ptrs.Object_Pointer; pragma Inline (Increment); function Decrement ( Pointer : Uint16_Ptrs.Object_Pointer; Amount : Natural) return Uint16_Ptrs.Object_Pointer; pragma Inline (Decrement); function Shift_Left ( Value : Uint16; Amount : Integer) return Uint16; pragma Inline (Shift_Left); function Shift_Right ( Value : Uint16; Amount : Integer) return Uint16; pragma Inline (Shift_Right); type Sint16 is new C.short; type Sint16_ptr is access all Sint16; pragma Convention (C, Sint16_ptr); type Sint16_ptr_ptr is access all Sint16_ptr; pragma Convention (C, Sint16_ptr_ptr); type Uint32 is new C.unsigned; type Uint32_ptr is access all Uint32; pragma Convention (C, Uint32_ptr); type Uint32_ptr_ptr is access all Uint32_ptr; pragma Convention (C, Uint32_ptr_ptr); package Uint32_Ptrs is new System.Address_To_Access_Conversions (Uint32); type Uint32_Array is array (C.size_t range <>) of aliased Uint32; package Uint32_PtrOps is new UintN_PtrOps ( The_Element => Uint32, The_Element_Array => Uint32_Array); function Increment ( Pointer : Uint32_Ptrs.Object_Pointer; Amount : Natural) return Uint32_Ptrs.Object_Pointer; pragma Inline (Increment); function Decrement ( Pointer : Uint32_Ptrs.Object_Pointer; Amount : Natural) return Uint32_Ptrs.Object_Pointer; pragma Inline (Decrement); function Shift_Left ( Value : Uint32; Amount : Integer) return Uint32; pragma Inline (Shift_Left); function Shift_Right ( Value : Uint32; Amount : Integer) return Uint32; pragma Inline (Shift_Right); type Sint32 is new C.int; type Sint32_ptr is access all Sint32; pragma Convention (C, Sint32_ptr); type Sint32_ptr_ptr is access all Sint32_ptr; pragma Convention (C, Sint32_ptr_ptr); type Uint64 is new CE.unsigned_long_long; type Uint64_ptr is access all Uint64; pragma Convention (C, Uint64_ptr); type Uint64_ptr_ptr is access all Uint64_ptr; pragma Convention (C, Uint64_ptr_ptr); type Sint64 is new CE.long_long; type Sint64_ptr is access all Sint64; pragma Convention (C, Sint64_ptr); type Sint64_ptr_ptr is access all Sint64_ptr; pragma Convention (C, Sint64_ptr_ptr); type bits1 is mod 2**1; -- for bits1'Size use 1; type bits6 is mod 2**6; -- for bits6'Size use 6; type bits16 is mod 2**16; -- for bits16'Size use 16; type bits31 is mod 2**31; -- for bits31'Size use 31; type void_ptr is new System.Address; type chars_ptr_ptr is access all C.Strings.chars_ptr; pragma Convention (C, chars_ptr_ptr); type int_ptr is access all C.int; pragma Convention (C, int_ptr); SDL_PRESSED : constant := 16#01#; SDL_RELEASED : constant := 16#00#; end SDL.Types;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- L I B . S O R T -- -- -- -- 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. -- -- -- -- 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 GNAT.Heap_Sort_G; separate (Lib) procedure Sort (Tbl : in out Unit_Ref_Table) is T : array (0 .. Integer (Tbl'Last - Tbl'First + 1)) of Unit_Number_Type; -- Actual sort is done on this copy of the array with 0's origin -- subscripts. Location 0 is used as a temporary by the sorting algorithm. -- Also the addressing of the table is more efficient with 0's origin, -- even though we have to copy Tbl back and forth. function Lt_Uname (C1, C2 : Natural) return Boolean; -- Comparison routine for comparing Unames. Needed by the sorting routine procedure Move_Uname (From : Natural; To : Natural); -- Move routine needed by the sorting routine below package Sorting is new GNAT.Heap_Sort_G (Move_Uname, Lt_Uname); -------------- -- Lt_Uname -- -------------- function Lt_Uname (C1, C2 : Natural) return Boolean is begin -- Preprocessing data and definition files are not sorted, they are -- at the bottom of the list. They are recognized because they are -- the only ones without a Unit_Name. if Units.Table (T (C1)).Unit_Name = No_Unit_Name then return False; elsif Units.Table (T (C2)).Unit_Name = No_Unit_Name then return True; else return Uname_Lt (Units.Table (T (C1)).Unit_Name, Units.Table (T (C2)).Unit_Name); end if; end Lt_Uname; ---------------- -- Move_Uname -- ---------------- procedure Move_Uname (From : Natural; To : Natural) is begin T (To) := T (From); end Move_Uname; -- Start of processing for Sort begin if T'Last > 0 then for I in 1 .. T'Last loop T (I) := Tbl (Int (I) - 1 + Tbl'First); end loop; Sorting.Sort (T'Last); -- Sort is complete, copy result back into place for I in 1 .. T'Last loop Tbl (Int (I) - 1 + Tbl'First) := T (I); end loop; end if; end Sort;
----------------------------------------------------------------------- -- awa-images-modules -- Image management module -- Copyright (C) 2012, 2016, 2020 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 Util.Processes; with Util.Beans.Objects; with Util.Log.Loggers; with Util.Streams.Pipes; with Util.Streams.Texts; with Util.Strings; with ADO.Sessions; with EL.Variables.Default; with EL.Contexts.Default; with AWA.Modules.Get; with AWA.Applications; with AWA.Storages.Modules; with AWA.Services.Contexts; with AWA.Modules.Beans; with AWA.Images.Beans; package body AWA.Images.Modules is package ASC renames AWA.Services.Contexts; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Images.Module"); package Register is new AWA.Modules.Beans (Module => Image_Module, Module_Access => Image_Module_Access); -- ------------------------------ -- Job worker procedure to identify an image and generate its thumnbnail. -- ------------------------------ procedure Thumbnail_Worker (Job : in out AWA.Jobs.Services.Abstract_Job_Type'Class) is Module : constant Image_Module_Access := Get_Image_Module; begin Module.Do_Thumbnail_Job (Job); end Thumbnail_Worker; -- ------------------------------ -- Initialize the image module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Image_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the image module"); -- Setup the resource bundles. App.Register ("imageMsg", "images"); Register.Register (Plugin => Plugin, Name => "AWA.Images.Beans.Image_List_Bean", Handler => AWA.Images.Beans.Create_Image_List_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Images.Beans.Image_Bean", Handler => AWA.Images.Beans.Create_Image_Bean'Access); App.Add_Servlet ("image", Plugin.Image_Servlet'Unchecked_Access); AWA.Modules.Module (Plugin).Initialize (App, Props); Plugin.Add_Listener (AWA.Storages.Modules.NAME, Plugin'Unchecked_Access); end Initialize; -- ------------------------------ -- Configures the module after its initialization and after having -- read its XML configuration. -- ------------------------------ overriding procedure Configure (Plugin : in out Image_Module; Props : in ASF.Applications.Config) is pragma Unreferenced (Props); use type AWA.Jobs.Modules.Job_Module_Access; begin Plugin.Job_Module := AWA.Jobs.Modules.Get_Job_Module; if Plugin.Job_Module = null then Log.Error ("Cannot find the AWA Job module for the image thumbnail generation"); else Plugin.Job_Module.Register (Definition => Thumbnail_Job_Definition.Factory); end if; Plugin.Thumbnail_Command := Plugin.Get_Config (PARAM_THUMBNAIL_COMMAND); end Configure; -- ------------------------------ -- Create a thumbnail job for the image. -- ------------------------------ procedure Make_Thumbnail_Job (Plugin : in Image_Module; Image : in AWA.Images.Models.Image_Ref'Class) is pragma Unreferenced (Plugin); J : AWA.Jobs.Services.Job_Type; begin J.Set_Parameter ("image_id", Image); J.Schedule (Thumbnail_Job_Definition.Factory.all); end Make_Thumbnail_Job; -- ------------------------------ -- Returns true if the storage file has an image mime type. -- ------------------------------ function Is_Image (File : in AWA.Storages.Models.Storage_Ref'Class) return Boolean is Mime : constant String := File.Get_Mime_Type; Pos : constant Natural := Util.Strings.Index (Mime, '/'); begin if Pos = 0 then return False; else return Mime (Mime'First .. Pos - 1) = "image"; end if; end Is_Image; -- ------------------------------ -- Create an image instance. -- ------------------------------ procedure Create_Image (Plugin : in Image_Module; File : in AWA.Storages.Models.Storage_Ref'Class) is begin if File.Get_Original.Is_Null then declare Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); Img : AWA.Images.Models.Image_Ref; begin Img.Set_Width (0); Img.Set_Height (0); Img.Set_Thumb_Height (0); Img.Set_Thumb_Width (0); Img.Set_Storage (File); Img.Set_Folder (File.Get_Folder); Img.Set_Owner (File.Get_Owner); Img.Save (DB); Plugin.Make_Thumbnail_Job (Img); end; end if; end Create_Image; -- ------------------------------ -- The `On_Create` procedure is called by `Notify_Create` to notify -- the creation of the item. -- ------------------------------ overriding procedure On_Create (Instance : in Image_Module; Item : in AWA.Storages.Models.Storage_Ref'Class) is begin if Is_Image (Item) then Image_Module'Class (Instance).Create_Image (Item); end if; end On_Create; -- ------------------------------ -- The `On_Update` procedure is called by `Notify_Update` to notify -- the update of the item. -- ------------------------------ overriding procedure On_Update (Instance : in Image_Module; Item : in AWA.Storages.Models.Storage_Ref'Class) is begin if Is_Image (Item) then Image_Module'Class (Instance).Create_Image (Item); else Image_Module'Class (Instance).Delete_Image (Item); end if; end On_Update; -- ------------------------------ -- The `On_Delete` procedure is called by `Notify_Delete` to notify -- the deletion of the item. -- ------------------------------ overriding procedure On_Delete (Instance : in Image_Module; Item : in AWA.Storages.Models.Storage_Ref'Class) is begin Image_Module'Class (Instance).Delete_Image (Item); end On_Delete; -- ------------------------------ -- Thumbnail job to identify the image dimension and produce a thumbnail. -- ------------------------------ procedure Do_Thumbnail_Job (Plugin : in Image_Module; Job : in out AWA.Jobs.Services.Abstract_Job_Type'Class) is Image_Id : constant ADO.Identifier := Job.Get_Parameter ("image_id"); begin Image_Module'Class (Plugin).Build_Thumbnail (Image_Id); end Do_Thumbnail_Job; -- ------------------------------ -- Get the image module instance associated with the current application. -- ------------------------------ function Get_Image_Module return Image_Module_Access is function Get is new AWA.Modules.Get (Image_Module, Image_Module_Access, NAME); begin return Get; end Get_Image_Module; procedure Create_Thumbnail (Service : in Image_Module; Source : in String; Into : in String; Width : in out Natural; Height : in out Natural) is Ctx : EL.Contexts.Default.Default_Context; Variables : aliased EL.Variables.Default.Default_Variable_Mapper; Proc : Util.Processes.Process; Pipe : aliased Util.Streams.Pipes.Pipe_Stream; begin Variables.Bind ("src", Util.Beans.Objects.To_Object (Source)); Variables.Bind ("dst", Util.Beans.Objects.To_Object (Into)); Variables.Bind ("width", Util.Beans.Objects.To_Object (Width)); Variables.Bind ("height", Util.Beans.Objects.To_Object (Height)); Ctx.Set_Variable_Mapper (Variables'Unchecked_Access); declare Cmd : constant Util.Beans.Objects.Object := Service.Thumbnail_Command.Get_Value (Ctx); Command : constant String := Util.Beans.Objects.To_String (Cmd); Input : Util.Streams.Texts.Reader_Stream; begin Width := 0; Height := 0; Pipe.Open (Command, Util.Processes.READ_ALL); Input.Initialize (Pipe'Unchecked_Access, 1024); while not Input.Is_Eof loop declare use Ada.Strings; Line : Ada.Strings.Unbounded.Unbounded_String; Pos : Natural; Sep : Natural; Last : Natural; begin Input.Read_Line (Into => Line, Strip => False); exit when Ada.Strings.Unbounded.Length (Line) = 0; Log.Info ("Received: {0}", Line); -- The '-verbose' option of ImageMagick reports information -- about the original image. Extract the picture width and -- height. -- image.png PNG 120x282 120x282+0+0 8-bit \ -- DirectClass 34.4KB 0.000u 0:00.018 Pos := Ada.Strings.Unbounded.Index (Line, " "); if Pos > 0 and Width = 0 then Pos := Ada.Strings.Unbounded.Index (Line, " ", Pos + 1); if Pos > 0 then Sep := Ada.Strings.Unbounded.Index (Line, "x", Pos + 1); Last := Ada.Strings.Unbounded.Index (Line, "=", Pos + 1); if Sep > 0 and Sep < Last then Log.Info ("Dimension {0} - {1}..{2}", Ada.Strings.Unbounded.Slice (Line, Pos, Last), Natural'Image (Pos), Natural'Image (Last)); Width := Natural'Value (Unbounded.Slice (Line, Pos + 1, Sep - 1)); Height := Natural'Value (Unbounded.Slice (Line, Sep + 1, Last - 1)); end if; end if; end if; end; end loop; Pipe.Close; Util.Processes.Wait (Proc); if Pipe.Get_Exit_Status /= 0 then Log.Error ("Command {0} exited with status {1}", Command, Integer'Image (Pipe.Get_Exit_Status)); end if; end; end Create_Thumbnail; -- Build a thumbnail for the image identified by the Id. procedure Build_Thumbnail (Service : in Image_Module; Id : in ADO.Identifier) is Storage_Service : constant AWA.Storages.Services.Storage_Service_Access := AWA.Storages.Modules.Get_Storage_Manager; Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); Img : AWA.Images.Models.Image_Ref; Thumb : AWA.Images.Models.Image_Ref; Target_File : AWA.Storages.Storage_File (AWA.Storages.TMP); Local_File : AWA.Storages.Storage_File (AWA.Storages.CACHE); Thumbnail : AWA.Storages.Models.Storage_Ref; Width : Natural := 64; Height : Natural := 64; begin Img.Load (DB, Id); declare Image_File : constant AWA.Storages.Models.Storage_Ref'Class := Img.Get_Storage; begin Storage_Service.Get_Local_File (From => Image_File.Get_Id, Into => Local_File); Storage_Service.Create_Local_File (Target_File); Service.Create_Thumbnail (AWA.Storages.Get_Path (Local_File), AWA.Storages.Get_Path (Target_File), Width, Height); Thumbnail.Set_Mime_Type ("image/jpeg"); Thumbnail.Set_Original (Image_File); Thumbnail.Set_Workspace (Image_File.Get_Workspace); Thumbnail.Set_Folder (Image_File.Get_Folder); Thumbnail.Set_Owner (Image_File.Get_Owner); Thumbnail.Set_Name (String '(Image_File.Get_Name)); Storage_Service.Save (Thumbnail, AWA.Storages.Get_Path (Target_File), AWA.Storages.Models.DATABASE); Thumb.Set_Width (64); Thumb.Set_Height (64); Thumb.Set_Owner (Image_File.Get_Owner); Thumb.Set_Folder (Image_File.Get_Folder); Thumb.Set_Storage (Thumbnail); Img.Set_Width (Width); Img.Set_Height (Height); Img.Set_Thumb_Width (64); Img.Set_Thumb_Height (64); Img.Set_Thumbnail (Thumbnail); Ctx.Start; Img.Save (DB); Thumb.Save (DB); Ctx.Commit; end; end Build_Thumbnail; -- Deletes the storage instance. procedure Delete_Image (Service : in Image_Module; File : in AWA.Storages.Models.Storage_Ref'Class) is begin null; end Delete_Image; -- ------------------------------ -- Scale the image dimension. -- ------------------------------ procedure Scale (Width : in Natural; Height : in Natural; To_Width : in out Natural; To_Height : in out Natural) is begin if To_Width = Natural'Last or To_Height = Natural'Last or (To_Width = 0 and To_Height = 0) then To_Width := Width; To_Height := Height; elsif To_Width = 0 then To_Width := (Width * To_Height) / Height; elsif To_Height = 0 then To_Height := (Height * To_Width) / Width; end if; end Scale; -- ------------------------------ -- Get the dimension represented by the string. The string has one -- of the following formats: -- original -> Width, Height := Natural'Last -- default -> Width, Height := 0 -- <width>x -> Width := <width>, Height := 0 -- x<height> -> Width := 0, Height := <height> -- <width>x<height> -> Width := <width>, Height := <height> -- ------------------------------ procedure Get_Sizes (Dimension : in String; Width : out Natural; Height : out Natural) is Pos : Natural; begin if Dimension = "original" then Width := Natural'Last; Height := Natural'Last; elsif Dimension = "default" then Width := 800; Height := 0; else Pos := Util.Strings.Index (Dimension, 'x'); if Pos > Dimension'First then begin Width := Natural'Value (Dimension (Dimension'First .. Pos - 1)); exception when Constraint_Error => Width := 0; end; else Width := 0; end if; if Pos < Dimension'Last then begin Height := Natural'Value (Dimension (Pos + 1 .. Dimension'Last)); exception when Constraint_Error => Height := 0; end; else Height := 0; end if; end if; end Get_Sizes; end AWA.Images.Modules;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M A K E U T L -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2016, 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 ALI; use ALI; with Atree; use Atree; with Debug; with Err_Vars; use Err_Vars; with Errutil; with Fname; with Osint; use Osint; with Output; use Output; with Opt; use Opt; with Prj.Com; with Prj.Err; with Prj.Ext; with Prj.Util; use Prj.Util; with Sinput.P; with Tempdir; with Ada.Command_Line; use Ada.Command_Line; with Ada.Unchecked_Deallocation; with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.HTable; with GNAT.Regexp; use GNAT.Regexp; package body Makeutl is type Linker_Options_Data is record Project : Project_Id; Options : String_List_Id; end record; Linker_Option_Initial_Count : constant := 20; Linker_Options_Buffer : String_List_Access := new String_List (1 .. Linker_Option_Initial_Count); Last_Linker_Option : Natural := 0; package Linker_Opts is new Table.Table ( Table_Component_Type => Linker_Options_Data, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Make.Linker_Opts"); procedure Add_Linker_Option (Option : String); --------- -- Add -- --------- procedure Add (Option : String_Access; To : in out String_List_Access; Last : in out Natural) is begin if Last = To'Last then declare New_Options : constant String_List_Access := new String_List (1 .. To'Last * 2); begin New_Options (To'Range) := To.all; -- Set all elements of the original options to null to avoid -- deallocation of copies. To.all := (others => null); Free (To); To := New_Options; end; end if; Last := Last + 1; To (Last) := Option; end Add; procedure Add (Option : String; To : in out String_List_Access; Last : in out Natural) is begin Add (Option => new String'(Option), To => To, Last => Last); end Add; ----------------------- -- Add_Linker_Option -- ----------------------- procedure Add_Linker_Option (Option : String) is begin if Option'Length > 0 then if Last_Linker_Option = Linker_Options_Buffer'Last then declare New_Buffer : constant String_List_Access := new String_List (1 .. Linker_Options_Buffer'Last + Linker_Option_Initial_Count); begin New_Buffer (Linker_Options_Buffer'Range) := Linker_Options_Buffer.all; Linker_Options_Buffer.all := (others => null); Free (Linker_Options_Buffer); Linker_Options_Buffer := New_Buffer; end; end if; Last_Linker_Option := Last_Linker_Option + 1; Linker_Options_Buffer (Last_Linker_Option) := new String'(Option); end if; end Add_Linker_Option; ------------------- -- Absolute_Path -- ------------------- function Absolute_Path (Path : Path_Name_Type; Project : Project_Id) return String is begin Get_Name_String (Path); declare Path_Name : constant String := Name_Buffer (1 .. Name_Len); begin if Is_Absolute_Path (Path_Name) then return Path_Name; else declare Parent_Directory : constant String := Get_Name_String (Project.Directory.Display_Name); begin return Parent_Directory & Path_Name; end; end if; end; end Absolute_Path; ---------------------------- -- Aggregate_Libraries_In -- ---------------------------- function Aggregate_Libraries_In (Tree : Project_Tree_Ref) return Boolean is List : Project_List; begin List := Tree.Projects; while List /= null loop if List.Project.Qualifier = Aggregate_Library then return True; end if; List := List.Next; end loop; return False; end Aggregate_Libraries_In; ------------------------- -- Base_Name_Index_For -- ------------------------- function Base_Name_Index_For (Main : String; Main_Index : Int; Index_Separator : Character) return File_Name_Type is Result : File_Name_Type; begin Name_Len := 0; Add_Str_To_Name_Buffer (Base_Name (Main)); -- Remove the extension, if any, that is the last part of the base name -- starting with a dot and following some characters. for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Len := J - 1; exit; end if; end loop; -- Add the index info, if index is different from 0 if Main_Index > 0 then Add_Char_To_Name_Buffer (Index_Separator); declare Img : constant String := Main_Index'Img; begin Add_Str_To_Name_Buffer (Img (2 .. Img'Last)); end; end if; Result := Name_Find; return Result; end Base_Name_Index_For; ------------------------------ -- Check_Source_Info_In_ALI -- ------------------------------ function Check_Source_Info_In_ALI (The_ALI : ALI_Id; Tree : Project_Tree_Ref) return Name_Id is Result : Name_Id := No_Name; Unit_Name : Name_Id; begin -- Loop through units for U in ALIs.Table (The_ALI).First_Unit .. ALIs.Table (The_ALI).Last_Unit loop -- Check if the file name is one of the source of the unit Get_Name_String (Units.Table (U).Uname); Name_Len := Name_Len - 2; Unit_Name := Name_Find; if File_Not_A_Source_Of (Tree, Unit_Name, Units.Table (U).Sfile) then return No_Name; end if; if Result = No_Name then Result := Unit_Name; end if; -- Loop to do same check for each of the withed units for W in Units.Table (U).First_With .. Units.Table (U).Last_With loop declare WR : ALI.With_Record renames Withs.Table (W); begin if WR.Sfile /= No_File then Get_Name_String (WR.Uname); Name_Len := Name_Len - 2; Unit_Name := Name_Find; if File_Not_A_Source_Of (Tree, Unit_Name, WR.Sfile) then return No_Name; end if; end if; end; end loop; end loop; -- Loop to check subunits and replaced sources for D in ALIs.Table (The_ALI).First_Sdep .. ALIs.Table (The_ALI).Last_Sdep loop declare SD : Sdep_Record renames Sdep.Table (D); begin Unit_Name := SD.Subunit_Name; if Unit_Name = No_Name then -- Check if this source file has been replaced by a source with -- a different file name. if Tree /= null and then Tree.Replaced_Source_Number > 0 then declare Replacement : constant File_Name_Type := Replaced_Source_HTable.Get (Tree.Replaced_Sources, SD.Sfile); begin if Replacement /= No_File then if Verbose_Mode then Write_Line ("source file" & Get_Name_String (SD.Sfile) & " has been replaced by " & Get_Name_String (Replacement)); end if; return No_Name; end if; end; end if; -- Check that a dependent source for a unit that is from a -- project is indeed a source of this unit. Unit_Name := SD.Unit_Name; if Unit_Name /= No_Name and then not Fname.Is_Internal_File_Name (SD.Sfile) and then File_Not_A_Source_Of (Tree, Unit_Name, SD.Sfile) then return No_Name; end if; else -- For separates, the file is no longer associated with the -- unit ("proc-sep.adb" is not associated with unit "proc.sep") -- so we need to check whether the source file still exists in -- the source tree: it will if it matches the naming scheme -- (and then will be for the same unit). if Find_Source (In_Tree => Tree, Project => No_Project, Base_Name => SD.Sfile) = No_Source then -- If this is not a runtime file or if, when gnatmake switch -- -a is used, we are not able to find this subunit in the -- source directories, then recompilation is needed. if not Fname.Is_Internal_File_Name (SD.Sfile) or else (Check_Readonly_Files and then Full_Source_Name (SD.Sfile) = No_File) then if Verbose_Mode then Write_Line ("While parsing ALI file, file " & Get_Name_String (SD.Sfile) & " is indicated as containing subunit " & Get_Name_String (Unit_Name) & " but this does not match what was found while" & " parsing the project. Will recompile"); end if; return No_Name; end if; end if; end if; end; end loop; return Result; end Check_Source_Info_In_ALI; -------------------------------- -- Create_Binder_Mapping_File -- -------------------------------- function Create_Binder_Mapping_File (Project_Tree : Project_Tree_Ref) return Path_Name_Type is Mapping_Path : Path_Name_Type := No_Path; Mapping_FD : File_Descriptor := Invalid_FD; -- A File Descriptor for an eventual mapping file ALI_Unit : Unit_Name_Type := No_Unit_Name; -- The unit name of an ALI file ALI_Name : File_Name_Type := No_File; -- The file name of the ALI file ALI_Project : Project_Id := No_Project; -- The project of the ALI file Bytes : Integer; OK : Boolean := False; Unit : Unit_Index; Status : Boolean; -- For call to Close Iter : Source_Iterator := For_Each_Source (In_Tree => Project_Tree, Language => Name_Ada, Encapsulated_Libs => False, Locally_Removed => False); Source : Prj.Source_Id; begin Tempdir.Create_Temp_File (Mapping_FD, Mapping_Path); Record_Temp_File (Project_Tree.Shared, Mapping_Path); if Mapping_FD /= Invalid_FD then OK := True; loop Source := Element (Iter); exit when Source = No_Source; Unit := Source.Unit; if Source.Replaced_By /= No_Source or else Unit = No_Unit_Index or else Unit.Name = No_Name then ALI_Name := No_File; -- If this is a body, put it in the mapping elsif Source.Kind = Impl and then Unit.File_Names (Impl) /= No_Source and then Unit.File_Names (Impl).Project /= No_Project then Get_Name_String (Unit.Name); Add_Str_To_Name_Buffer ("%b"); ALI_Unit := Name_Find; ALI_Name := Lib_File_Name (Unit.File_Names (Impl).Display_File); ALI_Project := Unit.File_Names (Impl).Project; -- Otherwise, if this is a spec and there is no body, put it in -- the mapping. elsif Source.Kind = Spec and then Unit.File_Names (Impl) = No_Source and then Unit.File_Names (Spec) /= No_Source and then Unit.File_Names (Spec).Project /= No_Project then Get_Name_String (Unit.Name); Add_Str_To_Name_Buffer ("%s"); ALI_Unit := Name_Find; ALI_Name := Lib_File_Name (Unit.File_Names (Spec).Display_File); ALI_Project := Unit.File_Names (Spec).Project; else ALI_Name := No_File; end if; -- If we have something to put in the mapping then do it now. If -- the project is extended, look for the ALI file in the project, -- then in the extending projects in order, and use the last one -- found. if ALI_Name /= No_File then -- Look in the project and the projects that are extending it -- to find the real ALI file. declare ALI : constant String := Get_Name_String (ALI_Name); ALI_Path : Name_Id := No_Name; begin loop -- For library projects, use the library ALI directory, -- for other projects, use the object directory. if ALI_Project.Library then Get_Name_String (ALI_Project.Library_ALI_Dir.Display_Name); else Get_Name_String (ALI_Project.Object_Directory.Display_Name); end if; Add_Str_To_Name_Buffer (ALI); if Is_Regular_File (Name_Buffer (1 .. Name_Len)) then ALI_Path := Name_Find; end if; ALI_Project := ALI_Project.Extended_By; exit when ALI_Project = No_Project; end loop; if ALI_Path /= No_Name then -- First line is the unit name Get_Name_String (ALI_Unit); Add_Char_To_Name_Buffer (ASCII.LF); Bytes := Write (Mapping_FD, Name_Buffer (1)'Address, Name_Len); OK := Bytes = Name_Len; exit when not OK; -- Second line is the ALI file name Get_Name_String (ALI_Name); Add_Char_To_Name_Buffer (ASCII.LF); Bytes := Write (Mapping_FD, Name_Buffer (1)'Address, Name_Len); OK := (Bytes = Name_Len); exit when not OK; -- Third line is the ALI path name Get_Name_String (ALI_Path); Add_Char_To_Name_Buffer (ASCII.LF); Bytes := Write (Mapping_FD, Name_Buffer (1)'Address, Name_Len); OK := (Bytes = Name_Len); -- If OK is False, it means we were unable to write a -- line. No point in continuing with the other units. exit when not OK; end if; end; end if; Next (Iter); end loop; Close (Mapping_FD, Status); OK := OK and Status; end if; -- If the creation of the mapping file was successful, we add the switch -- to the arguments of gnatbind. if OK then return Mapping_Path; else return No_Path; end if; end Create_Binder_Mapping_File; ----------------- -- Create_Name -- ----------------- function Create_Name (Name : String) return File_Name_Type is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; function Create_Name (Name : String) return Name_Id is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; function Create_Name (Name : String) return Path_Name_Type is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); return Name_Find; end Create_Name; --------------------------- -- Ensure_Absolute_Path -- --------------------------- procedure Ensure_Absolute_Path (Switch : in out String_Access; Parent : String; Do_Fail : Fail_Proc; For_Gnatbind : Boolean := False; Including_Non_Switch : Boolean := True; Including_RTS : Boolean := False) is begin if Switch /= null then declare Sw : String (1 .. Switch'Length); Start : Positive; begin Sw := Switch.all; if Sw (1) = '-' then if Sw'Length >= 3 and then (Sw (2) = 'I' or else (not For_Gnatbind and then (Sw (2) = 'L' or else Sw (2) = 'A'))) then Start := 3; if Sw = "-I-" then return; end if; elsif Sw'Length >= 4 and then (Sw (2 .. 3) = "aL" or else Sw (2 .. 3) = "aO" or else Sw (2 .. 3) = "aI" or else (For_Gnatbind and then Sw (2 .. 3) = "A=")) then Start := 4; elsif Including_RTS and then Sw'Length >= 7 and then Sw (2 .. 6) = "-RTS=" then Start := 7; else return; end if; -- Because relative path arguments to --RTS= may be relative to -- the search directory prefix, those relative path arguments -- are converted only when they include directory information. if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then if Parent'Length = 0 then Do_Fail ("relative search path switches (""" & Sw & """) are not allowed"); elsif Including_RTS then for J in Start .. Sw'Last loop if Sw (J) = Directory_Separator then Switch := new String' (Sw (1 .. Start - 1) & Parent & Directory_Separator & Sw (Start .. Sw'Last)); return; end if; end loop; else Switch := new String' (Sw (1 .. Start - 1) & Parent & Directory_Separator & Sw (Start .. Sw'Last)); end if; end if; elsif Including_Non_Switch then if not Is_Absolute_Path (Sw) then if Parent'Length = 0 then Do_Fail ("relative paths (""" & Sw & """) are not allowed"); else Switch := new String'(Parent & Directory_Separator & Sw); end if; end if; end if; end; end if; end Ensure_Absolute_Path; ---------------------------- -- Executable_Prefix_Path -- ---------------------------- function Executable_Prefix_Path return String is Exec_Name : constant String := Command_Name; function Get_Install_Dir (S : String) return String; -- S is the executable name preceded by the absolute or relative path, -- e.g. "c:\usr\bin\gcc.exe". Returns the absolute directory where "bin" -- lies (in the example "C:\usr"). If the executable is not in a "bin" -- directory, return "". --------------------- -- Get_Install_Dir -- --------------------- function Get_Install_Dir (S : String) return String is Exec : String := S; Path_Last : Integer := 0; begin for J in reverse Exec'Range loop if Exec (J) = Directory_Separator then Path_Last := J - 1; exit; end if; end loop; if Path_Last >= Exec'First + 2 then To_Lower (Exec (Path_Last - 2 .. Path_Last)); end if; if Path_Last < Exec'First + 2 or else Exec (Path_Last - 2 .. Path_Last) /= "bin" or else (Path_Last - 3 >= Exec'First and then Exec (Path_Last - 3) /= Directory_Separator) then return ""; end if; return Normalize_Pathname (Exec (Exec'First .. Path_Last - 4), Resolve_Links => Opt.Follow_Links_For_Dirs) & Directory_Separator; end Get_Install_Dir; -- Beginning of Executable_Prefix_Path begin -- First determine if a path prefix was placed in front of the -- executable name. for J in reverse Exec_Name'Range loop if Exec_Name (J) = Directory_Separator then return Get_Install_Dir (Exec_Name); end if; end loop; -- If we get here, the user has typed the executable name with no -- directory prefix. declare Path : String_Access := Locate_Exec_On_Path (Exec_Name); begin if Path = null then return ""; else declare Dir : constant String := Get_Install_Dir (Path.all); begin Free (Path); return Dir; end; end if; end; end Executable_Prefix_Path; ------------------ -- Fail_Program -- ------------------ procedure Fail_Program (Project_Tree : Project_Tree_Ref; S : String; Flush_Messages : Boolean := True) is begin if Flush_Messages and not No_Exit_Message then if Total_Errors_Detected /= 0 or else Warnings_Detected /= 0 then Errutil.Finalize; end if; end if; Finish_Program (Project_Tree, E_Fatal, S => S); end Fail_Program; -------------------- -- Finish_Program -- -------------------- procedure Finish_Program (Project_Tree : Project_Tree_Ref; Exit_Code : Osint.Exit_Code_Type := Osint.E_Success; S : String := "") is begin if not Debug.Debug_Flag_N then Delete_Temp_Config_Files (Project_Tree); if Project_Tree /= null then Delete_All_Temp_Files (Project_Tree.Shared); end if; end if; if S'Length > 0 then if Exit_Code /= E_Success then if No_Exit_Message then Osint.Exit_Program (E_Fatal); else Osint.Fail (S); end if; elsif not No_Exit_Message then Write_Str (S); end if; end if; -- Output Namet statistics Namet.Finalize; Exit_Program (Exit_Code); end Finish_Program; -------------------------- -- File_Not_A_Source_Of -- -------------------------- function File_Not_A_Source_Of (Project_Tree : Project_Tree_Ref; Uname : Name_Id; Sfile : File_Name_Type) return Boolean is Unit : constant Unit_Index := Units_Htable.Get (Project_Tree.Units_HT, Uname); At_Least_One_File : Boolean := False; begin if Unit /= No_Unit_Index then for F in Unit.File_Names'Range loop if Unit.File_Names (F) /= null then At_Least_One_File := True; if Unit.File_Names (F).File = Sfile then return False; end if; end if; end loop; if not At_Least_One_File then -- The unit was probably created initially for a separate unit -- (which are initially created as IMPL when both suffixes are the -- same). Later on, Override_Kind changed the type of the file, -- and the unit is no longer valid in fact. return False; end if; Verbose_Msg (Uname, "sources do not include ", Name_Id (Sfile)); return True; end if; return False; end File_Not_A_Source_Of; --------------------- -- Get_Directories -- --------------------- procedure Get_Directories (Project_Tree : Project_Tree_Ref; For_Project : Project_Id; Activity : Activity_Type; Languages : Name_Ids) is procedure Recursive_Add (Project : Project_Id; Tree : Project_Tree_Ref; Extended : in out Boolean); -- Add all the source directories of a project to the path only if -- this project has not been visited. Calls itself recursively for -- projects being extended, and imported projects. procedure Add_Dir (Value : Path_Name_Type); -- Add directory Value in table Directories, if it is defined and not -- already there. ------------- -- Add_Dir -- ------------- procedure Add_Dir (Value : Path_Name_Type) is Add_It : Boolean := True; begin if Value /= No_Path and then Is_Directory (Get_Name_String (Value)) then for Index in 1 .. Directories.Last loop if Directories.Table (Index) = Value then Add_It := False; exit; end if; end loop; if Add_It then Directories.Increment_Last; Directories.Table (Directories.Last) := Value; end if; end if; end Add_Dir; ------------------- -- Recursive_Add -- ------------------- procedure Recursive_Add (Project : Project_Id; Tree : Project_Tree_Ref; Extended : in out Boolean) is Current : String_List_Id; Dir : String_Element; OK : Boolean := False; Lang_Proc : Language_Ptr := Project.Languages; begin -- Add to path all directories of this project if Activity = Compilation then Lang_Loop : while Lang_Proc /= No_Language_Index loop for J in Languages'Range loop OK := Lang_Proc.Name = Languages (J); exit Lang_Loop when OK; end loop; Lang_Proc := Lang_Proc.Next; end loop Lang_Loop; if OK then Current := Project.Source_Dirs; while Current /= Nil_String loop Dir := Tree.Shared.String_Elements.Table (Current); Add_Dir (Path_Name_Type (Dir.Value)); Current := Dir.Next; end loop; end if; elsif Project.Library then if Activity = SAL_Binding and then Extended then Add_Dir (Project.Object_Directory.Display_Name); else Add_Dir (Project.Library_ALI_Dir.Display_Name); end if; else Add_Dir (Project.Object_Directory.Display_Name); end if; if Project.Extends = No_Project then Extended := False; end if; end Recursive_Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Recursive_Add); Extended : Boolean := True; -- Start of processing for Get_Directories begin Directories.Init; For_All_Projects (For_Project, Project_Tree, Extended); end Get_Directories; ------------------ -- Get_Switches -- ------------------ procedure Get_Switches (Source : Prj.Source_Id; Pkg_Name : Name_Id; Project_Tree : Project_Tree_Ref; Value : out Variable_Value; Is_Default : out Boolean) is begin Get_Switches (Source_File => Source.File, Source_Lang => Source.Language.Name, Source_Prj => Source.Project, Pkg_Name => Pkg_Name, Project_Tree => Project_Tree, Value => Value, Is_Default => Is_Default); end Get_Switches; ------------------ -- Get_Switches -- ------------------ procedure Get_Switches (Source_File : File_Name_Type; Source_Lang : Name_Id; Source_Prj : Project_Id; Pkg_Name : Name_Id; Project_Tree : Project_Tree_Ref; Value : out Variable_Value; Is_Default : out Boolean; Test_Without_Suffix : Boolean := False; Check_ALI_Suffix : Boolean := False) is Project : constant Project_Id := Ultimate_Extending_Project_Of (Source_Prj); Pkg : constant Package_Id := Prj.Util.Value_Of (Name => Pkg_Name, In_Packages => Project.Decl.Packages, Shared => Project_Tree.Shared); Lang : Language_Ptr; begin Is_Default := False; if Source_File /= No_File then Value := Prj.Util.Value_Of (Name => Name_Id (Source_File), Attribute_Or_Array_Name => Name_Switches, In_Package => Pkg, Shared => Project_Tree.Shared, Allow_Wildcards => True); end if; if Value = Nil_Variable_Value and then Test_Without_Suffix then Lang := Get_Language_From_Name (Project, Get_Name_String (Source_Lang)); if Lang /= null then declare Naming : Lang_Naming_Data renames Lang.Config.Naming_Data; SF_Name : constant String := Get_Name_String (Source_File); Last : Positive := SF_Name'Length; Name : String (1 .. Last + 3); Spec_Suffix : String := Get_Name_String (Naming.Spec_Suffix); Body_Suffix : String := Get_Name_String (Naming.Body_Suffix); Truncated : Boolean := False; begin Canonical_Case_File_Name (Spec_Suffix); Canonical_Case_File_Name (Body_Suffix); Name (1 .. Last) := SF_Name; if Last > Body_Suffix'Length and then Name (Last - Body_Suffix'Length + 1 .. Last) = Body_Suffix then Truncated := True; Last := Last - Body_Suffix'Length; end if; if not Truncated and then Last > Spec_Suffix'Length and then Name (Last - Spec_Suffix'Length + 1 .. Last) = Spec_Suffix then Truncated := True; Last := Last - Spec_Suffix'Length; end if; if Truncated then Name_Len := 0; Add_Str_To_Name_Buffer (Name (1 .. Last)); Value := Prj.Util.Value_Of (Name => Name_Find, Attribute_Or_Array_Name => Name_Switches, In_Package => Pkg, Shared => Project_Tree.Shared, Allow_Wildcards => True); end if; if Value = Nil_Variable_Value and then Check_ALI_Suffix then Last := SF_Name'Length; while Name (Last) /= '.' loop Last := Last - 1; end loop; Name_Len := 0; Add_Str_To_Name_Buffer (Name (1 .. Last)); Add_Str_To_Name_Buffer ("ali"); Value := Prj.Util.Value_Of (Name => Name_Find, Attribute_Or_Array_Name => Name_Switches, In_Package => Pkg, Shared => Project_Tree.Shared, Allow_Wildcards => True); end if; end; end if; end if; if Value = Nil_Variable_Value then Is_Default := True; Value := Prj.Util.Value_Of (Name => Source_Lang, Attribute_Or_Array_Name => Name_Switches, In_Package => Pkg, Shared => Project_Tree.Shared, Force_Lower_Case_Index => True); end if; if Value = Nil_Variable_Value then Value := Prj.Util.Value_Of (Name => All_Other_Names, Attribute_Or_Array_Name => Name_Switches, In_Package => Pkg, Shared => Project_Tree.Shared, Force_Lower_Case_Index => True); end if; if Value = Nil_Variable_Value then Value := Prj.Util.Value_Of (Name => Source_Lang, Attribute_Or_Array_Name => Name_Default_Switches, In_Package => Pkg, Shared => Project_Tree.Shared); end if; end Get_Switches; ------------ -- Inform -- ------------ procedure Inform (N : File_Name_Type; Msg : String) is begin Inform (Name_Id (N), Msg); end Inform; procedure Inform (N : Name_Id := No_Name; Msg : String) is begin Osint.Write_Program_Name; Write_Str (": "); if N /= No_Name then Write_Str (""""); declare Name : constant String := Get_Name_String (N); begin if Debug.Debug_Flag_F and then Is_Absolute_Path (Name) then Write_Str (File_Name (Name)); else Write_Str (Name); end if; end; Write_Str (""" "); end if; Write_Str (Msg); Write_Eol; end Inform; ------------------------------ -- Initialize_Source_Record -- ------------------------------ procedure Initialize_Source_Record (Source : Prj.Source_Id) is procedure Set_Object_Project (Obj_Dir : String; Obj_Proj : Project_Id; Obj_Path : Path_Name_Type; Stamp : Time_Stamp_Type); -- Update information about object file, switches file,... ------------------------ -- Set_Object_Project -- ------------------------ procedure Set_Object_Project (Obj_Dir : String; Obj_Proj : Project_Id; Obj_Path : Path_Name_Type; Stamp : Time_Stamp_Type) is begin Source.Object_Project := Obj_Proj; Source.Object_Path := Obj_Path; Source.Object_TS := Stamp; if Source.Language.Config.Dependency_Kind /= None then declare Dep_Path : constant String := Normalize_Pathname (Name => Get_Name_String (Source.Dep_Name), Resolve_Links => Opt.Follow_Links_For_Files, Directory => Obj_Dir); begin Source.Dep_Path := Create_Name (Dep_Path); Source.Dep_TS := Osint.Unknown_Attributes; end; end if; -- Get the path of the switches file, even if Opt.Check_Switches is -- not set, as switch -s may be in the Builder switches that have not -- been scanned yet. declare Switches_Path : constant String := Normalize_Pathname (Name => Get_Name_String (Source.Switches), Resolve_Links => Opt.Follow_Links_For_Files, Directory => Obj_Dir); begin Source.Switches_Path := Create_Name (Switches_Path); if Stamp /= Empty_Time_Stamp then Source.Switches_TS := File_Stamp (Source.Switches_Path); end if; end; end Set_Object_Project; Obj_Proj : Project_Id; begin -- Nothing to do if source record has already been fully initialized if Source.Initialized then return; end if; -- Systematically recompute the time stamp Source.Source_TS := File_Stamp (Source.Path.Display_Name); -- Parse the source file to check whether we have a subunit if Source.Language.Config.Kind = Unit_Based and then Source.Kind = Impl and then Is_Subunit (Source) then Source.Kind := Sep; end if; if Source.Language.Config.Object_Generated and then Is_Compilable (Source) then -- First, get the correct object file name and dependency file name -- if the source is in a multi-unit file. if Source.Index /= 0 then Source.Object := Object_Name (Source_File_Name => Source.File, Source_Index => Source.Index, Index_Separator => Source.Language.Config.Multi_Unit_Object_Separator, Object_File_Suffix => Source.Language.Config.Object_File_Suffix); Source.Dep_Name := Dependency_Name (Source.Object, Source.Language.Config.Dependency_Kind); end if; -- Find the object file for that source. It could be either in the -- current project or in an extended project (it might actually not -- exist yet in the ultimate extending project, but if not found -- elsewhere that's where we'll expect to find it). Obj_Proj := Source.Project; while Obj_Proj /= No_Project loop if Obj_Proj.Object_Directory /= No_Path_Information then declare Dir : constant String := Get_Name_String (Obj_Proj.Object_Directory.Display_Name); Object_Path : constant String := Normalize_Pathname (Name => Get_Name_String (Source.Object), Resolve_Links => Opt.Follow_Links_For_Files, Directory => Dir); Obj_Path : constant Path_Name_Type := Create_Name (Object_Path); Stamp : Time_Stamp_Type := Empty_Time_Stamp; begin -- For specs, we do not check object files if there is a -- body. This saves a system call. On the other hand, we do -- need to know the object_path, in case the user has passed -- the .ads on the command line to compile the spec only. if Source.Kind /= Spec or else Source.Unit = No_Unit_Index or else Source.Unit.File_Names (Impl) = No_Source then Stamp := File_Stamp (Obj_Path); end if; if Stamp /= Empty_Time_Stamp or else (Obj_Proj.Extended_By = No_Project and then Source.Object_Project = No_Project) then Set_Object_Project (Dir, Obj_Proj, Obj_Path, Stamp); end if; end; end if; Obj_Proj := Obj_Proj.Extended_By; end loop; elsif Source.Language.Config.Dependency_Kind = Makefile then declare Object_Dir : constant String := Get_Name_String (Source.Project.Object_Directory.Display_Name); Dep_Path : constant String := Normalize_Pathname (Name => Get_Name_String (Source.Dep_Name), Resolve_Links => Opt.Follow_Links_For_Files, Directory => Object_Dir); begin Source.Dep_Path := Create_Name (Dep_Path); Source.Dep_TS := Osint.Unknown_Attributes; end; end if; Source.Initialized := True; end Initialize_Source_Record; ---------------------------- -- Is_External_Assignment -- ---------------------------- function Is_External_Assignment (Env : Prj.Tree.Environment; Argv : String) return Boolean is Start : Positive := 3; Finish : Natural := Argv'Last; pragma Assert (Argv'First = 1); pragma Assert (Argv (1 .. 2) = "-X"); begin if Argv'Last < 5 then return False; elsif Argv (3) = '"' then if Argv (Argv'Last) /= '"' or else Argv'Last < 7 then return False; else Start := 4; Finish := Argv'Last - 1; end if; end if; return Prj.Ext.Check (Self => Env.External, Declaration => Argv (Start .. Finish)); end Is_External_Assignment; ---------------- -- Is_Subunit -- ---------------- function Is_Subunit (Source : Prj.Source_Id) return Boolean is Src_Ind : Source_File_Index; begin if Source.Kind = Sep then return True; -- A Spec, a file based language source or a body with a spec cannot be -- a subunit. elsif Source.Kind = Spec or else Source.Unit = No_Unit_Index or else Other_Part (Source) /= No_Source then return False; end if; -- Here, we are assuming that the language is Ada, as it is the only -- unit based language that we know. Src_Ind := Sinput.P.Load_Project_File (Get_Name_String (Source.Path.Display_Name)); return Sinput.P.Source_File_Is_Subunit (Src_Ind); end Is_Subunit; ----------------------------- -- Linker_Options_Switches -- ----------------------------- function Linker_Options_Switches (Project : Project_Id; Do_Fail : Fail_Proc; In_Tree : Project_Tree_Ref) return String_List is procedure Recursive_Add (Proj : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean); -- The recursive routine used to add linker options ------------------- -- Recursive_Add -- ------------------- procedure Recursive_Add (Proj : Project_Id; In_Tree : Project_Tree_Ref; Dummy : in out Boolean) is Linker_Package : Package_Id; Options : Variable_Value; begin Linker_Package := Prj.Util.Value_Of (Name => Name_Linker, In_Packages => Proj.Decl.Packages, Shared => In_Tree.Shared); Options := Prj.Util.Value_Of (Name => Name_Ada, Index => 0, Attribute_Or_Array_Name => Name_Linker_Options, In_Package => Linker_Package, Shared => In_Tree.Shared); -- If attribute is present, add the project with the attribute to -- table Linker_Opts. if Options /= Nil_Variable_Value then Linker_Opts.Increment_Last; Linker_Opts.Table (Linker_Opts.Last) := (Project => Proj, Options => Options.Values); end if; end Recursive_Add; procedure For_All_Projects is new For_Every_Project_Imported (Boolean, Recursive_Add); Dummy : Boolean := False; -- Start of processing for Linker_Options_Switches begin Linker_Opts.Init; For_All_Projects (Project, In_Tree, Dummy, Imported_First => True); Last_Linker_Option := 0; for Index in reverse 1 .. Linker_Opts.Last loop declare Options : String_List_Id; Proj : constant Project_Id := Linker_Opts.Table (Index).Project; Option : Name_Id; Dir_Path : constant String := Get_Name_String (Proj.Directory.Name); begin Options := Linker_Opts.Table (Index).Options; while Options /= Nil_String loop Option := In_Tree.Shared.String_Elements.Table (Options).Value; Get_Name_String (Option); -- Do not consider empty linker options if Name_Len /= 0 then Add_Linker_Option (Name_Buffer (1 .. Name_Len)); -- Object files and -L switches specified with relative -- paths must be converted to absolute paths. Ensure_Absolute_Path (Switch => Linker_Options_Buffer (Last_Linker_Option), Parent => Dir_Path, Do_Fail => Do_Fail, For_Gnatbind => False); end if; Options := In_Tree.Shared.String_Elements.Table (Options).Next; end loop; end; end loop; return Linker_Options_Buffer (1 .. Last_Linker_Option); end Linker_Options_Switches; ----------- -- Mains -- ----------- package body Mains is package Names is new Table.Table (Table_Component_Type => Main_Info, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 10, Table_Increment => 100, Table_Name => "Makeutl.Mains.Names"); -- The table that stores the mains Current : Natural := 0; -- The index of the last main retrieved from the table Count_Of_Mains_With_No_Tree : Natural := 0; -- Number of main units for which we do not know the project tree -------------- -- Add_Main -- -------------- procedure Add_Main (Name : String; Index : Int := 0; Location : Source_Ptr := No_Location; Project : Project_Id := No_Project; Tree : Project_Tree_Ref := null) is begin if Current_Verbosity = High then Debug_Output ("Add_Main """ & Name & """ " & Index'Img & " with_tree? " & Boolean'Image (Tree /= null)); end if; Name_Len := 0; Add_Str_To_Name_Buffer (Name); Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); Names.Increment_Last; Names.Table (Names.Last) := (Name_Find, Index, Location, No_Source, Project, Tree); if Tree /= null then Builder_Data (Tree).Number_Of_Mains := Builder_Data (Tree).Number_Of_Mains + 1; else Mains.Count_Of_Mains_With_No_Tree := Mains.Count_Of_Mains_With_No_Tree + 1; end if; end Add_Main; -------------------- -- Complete_Mains -- -------------------- procedure Complete_Mains (Flags : Processing_Flags; Root_Project : Project_Id; Project_Tree : Project_Tree_Ref) is procedure Do_Complete (Project : Project_Id; Tree : Project_Tree_Ref); -- Check the mains for this specific project procedure Complete_All is new For_Project_And_Aggregated (Do_Complete); procedure Add_Multi_Unit_Sources (Tree : Project_Tree_Ref; Source : Prj.Source_Id); -- Add all units from the same file as the multi-unit Source function Find_File_Add_Extension (Tree : Project_Tree_Ref; Base_Main : String) return Prj.Source_Id; -- Search for Main in the project, adding body or spec extensions ---------------------------- -- Add_Multi_Unit_Sources -- ---------------------------- procedure Add_Multi_Unit_Sources (Tree : Project_Tree_Ref; Source : Prj.Source_Id) is Iter : Source_Iterator; Src : Prj.Source_Id; begin Debug_Output ("found multi-unit source file in project", Source.Project.Name); Iter := For_Each_Source (In_Tree => Tree, Project => Source.Project); while Element (Iter) /= No_Source loop Src := Element (Iter); if Src.File = Source.File and then Src.Index /= Source.Index then if Src.File = Source.File then Debug_Output ("add main in project, index=" & Src.Index'Img); end if; Names.Increment_Last; Names.Table (Names.Last) := (File => Src.File, Index => Src.Index, Location => No_Location, Source => Src, Project => Src.Project, Tree => Tree); Builder_Data (Tree).Number_Of_Mains := Builder_Data (Tree).Number_Of_Mains + 1; end if; Next (Iter); end loop; end Add_Multi_Unit_Sources; ----------------------------- -- Find_File_Add_Extension -- ----------------------------- function Find_File_Add_Extension (Tree : Project_Tree_Ref; Base_Main : String) return Prj.Source_Id is Spec_Source : Prj.Source_Id := No_Source; Source : Prj.Source_Id; Iter : Source_Iterator; Suffix : File_Name_Type; begin Source := No_Source; Iter := For_Each_Source (Tree); -- In all projects loop Source := Prj.Element (Iter); exit when Source = No_Source; if Source.Kind = Impl then Get_Name_String (Source.File); if Name_Len > Base_Main'Length and then Name_Buffer (1 .. Base_Main'Length) = Base_Main then Suffix := Source.Language.Config.Naming_Data.Body_Suffix; if Suffix /= No_File then declare Suffix_Str : String := Get_Name_String (Suffix); begin Canonical_Case_File_Name (Suffix_Str); exit when Name_Buffer (Base_Main'Length + 1 .. Name_Len) = Suffix_Str; end; end if; end if; elsif Source.Kind = Spec and then Source.Language.Config.Kind = Unit_Based then -- An Ada spec needs to be taken into account unless there -- is also a body. So we delay the decision for them. Get_Name_String (Source.File); if Name_Len > Base_Main'Length and then Name_Buffer (1 .. Base_Main'Length) = Base_Main then Suffix := Source.Language.Config.Naming_Data.Spec_Suffix; if Suffix /= No_File then declare Suffix_Str : String := Get_Name_String (Suffix); begin Canonical_Case_File_Name (Suffix_Str); if Name_Buffer (Base_Main'Length + 1 .. Name_Len) = Suffix_Str then Spec_Source := Source; end if; end; end if; end if; end if; Next (Iter); end loop; if Source = No_Source then Source := Spec_Source; end if; return Source; end Find_File_Add_Extension; ----------------- -- Do_Complete -- ----------------- procedure Do_Complete (Project : Project_Id; Tree : Project_Tree_Ref) is J : Integer; begin if Mains.Number_Of_Mains (Tree) > 0 or else Mains.Count_Of_Mains_With_No_Tree > 0 then -- Traverse in reverse order, since in the case of multi-unit -- files we will be adding extra files at the end, and there's -- no need to process them in turn. J := Names.Last; Main_Loop : loop declare File : Main_Info := Names.Table (J); Main_Id : File_Name_Type := File.File; Main : constant String := Get_Name_String (Main_Id); Base : constant String := Base_Name (Main); Source : Prj.Source_Id := No_Source; Is_Absolute : Boolean := False; begin if Base /= Main then Is_Absolute := True; if Is_Absolute_Path (Main) then Main_Id := Create_Name (Base); -- Not an absolute path else -- Always resolve links here, so that users can be -- specify any name on the command line. If the -- project itself uses links, the user will be -- using -eL anyway, and thus files are also stored -- with resolved names. declare Absolute : constant String := Normalize_Pathname (Name => Main, Directory => "", Resolve_Links => True, Case_Sensitive => False); begin File.File := Create_Name (Absolute); Main_Id := Create_Name (Base); end; end if; end if; -- If no project or tree was specified for the main, it -- came from the command line. -- Note that the assignments below will not modify inside -- the table itself. if File.Project = null then File.Project := Project; end if; if File.Tree = null then File.Tree := Tree; end if; if File.Source = null then if Current_Verbosity = High then Debug_Output ("search for main """ & Main & '"' & File.Index'Img & " in " & Get_Name_String (Debug_Name (File.Tree)) & ", project", Project.Name); end if; -- First, look for the main as specified. We need to -- search for the base name though, and if needed -- check later that we found the correct file. declare Sources : constant Source_Ids := Find_All_Sources (In_Tree => File.Tree, Project => File.Project, Base_Name => Main_Id, Index => File.Index, In_Imported_Only => True); begin if Is_Absolute then for J in Sources'Range loop if File_Name_Type (Sources (J).Path.Name) = File.File then Source := Sources (J); exit; end if; end loop; elsif Sources'Length > 1 then -- This is only allowed if the units are from -- the same multi-unit source file. Source := Sources (1); for J in 2 .. Sources'Last loop if Sources (J).Path /= Source.Path or else Sources (J).Index = Source.Index then Error_Msg_File_1 := Main_Id; Prj.Err.Error_Msg (Flags, "several main sources {", No_Location, File.Project); exit Main_Loop; end if; end loop; elsif Sources'Length = 1 then Source := Sources (Sources'First); end if; end; if Source = No_Source then Source := Find_File_Add_Extension (File.Tree, Get_Name_String (Main_Id)); end if; if Is_Absolute and then Source /= No_Source and then File_Name_Type (Source.Path.Name) /= File.File then Debug_Output ("Found a non-matching file", Name_Id (Source.Path.Display_Name)); Source := No_Source; end if; if Source /= No_Source then if not Is_Allowed_Language (Source.Language.Name) then -- Remove any main that is not in the list of -- restricted languages. Names.Table (J .. Names.Last - 1) := Names.Table (J + 1 .. Names.Last); Names.Set_Last (Names.Last - 1); else -- If we have found a multi-unit source file but -- did not specify an index initially, we'll -- need to compile all the units from the same -- source file. if Source.Index /= 0 and then File.Index = 0 then Add_Multi_Unit_Sources (File.Tree, Source); end if; -- Now update the original Main, otherwise it -- will be reported as not found. Debug_Output ("found main in project", Source.Project.Name); Names.Table (J).File := Source.File; Names.Table (J).Project := Source.Project; if Names.Table (J).Tree = null then Names.Table (J).Tree := File.Tree; Builder_Data (File.Tree).Number_Of_Mains := Builder_Data (File.Tree).Number_Of_Mains + 1; Mains.Count_Of_Mains_With_No_Tree := Mains.Count_Of_Mains_With_No_Tree - 1; end if; Names.Table (J).Source := Source; Names.Table (J).Index := Source.Index; end if; elsif File.Location /= No_Location then -- If the main is declared in package Builder of -- the main project, report an error. If the main -- is on the command line, it may be a main from -- another project, so do nothing: if the main does -- not exist in another project, an error will be -- reported later. Error_Msg_File_1 := Main_Id; Error_Msg_Name_1 := File.Project.Name; Prj.Err.Error_Msg (Flags, "{ is not a source of project %%", File.Location, File.Project); end if; end if; end; J := J - 1; exit Main_Loop when J < Names.First; end loop Main_Loop; end if; if Total_Errors_Detected > 0 then Fail_Program (Tree, "problems with main sources"); end if; end Do_Complete; -- Start of processing for Complete_Mains begin Complete_All (Root_Project, Project_Tree); if Mains.Count_Of_Mains_With_No_Tree > 0 then for J in Names.First .. Names.Last loop if Names.Table (J).Source = No_Source then Fail_Program (Project_Tree, '"' & Get_Name_String (Names.Table (J).File) & """ is not a source of any project"); end if; end loop; end if; end Complete_Mains; ------------ -- Delete -- ------------ procedure Delete is begin Names.Set_Last (0); Mains.Reset; end Delete; ----------------------- -- Fill_From_Project -- ----------------------- procedure Fill_From_Project (Root_Project : Project_Id; Project_Tree : Project_Tree_Ref) is procedure Add_Mains_From_Project (Project : Project_Id; Tree : Project_Tree_Ref); -- Add the main units from this project into Mains. -- This takes into account the aggregated projects ---------------------------- -- Add_Mains_From_Project -- ---------------------------- procedure Add_Mains_From_Project (Project : Project_Id; Tree : Project_Tree_Ref) is List : String_List_Id; Element : String_Element; begin if Number_Of_Mains (Tree) = 0 and then Mains.Count_Of_Mains_With_No_Tree = 0 then Debug_Output ("Add_Mains_From_Project", Project.Name); List := Project.Mains; if List /= Prj.Nil_String then -- The attribute Main is not an empty list. Get the mains in -- the list. while List /= Prj.Nil_String loop Element := Tree.Shared.String_Elements.Table (List); Debug_Output ("Add_Main", Element.Value); if Project.Library then Fail_Program (Tree, "cannot specify a main program " & "for a library project file"); end if; Add_Main (Name => Get_Name_String (Element.Value), Index => Element.Index, Location => Element.Location, Project => Project, Tree => Tree); List := Element.Next; end loop; end if; end if; if Total_Errors_Detected > 0 then Fail_Program (Tree, "problems with main sources"); end if; end Add_Mains_From_Project; procedure Fill_All is new For_Project_And_Aggregated (Add_Mains_From_Project); -- Start of processing for Fill_From_Project begin Fill_All (Root_Project, Project_Tree); end Fill_From_Project; --------------- -- Next_Main -- --------------- function Next_Main return String is Info : constant Main_Info := Next_Main; begin if Info = No_Main_Info then return ""; else return Get_Name_String (Info.File); end if; end Next_Main; function Next_Main return Main_Info is begin if Current >= Names.Last then return No_Main_Info; else Current := Current + 1; -- If not using projects, and in the gnatmake case, the main file -- may have not have the extension. Try ".adb" first then ".ads" if Names.Table (Current).Project = No_Project then declare Orig_Main : constant File_Name_Type := Names.Table (Current).File; Current_Main : File_Name_Type; begin if Strip_Suffix (Orig_Main) = Orig_Main then Get_Name_String (Orig_Main); Add_Str_To_Name_Buffer (".adb"); Current_Main := Name_Find; if Full_Source_Name (Current_Main) = No_File then Get_Name_String (Orig_Main); Add_Str_To_Name_Buffer (".ads"); Current_Main := Name_Find; if Full_Source_Name (Current_Main) /= No_File then Names.Table (Current).File := Current_Main; end if; else Names.Table (Current).File := Current_Main; end if; end if; end; end if; return Names.Table (Current); end if; end Next_Main; --------------------- -- Number_Of_Mains -- --------------------- function Number_Of_Mains (Tree : Project_Tree_Ref) return Natural is begin if Tree = null then return Names.Last; else return Builder_Data (Tree).Number_Of_Mains; end if; end Number_Of_Mains; ----------- -- Reset -- ----------- procedure Reset is begin Current := 0; end Reset; -------------------------- -- Set_Multi_Unit_Index -- -------------------------- procedure Set_Multi_Unit_Index (Project_Tree : Project_Tree_Ref := null; Index : Int := 0) is begin if Index /= 0 then if Names.Last = 0 then Fail_Program (Project_Tree, "cannot specify a multi-unit index but no main " & "on the command line"); elsif Names.Last > 1 then Fail_Program (Project_Tree, "cannot specify several mains with a multi-unit index"); else Names.Table (Names.Last).Index := Index; end if; end if; end Set_Multi_Unit_Index; end Mains; ----------------------- -- Path_Or_File_Name -- ----------------------- function Path_Or_File_Name (Path : Path_Name_Type) return String is Path_Name : constant String := Get_Name_String (Path); begin if Debug.Debug_Flag_F then return File_Name (Path_Name); else return Path_Name; end if; end Path_Or_File_Name; ------------------- -- Unit_Index_Of -- ------------------- function Unit_Index_Of (ALI_File : File_Name_Type) return Int is Start : Natural; Finish : Natural; Result : Int := 0; begin Get_Name_String (ALI_File); -- First, find the last dot Finish := Name_Len; while Finish >= 1 and then Name_Buffer (Finish) /= '.' loop Finish := Finish - 1; end loop; if Finish = 1 then return 0; end if; -- Now check that the dot is preceded by digits Start := Finish; Finish := Finish - 1; while Start >= 1 and then Name_Buffer (Start - 1) in '0' .. '9' loop Start := Start - 1; end loop; -- If there are no digits, or if the digits are not preceded by the -- character that precedes a unit index, this is not the ALI file of -- a unit in a multi-unit source. if Start > Finish or else Start = 1 or else Name_Buffer (Start - 1) /= Multi_Unit_Index_Character then return 0; end if; -- Build the index from the digit(s) while Start <= Finish loop Result := Result * 10 + Character'Pos (Name_Buffer (Start)) - Character'Pos ('0'); Start := Start + 1; end loop; return Result; end Unit_Index_Of; ----------------- -- Verbose_Msg -- ----------------- procedure Verbose_Msg (N1 : Name_Id; S1 : String; N2 : Name_Id := No_Name; S2 : String := ""; Prefix : String := " -> "; Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low) is begin if not Opt.Verbose_Mode or else Minimum_Verbosity > Opt.Verbosity_Level then return; end if; Write_Str (Prefix); Write_Str (""""); Write_Name (N1); Write_Str (""" "); Write_Str (S1); if N2 /= No_Name then Write_Str (" """); Write_Name (N2); Write_Str (""" "); end if; Write_Str (S2); Write_Eol; end Verbose_Msg; procedure Verbose_Msg (N1 : File_Name_Type; S1 : String; N2 : File_Name_Type := No_File; S2 : String := ""; Prefix : String := " -> "; Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low) is begin Verbose_Msg (Name_Id (N1), S1, Name_Id (N2), S2, Prefix, Minimum_Verbosity); end Verbose_Msg; ----------- -- Queue -- ----------- package body Queue is type Q_Record is record Info : Source_Info; Processed : Boolean; end record; package Q is new Table.Table (Table_Component_Type => Q_Record, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 1000, Table_Increment => 100, Table_Name => "Makeutl.Queue.Q"); -- This is the actual Queue package Busy_Obj_Dirs is new GNAT.HTable.Simple_HTable (Header_Num => Prj.Header_Num, Element => Boolean, No_Element => False, Key => Path_Name_Type, Hash => Hash, Equal => "="); type Mark_Key is record File : File_Name_Type; Index : Int; end record; -- Identify either a mono-unit source (when Index = 0) or a specific -- unit (index = 1's origin index of unit) in a multi-unit source. Max_Mask_Num : constant := 2048; subtype Mark_Num is Union_Id range 0 .. Max_Mask_Num - 1; function Hash (Key : Mark_Key) return Mark_Num; package Marks is new GNAT.HTable.Simple_HTable (Header_Num => Mark_Num, Element => Boolean, No_Element => False, Key => Mark_Key, Hash => Hash, Equal => "="); -- A hash table to keep tracks of the marked units. -- These are the units that have already been processed, when using the -- gnatmake format. When using the gprbuild format, we can directly -- store in the source_id whether the file has already been processed. procedure Mark (Source_File : File_Name_Type; Index : Int := 0); -- Mark a unit, identified by its source file and, when Index is not 0, -- the index of the unit in the source file. Marking is used to signal -- that the unit has already been inserted in the Q. function Is_Marked (Source_File : File_Name_Type; Index : Int := 0) return Boolean; -- Returns True if the unit was previously marked Q_Processed : Natural := 0; Q_Initialized : Boolean := False; Q_First : Natural := 1; -- Points to the first valid element in the queue One_Queue_Per_Obj_Dir : Boolean := False; -- See parameter to Initialize function Available_Obj_Dir (S : Source_Info) return Boolean; -- Whether the object directory for S is available for a build procedure Debug_Display (S : Source_Info); -- A debug display for S function Was_Processed (S : Source_Info) return Boolean; -- Whether S has already been processed. This marks the source as -- processed, if it hasn't already been processed. function Insert_No_Roots (Source : Source_Info) return Boolean; -- Insert Source, but do not look for its roots (see doc for Insert) ------------------- -- Was_Processed -- ------------------- function Was_Processed (S : Source_Info) return Boolean is begin case S.Format is when Format_Gprbuild => if S.Id.In_The_Queue then return True; end if; S.Id.In_The_Queue := True; when Format_Gnatmake => if Is_Marked (S.File, S.Index) then return True; end if; Mark (S.File, Index => S.Index); end case; return False; end Was_Processed; ----------------------- -- Available_Obj_Dir -- ----------------------- function Available_Obj_Dir (S : Source_Info) return Boolean is begin case S.Format is when Format_Gprbuild => return not Busy_Obj_Dirs.Get (S.Id.Project.Object_Directory.Name); when Format_Gnatmake => return S.Project = No_Project or else not Busy_Obj_Dirs.Get (S.Project.Object_Directory.Name); end case; end Available_Obj_Dir; ------------------- -- Debug_Display -- ------------------- procedure Debug_Display (S : Source_Info) is begin case S.Format is when Format_Gprbuild => Write_Name (S.Id.File); if S.Id.Index /= 0 then Write_Str (", "); Write_Int (S.Id.Index); end if; when Format_Gnatmake => Write_Name (S.File); if S.Index /= 0 then Write_Str (", "); Write_Int (S.Index); end if; end case; end Debug_Display; ---------- -- Hash -- ---------- function Hash (Key : Mark_Key) return Mark_Num is begin return Union_Id (Key.File) mod Max_Mask_Num; end Hash; --------------- -- Is_Marked -- --------------- function Is_Marked (Source_File : File_Name_Type; Index : Int := 0) return Boolean is begin return Marks.Get (K => (File => Source_File, Index => Index)); end Is_Marked; ---------- -- Mark -- ---------- procedure Mark (Source_File : File_Name_Type; Index : Int := 0) is begin Marks.Set (K => (File => Source_File, Index => Index), E => True); end Mark; ------------- -- Extract -- ------------- procedure Extract (Found : out Boolean; Source : out Source_Info) is begin Found := False; if One_Queue_Per_Obj_Dir then for J in Q_First .. Q.Last loop if not Q.Table (J).Processed and then Available_Obj_Dir (Q.Table (J).Info) then Found := True; Source := Q.Table (J).Info; Q.Table (J).Processed := True; if J = Q_First then while Q_First <= Q.Last and then Q.Table (Q_First).Processed loop Q_First := Q_First + 1; end loop; end if; exit; end if; end loop; elsif Q_First <= Q.Last then Source := Q.Table (Q_First).Info; Q.Table (Q_First).Processed := True; Q_First := Q_First + 1; Found := True; end if; if Found then Q_Processed := Q_Processed + 1; end if; if Found and then Debug.Debug_Flag_Q then Write_Str (" Q := Q - [ "); Debug_Display (Source); Write_Str (" ]"); Write_Eol; Write_Str (" Q_First ="); Write_Int (Int (Q_First)); Write_Eol; Write_Str (" Q.Last ="); Write_Int (Int (Q.Last)); Write_Eol; end if; end Extract; --------------- -- Processed -- --------------- function Processed return Natural is begin return Q_Processed; end Processed; ---------------- -- Initialize -- ---------------- procedure Initialize (Queue_Per_Obj_Dir : Boolean; Force : Boolean := False) is begin if Force or else not Q_Initialized then Q_Initialized := True; for J in 1 .. Q.Last loop case Q.Table (J).Info.Format is when Format_Gprbuild => Q.Table (J).Info.Id.In_The_Queue := False; when Format_Gnatmake => null; end case; end loop; Q.Init; Q_Processed := 0; Q_First := 1; One_Queue_Per_Obj_Dir := Queue_Per_Obj_Dir; end if; end Initialize; --------------------- -- Insert_No_Roots -- --------------------- function Insert_No_Roots (Source : Source_Info) return Boolean is begin pragma Assert (Source.Format = Format_Gnatmake or else Source.Id /= No_Source); -- Only insert in the Q if it is not already done, to avoid -- simultaneous compilations if -jnnn is used. if Was_Processed (Source) then return False; end if; -- For gprbuild, check if a source has already been inserted in the -- queue from the same project in a different project tree. if Source.Format = Format_Gprbuild then for J in 1 .. Q.Last loop if Source.Id.Path.Name = Q.Table (J).Info.Id.Path.Name and then Source.Id.Index = Q.Table (J).Info.Id.Index and then Ultimate_Extending_Project_Of (Source.Id.Project).Path.Name = Ultimate_Extending_Project_Of (Q.Table (J).Info.Id.Project). Path.Name then -- No need to insert this source in the queue, but still -- return True as we may need to insert its roots. return True; end if; end loop; end if; if Current_Verbosity = High then Write_Str ("Adding """); Debug_Display (Source); Write_Line (""" to the queue"); end if; Q.Append (New_Val => (Info => Source, Processed => False)); if Debug.Debug_Flag_Q then Write_Str (" Q := Q + [ "); Debug_Display (Source); Write_Str (" ] "); Write_Eol; Write_Str (" Q_First ="); Write_Int (Int (Q_First)); Write_Eol; Write_Str (" Q.Last ="); Write_Int (Int (Q.Last)); Write_Eol; end if; return True; end Insert_No_Roots; ------------ -- Insert -- ------------ function Insert (Source : Source_Info; With_Roots : Boolean := False) return Boolean is Root_Arr : Array_Element_Id; Roots : Variable_Value; List : String_List_Id; Elem : String_Element; Unit_Name : Name_Id; Pat_Root : Boolean; Root_Pattern : Regexp; Root_Found : Boolean; Roots_Found : Boolean; Root_Source : Prj.Source_Id; Iter : Source_Iterator; Dummy : Boolean; begin if not Insert_No_Roots (Source) then -- Was already in the queue return False; end if; if With_Roots and then Source.Format = Format_Gprbuild then Debug_Output ("looking for roots of", Name_Id (Source.Id.File)); Root_Arr := Prj.Util.Value_Of (Name => Name_Roots, In_Arrays => Source.Id.Project.Decl.Arrays, Shared => Source.Tree.Shared); Roots := Prj.Util.Value_Of (Index => Name_Id (Source.Id.File), Src_Index => 0, In_Array => Root_Arr, Shared => Source.Tree.Shared); -- If there is no roots for the specific main, try the language if Roots = Nil_Variable_Value then Roots := Prj.Util.Value_Of (Index => Source.Id.Language.Name, Src_Index => 0, In_Array => Root_Arr, Shared => Source.Tree.Shared, Force_Lower_Case_Index => True); end if; -- Then try "*" if Roots = Nil_Variable_Value then Name_Len := 1; Name_Buffer (1) := '*'; Roots := Prj.Util.Value_Of (Index => Name_Find, Src_Index => 0, In_Array => Root_Arr, Shared => Source.Tree.Shared, Force_Lower_Case_Index => True); end if; if Roots = Nil_Variable_Value then Debug_Output (" -> no roots declared"); else List := Roots.Values; Pattern_Loop : while List /= Nil_String loop Elem := Source.Tree.Shared.String_Elements.Table (List); Get_Name_String (Elem.Value); To_Lower (Name_Buffer (1 .. Name_Len)); Unit_Name := Name_Find; -- Check if it is a unit name or a pattern Pat_Root := False; for J in 1 .. Name_Len loop if Name_Buffer (J) not in 'a' .. 'z' and then Name_Buffer (J) not in '0' .. '9' and then Name_Buffer (J) /= '_' and then Name_Buffer (J) /= '.' then Pat_Root := True; exit; end if; end loop; if Pat_Root then begin Root_Pattern := Compile (Pattern => Name_Buffer (1 .. Name_Len), Glob => True); exception when Error_In_Regexp => Err_Vars.Error_Msg_Name_1 := Unit_Name; Errutil.Error_Msg ("invalid pattern %", Roots.Location); exit Pattern_Loop; end; end if; Roots_Found := False; Iter := For_Each_Source (Source.Tree); Source_Loop : loop Root_Source := Prj.Element (Iter); exit Source_Loop when Root_Source = No_Source; Root_Found := False; if Pat_Root then Root_Found := Root_Source.Unit /= No_Unit_Index and then Match (Get_Name_String (Root_Source.Unit.Name), Root_Pattern); else Root_Found := Root_Source.Unit /= No_Unit_Index and then Root_Source.Unit.Name = Unit_Name; end if; if Root_Found then case Root_Source.Kind is when Impl => null; when Spec => Root_Found := Other_Part (Root_Source) = No_Source; when Sep => Root_Found := False; end case; end if; if Root_Found then Roots_Found := True; Debug_Output (" -> ", Name_Id (Root_Source.Display_File)); Dummy := Queue.Insert_No_Roots (Source => (Format => Format_Gprbuild, Tree => Source.Tree, Id => Root_Source, Closure => False)); Initialize_Source_Record (Root_Source); if Other_Part (Root_Source) /= No_Source then Initialize_Source_Record (Other_Part (Root_Source)); end if; -- Save the root for the binder Source.Id.Roots := new Source_Roots' (Root => Root_Source, Next => Source.Id.Roots); exit Source_Loop when not Pat_Root; end if; Next (Iter); end loop Source_Loop; if not Roots_Found then if Pat_Root then if not Quiet_Output then Error_Msg_Name_1 := Unit_Name; Errutil.Error_Msg ("?no unit matches pattern %", Roots.Location); end if; else Errutil.Error_Msg ("Unit " & Get_Name_String (Unit_Name) & " does not exist", Roots.Location); end if; end if; List := Elem.Next; end loop Pattern_Loop; end if; end if; return True; end Insert; ------------ -- Insert -- ------------ procedure Insert (Source : Source_Info; With_Roots : Boolean := False) is Discard : Boolean; begin Discard := Insert (Source, With_Roots); end Insert; -------------- -- Is_Empty -- -------------- function Is_Empty return Boolean is begin return Q_Processed >= Q.Last; end Is_Empty; ------------------------ -- Is_Virtually_Empty -- ------------------------ function Is_Virtually_Empty return Boolean is begin if One_Queue_Per_Obj_Dir then for J in Q_First .. Q.Last loop if not Q.Table (J).Processed and then Available_Obj_Dir (Q.Table (J).Info) then return False; end if; end loop; return True; else return Is_Empty; end if; end Is_Virtually_Empty; ---------------------- -- Set_Obj_Dir_Busy -- ---------------------- procedure Set_Obj_Dir_Busy (Obj_Dir : Path_Name_Type) is begin if One_Queue_Per_Obj_Dir then Busy_Obj_Dirs.Set (Obj_Dir, True); end if; end Set_Obj_Dir_Busy; ---------------------- -- Set_Obj_Dir_Free -- ---------------------- procedure Set_Obj_Dir_Free (Obj_Dir : Path_Name_Type) is begin if One_Queue_Per_Obj_Dir then Busy_Obj_Dirs.Set (Obj_Dir, False); end if; end Set_Obj_Dir_Free; ---------- -- Size -- ---------- function Size return Natural is begin return Q.Last; end Size; ------------- -- Element -- ------------- function Element (Rank : Positive) return File_Name_Type is begin if Rank <= Q.Last then case Q.Table (Rank).Info.Format is when Format_Gprbuild => return Q.Table (Rank).Info.Id.File; when Format_Gnatmake => return Q.Table (Rank).Info.File; end case; else return No_File; end if; end Element; ------------------ -- Remove_Marks -- ------------------ procedure Remove_Marks is begin Marks.Reset; end Remove_Marks; ---------------------------- -- Insert_Project_Sources -- ---------------------------- procedure Insert_Project_Sources (Project : Project_Id; Project_Tree : Project_Tree_Ref; All_Projects : Boolean; Unique_Compile : Boolean) is procedure Do_Insert (Project : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context); -- Local procedures must be commented ??? --------------- -- Do_Insert -- --------------- procedure Do_Insert (Project : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context) is Unit_Based : constant Boolean := Unique_Compile or else not Builder_Data (Tree).Closure_Needed; -- When Unit_Based is True, we enqueue all compilable sources -- including the unit based (Ada) one. When Unit_Based is False, -- put the Ada sources only when they are in a library project. Iter : Source_Iterator; Source : Prj.Source_Id; OK : Boolean; Closure : Boolean; begin -- Nothing to do when "-u" was specified and some files were -- specified on the command line if Unique_Compile and then Mains.Number_Of_Mains (Tree) > 0 then return; end if; Iter := For_Each_Source (Tree); loop Source := Prj.Element (Iter); exit when Source = No_Source; if Is_Allowed_Language (Source.Language.Name) and then Is_Compilable (Source) and then (All_Projects or else Is_Extending (Project, Source.Project)) and then not Source.Locally_Removed and then Source.Replaced_By = No_Source and then (not Source.Project.Externally_Built or else (Is_Extending (Project, Source.Project) and then not Project.Externally_Built)) and then Source.Kind /= Sep and then Source.Path /= No_Path_Information then if Source.Kind = Impl or else (Source.Unit /= No_Unit_Index and then Source.Kind = Spec and then (Other_Part (Source) = No_Source or else Other_Part (Source).Locally_Removed)) then if (Unit_Based or else Source.Unit = No_Unit_Index or else Source.Project.Library or else Context.In_Aggregate_Lib or else Project.Qualifier = Aggregate_Library) and then not Is_Subunit (Source) then OK := True; Closure := False; if Source.Unit /= No_Unit_Index and then (Source.Project.Library or else Project.Qualifier = Aggregate_Library or else Context.In_Aggregate_Lib) and then Source.Project.Standalone_Library /= No then -- Check if the unit is in the interface OK := False; declare List : String_List_Id; Element : String_Element; begin List := Source.Project.Lib_Interface_ALIs; while List /= Nil_String loop Element := Project_Tree.Shared.String_Elements.Table (List); if Element.Value = Name_Id (Source.Dep_Name) then OK := True; Closure := True; exit; end if; List := Element.Next; end loop; end; end if; if OK then Queue.Insert (Source => (Format => Format_Gprbuild, Tree => Tree, Id => Source, Closure => Closure)); end if; end if; end if; end if; Next (Iter); end loop; end Do_Insert; procedure Insert_All is new For_Project_And_Aggregated_Context (Do_Insert); begin Insert_All (Project, Project_Tree); end Insert_Project_Sources; ------------------------------- -- Insert_Withed_Sources_For -- ------------------------------- procedure Insert_Withed_Sources_For (The_ALI : ALI.ALI_Id; Project_Tree : Project_Tree_Ref; Excluding_Shared_SALs : Boolean := False) is Sfile : File_Name_Type; Afile : File_Name_Type; Src_Id : Prj.Source_Id; begin -- Insert in the queue the unmarked source files (i.e. those which -- have never been inserted in the queue and hence never considered). for J in ALI.ALIs.Table (The_ALI).First_Unit .. ALI.ALIs.Table (The_ALI).Last_Unit loop for K in ALI.Units.Table (J).First_With .. ALI.Units.Table (J).Last_With loop Sfile := ALI.Withs.Table (K).Sfile; -- Skip generics if Sfile /= No_File then Afile := ALI.Withs.Table (K).Afile; Src_Id := Source_Files_Htable.Get (Project_Tree.Source_Files_HT, Sfile); while Src_Id /= No_Source loop Initialize_Source_Record (Src_Id); if Is_Compilable (Src_Id) and then Src_Id.Dep_Name = Afile then case Src_Id.Kind is when Spec => declare Bdy : constant Prj.Source_Id := Other_Part (Src_Id); begin if Bdy /= No_Source and then not Bdy.Locally_Removed then Src_Id := Other_Part (Src_Id); end if; end; when Impl => if Is_Subunit (Src_Id) then Src_Id := No_Source; end if; when Sep => Src_Id := No_Source; end case; exit; end if; Src_Id := Src_Id.Next_With_File_Name; end loop; -- If Excluding_Shared_SALs is True, do not insert in the -- queue the sources of a shared Stand-Alone Library. if Src_Id /= No_Source and then (not Excluding_Shared_SALs or else Src_Id.Project.Standalone_Library = No or else Src_Id.Project.Library_Kind = Static) then Queue.Insert (Source => (Format => Format_Gprbuild, Tree => Project_Tree, Id => Src_Id, Closure => True)); end if; end if; end loop; end loop; end Insert_Withed_Sources_For; end Queue; ---------- -- Free -- ---------- procedure Free (Data : in out Builder_Project_Tree_Data) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Binding_Data_Record, Binding_Data); TmpB, Binding : Binding_Data := Data.Binding; begin while Binding /= null loop TmpB := Binding.Next; Unchecked_Free (Binding); Binding := TmpB; end loop; end Free; ------------------ -- Builder_Data -- ------------------ function Builder_Data (Tree : Project_Tree_Ref) return Builder_Data_Access is begin if Tree.Appdata = null then Tree.Appdata := new Builder_Project_Tree_Data; end if; return Builder_Data_Access (Tree.Appdata); end Builder_Data; -------------------------------- -- Compute_Compilation_Phases -- -------------------------------- procedure Compute_Compilation_Phases (Tree : Project_Tree_Ref; Root_Project : Project_Id; Option_Unique_Compile : Boolean := False; -- Was "-u" specified ? Option_Compile_Only : Boolean := False; -- Was "-c" specified ? Option_Bind_Only : Boolean := False; Option_Link_Only : Boolean := False) is procedure Do_Compute (Project : Project_Id; Tree : Project_Tree_Ref); ---------------- -- Do_Compute -- ---------------- procedure Do_Compute (Project : Project_Id; Tree : Project_Tree_Ref) is Data : constant Builder_Data_Access := Builder_Data (Tree); All_Phases : constant Boolean := not Option_Compile_Only and then not Option_Bind_Only and then not Option_Link_Only; -- Whether the command line asked for all three phases. Depending on -- the project settings, we might still disable some of the phases. Has_Mains : constant Boolean := Data.Number_Of_Mains > 0; -- Whether there are some main units defined for this project tree -- (either from one of the projects, or from the command line) begin if Option_Unique_Compile then -- If -u or -U is specified on the command line, disregard any -c, -- -b or -l switch: only perform compilation. Data.Closure_Needed := False; Data.Need_Compilation := True; Data.Need_Binding := False; Data.Need_Linking := False; else Data.Closure_Needed := Has_Mains or else (Root_Project.Library and then Root_Project.Standalone_Library /= No); Data.Need_Compilation := All_Phases or Option_Compile_Only; Data.Need_Binding := All_Phases or Option_Bind_Only; Data.Need_Linking := (All_Phases or Option_Link_Only) and Has_Mains; end if; if Current_Verbosity = High then Debug_Output ("compilation phases: " & " compile=" & Data.Need_Compilation'Img & " bind=" & Data.Need_Binding'Img & " link=" & Data.Need_Linking'Img & " closure=" & Data.Closure_Needed'Img & " mains=" & Data.Number_Of_Mains'Img, Project.Name); end if; end Do_Compute; procedure Compute_All is new For_Project_And_Aggregated (Do_Compute); begin Compute_All (Root_Project, Tree); end Compute_Compilation_Phases; ------------------------------ -- Compute_Builder_Switches -- ------------------------------ procedure Compute_Builder_Switches (Project_Tree : Project_Tree_Ref; Env : in out Prj.Tree.Environment; Main_Project : Project_Id; Only_For_Lang : Name_Id := No_Name) is Builder_Package : constant Package_Id := Value_Of (Name_Builder, Main_Project.Decl.Packages, Project_Tree.Shared); Global_Compilation_Array : Array_Element_Id; Global_Compilation_Elem : Array_Element; Global_Compilation_Switches : Variable_Value; Default_Switches_Array : Array_Id; Builder_Switches_Lang : Name_Id := No_Name; List : String_List_Id; Element : String_Element; Index : Name_Id; Source : Prj.Source_Id; Lang : Name_Id := No_Name; -- language index for Switches Switches_For_Lang : Variable_Value := Nil_Variable_Value; -- Value of Builder'Default_Switches(lang) Name : Name_Id := No_Name; -- main file index for Switches Switches_For_Main : Variable_Value := Nil_Variable_Value; -- Switches for a specific main. When there are several mains, Name is -- set to No_Name, and Switches_For_Main might be left with an actual -- value (so that we can display a warning that it was ignored). Other_Switches : Variable_Value := Nil_Variable_Value; -- Value of Builder'Switches(others) Defaults : Variable_Value := Nil_Variable_Value; Switches : Variable_Value := Nil_Variable_Value; -- The computed builder switches Success : Boolean := False; begin if Builder_Package /= No_Package then Mains.Reset; -- If there is no main, and there is only one compilable language, -- use this language as the switches index. if Mains.Number_Of_Mains (Project_Tree) = 0 then if Only_For_Lang = No_Name then declare Language : Language_Ptr := Main_Project.Languages; begin while Language /= No_Language_Index loop if Language.Config.Compiler_Driver /= No_File and then Language.Config.Compiler_Driver /= Empty_File then if Lang /= No_Name then Lang := No_Name; exit; else Lang := Language.Name; end if; end if; Language := Language.Next; end loop; end; else Lang := Only_For_Lang; end if; else for Index in 1 .. Mains.Number_Of_Mains (Project_Tree) loop Source := Mains.Next_Main.Source; if Source /= No_Source then if Switches_For_Main = Nil_Variable_Value then Switches_For_Main := Value_Of (Name => Name_Id (Source.File), Attribute_Or_Array_Name => Name_Switches, In_Package => Builder_Package, Shared => Project_Tree.Shared, Force_Lower_Case_Index => False, Allow_Wildcards => True); -- If not found, try without extension. -- That's because gnatmake accepts truncated file names -- in Builder'Switches if Switches_For_Main = Nil_Variable_Value and then Source.Unit /= null then Switches_For_Main := Value_Of (Name => Source.Unit.Name, Attribute_Or_Array_Name => Name_Switches, In_Package => Builder_Package, Shared => Project_Tree.Shared, Force_Lower_Case_Index => False, Allow_Wildcards => True); end if; end if; if Index = 1 then Lang := Source.Language.Name; Name := Name_Id (Source.File); else Name := No_Name; -- Can't use main specific switches if Lang /= Source.Language.Name then Lang := No_Name; end if; end if; end if; end loop; end if; Global_Compilation_Array := Value_Of (Name => Name_Global_Compilation_Switches, In_Arrays => Project_Tree.Shared.Packages.Table (Builder_Package).Decl.Arrays, Shared => Project_Tree.Shared); Default_Switches_Array := Project_Tree.Shared.Packages.Table (Builder_Package).Decl.Arrays; while Default_Switches_Array /= No_Array and then Project_Tree.Shared.Arrays.Table (Default_Switches_Array).Name /= Name_Default_Switches loop Default_Switches_Array := Project_Tree.Shared.Arrays.Table (Default_Switches_Array).Next; end loop; if Global_Compilation_Array /= No_Array_Element and then Default_Switches_Array /= No_Array then Prj.Err.Error_Msg (Env.Flags, "Default_Switches forbidden in presence of " & "Global_Compilation_Switches. Use Switches instead.", Project_Tree.Shared.Arrays.Table (Default_Switches_Array).Location); Fail_Program (Project_Tree, "*** illegal combination of Builder attributes"); end if; if Lang /= No_Name then Switches_For_Lang := Prj.Util.Value_Of (Name => Lang, Index => 0, Attribute_Or_Array_Name => Name_Switches, In_Package => Builder_Package, Shared => Project_Tree.Shared, Force_Lower_Case_Index => True); Defaults := Prj.Util.Value_Of (Name => Lang, Index => 0, Attribute_Or_Array_Name => Name_Default_Switches, In_Package => Builder_Package, Shared => Project_Tree.Shared, Force_Lower_Case_Index => True); end if; Other_Switches := Prj.Util.Value_Of (Name => All_Other_Names, Index => 0, Attribute_Or_Array_Name => Name_Switches, In_Package => Builder_Package, Shared => Project_Tree.Shared); if not Quiet_Output and then Mains.Number_Of_Mains (Project_Tree) > 1 and then Switches_For_Main /= Nil_Variable_Value then -- More than one main, but we had main-specific switches that -- are ignored. if Switches_For_Lang /= Nil_Variable_Value then Write_Line ("Warning: using Builder'Switches(""" & Get_Name_String (Lang) & """), as there are several mains"); elsif Other_Switches /= Nil_Variable_Value then Write_Line ("Warning: using Builder'Switches(others), " & "as there are several mains"); elsif Defaults /= Nil_Variable_Value then Write_Line ("Warning: using Builder'Default_Switches(""" & Get_Name_String (Lang) & """), as there are several mains"); else Write_Line ("Warning: using no switches from package " & "Builder, as there are several mains"); end if; end if; Builder_Switches_Lang := Lang; if Name /= No_Name then -- Get the switches for the single main Switches := Switches_For_Main; end if; if Switches = Nil_Variable_Value or else Switches.Default then -- Get the switches for the common language of the mains Switches := Switches_For_Lang; end if; if Switches = Nil_Variable_Value or else Switches.Default then Switches := Other_Switches; end if; -- For backward compatibility with gnatmake, if no Switches -- are declared, check for Default_Switches (<language>). if Switches = Nil_Variable_Value or else Switches.Default then Switches := Defaults; end if; -- If switches have been found, scan them if Switches /= Nil_Variable_Value and then not Switches.Default then List := Switches.Values; while List /= Nil_String loop Element := Project_Tree.Shared.String_Elements.Table (List); Get_Name_String (Element.Value); if Name_Len /= 0 then declare -- Add_Switch might itself be using the name_buffer, so -- we make a temporary here. Switch : constant String := Name_Buffer (1 .. Name_Len); begin Success := Add_Switch (Switch => Switch, For_Lang => Builder_Switches_Lang, For_Builder => True, Has_Global_Compilation_Switches => Global_Compilation_Array /= No_Array_Element); end; if not Success then for J in reverse 1 .. Name_Len loop Name_Buffer (J + J) := Name_Buffer (J); Name_Buffer (J + J - 1) := '''; end loop; Name_Len := Name_Len + Name_Len; Prj.Err.Error_Msg (Env.Flags, '"' & Name_Buffer (1 .. Name_Len) & """ is not a builder switch. Consider moving " & "it to Global_Compilation_Switches.", Element.Location); Fail_Program (Project_Tree, "*** illegal switch """ & Get_Name_String (Element.Value) & '"'); end if; end if; List := Element.Next; end loop; end if; -- Reset the Builder Switches language Builder_Switches_Lang := No_Name; -- Take into account attributes Global_Compilation_Switches while Global_Compilation_Array /= No_Array_Element loop Global_Compilation_Elem := Project_Tree.Shared.Array_Elements.Table (Global_Compilation_Array); Get_Name_String (Global_Compilation_Elem.Index); To_Lower (Name_Buffer (1 .. Name_Len)); Index := Name_Find; if Only_For_Lang = No_Name or else Index = Only_For_Lang then Global_Compilation_Switches := Global_Compilation_Elem.Value; if Global_Compilation_Switches /= Nil_Variable_Value and then not Global_Compilation_Switches.Default then -- We have found an attribute -- Global_Compilation_Switches for a language: put the -- switches in the appropriate table. List := Global_Compilation_Switches.Values; while List /= Nil_String loop Element := Project_Tree.Shared.String_Elements.Table (List); if Element.Value /= No_Name then Success := Add_Switch (Switch => Get_Name_String (Element.Value), For_Lang => Index, For_Builder => False, Has_Global_Compilation_Switches => Global_Compilation_Array /= No_Array_Element); end if; List := Element.Next; end loop; end if; end if; Global_Compilation_Array := Global_Compilation_Elem.Next; end loop; end if; end Compute_Builder_Switches; --------------------- -- Write_Path_File -- --------------------- procedure Write_Path_File (FD : File_Descriptor) is Last : Natural; Status : Boolean; begin Name_Len := 0; for Index in Directories.First .. Directories.Last loop Add_Str_To_Name_Buffer (Get_Name_String (Directories.Table (Index))); Add_Char_To_Name_Buffer (ASCII.LF); end loop; Last := Write (FD, Name_Buffer (1)'Address, Name_Len); if Last = Name_Len then Close (FD, Status); else Status := False; end if; if not Status then Prj.Com.Fail ("could not write temporary file"); end if; end Write_Path_File; end Makeutl;
with System; with TLSF.Config; use TLSF.Config; with TLSF.Block.Types; use TLSF.Block.Types; with TLSF.Block.Proof; package TLSF.Block.Operations_Old with SPARK_Mode is package Proof renames TLSF.Block.Proof; function Get_Block_At_Address(Base : System.Address; Addr : Aligned_Address) return Block_Header with Pre => (Addr /= Address_Null and then Proof.Block_Present_At_Address(Addr)), Post => Get_Block_At_Address'Result = Proof.Block_At_Address(Addr); procedure Set_Block_At_Address(Base : System.Address; Addr : Aligned_Address; Header : Block_Header) with Pre => (Addr /= Address_Null and then not Proof.Block_Present_At_Address(Addr)), Post => (Proof.Block_Present_At_Address(Addr) and then Proof.Block_At_Address(Addr) = Header); procedure Remove_Block_At_Address(Base : System.Address; Addr : Aligned_Address) with Pre => (Addr /= Address_Null and then Proof.Block_Present_At_Address(Addr)), Post => not Proof.Block_Present_At_Address(Addr); -- Work with free lists function Check_Blocks_Linked_Correctly (Block_Left, Block_Right : Block_Header; Block_Left_Address, Block_Right_Address : Aligned_Address) return Boolean is (Is_Block_Free(Block_Left) and then Is_Block_Free(Block_Right) and then Block_Left.Free_List.Next_Address = Block_Right_Address and then Block_Right.Free_List.Prev_Address = Block_Left_Address); function Check_Free_List_Correctness_After_Unlinking (Base : System.Address; Block : Block_Header) return Boolean is -- properly linked in free list block cannot have zero links -- because free list is circular double linked list (Check_Blocks_Linked_Correctly (Block_Left => Get_Block_At_Address(Base, Block.Free_List.Prev_Address), Block_Right => Get_Block_At_Address(Base, Block.Free_List.Next_Address), Block_Left_Address => Block.Free_List.Prev_Address, Block_Right_Address => Block.Free_List.Next_Address)) with Pre => Is_Block_Free(Block) and then Proof.Block_Present_At_Address(Block.Free_List.Prev_Address) and then Proof.Block_Present_At_Address(Block.Free_List.Next_Address); function Is_Block_Physically_Present_At_Address_And_In_Free_List_For_Specific_Size (Base : System.Address; Address : Aligned_Address; Size : Aligned_Size; Block : Block_Header) return Boolean is (Is_Block_Free(Block) and then Proof.Specific_Block_Present_At_Address(Address, Block) and then Is_Block_Linked_To_Free_List(Block) and then Proof.Is_Block_In_Free_List_For_Size (Size, Address)) with Ghost; procedure Unlink_From_Free_List (Base : System.Address; Address : Aligned_Address; Block : in out Block_Header; Free_List : in out Free_Blocks_List) with Pre => -- TODO: think about storing meta info about Free_Lists, -- ie add extra structure for Free_Blocks_List for size Is_Block_Free(Block) and then -- Free List is not empty not Is_Free_List_Empty(Free_List) and then -- presence in free lists Is_Block_Physically_Present_At_Address_And_In_Free_List_For_Specific_Size (Base => Base, Address => Address, Size => Block.Size, Block => Block) and then -- is neighbors from free list are free blocks to (like inductive case) -- left heighbor Proof.Block_Present_At_Address(Block.Free_List.Prev_Address) and then Is_Block_Physically_Present_At_Address_And_In_Free_List_For_Specific_Size (Base => Base, Address => Block.Free_List.Prev_Address, Size => Block.Size, Block => Get_Block_At_Address(Base, Block.Free_List.Prev_Address)) and then -- right heighbor Proof.Block_Present_At_Address(Block.Free_List.Next_Address) and then Is_Block_Physically_Present_At_Address_And_In_Free_List_For_Specific_Size (Base => Base, Address => Block.Free_List.Next_Address, Size => Block.Size, Block => Get_Block_At_Address(Base, Block.Free_List.Next_Address)) and then -- Last block is in correct state regarding linking (if Is_Block_Last_In_Free_List(Block) then (Block.Free_List = Free_List and then Block.Free_List.Prev_Address = Block.Free_List.Next_Address and then Block.Free_List.Prev_Address = Address)), Post => -- physycal presence same block (modulo free list links) at same address Proof.Specific_Block_Present_At_Address(Address, Block) and then -- removed from free lists (to do may be : for all free_lists: ... ?) not Proof.Is_Block_In_Free_List_For_Size (Block.Size, Address) and then not Is_Block_Linked_To_Free_List(Block) and then -- everything the same, except free list links Changed_Only_Links_For_Free_List(Block, Block'Old) and then -- check that list in correct state ; Check_Free_List_Correctness_After_Unlinking (Base => Base, Block => Block'Old) and then -- Check correst update of Free_List if it is was last block in it (if Block'Old.Free_List = Free_List'Old then Is_Free_List_Empty(Free_List)); -- function Is_Free_Block_Splitable(Block : Block_Header) -- return Boolean -- with -- Pre => -- Is_Block_Free(Block) and then -- Block.Size >= Small_Block_Size * 2, -- -- Contract_Cases => -- ( Block.Size >= 2*Small_Block_Size -- => Is_Free_Block_Splitable'Result = True, -- others -- => Is_Free_Block_Splitable'Result = False); -- -- -- NB: we can split only unlinked block -- -- this approach will be helpful for multithread version, -- -- because we can unlink fast, using fast lock or even move to lockless -- -- double-linked-lists -- procedure Split_Free_Block (Base : System.Address; -- Addr : Aligned_Address; -- Block : Block_Header; -- Left_Size, Right_Size : Aligned_Size; -- Block_Left, Block_Right : out Block_Header) -- with -- Pre => -- -- -- physical presence -- Proof.Specific_Block_Present_At_Address(Addr, Block) and then -- -- -- Block already should be unlinked from free lists (TODO: all lists?) -- not Is_Block_Linked_To_Free_List(Block) and then -- not Proof.Is_Block_In_Free_List_For_Size(Block.Size, Addr) and then -- -- -- splittable -- Is_Free_Block_Splitable(Block) and then -- -- -- Sizes preservation -- Block.Size = Left_Size + Right_Size, -- -- Post => -- -- -- physical presence : original block is nowhere -- not Proof.Specific_Block_Present_At_Address(Addr, Block) and then -- -- -- check once again that it is not included into any free lists -- not Is_Block_Linked_To_Free_List(Block) and then -- -- TODO: no free list contains blocks, ie we removed it from everywhere -- not Proof.Is_Block_In_Free_List_For_Size(Block.Size, Addr) and then -- -- -- Correctnes of sizes -- Block_Left.Size = Left_Size and then -- Block_Right.Size = Right_Size and then -- -- -- Check properties of the Left block: -- -- -- check if type is correct -- Is_Block_Free(Block_Left) and then -- -- -- physical presense -- Proof.Specific_Block_Present_At_Address(Addr, Block_Left) and then -- -- -- not yet linked into free lists -- not Is_Block_Linked_To_Free_List(Block_Left) and then -- not Proof.Is_Block_In_Free_List_For_Size(Block_Left.Size, Addr) and then -- -- -- TODO: add neighbors check -- -- -- The same for the right block -- Is_Block_Free(Block_Right) and then -- -- Proof.Specific_Block_Present_At_Address(Addr + Left_Size, Block_Right) and then -- -- not Is_Block_Linked_To_Free_List(Block_Right) and then -- not Proof.Is_Block_In_Free_List_For_Size(Block_Right.Size, Addr); -- -- -- procedure Link_To_Free_List_For_Size(Base : System.Address; -- Addr : Aligned_Address; -- Block : in out Block_Header; -- Free_List : in out Free_Blocks_List) -- with -- Pre => -- -- type check -- Is_Block_Free(Block) and then -- -- -- physical presense -- Proof.Specific_Block_Present_At_Address(Addr, Block) and then -- -- -- not linked to free lists yet (TODO: all free lists?) -- not Proof.Is_Block_In_Free_List_For_Size(Block.Size, Addr) and then -- not Is_Block_Linked_To_Free_List(Block), -- -- Post => -- -- type check -- Is_Block_Free(Block) and then -- -- -- physical presense -- Proof.Specific_Block_Present_At_Address(Addr, Block) and then -- -- -- linked to specific free list -- Is_Block_Linked_To_Free_List(Block) and then -- Proof.Is_Block_Present_In_Exactly_One_Free_List_For_Size(Block.Size, Addr) and then -- -- -- everything the same, except free list links -- Changed_Only_Links_For_Free_List(Block, Block'Old); end TLSF.Block.Operations_Old;
------------------------------------------------------------------------------- -- package Disorderly.Basic_Rand.Deviates, Floating point random deviates. -- Copyright (C) 1995-2018 Jonathan S. Parker -- -- 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. ------------------------------------------------------------------------------- -- PACKAGE Disorderly.Basic_Rand.Deviates -- -- Generates floating point streams of Random deviates (variates) from -- the following distributions: -- -- Uniform, Normal (Gaussian), Exponential, Lorentzian (Cauchy), -- Poissonian, Binomial, Negative Binomial, Weibull, Rayleigh, -- Student_t, Beta, Gamma, Chi_Squared, Log_Normal, Multivariate_Normal -- -- The more complicated deviates are accompanied by routines that -- calculate their respective probability densities. The test routine, -- (basic_deviates_demo_1), verifies that the random variables are -- drawn from these probability distributions, as advertized. -- -- So basic_deviates_demo_1.adb is a useful demonstration of the -- random variable generators in this package, as well as the exact -- distributions they are drawn from. -- -- The package is pure. -- -- Most routines would grind to a halt if they had to recalculate -- certain quantities each call. So these quantities are calculated -- on the first call, and then placed into a record that's passed -- as in/out parameter to keep the package pure. -- -- Uses 53 bits of the 61-bit generator Disorderly.Basic_Rand. -- -- For most of the routines, the time_per_call is not constant. Most -- routines call the random number generator an unpredictable number -- of times each time the routine is called. -- -- Wikipedia gives extended descriptions of each distribution. The -- probability density functions generated by the functions declared -- below are taken directly from the Wikipedia articles on the same, -- to ensure that the Wikipedia discussions are exactly relevant. -- -- Uses the integer valued Disorderly.Basic_Rand in the parent package to -- create a floating point generator (Uniform). -- Is generic in the floating point type (as long as its 15 digits!). -- -- Like the other routines in this collection, Deviates is designed -- to exploit the newer 64-bit CPU's. All of the routines use -- 15 digit floats, which means 53 bit mantissas in practice. -- Poisson should be thought of as single precision though. -- -- References: -- -- Chandrasekaran and Sheppard, -- Journal of Pascal, Ada, and Modula2, Vol 5, Num 4, (1986). -- -- Kemp, C.D. (1986). 'A modal method for generating binomial -- variables', Commun. Statist. - Theor. Meth. 15(3), 805-813. -- -- see also Fortran 77 code from the book: -- Dagpunar, J. 'Principles of random variate generation' -- Clarendon Press, Oxford, 1988. ISBN 0-19-852202-9 -- -- Many thanks are due to Allan Miller - most routines are based on -- his Fortran 90 versions of the Dagpunar code. -- -- Notes on the Distributions: -- -- The functions approximate in a statistical manner certain continuous -- probability distributions or densities (except Poisson and the Binomials, -- which are integer valued here, not continuous). More precisely, if -- you ran the program a long time, added up the number of points output -- in each interval (X,X+dX), and plotted the resulting histogram, -- you would get a function f(X), where f(X) is given as follows. -- The functions are given in Normalized form. -- -- The easy ones: -- -- Random_Real (X, State_Val) samples from a uniform distribution: -- = 1 for 0.0 <= X < 1.0 -- = 0 otherwise. -- -- Exponential (Mean) = Exp (-X / Mean) / Mean for X > 0; 0 otherwise. -- -- Normal (Mean, Sigma) = -- = Exp (-(X - Mean)**2 / (2*Sigma**2)) / (Sigma*Sqrt(2*Pi)) -- -- Sometimes Normal is called Gaussian if Mean /=0 and Std Dev /= 1. -- Sometimes Normal is called Std Normal if Mean =0 and Std Dev = 1. -- -- Poisson (Mean) = Mean**k * Exp (-Mean) / k! -- -- Output of Poisson is integer valued; Output includes 0. -- -- The Cauchy probability density has a Lorentzian shape: (a/pi) / (a^2 + X^2). -- -- The more complicated distribution are described well in their -- respective Wikipedia articles. generic type Real is digits <>; -- 15 digits required. This is checked. package Disorderly.Basic_Rand.Deviates is pragma Pure (Deviates); procedure Get_Random_Real (Random_Real : out Real; Stream : in out State); -- -- Uniform on [0.0, 1.0). -- (X starts out on 0..2**53-1; then squeezed onto [0,1) by -- multiplying X by 2.0**(-53).) type Normal_Initializer is private; procedure Get_Normal (Mean : in Real; Sigma : in Real; N_Init : in out Normal_Initializer; Stream : in out State; Result : out Real); -- -- 1. Must declare variable of type Normal_Initializer and pass it in. -- The procedure Get_Normal does everything else for you. -- -- The Gaussian distribution probability density: -- -- f(X) = A * Exp (-(X-Mean)**2 / (2*Sigma**2)) -- -- Sigma = Standard_Deviation -- A = 1.0 / (Sigma*Sqrt(2*Pi)) (normalization constant) -- -- If Sigma=1, and Mean=0 then its usually called the -- Standard Normal distribution. function Normal_Probability (Mean : in Real; -- Mean of random variable X Sigma : in Real; -- Std Dev of random variable X X : in Real) return Real; subtype Log_Normal_Initializer is Normal_Initializer; procedure Get_Log_Normal -- outputs random variable X (Mean_Z : in Real; -- Mean of random variable Z = Log (X) Sigma_Z : in Real; -- Std Dev of random variable Z = Log (X) LN_Init : in out Log_Normal_Initializer; Stream : in out State; Result : out Real); -- X -- -- 1. Must declare variable of type Log_Normal_Initializer and pass it in. -- The procedure Get_Log_Normal does everything else for you. -- -- The Log_Normal distribution probability density for X: -- -- f(X) = A * Exp (-(Log(X) - Mean_Z)**2 / (2*Sigma_Z**2)) / X -- -- f(X) = 0 (for X <= 0) -- -- Sigma_Z = Standard_Deviation of Z = Log (X) -- A = 1.0 / (Sigma_Z * Sqrt (2*Pi)) -- -- If Z is a normally distributed Random Variable with (Mean_Z, Sigma_Z) -- then X = Exp (Z) is Log_Normal distributed with the distribution given -- above. In terms of Z's Average and Std Deviation, (Mean_Z, Sigma_Z): -- Mean_X = Exp (Mean_Z + Sigma_Z**2 / 2) -- Sigma_X**2 = Mean_X**2 * (Exp (Sigma_Z**2) - 1)) -- -- Suppose you have (Mean_X, Sigma_X) and you want (Mean_Z, Sigma_Z) of -- Z = Log(X), (the latter is the pair you plug into Get_Log_Normal above). -- The formula is -- Sigma_Z**2 = Log (1 + Sigma_X**2 / Mean_X**2)) -- Mean_Z = Log (Mean_X) - 0.5 * Sigma_Z**2 -- function Log_Normal_Probability (Mean_Z : in Real; -- Mean of random variable Z = Log (X) Sigma_Z : in Real; -- Std Dev of random variable Z = Log (X) X : in Real) return Real; -- -- NOT a random deviate. (Used for testing mostly.) -- -- The Log_Normal probability density: -- -- f(X) = A * Exp (-(Log(X) - Mean_Z)**2 / (2*Sigma_Z**2)) / X -- -- f(X) = 0 (for X <= 0) -- -- Sigma_Z = Standard_Deviation of Z, (where Z = Log (X)). -- A = 1.0 / (Sigma_Z * Sqrt (2*Pi)) procedure Get_Cauchy (A : in Real; Stream : in out State; Result : out Real); -- -- The Cauchy (Lorentzian) distribution probability density: -- -- f(X) = A / [(A*A + X*X) * Pi] -- normalized and scaled -- -- Generates random deviates X in range (-inf, inf). procedure Get_Exponential (Mean : in Real; Stream : in out State; Result : out Real); -- -- 1. Must have Mean > 0.0. -- Raises contraint_Error if Mean is <= 0.0. -- -- The Exponential distribution probability density: -- -- f(X) = Exp (-X / Mean) / Mean for X > 0; 0 otherwise. -- -- Generates a random deviate X in [0,inf). procedure Get_Weibull (a : in Real; Stream : in out State; Result : out Real); -- -- The Weibull distribution probability density function: -- -- f(X) = a * X**(a-1) * Exp (-X**a) if X > 0; f(X) = 0 otherwise. -- -- If a=1 its Get_Exponential with Mean=1. Use Get_Exponential; much faster. -- If a=2 its Rayleigh distribution. Use Get_Rayleigh; its faster. -- If a=0, raises contraint_Error. -- If a is too near 0, (or far from 1 in general) get Nan's or nonsense. procedure Get_Rayleigh (Stream : in out State; Result : out Real); -- -- The Rayleigh distribution probability density: -- -- f(X) = 2 * X * Exp (-X**2) if X > 0; f(X) = 0 otherwise. -- type Binomial_Initializer is private; procedure Get_Binomial (n : in Positive; p : in Real; B_Init : in out Binomial_Initializer; Stream : in out State; Result : out Real); -- -- 1. Must declare variable of type Binomial_Initializer and pass it in. -- The procedure Get_Binomial does everything else for you. -- -- 2. Must have: 0 < p < 1. (p = Bernoulli success probability.) -- -- The Binomial distribution probability density: -- -- f(X) = (n!/([X]!(n-[X])!)) * p^[X] * (1-p)^(n-[X]) -- if 0 <= X <= n; f(X) = 0 otherwise. -- -- Result is output as a float, but is always Integer valued. function Binomial_Probability (n : in Positive; k : in Integer; p : in Real) return Real; -- -- NOT a random deviate. (Used for testing mostly.) -- -- Uses Log_Gamma to get: -- -- [n!/(k!(n-k)!)] * p^k * (1-p)^(n-k) -- if 0 <= k <= n; -- returns 0 otherwise. -- -- k < 0 returns 0 -- k > n returns 0 -- -- p <= 0.0 raises Constraint_Error -- p >= 1.0 raises Constraint_Error type Neg_Binomial_Initializer is private; procedure Get_Neg_Binomial (r : in Real; p : in Real; NB_Init : in out Neg_Binomial_Initializer; Stream : in out State; Result : out Real); -- -- Result is a random deviate from distribution f_r(k) where f_r(k) is -- the probability of r successes and k failures in n = k+r Bernoulli trials. -- Assumes that the final trial is a success, and p = success probability. -- (r is not retricted to integer values; output Result is. Result is k-like.) -- -- Slow for large r, (r >> 10). -- Slow for small p, (p < 0.1). -- -- Must have: r > 0.0 -- r = the number of successes when r integer. -- The random deviate output (Result) is sampled -- from a distribution f_r(k) where f_r(k) is the -- probability that k failures and r successes -- are observed in a series of uncorrelated Bernoulli trials -- (with the final trial being a success). -- Must have: 0 < p < 1 -- p = Bernoulli success probability -- -- Result is output as a float, but is always Integer valued. function Neg_Binomial_Probability (r : in Real; k : in Integer; p : in Real) return Real; -- -- NOT a random deviate. (Used for testing mostly.) -- -- Uses Log_Gamma to get: -- -- [Gamma(r + k)/[(Gamma(r)*k!] * p^r * (1-p)^k -- -- Must have: r > 0.0 -- Must have: 0 < p < 1 -- p = Bernoulli success probability -- -- Probability of r successes and k failures in n = k+r Bernoulli trials. -- Assumes that the final trial is a success, and p = success probability. -- -- If r = 1, the distribution is the probability of success on the (k+1)th -- trial with k previous failures: geometric distribution, p*(1-p)^k. -- As r -> inf, keeping the Mean = r*(1-p)/p constant, you get the -- Poissonian distribution. So its a large p limit, opposite of Binomial. subtype Poisson_Initializer is Binomial_Initializer; p_Shift : constant := -20; -- binomial is used to get Poisson, by setting p~2**(-20) and p*Mean = n. -- p is the binomial (Bernoulli) success probability: p = 2.0**p_Shift. -- p = -20 is stnd. If p=-20, then Max allowed Mean is < 2048, and you can -- sample for 2 days at least without detecting difference between Poisson -- and binomial. If you set p=-23, then you can sample for 2 wks without -- problem, but then the maximum allowed Mean is < 256. procedure Get_Poisson (Mean : in Real; P_Init : in out Poisson_Initializer; Stream : in out State; Result : out Real); -- -- The Poisson distribution probability mass function: -- -- f(k) = Mean^k * Exp (-Mean) / k! -- -- Output of Poisson is integer valued, but floating point type. -- Output includes 0. -- -- Must have Mean > 0 -- Must have Mean < 2047.0 (if p_Shift = -20; ie p = 2**(-20)) -- Must have Mean < 256.0 (if p_Shift = -23; ie p = 2**(-23)) -- -- If mean > 8 then routine uses Binomial with p = 2**(-20) (with large -- n so that Mean=n*p). The binomial distribution agrees with Poisson -- with err ~ 5.0e-7 here. This discrepency is hard to -- measure, but the routine should be thought of as single-precision. -- This discrepency can be reduced by a factor of 8 by reducing p -- by a factor of 8, (but max allowed Mean falls by a factor of 8). function Poisson_Probability (Mean : in Real; k : in Integer) return Real; -- -- NOT a random deviate. (Used for testing mostly.) -- -- The Poisson distribution (probability mass function): -- -- f(k) = Mean^k * Exp (-Mean) / k! -- -- Negative k input is allowed (for convenience). -- Output is 0 for k < 0. type Student_t_Initializer is private; procedure Get_Student_t (m : in Positive; Student_t_Init : in out Student_t_Initializer; Stream : in out State; Result : out Real); -- -- 1. Must declare variable of type Student_t_Initializer and pass it in. -- The procedure Get_Student_t does everything else for you. -- -- 2. Must have m >= 1. (m = degrees of freedom of distribution.) -- -- The Student_t distribution probability density: -- -- f(X) = (1 + X*X/m)^(-(m+1)/2) * -- Gamma((m+1)/2) / [Sqrt (m*Pi) * Gamma(m/2)] -- -- generates a random deviate from a t distribution -- using Kinderman and Monahan's ratio method. function Student_t_Probability (m : in Positive; x : in Real) return Real; -- -- A Probability density function. -- -- NOT a random deviate. (Used for testing mostly.) -- -- Uses Log_Gamma to get: -- -- f(X) = Gamma((m+1)/2) * (1 + X*X/m)^(-(m+1)/2) / [Sqrt (m*Pi) * Gamma(m/2)] type Beta_Initializer is private; procedure Get_Beta (aa : in Real; bb : in Real; Beta_Init : in out Beta_Initializer; Stream : in out State; Result : out Real); -- -- 1. Must declare variable of type Beta_Initializer and pass it in. -- The procedure Get_Beta does everything else for you. -- -- 2. Must have aa > 0, bb > 0. -- -- Get_Beta generates a random deviate in [0,1] from a beta distribution. -- Uses Cheng's log logistic method. -- -- The Beta distribution probability density: -- -- f(X) = X**(aa-1) * (1-X)**(bb-1) * -- Gamma (aa + bb) / (Gamma (bb)*Gamma (aa)) -- function Beta_Probability (aa, bb : in Real; x : in Real) return Real; -- -- NOT a random deviate. (Used for testing mostly.) -- -- f(x) = x**(aa-1) * (1-x)**(bb-1) * -- Gamma (aa + bb) / (Gamma (bb)*Gamma (aa)) -- -- x must be in range (0, 1) type Gamma_Initializer is private; procedure Get_Gamma (s : in Real; Gamma_Init : in out Gamma_Initializer; Stream : in out State; Result : out Real); -- -- 1. Must declare variable of type Gamma_Initializer and pass it in. -- The procedure Get_Gamma does everything else for you. -- -- 2. Must have s > 0. -- s = Shape parameter of Gamma distribution. -- -- Generates a random deviate in [0,infinity) from a gamma distribution. function Gamma_Probability (s : in Real; x : in Real) return Real; -- -- f(x) = x**(s-1) * Exp (-x) / Gamma (s) -- = 0 if x < 0. -- -- (where s = Gamma shape parameter). -- Must have s > 0. -- NOT a random deviate. (Used for testing mostly.) subtype Chi_Initializer is Gamma_Initializer; procedure Get_Chi_Squared (Degrees_of_Freedom : in Real; Chi_Init : in out Chi_Initializer; Stream : in out State; Result : out Real); -- -- 1. Must declare variable of type Chi_Initializer and pass it in. -- The procedure Get_Chi_Squared does everything else for you. -- -- 2. Must have Degrees_of_Freedom > 0. -- -- Generates a random deviate in [0,infinity) from a Chi-Sq distribution. function Chi_Squared_Probability (Degrees_of_Freedom : in Real; x : in Real) return Real; -- -- f(x) = (1 / 2) * (x / 2)**(s-1) * Exp (-x / 2) / Gamma (s) -- = 0 if x < 0. -- -- (where s = 0.5 * Degrees_of_Freedom). -- NOT a random deviate. (Used for testing mostly.) -- USING Get_Multivariate_Normal: -- -- procedure Get_Multivariate_Normal is harder to use than the 1-dimensional -- routines. You have to remember the following: -- 1. You need a positive definite Covariance matrix. -- 2. Declare it type Matrix (a..b, a..b) where a and b are type Positive. -- 3. Declare Means : Vector(a..b), same range as Matrix, and initialize Means. -- 4. Use procedure Choleski_Decompose to get the LU decomp. of Covariance. subtype MV_Normal_Initializer is Normal_Initializer; type Vector is array (Positive range <>) of Real; type Matrix is array (Positive range <>, Positive range <>) of Real; procedure Choleski_Decompose (Covariance : in Matrix; LU_of_Covariance : out Matrix); -- Choleski Decomp of Covariance matrix. procedure Get_Multivariate_Normal (Mean : in Vector; LU_of_Covariance : in Matrix; MV_Init : in out MV_Normal_Initializer; Stream : in out State; Result : out Vector); -- -- To use Get_Multivariate_Normal: -- put a Positive Definite Covariance matrix into -- Choleski_Decompose to get Sqrt_Covariance. -- -- Must have -- Mean'First = Covariance'First(1) = Covariance'First(2) -- Mean'Last = Covariance'Last(1) = Covariance'Last(2) -- Mean'Length > 1 -- So use: -- Mean : Vector (1..n); -- Covariance : Matrix (1..n, 1..n); -- -- Must initialize: Mean. function Multivariate_Normal_Probability (Mean : in Vector; -- Mean of random variables X LU_of_Covariance : in Matrix; -- L of LU decomp of Covariance matrix X : in Vector) return Real; procedure Test_Choleski; private Half : constant Real := +0.5; Zero : constant Real := +0.0; One : constant Real := +1.0; Two : constant Real := +2.0; Three : constant Real := +3.0; Four : constant Real := +4.0; Five : constant Real := +5.0; Eight : constant Real := +8.0; Sixteen : constant Real := +16.0; Quarter : constant Real := +0.25; Two_to_the_Ninth : constant Real := +512.0; type Binomial_Initializer is record n : Positive := Positive'First; r0 : Integer := 0; p : Real := Half; p_r : Real := Zero; odds_ratio : Real := Zero; Uninitialized : Boolean := True; end record; type Student_t_Initializer is record m : Positive := Positive'First; a, f, g : Real := Zero; Uninitialized : Boolean := True; end record; type Beta_Initializer is record Alpha, Beta : Real := Zero; d, f, h, t, c : Real := Zero; Swap : Boolean := False; Uninitialized : Boolean := True; end record; type Gamma_Initializer is record s, p, c, uf, vr, d : Real := Zero; Uninitialized : Boolean := True; end record; type Neg_Binomial_Initializer is record Reciprocal_Log_p1 : Real := Zero; Reciprocal_Log_q1 : Real := Zero; p : Real := Half; Uninitialized : Boolean := True; end record; type Normal_Initializer is record Mean : Real := Zero; Sigma : Real := Zero; X2 : Real := Zero; Uninitialized : Boolean := True; end record; Max_Allowed_Real : constant Real := Two**(Real'Machine_Emax-32); Min_Allowed_Real : constant Real := Two**(Real'Machine_Emin+32); end Disorderly.Basic_Rand.Deviates;
with System; use System; package body opencl_api_spec is function Load_From(h: dl_loader.Handle) return Boolean is begin clGetPlatformIDs := dl_loader.Get_Symbol(h, "clGetPlatformIDs"); clGetPlatformInfo := dl_loader.Get_Symbol(h, "clGetPlatformInfo"); clGetDeviceIDs := dl_loader.Get_Symbol(h, "clGetDeviceIDs"); clGetDeviceInfo := dl_loader.Get_Symbol(h, "clGetDeviceInfo"); clCreateContext := dl_loader.Get_Symbol(h, "clCreateContext"); clReleaseContext := dl_loader.Get_Symbol(h, "clReleaseContext"); clCreateProgramWithSource := dl_loader.Get_Symbol(h, "clCreateProgramWithSource"); clBuildProgram := dl_loader.Get_Symbol(h, "clBuildProgram"); clGetProgramBuildInfo := dl_loader.Get_Symbol(h, "clGetProgramBuildInfo"); clReleaseProgram := dl_loader.Get_Symbol(h, "clReleaseProgram"); clCreateKernel := dl_loader.Get_Symbol(h, "clCreateKernel"); clReleaseKernel := dl_loader.Get_Symbol(h, "clReleaseKernel"); clEnqueueNDRangeKernel := dl_loader.Get_Symbol(h, "clEnqueueNDRangeKernel"); clSetKernelArg := dl_loader.Get_Symbol(h, "clSetKernelArg"); clReleaseMemObject := dl_loader.Get_Symbol(h, "clReleaseMemObject"); clCreateBuffer := dl_loader.Get_Symbol(h, "clCreateBuffer"); clEnqueueReadBuffer := dl_loader.Get_Symbol(h, "clEnqueueReadBuffer"); clEnqueueWriteBuffer := dl_loader.Get_Symbol(h, "clEnqueueWriteBuffer"); clCreateCommandQueueWithProperties := dl_loader.Get_Symbol(h, "clCreateCommandQueueWithProperties"); clReleaseCommandQueue := dl_loader.Get_Symbol(h, "clReleaseCommandQueue"); clWaitForEvents := dl_loader.Get_Symbol(h, "clWaitForEvents"); clReleaseEvent := dl_loader.Get_Symbol(h, "clReleaseEvent"); clRetainEvent := dl_loader.Get_Symbol(h, "clRetainEvent"); clFinish := dl_loader.Get_Symbol(h, "clFinish"); return clCreateBuffer /= System.Null_Address; --TODO end; end opencl_api_spec;
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C; use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C; procedure euler31 is type stringptr is access all char_array; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; type a is Array (Integer range <>) of Integer; type a_PTR is access a; type b is Array (Integer range <>) of a_PTR; type b_PTR is access b; function result(sum : in Integer; t : in a_PTR; maxIndex : in Integer; cache : in b_PTR) return Integer is out0 : Integer; div : Integer; begin if cache(sum)(maxIndex) /= 0 then return cache(sum)(maxIndex); else if sum = 0 or else maxIndex = 0 then return 1; else out0 := 0; div := sum / t(maxIndex); for i in integer range 0..div loop out0 := out0 + result(sum - i * t(maxIndex), t, maxIndex - 1, cache); end loop; cache(sum)(maxIndex) := out0; return out0; end if; end if; end; t : a_PTR; o : a_PTR; cache : b_PTR; begin t := new a (0..7); for i in integer range 0..7 loop t(i) := 0; end loop; t(0) := 1; t(1) := 2; t(2) := 5; t(3) := 10; t(4) := 20; t(5) := 50; t(6) := 100; t(7) := 200; cache := new b (0..200); for j in integer range 0..200 loop o := new a (0..7); for k in integer range 0..7 loop o(k) := 0; end loop; cache(j) := o; end loop; PInt(result(200, t, 7, cache)); end;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 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 Orka.Rendering.Buffers.Mapped.Unsynchronized; package Orka.Rendering.Buffers.MDI is pragma Preelaborate; package UB renames Mapped.Unsynchronized; type Batch (Vertex_Kind : Types.Numeric_Type; Index_Kind : Types.Index_Type) is tagged record -- Attributes Data : UB.Unsynchronized_Mapped_Buffer (Kind => Vertex_Kind, Mode => Mapped.Write); Indices : UB.Unsynchronized_Mapped_Buffer (Kind => Index_Kind, Mode => Mapped.Write); Commands : UB.Unsynchronized_Mapped_Buffer (Kind => Types.Elements_Command_Type, Mode => Mapped.Write); Index_Offset : Natural := 0; Vertex_Offset : Natural := 0; Draw_Index : Natural := 0; Instance_Index : Natural := 0; end record; procedure Append (Object : in out Batch; Instances : Natural; Vertices : Natural; Indices : Natural; Append_Vertices : not null access procedure (Offset, Count : Natural); Append_Indices : not null access procedure (Offset, Count : Natural)); function Create_Batch (Vertex_Kind : Types.Numeric_Type; Index_Kind : Types.Index_Type; Parts, Vertex_Data, Indices : Positive) return Batch; procedure Finish_Batch (Object : in out Batch); ----------------------------------------------------------------------------- function Create_Batch (Parts, Vertices, Indices : Positive) return Batch with Post => Create_Batch'Result.Vertex_Kind = Types.Half_Type and Create_Batch'Result.Index_Kind = Types.UInt_Type; procedure Append (Object : in out Batch; Positions : not null Indirect.Half_Array_Access; Normals : not null Indirect.Half_Array_Access; UVs : not null Indirect.Half_Array_Access; Indices : not null Indirect.UInt_Array_Access) with Pre => Object.Vertex_Kind = Types.Half_Type and Object.Index_Kind = Types.UInt_Type; end Orka.Rendering.Buffers.MDI;
pragma No_Run_Time; with Interfaces.C; with APEX; use APEX; with APEX.Processes; use APEX.Processes; with APEX.Partitions; use APEX.Partitions; with APEX.Timing; use APEX.Timing; with APEX.Sampling_Ports; use APEX.Sampling_Ports; package Main is procedure Send; procedure Main; pragma Export (C, Main, "main"); end Main;
package Altunits with Spark_Mode is -- Base Units subtype Length_Type is Float; subtype Time_Type is Float; subtype Linear_Velocity_Type is Float; -- Base units --Meter : constant Length_Type := Length_Type (1.0); --Second : constant Time_Type := Time_Type (1.0); end Altunits;
with Interfaces.C, System; package eGL is use Interfaces; --------- -- Types -- subtype void_Ptr is System.Address; subtype Display is System.Address; subtype NativeWindowType is Interfaces.C.unsigned_long; subtype NativePixmapType is Interfaces.C.unsigned_long; subtype EGLint is Interfaces.Integer_32; subtype EGLBoolean is Interfaces.C.unsigned; subtype EGLenum is Interfaces.C.unsigned; subtype EGLConfig is void_ptr; subtype EGLContext is void_ptr; subtype EGLDisplay is void_ptr; subtype EGLSurface is void_ptr; subtype EGLClientBuffer is void_ptr; type void_Ptr_array is array (C.size_t range <>) of aliased void_Ptr; type Display_array is array (C.size_t range <>) of aliased eGL.Display; type NativeWindowType_array is array (C.size_t range <>) of aliased eGL.NativeWindowType; type NativePixmapType_array is array (C.size_t range <>) of aliased eGL.NativePixmapType; type EGLint_array is array (C.size_t range <>) of aliased eGL.EGLint; type EGLBoolean_array is array (C.size_t range <>) of aliased eGL.EGLBoolean; type EGLenum_array is array (C.size_t range <>) of aliased eGL.EGLenum; type EGLConfig_array is array (C.size_t range <>) of aliased eGL.EGLConfig; type EGLContext_array is array (C.size_t range <>) of aliased eGL.EGLContext; type EGLDisplay_array is array (C.size_t range <>) of aliased eGL.EGLDisplay; type EGLSurface_array is array (C.size_t range <>) of aliased eGL.EGLSurface; type EGLClientBuffer_array is array (C.size_t range <>) of aliased eGL.EGLClientBuffer; ------------- -- Constants -- EGL_VERSION_1_0 : constant := 1; EGL_VERSION_1_1 : constant := 1; EGL_VERSION_1_2 : constant := 1; EGL_VERSION_1_3 : constant := 1; EGL_VERSION_1_4 : constant := 1; EGL_FALSE : constant := 0; EGL_TRUE : constant := 1; EGL_SUCCESS : constant := 16#3000#; EGL_NOT_INITIALIZED : constant := 16#3001#; EGL_BAD_ACCESS : constant := 16#3002#; EGL_BAD_ALLOC : constant := 16#3003#; EGL_BAD_ATTRIBUTE : constant := 16#3004#; EGL_BAD_CONFIG : constant := 16#3005#; EGL_BAD_CONTEXT : constant := 16#3006#; EGL_BAD_CURRENT_SURFACE : constant := 16#3007#; EGL_BAD_DISPLAY : constant := 16#3008#; EGL_BAD_MATCH : constant := 16#3009#; EGL_BAD_NATIVE_PIXMAP : constant := 16#300a#; EGL_BAD_NATIVE_WINDOW : constant := 16#300b#; EGL_BAD_PARAMETER : constant := 16#300c#; EGL_BAD_SURFACE : constant := 16#300d#; EGL_CONTEXT_LOST : constant := 16#300e#; EGL_BUFFER_SIZE : constant := 16#3020#; EGL_ALPHA_SIZE : constant := 16#3021#; EGL_BLUE_SIZE : constant := 16#3022#; EGL_GREEN_SIZE : constant := 16#3023#; EGL_RED_SIZE : constant := 16#3024#; EGL_DEPTH_SIZE : constant := 16#3025#; EGL_STENCIL_SIZE : constant := 16#3026#; EGL_CONFIG_CAVEAT : constant := 16#3027#; EGL_CONFIG_ID : constant := 16#3028#; EGL_LEVEL : constant := 16#3029#; EGL_MAX_PBUFFER_HEIGHT : constant := 16#302a#; EGL_MAX_PBUFFER_PIXELS : constant := 16#302b#; EGL_MAX_PBUFFER_WIDTH : constant := 16#302c#; EGL_NATIVE_RENDERABLE : constant := 16#302d#; EGL_NATIVE_VISUAL_ID : constant := 16#302e#; EGL_NATIVE_VISUAL_TYPE : constant := 16#302f#; EGL_PRESERVED_RESOURCES : constant := 16#3030#; EGL_SAMPLES : constant := 16#3031#; EGL_SAMPLE_BUFFERS : constant := 16#3032#; EGL_SURFACE_TYPE : constant := 16#3033#; EGL_TRANSPARENT_TYPE : constant := 16#3034#; EGL_TRANSPARENT_BLUE_VALUE : constant := 16#3035#; EGL_TRANSPARENT_GREEN_VALUE : constant := 16#3036#; EGL_TRANSPARENT_RED_VALUE : constant := 16#3037#; EGL_NONE : constant := 16#3038#; EGL_BIND_TO_TEXTURE_RGB : constant := 16#3039#; EGL_BIND_TO_TEXTURE_RGBA : constant := 16#303a#; EGL_MIN_SWAP_INTERVAL : constant := 16#303b#; EGL_MAX_SWAP_INTERVAL : constant := 16#303c#; EGL_LUMINANCE_SIZE : constant := 16#303d#; EGL_ALPHA_MASK_SIZE : constant := 16#303e#; EGL_COLOR_BUFFER_TYPE : constant := 16#303f#; EGL_RENDERABLE_TYPE : constant := 16#3040#; EGL_MATCH_NATIVE_PIXMAP : constant := 16#3041#; EGL_CONFORMANT : constant := 16#3042#; EGL_SLOW_CONFIG : constant := 16#3050#; EGL_NON_CONFORMANT_CONFIG : constant := 16#3051#; EGL_TRANSPARENT_RGB : constant := 16#3052#; EGL_RGB_BUFFER : constant := 16#308e#; EGL_LUMINANCE_BUFFER : constant := 16#308f#; EGL_NO_TEXTURE : constant := 16#305c#; EGL_TEXTURE_RGB : constant := 16#305d#; EGL_TEXTURE_RGBA : constant := 16#305e#; EGL_TEXTURE_2D : constant := 16#305f#; EGL_PBUFFER_BIT : constant := 16#1#; EGL_PIXMAP_BIT : constant := 16#2#; EGL_WINDOW_BIT : constant := 16#4#; EGL_VG_COLORSPACE_LINEAR_BIT : constant := 16#20#; EGL_VG_ALPHA_FORMAT_PRE_BIT : constant := 16#40#; EGL_MULTISAMPLE_RESOLVE_BOX_BIT : constant := 16#200#; EGL_SWAP_BEHAVIOR_PRESERVED_BIT : constant := 16#400#; EGL_OPENGL_ES_BIT : constant := 16#1#; EGL_OPENVG_BIT : constant := 16#2#; EGL_OPENGL_ES2_BIT : constant := 16#4#; EGL_OPENGL_BIT : constant := 16#8#; EGL_VENDOR : constant := 16#3053#; EGL_VERSION : constant := 16#3054#; EGL_EXTENSIONS : constant := 16#3055#; EGL_CLIENT_APIS : constant := 16#308d#; EGL_HEIGHT : constant := 16#3056#; EGL_WIDTH : constant := 16#3057#; EGL_LARGEST_PBUFFER : constant := 16#3058#; EGL_TEXTURE_FORMAT : constant := 16#3080#; EGL_TEXTURE_TARGET : constant := 16#3081#; EGL_MIPMAP_TEXTURE : constant := 16#3082#; EGL_MIPMAP_LEVEL : constant := 16#3083#; EGL_RENDER_BUFFER : constant := 16#3086#; EGL_VG_COLORSPACE : constant := 16#3087#; EGL_VG_ALPHA_FORMAT : constant := 16#3088#; EGL_HORIZONTAL_RESOLUTION : constant := 16#3090#; EGL_VERTICAL_RESOLUTION : constant := 16#3091#; EGL_PIXEL_ASPECT_RATIO : constant := 16#3092#; EGL_SWAP_BEHAVIOR : constant := 16#3093#; EGL_MULTISAMPLE_RESOLVE : constant := 16#3099#; EGL_BACK_BUFFER : constant := 16#3084#; EGL_SINGLE_BUFFER : constant := 16#3085#; EGL_VG_COLORSPACE_sRGB : constant := 16#3089#; EGL_VG_COLORSPACE_LINEAR : constant := 16#308a#; EGL_VG_ALPHA_FORMAT_NONPRE : constant := 16#308b#; EGL_VG_ALPHA_FORMAT_PRE : constant := 16#308c#; EGL_DISPLAY_SCALING : constant := 10000; EGL_BUFFER_PRESERVED : constant := 16#3094#; EGL_BUFFER_DESTROYED : constant := 16#3095#; EGL_OPENVG_IMAGE : constant := 16#3096#; EGL_CONTEXT_CLIENT_TYPE : constant := 16#3097#; EGL_CONTEXT_CLIENT_VERSION : constant := 16#3098#; EGL_MULTISAMPLE_RESOLVE_DEFAULT : constant := 16#309a#; EGL_MULTISAMPLE_RESOLVE_BOX : constant := 16#309b#; EGL_OPENGL_ES_API : constant := 16#30a0#; EGL_OPENVG_API : constant := 16#30a1#; EGL_OPENGL_API : constant := 16#30a2#; EGL_DRAW : constant := 16#3059#; EGL_READ : constant := 16#305a#; EGL_CORE_NATIVE_ENGINE : constant := 16#305b#; EGL_COLORSPACE : constant := 16#3087#; EGL_ALPHA_FORMAT : constant := 16#3088#; EGL_COLORSPACE_sRGB : constant := 16#3089#; EGL_COLORSPACE_LINEAR : constant := 16#308a#; EGL_ALPHA_FORMAT_NONPRE : constant := 16#308b#; EGL_ALPHA_FORMAT_PRE : constant := 16#308c#; end eGL;