content
stringlengths
23
1.05M
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. separate (Latin_Utils.Dictionary_Package) package body Translation_Record_IO is --------------------------------------------------------------------------- procedure Get (File : in Ada.Text_IO.File_Type; Item : out Translation_Record) is Spacer : Character; pragma Unreferenced (Spacer); begin Age_Type_IO.Get (File, Item.Age); Ada.Text_IO.Get (File, Spacer); Area_Type_IO.Get (File, Item.Area); Ada.Text_IO.Get (File, Spacer); Geo_Type_IO.Get (File, Item.Geo); Ada.Text_IO.Get (File, Spacer); Frequency_Type_IO.Get (File, Item.Freq); Ada.Text_IO.Get (File, Spacer); Source_Type_IO.Get (File, Item.Source); end Get; --------------------------------------------------------------------------- procedure Get (Item : out Translation_Record) is Spacer : Character; pragma Unreferenced (Spacer); begin Age_Type_IO.Get (Item.Age); Ada.Text_IO.Get (Spacer); Area_Type_IO.Get (Item.Area); Ada.Text_IO.Get (Spacer); Geo_Type_IO.Get (Item.Geo); Ada.Text_IO.Get (Spacer); Frequency_Type_IO.Get (Item.Freq); Ada.Text_IO.Get (Spacer); Source_Type_IO.Get (Item.Source); end Get; --------------------------------------------------------------------------- procedure Put (File : in Ada.Text_IO.File_Type; Item : in Translation_Record) is begin Age_Type_IO.Put (File, Item.Age); Ada.Text_IO.Put (File, ' '); Area_Type_IO.Put (File, Item.Area); Ada.Text_IO.Put (File, ' '); Geo_Type_IO.Put (File, Item.Geo); Ada.Text_IO.Put (File, ' '); Frequency_Type_IO.Put (File, Item.Freq); Ada.Text_IO.Put (File, ' '); Source_Type_IO.Put (File, Item.Source); end Put; --------------------------------------------------------------------------- procedure Put (Item : in Translation_Record) is begin Age_Type_IO.Put (Item.Age); Ada.Text_IO.Put (' '); Area_Type_IO.Put (Item.Area); Ada.Text_IO.Put (' '); Geo_Type_IO.Put (Item.Geo); Ada.Text_IO.Put (' '); Frequency_Type_IO.Put (Item.Freq); Ada.Text_IO.Put (' '); Source_Type_IO.Put (Item.Source); end Put; --------------------------------------------------------------------------- procedure Get (Source : in String; Target : out Translation_Record; Last : out Integer ) is -- Used to compute lower bound of string Low : Integer := Source'First - 1; begin Age_Type_IO.Get (Source (Low + 1 .. Source'Last), Target.Age, Low); Low := Low + 1; Area_Type_IO.Get (Source (Low + 1 .. Source'Last), Target.Area, Low); Low := Low + 1; Geo_Type_IO.Get (Source (Low + 1 .. Source'Last), Target.Geo, Low); Low := Low + 1; Frequency_Type_IO.Get (Source (Low + 1 .. Source'Last), Target.Freq, Low); Low := Low + 1; Source_Type_IO.Get (Source (Low + 1 .. Source'Last), Target.Source, Last); end Get; --------------------------------------------------------------------------- procedure Put (Target : out String; Item : in Translation_Record) is -- Used to compute bounds of substrings Low : Integer := 0; High : Integer := 0; begin -- Put Age_Type High := Low + Age_Type_IO.Default_Width; Age_Type_IO.Put (Target (Target'First + Low .. High), Item.Age); Low := High + 1; Target (Low) := ' '; -- Put Area_Type High := Low + Area_Type_IO.Default_Width; Area_Type_IO.Put (Target (Low + 1 .. High), Item.Area); Low := High + 1; Target (Low) := ' '; -- Put Geo_Type High := Low + Geo_Type_IO.Default_Width; Geo_Type_IO.Put (Target (Target'First + Low .. High), Item.Geo); Low := High + 1; Target (Low) := ' '; -- Put Frequency_Type High := Low + Frequency_Type_IO.Default_Width; Frequency_Type_IO.Put (Target (Low + 1 .. High), Item.Freq); Low := High + 1; Target (Low) := ' '; -- Put Source_Type High := Low + Source_Type_IO.Default_Width; Source_Type_IO.Put (Target (Low + 1 .. High), Item.Source); -- Fill remainder of string Target (High + 1 .. Target'Last) := (others => ' '); end Put; --------------------------------------------------------------------------- end Translation_Record_IO;
----------------------------------------------------------------------- -- wiki-filters-collectors -- Wiki word and link collectors -- Copyright (C) 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.Containers.Indefinite_Ordered_Maps; -- === Collector Filters === -- The `Wiki.Filters.Collectors` package defines three filters that can be used to -- collect words, links or images contained in a Wiki document. The collector filters are -- inserted in the filter chain and they collect the data as the Wiki text is parsed. -- After the parsing, the collector filters have collected either the words or the links -- and they can be queried by using the `Find` or `Iterate` operations. -- The following collectors are defined: -- -- * The `Word_Collector_Type` collects words from text, headers, links, -- * The `Link_Collector_Type` collects links, -- * The `Image_Collector_Type` collects images, -- -- The filter is inserted in the filter chain before parsing the Wiki document. -- -- Words : aliased Wiki.Filters.Collectors.Word_Collector_Type; -- ... -- Engine.Add_Filter (Words'Unchecked_Access); -- -- Once the document is parsed, the collector filters contains the data that was collected. -- The `Iterate` procedure can be used to have a procedure called for each value -- collected by the filter. -- -- Words.Iterate (Print'Access); -- package Wiki.Filters.Collectors is pragma Preelaborate; package WString_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Wiki.Strings.WString, Element_Type => Natural, "<" => "<", "=" => "="); subtype Map is WString_Maps.Map; subtype Cursor is WString_Maps.Cursor; -- ------------------------------ -- General purpose collector type -- ------------------------------ type Collector_Type is new Filter_Type with private; type Collector_Type_Access is access all Collector_Type'Class; function Find (Map : in Collector_Type; Item : in Wiki.Strings.WString) return Cursor; function Contains (Map : in Collector_Type; Item : in Wiki.Strings.WString) return Boolean; procedure Iterate (Map : in Collector_Type; Process : not null access procedure (Pos : in Cursor)); -- ------------------------------ -- Word Collector type -- ------------------------------ type Word_Collector_Type is new Collector_Type with private; type Word_Collector_Type_Access is access all Word_Collector_Type'Class; -- Add a text content with the given format to the document. procedure Add_Text (Filter : in out Word_Collector_Type; Document : in out Wiki.Documents.Document; Text : in Wiki.Strings.WString; Format : in Wiki.Format_Map); -- Add a section header with the given level in the document. procedure Add_Header (Filter : in out Word_Collector_Type; Document : in out Wiki.Documents.Document; Header : in Wiki.Strings.WString; Level : in Natural); -- Add a link. procedure Add_Link (Filter : in out Word_Collector_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Add an image. procedure Add_Image (Filter : in out Word_Collector_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Add a quote. procedure Add_Quote (Filter : in out Word_Collector_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Add a text block that is pre-formatted. procedure Add_Preformatted (Filter : in out Word_Collector_Type; Document : in out Wiki.Documents.Document; Text : in Wiki.Strings.WString; Format : in Wiki.Strings.WString); -- ------------------------------ -- Link Collector type -- ------------------------------ type Link_Collector_Type is new Collector_Type with private; type Link_Collector_Type_Access is access all Link_Collector_Type'Class; -- Add a link. overriding procedure Add_Link (Filter : in out Link_Collector_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Push a HTML node with the given tag to the document. overriding procedure Push_Node (Filter : in out Link_Collector_Type; Document : in out Wiki.Documents.Document; Tag : in Wiki.Html_Tag; Attributes : in out Wiki.Attributes.Attribute_List); -- ------------------------------ -- Image Collector type -- ------------------------------ type Image_Collector_Type is new Collector_Type with private; type Image_Collector_Type_Access is access all Image_Collector_Type'Class; -- Add an image. overriding procedure Add_Image (Filter : in out Image_Collector_Type; Document : in out Wiki.Documents.Document; Name : in Wiki.Strings.WString; Attributes : in out Wiki.Attributes.Attribute_List); -- Push a HTML node with the given tag to the document. overriding procedure Push_Node (Filter : in out Image_Collector_Type; Document : in out Wiki.Documents.Document; Tag : in Wiki.Html_Tag; Attributes : in out Wiki.Attributes.Attribute_List); private type Collector_Type is new Filter_Type with record Items : WString_Maps.Map; end record; procedure Collect_Attribute (Filter : in out Collector_Type; Attributes : in Wiki.Attributes.Attribute_List; Name : in String); type Word_Collector_Type is new Collector_Type with null record; procedure Collect_Words (Filter : in out Word_Collector_Type; Content : in Wiki.Strings.WString); type Link_Collector_Type is new Collector_Type with null record; type Image_Collector_Type is new Collector_Type with null record; end Wiki.Filters.Collectors;
-- { dg-do compile } -- { dg-options "-gnatws" } procedure Nested_Proc2 is type Arr is array(1..2) of Integer; type Rec is record Data : Arr; end record; From : Rec; Index : Integer; function F (X : Arr) return Integer is begin return 0; end; procedure Test is begin Index := F (From.Data); If Index /= 0 then raise Program_Error; end if; end; begin Test; end;
package box_info is -- exception levée si paramètres incorrects invalid_args : exception; -- décrit les paramètres de la boîte type box_info_t is record -- paramètre t thickness : integer; -- paramètre h height : integer; -- paramètre w width : integer; -- paramètre l length : integer; -- paramètre q queue_length : integer; -- paramètre b -- requiert : b < h - 2t inner_height : integer; end record; -- initialise une boîte avec les paramètres donnés -- param t : epaisseur des planches -- param w : largeur de la boîte -- param l : longueur de la boîte -- param h : hauteur de la boîte -- param q : longueur des queues -- param b : hauteur de la boîte interne function initialize_box(t, w, l, h, q, b : integer) return box_info_t; -- valide les mesures fournies pour la boîte -- exception : invalid_args si incohérence dans les coordonnées procedure validate_box_measurements(box : box_info_t); -- renvoie une chaine de texte décrivant l'état de l'objet function to_string(box : box_info_t) return string; end box_info;
-- Ada Unit Library -- -- Authors: Emanuel Regnath (emanuel.regnath@tum.de) -- -- Description: Library for physical calculations -- -- ToDo: -- [ ] rename to Units.Mechanics3D or Physics.Units, Physics.Vector3D with Ada.Numerics.Generic_Real_Arrays; package Units.Vectors with SPARK_Mode is package Unit_Arrays_Pack is new Ada.Numerics.Generic_Real_Arrays(Base_Unit_Type); subtype Scalar is Base_Unit_Type; type Vector3D_Type is array(1 .. 3) of Base_Unit_Type; type Polar_Coordinates_Type is (Phi, Rho, Psi); type Earth_Coordinates_Type is (LONGITUDE, LATITUDE, ALTITUDE); type Cartesian_Coordinates_Type is (X, Y, Z); type Cartesian_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type; subtype Translation_Vector_Array is Vector3D_Type; -- of Length_Type; --subtype Position_Vector is Karthesian_Vector_Type with Dimension => (Symbol => 'm', Meter => 1, others => 0); -- type Dim_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type with Dimension_System => -- ((Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'), -- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'), -- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'), -- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'), -- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"), -- (Unit_Name => Radian, Unit_Symbol => "Rad", Dim_Symbol => "A")); type Translation_Vector is array(Cartesian_Coordinates_Type) of Length_Type; -- of Length_Type; type Linear_Velocity_Vector is array(Cartesian_Coordinates_Type) of Linear_Velocity_Type; type Linear_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Linear_Acceleration_Type; -- -- -- type Orientation_Dimension_Type is (R, P, Y); -- subtype Orientation_Vector_Type is Unit_Arrays.Real_Vector(Orientation_Dimension_Type) of Angle_Type; -- -- subtype Orientation_Vector is Orientation_Vector_Type of Angle_Type; -- subtype Rotation_Vector is Orientation_Vector_Type of Angle_Type; type Magnetic_Flux_Density_Vector is array(Cartesian_Coordinates_Type) of Magnetic_Flux_Density_Type; -- Rotation Systems type Tait_Bryan_Angle_Type is (ROLL, PITCH, YAW); type Euler_Angle_Type is (X1, Z2, X3); type Angular_Vector is array(Cartesian_Coordinates_Type) of Base_Unit_Type; type Unit_Vector is array(Tait_Bryan_Angle_Type) of Angle_Type; type Angle_Vector is array(Cartesian_Coordinates_Type) of Angle_Type; type Rotation_Vector is array(Cartesian_Coordinates_Type) of Angle_Type; type Angular_Velocity_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type; type Angular_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type; function "+" (Left, Right : Translation_Vector) return Translation_Vector is ( ( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) ) ); function "+" (Left, Right : Angle_Vector) return Angle_Vector is ( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) ); function "+" (Left, Right : Rotation_Vector) return Rotation_Vector is ( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) ); function "*" (Left : Base_Unit_Type; Right : Rotation_Vector) return Rotation_Vector is ( ( Unit_Type(Left) * Right(X), Unit_Type(Left) * Right(Y), Unit_Type(Left) * Right(Z) ) ); function "+" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is ( ( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) ) ); function "-" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is ( ( Left(X) - Right(X), Left(Y) - Right(Y), Left(Z) - Right(Z) ) ); function "*" (Left : Angular_Velocity_Vector; Right : Time_Type) return Rotation_Vector is ( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) ); function "*" (Left : Linear_Velocity_Vector; Right : Time_Type) return Translation_Vector is ( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) ); function Unit_Square (val : Base_Unit_Type) return Base_Unit_Type with Post => Unit_Square'Result >= Base_Unit_Type (0.0); -- numerically safe power val*val procedure rotate(vector : in out Cartesian_Vector_Type; axis : Cartesian_Coordinates_Type; angle : Angle_Type); function "abs" (vector : Cartesian_Vector_Type) return Base_Unit_Type; function "abs" (vector : Angular_Vector) return Base_Unit_Type; function "abs" (vector : Linear_Acceleration_Vector) return Linear_Acceleration_Type; -- Matrices subtype Unit_Matrix is Unit_Arrays_Pack.Real_Matrix; -- array(Natural <>, Natural <>) of type Unit_Vector2D is array(1..2) of Base_Unit_Type; type Unit_Matrix2D is array(1..2, 1..2) of Base_Unit_Type; -- subtype Unit_Vector2D is Unit_Arrays_Pack.Real_Vector(1..2); --subtype Unit_Vector3D is Unit_Arrays_Pack.Real_Vector(1..3); subtype Unit_Matrix3D is Unit_Arrays_Pack.Real_Matrix(1..3, 1..3); function "+" (Left, Right : Unit_Vector2D) return Unit_Vector2D is ( Left(1) + Right(1), Left(2) + Right(2) ); function "-" (Left, Right : Unit_Vector2D) return Unit_Vector2D is ( Left(1) - Right(1), Left(2) - Right(2) ); -- n×n Identity Matrix function Eye( n : Natural ) return Unit_Matrix; -- with Pre => n > 0; -- n×n Matrix with all elements 1.0 function Ones( n : Natural ) return Unit_Matrix; -- with Pre => n > 0; -- n×n Matrix with all elements 0.0 function Zeros( n : Natural ) return Unit_Matrix; -- with Pre => n > 0; procedure setOnes( A : in out Unit_Matrix; first : Natural; last : Natural); end Units.Vectors;
-- { dg-do compile } -- { dg-options "-gnatN" } with inline_scope_p; procedure inline_scope (X : Integer) is type A is array (Integer range 1 .. 2) of Boolean; S : A; pragma Warnings (Off, S); procedure Report_List is begin inline_scope_p.Assert (S (1), Natural'Image (Natural (1))); end Report_List; begin null; end;
with Ada.Text_IO; use Ada.Text_IO; procedure T_Inv is package Internal is type Unknown is private with Type_Invariant => Isnt_Bad_Luck (Unknown); function Isnt_Bad_Luck (S : Unknown) return Boolean; procedure Assign (S : out Unknown; D : in Integer); function To_String (S : Unknown) return String; private type Unknown is new Integer; end Internal; package body Internal is procedure Assign (S : out Unknown; D : in Integer) is P : constant Unknown := 13; begin -- This is ok: this intermediate value won't go outside here S := P; Put_Line ("It's ok " & Integer'Image (Integer (S))); S := Unknown (D + 2 * Integer (P)); Put_Line ("And now?"); -- let's see what happens later end Assign; -- 13 is bad luck - indeed it's just like any other number, but -- you know, people can believe it. function Isnt_Bad_Luck (S : Unknown) return Boolean is (S /= 13); -- This helps function To_String (S : Unknown) return String is (Integer'Image (Integer (S))); end Internal; V : Internal.Unknown; begin Internal.Assign (V, 11); Put_Line ("Here it is " & Internal.To_String (V)); Internal.Assign (V, -13); Put_Line ("And another one " & Internal.To_String (V)); end T_Inv;
----------------------------------------------------------------------- -- gen-commands-page -- Page creation command for dynamo -- Copyright (C) 2011, 2012, 2013, 2014, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Ada.Text_IO; with Gen.Artifacts; with Util.Strings; package body Gen.Commands.Page is -- ------------------------------ -- Execute the command with the arguments. -- ------------------------------ overriding procedure Execute (Cmd : in out Command; Name : in String; Args : in Argument_List'Class; Generator : in out Gen.Generator.Handler) is function Get_Layout return String; function Get_Name return String; Dir : constant String := Generator.Get_Result_Directory & "web/"; function Get_Name return String is Name : constant String := Args.Get_Argument (1); Pos : constant Natural := Util.Strings.Rindex (Name, '.'); begin if Pos = 0 then return Name; elsif Name (Pos .. Name'Last) = ".xhtml" then return Name (Name'First .. Pos - 1); elsif Name (Pos .. Name'Last) = ".html" then return Name (Name'First .. Pos - 1); else return Name; end if; end Get_Name; function Get_Layout return String is begin if Args.Get_Count = 1 then return "layout"; end if; declare Layout : constant String := Args.Get_Argument (2); begin if Ada.Directories.Exists (Dir & "WEB-INF/layouts/" & Layout & ".xhtml") then return Layout; end if; Generator.Info ("Layout file {0} not found.", Layout); return Layout; end; end Get_Layout; begin if Args.Get_Count = 0 or Args.Get_Count > 2 then Cmd.Usage (Name, Generator); return; end if; Generator.Set_Force_Save (False); Generator.Set_Result_Directory (Dir); Generator.Set_Global ("pageName", Get_Name); Generator.Set_Global ("layout", Get_Layout); Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "page"); end Execute; -- ------------------------------ -- Write the help associated with the command. -- ------------------------------ overriding procedure Help (Cmd : in out Command; Name : in String; Generator : in out Gen.Generator.Handler) is pragma Unreferenced (Cmd, Name); use Ada.Text_IO; use Ada.Directories; Path : constant String := Generator.Get_Result_Directory & "web/WEB-INF/layouts"; Filter : constant Filter_Type := (Ordinary_File => True, others => False); Search : Search_Type; Ent : Directory_Entry_Type; begin Put_Line ("add-page: Add a new web page to the application"); Put_Line ("Usage: add-page NAME [LAYOUT]"); New_Line; Put_Line (" The web page is an XHTML file created under the 'web' directory."); Put_Line (" The NAME can contain a directory that will be created if necessary."); Put_Line (" The new web page can be configured to use the given layout."); Put_Line (" The layout file must exist to be used. The default layout is 'layout'."); Put_Line (" You can create a new layout with 'add-layout' command."); Put_Line (" You can also write your layout by adding an XHTML file in the directory:"); Put_Line (" " & Path); if Exists (Path) then New_Line; Put_Line (" Available layouts:"); Start_Search (Search, Directory => Path, Pattern => "*.xhtml", Filter => Filter); while More_Entries (Search) loop Get_Next_Entry (Search, Ent); declare Name : constant String := Simple_Name (Ent); Layout : constant String := Base_Name (Name); begin Put_Line (" " & Layout); end; end loop; end if; New_Line; Put_Line (" The following files are generated:"); Put_Line (" web/<name>.xhtml"); end Help; end Gen.Commands.Page;
With INI.Section_to_Map, Ada.Containers, Ada.Text_IO, Ada.Characters.Conversions, Ada.Characters.Latin_1, Ada.Strings.Fixed, Ada.Strings.Unbounded, Gnoga.Gui.Element.Form.Fieldset; Package Body NSO.Helpers is Use NSO.Types; Procedure Add_Discrete( Form : in out Gnoga.Gui.Element.Form.Form_Type'Class; Parent : in out Gnoga.Gui.Element.Form.Selection_Type'Class ) is Use Gnoga.Gui.Element.Form; Items : Array(Options'Range) of Option_Type; Begin For Index in Items'Range Loop declare Image : String renames Options'Image(Index); Element : Option_Type renames Items(Index); begin Element.Create ( --ID => "OPTION_" & Image, Form => Form, Selection => Parent, Value => Image, Text => Image, Selected => False, Disabled => False ); end; End loop; End Add_Discrete; Procedure Add_Vector( Form : in out Gnoga.Gui.Element.Form.Form_Type'Class; Parent : in out Gnoga.Gui.Element.Form.Selection_Type'Class; Input : in String_Vector.Vector; Prefix : in String:= "" ) is Use Gnoga.Gui.Element.Form; Items : Array(Input.First_Index..Input.Last_Index) of Option_Type; Begin For Index in Items'Range Loop declare This : String renames Input(Index); Image : String renames "&"(Prefix, This); Element : Option_Type renames Items(Index); begin Element.Create ( --ID => "OPTION_" & Image, Form => Form, Selection => Parent, Value => Image, Text => This, Selected => False, Disabled => False ); end; End loop; End Add_Vector; Procedure Add_Map( Form : in out Gnoga.Gui.Element.Form.Form_Type'Class; Parent : in out Gnoga.Gui.Element.Form.Selection_Type'Class; Input : in String_Map.Map; Prefix : in String:= "" ) is Use Gnoga.Gui.Element.Form, NSO.Types.String_Map, Ada.Containers; Items : Array(1..Input.Length) of Option_Type; Current : Count_Type := Items'First; Begin For KVP in Input.Iterate loop declare This : String renames Element(KVP); Image : String renames Key(KVP); Element : Option_Type renames Items(Current); begin Element.Create ( --ID => "OPTION_" & Image, Form => Form, Selection => Parent, Value => Image, -- Value is the value of the selection; which should be KEY. Text => This, -- Text is the display's value, which should be the ELEMENT. Selected => False, Disabled => False ); end; Current:= Count_Type'Succ(Current); end loop; End Add_Map; Procedure Add_Sections( Form : in out Gnoga.Gui.Element.Form.Form_Type'Class; Parent : in out Gnoga.Gui.Element.Form.Selection_Type'Class; Fields : in NSO.Types.String_Vector.Vector; File : in INI.Instance; Prefix : in String:= "" ) is Use Gnoga.Gui.Element.Form; Sections : Array(1..Natural(Fields.Length)) of Option_Group_Type; Begin For S in Sections'Range loop Declare Group : Option_Group_Type renames Sections(S); Name : String renames Fields(S); Begin Group.Create( Form => Form, Selection => Parent, Label => Name ); Declare Function "-"(Right : String_Map.Cursor) return String is E : String renames String_Map.Element(Right); First : Constant Natural:= E'First; Last : Constant Natural:= E'Last; Begin Return (if E(First) = '"' and E(Last) = '"' then E(Natural'Succ(First)..Natural'Pred(Last)) else E ); End "-"; Mapping : String_Map.Map renames INI.Section_to_Map(File, Name); Options : Array(1..Natural(Mapping.Length)) of Option_Type; Cursor : Natural:= Options'First; use String_Map; Begin For KVP in Mapping.Iterate loop Options(Cursor).Create( Form => Form, Selection => Group, Value => Name & '.' & (-KVP), Text => (-KVP) ); Cursor:= Natural'Succ( Cursor ); End loop; End; End; End loop; End Add_Sections; Procedure Add_Section_Groups( Form : in out Gnoga.Gui.Element.Form.Form_Type'Class; Parent : in out Gnoga.Gui.Element.Element_Type'Class;--Form.Selection_Type'Class; Fields : in NSO.Types.String_Vector.Vector; File : in INI.Instance; Name : in String:= "" ) is Function Base_ID return String is (if Name'Length in Positive then Name&'.' else""); Use Gnoga.Gui.Element.Form, Gnoga.Gui.Element.Form.Fieldset; Sections : Array(1..Natural(Fields.Length)) of Selection_Type; Container: Fieldset_Type; Caption : String renames Trim( Name ); Begin Container.Create(Parent => Parent);--, ID => Caption); if Caption'Length in Positive then Container.Put_Legend(Value => Caption); end if; For S in Sections'Range loop MAKE_GROUP: Declare Group : Selection_Type renames Sections(S); Name : String renames Fields(S); Label : Label_Type; Begin Group.Create ( ID => Base_ID & Name, Form => Form, Name => Name, Multiple_Select => True, Visible_Lines => 5 ); Label.Create ( Form => Form, Label_For => Group, Content => "<span style=""Display:Block; Clear:Both;"">" & Name & "</span>" ); Label.Style(Name => "display", Value => "inline-block"); Label.Margin(Right => "5em"); --Label.Vertical_Align(Gnoga.Gui.Element.Top); POPULATE_POTIONS: Declare Function "-"(Right : String_Map.Cursor) return String is E : String renames String_Map.Element(Right); First : Constant Natural:= E'First; Last : Constant Natural:= E'Last; Begin Return (if E(First) = '"' and E(Last) = '"' then E(Natural'Succ(First)..Natural'Pred(Last)) else E ); End "-"; Mapping : String_Map.Map renames INI.Section_to_Map(File, Name); Options : Array(1..Natural(Mapping.Length)) of Option_Type; Cursor : Natural:= Options'First; use String_Map; Begin For KVP in Mapping.Iterate loop Options(Cursor).Create( Form => Form, Selection => Group, Value => Name & '.' & (-KVP), Text => (-KVP) ); Cursor:= Natural'Succ( Cursor ); End loop; End POPULATE_POTIONS; Group.Place_Inside_Bottom_Of( Label ); Label.Place_Inside_Bottom_Of(Container); End MAKE_GROUP; Container.Place_Inside_Bottom_Of(Parent); End loop; End ADD_SECTION_GROUPS; Function Unescape_JSON_String( Input : String ) Return String is Use Ada.Strings.Unbounded, Ada.Characters; Working : Unbounded_String := To_Unbounded_String(""); Escape : Boolean := False; Subtype Escape_Character is Character with Static_Predicate => Escape_Character in '"' | '\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u'; Procedure Append( Item : Character ) with Inline is Begin Append( New_Item => Item, Source => Working ); End Append; Begin -- For handling escaped characters, I've separated things into two -- portions: First, we handle the single-character escapes; Second, -- we handle the hex-code escapes. For C of Input loop if Escape then Escape:= False; case Escape_Character'(C) is when '"' => Append( Latin_1.Quotation ); when '\' => Append( Latin_1.Reverse_Solidus ); when '/' => Append( Latin_1.Solidus ); when 'b' => Append( Latin_1.BS ); when 'f' => Append( Latin_1.FF ); when 'n' => Append( Latin_1.LF ); when 'r' => Append( Latin_1.CR ); when 't' => Append( Latin_1.HT ); when 'u' => -- Four-hex escape-value next. Append( New_Item => "\u", Source => Working ); end case; elsif C = '\' then Escape:= True; else Append( C ); end if; End Loop; Handle_Hex: Declare Hex_Escape : Constant String:= "\u"; Location : Natural := Index( Working, Hex_Escape ); -- Function WChar return Wide_Wide_Character is -- ( Wide_Wide_Character'Pos( Wide_Wide_Integer'Va ) ); Begin -- while Location in Positive loop Declare Subtype String_4 is String(1..4); Chunk : String_4 renames Slice(Working, Location, Location+3); -- Pos : Long_Long_Integer renames Long_Long_Integer'Value( "16#" & Chunk & '#' ); -- WC : Wide_Wide_Character renames Wide_Wide_Character'Val( Pos ); Begin Ada.Text_IO.Put_Line( "CHUNK: " & Chunk ); -- Append(Ada.Characters.Conversions.To_Character( WC )); End; -- Ada.Characters.Conversions.To_Character -- ( -- -- ); -- end loop; End Handle_Hex; Return Ada.Strings.Unbounded.To_String( Working ); End Unescape_JSON_String; Function Next( Stream : not null access NSO.Types.Root_Stream_Class ) return Character_Reference is ( New Character'( Character'Input(Stream) ) ); -- Given "X", produces "<X>". Function HTML_Open(Name : String) return String is ( '<' & Name & '>' ) with Inline; -- Produces: <Name Attribute="Value"> Function HTML_Open(Name, Attribute, Value: String) return String is ( '<' & Name &' '& Attribute & "=""" & Value & """>" ) with Inline; -- Given "X", produces "</X>"; uses HTML_Open for bracket-consistency. Function HTML_Close(Name : String) return String is ( HTML_Open('/' & Name) ) with Inline; Function HTML_Tag(Name, Text : String) return String is ( HTML_Open(Name) & Text & HTML_Close(Name) ); Function HTML_Tag(Name, Text, Attribute, Value : String) return String is ( HTML_Open(Name, Attribute, Value) & Text & HTML_Close(Name) ); Function Trim( Input : String ) return String is Use Ada.Strings; Begin Return Fixed.Trim( Side => Both, Source => Input ); End Trim; End NSO.Helpers;
-- AoC 2020, Day 22 with Ada.Text_IO; with Ada.Containers.Vectors; with Ada.Containers.Hashed_Sets; use Ada.Containers; with Ada.Strings.Hash; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Day is package TIO renames Ada.Text_IO; package Deck_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Natural); use Deck_Vectors; type State is record player1 : Deck_Vectors.Vector; player2 : Deck_Vectors.Vector; end record; function state_hash(item : in State) return Hash_Type is h : Unbounded_String := Null_Unbounded_String; begin for c of item.player1 loop h := h & c'IMAGE; end loop; h := h & '-'; for c of item.player2 loop h := h & c'IMAGE; end loop; return Ada.Strings.Hash(to_string(h)); end state_hash; package State_Sets is new Ada.Containers.Hashed_Sets (Element_Type => State, Hash => state_hash, Equivalent_Elements => "="); use State_Sets; pragma Warnings (Off, "procedure ""put_line"" is not referenced"); procedure put_line(d : in Deck_Vectors.Vector) is pragma Warnings (On, "procedure ""put_line"" is not referenced"); begin for card of d loop TIO.put(card'IMAGE & ", "); end loop; TIO.new_line; end put_line; procedure load_deck(file : in out TIO.File_Type; p : in out Deck_Vectors.Vector) is begin p.clear; while not TIO.end_of_file(file) loop declare line : constant String := TIO.get_line(file); begin if line'length = 0 then exit; end if; if line(1) /= 'P' then p.append(Natural'Value(line)); end if; end; end loop; end load_deck; procedure load_decks(filename : in String; p1, p2 : in out Deck_Vectors.Vector) is file : TIO.File_Type; begin TIO.open(File => file, Mode => TIO.In_File, Name => filename); load_deck(file, p1); load_deck(file, p2); TIO.close(file); end load_decks; function score(deck : in Deck_Vectors.Vector) return Natural is cnt : Natural := Natural(deck.length); sum : Natural := 0; begin for c of deck loop sum := sum + (c * cnt); cnt := cnt - 1; end loop; return sum; end score; function score(p1, p2 : in Deck_Vectors.Vector) return Natural is begin if p1.length = 0 then return score(p2); else return score(p1); end if; end score; procedure take_cards(winner, loser : in out Deck_Vectors.Vector) is begin winner.append(winner.first_element); winner.append(loser.first_element); winner.delete(winner.first_index); loser.delete(loser.first_index); end take_cards; procedure battle(player1, player2 : in out Deck_Vectors.Vector) is begin while player1.length > 0 and player2.length > 0 loop if player1.first_element > player2.first_element then take_cards(player1, player2); else take_cards(player2, player1); end if; end loop; end battle; function should_recurse(p1, p2 : in Deck_Vectors.Vector) return Boolean is begin return p1.first_element < Natural(p1.length) and p2.first_element < Natural(p2.length); end should_recurse; function reduced(d : in Deck_Vectors.Vector) return Deck_Vectors.Vector is new_d : Deck_Vectors.Vector := Empty_Vector; first : constant Natural := d.first_index + 1; last : constant Natural := d.first_index + d.first_element; begin for idx in first..last loop new_d.append(d(idx)); end loop; return new_d; end reduced; function recursive_battle(player1, player2 : in out Deck_Vectors.Vector) return Boolean is past_states : State_Sets.Set := Empty_Set; begin while player1.length > 0 and player2.length > 0 loop declare s : constant State := State'(player1 => player1, player2 => player2); p1_wins : Boolean; begin if past_states.contains(s) then return true; end if; past_states.insert(s); if should_recurse(player1, player2) then declare new_p1 : Deck_Vectors.Vector := reduced(player1); new_p2 : Deck_Vectors.Vector := reduced(player2); begin p1_wins := recursive_battle(new_p1, new_p2); end; else p1_wins := player1.first_element > player2.first_element; end if; if p1_wins then take_cards(player1, player2); else take_cards(player2, player1); end if; end; end loop; return player1.length > 0; end recursive_battle; function combat(filename : in String) return Natural is player1 : Deck_Vectors.Vector; player2 : Deck_Vectors.Vector; begin load_decks(filename, player1, player2); battle(player1, player2); return score(player1, player2); end combat; function recursive_combat(filename : in String) return Natural is player1 : Deck_Vectors.Vector; player2 : Deck_Vectors.Vector; begin load_decks(filename, player1, player2); if recursive_battle(player1, player2) then TIO.put_line("Player 1 wins"); else TIO.put_line("Player 2 wins"); end if; return score(player1, player2); end recursive_combat; end Day;
-- Lua -- an Ada 2012 interface to Lua -- Copyright (c) 2015-2021, James Humphry - see LICENSE for terms with Ada.Unchecked_Conversion, Ada.Unchecked_Deallocation; with System.Address_To_Access_Conversions; with Ada.Streams; with Interfaces; use Interfaces; with Interfaces.C; use type Interfaces.C.int, Interfaces.C.size_t, Interfaces.C.ptrdiff_t; with Interfaces.C.Strings; use type Interfaces.C.Strings.chars_ptr; with Interfaces.C.Pointers; with System; use type System.Address; with Lua.Internal, Lua.AuxInternal; package body Lua is -- -- *** Routines only used internally -- function Stream_Lua_Writer (L : void_ptr; p : void_ptr; sz : C.size_t; ud : void_ptr) return C.int with Convention => C; function String_Lua_Reader (L : void_ptr; data : void_ptr; size : access C.size_t) return C.Strings.chars_ptr with Convention => C; function Stream_Lua_Reader (L : void_ptr; data : void_ptr; size : access C.size_t) return C.Strings.chars_ptr with Convention => C; function CFunction_Trampoline (L : System.Address) return Interfaces.C.int with Convention => C; -- -- *** Types only used internally -- -- Used by String_Lua_Reader to read strings type String_Details is record S_Address : System.Address; S_Length : Natural; Readable : Boolean := False; end record; type Stream_Details(Buffer_Size : Ada.Streams.Stream_Element_Count) is record S : access Ada.Streams.Root_Stream_Type'Class; Buffer : aliased Ada.Streams.Stream_Element_Array(1..Buffer_Size) with Convention => C; end record; type Stream_Element_Access is not null access all Ada.Streams.Stream_Element; -- -- *** Conversions between Ada enumerations and C integer constants -- function Int_To_Thread_Status is new Ada.Unchecked_Conversion(Source => C.int, Target => Thread_Status); function Arith_Op_To_Int is new Ada.Unchecked_Conversion(Source => Arith_Op, Target => C.int); function Comparison_Op_To_Int is new Ada.Unchecked_Conversion(Source => Comparison_Op, Target => C.int); function GC_Op_To_Int is new Ada.Unchecked_Conversion(Source => GC_Op, Target => C.int); function GC_Param_To_Int is new Ada.Unchecked_Conversion(Source => GC_Param, Target => C.int); function Lua_Type_To_Int is new Ada.Unchecked_Conversion(Source => Lua_Type, Target => C.int); function Int_To_Lua_Type is new Ada.Unchecked_Conversion(Source => C.int, Target => Lua_Type); -- -- *** Conversions between C pointers and Ada types -- function AdaFunction_To_Address is new Ada.Unchecked_Conversion(Source => AdaFunction, Target => System.Address); function Address_To_AdaFunction is new Ada.Unchecked_Conversion(Source => System.Address, Target => AdaFunction); package Stream_Access_Conversions is new System.Address_To_Access_Conversions(Ada.Streams.Root_Stream_Type'Class); package String_Details_Access_Conversions is new System.Address_To_Access_Conversions(String_Details); package Char_Access_Conversions is new System.Address_To_Access_Conversions(C.char); function Char_Object_Pointer_To_Chars_Ptr is new Ada.Unchecked_Conversion(Source => Char_Access_Conversions.Object_Pointer, Target => C.Strings.chars_ptr); package Stream_Details_Access_Conversions is new System.Address_To_Access_Conversions(Stream_Details); function Stream_Element_Access_To_Chars_Ptr is new Ada.Unchecked_Conversion(Source => Stream_Element_Access, Target => C.Strings.chars_ptr); -- -- *** Conversions between a C void * and a Stream_Element_Array -- package Void_Ptr_To_Stream_Array is new Interfaces.C.Pointers(Index => Ada.Streams.Stream_Element_Offset, Element => Ada.Streams.Stream_Element, Element_Array => Ada.Streams.Stream_Element_Array, Default_Terminator => 0); package Stream_Element_Access_Conversions is new System.Address_To_Access_Conversions(Ada.Streams.Stream_Element); -- -- *** Special stack positions and the registry -- function UpvalueIndex (i : in Integer) return Integer is (RegistryIndex - i - 1); -- Lua cannot call Ada functions directly, so a trampoline is used. -- The first UpvalueIndex is reserved for the address of the Ada function -- to be called by CFunction_Trampoline -- -- *** Basic state control -- -- The Stream_Lua_Writer is an internal Lua_Writer where the userdata pointer -- is a Stream_Access type from Ada.Streams.Stream_IO. It should therefore -- support writing to and from any type of stream. function Stream_Lua_Writer (L : void_ptr; p : void_ptr; sz : C.size_t; ud : void_ptr) return C.int is pragma Unreferenced (L); package SAC renames Stream_Access_Conversions; package SEAC renames Stream_Element_Access_Conversions; package VPTSA renames Void_Ptr_To_Stream_Array; use Ada.Streams; use Ada.Streams.Stream_IO; Output_Stream_Access : constant Stream_Access := Stream_Access(SAC.To_Pointer(ud)); -- First we need to convert the address of the data to dump to an access -- value using System.Address_To_Access_Conversions, then we need to -- convert this to the equivalent access value in Interfaces.C.Pointers. -- Once we know the length of the array, we can then convert it back to a -- true Ada array. Output_Data_Access : constant VPTSA.Pointer := VPTSA.Pointer(SEAC.To_Pointer(p)); -- This calculation is intended to deal with (most) cases in which -- Stream_Element is not a single byte. Why anyone would do that I -- don't know, but it seems possible according to the RM. Cases in which -- Stream_Element is a fractional number of bytes will not work, but -- I can't see how an Ada system using such a convention could ever -- be expected to interoperate with C code. Output_Data_Length : constant C.ptrdiff_t := (C.ptrdiff_t(sz) * 8) / Stream_Element'Size; Output_Data : constant Stream_Element_Array := VPTSA.Value(Ref => Output_Data_Access, Length => Output_Data_Length); begin Output_Stream_Access.Write(Item => Output_Data); return 0; exception when Status_Error | Mode_Error | Device_Error => return 1; -- Other exceptions are deliberately not handled as they are more -- likely to indicate serious internal problems, for example being -- sent a null pointer as the data to write. end Stream_Lua_Writer; procedure DumpFile(L : in Lua_State; Name : in String; Strip : in Boolean := False) is use Ada.Streams.Stream_IO; Output_File : File_Type; begin Create(File => Output_File, Mode => Out_File, Name => Name); DumpStream(L => L, Output_Stream => Stream(Output_File), Strip => Strip); Close(Output_File); end DumpFile; procedure DumpStream(L : in Lua_State; Output_Stream : in Ada.Streams.Stream_IO.Stream_Access; Strip : in Boolean := False) is package SAC renames Stream_Access_Conversions; Result : C.int; Stream_Pointer : constant SAC.Object_Pointer := SAC.Object_Pointer(Output_Stream); begin Result := Internal.lua_dump(L.L, Stream_Lua_Writer'Access, SAC.To_Address(Stream_Pointer), (if Strip then 1 else 0)); if Result /= 0 then raise Lua_Error with "Could not dump Lua chunk to stream"; end if; end DumpStream; function String_Lua_Reader (L : void_ptr; data : void_ptr; size : access C.size_t) return C.Strings.chars_ptr is pragma Unreferenced (L); SDA : constant access String_Details := String_Details_Access_Conversions.To_Pointer(data); S_Object_Ptr : constant Char_Access_Conversions.Object_Pointer := Char_Access_Conversions.To_Pointer(SDA.S_Address); S_chars_ptr : constant C.Strings.chars_ptr := Char_Object_Pointer_To_Chars_Ptr(S_Object_Ptr); begin if SDA.Readable then SDA.Readable := False; size.all := C.size_t(SDA.S_Length * String'Component_Size / 8); return S_chars_ptr; else size.all := 0; return C.Strings.Null_Ptr; end if; end String_Lua_Reader; function LoadString (L : in Lua_State; S : aliased String; ChunkName : in String := ""; Mode : Lua_ChunkMode := Binary_and_Text) return Thread_Status is Result : C.int; C_ChunkName : C.Strings.chars_ptr := C.Strings.New_String(ChunkName); C_Mode : C.Strings.chars_ptr := C.Strings.New_String(case Mode is when Binary => "b", when Text => "t", when Binary_and_Text => "bt" ); To_Load : aliased String_Details := (S_Address => S'Address, S_Length => S'Length, Readable => True); begin if C.char_array'Component_Size /= String'Component_Size then raise Program_Error with "Ada and C strings are not sufficiently compatible for direct " & "loading - only LoadString_By_Copy can be used on this system."; end if; Result := Internal.lua_load(L.L, String_Lua_Reader'Access, To_Load'Address, C_ChunkName, C_Mode); C.Strings.Free(C_ChunkName); C.Strings.Free(C_Mode); return Int_To_Thread_Status(Result); end LoadString; function LoadString_By_Copy (L : in Lua_State; S : in String) return Thread_Status is CS : C.Strings.chars_ptr; Result : C.int; begin CS := C.Strings.New_String(S); Result := AuxInternal.luaL_loadstring(L.L, CS); C.Strings.Free(CS); return Int_To_Thread_Status(Result); end; function Stream_Lua_Reader (L : void_ptr; data : void_ptr; size : access C.size_t) return C.Strings.chars_ptr is pragma Unreferenced (L); use Ada.Streams; Stream_Detail : access Stream_Details := Stream_Details_Access_Conversions.To_Pointer(data); Buffer_Ptr :constant C.Strings.chars_ptr := Stream_Element_Access_To_Chars_Ptr(Stream_Detail.Buffer(1)'Access); Last_Read : Stream_Element_Offset; begin Read(Stream => Stream_Detail.S.all, Item => Stream_Detail.Buffer, Last => Last_Read); if Last_Read /= 0 then size.all := C.size_t(Last_Read * Stream_Element'Size / 8); return Buffer_Ptr; else size.all := 0; return C.Strings.Null_Ptr; end if; end Stream_Lua_Reader; function LoadFile (L : in Lua_State; Name : in String; ChunkName : in String := ""; Mode : in Lua_ChunkMode := Binary_and_Text; Buffer_Size : in Positive := 256) return Thread_Status is use Ada.Streams.Stream_IO; Input_File : File_Type; Result : Thread_Status; begin Open(File => Input_File, Mode => In_File, Name => Name); Result := LoadStream(L => L, Input_Stream => Stream(Input_File), ChunkName => ChunkName, Mode => Mode, Buffer_Size => Buffer_Size); Close(Input_File); return Result; end LoadFile; function LoadStream (L : in Lua_State; Input_Stream : in Ada.Streams.Stream_IO.Stream_Access; ChunkName : in String := ""; Mode : in Lua_ChunkMode := Binary_and_Text; Buffer_Size : in Positive := 256) return Thread_Status is use Ada.Streams; C_ChunkName : C.Strings.chars_ptr := C.Strings.New_String(ChunkName); C_Mode : C.Strings.chars_ptr := C.Strings.New_String(case Mode is when Binary => "b", when Text => "t", when Binary_and_Text => "bt" ); Stream_Detail : aliased Stream_Details(Stream_Element_Count(Buffer_Size)); Result : C.int; begin Stream_Detail.S := Input_Stream; Result := Internal.lua_load(L.L, Stream_Lua_Reader'Access, Stream_Detail'Address, C_ChunkName, C_Mode); C.Strings.Free(C_ChunkName); C.Strings.Free(C_Mode); return Int_To_Thread_Status(Result); end LoadStream; function Status (L : Lua_State) return Thread_Status is (Int_To_Thread_Status(Internal.lua_status(L.L))); function Version (L : Lua_State) return Long_Float is (Long_Float(Internal.lua_version(L.L).all)); -- -- *** Calling, yielding and functions -- procedure Call (L : in Lua_State; nargs : in Integer; nresults : in Integer) is begin Internal.lua_callk(L.L, C.int(nargs), C.int(nresults), 0, null); end Call; procedure Call_Function (L : in Lua_State; name : in String; nargs : in Integer; nresults : in Integer) is begin GetGlobal(L, name); if not IsFunction(L, -1) then raise Lua_Error with "Attempting to call a value that is not a Lua function"; end if; Rotate(L, -1-nargs, 1); Internal.lua_callk(L.L, C.int(nargs), C.int(nresults), 0, null); end Call_Function; function PCall (L : in Lua_State; nargs : in Integer; nresults : in Integer; msgh : in Integer := 0) return Thread_Status is ( Int_To_Thread_Status( Internal.lua_pcallk(L.L, C.int(nargs), C.int(nresults), C.int(msgh), 0, null ) ) ); function PCall_Function (L : in Lua_State; name : in String; nargs : in Integer; nresults : in Integer; msgh : in Integer := 0) return Thread_Status is Result : C.int; begin GetGlobal(L, name); if not IsFunction(L, -1) then raise Lua_Error with "Attempting to call a value that is not a Lua function"; end if; Rotate(L, -1-nargs, 1); Result := Internal.lua_pcallk(L.L, C.int(nargs), C.int(nresults), C.int(msgh), 0, null ); return Int_To_Thread_Status(Result); end PCall_Function; procedure Register(L : in Lua_State; name : in String; f : in AdaFunction) is C_name : C.Strings.chars_ptr := C.Strings.New_String(name); begin PushAdaClosure(L, f, 0); Internal.lua_setglobal(L.L, C_name); C.Strings.Free(C_name); end Register; -- -- *** Pushing values to the stack -- procedure PushAdaClosure (L : in Lua_State; f : in AdaFunction; n : in Natural) is begin Internal.lua_pushlightuserdata(L.L, AdaFunction_To_Address(f)); L.Rotate(L.GetTop - n, 1); Internal.lua_pushcclosure(L.L, CFunction_Trampoline'Access, C.int(1 + n)); end PushAdaClosure; procedure PushAdaFunction (L : in Lua_State; f : in AdaFunction) is begin PushAdaClosure(L, f, 0); end PushAdaFunction; procedure PushBoolean (L : in Lua_State; b : in Boolean) is begin Internal.lua_pushboolean(L.L, C.int( (if b then 1 else 0) ) ); end PushBoolean; procedure PushInteger (L : in Lua_State; n : in Lua_Integer) is begin Internal.lua_pushinteger(L.L, Internal.lua_Integer(n)); end PushInteger; procedure PushNil (L : in Lua_State) is begin Internal.lua_pushnil(L.L); end PushNil; procedure PushNumber (L : in Lua_State; n : in Lua_Number) is begin Internal.lua_pushnumber(L.L, Internal.lua_Number(n)); end PushNumber; procedure PushString (L : in Lua_State; s : in String) is C_s : C.Strings.chars_ptr; Discard : C.Strings.chars_ptr; begin C_s := C.Strings.New_String(s); Discard := Internal.lua_pushstring(L.L, C_s); C.Strings.Free(C_s); end PushString; function PushThread (L : in Lua_State) return Boolean is (Internal.lua_pushthread(L.L) = 1); procedure PushThread (L : in Lua_State) is Discard : C.int; begin -- Not interested if this thread is the main thread of its state, so the -- boolean result is discarded. Discard := Internal.lua_pushthread(L.L); end PushThread; procedure SetUserValue (L : in Lua_State; index : in Integer) is begin Internal.lua_setuservalue(L.L, C.int(index)); end SetUserValue; function StringToNumber (L : in Lua_State; s : in String) return Boolean is C_String : C.Strings.chars_ptr := C.Strings.New_String(s); Result : C.size_t; begin Result := Internal.lua_stringtonumber(L.L, C_String); C.Strings.Free(C_String); return Result /= 0; end StringToNumber; -- -- *** Pulling values from the stack -- function ToAdaFunction (L : in Lua_State; index : in Integer) return AdaFunction is Upvalue : System.Address; Upvalue_Name : C.Strings.chars_ptr; begin Upvalue_Name := Internal.lua_getupvalue(L.L, C.int(index), 1); if Upvalue_Name = C.Strings.Null_Ptr then raise Lua_Error with "Function referenced is not an AdaFunction"; end if; Upvalue := Internal.lua_touserdata(L.L, -1); Internal.lua_settop(L.L, -2); return Address_To_AdaFunction(Upvalue); end ToAdaFunction; function ToBoolean (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_toboolean(L.L, C.int(index)) /= 0); function ToInteger (L : in Lua_State; index : in Integer) return Lua_Integer is isnum : aliased C.int := 0; result : Internal.lua_Integer; begin result := Internal.lua_tointegerx(L.L , C.int(index), isnum'Access); if isnum = 0 then raise Lua_Error with "Value at Lua stack index " & Integer'Image(index) & " is not convertible to an integer."; end if; return Lua_Integer(result); end ToInteger; function ToNumber (L : in Lua_State; index : in Integer) return Lua_Number is isnum : aliased C.int := 0; result : Internal.lua_Number; begin result := Internal.lua_tonumberx(L.L , C.int(index), isnum'Access); if isnum = 0 then raise Lua_Error with "Value at Lua stack index " & Integer'Image(index) & " is not convertible to a number."; end if; return Lua_Number(result); end ToNumber; function ToString (L : in Lua_State; index : in Integer) return String is result : C.Strings.chars_ptr; len : aliased C.size_t := 0; begin result := Internal.lua_tolstring(L.L, C.int(index), len'Access); if len = 0 then raise Lua_Error with "Value at Lua stack index " & Integer'Image(index) & " is not convertible to a string."; else declare converted_result : String(1..Integer(len+1)); begin C.To_Ada(Item => C.Strings.Value(result), Target => converted_result, Count => Natural(len), Trim_Nul => False); return converted_result; end; end if; end ToString; function ToThread (L : in Lua_State; index : in Integer) return Lua_Thread is begin return R : Lua_Thread do R.L := Internal.lua_tothread(L.L, C.int(index)); if R.L = System.Null_Address then raise Lua_Error with "Value at Lua stack index " & Integer'Image(index) & " is not a thread value."; end if; end return; end ToThread; -- -- *** Operations on values -- procedure Arith (L : in Lua_State; op : in Arith_Op) is begin Internal.lua_arith(L.L, Arith_Op_To_Int(op)); end Arith; function Compare (L : in Lua_State; index1 : in Integer; index2 : in Integer; op : in Comparison_Op) return Boolean is (Internal.lua_compare(L.L, C.int(index1), C.int(index2), Comparison_Op_To_Int(op)) = 1); procedure Concat (L : in Lua_State; n : in Integer) is begin Internal.lua_concat(L.L, C.int(n)); end Concat; procedure Len (L : in Lua_State; index : Integer) is begin Internal.lua_len(L.L, C.int(index)); end Len; function RawEqual(L : in Lua_State; index1, index2 : in Integer) return Boolean is (Internal.lua_rawequal(L.L, C.int(index1), C.int(index2)) /= 0); function RawLen (L : in Lua_State; index : Integer) return Integer is (Integer(Internal.lua_rawlen(L.L, C.int(index)))); -- -- *** Garbage Collector control --- procedure GC (L : in Lua_State; what : in GC_Op) is Discard : C.int; begin -- For the operations within subtype GC_Op, this will not return anything -- interesting Discard := Internal.lua_gc(L.L, GC_Op_To_Int(what), 0); end GC; function GC (L : in Lua_State; what : in GC_Param; data : in Integer) return Integer is (Integer(Internal.lua_gc(L.L, GC_Param_To_Int(what), C.int(data)))); function GC_IsRunning (L : in Lua_State) return Boolean is (Internal.lua_gc(L.L, GCISRUNNING, 0) /= 0); -- -- *** Stack manipulation and information -- function AbsIndex (L : in Lua_State; idx : in Integer) return Integer is (Integer(Internal.lua_absindex(L.L, C.int(idx)))); function CheckStack (L : in Lua_State; n : in Integer) return Boolean is (Internal.lua_checkstack(L.L, C.int(n)) /= 0); procedure Copy (L : in Lua_State; fromidx : in Integer; toidx : in Integer) is begin Internal.lua_copy(L.L, C.int(fromidx), C.int(toidx)); end Copy; function GetTop (L : in Lua_State) return Integer is (Integer(Internal.lua_gettop(L.L))); procedure Insert (L : in Lua_State; index : in Integer) is begin Internal.lua_rotate(L.L, C.int(index), 1); end Insert; procedure Pop (L : in Lua_State; n : in Integer) is begin Internal.lua_settop(L.L, -C.int(n)-1); end Pop; procedure PushValue (L : in Lua_State; index : in Integer) is begin Internal.lua_pushvalue(L.L, C.int(index)); end PushValue; procedure Remove (L : in Lua_State; index : in Integer) is begin Internal.lua_rotate(L.L, C.int(index), -1); Internal.lua_settop(L.L, -2); end Remove; procedure Replace (L : in Lua_State; index : in Integer) is begin Internal.lua_copy(L.L, -1, C.int(index)); Internal.lua_settop(L.L, -2); end Replace; procedure Rotate (L : in Lua_State; idx : in Integer; n : in Integer) is begin Internal.lua_rotate(L.L, C.int(idx), C.int(n)); end Rotate; procedure SetTop (L : in Lua_State; index : in Integer) is begin Internal.lua_settop(L.L, C.int(index)); end SetTop; -- -- *** Type information -- function IsAdaFunction (L : in Lua_State; index : in Integer) return Boolean is use Lua.Internal; begin return lua_tocfunction(L.L, C.int(index)) = CFunction_Trampoline'Access; -- As CFunction_Trampoline is not visible outside this body, and this -- package will always create closure correctly, it is not necessary -- to check that the required upvalue exists. end IsAdaFunction; function IsBoolean (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TBOOLEAN); function IsCFunction (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_iscfunction(L.L, C.int(index)) /= 0); function IsFunction (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TFUNCTION); function IsInteger (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_isinteger(L.L, C.int(index)) /= 0); function IsLightuserdata (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TLIGHTUSERDATA); function IsNil (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TNIL); function IsNone (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TNONE); function IsNoneOrNil (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TNONE or TypeInfo(L, index) = TNIL); function IsNumber (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_isnumber(L.L, C.int(index)) /= 0); function IsString (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_isstring(L.L, C.int(index)) /= 0); function IsTable (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TTABLE); function IsThread (L : in Lua_State; index : in Integer) return Boolean is (TypeInfo(L, index) = TTHREAD); function IsUserdata (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_isuserdata(L.L, C.int(index)) /= 0); function TypeInfo (L : in Lua_State; index : in Integer) return Lua_Type is ( Int_To_Lua_Type(Internal.lua_type(L.L, C.int(index))) ); function TypeName (L : in Lua_State; tp : in Lua_Type) return String is ( C.Strings.Value(Internal.lua_typename(L.L, C.int(Lua_Type_To_Int(tp)))) ); function TypeName (L : in Lua_State; index : in Integer) return String is (TypeName(L, TypeInfo(L, index))); function Userdata_Name (L : in Lua_State; index : in Integer) return String is Has_Metatable : Boolean; Name_Field_Type : Lua_Type; begin Has_Metatable := GetMetatable(L, index); if not Has_Metatable then return ""; end if; Name_Field_Type := L.GetField(-1, "__name"); if Name_Field_Type = TNIL then L.Pop(1); -- just the metatable return ""; elsif Name_Field_Type /= TSTRING then L.Pop(2); -- the metatable and the non-standard __name field return ""; end if; declare Name : constant String := L.ToString(-1); begin if Name'Length > 4 and then Name(Name'First..Name'First+3) = "Ada:" then L.Pop(2); -- the metatable and the __name field return (Name(Name'First+4..Name'Last)); else L.Pop(2); -- the metatable and the non-Ada __name field return ""; end if; end; end Userdata_Name; -- -- *** Table Manipulation -- procedure CreateTable (L : in Lua_State; narr : in Integer := 0; nrec : in Integer := 0) is begin Internal.lua_createtable(L.L, C.int(narr), C.int(nrec)); end CreateTable; procedure NewTable (L : in Lua_State) is begin Internal.lua_createtable(L.L, 0, 0); end NewTable; function GetField (L : in Lua_State; index : in Integer; k : in String) return Lua_Type is Result : C.int; C_k : C.Strings.chars_ptr := C.Strings.New_String(k); begin Result := Internal.lua_getfield(L.L, C.int(index), C_k); C.Strings.Free(C_k); return Int_To_Lua_Type(Result); end GetField; procedure GetField (L : in Lua_State; index : in Integer; k : in String) is Result_Type : C.int; C_k : C.Strings.chars_ptr := C.Strings.New_String(k); begin Result_Type := Internal.lua_getfield(L.L, C.int(index), C_k); C.Strings.Free(C_k); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "No value for key: '" & k & "'."; end if; end GetField; function Geti (L : in Lua_State; index : in Integer; i : in Lua_Integer) return Lua_Type is ( Int_To_Lua_Type(Internal.lua_geti(L.L, C.int(index), Long_Long_Integer(i))) ); procedure Geti (L : in Lua_State; index : in Integer; i : in Lua_Integer) is Result_Type : C.int; begin Result_Type := Internal.lua_geti(L.L, C.int(index), Long_Long_Integer(i)); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "No value for key: '" & Lua_Integer'Image(i) & "'."; end if; end Geti; function GetTable (L : in Lua_State; index : in Integer) return Lua_Type is ( Int_To_Lua_Type(Internal.lua_gettable(L.L, C.int(index))) ); procedure GetTable (L : in Lua_State; index : in Integer) is Result_Type : C.int; begin Result_Type := Internal.lua_gettable(L.L, C.int(index)); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "No value for key and target specified."; end if; end GetTable; function Next (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_next(L.L, C.int(index)) /= 0); function RawGet (L : in Lua_State; index : in Integer) return Lua_Type is ( Int_To_Lua_Type(Internal.lua_rawget(L.L, C.int(index))) ); procedure RawGet (L : in Lua_State; index : in Integer) is Result_Type : C.int; begin Result_Type := Internal.lua_rawget(L.L, C.int(index)); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "No value for key and target specified."; end if; end RawGet; function RawGeti (L : in Lua_State; index : in Integer; i : in Lua_Integer) return Lua_Type is ( Int_To_Lua_Type(Internal.lua_rawgeti(L.L, C.int(index), Long_Long_Integer(i)) ) ); procedure RawGeti (L : in Lua_State; index : in Integer; i : in Lua_Integer) is Result_Type : C.int; begin Result_Type := Internal.lua_rawgeti(L.L, C.int(index), Long_Long_Integer(i)); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "No value for key: '" & Lua_Integer'Image(i) & "'."; end if; end RawGeti; procedure RawSet (L : in Lua_State; index : in Integer) is begin Internal.lua_rawset(L.L, C.int(index)); end RawSet; procedure RawSeti (L : in Lua_State; index : in Integer; i : in Lua_Integer) is begin Internal.lua_rawseti(L.L, C.int(index), Long_Long_Integer(i)); end RawSeti; procedure SetField (L : in Lua_State; index : in Integer; k : in String) is C_k : C.Strings.chars_ptr := C.Strings.New_String(k); begin Internal.lua_setfield(L.L, C.int(index), C_k); C.Strings.Free(C_k); end SetField; procedure Seti (L : in Lua_State; index : in Integer; i : in Lua_Integer) is begin Internal.lua_seti(L.L, C.int(index), Long_Long_Integer(i)); end Seti; procedure SetTable (L : in Lua_State; index : in Integer) is begin Internal.lua_settable(L.L, C.int(index)); end SetTable; -- -- *** Globals and Metatables -- function GetGlobal (L : in Lua_State; name : in String) return Lua_Type is C_name : C.Strings.chars_ptr := C.Strings.New_String(name); Result : C.int; begin Result := Internal.lua_getglobal(L.L, C_name); C.Strings.Free(C_name); return Int_To_Lua_Type(Result); end GetGlobal; procedure GetGlobal (L : in Lua_State; name : in String) is C_name : C.Strings.chars_ptr := C.Strings.New_String(name); Result_Type : C.int; begin Result_Type := Internal.lua_getglobal(L.L, C_name); C.Strings.Free(C_name); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "No global by the name of :'" & name & "' found."; end if; end GetGlobal; function GetMetatable (L : in Lua_State; index : in Integer) return Boolean is (Internal.lua_getmetatable(L.L, C.int(index)) /= 0); procedure GetMetatable (L : in Lua_State; index : in Integer) is begin if Internal.lua_getmetatable(L.L, C.int(index)) = 0 then raise Lua_Error with "No metatable exists for stack index: " & Integer'Image(index); end if; end GetMetatable; procedure PushGlobalTable (L : in Lua_State) is Discard : C.int; begin -- The global table should always exist so no test is performed. Discard := Internal.lua_rawgeti(L.L, C.int(RegistryIndex), Long_Long_Integer(RIDX_Globals)); end PushGlobalTable; procedure SetGlobal (L : in Lua_State; name : in String) is C_name : C.Strings.chars_ptr := C.Strings.New_String(name); begin Internal.lua_setglobal(L.L, C_name); C.Strings.Free(C_name); end SetGlobal; procedure SetMetatable (L : in Lua_State; index : in Integer) is Discard : C.int; begin -- According to the Lua documentation, lua_setmetatable does not have a -- return value, but according to lua.h it does... Discard := Internal.lua_setmetatable(L.L, C.int(index)); end SetMetatable; -- -- *** Threads -- function IsYieldable (L : in Lua_State'Class) return Boolean is begin return Internal.lua_isyieldable(L.L) /= 0; end IsYieldable; function NewThread (L : in Lua_State'Class) return Lua_Thread is begin return T : Lua_Thread do T.L := Internal.lua_newthread(L.L); end return; end NewThread; function Resume(L : in Lua_State'Class; nargs : in Integer; from : in Lua_State'Class := Null_Thread ) return Thread_Status is (Int_To_Thread_Status(Internal.lua_resume(L.L, from.L, C.int(nargs)))); procedure XMove (from, to : in Lua_Thread; n : in Integer) is begin Internal.lua_xmove(from.L, to.L, C.int(n)); end XMove; procedure Yield (L : in Lua_State; nresults : Integer) is Discard : C.int; begin -- Return value does not appear to be useful. Discard := Internal.lua_yieldk(L.L, C.int(nresults), 0, null); end Yield; -- -- *** Resource Management *** -- procedure Initialize (Object : in out Lua_State) is begin Object.L := AuxInternal.luaL_newstate; end Initialize; procedure Finalize (Object : in out Lua_State) is begin Internal.lua_close(Object.L); end Finalize; -- -- *** Trampolines -- function CFunction_Trampoline (L : System.Address) return C.int is S : Existing_State; f_index : constant C.int := C.int(RegistryIndex-1); f_address : constant System.Address := Internal.lua_touserdata(L, f_index); f : constant AdaFunction := Address_To_AdaFunction(f_address); begin S.L := L; return C.int(f(S)); end CFunction_Trampoline; -- -- *** References -- procedure Free is new Ada.Unchecked_Deallocation ( Object => Lua_Reference_Value, Name => Lua_Reference_Value_Access); function Ref (L : in Lua_State'Class; t : in Integer := RegistryIndex) return Lua_Reference is begin return R : Lua_Reference do R.E := new Lua_Reference_Value; R.E.State := L.L; R.E.Table := C.int(t); R.E.Ref := AuxInternal.luaL_ref(L.L, C.int(t)); R.E.Count := 1; end return; end Ref; function Get (L : in Lua_State; R : Lua_Reference'Class) return Lua_Type is begin if R.E = null then raise Lua_Error with "Empty Lua reference used"; elsif R.E.State /= L.L then raise Lua_Error with "Lua reference used on the wrong state!"; end if; return Int_To_Lua_Type(Internal.lua_rawgeti(R.E.all.State, R.E.all.Table, Long_Long_Integer(R.E.all.Ref))); end Get; procedure Get (L : in Lua_State; R : Lua_Reference'Class) is Result_Type : C.int; begin if R.E = null then raise Lua_Error with "Empty Lua reference used"; elsif R.E.State /= L.L then raise Lua_Error with "Lua reference used on the wrong state!"; end if; Result_Type := Internal.lua_rawgeti(R.E.all.State, R.E.all.Table, Long_Long_Integer(R.E.all.Ref)); if Int_To_Lua_Type(Result_Type) = TNIL then raise Lua_Error with "Lua reference somehow pointing to nil value."; end if; end Get; overriding procedure Adjust (Object : in out Lua_Reference) is begin if Object.E /= null then Object.E.Count := Object.E.Count + 1; end if; end Adjust; overriding procedure Finalize (Object : in out Lua_Reference) is begin if Object.E /= null then Object.E.Count := Object.E.Count - 1; if Object.E.Count = 0 then -- Note this relies on the Lua state not having been destroyed -- before the references stop being used. AuxInternal.luaL_unref(Object.E.State, Object.E.Table, Object.E.Ref); Free(Object.E); end if; end if; end Finalize; end Lua;
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 aaa_01hello is type stringptr is access all char_array; procedure PString(s : stringptr) is begin String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all)); end; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; a : Integer; begin PString(new char_array'( To_C("Hello World"))); a := 5; PInt((4 + 6) * 2); PString(new char_array'( To_C(" " & Character'Val(10)))); PInt(a); PString(new char_array'( To_C("foo"))); if 1 + 2 * 2 * (3 + 8) / 4 - 2 = 12 and then TRUE then PString(new char_array'( To_C("True"))); else PString(new char_array'( To_C("False"))); end if; PString(new char_array'( To_C("" & Character'Val(10)))); if (3 * (4 + 11) * 2 = 45) = FALSE then PString(new char_array'( To_C("True"))); else PString(new char_array'( To_C("False"))); end if; PString(new char_array'( To_C(" "))); if (2 = 1) = FALSE then PString(new char_array'( To_C("True"))); else PString(new char_array'( To_C("False"))); end if; PString(new char_array'( To_C(" "))); PInt(5 / 3 / 3); PInt(4 * 1 / 3 / 2 * 1); if not (not (a = 0) and then not (a = 4)) then PString(new char_array'( To_C("True"))); else PString(new char_array'( To_C("False"))); end if; if (TRUE and then not FALSE) and then not (TRUE and then FALSE) then PString(new char_array'( To_C("True"))); else PString(new char_array'( To_C("False"))); end if; PString(new char_array'( To_C("" & Character'Val(10)))); end;
with Ada.Characters.Handling; with Ada.Command_Line; with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Directories; with Ada.Environment_Variables; with Ada.Exceptions; with Ada.Strings.Equal_Case_Insensitive; with Ada.Strings.Fixed; with Ada.Strings.Less_Case_Insensitive; with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Unchecked_Deallocation; procedure run_acats is use type Ada.Containers.Count_Type; use type Ada.Strings.Unbounded.Unbounded_String; function "+" (Right : Ada.Strings.Unbounded.Unbounded_String) return String renames Ada.Strings.Unbounded.To_String; Command_Not_Found : exception; Command_Failure : exception; Configuration_Error : exception; Unknown_Test : exception; Compile_Failure : exception; Test_Failure : exception; Should_Be_Failure : exception; -- child process procedure Shell_Execute (Command : in String; Result : out Integer) is function system (S : String) return Integer; pragma Import (C, system); Code : Integer; type UI is mod 2 ** Integer'Size; begin Ada.Text_IO.Put_Line (Command); Code := system (Command & ASCII.NUL); if Code mod 256 /= 0 then if (UI (Code) and 4) = 0 then -- WEXITED raise Command_Not_Found with Command & Integer'Image (Code); else raise Command_Failure with Command & Integer'Image (Code); end if; end if; Result := Code / 256; end Shell_Execute; procedure Shell_Execute (Command : in String) is Result : Integer; begin Shell_Execute (Command, Result); if Result /= 0 then raise Command_Failure with Command; end if; end Shell_Execute; procedure Symbolic_Link (Source, Destination : in String) is begin Shell_Execute ("ln -s " & Source & " " & Destination); end Symbolic_Link; procedure Sorted_Search ( Directory : in String; Pattern : in String; Filter : in Ada.Directories.Filter_Type; Process : not null access procedure ( Directory_Entry : Ada.Directories.Directory_Entry_Type)) is type Directory_Entry_Access is access Ada.Directories.Directory_Entry_Type; package Entry_Maps is new Ada.Containers.Indefinite_Ordered_Maps ( String, Directory_Entry_Access); Entries : Entry_Maps.Map; begin declare -- make entries Search : Ada.Directories.Search_Type; begin Ada.Directories.Start_Search ( Search, Directory => Directory, Pattern => Pattern, Filter => Filter); while Ada.Directories.More_Entries (Search) loop declare New_Entry : constant not null Directory_Entry_Access := new Ada.Directories.Directory_Entry_Type; begin Ada.Directories.Get_Next_Entry (Search, New_Entry.all); Entry_Maps.Insert ( Entries, Ada.Directories.Simple_Name (New_Entry.all), New_Entry); end; end loop; Ada.Directories.End_Search (Search); end; declare -- iterate sorted entries procedure Do_Process (Position : in Entry_Maps.Cursor) is begin Process (Entry_Maps.Element (Position).all); end Do_Process; begin Entry_Maps.Iterate (Entries, Process => Do_Process'Access); end; declare -- cleanup procedure Cleanup (Position : in Entry_Maps.Cursor) is procedure Update ( Unused_Key : in String; Element : in out Directory_Entry_Access) is procedure Free is new Ada.Unchecked_Deallocation ( Ada.Directories.Directory_Entry_Type, Directory_Entry_Access); begin Free (Element); end Update; begin Entry_Maps.Update_Element (Entries, Position, Process => Update'Access); end Cleanup; begin Entry_Maps.Iterate (Entries, Process => Cleanup'Access); end; end Sorted_Search; -- getting environment GCC_Prefix : constant String := Ada.Environment_Variables.Value ("GCCPREFIX", Default => ""); GCC_Suffix : constant String := Ada.Environment_Variables.Value ("GCCSUFFIX", Default => ""); Start_Dir : constant String := Ada.Directories.Current_Directory; ACATS_Dir : constant String := Ada.Environment_Variables.Value ("ACATSDIR"); Support_Dir : constant String := Ada.Environment_Variables.Value ("SUPPORTDIR"); Test_Dir : constant String := Ada.Environment_Variables.Value ("TESTDIR"); RTS_Dir : constant String := Ada.Environment_Variables.Value ("RTSDIR", Default => ""); -- test result type Test_Result is ( Passed, -- 0 Any_Exception, -- 1 Not_Applicative, -- 2 Tentatively, -- 3, Failed, -- 4 Compile_Error, Untested); function Image (Item : Test_Result) return Character is Table : constant array (Test_Result) of Character := "PANTFCU"; begin return Table (Item); end Image; function Value (Item : Character) return Test_Result is begin case Item is when 'P' => return Passed; when 'A' => return Any_Exception; when 'N' => return Not_Applicative; when 'T' => return Tentatively; when 'F' => return Failed; when 'C' => return Compile_Error; when 'U' => return Untested; when others => raise Constraint_Error; end case; end Value; -- test info function Is_Only_Pragmas (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "cxh30030.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70010.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70030.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70040.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70050.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70060.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70070.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70080.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70090.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40010.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40021.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40030.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40041.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40051.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40060.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40071.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40082.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40090.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40101.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40111.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40121.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40130.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40140.a") or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40142.a"); end Is_Only_Pragmas; function Clear_Screen_Before_Run (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "ee3412c"); end Clear_Screen_Before_Run; -- test info (error class) function Is_Error_Class (Name : String) return Boolean is begin -- bxxxxxxx, lxxxxxxx (excluding la1xxxxx) return Name (Name'First) = 'B' or else Name (Name'First) = 'b' or else ( (Name (Name'First) = 'L' or else Name (Name'First) = 'l') and then not ( (Name (Name'First + 1) = 'A' or else Name (Name'First + 1) = 'a') and then (Name (Name'First + 2) = '1'))); end Is_Error_Class; function Is_No_Error (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "ba1020c") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba15001"); end Is_No_Error; function Is_Missing_Subunits (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "ba2001f") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001e") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007a") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007b") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007c") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007d") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007e") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007f") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007g") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008d") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008e") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008f") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008g"); end Is_Missing_Subunits; function Is_Not_Found (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "ba11003") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba11013") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1101a") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1101b") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1101c") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1109a") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba12007") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba12008") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba16001") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba16002") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001a") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001b") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001c") or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001f") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007a") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007b") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007c") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008a") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008b") or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008c"); end Is_Not_Found; -- expected test results function Expected_Result (Name : String) return Test_Result is begin if Is_Error_Class (Name) and then not Is_No_Error (Name) then return Compile_Error; elsif Ada.Strings.Equal_Case_Insensitive (Name, "cz1101a") or else Ada.Strings.Equal_Case_Insensitive (Name, "cz1103a") or else Ada.Strings.Equal_Case_Insensitive (Name, "e28002b") or else Ada.Strings.Equal_Case_Insensitive (Name, "e28005d") or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3203a") or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3204a") or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3402b") or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3409f") or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3412c") then return Tentatively; elsif Ada.Strings.Equal_Case_Insensitive (Name, "eb4011a") or else Ada.Strings.Equal_Case_Insensitive (Name, "eb4012a") or else Ada.Strings.Equal_Case_Insensitive (Name, "eb4014a") then return Any_Exception; -- Tentatively else return Passed; end if; end Expected_Result; -- test operations procedure Setup_Test_Dir is begin if Ada.Directories.Exists (Test_Dir) then declare procedure Process (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry); begin if Simple_Name (Simple_Name'First) /= '.' then declare Full_Name : constant String := Ada.Directories.Full_Name (Dir_Entry); begin case Ada.Directories.Kind (Dir_Entry) is when Ada.Directories.Ordinary_File | Ada.Directories.Special_File => Ada.Directories.Delete_File (Full_Name); when Ada.Directories.Directory => Ada.Directories.Delete_Tree (Full_Name); end case; end; end if; end Process; begin Ada.Directories.Search ( Directory => Test_Dir, Pattern => "*", Filter => (others => True), Process => Process'Access); end; else Ada.Directories.Create_Directory (Test_Dir); end if; end Setup_Test_Dir; procedure Adjust_After_Extract (Name : in String) is procedure Delete (Name : in String) is begin Ada.Text_IO.Put_Line ("remove " & Name); Ada.Directories.Delete_File (Name); end Delete; procedure Copy (Source, Destination : in String) is begin Ada.Text_IO.Put_Line ("copy " & Source & " to " & Destination); Ada.Directories.Copy_File (Source, Destination); end Copy; begin if Ada.Strings.Equal_Case_Insensitive (Name, "ca1020e") then Delete ("ca1020e_func1.adb"); Delete ("ca1020e_func2.adb"); Delete ("ca1020e_proc1.adb"); Delete ("ca1020e_proc2.adb"); elsif Ada.Strings.Equal_Case_Insensitive (Name, "ca14028") then Delete ("ca14028_func2.adb"); Delete ("ca14028_func3.adb"); Delete ("ca14028_proc1.adb"); Delete ("ca14028_proc3.adb"); elsif Ada.Strings.Equal_Case_Insensitive (Name, "ce2108f") then Copy ("../X2108E", "X2108E"); elsif Ada.Strings.Equal_Case_Insensitive (Name, "ce2108h") then Copy ("../X2108G", "X2108G"); elsif Ada.Strings.Equal_Case_Insensitive (Name, "ce3112d") then Copy ("../X3112C", "X3112C"); end if; -- patch declare Patch_Name : constant String := Ada.Directories.Compose ( Containing_Directory => "..", Name => Ada.Characters.Handling.To_Lower (Name), Extension => "diff"); begin if Ada.Directories.Exists (Patch_Name) then Shell_Execute ("patch -bi " & Patch_Name); end if; end; end Adjust_After_Extract; procedure Invoke ( Executable : in String; Expected : in Test_Result; Result : not null access Test_Result) is C : Integer; begin Shell_Execute ("./" & Executable, C); if C = 134 then -- SIGABORT in Linux Result.all := Any_Exception; else Result.all := Test_Result'Val (C); end if; if Result.all /= Expected then raise Test_Failure; end if; exception when Command_Failure => Result.all := Any_Exception; if Expected /= Any_Exception then raise Test_Failure; end if; end Invoke; -- compiler commands procedure Chop ( Name : in String; Destination_Directory : in String := ""; Accept_Error : in Boolean := False) is Command : Ada.Strings.Unbounded.Unbounded_String; begin Ada.Strings.Unbounded.Append (Command, "gnatchop -w"); if GCC_Prefix /= "" or else GCC_Suffix /= "" then Ada.Strings.Unbounded.Append (Command, " --GCC="); Ada.Strings.Unbounded.Append (Command, GCC_Prefix); Ada.Strings.Unbounded.Append (Command, "gcc"); Ada.Strings.Unbounded.Append (Command, GCC_Suffix); end if; Ada.Strings.Unbounded.Append (Command, " "); Ada.Strings.Unbounded.Append (Command, Name); if Destination_Directory /= "" then Ada.Strings.Unbounded.Append (Command, " "); Ada.Strings.Unbounded.Append (Command, Destination_Directory); end if; begin Shell_Execute (+Command); exception when Command_Failure => if not Accept_Error then raise; end if; end; end Chop; procedure Compile_Only (Name : in String; Result : not null access Test_Result) is Command : Ada.Strings.Unbounded.Unbounded_String; begin Ada.Strings.Unbounded.Append (Command, GCC_Prefix); Ada.Strings.Unbounded.Append (Command, "gcc"); Ada.Strings.Unbounded.Append (Command, GCC_Suffix); Ada.Strings.Unbounded.Append (Command, " -c "); Ada.Strings.Unbounded.Append (Command, Name); Shell_Execute (+Command); exception when Command_Failure => Result.all := Compile_Error; raise Compile_Failure with +Command; end Compile_Only; procedure Compile ( Name : in String; Stack_Check : in Boolean := False; Overflow_Check : in Boolean := False; Dynamic_Elaboration : in Boolean := False; UTF_8 : in Boolean := False; Link_With : in String := ""; RTS : in String := ""; Save_Log : in Boolean := False; Result : not null access Test_Result) is Command : Ada.Strings.Unbounded.Unbounded_String; begin Ada.Strings.Unbounded.Append (Command, GCC_Prefix); Ada.Strings.Unbounded.Append (Command, "gnatmake"); Ada.Strings.Unbounded.Append (Command, GCC_Suffix); if Support_Dir /= "" then Ada.Strings.Unbounded.Append (Command, " -I../"); -- relative path from Test_Dir Ada.Strings.Unbounded.Append (Command, Support_Dir); end if; Ada.Strings.Unbounded.Append (Command, " -gnat05"); -- default version Ada.Strings.Unbounded.Append (Command, " -gnata"); -- assertions if Stack_Check then Ada.Strings.Unbounded.Append (Command, " -fstack-check"); end if; if Overflow_Check then Ada.Strings.Unbounded.Append (Command, " -gnato"); end if; if Dynamic_Elaboration then Ada.Strings.Unbounded.Append (Command, " -gnatE -f"); end if; Ada.Strings.Unbounded.Append (Command, " -gnatws"); -- suppress all warnings if UTF_8 then Ada.Strings.Unbounded.Append (Command, " -gnatW8"); end if; Ada.Strings.Unbounded.Append (Command, " "); Ada.Strings.Unbounded.Append (Command, Name); if RTS /= "" then Ada.Strings.Unbounded.Append (Command, " --RTS="); Ada.Strings.Unbounded.Append (Command, RTS); end if; if Link_With /= "" then Ada.Strings.Unbounded.Append (Command, " -largs "); Ada.Strings.Unbounded.Append (Command, Link_With); end if; if Save_Log then Ada.Strings.Unbounded.Append (Command, " 2>&1 | tee log.txt"); end if; Shell_Execute (+Command); exception when Command_Failure => Result.all := Compile_Error; raise Compile_Failure with +Command; end Compile; -- runtime info type Runtime_Type is (GNAT, Drake); function Get_Runtime return Runtime_Type is begin if RTS_Dir = "" then return GNAT; else return Drake; end if; end Get_Runtime; Runtime : constant Runtime_Type := Get_Runtime; function Get_Expected_File_Name return String is begin case Runtime is when GNAT => return "gnat-expected.txt"; when Drake => return "drake-expected.txt"; end case; end Get_Expected_File_Name; Expected_File_Name : constant String := Get_Expected_File_Name; function Get_Report_File_Name return String is begin case Runtime is when GNAT => return "gnat-result.txt"; when Drake => return "drake-result.txt"; end case; end Get_Report_File_Name; Report_File_Name : constant String := Get_Report_File_Name; -- test info for compiler/runtime function Stack_Check (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "c52103x") or else Ada.Strings.Equal_Case_Insensitive (Name, "c52104x") or else Ada.Strings.Equal_Case_Insensitive (Name, "c52104y") or else Ada.Strings.Equal_Case_Insensitive (Name, "cb1010c") or else Ada.Strings.Equal_Case_Insensitive (Name, "cb1010d"); end Stack_Check; function Overflow_Check (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "c43206a") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45304a") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45304b") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45304c") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45504a") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45504b") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45504c") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45613a") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45613b") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45613c") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45632a") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45632b") or else Ada.Strings.Equal_Case_Insensitive (Name, "c45632c") or else Ada.Strings.Equal_Case_Insensitive (Name, "c460008") or else Ada.Strings.Equal_Case_Insensitive (Name, "c460011") or else Ada.Strings.Equal_Case_Insensitive (Name, "c46014a") or else (Runtime = Drake and then Ada.Strings.Equal_Case_Insensitive (Name, "c96005d")); end Overflow_Check; function Dynamic_Elaboration (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "c731001") or else Ada.Strings.Equal_Case_Insensitive (Name, "c854002") or else Ada.Strings.Equal_Case_Insensitive (Name, "ca5006a"); end Dynamic_Elaboration; function Need_lm (Name : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (Name, "cxb5004"); -- for Linux end Need_lm; -- test operations for compiler/runtime (error class) procedure Check_Log_In_Error_Class (Name : in String; Result : not null access Test_Result) is File : Ada.Text_IO.File_Type; Runtime_Configuration_Error : Boolean := False; begin Ada.Text_IO.Open (File, Ada.Text_IO.In_File, "log.txt"); while not Ada.Text_IO.End_Of_File (File) loop declare Line : constant String := Ada.Text_IO.Get_Line (File); begin if Ada.Strings.Fixed.Index (Line, "file can have only one compilation unit") >= 1 or else (Ada.Strings.Fixed.Index (Line, "cannot generate code") >= 1 and then not Is_Missing_Subunits (Name)) then raise Configuration_Error; elsif Ada.Strings.Fixed.Index (Line, "run-time library configuration error") >= 1 then Runtime_Configuration_Error := True; elsif Ada.Strings.Fixed.Index (Line, "not found") >= 1 then if Runtime_Configuration_Error then null; -- raise Should_Be_Failure elsif Is_Not_Found (Name) then Result.all := Compile_Error; else raise Configuration_Error; end if; elsif Ada.Strings.Fixed.Index (Line, "compilation error") >= 1 or else Ada.Strings.Fixed.Index (Line, "bind failed") >= 1 then Result.all := Compile_Error; end if; end; end loop; Ada.Text_IO.Close (File); if Is_No_Error (Name) then if Result.all = Untested then Result.all := Passed; else raise Compile_Failure; end if; elsif Result.all /= Compile_Error then Result.all := Failed; raise Should_Be_Failure; end if; end Check_Log_In_Error_Class; -- expected test results for compiler/runtime type Expected_Test_Result is record Result : Test_Result; Note : Ada.Strings.Unbounded.Unbounded_String; end record; package Expected_Tables is new Ada.Containers.Indefinite_Ordered_Maps ( String, Expected_Test_Result, "<" => Ada.Strings.Less_Case_Insensitive); function Read_Expected_Table return Expected_Tables.Map is begin return Result : Expected_Tables.Map do declare File : Ada.Text_IO.File_Type; begin Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Name => Expected_File_Name); Ada.Text_IO.Put ("reading " & Expected_File_Name & "..."); while not Ada.Text_IO.End_Of_File (File) loop declare Line : constant String := Ada.Text_IO.Get_Line (File); Element : Expected_Test_Result; begin if Line (8) /= ' ' or else Line (10) /= ' ' then raise Ada.Text_IO.Data_Error with Line; end if; begin Element.Result := Value (Line (9)); exception when Constraint_Error => raise Ada.Text_IO.Data_Error with Line; end; Element.Note := Ada.Strings.Unbounded.To_Unbounded_String (Line (11 .. Line'Last)); Expected_Tables.Include (Result, Line (1 .. 7), Element); end; end loop; Ada.Text_IO.Close (File); end; end return; end Read_Expected_Table; Expected_Table : constant Expected_Tables.Map := Read_Expected_Table; function Runtime_Expected_Result (Name : String) return Expected_Test_Result is begin if Expected_Table.Contains (Name) then return Expected_Table.Element (Name); else return (Passed, Ada.Strings.Unbounded.Null_Unbounded_String); end if; end Runtime_Expected_Result; function ACATS_And_Runtime_Expected_Result (Name : String) return Expected_Test_Result is begin return Result : Expected_Test_Result := Runtime_Expected_Result (Name) do if Result.Result = Passed then Result.Result := Expected_Result (Name); Result.Note := Ada.Strings.Unbounded.To_Unbounded_String ("violate ACATS"); end if; end return; end ACATS_And_Runtime_Expected_Result; -- test result records type Test_Record is record Result : Test_Result; Is_Expected : Boolean; end record; package Test_Records is new Ada.Containers.Indefinite_Ordered_Maps ( String, Test_Record, "<" => Ada.Strings.Less_Case_Insensitive); Records: Test_Records.Map; -- executing test package String_CI_Sets is new Ada.Containers.Indefinite_Ordered_Sets ( String, "<" => Ada.Strings.Less_Case_Insensitive, "=" => Ada.Strings.Equal_Case_Insensitive); procedure Test (Directory : in String; Name : in String) is In_Error_Class : constant Boolean := Is_Error_Class (Name); Main : Ada.Strings.Unbounded.Unbounded_String; Link_With : Ada.Strings.Unbounded.Unbounded_String; UTF_8 : Boolean := False; Result : aliased Test_Result := Untested; procedure Process_Extract (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry); begin if Simple_Name (Simple_Name'First) /= '.' then declare Extension : constant String := Ada.Directories.Extension (Simple_Name); begin if Ada.Strings.Equal_Case_Insensitive (Extension, "ada") or else Ada.Strings.Equal_Case_Insensitive (Extension, "dep") or else Ada.Strings.Equal_Case_Insensitive (Extension, "a") then declare Only_Pragmas : constant Boolean := Is_Only_Pragmas (Simple_Name); begin if Only_Pragmas then Symbolic_Link ( Source => "../" & Ada.Directories.Compose (Directory, Simple_Name), Destination => "gnat.adc;"); else Chop ( "../" & Ada.Directories.Compose (Directory, Simple_Name), Accept_Error => In_Error_Class); end if; end; elsif Ada.Strings.Equal_Case_Insensitive (Extension, "am") then Chop ( "../" & Ada.Directories.Compose (Directory, Simple_Name), Accept_Error => In_Error_Class); declare Main_Name : constant String := Ada.Directories.Compose ( Name => Ada.Directories.Base_Name (Simple_Name), Extension => "adb"); begin if Ada.Directories.Exists (Main_Name) then Main := Ada.Strings.Unbounded.To_Unbounded_String (Main_Name); end if; end; elsif Ada.Strings.Equal_Case_Insensitive (Extension, "au") then UTF_8 := True; Chop ( "../" & Ada.Directories.Compose (Directory, Simple_Name), Accept_Error => In_Error_Class); elsif Ada.Strings.Equal_Case_Insensitive (Extension, "tst") then declare File : Ada.Text_IO.File_Type; begin Ada.Text_IO.Create (File, Name => "TSTTESTS.DAT"); Ada.Text_IO.Put_Line (File, Simple_Name); Ada.Text_IO.Close (File); Symbolic_Link ( Source => "../" & Ada.Directories.Compose (Directory, Simple_Name), Destination => Simple_Name); Symbolic_Link ( Source => "../support/MACRO.DFS", Destination => "MACRO.DFS"); Shell_Execute (Ada.Directories.Compose ( Containing_Directory => Ada.Directories.Compose ("..", Support_Dir), Name => "macrosub")); end; Chop ( Ada.Directories.Compose (Name => Ada.Directories.Base_Name (Simple_Name), Extension => "adt"), Accept_Error => In_Error_Class); elsif Ada.Strings.Equal_Case_Insensitive (Extension, "c") or else Ada.Strings.Equal_Case_Insensitive (Extension, "cbl") or else Ada.Strings.Equal_Case_Insensitive (Extension, "ftn") then Symbolic_Link ( Source => "../" & Ada.Directories.Compose (Directory, Simple_Name), Destination => Simple_Name); if not Ada.Strings.Equal_Case_Insensitive (Simple_Name, "cd300051.c") then -- use .o in support dir Compile_Only (Simple_Name, Result'Access); if Link_With /= "" then Ada.Strings.Unbounded.Append (Link_With, " "); end if; Ada.Strings.Unbounded.Append (Link_With, Ada.Directories.Compose ( Name => Ada.Directories.Base_Name (Simple_Name), Extension => "o")); end if; else raise Unknown_Test with "unknown extension """ & Extension & """ of " & Simple_Name; end if; end; end if; end Process_Extract; Expected : constant Expected_Test_Result := ACATS_And_Runtime_Expected_Result (Name); Is_Expected : Boolean := False; begin Ada.Text_IO.Put_Line ("**** " & Name & " ****"); begin Setup_Test_Dir; Ada.Directories.Set_Directory (Test_Dir); Sorted_Search ( Directory => Start_Dir & "/" & Directory, Pattern => Name & "*", Filter => (others => True), Process => Process_Extract'Access); Adjust_After_Extract (Name); if In_Error_Class then declare package Library_Unit_Sets renames String_CI_Sets; Library_Units : Library_Unit_Sets.Set; procedure Process_Collect (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry); File : Ada.Text_IO.File_Type; begin Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Simple_Name); while not Ada.Text_IO.End_Of_File (File) loop declare Separate_Word : constant String := "SEPARATE"; Line : constant String := Ada.Text_IO.Get_Line (File); begin if Line'Length >= Separate_Word'Length and then Ada.Strings.Equal_Case_Insensitive ( Line (Line'First .. Line'First + Separate_Word'Length - 1), Separate_Word) then return; -- separate unit is not a library unit end if; end; end loop; Ada.Text_IO.Close (File); declare Unit_Name : String := Ada.Directories.Base_Name (Simple_Name); begin for I in Unit_Name'Range loop if Unit_Name (I) = '-' then Unit_Name (I) := '.'; end if; end loop; Library_Unit_Sets.Include (Library_Units, Unit_Name); end; end Process_Collect; File : Ada.Text_IO.File_Type; procedure Process_With (Position : in Library_Unit_Sets.Cursor) is begin Ada.Text_IO.Put_Line (File, "with " & Library_Unit_Sets.Element (Position) & ";"); end Process_With; begin Ada.Directories.Search ( Directory => ".", -- Test_Dir Pattern => "*.ad?", Filter => (Ada.Directories.Ordinary_File => True, others => False), Process => Process_Collect'Access); Ada.Text_IO.Create (File, Name => "main.adb"); Library_Unit_Sets.Iterate (Library_Units, Process_With'Access); Ada.Text_IO.Put_Line (File, "procedure main is"); Ada.Text_IO.Put_Line (File, "begin"); Ada.Text_IO.Put_Line (File, " null;"); Ada.Text_IO.Put_Line (File, "end main;"); Ada.Text_IO.Close (File); begin Compile ("main.adb", UTF_8 => UTF_8, RTS => RTS_Dir, Save_Log => True, Result => Result'Access); -- no error caused by "tee" command when succeeded or failed to compile exception when Compile_Failure => null; end; Check_Log_In_Error_Class (Name, Result'Access); Is_Expected := True; end; else if Main = "" then declare procedure Process_Find_Main (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry); Base_Name : constant String := Ada.Directories.Base_Name (Simple_Name); begin if Ada.Strings.Equal_Case_Insensitive (Name, Base_Name) or else (Base_Name'Length > Name'Length and then Ada.Strings.Equal_Case_Insensitive (Name, Base_Name (1 .. Name'Length)) and then (Base_Name (Base_Name'Last) = 'M' or else Base_Name (Base_Name'Last) = 'm')) then Main := Ada.Strings.Unbounded.To_Unbounded_String (Simple_Name); end if; end Process_Find_Main; begin Ada.Directories.Search ( Directory => ".", -- Test_Dir Pattern => "*.adb", Filter => (Ada.Directories.Ordinary_File => True, others => False), Process => Process_Find_Main'Access); end; end if; if Main = "" then if Ada.Strings.Equal_Case_Insensitive (Name (Name'First .. Name'First + 2), "cxe") then raise Compile_Failure; -- unimplemented test with GLADE else raise Configuration_Error with "main subprogram is not found."; end if; end if; if Need_lm (Name) then if Link_With /= "" then Ada.Strings.Unbounded.Append (Link_With, " "); end if; Ada.Strings.Unbounded.Append (Link_With, "-lm"); end if; Compile ( +Main, Stack_Check => Stack_Check (Name), Overflow_Check => Overflow_Check (Name), Dynamic_Elaboration => Dynamic_Elaboration (Name), Link_With => +Link_With, RTS => RTS_Dir, UTF_8 => UTF_8, Result => Result'Access); if Expected.Result = Untested then raise Test_Failure; else if Clear_Screen_Before_Run (Name) then Ada.Text_IO.New_Page; end if; Invoke ( Ada.Directories.Base_Name (+Main), Expected => Expected.Result, Result => Result'Access); Is_Expected := True; end if; end if; exception when E : Compile_Failure | Test_Failure | Should_Be_Failure => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); if Expected.Result /= Passed then Is_Expected := Result = Expected.Result; if Is_Expected then Ada.Text_IO.Put_Line ( "expected: " & Test_Result'Image (Result) & " " & Ada.Strings.Unbounded.To_String (Expected.Note)); else Ada.Text_IO.Put_Line ( "unexpected: " & Test_Result'Image (Result) & " (expected: " & Test_Result'Image (Expected.Result) & ")"); end if; else Is_Expected := False; Ada.Text_IO.Put_Line ("unexpected: " & Test_Result'Image (Result)); end if; end; Test_Records.Include (Records, Name, Test_Record'(Result => Result, Is_Expected => Is_Expected)); Ada.Directories.Set_Directory (Start_Dir); Ada.Text_IO.New_Line; end Test; package Test_Sets renames String_CI_Sets; Executed_Tests : Test_Sets.Set; type State_Type is (Skip, Run, Stop, Trial); State : State_Type; Continue_From : Ada.Strings.Unbounded.Unbounded_String; Run_Until : Ada.Strings.Unbounded.Unbounded_String; Report_File : Ada.Text_IO.File_Type; procedure Process_File ( Directory : in String; Dir_Entry : in Ada.Directories.Directory_Entry_Type) is Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry); begin if Simple_Name (Simple_Name'First) /= '.' then declare Base_Name : constant String := Ada.Directories.Base_Name (Simple_Name); Test_Name : String renames Base_Name (1 .. 7); Extension : constant String := Ada.Directories.Extension (Simple_Name); function Eq_Test_Name (S : String) return Boolean is begin return Ada.Strings.Equal_Case_Insensitive (S, Simple_Name) or else Ada.Strings.Equal_Case_Insensitive (S, Base_Name) or else Ada.Strings.Equal_Case_Insensitive (S, Test_Name); end Eq_Test_Name; begin if State = Skip and then Eq_Test_Name (+Continue_From) then State := Run; end if; if not Executed_Tests.Contains (Test_Name) then Test_Sets.Insert (Executed_Tests, Test_Name); if State = Run or else (State = Trial and then ( not Records.Contains (Test_Name) or else not Records.Element (Test_Name).Is_Expected)) then if Ada.Strings.Equal_Case_Insensitive (Extension, "ada") or else Ada.Strings.Equal_Case_Insensitive (Extension, "dep") -- implementation depending or else Ada.Strings.Equal_Case_Insensitive (Extension, "tst") -- macro then Test (Directory, Test_Name); -- legacy style test elsif Ada.Strings.Equal_Case_Insensitive (Extension, "a") or else Ada.Strings.Equal_Case_Insensitive (Extension, "am") -- main of multiple source or else Ada.Strings.Equal_Case_Insensitive (Extension, "au") -- UTF-8 or else Ada.Strings.Equal_Case_Insensitive (Extension, "c") -- C source or else Ada.Strings.Equal_Case_Insensitive (Extension, "cbl") -- COBOL source or else Ada.Strings.Equal_Case_Insensitive (Extension, "ftn") -- Fortran source then Test (Directory, Test_Name); -- modern style test else raise Unknown_Test with "unknown extension """ & Extension & """ of " & Simple_Name; end if; if State = Trial and then not Records.Element (Test_Name).Is_Expected then State := Stop; end if; else if not Records.Contains (Test_Name) then Test_Records.Include ( Records, Test_Name, Test_Record'(Result => Untested, Is_Expected => False)); end if; end if; declare R : Test_Record renames Test_Records.Element (Records, Test_Name); XO : constant array (Boolean) of Character := "XO"; begin Ada.Text_IO.Put_Line ( Report_File, Test_Name & ' ' & Image (R.Result) & ' ' & XO (R.Is_Expected)); end; end if; if State = Run and then Eq_Test_Name (+Run_Until) then State := Stop; end if; end; end if; end Process_File; procedure Process_Dir (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry); begin if Simple_Name (Simple_Name'First) /= '.' and then not Ada.Strings.Equal_Case_Insensitive (Simple_Name, "docs") and then not Ada.Strings.Equal_Case_Insensitive (Simple_Name, "support") then declare Directory : constant String := Ada.Directories.Compose ( Containing_Directory => ACATS_Dir, Name => Simple_Name); procedure Process (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is begin Process_File (Directory, Dir_Entry); end Process; begin Sorted_Search ( Directory => Ada.Directories.Full_Name (Dir_Entry), Pattern => "*", Filter => (others => True), Process => Process'Access); end; end if; end Process_Dir; begin if Ada.Command_Line.Argument_Count < 1 then State := Run; elsif Ada.Command_Line.Argument (1) = "--trial" then State := Trial; else State := Skip; Continue_From := Ada.Strings.Unbounded.To_Unbounded_String (Ada.Command_Line.Argument (1)); if Ada.Command_Line.Argument_Count < 2 then Run_Until := Continue_From; elsif Ada.Command_Line.Argument (2) = ".." then Run_Until := Ada.Strings.Unbounded.Null_Unbounded_String; else Run_Until := Ada.Strings.Unbounded.To_Unbounded_String (Ada.Command_Line.Argument (2)); end if; end if; begin Ada.Text_IO.Open (Report_File, Ada.Text_IO.In_File, Name => Report_File_Name); Ada.Text_IO.Put ("reading " & Report_File_Name & "..."); while not Ada.Text_IO.End_Of_File (Report_File) loop declare Line : constant String := Ada.Text_IO.Get_Line (Report_File); Result : Test_Result; Is_Expected : Boolean; begin if Line (8) /= ' ' or else Line (10) /= ' ' then raise Ada.Text_IO.Data_Error with Line; end if; begin Result := Value (Line (9)); exception when Constraint_Error => raise Ada.Text_IO.Data_Error with Line; end; case Line (11) is when 'X' => Is_Expected := False; when 'O' => Is_Expected := True; when others => raise Ada.Text_IO.Data_Error with Line; end case; Test_Records.Include ( Records, Line (1 .. 7), Test_Record'(Result => Result, Is_Expected => Is_Expected)); end; end loop; Ada.Text_IO.Close (Report_File); Ada.Text_IO.Put_Line ("done."); exception when Ada.Text_IO.Name_Error => null; end; Ada.Text_IO.Create (Report_File, Name => Report_File_Name); Sorted_Search ( Directory => ACATS_Dir, Pattern => "*", Filter => (Ada.Directories.Directory => True, others => False), Process => Process_Dir'Access); Ada.Text_IO.Close (Report_File); case State is when Run | Trial => Ada.Text_IO.Put_Line ("**** complete ****"); when others => null; end case; end run_acats;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . D Y N A M I C _ H T A B L E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2002-2016, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; package body GNAT.Dynamic_HTables is ------------------- -- Static_HTable -- ------------------- package body Static_HTable is type Table_Type is array (Header_Num) of Elmt_Ptr; type Instance_Data is record Table : Table_Type; Iterator_Index : Header_Num; Iterator_Ptr : Elmt_Ptr; Iterator_Started : Boolean := False; end record; function Get_Non_Null (T : Instance) return Elmt_Ptr; -- Returns Null_Ptr if Iterator_Started is False or if the Table is -- empty. Returns Iterator_Ptr if non null, or the next non null -- element in table if any. --------- -- Get -- --------- function Get (T : Instance; K : Key) return Elmt_Ptr is Elmt : Elmt_Ptr; begin if T = null then return Null_Ptr; end if; Elmt := T.Table (Hash (K)); loop if Elmt = Null_Ptr then return Null_Ptr; elsif Equal (Get_Key (Elmt), K) then return Elmt; else Elmt := Next (Elmt); end if; end loop; end Get; --------------- -- Get_First -- --------------- function Get_First (T : Instance) return Elmt_Ptr is begin if T = null then return Null_Ptr; end if; T.Iterator_Started := True; T.Iterator_Index := T.Table'First; T.Iterator_Ptr := T.Table (T.Iterator_Index); return Get_Non_Null (T); end Get_First; -------------- -- Get_Next -- -------------- function Get_Next (T : Instance) return Elmt_Ptr is begin if T = null or else not T.Iterator_Started then return Null_Ptr; end if; T.Iterator_Ptr := Next (T.Iterator_Ptr); return Get_Non_Null (T); end Get_Next; ------------------ -- Get_Non_Null -- ------------------ function Get_Non_Null (T : Instance) return Elmt_Ptr is begin if T = null then return Null_Ptr; end if; while T.Iterator_Ptr = Null_Ptr loop if T.Iterator_Index = T.Table'Last then T.Iterator_Started := False; return Null_Ptr; end if; T.Iterator_Index := T.Iterator_Index + 1; T.Iterator_Ptr := T.Table (T.Iterator_Index); end loop; return T.Iterator_Ptr; end Get_Non_Null; ------------ -- Remove -- ------------ procedure Remove (T : Instance; K : Key) is Index : constant Header_Num := Hash (K); Elmt : Elmt_Ptr; Next_Elmt : Elmt_Ptr; begin if T = null then return; end if; Elmt := T.Table (Index); if Elmt = Null_Ptr then return; elsif Equal (Get_Key (Elmt), K) then T.Table (Index) := Next (Elmt); else loop Next_Elmt := Next (Elmt); if Next_Elmt = Null_Ptr then return; elsif Equal (Get_Key (Next_Elmt), K) then Set_Next (Elmt, Next (Next_Elmt)); return; else Elmt := Next_Elmt; end if; end loop; end if; end Remove; ----------- -- Reset -- ----------- procedure Reset (T : in out Instance) is procedure Free is new Ada.Unchecked_Deallocation (Instance_Data, Instance); begin if T = null then return; end if; for J in T.Table'Range loop T.Table (J) := Null_Ptr; end loop; Free (T); end Reset; --------- -- Set -- --------- procedure Set (T : in out Instance; E : Elmt_Ptr) is Index : Header_Num; begin if T = null then T := new Instance_Data; end if; Index := Hash (Get_Key (E)); Set_Next (E, T.Table (Index)); T.Table (Index) := E; end Set; end Static_HTable; ------------------- -- Simple_HTable -- ------------------- package body Simple_HTable is procedure Free is new Ada.Unchecked_Deallocation (Element_Wrapper, Elmt_Ptr); --------- -- Get -- --------- function Get (T : Instance; K : Key) return Element is Tmp : Elmt_Ptr; begin if T = Nil then return No_Element; end if; Tmp := Tab.Get (Tab.Instance (T), K); if Tmp = null then return No_Element; else return Tmp.E; end if; end Get; --------------- -- Get_First -- --------------- function Get_First (T : Instance) return Element is Tmp : constant Elmt_Ptr := Tab.Get_First (Tab.Instance (T)); begin if Tmp = null then return No_Element; else return Tmp.E; end if; end Get_First; ------------- -- Get_Key -- ------------- function Get_Key (E : Elmt_Ptr) return Key is begin return E.K; end Get_Key; -------------- -- Get_Next -- -------------- function Get_Next (T : Instance) return Element is Tmp : constant Elmt_Ptr := Tab.Get_Next (Tab.Instance (T)); begin if Tmp = null then return No_Element; else return Tmp.E; end if; end Get_Next; ---------- -- Next -- ---------- function Next (E : Elmt_Ptr) return Elmt_Ptr is begin return E.Next; end Next; ------------ -- Remove -- ------------ procedure Remove (T : Instance; K : Key) is Tmp : Elmt_Ptr; begin Tmp := Tab.Get (Tab.Instance (T), K); if Tmp /= null then Tab.Remove (Tab.Instance (T), K); Free (Tmp); end if; end Remove; ----------- -- Reset -- ----------- procedure Reset (T : in out Instance) is E1, E2 : Elmt_Ptr; begin E1 := Tab.Get_First (Tab.Instance (T)); while E1 /= null loop E2 := Tab.Get_Next (Tab.Instance (T)); Free (E1); E1 := E2; end loop; Tab.Reset (Tab.Instance (T)); end Reset; --------- -- Set -- --------- procedure Set (T : in out Instance; K : Key; E : Element) is Tmp : constant Elmt_Ptr := Tab.Get (Tab.Instance (T), K); begin if Tmp = null then Tab.Set (Tab.Instance (T), new Element_Wrapper'(K, E, null)); else Tmp.E := E; end if; end Set; -------------- -- Set_Next -- -------------- procedure Set_Next (E : Elmt_Ptr; Next : Elmt_Ptr) is begin E.Next := Next; end Set_Next; end Simple_HTable; ------------------------ -- Load_Factor_HTable -- ------------------------ package body Load_Factor_HTable is Min_Size_Increase : constant := 5; -- The minimum increase expressed as number of buckets. This value is -- used to determine the new size of small tables and/or small growth -- percentages. procedure Attach (Elmt : not null Element_Ptr; Chain : not null Element_Ptr); -- Prepend an element to a bucket chain. Elmt is inserted after the -- dummy head of Chain. function Create_Buckets (Size : Positive) return Buckets_Array_Ptr; -- Allocate and initialize a new set of buckets. The buckets are created -- in the range Range_Type'First .. Range_Type'First + Size - 1. procedure Detach (Elmt : not null Element_Ptr); -- Remove an element from an arbitrary bucket chain function Find (Key : Key_Type; Chain : not null Element_Ptr) return Element_Ptr; -- Try to locate the element which contains a particular key within a -- bucket chain. If no such element exists, return No_Element. procedure Free is new Ada.Unchecked_Deallocation (Buckets_Array, Buckets_Array_Ptr); procedure Free is new Ada.Unchecked_Deallocation (Element, Element_Ptr); function Is_Empty_Chain (Chain : not null Element_Ptr) return Boolean; -- Determine whether a bucket chain contains only one element, namely -- the dummy head. ------------ -- Attach -- ------------ procedure Attach (Elmt : not null Element_Ptr; Chain : not null Element_Ptr) is begin Chain.Next.Prev := Elmt; Elmt.Next := Chain.Next; Chain.Next := Elmt; Elmt.Prev := Chain; end Attach; -------------------- -- Create_Buckets -- -------------------- function Create_Buckets (Size : Positive) return Buckets_Array_Ptr is Low_Bound : constant Range_Type := Range_Type'First; Buckets : Buckets_Array_Ptr; begin Buckets := new Buckets_Array (Low_Bound .. Low_Bound + Range_Type (Size) - 1); -- Ensure that the dummy head of each bucket chain points to itself -- in both directions. for Index in Buckets'Range loop declare Bucket : Element renames Buckets (Index); begin Bucket.Prev := Bucket'Unchecked_Access; Bucket.Next := Bucket'Unchecked_Access; end; end loop; return Buckets; end Create_Buckets; ------------------ -- Current_Size -- ------------------ function Current_Size (T : Table) return Positive is begin -- The table should have been properly initialized during object -- elaboration. if T.Buckets = null then raise Program_Error; -- The size of the table is determined by the number of buckets else return T.Buckets'Length; end if; end Current_Size; ------------ -- Detach -- ------------ procedure Detach (Elmt : not null Element_Ptr) is begin if Elmt.Prev /= null and Elmt.Next /= null then Elmt.Prev.Next := Elmt.Next; Elmt.Next.Prev := Elmt.Prev; Elmt.Prev := null; Elmt.Next := null; end if; end Detach; -------------- -- Finalize -- -------------- procedure Finalize (T : in out Table) is Bucket : Element_Ptr; Elmt : Element_Ptr; begin -- Inspect the buckets and deallocate bucket chains for Index in T.Buckets'Range loop Bucket := T.Buckets (Index)'Unchecked_Access; -- The current bucket chain contains an element other than the -- dummy head. while not Is_Empty_Chain (Bucket) loop -- Skip the dummy head, remove and deallocate the element Elmt := Bucket.Next; Detach (Elmt); Free (Elmt); end loop; end loop; -- Deallocate the buckets Free (T.Buckets); end Finalize; ---------- -- Find -- ---------- function Find (Key : Key_Type; Chain : not null Element_Ptr) return Element_Ptr is Elmt : Element_Ptr; begin -- Skip the dummy head, inspect the bucket chain for an element whose -- key matches the requested key. Since each bucket chain is circular -- the search must stop once the dummy head is encountered. Elmt := Chain.Next; while Elmt /= Chain loop if Equal (Elmt.Key, Key) then return Elmt; end if; Elmt := Elmt.Next; end loop; return No_Element; end Find; --------- -- Get -- --------- function Get (T : Table; Key : Key_Type) return Value_Type is Bucket : Element_Ptr; Elmt : Element_Ptr; begin -- Obtain the bucket chain where the (key, value) pair should reside -- by calculating the proper hash location. Bucket := T.Buckets (Hash (Key, Current_Size (T)))'Unchecked_Access; -- Try to find an element whose key matches the requested key Elmt := Find (Key, Bucket); -- The hash table does not contain a matching (key, value) pair if Elmt = No_Element then return No_Value; else return Elmt.Val; end if; end Get; ---------------- -- Initialize -- ---------------- procedure Initialize (T : in out Table) is begin pragma Assert (T.Buckets = null); T.Buckets := Create_Buckets (Initial_Size); T.Element_Count := 0; end Initialize; -------------------- -- Is_Empty_Chain -- -------------------- function Is_Empty_Chain (Chain : not null Element_Ptr) return Boolean is begin return Chain.Next = Chain and Chain.Prev = Chain; end Is_Empty_Chain; ------------ -- Remove -- ------------ procedure Remove (T : in out Table; Key : Key_Type) is Bucket : Element_Ptr; Elmt : Element_Ptr; begin -- Obtain the bucket chain where the (key, value) pair should reside -- by calculating the proper hash location. Bucket := T.Buckets (Hash (Key, Current_Size (T)))'Unchecked_Access; -- Try to find an element whose key matches the requested key Elmt := Find (Key, Bucket); -- Remove and deallocate the (key, value) pair if Elmt /= No_Element then Detach (Elmt); Free (Elmt); end if; end Remove; --------- -- Set -- --------- procedure Set (T : in out Table; Key : Key_Type; Val : Value_Type) is Curr_Size : constant Positive := Current_Size (T); procedure Grow; -- Grow the table to a new size according to the desired percentage -- and relocate all existing elements to the new buckets. ---------- -- Grow -- ---------- procedure Grow is Buckets : Buckets_Array_Ptr; Elmt : Element_Ptr; Hash_Loc : Range_Type; Old_Bucket : Element_Ptr; Old_Buckets : Buckets_Array_Ptr := T.Buckets; Size : Positive; begin -- Calculate the new size and allocate a new set of buckets. Note -- that a table with a small size or a small growth percentage may -- not always grow (for example, 10 buckets and 3% increase). In -- that case, enforce a minimum increase. Size := Positive'Max (Curr_Size * ((100 + Growth_Percentage) / 100), Min_Size_Increase); Buckets := Create_Buckets (Size); -- Inspect the old buckets and transfer all elements by rehashing -- all (key, value) pairs in the new buckets. for Index in Old_Buckets'Range loop Old_Bucket := Old_Buckets (Index)'Unchecked_Access; -- The current bucket chain contains an element other than the -- dummy head. while not Is_Empty_Chain (Old_Bucket) loop -- Skip the dummy head and find the new hash location Elmt := Old_Bucket.Next; Hash_Loc := Hash (Elmt.Key, Size); -- Remove the element from the old buckets and insert it -- into the new buckets. Note that there is no need to check -- for duplicates because the hash table did not have any to -- begin with. Detach (Elmt); Attach (Elmt => Elmt, Chain => Buckets (Hash_Loc)'Unchecked_Access); end loop; end loop; -- Associate the new buckets with the table and reclaim the -- storage occupied by the old buckets. T.Buckets := Buckets; Free (Old_Buckets); end Grow; -- Local variables subtype LLF is Long_Long_Float; Count : Natural renames T.Element_Count; Bucket : Element_Ptr; Hash_Loc : Range_Type; -- Start of processing for Set begin -- Find the bucket where the (key, value) pair should be inserted by -- computing the proper hash location. Hash_Loc := Hash (Key, Curr_Size); Bucket := T.Buckets (Hash_Loc)'Unchecked_Access; -- Ensure that the key is not already present in the bucket in order -- to avoid duplicates. if Find (Key, Bucket) = No_Element then Attach (Elmt => new Element'(Key, Val, null, null), Chain => Bucket); Count := Count + 1; -- Multiple insertions may cause long bucket chains and decrease -- the performance of basic operations. If this is the case, grow -- the table and rehash all existing elements. if (LLF (Count) / LLF (Curr_Size)) > LLF (Load_Factor) then Grow; end if; end if; end Set; end Load_Factor_HTable; end GNAT.Dynamic_HTables;
----------------------------------------------------------------------- -- util-streams-sockets-tests -- Unit tests for socket streams -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.IO_Exceptions; with Util.Test_Caller; with Util.Streams.Texts; with Util.Tests.Servers; package body Util.Streams.Sockets.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Streams.Sockets"); type Test_Server is new Util.Tests.Servers.Server with record Count : Natural := 0; end record; -- Process the line received by the server. overriding procedure Process_Line (Into : in out Test_Server; Line : in Ada.Strings.Unbounded.Unbounded_String; Stream : in out Util.Streams.Texts.Reader_Stream'Class; Client : in out Util.Streams.Sockets.Socket_Stream'Class); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Streams.Initialize,Connect", Test_Socket_Init'Access); Caller.Add_Test (Suite, "Test Util.Streams.Connect,Read,Write", Test_Socket_Read'Access); end Add_Tests; -- ------------------------------ -- Process the line received by the server. -- ------------------------------ overriding procedure Process_Line (Into : in out Test_Server; Line : in Ada.Strings.Unbounded.Unbounded_String; Stream : in out Util.Streams.Texts.Reader_Stream'Class; Client : in out Util.Streams.Sockets.Socket_Stream'Class) is pragma Unreferenced (Stream, Client); begin if Ada.Strings.Unbounded.Index (Line, "test-" & Natural'Image (Into.Count + 1)) > 0 then Into.Count := Into.Count + 1; end if; end Process_Line; -- ------------------------------ -- Test reading and writing on a socket stream. -- ------------------------------ procedure Test_Socket_Read (T : in out Test) is Stream : aliased Sockets.Socket_Stream; Writer : Util.Streams.Texts.Print_Stream; Server : Test_Server; Addr : GNAT.Sockets.Sock_Addr_Type; begin Server.Start; T.Assert (Server.Get_Port > 0, "The server was not started"); Addr := (GNAT.Sockets.Family_Inet, GNAT.Sockets.Addresses (GNAT.Sockets.Get_Host_By_Name (GNAT.Sockets.Host_Name), 1), GNAT.Sockets.Port_Type (Server.Get_Port)); -- Let the server start. delay 0.1; -- Get a connection and write 10 lines. Stream.Connect (Server => Addr); Writer.Initialize (Output => Stream'Unchecked_Access, Input => null, Size => 1024); for I in 1 .. 10 loop Writer.Write ("Sending a line on the socket test-" & Natural'Image (I) & ASCII.CR & ASCII.LF); Writer.Flush; end loop; Writer.Close; -- Stop the server and verify that 10 lines were received. Server.Stop; Util.Tests.Assert_Equals (T, 10, Server.Count, "Invalid number of lines received"); end Test_Socket_Read; -- ------------------------------ -- Test socket initialization. -- ------------------------------ procedure Test_Socket_Init (T : in out Test) is Stream : aliased Sockets.Socket_Stream; Fd : GNAT.Sockets.Socket_Type; Addr : GNAT.Sockets.Sock_Addr_Type; begin Addr := (GNAT.Sockets.Family_Inet, GNAT.Sockets.Addresses (GNAT.Sockets.Get_Host_By_Name (GNAT.Sockets.Host_Name), 1), 80); GNAT.Sockets.Create_Socket (Fd); Stream.Open (Fd); begin Stream.Connect (Addr); T.Assert (False, "No exception was raised"); exception when Ada.IO_Exceptions.Use_Error => null; end; end Test_Socket_Init; end Util.Streams.Sockets.Tests;
with Ada.Streams; use Ada.Streams; -- Several utilities to ease encoded string processing package Encodings.Utility is pragma Pure; -- Generic array version of Stream.Read returning last element written generic type Element_Type is (<>); type Index_Type is (<>); type Array_Type is array(Index_Type range <>) of Element_Type; procedure Read_Array( Stream: in out Root_Stream_Type'Class; Item: out Array_Type; Last: out Index_Type'Base ); procedure Read_String(Stream: in out Root_Stream_Type'Class; Item: out String; Last: out Positive'Base); end Encodings.Utility;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- O P T -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains global switches set by the initialization -- routine from the command line and referenced throughout the compiler, -- the binder or gnatmake. The comments indicate which options are used by -- which programs (GNAT, GNATBIND, GNATMAKE). with Hostparm; use Hostparm; with Types; use Types; with System.WCh_Con; use System.WCh_Con; package Opt is ---------------------------------------------- -- Settings of Modes for Current Processing -- ---------------------------------------------- -- The following mode values represent the current state of processing. -- The values set here are the default values. Unless otherwise noted, -- the value may be reset in Switch with an appropropiate switch. In -- some cases, the values can also be modified by pragmas, and in the -- case of some binder variables, Gnatbind.Scan_Bind_Arg may modify -- the default values. Ada_Bind_File : Boolean := True; -- GNATBIND -- Set True if binder file to be generated in Ada rather than C Ada_95 : Boolean := True; -- GNAT -- Set True if operating in Ada 95 mode -- Set False if operating in Ada 83 mode Ada_83 : Boolean := False; -- GNAT -- Set True if operating in Ada 83 mode -- Set False if operating in Ada 95 mode Ada_Final_Suffix : constant String := "final"; -- GNATBIND -- The suffix of the name of the finalization procedure. This variable -- may be modified by Gnatbind.Scan_Bind_Arg. Ada_Final_Name : String_Ptr := new String'("ada" & Ada_Final_Suffix); -- GNATBIND -- The name of the procedure that performs the finalization at the end of -- execution. This variable may be modified by Gnatbind.Scan_Bind_Arg. Ada_Init_Suffix : constant String := "init"; -- GNATBIND -- The suffix of the name of the initialization procedure. This variable -- may be modified by Gnatbind.Scan_Bind_Arg. Ada_Init_Name : String_Ptr := new String'("ada" & Ada_Init_Suffix); -- GNATBIND -- The name of the procedure that performs initialization at the start -- of execution. This variable may be modified by Gnatbind.Scan_Bind_Arg. Ada_Main_Name_Suffix : constant String := "main"; -- GNATBIND -- The suffix for Ada_Main_Name. Defined as a constant here so that it -- can be referenced in a uniform manner to create either the default -- value of Ada_Main_Name (declared below), or the non-default name -- set by Gnatbind.Scan_Bind_Arg. Ada_Main_Name : String_Ptr := new String'("ada_" & Ada_Main_Name_Suffix); -- GNATBIND -- The name of the Ada package generated by the binder (when in Ada mode). -- This variable may be modified by Gnatbind.Scan_Bind_Arg. Address_Clause_Overlay_Warnings : Boolean := True; -- GNAT -- Set False to disable address clause warnings All_Errors_Mode : Boolean := False; -- GNAT -- Flag set to force display of multiple errors on a single line and -- also repeated error messages for references to undefined identifiers -- and certain other repeated error messages. All_Sources : Boolean := False; -- GNATBIND -- Set to True to require all source files to be present. This flag is -- directly modified by gnatmake to affect the shared binder routines. Alternate_Main_Name : String_Ptr := null; -- Set to non null when Bind_Alternate_Main_Name is True. This value -- is modified as needed by Gnatbind.Scan_Bind_Arg. Assertions_Enabled : Boolean := False; -- GNAT -- Enable assertions made using pragma Assert. Back_Annotate_Rep_Info : Boolean := False; -- GNAT -- If set True (by use of -gnatB), enables back annotation of -- representation information by gigi, even in -gnatc mode. Bind_Alternate_Main_Name : Boolean := False; -- GNATBIND -- Set to True if main should be called Alternate_Main_Name.all. This -- variable may be set to True by Gnatbind.Scan_Bind_Arg. Bind_Main_Program : Boolean := True; -- GNATBIND -- Set to False if not binding main Ada program. Bind_For_Library : Boolean := False; -- GNATBIND -- Set to True if the binder needs to generate a file designed for -- building a library. May be set to True by Gnatbind.Scan_Bind_Arg. Bind_Only : Boolean := False; -- GNATMAKE -- Set to True to skip compile and link steps -- (except when Compile_Only and/or Link_Only are True). Brief_Output : Boolean := False; -- GNAT, GNATBIND -- Force brief error messages to standard error, even if verbose mode is -- set (so that main error messages go to standard output). Check_Object_Consistency : Boolean := False; -- GNATBIND, GNATMAKE -- Set to True to check whether every object file is consistent with -- with its corresponding ada library information (ali) file. An object -- file is inconsistent with the corresponding ali file if the object -- file does not exist or if it has an older time stamp than the ali file. -- Default above is for GNATBIND. GNATMAKE overrides this default to -- True (see Make.Initialize) since we do not need to check source -- consistencies in gnatmake in this sense. Check_Only : Boolean := False; -- GNATBIND -- Set to True to do checks only, no output of binder file. Check_Readonly_Files : Boolean := False; -- GNATMAKE -- Set to True to check readonly files during the make process. Check_Source_Files : Boolean := True; -- GNATBIND -- Set to True to enable consistency checking for any source files that -- are present (i.e. date must match the date in the library info file). -- Set to False for object file consistency check only. This flag is -- directly modified by gnatmake, to affect the shared binder routines. Check_Switches : Boolean := False; -- GNATMAKE -- Set to True to check compiler options during the make process. Check_Unreferenced : Boolean := False; -- GNAT -- Set to True to enable checking for unreferenced variables Check_Withs : Boolean := False; -- GNAT -- Set to True to enable checking for unused withs, and also the case -- of withing a package and using none of the entities in the package. Compile_Only : Boolean := False; -- GNATMAKE -- Set to True to skip bind and link steps (except when Bind_Only is True) Compress_Debug_Names : Boolean := False; -- GNATMAKE -- Set to True if the option to compress debug information is set (-gnatC) Config_File : Boolean := True; -- GNAT -- Set to False to inhibit reading and processing of gnat.adc file Config_File_Name : String_Ptr := null; -- GNAT -- File name of configuration pragmas file (given by switch -gnatec) Constant_Condition_Warnings : Boolean := False; -- GNAT -- Set to True to activate warnings on constant conditions subtype Debug_Level_Value is Nat range 0 .. 3; Debugger_Level : Debug_Level_Value := 0; -- GNATBIND -- The value given to the -g parameter. -- The default value for -g with no value is 2 -- This is usually ignored by GNATBIND, except in the VMS version -- where it is passed as an argument to __gnat_initialize to trigger -- the activation of the remote debugging interface (is this true???). Debug_Generated_Code : Boolean := False; -- GNAT -- Set True (-gnatD switch) to debug generated expanded code instead -- of the original source code. Causes debugging information to be -- written with respect to the generated code file that is written. Display_Compilation_Progress : Boolean := False; -- GNATMAKE -- Set True (-d switch) to display information on progress while compiling -- files. Internal switch to be used in conjunction with an IDE such as -- Glide. type Distribution_Stub_Mode_Type is -- GNAT (No_Stubs, -- Normal mode, no generation/compilation of distribution stubs Generate_Receiver_Stub_Body, -- The unit being compiled is the RCI body, and the compiler will -- generate the body for the receiver stubs and compile it. Generate_Caller_Stub_Body); -- The unit being compiled is the RCI spec, and the compiler will -- generate the body for the caller stubs and compile it. Distribution_Stub_Mode : Distribution_Stub_Mode_Type := No_Stubs; -- GNAT -- This enumeration variable indicates the five states of distribution -- annex stub generation/compilation. Do_Not_Execute : Boolean := False; -- GNATMAKE -- Set to True if no actual compilations should be undertaken. Dynamic_Elaboration_Checks : Boolean := False; -- GNAT -- Set True for dynamic elaboration checking mode, as set by the -gnatE -- switch or by the use of pragma Elaboration_Checks (Dynamic). Elab_Dependency_Output : Boolean := False; -- GNATBIND -- Set to True to output complete list of elaboration constraints Elab_Order_Output : Boolean := False; -- GNATBIND -- Set to True to output chosen elaboration order Elab_Warnings : Boolean := False; -- GNAT -- Set to True to generate full elaboration warnings (-gnatwl) type Exception_Mechanism_Type is (Setjmp_Longjmp, Front_End_ZCX, GCC_ZCX); Exception_Mechanism : Exception_Mechanism_Type := Setjmp_Longjmp; -- GNAT -- Set to the appropriate value depending on the default as given in -- system.ads (ZCX_By_Default, GCC_ZCX_Support, Front_End_ZCX_Support) -- and the use of -gnatL -gnatZ (and -gnatdX) Exception_Tracebacks : Boolean := False; -- GNATBIND -- Set to True to store tracebacks in exception occurrences (-E) Extensions_Allowed : Boolean := False; -- GNAT type External_Casing_Type is ( As_Is, -- External names cased as they appear in the Ada source Uppercase, -- External names forced to all uppercase letters Lowercase); -- External names forced to all lowercase letters External_Name_Imp_Casing : External_Casing_Type := Lowercase; -- The setting of this switch determines the casing of external names -- when the name is implicitly derived from an entity name (i.e. either -- no explicit External_Name or Link_Name argument is used, or, in the -- case of extended DEC pragmas, the external name is given using an -- identifier. The As_Is setting is not permitted here (since this would -- create Ada source programs that were case sensitive). External_Name_Exp_Casing : External_Casing_Type := As_Is; -- The setting of this switch determines the casing of an external name -- specified explicitly with a string literal. As_Is means the string -- literal is used as given with no modification to the casing. If -- Lowercase or Uppercase is set, then the string is forced to all -- lowercase or all uppercase letters as appropriate. Note that this -- setting has no effect if the external name is given using an identifier -- in the case of extended DEC import/export pragmas (in this case the -- casing is controlled by External_Name_Imp_Casing), and also has no -- effect if an explicit Link_Name is supplied (a link name is always -- used exactly as given). Float_Format : Character := ' '; -- GNAT -- A non-blank value indicates that a Float_Format pragma has been -- processed, in which case this variable is set to 'I' for IEEE or -- to 'V' for VAX. The setting of 'V' is only possible on OpenVMS -- versions of GNAT. Float_Format_Long : Character := ' '; -- GNAT -- A non-blank value indicates that a Long_Float pragma has been -- processed (this pragma is recognized only in OpenVMS versions -- of GNAT), in which case this variable is set to D or G for -- D_Float or G_Float. Force_ALI_Tree_File : Boolean := False; -- GNAT -- Force generation of ali file even if errors are encountered. -- Also forces generation of tree file if -gnatt is also set. Force_Compilations : Boolean := False; -- GNATMAKE -- Set to force recompilations even when the objects are up-to-date. Force_RM_Elaboration_Order : Boolean := False; -- GNATBIND -- True if binding with forced RM elaboration order (-f switch set) -- Note: this is considered an obsolescent option, to be removed in -- some future release. it is no longer documented. The proper way -- to get this effect is to use -gnatE and suppress elab checks. Full_List : Boolean := False; -- GNAT -- Set True to generate full source listing with embedded errors Global_Discard_Names : Boolean := False; -- GNAT -- Set true if a pragma Discard_Names applies to the current unit GNAT_Mode : Boolean := False; -- GNAT -- True if compiling in GNAT system mode (-g switch set) HLO_Active : Boolean := False; -- GNAT -- True if High Level Optimizer is activated Implementation_Unit_Warnings : Boolean := True; -- GNAT -- Set True to active warnings for use of implementation internal units. -- Can be controlled by use of -gnatwi/-gnatwI. Identifier_Character_Set : Character; -- GNAT -- This variable indicates the character set to be used for identifiers. -- The possible settings are: -- '1' Latin-1 -- '2' Latin-2 -- '3' Latin-3 -- '4' Latin-4 -- 'p' PC (US, IBM page 437) -- '8' PC (European, IBM page 850) -- 'f' Full upper set (all distinct) -- 'n' No upper characters (Ada/83 rules) -- 'w' Latin-1 plus wide characters allowed in identifiers -- -- The setting affects the set of letters allowed in identifiers and the -- upper/lower case equivalences. It does not affect the interpretation of -- character and string literals, which are always stored using the actual -- coding in the source program. This variable is initialized to the -- default value appropriate to the system (in Osint.Initialize), and then -- reset if a command line switch is used to change the setting. Ineffective_Inline_Warnings : Boolean := False; -- GNAT -- Set True to activate warnings if front-end inlining (-gnatN) is not -- able to actually inline a particular call (or all calls). Can be -- controlled by use of -gnatwp/-gnatwP. Init_Or_Norm_Scalars : Boolean := False; -- GNAT -- Set True if a pragma Initialize_Scalars applies to the current unit. -- Also set True if a pragma Normalize_Scalars applies. Initialize_Scalars : Boolean := False; -- GNAT -- Set True if a pragma Initialize_Scalars applies to the current unit. -- Note that Init_Or_Norm_Scalars is also set to True if this is True. Initialize_Scalars_Mode : Character := 'I'; -- GNATBIND -- Set to 'I' for -Sin (default), 'L' for -Slo, 'H' for -Shi, 'X' for -Sxx Initialize_Scalars_Val : String (1 .. 2); -- GNATBIND -- Valid only if Initialize_Scalars_Mode is set to 'X' (-Shh). Contains -- the two hex bytes from the -Shh switch. Inline_Active : Boolean := False; -- GNAT -- Set True to activate pragma Inline processing across modules. Default -- for now is not to inline across module boundaries. Front_End_Inlining : Boolean := False; -- GNAT -- Set True to activate inlining by front-end expansion. Inline_Processing_Required : Boolean := False; -- GNAT -- Set True if inline processing is required. Inline processing is -- required if an active Inline pragma is processed. The flag is set -- for a pragma Inline or Inline_Always that is actually active. In_Place_Mode : Boolean := False; -- GNATMAKE -- Set True to store ALI and object files in place ie in the object -- directory if these files already exist or in the source directory -- if not. Keep_Going : Boolean := False; -- GNATMAKE -- When True signals gnatmake to ignore compilation errors and keep -- processing sources until there is no more work. Link_Only : Boolean := False; -- GNATMAKE -- Set to True to skip compile and bind steps -- (except when Bind_Only is set to True). List_Units : Boolean := False; -- GNAT -- List units in the active library List_Dependencies : Boolean := False; -- GNATMAKE -- When True gnatmake verifies that the objects are up to date and -- outputs the list of object dependencies. This list can be used -- directly in a Makefile. List_Representation_Info : Int range 0 .. 3 := 0; -- GNAT -- Set true by -gnatR switch to list representation information. -- The settings are as follows: -- -- 0 = no listing of representation information (default as above) -- 1 = list rep info for user defined record and array types -- 2 = list rep info for all user defined types and objects -- 3 = like 2, but variable fields are decoded symbolically Locking_Policy : Character := ' '; -- GNAT -- Set to ' ' for the default case (no locking policy specified). -- Reset to first character (uppercase) of locking policy name if a -- valid pragma Locking_Policy is encountered. Look_In_Primary_Dir : Boolean := True; -- GNAT, GNATBIND, GNATMAKE -- Set to False if a -I- was present on the command line. -- When True we are allowed to look in the primary directory to locate -- other source or library files. Mapping_File_Name : String_Ptr := null; -- GNAT -- File name of mapping between unit names, file names and path names. -- (given by switch -gnatem) Maximum_Errors : Int := 9999; -- GNAT, GNATBIND -- Maximum number of errors before compilation is terminated Maximum_File_Name_Length : Int; -- GNAT, GNATBIND -- Maximum number of characters allowed in a file name, not counting the -- extension, as set by the appropriate switch. If no switch is given, -- then this value is initialized by Osint to the appropriate value. Maximum_Processes : Positive := 1; -- GNATMAKE -- Maximum number of processes that should be spawned to carry out -- compilations. Minimal_Recompilation : Boolean := False; -- GNATMAKE -- Set to True if minimal recompilation mode requested. No_Stdlib : Boolean := False; -- GNATMAKE -- Set to True if no default library search dirs added to search list. No_Stdinc : Boolean := False; -- GNATMAKE -- Set to True if no default source search dirs added to search list. No_Main_Subprogram : Boolean := False; -- GNATMAKE, GNATBIND -- Set to True if compilation/binding of a program without main -- subprogram requested. Normalize_Scalars : Boolean := False; -- GNAT -- Set True if a pragma Normalize_Scalars applies to the current unit. -- Note that Init_Or_Norm_Scalars is also set to True if this is True. No_Run_Time : Boolean := False; -- GNAT -- Set True if a valid pragma No_Run_Time is processed or if the -- flag Targparm.High_Integrity_Mode_On_Target is set True. type Operating_Mode_Type is (Check_Syntax, Check_Semantics, Generate_Code); Operating_Mode : Operating_Mode_Type := Generate_Code; -- GNAT -- Indicates the operating mode of the compiler. The default is generate -- code, which runs the parser, semantics and backend. Switches can be -- used to set syntax checking only mode, or syntax and semantics checking -- only mode. Operating_Mode can also be modified as a result of detecting -- errors during the compilation process. In particular if any error is -- detected then this flag is reset from Generate_Code to Check_Semantics -- after generating an error message. Output_File_Name_Present : Boolean := False; -- GNATBIND, GNAT -- Set to True when the output C file name is given with option -o -- for GNATBIND or when the object file name is given with option -- -gnatO for GNAT. Output_Linker_Option_List : Boolean := False; -- GNATBIND -- True if output of list of linker options is requested (-K switch set) Output_Object_List : Boolean := False; -- GNATBIND -- True if output of list of objects is requested (-O switch set) Pessimistic_Elab_Order : Boolean := False; -- GNATBIND -- True if pessimistic elaboration order is to be chosen (-p switch set) Polling_Required : Boolean := False; -- GNAT -- Set to True if polling for asynchronous abort is enabled by using -- the -gnatP option for GNAT. Print_Generated_Code : Boolean := False; -- GNAT -- Set to True to enable output of generated code in source form. This -- flag is set by the -gnatG switch. Propagate_Exceptions : Boolean := False; -- GNAT -- Indicates if subprogram descriptor exception tables should be -- built for imported subprograms. Set True if a Propagate_Exceptions -- pragma applies to the extended main unit. Queuing_Policy : Character := ' '; -- GNAT -- Set to ' ' for the default case (no queuing policy specified). Reset to -- Reset to first character (uppercase) of locking policy name if a valid -- Queuing_Policy pragma is encountered. Quiet_Output : Boolean := False; -- GNATMAKE -- Set to True if the list of compilation commands should not be output. Shared_Libgnat : Boolean; -- GNATBIND -- Set to True if a shared libgnat is requested by using the -shared -- option for GNATBIND and to False when using the -static option. The -- value of this switch is set by Gnatbind.Scan_Bind_Arg. Software_Overflow_Checking : Boolean; -- GNAT -- Set to True by Osint.Initialize if the target requires the software -- approach to integer arithmetic overflow checking (i.e. the use of -- double length arithmetic followed by a range check). Set to False -- if the target implements hardware overflow checking. Stack_Checking_Enabled : Boolean; -- GNAT -- Set to indicate if -fstack-check switch is set for the compilation. -- True means that the switch is set, so that stack checking is enabled. -- False means that the switch is not set (no stack checking). This -- value is obtained from the external imported value flag_stack_check -- in the gcc backend (see Frontend) and may be referenced throughout -- the compilation phases. Strict_Math : aliased Boolean := False; -- GNAT -- This switch is set True if the current unit is to be compiled in -- strict math mode. The effect is to cause certain library file name -- substitutions to implement strict math semantics. See the routine -- Adjust_File_Name_For_Configuration, and also the configuration -- in the body of Opt. -- -- Note: currently this switch is always False. Eventually it will be -- settable by a switch and a configuration pragma. Style_Check : Boolean := False; -- GNAT -- Set True to perform style checks. Activates checks carried out -- in package Style (see body of this package for details of checks) -- This flag is set True by either the -gnatg or -gnaty switches. System_Extend_Pragma_Arg : Node_Id := Empty; -- GNAT -- Set non-empty if and only if a correct Extend_System pragma was present -- in which case it points to the argument of the pragma, and the name can -- be located as Chars (Expression (System_Extend_Pragma_Arg)). Subunits_Missing : Boolean := False; -- This flag is set true if missing subunits are detected with code -- generation active. This causes code generation to be skipped. Suppress_Options : Suppress_Record; -- GNAT -- Flags set True to suppress corresponding check, i.e. add an implicit -- pragma Suppress at the outer level of each unit compiled. Note that -- these suppress actions can be overridden by the use of the Unsuppress -- pragma. This variable is initialized by Osint.Initialize. Table_Factor : Int := 1; -- Factor by which all initial table sizes set in Alloc are multiplied. -- Used in Table to calculate initial table sizes (the initial table -- size is the value in Alloc, used as the Table_Initial parameter -- value, multiplied by the factor given here. The default value is -- used if no -gnatT switch appears. Task_Dispatching_Policy : Character := ' '; -- GNAT -- Set to ' ' for the default case (no task dispatching policy specified). -- Reset to first character (uppercase) of task dispatching policy name -- if a valid Task_Dispatching_Policy pragma is encountered. Tasking_Used : Boolean := False; -- Set True if any tasking construct is encountered. Used to activate the -- output of the Q, L and T lines in ali files. Time_Slice_Set : Boolean := False; -- Set True if a pragma Time_Slice is processed in the main unit, or -- if the T switch is present to set a time slice value. Time_Slice_Value : Nat; -- Time slice value. Valid only if Time_Slice_Set is True, i.e. if a -- Time_Slice pragma has been processed. Set to the time slice value -- in microseconds. Negative values are stored as zero, and the value -- is not larger than 1_000_000_000 (1000 seconds). Values larger than -- this are reset to this maximum. Tolerate_Consistency_Errors : Boolean := False; -- GNATBIND -- Tolerate time stamp and other consistency errors. If this switch is -- set true, then inconsistencies result in warnings rather than errors. Tree_Output : Boolean := False; -- GNAT -- Set True to generate output tree file Try_Semantics : Boolean := False; -- GNAT -- Flag set to force attempt at semantic analysis, even if parser errors -- occur. This will probably cause blowups at this stage in the game. On -- the other hand, most such blowups will be caught cleanly and simply -- say compilation abandoned. Unique_Error_Tag : Boolean := Tag_Errors; -- GNAT -- Indicates if error messages are to be prefixed by the string error: -- Initialized from Tag_Errors, can be forced on with the -gnatU switch. Unreserve_All_Interrupts : Boolean := False; -- GNAT, GNATBIND -- Normally set False, set True if a valid Unreserve_All_Interrupts -- pragma appears anywhere in the main unit for GNAT, or if any ALI -- file has the corresponding attribute set in GNATBIND. Upper_Half_Encoding : Boolean := False; -- GNAT -- Normally set False, indicating that upper half ASCII characters are -- used in the normal way to represent themselves. If the wide character -- encoding method uses the upper bit for this encoding, then this flag -- is set True, and upper half characters in the source indicate the -- start of a wide character sequence. Usage_Requested : Boolean := False; -- GNAT, GNATBIND, GNATMAKE -- Set to True if h switch encountered requesting usage information Use_VADS_Size : Boolean := False; -- GNAT -- Set to True if a valid pragma Use_VADS_Size is processed Validity_Checks_On : Boolean := True; -- This flag determines if validity checking is on or off. The initial -- state is on, and the required default validity checks are active. The -- actual set of checks that is performed if Validity_Checks_On is set -- is defined by the switches in package Sem_Val. The Validity_Checks_On -- switch is controlled by pragma Validity_Checks (On | Off), and also -- some generated compiler code (typically code that has to do with -- validity check generation) is compiled with this switch set to False. Verbose_Mode : Boolean := False; -- GNAT, GNATBIND -- Set to True to get verbose mode (full error message text and location -- information sent to standard output, also header, copyright and summary) Warn_On_Biased_Rounding : Boolean := False; -- GNAT -- Set to True to generate warnings for static constants that are rounded -- in a manner inconsistent with unbiased rounding (round to even). Can -- be modified by use of -gnatwb/B. Warn_On_Hiding : Boolean := False; -- GNAT -- Set to True to generate warnings if a declared entity hides another -- entity. The default is that this warning is suppressed. Warn_On_Redundant_Constructs : Boolean := False; -- GNAT -- Set to True to generate warnings for redundant constructs (e.g. useless -- assignments/conversions). The default is that this warning is disabled. type Warning_Mode_Type is (Suppress, Normal, Treat_As_Error); Warning_Mode : Warning_Mode_Type := Normal; -- GNAT, GNATBIND -- Controls treatment of warning messages. If set to Suppress, warning -- messages are not generated at all. In Normal mode, they are generated -- but do not count as errors. In Treat_As_Error mode, warning messages -- are generated and are treated as errors. Wide_Character_Encoding_Method : WC_Encoding_Method := WCEM_Brackets; -- GNAT -- Method used for encoding wide characters in the source program. See -- description of type in unit System.WCh_Con for a list of the methods -- that are currently supported. Note that brackets notation is always -- recognized in source programs regardless of the setting of this -- variable. The default setting causes only the brackets notation -- to be recognized. If this is the main unit, this setting also -- controls the output of the W=? parameter in the ali file, which -- is used to provide the default for Wide_Text_IO files. Xref_Active : Boolean := True; -- GNAT -- Set if cross-referencing is enabled (i.e. xref info in ali files) Zero_Cost_Exceptions_Val : Boolean; Zero_Cost_Exceptions_Set : Boolean := False; -- GNAT -- These values are to record the setting of the zero cost exception -- handling mode set by argument switches (-gnatZ/-gnatL). If the -- value is set by one of these switches, then Zero_Cost_Exceptions_Set -- is set to True, and Zero_Cost_Exceptions_Val indicates the setting. -- This value is used to reset ZCX_By_Default_On_Target. ---------------------------- -- Configuration Settings -- ---------------------------- -- These are settings that are used to establish the mode at the start -- of each unit. The values defined below can be affected either by -- command line switches, or by the use of appropriate configuration -- pragmas in the gnat.adc file. Ada_83_Config : Boolean; -- GNAT -- This is the value of the configuration switch for Ada 83 mode, as set -- by the command line switch -gnat83, and possibly modified by the use -- of configuration pragmas Ada_95 and Ada_83 in the gnat.adc file. This -- switch is used to set the initial value for Ada_83 mode at the start -- of analysis of a unit. Note however, that the setting of this switch -- is ignored for internal and predefined units (which are always compiled -- in Ada 95 mode). Dynamic_Elaboration_Checks_Config : Boolean := False; -- GNAT -- Set True for dynamic elaboration checking mode, as set by the -gnatE -- switch or by the use of pragma Elaboration_Checking (Dynamic). Extensions_Allowed_Config : Boolean; -- GNAT -- This is the switch that indicates whether extensions are allowed. -- It can be set True either by use of the -gnatX switch, or by use -- of the configuration pragma Extensions_Allowed (On). It is always -- set to True for internal GNAT units, since extensions are always -- permitted in such units. External_Name_Exp_Casing_Config : External_Casing_Type; -- GNAT -- This is the value of the configuration switch that controls casing -- of external symbols for which an explicit external name is given. It -- can be set to Uppercase by the command line switch -gnatF, and further -- modified by the use of the configuration pragma External_Name_Casing -- in the gnat.adc file. This switch is used to set the initial value -- for External_Name_Exp_Casing at the start of analyzing each unit. -- Note however that the setting of this switch is ignored for internal -- and predefined units (which are always compiled with As_Is mode). External_Name_Imp_Casing_Config : External_Casing_Type; -- GNAT -- This is the value of the configuration switch that controls casing -- of external symbols where the external name is implicitly given. It -- can be set to Uppercase by the command line switch -gnatF, and further -- modified by the use of the configuration pragma External_Name_Casing -- in the gnat.adc file. This switch is used to set the initial value -- for External_Name_Imp_Casing at the start of analyzing each unit. -- Note however that the setting of this switch is ignored for internal -- and predefined units (which are always compiled with Lowercase mode). Polling_Required_Config : Boolean; -- GNAT -- This is the value of the configuration switch that controls polling -- mode. It can be set True by the command line switch -gnatP, and then -- further modified by the use of pragma Polling in the gnat.adc file. -- This switch is used to set the initial value for Polling_Required -- at the start of analyzing each unit. Use_VADS_Size_Config : Boolean; -- GNAT -- This is the value of the configuration switch that controls the use -- of VADS_Size instead of Size whereever the attribute Size is used. -- It can be set True by the use of the pragma Use_VADS_Size in the -- gnat.adc file. This switch is used to set the initial value for -- Use_VADS_Size at the start of analyzing each unit. Note however that -- the setting of this switch is ignored for internal and predefined -- units (which are always compiled with the standard Size semantics). type Config_Switches_Type is private; -- Type used to save values of the switches set from Config values procedure Save_Opt_Config_Switches (Save : out Config_Switches_Type); -- This procedure saves the current values of the switches which are -- initialized from the above Config values, and then resets these -- switches according to the Config value settings. procedure Set_Opt_Config_Switches (Internal_Unit : Boolean); -- This procedure sets the switches to the appropriate initial values. -- The parameter Internal_Unit is True for an internal or predefined -- unit, and affects the way the switches are set (see above). procedure Restore_Opt_Config_Switches (Save : Config_Switches_Type); -- This procedure restores a set of switch values previously saved -- by a call to Save_Opt_Switches. procedure Register_Opt_Config_Switches; -- This procedure is called after processing the gnat.adc file to record -- the values of the Config switches, as possibly modified by the use -- of command line switches and configuration pragmas. ------------------------ -- Other Global Flags -- ------------------------ Expander_Active : Boolean := False; -- A flag that indicates if expansion is active (True) or deactivated -- (False). When expansion is deactivated all calls to expander routines -- have no effect. Note that the initial setting of False is merely to -- prevent saving of an undefined value for an initial call to the -- Expander_Mode_Save_And_Set procedure. For more information on the -- use of this flag, see package Expander. Indeed this flag might more -- logically be in the spec of Expander, but it is referenced by Errout, -- and it really seems wrong for Errout to depend on Expander. ----------------------- -- Tree I/O Routines -- ----------------------- procedure Tree_Read; -- Reads switch settings from current tree file using Tree_Read procedure Tree_Write; -- Writes out switch settings to current tree file using Tree_Write private type Config_Switches_Type is record Ada_83 : Boolean; Dynamic_Elaboration_Checks : Boolean; Extensions_Allowed : Boolean; External_Name_Exp_Casing : External_Casing_Type; External_Name_Imp_Casing : External_Casing_Type; Polling_Required : Boolean; Use_VADS_Size : Boolean; end record; end Opt;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Conversions; use Ada.Characters.Conversions; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Langkit_Support.Text; with Libadalang.Analysis; with Libadalang.Helpers; with Libadalang.Unparsing; with GNATCOLL; use GNATCOLL; with GNATCOLL.VFS; with GNATCOLL.Opt_Parse; with GNATCOLL.Traces; with GNATCOLL.Strings; with GNAT.OS_Lib; with Langkit_Support.Diagnostics; with Libadalang.Common; with Libadalang.Rewriting; with Libadalang.Expr_Eval; with Offmt_Lib; with Offmt_Lib.Parser; with Offmt_Lib.Rewrite; with Offmt_Lib.Detection; with Offmt_Lib.Storage; with Offmt_Lib.Decoding; procedure Offmt_Tool is package Helpers renames Libadalang.Helpers; package LAL renames Libadalang.Analysis; package LALU renames Libadalang.Unparsing; package LALCO renames Libadalang.Common; package LALRW renames Libadalang.Rewriting; package LALEXPR renames Libadalang.Expr_Eval; All_Traces : Offmt_Lib.Trace_Map; function Base_Name (Full_Path : String) return String; procedure Setup (Ctx : Helpers.App_Context; Jobs : Helpers.App_Job_Context_Array); procedure Process_Unit (Job_Ctx : Helpers.App_Job_Context; Unit : LAL.Analysis_Unit); procedure Post_Process (Ctx : Helpers.App_Context; Jobs : Helpers.App_Job_Context_Array); procedure Output_Unit (Job_Ctx : Libadalang.Helpers.App_Job_Context; Unit : Libadalang.Analysis.Analysis_Unit; Out_Dir_Path : GNATCOLL.Strings.XString); procedure Output_Map (Map : Offmt_Lib.Trace_Map); function Map_Filename return String; procedure Handle_Log_Call (RH : LALRW.Rewriting_Handle; Node : LAL.Call_Stmt'Class); package App is new Helpers.App (Name => To_String (Offmt_Lib.Log_Root_Pkg), Description => "Offloaded string format", App_Setup => Setup, App_Post_Process => Post_Process, Process_Unit => Process_Unit); package Output_Dir is new GNATCOLL.Opt_Parse.Parse_Option (Parser => App.Args.Parser, Long => "--output-dir", Arg_Type => GNATCOLL.Strings.XString, Convert => GNATCOLL.Opt_Parse.Convert, Default_Val => GNATCOLL.Strings.Null_XString, Help => "The directory in which to output the instrumented ada units." & "When invoked with a project file, this path is treated as " & "relative to the (sub-)projects' object directories, unless " & "this is an absolute path."); Instr_Mode_Long : constant String := "--instrument"; Decode_Mode_Long : constant String := "--decode"; package Instrument_Mode is new GNATCOLL.Opt_Parse.Parse_Flag (Parser => App.Args.Parser, Long => Instr_Mode_Long, Help => "Enable instrumentation mode"); package Decode_Mode is new GNATCOLL.Opt_Parse.Parse_Flag (Parser => App.Args.Parser, Long => Decode_Mode_Long, Help => "Enable decode mode"); --------------- -- Base_Name -- --------------- function Base_Name (Full_Path : String) return String is use GNATCOLL.VFS; begin return +Create (+Full_Path).Base_Name; end Base_Name; ------------------ -- Map_Filename -- ------------------ function Map_Filename return String is Out_Dir : constant VFS.Virtual_File := VFS.Create_From_Base (VFS."+" (Strings.To_String (Output_Dir.Get))); Out_File : constant VFS.Virtual_File := VFS.Join (Out_Dir, "offmt_map.toml"); begin return VFS."+" (Out_File.Full_Name); end Map_Filename; --------------------- -- Handle_Log_Call -- --------------------- procedure Handle_Log_Call (RH : LALRW.Rewriting_Handle; Node : LAL.Call_Stmt'Class) is Call : LAL.Call_Expr; begin if Offmt_Lib.Detection.Check_Defmt_Log_Call (Node, Call) then declare S : constant LAL.Ada_Node := Call.F_Suffix; Arg : LAL.Expr; begin Arg := S.Child (1).As_Param_Assoc.F_R_Expr; declare Arg_Val : constant LALEXPR.Eval_Result := LALEXPR.Expr_Eval (Arg); begin case Arg_Val.Kind is when LALEXPR.String_Lit => declare use Langkit_Support.Text; Txt : constant Text_Type := To_Text (Arg_Val.String_Result); Str : constant String := Image (Txt); Trace : constant Offmt_Lib.Trace := Offmt_Lib.Parser.Parse (Str); begin Put_Line (Str); Offmt_Lib.Pretty_Print (Trace); Offmt_Lib.Rewrite.Rewrite_Log_Call (RH, Node, Trace); All_Traces.Include (Trace.Id, Trace); end; when others => raise Program_Error with "String lit expected"; end case; end; end; end if; end Handle_Log_Call; ------------------ -- Process_Unit -- ------------------ procedure Process_Unit (Job_Ctx : Helpers.App_Job_Context; Unit : LAL.Analysis_Unit) is RH : LALRW.Rewriting_Handle := LALRW.Start_Rewriting (Unit.Context); function Process_Node (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status; ------------------ -- Process_Node -- ------------------ function Process_Node (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status is begin case Node.Kind is when LALCO.Ada_Call_Stmt => Handle_Log_Call (RH, Node.As_Call_Stmt); when others => null; end case; return LALCO.Into; end Process_Node; use type LALCO.Ada_Node_Kind_Type; begin if Unit.Root.Kind /= LALCO.Ada_Compilation_Unit then raise Program_Error with "Unhandled multi compilation unit files"; end if; Put_Line (" [Ada] " & Base_Name (Unit.Get_Filename)); if Unit.Has_Diagnostics then Put_Line ("Invalid ada unit " & Unit.Get_Filename); else Unit.Root.Traverse (Process_Node'Access); declare Result : constant LALRW.Apply_Result := LALRW.Apply (RH); begin if Result.Success then Put_Line ("Success Rewrite"); Output_Unit (Job_Ctx, Unit, Output_Dir.Get); else Put_Line ("Could not apply rewritings for " & Result.Unit.Get_Filename); declare use Langkit_Support.Diagnostics; procedure Test (Cursor : Diagnostics_Vectors.Cursor); procedure Test (Cursor : Diagnostics_Vectors.Cursor) is begin Put_Line (Langkit_Support.Diagnostics.To_Pretty_String ( Diagnostics_Vectors.Element (Cursor))); end Test; begin Result.Diagnostics.Iterate (Test'Access); end; raise Program_Error with "Could not apply rewritings"; end if; end; end if; end Process_Unit; ----------- -- Setup -- ----------- procedure Setup (Ctx : Helpers.App_Context; Jobs : Helpers.App_Job_Context_Array) is pragma Unreferenced (Jobs, Ctx); begin Traces.Parse_Config_File; if Instrument_Mode.Get and then Decode_Mode.Get then Put_Line ("Only one mode can be used (" & Instr_Mode_Long & " | " & Decode_Mode_Long & ")"); GNAT.OS_Lib.OS_Exit (1); elsif Instrument_Mode.Get then Put_Line ("Instrument"); elsif Decode_Mode.Get then Offmt_Lib.Decoding.Decode (Map_Filename); GNAT.OS_Lib.OS_Exit (0); else Put_Line ("Missing mode switch (" & Instr_Mode_Long & " | " & Decode_Mode_Long & ")"); GNAT.OS_Lib.OS_Exit (1); end if; end Setup; ----------------- -- Output_Unit -- ----------------- procedure Output_Unit (Job_Ctx : Libadalang.Helpers.App_Job_Context; Unit : Libadalang.Analysis.Analysis_Unit; Out_Dir_Path : Strings.XString) is pragma Unreferenced (Job_Ctx); use type Strings.XString; Content : constant String := LALU.Unparse (Unit.Root); Orig_Unit : constant VFS.Virtual_File := VFS.Create (VFS."+" (Unit.Get_Filename)); Unit_Base_Name : constant VFS.Filesystem_String := VFS.Base_Name (Orig_Unit); begin if Out_Dir_Path = Strings.Null_XString then Put_Line ("-- " & VFS."+" (Unit_Base_Name)); Put_Line (Content); New_Line; else declare Out_Dir : constant VFS.Virtual_File := VFS.Create_From_Base (VFS."+" (Strings.To_String (Out_Dir_Path))); New_Unit : VFS.Writable_File := VFS.Join (Out_Dir, Unit_Base_Name).Write_File; begin VFS.Write (New_Unit, Content); VFS.Close (New_Unit); end; end if; end Output_Unit; ---------------- -- Output_Map -- ---------------- procedure Output_Map (Map : Offmt_Lib.Trace_Map) is use Offmt_Lib.Storage; Store_Res : constant Store_Result := Offmt_Lib.Storage.Store (Map, Map_Filename); begin if Store_Res.Success then Put_Line ("Trace map saved."); else Put_Line ("Cannot store trace map: " & To_String (Store_Res.Msg)); end if; end Output_Map; ------------------ -- Post_Process -- ------------------ procedure Post_Process (Ctx : Helpers.App_Context; Jobs : Helpers.App_Job_Context_Array) is pragma Unreferenced (Ctx, Jobs); begin Output_Map (All_Traces); end Post_Process; begin App.Run; end Offmt_Tool;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y M B O L S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2003-2005 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the VMS version of this package with Ada.Exceptions; use Ada.Exceptions; with Ada.Sequential_IO; with Ada.Text_IO; use Ada.Text_IO; package body Symbols is Case_Sensitive : constant String := "case_sensitive="; Symbol_Vector : constant String := "SYMBOL_VECTOR=("; Equal_Data : constant String := "=DATA)"; Equal_Procedure : constant String := "=PROCEDURE)"; Gsmatch : constant String := "gsmatch="; Gsmatch_Lequal : constant String := "gsmatch=lequal,"; Symbol_File_Name : String_Access := null; -- Name of the symbol file Sym_Policy : Policy := Autonomous; -- The symbol policy. Set by Initialize Major_ID : Integer := 1; -- The Major ID. May be modified by Initialize if Library_Version is -- specified or if it is read from the reference symbol file. Soft_Major_ID : Boolean := True; -- False if library version is specified in procedure Initialize. -- When True, Major_ID may be modified if found in the reference symbol -- file. Minor_ID : Natural := 0; -- The Minor ID. May be modified if read from the reference symbol file Soft_Minor_ID : Boolean := True; -- False if symbol policy is Autonomous, if library version is specified -- in procedure Initialize and is not the same as the major ID read from -- the reference symbol file. When True, Minor_ID may be increased in -- Compliant symbol policy. subtype Byte is Character; -- Object files are stream of bytes, but some of these bytes, those for -- the names of the symbols, are ASCII characters. package Byte_IO is new Ada.Sequential_IO (Byte); use Byte_IO; File : Byte_IO.File_Type; -- Each object file is read as a stream of bytes (characters) function Equal (Left, Right : Symbol_Data) return Boolean; -- Test for equality of symbols function Image (N : Integer) return String; -- Returns the image of N, without the initial space ----------- -- Equal -- ----------- function Equal (Left, Right : Symbol_Data) return Boolean is begin return Left.Name /= null and then Right.Name /= null and then Left.Name.all = Right.Name.all and then Left.Kind = Right.Kind and then Left.Present = Right.Present; end Equal; ----------- -- Image -- ----------- function Image (N : Integer) return String is Result : constant String := N'Img; begin if Result (Result'First) = ' ' then return Result (Result'First + 1 .. Result'Last); else return Result; end if; end Image; ---------------- -- Initialize -- ---------------- procedure Initialize (Symbol_File : String; Reference : String; Symbol_Policy : Policy; Quiet : Boolean; Version : String; Success : out Boolean) is File : Ada.Text_IO.File_Type; Line : String (1 .. 1_000); Last : Natural; begin -- Record the symbol file name Symbol_File_Name := new String'(Symbol_File); -- Record the policy Sym_Policy := Symbol_Policy; -- Record the version (Major ID) if Version = "" then Major_ID := 1; Soft_Major_ID := True; else begin Major_ID := Integer'Value (Version); Soft_Major_ID := False; if Major_ID <= 0 then raise Constraint_Error; end if; exception when Constraint_Error => if not Quiet then Put_Line ("Version """ & Version & """ is illegal."); Put_Line ("On VMS, version must be a positive number"); end if; Success := False; return; end; end if; Minor_ID := 0; Soft_Minor_ID := Sym_Policy /= Autonomous; -- Empty the symbol tables Symbol_Table.Set_Last (Original_Symbols, 0); Symbol_Table.Set_Last (Complete_Symbols, 0); -- Assume that everything will be fine Success := True; -- If policy is Compliant or Controlled, attempt to read the reference -- file. If policy is Restricted, attempt to read the symbol file. if Sym_Policy /= Autonomous then case Sym_Policy is when Autonomous => null; when Compliant | Controlled => begin Open (File, In_File, Reference); exception when Ada.Text_IO.Name_Error => Success := False; return; when X : others => if not Quiet then Put_Line ("could not open """ & Reference & """"); Put_Line (Exception_Message (X)); end if; Success := False; return; end; when Restricted => begin Open (File, In_File, Symbol_File); exception when Ada.Text_IO.Name_Error => Success := False; return; when X : others => if not Quiet then Put_Line ("could not open """ & Symbol_File & """"); Put_Line (Exception_Message (X)); end if; Success := False; return; end; end case; -- Read line by line while not End_Of_File (File) loop Get_Line (File, Line, Last); -- Ignore empty lines if Last = 0 then null; -- Ignore lines starting with "case_sensitive=" elsif Last > Case_Sensitive'Length and then Line (1 .. Case_Sensitive'Length) = Case_Sensitive then null; -- Line starting with "SYMBOL_VECTOR=(" elsif Last > Symbol_Vector'Length and then Line (1 .. Symbol_Vector'Length) = Symbol_Vector then -- SYMBOL_VECTOR=(<symbol>=DATA) if Last > Symbol_Vector'Length + Equal_Data'Length and then Line (Last - Equal_Data'Length + 1 .. Last) = Equal_Data then Symbol_Table.Increment_Last (Original_Symbols); Original_Symbols.Table (Symbol_Table.Last (Original_Symbols)) := (Name => new String'(Line (Symbol_Vector'Length + 1 .. Last - Equal_Data'Length)), Kind => Data, Present => True); -- SYMBOL_VECTOR=(<symbol>=PROCEDURE) elsif Last > Symbol_Vector'Length + Equal_Procedure'Length and then Line (Last - Equal_Procedure'Length + 1 .. Last) = Equal_Procedure then Symbol_Table.Increment_Last (Original_Symbols); Original_Symbols.Table (Symbol_Table.Last (Original_Symbols)) := (Name => new String'(Line (Symbol_Vector'Length + 1 .. Last - Equal_Procedure'Length)), Kind => Proc, Present => True); -- Anything else is incorrectly formatted else if not Quiet then Put_Line ("symbol file """ & Reference & """ is incorrectly formatted:"); Put_Line ("""" & Line (1 .. Last) & """"); end if; Close (File); Success := False; return; end if; -- Lines with "gsmatch=lequal," or "gsmatch=equal," elsif Last > Gsmatch'Length and then Line (1 .. Gsmatch'Length) = Gsmatch then declare Start : Positive := Gsmatch'Length + 1; Finish : Positive := Start; OK : Boolean := True; ID : Integer; begin -- First, look for the first coma loop if Start >= Last - 1 then OK := False; exit; elsif Line (Start) = ',' then Start := Start + 1; exit; else Start := Start + 1; end if; end loop; Finish := Start; -- If the comma is found, get the Major and the Minor IDs if OK then loop if Line (Finish) not in '0' .. '9' or else Finish >= Last - 1 then OK := False; exit; end if; exit when Line (Finish + 1) = ','; Finish := Finish + 1; end loop; end if; if OK then ID := Integer'Value (Line (Start .. Finish)); OK := ID /= 0; -- If Soft_Major_ID is True, it means that -- Library_Version was not specified. if Soft_Major_ID then Major_ID := ID; -- If the Major ID in the reference file is different -- from the Library_Version, then the Minor ID will be 0 -- because there is no point in taking the Minor ID in -- the reference file, or incrementing it. So, we set -- Soft_Minor_ID to False, so that we don't modify -- the Minor_ID later. elsif Major_ID /= ID then Soft_Minor_ID := False; end if; Start := Finish + 2; Finish := Start; loop if Line (Finish) not in '0' .. '9' then OK := False; exit; end if; exit when Finish = Last; Finish := Finish + 1; end loop; -- Only set Minor_ID if Soft_Minor_ID is True (see above) if OK and then Soft_Minor_ID then Minor_ID := Integer'Value (Line (Start .. Finish)); end if; end if; -- If OK is not True, that means the line is not correctly -- formatted. if not OK then if not Quiet then Put_Line ("symbol file """ & Reference & """ is incorrectly formatted"); Put_Line ("""" & Line (1 .. Last) & """"); end if; Close (File); Success := False; return; end if; end; -- Anything else is incorrectly formatted else if not Quiet then Put_Line ("unexpected line in symbol file """ & Reference & """"); Put_Line ("""" & Line (1 .. Last) & """"); end if; Close (File); Success := False; return; end if; end loop; Close (File); end if; end Initialize; ---------------- -- Processing -- ---------------- package body Processing is separate; -------------- -- Finalize -- -------------- procedure Finalize (Quiet : Boolean; Success : out Boolean) is File : Ada.Text_IO.File_Type; -- The symbol file S_Data : Symbol_Data; -- A symbol Cur : Positive := 1; -- Most probable index in the Complete_Symbols of the current symbol -- in Original_Symbol. Found : Boolean; begin -- Nothing to be done if Initialize has never been called if Symbol_File_Name = null then Success := False; else -- First find if the symbols in the reference symbol file are also -- in the object files. Note that this is not done if the policy is -- Autonomous, because no reference symbol file has been read. -- Expect the first symbol in the symbol file to also be the first -- in Complete_Symbols. Cur := 1; for Index_1 in 1 .. Symbol_Table.Last (Original_Symbols) loop S_Data := Original_Symbols.Table (Index_1); Found := False; First_Object_Loop : for Index_2 in Cur .. Symbol_Table.Last (Complete_Symbols) loop if Equal (S_Data, Complete_Symbols.Table (Index_2)) then Cur := Index_2 + 1; Complete_Symbols.Table (Index_2).Present := False; Found := True; exit First_Object_Loop; end if; end loop First_Object_Loop; -- If the symbol could not be found between Cur and Last, try -- before Cur. if not Found then Second_Object_Loop : for Index_2 in 1 .. Cur - 1 loop if Equal (S_Data, Complete_Symbols.Table (Index_2)) then Cur := Index_2 + 1; Complete_Symbols.Table (Index_2).Present := False; Found := True; exit Second_Object_Loop; end if; end loop Second_Object_Loop; end if; -- If the symbol is not found, mark it as such in the table if not Found then if (not Quiet) or else Sym_Policy = Controlled then Put_Line ("symbol """ & S_Data.Name.all & """ is no longer present in the object files"); end if; if Sym_Policy = Controlled or else Sym_Policy = Restricted then Success := False; return; -- Any symbol that is undefined in the reference symbol file -- triggers an increase of the Major ID, because the new -- version of the library is no longer compatible with -- existing executables. elsif Soft_Major_ID then Major_ID := Major_ID + 1; Minor_ID := 0; Soft_Major_ID := False; Soft_Minor_ID := False; end if; Original_Symbols.Table (Index_1).Present := False; Free (Original_Symbols.Table (Index_1).Name); if Soft_Minor_ID then Minor_ID := Minor_ID + 1; Soft_Minor_ID := False; end if; end if; end loop; if Sym_Policy /= Restricted then -- Append additional symbols, if any, to the Original_Symbols -- table. for Index in 1 .. Symbol_Table.Last (Complete_Symbols) loop S_Data := Complete_Symbols.Table (Index); if S_Data.Present then if Sym_Policy = Controlled then Put_Line ("symbol """ & S_Data.Name.all & """ is not in the reference symbol file"); Success := False; return; elsif Soft_Minor_ID then Minor_ID := Minor_ID + 1; Soft_Minor_ID := False; end if; Symbol_Table.Increment_Last (Original_Symbols); Original_Symbols.Table (Symbol_Table.Last (Original_Symbols)) := S_Data; Complete_Symbols.Table (Index).Present := False; end if; end loop; -- Create the symbol file Create (File, Ada.Text_IO.Out_File, Symbol_File_Name.all); Put (File, Case_Sensitive); Put_Line (File, "yes"); -- Put a line in the symbol file for each symbol in symbol table for Index in 1 .. Symbol_Table.Last (Original_Symbols) loop if Original_Symbols.Table (Index).Present then Put (File, Symbol_Vector); Put (File, Original_Symbols.Table (Index).Name.all); if Original_Symbols.Table (Index).Kind = Data then Put_Line (File, Equal_Data); else Put_Line (File, Equal_Procedure); end if; Free (Original_Symbols.Table (Index).Name); end if; end loop; Put (File, Case_Sensitive); Put_Line (File, "NO"); -- Put the version IDs Put (File, Gsmatch_Lequal); Put (File, Image (Major_ID)); Put (File, ','); Put_Line (File, Image (Minor_ID)); -- And we are done Close (File); -- Reset both tables Symbol_Table.Set_Last (Original_Symbols, 0); Symbol_Table.Set_Last (Complete_Symbols, 0); -- Clear the symbol file name Free (Symbol_File_Name); end if; Success := True; end if; exception when X : others => Put_Line ("unexpected exception raised while finalizing """ & Symbol_File_Name.all & """"); Put_Line (Exception_Information (X)); Success := False; end Finalize; end Symbols;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . D Y N A M I C _ H T A B L E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2005, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 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. -- -- -- ------------------------------------------------------------------------------ -- Hash table searching routines -- This package contains two separate packages. The Simple_HTable package -- provides a very simple abstraction that associates one element to one -- key value and takes care of all allocations automatically using the heap. -- The Static_HTable package provides a more complex interface that allows -- complete control over allocation. -- This package provides a facility similar to that of GNAT.HTable, except -- that this package declares types that can be used to define dynamic -- instances of hash tables, while instantiations in GNAT.HTable creates a -- single instance of the hash table. -- Note that this interface should remain synchronized with those in -- GNAT.HTable to keep as much coherency as possible between these two -- related units. with Ada.Unchecked_Deallocation; package GNAT.Dynamic_HTables is ------------------- -- Static_HTable -- ------------------- -- A low-level Hash-Table abstraction, not as easy to instantiate as -- Simple_HTable but designed to allow complete control over the -- allocation of necessary data structures. Particularly useful when -- dynamic allocation is not desired. The model is that each Element -- contains its own Key that can be retrieved by Get_Key. Furthermore, -- Element provides a link that can be used by the HTable for linking -- elements with same hash codes: -- Element -- +-------------------+ -- | Key | -- +-------------------+ -- : other data : -- +-------------------+ -- | Next Elmt | -- +-------------------+ generic type Header_Num is range <>; -- An integer type indicating the number and range of hash headers type Element (<>) is limited private; -- The type of element to be stored type Elmt_Ptr is private; -- The type used to reference an element (will usually be an access -- type, but could be some other form of type such as an integer type). Null_Ptr : Elmt_Ptr; -- The null value of the Elmt_Ptr type with procedure Set_Next (E : Elmt_Ptr; Next : Elmt_Ptr); with function Next (E : Elmt_Ptr) return Elmt_Ptr; -- The type must provide an internal link for the sake of the -- staticness of the HTable. type Key is limited private; with function Get_Key (E : Elmt_Ptr) return Key; with function Hash (F : Key) return Header_Num; with function Equal (F1, F2 : Key) return Boolean; package Static_HTable is type Instance is private; Nil : constant Instance; procedure Reset (T : in out Instance); -- Resets the hash table by releasing all memory associated with -- it. The hash table can safely be reused after this call. For the -- most common case where Elmt_Ptr is an access type, and Null_Ptr is -- null, this is only needed if the same table is reused in a new -- context. If Elmt_Ptr is other than an access type, or Null_Ptr is -- other than null, then Reset must be called before the first use of -- the hash table. procedure Set (T : in out Instance; E : Elmt_Ptr); -- Insert the element pointer in the HTable function Get (T : Instance; K : Key) return Elmt_Ptr; -- Returns the latest inserted element pointer with the given Key -- or null if none. procedure Remove (T : Instance; K : Key); -- Removes the latest inserted element pointer associated with the -- given key if any, does nothing if none. function Get_First (T : Instance) return Elmt_Ptr; -- Returns Null_Ptr if the Htable is empty, otherwise returns one -- non specified element. There is no guarantee that 2 calls to this -- function will return the same element. function Get_Next (T : Instance) return Elmt_Ptr; -- Returns a non-specified element that has not been returned by the -- same function since the last call to Get_First or Null_Ptr if -- there is no such element or Get_First has bever been called. If -- there is no call to 'Set' in between Get_Next calls, all the -- elements of the Htable will be traversed. private type Instance_Data; type Instance is access all Instance_Data; Nil : constant Instance := null; end Static_HTable; ------------------- -- Simple_HTable -- ------------------- -- A simple hash table abstraction, easy to instantiate, easy to use. -- The table associates one element to one key with the procedure Set. -- Get retrieves the Element stored for a given Key. The efficiency of -- retrieval is function of the size of the Table parameterized by -- Header_Num and the hashing function Hash. generic type Header_Num is range <>; -- An integer type indicating the number and range of hash headers type Element is private; -- The type of element to be stored No_Element : Element; -- The object that is returned by Get when no element has been set for -- a given key type Key is private; with function Hash (F : Key) return Header_Num; with function Equal (F1, F2 : Key) return Boolean; package Simple_HTable is type Instance is private; Nil : constant Instance; procedure Set (T : in out Instance; K : Key; E : Element); -- Associates an element with a given key. Overrides any previously -- associated element. procedure Reset (T : in out Instance); -- Releases all memory associated with the table. The table can be -- reused after this call (it is automatically allocated on the first -- access to the table). function Get (T : Instance; K : Key) return Element; -- Returns the Element associated with a key or No_Element if the -- given key has not associated element procedure Remove (T : Instance; K : Key); -- Removes the latest inserted element pointer associated with the -- given key if any, does nothing if none. function Get_First (T : Instance) return Element; -- Returns No_Element if the Htable is empty, otherwise returns one -- non specified element. There is no guarantee that two calls to this -- function will return the same element, if the Htable has been -- modified between the two calls. function Get_Next (T : Instance) return Element; -- Returns a non-specified element that has not been returned by the -- same function since the last call to Get_First or No_Element if -- there is no such element. If there is no call to 'Set' in between -- Get_Next calls, all the elements of the Htable will be traversed. -- To guarantee that all the elements of the Htable will be traversed, -- no modification of the Htable (Set, Reset, Remove) should occur -- between a call to Get_First and subsequent consecutive calls to -- Get_Next, until one of these calls returns No_Element. private type Element_Wrapper; type Elmt_Ptr is access all Element_Wrapper; type Element_Wrapper is record K : Key; E : Element; Next : Elmt_Ptr; end record; procedure Free is new Ada.Unchecked_Deallocation (Element_Wrapper, Elmt_Ptr); procedure Set_Next (E : Elmt_Ptr; Next : Elmt_Ptr); function Next (E : Elmt_Ptr) return Elmt_Ptr; function Get_Key (E : Elmt_Ptr) return Key; package Tab is new Static_HTable (Header_Num => Header_Num, Element => Element_Wrapper, Elmt_Ptr => Elmt_Ptr, Null_Ptr => null, Set_Next => Set_Next, Next => Next, Key => Key, Get_Key => Get_Key, Hash => Hash, Equal => Equal); type Instance is new Tab.Instance; Nil : constant Instance := Instance (Tab.Nil); end Simple_HTable; end GNAT.Dynamic_HTables;
----------------------------------------------------------------------- -- awa-storages-services-tests -- Unit tests for storage service -- Copyright (C) 2012 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.Streams; with Ada.Strings.Unbounded; with Util.Test_Caller; with ADO; with ADO.Objects; with Security.Contexts; with AWA.Services.Contexts; with AWA.Storages.Modules; with AWA.Storages.Beans.Factories; with AWA.Tests.Helpers.Users; package body AWA.Storages.Services.Tests is use Util.Tests; use ADO; package Caller is new Util.Test_Caller (Test, "Storages.Services"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Storages.Services.Save (DATABASE)", Test_Create_Storage'Access); Caller.Add_Test (Suite, "Test AWA.Storages.Services.Save (FILE)", Test_File_Create_Storage'Access); Caller.Add_Test (Suite, "Test AWA.Storages.Services.Delete", Test_Delete_Storage'Access); Caller.Add_Test (Suite, "Test AWA.Storages.Services.Save_Folder, Folder_Bean", Test_Create_Folder'Access); Caller.Add_Test (Suite, "Test AWA.Storages.Services.Get_Local_File", Test_Get_Local_File'Access); end Add_Tests; -- ------------------------------ -- Save something in a storage element and keep track of the store id in the test <b>Id</b>. -- ------------------------------ procedure Save (T : in out Test) is Store : AWA.Storages.Models.Storage_Ref; begin T.Manager := AWA.Storages.Modules.Get_Storage_Manager; T.Assert (T.Manager /= null, "Null storage manager"); Store.Set_Mime_Type ("text/plain"); Store.Set_Name ("Makefile"); Store.Set_File_Size (1000); T.Manager.Save (Into => Store, Path => "Makefile", Storage => T.Kind); T.Assert (not Store.Is_Null, "Storage object should not be null"); T.Id := Store.Get_Id; T.Assert (T.Id > 0, "Invalid storage identifier"); end Save; -- ------------------------------ -- Load the storage element refered to by the test <b>Id</b>. -- ------------------------------ procedure Load (T : in out Test) is use type Ada.Streams.Stream_Element_Offset; Name : Ada.Strings.Unbounded.Unbounded_String; Mime : Ada.Strings.Unbounded.Unbounded_String; Date : Ada.Calendar.Time; Data : ADO.Blob_Ref; begin T.Manager := AWA.Storages.Modules.Get_Storage_Manager; T.Assert (T.Manager /= null, "Null storage manager"); T.Manager.Load (From => T.Id, Name => Name, Mime => Mime, Date => Date, Into => Data); T.Assert (not Data.Is_Null, "Null blob returned by load"); T.Assert (Data.Value.Len > 100, "Invalid length for the blob data"); end Load; -- ------------------------------ -- Test creation of a storage object -- ------------------------------ procedure Test_Create_Storage (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com"); T.Save; T.Load; end Test_Create_Storage; procedure Test_File_Create_Storage (T : in out Test) is begin T.Kind := AWA.Storages.Models.FILE; T.Test_Create_Storage; end Test_File_Create_Storage; -- ------------------------------ -- Test creation of a storage object and local file access after its creation. -- ------------------------------ procedure Test_Get_Local_File (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com"); T.Save; declare File : AWA.Storages.Storage_File; begin T.Manager.Get_Local_File (From => T.Id, Into => File); T.Assert (AWA.Storages.Get_Path (File)'Length > 0, "Invalid local file path"); end; end Test_Get_Local_File; -- ------------------------------ -- Test deletion of a storage object -- ------------------------------ procedure Test_Delete_Storage (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; Data : ADO.Blob_Ref; Name : Ada.Strings.Unbounded.Unbounded_String; Mime : Ada.Strings.Unbounded.Unbounded_String; Date : Ada.Calendar.Time; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com"); T.Save; T.Manager.Delete (T.Id); begin T.Manager.Load (From => T.Id, Name => Name, Mime => Mime, Date => Date, Into => Data); T.Assert (False, "No exception raised"); exception when ADO.Objects.NOT_FOUND => null; end; end Test_Delete_Storage; -- ------------------------------ -- Test creation of a storage folder -- ------------------------------ procedure Test_Create_Folder (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; Folder : AWA.Storages.Beans.Factories.Folder_Bean; Outcome : Ada.Strings.Unbounded.Unbounded_String; Upload : AWA.Storages.Beans.Factories.Upload_Bean; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com"); Folder.Module := AWA.Storages.Modules.Get_Storage_Module; Upload.Module := AWA.Storages.Modules.Get_Storage_Module; Folder.Set_Name ("Test folder name"); Folder.Save (Outcome); Util.Tests.Assert_Equals (T, "success", Outcome, "Invalid outcome returned by Save action"); Upload.Set_Value ("folderId", ADO.Objects.To_Object (Folder.Get_Key)); Util.Tests.Assert_Equals (T, "Test folder name", String '(Upload.Get_Folder.Get_Name), "Invalid folder name"); end Test_Create_Folder; end AWA.Storages.Services.Tests;
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32H743x.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package STM32_SVD.Ethernet is pragma Preelaborate; --------------- -- Registers -- --------------- subtype DMAMR_PR_Field is HAL.UInt3; -- DMA mode register type DMAMR_Register is record -- Software Reset SWR : Boolean := False; -- Read-only. DMA Tx or Rx Arbitration Scheme DA : Boolean := False; -- unspecified Reserved_2_10 : HAL.UInt9 := 16#0#; -- Read-only. Transmit priority TXPR : Boolean := False; -- Read-only. Priority ratio PR : DMAMR_PR_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Interrupt Mode INTM : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMAMR_Register use record SWR at 0 range 0 .. 0; DA at 0 range 1 .. 1; Reserved_2_10 at 0 range 2 .. 10; TXPR at 0 range 11 .. 11; PR at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; INTM at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; -- System bus mode register type DMASBMR_Register is record -- Fixed Burst Length FB : Boolean := False; -- unspecified Reserved_1_11 : HAL.UInt11 := 16#0#; -- Address-Aligned Beats AAL : Boolean := False; -- unspecified Reserved_13_13 : HAL.Bit := 16#0#; -- Read-only. Mixed Burst MB : Boolean := False; -- Read-only. Rebuild INCRx Burst RB : Boolean := False; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#101#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMASBMR_Register use record FB at 0 range 0 .. 0; Reserved_1_11 at 0 range 1 .. 11; AAL at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; MB at 0 range 14 .. 14; RB at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Interrupt status register type DMAISR_Register is record -- Read-only. DMA Channel Interrupt Status DC0IS : Boolean; -- unspecified Reserved_1_15 : HAL.UInt15; -- Read-only. MTL Interrupt Status MTLIS : Boolean; -- Read-only. MAC Interrupt Status MACIS : Boolean; -- unspecified Reserved_18_31 : HAL.UInt14; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMAISR_Register use record DC0IS at 0 range 0 .. 0; Reserved_1_15 at 0 range 1 .. 15; MTLIS at 0 range 16 .. 16; MACIS at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; subtype DMADSR_RPS0_Field is HAL.UInt4; subtype DMADSR_TPS0_Field is HAL.UInt4; -- Debug status register type DMADSR_Register is record -- Read-only. AHB Master Write Channel AXWHSTS : Boolean; -- unspecified Reserved_1_7 : HAL.UInt7; -- Read-only. DMA Channel Receive Process State RPS0 : DMADSR_RPS0_Field; -- Read-only. DMA Channel Transmit Process State TPS0 : DMADSR_TPS0_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMADSR_Register use record AXWHSTS at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; RPS0 at 0 range 8 .. 11; TPS0 at 0 range 12 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DMACCR_MSS_Field is HAL.UInt14; subtype DMACCR_DSL_Field is HAL.UInt3; -- Channel control register type DMACCR_Register is record -- Maximum Segment Size MSS : DMACCR_MSS_Field := 16#0#; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- 8xPBL mode PBLX8 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Descriptor Skip Length DSL : DMACCR_DSL_Field := 16#0#; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACCR_Register use record MSS at 0 range 0 .. 13; Reserved_14_15 at 0 range 14 .. 15; PBLX8 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DSL at 0 range 18 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype DMACTxCR_TXPBL_Field is HAL.UInt6; -- Channel transmit control register type DMACTxCR_Register is record -- Start or Stop Transmission Command ST : Boolean := False; -- unspecified Reserved_1_3 : HAL.UInt3 := 16#0#; -- Operate on Second Packet OSF : Boolean := False; -- unspecified Reserved_5_11 : HAL.UInt7 := 16#0#; -- TCP Segmentation Enabled TSE : Boolean := False; -- unspecified Reserved_13_15 : HAL.UInt3 := 16#0#; -- Transmit Programmable Burst Length TXPBL : DMACTxCR_TXPBL_Field := 16#0#; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACTxCR_Register use record ST at 0 range 0 .. 0; Reserved_1_3 at 0 range 1 .. 3; OSF at 0 range 4 .. 4; Reserved_5_11 at 0 range 5 .. 11; TSE at 0 range 12 .. 12; Reserved_13_15 at 0 range 13 .. 15; TXPBL at 0 range 16 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype DMACRxCR_RBSZ_Field is HAL.UInt14; subtype DMACRxCR_RXPBL_Field is HAL.UInt6; -- Channel receive control register type DMACRxCR_Register is record -- Start or Stop Receive Command SR : Boolean := False; -- Receive Buffer size RBSZ : DMACRxCR_RBSZ_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- RXPBL RXPBL : DMACRxCR_RXPBL_Field := 16#0#; -- unspecified Reserved_22_30 : HAL.UInt9 := 16#0#; -- DMA Rx Channel Packet Flush RPF : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACRxCR_Register use record SR at 0 range 0 .. 0; RBSZ at 0 range 1 .. 14; Reserved_15_15 at 0 range 15 .. 15; RXPBL at 0 range 16 .. 21; Reserved_22_30 at 0 range 22 .. 30; RPF at 0 range 31 .. 31; end record; subtype DMACTxDLAR_TDESLA_Field is HAL.UInt30; -- Channel Tx descriptor list address register type DMACTxDLAR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Start of Transmit List TDESLA : DMACTxDLAR_TDESLA_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACTxDLAR_Register use record Reserved_0_1 at 0 range 0 .. 1; TDESLA at 0 range 2 .. 31; end record; subtype DMACRxDLAR_RDESLA_Field is HAL.UInt30; -- Channel Rx descriptor list address register type DMACRxDLAR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Start of Receive List RDESLA : DMACRxDLAR_RDESLA_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACRxDLAR_Register use record Reserved_0_1 at 0 range 0 .. 1; RDESLA at 0 range 2 .. 31; end record; subtype DMACTxDTPR_TDT_Field is HAL.UInt30; -- Channel Tx descriptor tail pointer register type DMACTxDTPR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Transmit Descriptor Tail Pointer TDT : DMACTxDTPR_TDT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACTxDTPR_Register use record Reserved_0_1 at 0 range 0 .. 1; TDT at 0 range 2 .. 31; end record; subtype DMACRxDTPR_RDT_Field is HAL.UInt30; -- Channel Rx descriptor tail pointer register type DMACRxDTPR_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Receive Descriptor Tail Pointer RDT : DMACRxDTPR_RDT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACRxDTPR_Register use record Reserved_0_1 at 0 range 0 .. 1; RDT at 0 range 2 .. 31; end record; subtype DMACTxRLR_TDRL_Field is HAL.UInt10; -- Channel Tx descriptor ring length register type DMACTxRLR_Register is record -- Transmit Descriptor Ring Length TDRL : DMACTxRLR_TDRL_Field := 16#0#; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACTxRLR_Register use record TDRL at 0 range 0 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype DMACRxRLR_RDRL_Field is HAL.UInt10; -- Channel Rx descriptor ring length register type DMACRxRLR_Register is record -- Receive Descriptor Ring Length RDRL : DMACRxRLR_RDRL_Field := 16#0#; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACRxRLR_Register use record RDRL at 0 range 0 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- Channel interrupt enable register type DMACIER_Register is record -- Transmit Interrupt Enable TIE : Boolean := False; -- Transmit Stopped Enable TXSE : Boolean := False; -- Transmit Buffer Unavailable Enable TBUE : Boolean := False; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Receive Interrupt Enable RIE : Boolean := False; -- Receive Buffer Unavailable Enable RBUE : Boolean := False; -- Receive Stopped Enable RSE : Boolean := False; -- Receive Watchdog Timeout Enable RWTE : Boolean := False; -- Early Transmit Interrupt Enable ETIE : Boolean := False; -- Early Receive Interrupt Enable ERIE : Boolean := False; -- Fatal Bus Error Enable FBEE : Boolean := False; -- Context Descriptor Error Enable CDEE : Boolean := False; -- Abnormal Interrupt Summary Enable AIE : Boolean := False; -- Normal Interrupt Summary Enable NIE : Boolean := False; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACIER_Register use record TIE at 0 range 0 .. 0; TXSE at 0 range 1 .. 1; TBUE at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; RIE at 0 range 6 .. 6; RBUE at 0 range 7 .. 7; RSE at 0 range 8 .. 8; RWTE at 0 range 9 .. 9; ETIE at 0 range 10 .. 10; ERIE at 0 range 11 .. 11; FBEE at 0 range 12 .. 12; CDEE at 0 range 13 .. 13; AIE at 0 range 14 .. 14; NIE at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DMACRxIWTR_RWT_Field is HAL.UInt8; -- Channel Rx interrupt watchdog timer register type DMACRxIWTR_Register is record -- Receive Interrupt Watchdog Timer Count RWT : DMACRxIWTR_RWT_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACRxIWTR_Register use record RWT at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DMACSR_TEB_Field is HAL.UInt3; subtype DMACSR_REB_Field is HAL.UInt3; -- Channel status register type DMACSR_Register is record -- Transmit Interrupt TI : Boolean := False; -- Transmit Process Stopped TPS : Boolean := False; -- Transmit Buffer Unavailable TBU : Boolean := False; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Receive Interrupt RI : Boolean := False; -- Receive Buffer Unavailable RBU : Boolean := False; -- Receive Process Stopped RPS : Boolean := False; -- Receive Watchdog Timeout RWT : Boolean := False; -- Early Transmit Interrupt ET : Boolean := False; -- Early Receive Interrupt ER : Boolean := False; -- Fatal Bus Error FBE : Boolean := False; -- Context Descriptor Error CDE : Boolean := False; -- Abnormal Interrupt Summary AIS : Boolean := False; -- Normal Interrupt Summary NIS : Boolean := False; -- Read-only. Tx DMA Error Bits TEB : DMACSR_TEB_Field := 16#0#; -- Read-only. Rx DMA Error Bits REB : DMACSR_REB_Field := 16#0#; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACSR_Register use record TI at 0 range 0 .. 0; TPS at 0 range 1 .. 1; TBU at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; RI at 0 range 6 .. 6; RBU at 0 range 7 .. 7; RPS at 0 range 8 .. 8; RWT at 0 range 9 .. 9; ET at 0 range 10 .. 10; ER at 0 range 11 .. 11; FBE at 0 range 12 .. 12; CDE at 0 range 13 .. 13; AIS at 0 range 14 .. 14; NIS at 0 range 15 .. 15; TEB at 0 range 16 .. 18; REB at 0 range 19 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype DMACMFCR_MFC_Field is HAL.UInt11; -- Channel missed frame count register type DMACMFCR_Register is record -- Read-only. Dropped Packet Counters MFC : DMACMFCR_MFC_Field; -- unspecified Reserved_11_14 : HAL.UInt4; -- Read-only. Overflow status of the MFC Counter MFCO : Boolean; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DMACMFCR_Register use record MFC at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; MFCO at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MACCR_PRELEN_Field is HAL.UInt2; subtype MACCR_BL_Field is HAL.UInt2; subtype MACCR_IPG_Field is HAL.UInt3; subtype MACCR_SARC_Field is HAL.UInt3; -- Operating mode configuration register type MACCR_Register is record -- Receiver Enable RE : Boolean := False; -- TE TE : Boolean := False; -- PRELEN PRELEN : MACCR_PRELEN_Field := 16#0#; -- DC DC : Boolean := False; -- BL BL : MACCR_BL_Field := 16#0#; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- DR DR : Boolean := False; -- DCRS DCRS : Boolean := False; -- DO DO_k : Boolean := False; -- ECRSFD ECRSFD : Boolean := False; -- LM LM : Boolean := False; -- DM DM : Boolean := False; -- FES FES : Boolean := False; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- JE JE : Boolean := False; -- JD JD : Boolean := False; -- unspecified Reserved_18_18 : HAL.Bit := 16#0#; -- WD WD : Boolean := False; -- ACS ACS : Boolean := False; -- CST CST : Boolean := False; -- S2KP S2KP : Boolean := False; -- GPSLCE GPSLCE : Boolean := False; -- IPG IPG : MACCR_IPG_Field := 16#0#; -- IPC IPC : Boolean := False; -- SARC SARC : MACCR_SARC_Field := 16#0#; -- ARPEN ARPEN : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACCR_Register use record RE at 0 range 0 .. 0; TE at 0 range 1 .. 1; PRELEN at 0 range 2 .. 3; DC at 0 range 4 .. 4; BL at 0 range 5 .. 6; Reserved_7_7 at 0 range 7 .. 7; DR at 0 range 8 .. 8; DCRS at 0 range 9 .. 9; DO_k at 0 range 10 .. 10; ECRSFD at 0 range 11 .. 11; LM at 0 range 12 .. 12; DM at 0 range 13 .. 13; FES at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; JE at 0 range 16 .. 16; JD at 0 range 17 .. 17; Reserved_18_18 at 0 range 18 .. 18; WD at 0 range 19 .. 19; ACS at 0 range 20 .. 20; CST at 0 range 21 .. 21; S2KP at 0 range 22 .. 22; GPSLCE at 0 range 23 .. 23; IPG at 0 range 24 .. 26; IPC at 0 range 27 .. 27; SARC at 0 range 28 .. 30; ARPEN at 0 range 31 .. 31; end record; subtype MACECR_GPSL_Field is HAL.UInt14; subtype MACECR_EIPG_Field is HAL.UInt5; -- Extended operating mode configuration register type MACECR_Register is record -- GPSL GPSL : MACECR_GPSL_Field := 16#0#; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- DCRCC DCRCC : Boolean := False; -- SPEN SPEN : Boolean := False; -- USP USP : Boolean := False; -- unspecified Reserved_19_23 : HAL.UInt5 := 16#0#; -- EIPGEN EIPGEN : Boolean := False; -- EIPG EIPG : MACECR_EIPG_Field := 16#0#; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACECR_Register use record GPSL at 0 range 0 .. 13; Reserved_14_15 at 0 range 14 .. 15; DCRCC at 0 range 16 .. 16; SPEN at 0 range 17 .. 17; USP at 0 range 18 .. 18; Reserved_19_23 at 0 range 19 .. 23; EIPGEN at 0 range 24 .. 24; EIPG at 0 range 25 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype MACPFR_PCF_Field is HAL.UInt2; -- Packet filtering control register type MACPFR_Register is record -- PR PR : Boolean := False; -- HUC HUC : Boolean := False; -- HMC HMC : Boolean := False; -- DAIF DAIF : Boolean := False; -- PM PM : Boolean := False; -- DBF DBF : Boolean := False; -- PCF PCF : MACPFR_PCF_Field := 16#0#; -- SAIF SAIF : Boolean := False; -- SAF SAF : Boolean := False; -- HPF HPF : Boolean := False; -- unspecified Reserved_11_15 : HAL.UInt5 := 16#0#; -- VTFE VTFE : Boolean := False; -- unspecified Reserved_17_19 : HAL.UInt3 := 16#0#; -- IPFE IPFE : Boolean := False; -- DNTU DNTU : Boolean := False; -- unspecified Reserved_22_30 : HAL.UInt9 := 16#0#; -- RA RA : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACPFR_Register use record PR at 0 range 0 .. 0; HUC at 0 range 1 .. 1; HMC at 0 range 2 .. 2; DAIF at 0 range 3 .. 3; PM at 0 range 4 .. 4; DBF at 0 range 5 .. 5; PCF at 0 range 6 .. 7; SAIF at 0 range 8 .. 8; SAF at 0 range 9 .. 9; HPF at 0 range 10 .. 10; Reserved_11_15 at 0 range 11 .. 15; VTFE at 0 range 16 .. 16; Reserved_17_19 at 0 range 17 .. 19; IPFE at 0 range 20 .. 20; DNTU at 0 range 21 .. 21; Reserved_22_30 at 0 range 22 .. 30; RA at 0 range 31 .. 31; end record; subtype MACWTR_WTO_Field is HAL.UInt4; -- Watchdog timeout register type MACWTR_Register is record -- WTO WTO : MACWTR_WTO_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- PWE PWE : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACWTR_Register use record WTO at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; PWE at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype MACVTR_VL_Field is HAL.UInt16; subtype MACVTR_EVLS_Field is HAL.UInt2; subtype MACVTR_EIVLS_Field is HAL.UInt2; -- VLAN tag register type MACVTR_Register is record -- VL VL : MACVTR_VL_Field := 16#0#; -- ETV ETV : Boolean := False; -- VTIM VTIM : Boolean := False; -- ESVL ESVL : Boolean := False; -- ERSVLM ERSVLM : Boolean := False; -- DOVLTC DOVLTC : Boolean := False; -- EVLS EVLS : MACVTR_EVLS_Field := 16#0#; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- EVLRXS EVLRXS : Boolean := False; -- VTHM VTHM : Boolean := False; -- EDVLP EDVLP : Boolean := False; -- ERIVLT ERIVLT : Boolean := False; -- EIVLS EIVLS : MACVTR_EIVLS_Field := 16#0#; -- unspecified Reserved_30_30 : HAL.Bit := 16#0#; -- EIVLRXS EIVLRXS : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACVTR_Register use record VL at 0 range 0 .. 15; ETV at 0 range 16 .. 16; VTIM at 0 range 17 .. 17; ESVL at 0 range 18 .. 18; ERSVLM at 0 range 19 .. 19; DOVLTC at 0 range 20 .. 20; EVLS at 0 range 21 .. 22; Reserved_23_23 at 0 range 23 .. 23; EVLRXS at 0 range 24 .. 24; VTHM at 0 range 25 .. 25; EDVLP at 0 range 26 .. 26; ERIVLT at 0 range 27 .. 27; EIVLS at 0 range 28 .. 29; Reserved_30_30 at 0 range 30 .. 30; EIVLRXS at 0 range 31 .. 31; end record; subtype MACVHTR_VLHT_Field is HAL.UInt16; -- VLAN Hash table register type MACVHTR_Register is record -- VLHT VLHT : MACVHTR_VLHT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACVHTR_Register use record VLHT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MACVIR_VLT_Field is HAL.UInt16; subtype MACVIR_VLC_Field is HAL.UInt2; -- VLAN inclusion register type MACVIR_Register is record -- VLT VLT : MACVIR_VLT_Field := 16#0#; -- VLC VLC : MACVIR_VLC_Field := 16#0#; -- VLP VLP : Boolean := False; -- CSVL CSVL : Boolean := False; -- VLTI VLTI : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACVIR_Register use record VLT at 0 range 0 .. 15; VLC at 0 range 16 .. 17; VLP at 0 range 18 .. 18; CSVL at 0 range 19 .. 19; VLTI at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype MACIVIR_VLT_Field is HAL.UInt16; subtype MACIVIR_VLC_Field is HAL.UInt2; -- Inner VLAN inclusion register type MACIVIR_Register is record -- VLT VLT : MACIVIR_VLT_Field := 16#0#; -- VLC VLC : MACIVIR_VLC_Field := 16#0#; -- VLP VLP : Boolean := False; -- CSVL CSVL : Boolean := False; -- VLTI VLTI : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACIVIR_Register use record VLT at 0 range 0 .. 15; VLC at 0 range 16 .. 17; VLP at 0 range 18 .. 18; CSVL at 0 range 19 .. 19; VLTI at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype MACQTxFCR_PLT_Field is HAL.UInt3; subtype MACQTxFCR_PT_Field is HAL.UInt16; -- Tx Queue flow control register type MACQTxFCR_Register is record -- FCB_BPA FCB_BPA : Boolean := False; -- TFE TFE : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- PLT PLT : MACQTxFCR_PLT_Field := 16#0#; -- DZPQ DZPQ : Boolean := False; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; -- PT PT : MACQTxFCR_PT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACQTxFCR_Register use record FCB_BPA at 0 range 0 .. 0; TFE at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; PLT at 0 range 4 .. 6; DZPQ at 0 range 7 .. 7; Reserved_8_15 at 0 range 8 .. 15; PT at 0 range 16 .. 31; end record; -- Rx flow control register type MACRxFCR_Register is record -- RFE RFE : Boolean := False; -- UP UP : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACRxFCR_Register use record RFE at 0 range 0 .. 0; UP at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- Interrupt status register type MACISR_Register is record -- unspecified Reserved_0_2 : HAL.UInt3; -- Read-only. PHYIS PHYIS : Boolean; -- Read-only. PMTIS PMTIS : Boolean; -- Read-only. LPIIS LPIIS : Boolean; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. MMCIS MMCIS : Boolean; -- Read-only. MMCRXIS MMCRXIS : Boolean; -- Read-only. MMCTXIS MMCTXIS : Boolean; -- unspecified Reserved_11_11 : HAL.Bit; -- Read-only. TSIS TSIS : Boolean; -- Read-only. TXSTSIS TXSTSIS : Boolean; -- Read-only. RXSTSIS RXSTSIS : Boolean; -- unspecified Reserved_15_31 : HAL.UInt17; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACISR_Register use record Reserved_0_2 at 0 range 0 .. 2; PHYIS at 0 range 3 .. 3; PMTIS at 0 range 4 .. 4; LPIIS at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; MMCIS at 0 range 8 .. 8; MMCRXIS at 0 range 9 .. 9; MMCTXIS at 0 range 10 .. 10; Reserved_11_11 at 0 range 11 .. 11; TSIS at 0 range 12 .. 12; TXSTSIS at 0 range 13 .. 13; RXSTSIS at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; -- Interrupt enable register type MACIER_Register is record -- unspecified Reserved_0_2 : HAL.UInt3 := 16#0#; -- PHYIE PHYIE : Boolean := False; -- PMTIE PMTIE : Boolean := False; -- LPIIE LPIIE : Boolean := False; -- unspecified Reserved_6_11 : HAL.UInt6 := 16#0#; -- TSIE TSIE : Boolean := False; -- TXSTSIE TXSTSIE : Boolean := False; -- RXSTSIE RXSTSIE : Boolean := False; -- unspecified Reserved_15_31 : HAL.UInt17 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACIER_Register use record Reserved_0_2 at 0 range 0 .. 2; PHYIE at 0 range 3 .. 3; PMTIE at 0 range 4 .. 4; LPIIE at 0 range 5 .. 5; Reserved_6_11 at 0 range 6 .. 11; TSIE at 0 range 12 .. 12; TXSTSIE at 0 range 13 .. 13; RXSTSIE at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; -- Rx Tx status register type MACRxTxSR_Register is record -- Read-only. TJT TJT : Boolean; -- Read-only. NCARR NCARR : Boolean; -- Read-only. LCARR LCARR : Boolean; -- Read-only. EXDEF EXDEF : Boolean; -- Read-only. LCOL LCOL : Boolean; -- Read-only. LCOL EXCOL : Boolean; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. RWT RWT : Boolean; -- unspecified Reserved_9_31 : HAL.UInt23; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACRxTxSR_Register use record TJT at 0 range 0 .. 0; NCARR at 0 range 1 .. 1; LCARR at 0 range 2 .. 2; EXDEF at 0 range 3 .. 3; LCOL at 0 range 4 .. 4; EXCOL at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; RWT at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype MACPCSR_RWKPTR_Field is HAL.UInt5; -- PMT control status register type MACPCSR_Register is record -- PWRDWN PWRDWN : Boolean := False; -- MGKPKTEN MGKPKTEN : Boolean := False; -- RWKPKTEN RWKPKTEN : Boolean := False; -- unspecified Reserved_3_4 : HAL.UInt2 := 16#0#; -- Read-only. MGKPRCVD MGKPRCVD : Boolean := False; -- Read-only. RWKPRCVD RWKPRCVD : Boolean := False; -- unspecified Reserved_7_8 : HAL.UInt2 := 16#0#; -- GLBLUCAST GLBLUCAST : Boolean := False; -- RWKPFE RWKPFE : Boolean := False; -- unspecified Reserved_11_23 : HAL.UInt13 := 16#0#; -- RWKPTR RWKPTR : MACPCSR_RWKPTR_Field := 16#0#; -- unspecified Reserved_29_30 : HAL.UInt2 := 16#0#; -- RWKFILTRST RWKFILTRST : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACPCSR_Register use record PWRDWN at 0 range 0 .. 0; MGKPKTEN at 0 range 1 .. 1; RWKPKTEN at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; MGKPRCVD at 0 range 5 .. 5; RWKPRCVD at 0 range 6 .. 6; Reserved_7_8 at 0 range 7 .. 8; GLBLUCAST at 0 range 9 .. 9; RWKPFE at 0 range 10 .. 10; Reserved_11_23 at 0 range 11 .. 23; RWKPTR at 0 range 24 .. 28; Reserved_29_30 at 0 range 29 .. 30; RWKFILTRST at 0 range 31 .. 31; end record; -- LPI control status register type MACLCSR_Register is record -- Read-only. TLPIEN TLPIEN : Boolean := False; -- Read-only. TLPIEX TLPIEX : Boolean := False; -- Read-only. RLPIEN RLPIEN : Boolean := False; -- Read-only. RLPIEX RLPIEX : Boolean := False; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- Read-only. TLPIST TLPIST : Boolean := False; -- Read-only. RLPIST RLPIST : Boolean := False; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- LPIEN LPIEN : Boolean := False; -- PLS PLS : Boolean := False; -- PLSEN PLSEN : Boolean := False; -- LPITXA LPITXA : Boolean := False; -- LPITE LPITE : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACLCSR_Register use record TLPIEN at 0 range 0 .. 0; TLPIEX at 0 range 1 .. 1; RLPIEN at 0 range 2 .. 2; RLPIEX at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; TLPIST at 0 range 8 .. 8; RLPIST at 0 range 9 .. 9; Reserved_10_15 at 0 range 10 .. 15; LPIEN at 0 range 16 .. 16; PLS at 0 range 17 .. 17; PLSEN at 0 range 18 .. 18; LPITXA at 0 range 19 .. 19; LPITE at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype MACLTCR_TWT_Field is HAL.UInt16; subtype MACLTCR_LST_Field is HAL.UInt10; -- LPI timers control register type MACLTCR_Register is record -- TWT TWT : MACLTCR_TWT_Field := 16#0#; -- LST LST : MACLTCR_LST_Field := 16#3E8#; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACLTCR_Register use record TWT at 0 range 0 .. 15; LST at 0 range 16 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype MACLETR_LPIET_Field is HAL.UInt17; -- LPI entry timer register type MACLETR_Register is record -- LPIET LPIET : MACLETR_LPIET_Field := 16#0#; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACLETR_Register use record LPIET at 0 range 0 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype MAC1USTCR_TIC_1US_CNTR_Field is HAL.UInt12; -- 1-microsecond-tick counter register type MAC1USTCR_Register is record -- TIC_1US_CNTR TIC_1US_CNTR : MAC1USTCR_TIC_1US_CNTR_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MAC1USTCR_Register use record TIC_1US_CNTR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype MACVR_SNPSVER_Field is HAL.UInt8; subtype MACVR_USERVER_Field is HAL.UInt8; -- Version register type MACVR_Register is record -- Read-only. SNPSVER SNPSVER : MACVR_SNPSVER_Field; -- Read-only. USERVER USERVER : MACVR_USERVER_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACVR_Register use record SNPSVER at 0 range 0 .. 7; USERVER at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MACDR_RFCFCSTS_Field is HAL.UInt2; subtype MACDR_TFCSTS_Field is HAL.UInt2; -- Debug register type MACDR_Register is record -- Read-only. RPESTS RPESTS : Boolean; -- Read-only. RFCFCSTS RFCFCSTS : MACDR_RFCFCSTS_Field; -- unspecified Reserved_3_15 : HAL.UInt13; -- Read-only. TPESTS TPESTS : Boolean; -- Read-only. TFCSTS TFCSTS : MACDR_TFCSTS_Field; -- unspecified Reserved_19_31 : HAL.UInt13; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACDR_Register use record RPESTS at 0 range 0 .. 0; RFCFCSTS at 0 range 1 .. 2; Reserved_3_15 at 0 range 3 .. 15; TPESTS at 0 range 16 .. 16; TFCSTS at 0 range 17 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype MACHWF1R_RXFIFOSIZE_Field is HAL.UInt5; subtype MACHWF1R_TXFIFOSIZE_Field is HAL.UInt5; subtype MACHWF1R_ADDR64_Field is HAL.UInt2; subtype MACHWF1R_HASHTBLSZ_Field is HAL.UInt2; subtype MACHWF1R_L3L4FNUM_Field is HAL.UInt4; -- HW feature 1 register type MACHWF1R_Register is record -- Read-only. RXFIFOSIZE RXFIFOSIZE : MACHWF1R_RXFIFOSIZE_Field; -- unspecified Reserved_5_5 : HAL.Bit; -- Read-only. TXFIFOSIZE TXFIFOSIZE : MACHWF1R_TXFIFOSIZE_Field; -- Read-only. OSTEN OSTEN : Boolean; -- Read-only. PTOEN PTOEN : Boolean; -- Read-only. ADVTHWORD ADVTHWORD : Boolean; -- Read-only. ADDR64 ADDR64 : MACHWF1R_ADDR64_Field; -- Read-only. DCBEN DCBEN : Boolean; -- Read-only. SPHEN SPHEN : Boolean; -- Read-only. TSOEN TSOEN : Boolean; -- Read-only. DBGMEMA DBGMEMA : Boolean; -- Read-only. AVSEL AVSEL : Boolean; -- unspecified Reserved_21_23 : HAL.UInt3; -- Read-only. HASHTBLSZ HASHTBLSZ : MACHWF1R_HASHTBLSZ_Field; -- unspecified Reserved_26_26 : HAL.Bit; -- Read-only. L3L4FNUM L3L4FNUM : MACHWF1R_L3L4FNUM_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACHWF1R_Register use record RXFIFOSIZE at 0 range 0 .. 4; Reserved_5_5 at 0 range 5 .. 5; TXFIFOSIZE at 0 range 6 .. 10; OSTEN at 0 range 11 .. 11; PTOEN at 0 range 12 .. 12; ADVTHWORD at 0 range 13 .. 13; ADDR64 at 0 range 14 .. 15; DCBEN at 0 range 16 .. 16; SPHEN at 0 range 17 .. 17; TSOEN at 0 range 18 .. 18; DBGMEMA at 0 range 19 .. 19; AVSEL at 0 range 20 .. 20; Reserved_21_23 at 0 range 21 .. 23; HASHTBLSZ at 0 range 24 .. 25; Reserved_26_26 at 0 range 26 .. 26; L3L4FNUM at 0 range 27 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype MACHWF2R_RXQCNT_Field is HAL.UInt4; subtype MACHWF2R_TXQCNT_Field is HAL.UInt4; subtype MACHWF2R_RXCHCNT_Field is HAL.UInt4; subtype MACHWF2R_TXCHCNT_Field is HAL.UInt4; subtype MACHWF2R_PPSOUTNUM_Field is HAL.UInt3; subtype MACHWF2R_AUXSNAPNUM_Field is HAL.UInt3; -- HW feature 2 register type MACHWF2R_Register is record -- Read-only. RXQCNT RXQCNT : MACHWF2R_RXQCNT_Field; -- unspecified Reserved_4_5 : HAL.UInt2; -- Read-only. TXQCNT TXQCNT : MACHWF2R_TXQCNT_Field; -- unspecified Reserved_10_11 : HAL.UInt2; -- Read-only. RXCHCNT RXCHCNT : MACHWF2R_RXCHCNT_Field; -- unspecified Reserved_16_17 : HAL.UInt2; -- Read-only. TXCHCNT TXCHCNT : MACHWF2R_TXCHCNT_Field; -- unspecified Reserved_22_23 : HAL.UInt2; -- Read-only. PPSOUTNUM PPSOUTNUM : MACHWF2R_PPSOUTNUM_Field; -- unspecified Reserved_27_27 : HAL.Bit; -- Read-only. AUXSNAPNUM AUXSNAPNUM : MACHWF2R_AUXSNAPNUM_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACHWF2R_Register use record RXQCNT at 0 range 0 .. 3; Reserved_4_5 at 0 range 4 .. 5; TXQCNT at 0 range 6 .. 9; Reserved_10_11 at 0 range 10 .. 11; RXCHCNT at 0 range 12 .. 15; Reserved_16_17 at 0 range 16 .. 17; TXCHCNT at 0 range 18 .. 21; Reserved_22_23 at 0 range 22 .. 23; PPSOUTNUM at 0 range 24 .. 26; Reserved_27_27 at 0 range 27 .. 27; AUXSNAPNUM at 0 range 28 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype MACMDIOAR_GOC_Field is HAL.UInt2; subtype MACMDIOAR_CR_Field is HAL.UInt4; subtype MACMDIOAR_NTC_Field is HAL.UInt3; subtype MACMDIOAR_RDA_Field is HAL.UInt5; subtype MACMDIOAR_PA_Field is HAL.UInt5; -- MDIO address register type MACMDIOAR_Register is record -- MB MB : Boolean := False; -- C45E C45E : Boolean := False; -- GOC GOC : MACMDIOAR_GOC_Field := 16#0#; -- SKAP SKAP : Boolean := False; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- CR CR : MACMDIOAR_CR_Field := 16#0#; -- NTC NTC : MACMDIOAR_NTC_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- RDA RDA : MACMDIOAR_RDA_Field := 16#0#; -- PA PA : MACMDIOAR_PA_Field := 16#0#; -- BTB BTB : Boolean := False; -- PSE PSE : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACMDIOAR_Register use record MB at 0 range 0 .. 0; C45E at 0 range 1 .. 1; GOC at 0 range 2 .. 3; SKAP at 0 range 4 .. 4; Reserved_5_7 at 0 range 5 .. 7; CR at 0 range 8 .. 11; NTC at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; RDA at 0 range 16 .. 20; PA at 0 range 21 .. 25; BTB at 0 range 26 .. 26; PSE at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype MACMDIODR_MD_Field is HAL.UInt16; subtype MACMDIODR_RA_Field is HAL.UInt16; -- MDIO data register type MACMDIODR_Register is record -- MD MD : MACMDIODR_MD_Field := 16#0#; -- RA RA : MACMDIODR_RA_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACMDIODR_Register use record MD at 0 range 0 .. 15; RA at 0 range 16 .. 31; end record; subtype MACA0HR_ADDRHI_Field is HAL.UInt16; -- Address 0 high register type MACA0HR_Register is record -- ADDRHI ADDRHI : MACA0HR_ADDRHI_Field := 16#FFFF#; -- unspecified Reserved_16_30 : HAL.UInt15 := 16#0#; -- Read-only. AE AE : Boolean := True; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACA0HR_Register use record ADDRHI at 0 range 0 .. 15; Reserved_16_30 at 0 range 16 .. 30; AE at 0 range 31 .. 31; end record; subtype MACA1HR_ADDRHI_Field is HAL.UInt16; subtype MACA1HR_MBC_Field is HAL.UInt6; -- Address 1 high register type MACA1HR_Register is record -- ADDRHI ADDRHI : MACA1HR_ADDRHI_Field := 16#FFFF#; -- unspecified Reserved_16_23 : HAL.UInt8 := 16#0#; -- MBC MBC : MACA1HR_MBC_Field := 16#0#; -- SA SA : Boolean := False; -- AE AE : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACA1HR_Register use record ADDRHI at 0 range 0 .. 15; Reserved_16_23 at 0 range 16 .. 23; MBC at 0 range 24 .. 29; SA at 0 range 30 .. 30; AE at 0 range 31 .. 31; end record; subtype MACA2HR_ADDRHI_Field is HAL.UInt16; subtype MACA2HR_MBC_Field is HAL.UInt6; -- Address 2 high register type MACA2HR_Register is record -- ADDRHI ADDRHI : MACA2HR_ADDRHI_Field := 16#FFFF#; -- unspecified Reserved_16_23 : HAL.UInt8 := 16#0#; -- MBC MBC : MACA2HR_MBC_Field := 16#0#; -- SA SA : Boolean := False; -- AE AE : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACA2HR_Register use record ADDRHI at 0 range 0 .. 15; Reserved_16_23 at 0 range 16 .. 23; MBC at 0 range 24 .. 29; SA at 0 range 30 .. 30; AE at 0 range 31 .. 31; end record; subtype MACA3HR_ADDRHI_Field is HAL.UInt16; subtype MACA3HR_MBC_Field is HAL.UInt6; -- Address 3 high register type MACA3HR_Register is record -- ADDRHI ADDRHI : MACA3HR_ADDRHI_Field := 16#FFFF#; -- unspecified Reserved_16_23 : HAL.UInt8 := 16#0#; -- MBC MBC : MACA3HR_MBC_Field := 16#0#; -- SA SA : Boolean := False; -- AE AE : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACA3HR_Register use record ADDRHI at 0 range 0 .. 15; Reserved_16_23 at 0 range 16 .. 23; MBC at 0 range 24 .. 29; SA at 0 range 30 .. 30; AE at 0 range 31 .. 31; end record; -- MMC control register type MMC_CONTROL_Register is record -- CNTRST CNTRST : Boolean := False; -- CNTSTOPRO CNTSTOPRO : Boolean := False; -- RSTONRD RSTONRD : Boolean := False; -- CNTFREEZ CNTFREEZ : Boolean := False; -- CNTPRST CNTPRST : Boolean := False; -- CNTPRSTLVL CNTPRSTLVL : Boolean := False; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- UCDBC UCDBC : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MMC_CONTROL_Register use record CNTRST at 0 range 0 .. 0; CNTSTOPRO at 0 range 1 .. 1; RSTONRD at 0 range 2 .. 2; CNTFREEZ at 0 range 3 .. 3; CNTPRST at 0 range 4 .. 4; CNTPRSTLVL at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; UCDBC at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; -- MMC Rx interrupt register type MMC_RX_INTERRUPT_Register is record -- unspecified Reserved_0_4 : HAL.UInt5; -- Read-only. RXCRCERPIS RXCRCERPIS : Boolean; -- Read-only. RXALGNERPIS RXALGNERPIS : Boolean; -- unspecified Reserved_7_16 : HAL.UInt10; -- Read-only. RXUCGPIS RXUCGPIS : Boolean; -- unspecified Reserved_18_25 : HAL.UInt8; -- Read-only. RXLPIUSCIS RXLPIUSCIS : Boolean; -- Read-only. RXLPITRCIS RXLPITRCIS : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MMC_RX_INTERRUPT_Register use record Reserved_0_4 at 0 range 0 .. 4; RXCRCERPIS at 0 range 5 .. 5; RXALGNERPIS at 0 range 6 .. 6; Reserved_7_16 at 0 range 7 .. 16; RXUCGPIS at 0 range 17 .. 17; Reserved_18_25 at 0 range 18 .. 25; RXLPIUSCIS at 0 range 26 .. 26; RXLPITRCIS at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- MMC Tx interrupt register type MMC_TX_INTERRUPT_Register is record -- unspecified Reserved_0_13 : HAL.UInt14; -- Read-only. TXSCOLGPIS TXSCOLGPIS : Boolean; -- Read-only. TXMCOLGPIS TXMCOLGPIS : Boolean; -- unspecified Reserved_16_20 : HAL.UInt5; -- Read-only. TXGPKTIS TXGPKTIS : Boolean; -- unspecified Reserved_22_25 : HAL.UInt4; -- Read-only. TXLPIUSCIS TXLPIUSCIS : Boolean; -- Read-only. TXLPITRCIS TXLPITRCIS : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MMC_TX_INTERRUPT_Register use record Reserved_0_13 at 0 range 0 .. 13; TXSCOLGPIS at 0 range 14 .. 14; TXMCOLGPIS at 0 range 15 .. 15; Reserved_16_20 at 0 range 16 .. 20; TXGPKTIS at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; TXLPIUSCIS at 0 range 26 .. 26; TXLPITRCIS at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- MMC Rx interrupt mask register type MMC_RX_INTERRUPT_MASK_Register is record -- unspecified Reserved_0_4 : HAL.UInt5 := 16#0#; -- RXCRCERPIM RXCRCERPIM : Boolean := False; -- RXALGNERPIM RXALGNERPIM : Boolean := False; -- unspecified Reserved_7_16 : HAL.UInt10 := 16#0#; -- RXUCGPIM RXUCGPIM : Boolean := False; -- unspecified Reserved_18_25 : HAL.UInt8 := 16#0#; -- RXLPIUSCIM RXLPIUSCIM : Boolean := False; -- Read-only. RXLPITRCIM RXLPITRCIM : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MMC_RX_INTERRUPT_MASK_Register use record Reserved_0_4 at 0 range 0 .. 4; RXCRCERPIM at 0 range 5 .. 5; RXALGNERPIM at 0 range 6 .. 6; Reserved_7_16 at 0 range 7 .. 16; RXUCGPIM at 0 range 17 .. 17; Reserved_18_25 at 0 range 18 .. 25; RXLPIUSCIM at 0 range 26 .. 26; RXLPITRCIM at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- MMC Tx interrupt mask register type MMC_TX_INTERRUPT_MASK_Register is record -- unspecified Reserved_0_13 : HAL.UInt14 := 16#0#; -- TXSCOLGPIM TXSCOLGPIM : Boolean := False; -- TXMCOLGPIM TXMCOLGPIM : Boolean := False; -- unspecified Reserved_16_20 : HAL.UInt5 := 16#0#; -- TXGPKTIM TXGPKTIM : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- TXLPIUSCIM TXLPIUSCIM : Boolean := False; -- Read-only. TXLPITRCIM TXLPITRCIM : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MMC_TX_INTERRUPT_MASK_Register use record Reserved_0_13 at 0 range 0 .. 13; TXSCOLGPIM at 0 range 14 .. 14; TXMCOLGPIM at 0 range 15 .. 15; Reserved_16_20 at 0 range 16 .. 20; TXGPKTIM at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; TXLPIUSCIM at 0 range 26 .. 26; TXLPITRCIM at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype MACL3L4C0R_L3HSBM0_Field is HAL.UInt5; subtype MACL3L4C0R_L3HDBM0_Field is HAL.UInt5; -- L3 and L4 control 0 register type MACL3L4C0R_Register is record -- L3PEN0 L3PEN0 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- L3SAM0 L3SAM0 : Boolean := False; -- L3SAIM0 L3SAIM0 : Boolean := False; -- L3DAM0 L3DAM0 : Boolean := False; -- L3DAIM0 L3DAIM0 : Boolean := False; -- L3HSBM0 L3HSBM0 : MACL3L4C0R_L3HSBM0_Field := 16#0#; -- L3HDBM0 L3HDBM0 : MACL3L4C0R_L3HDBM0_Field := 16#0#; -- L4PEN0 L4PEN0 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- L4SPM0 L4SPM0 : Boolean := False; -- L4SPIM0 L4SPIM0 : Boolean := False; -- L4DPM0 L4DPM0 : Boolean := False; -- L4DPIM0 L4DPIM0 : Boolean := False; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACL3L4C0R_Register use record L3PEN0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; L3SAM0 at 0 range 2 .. 2; L3SAIM0 at 0 range 3 .. 3; L3DAM0 at 0 range 4 .. 4; L3DAIM0 at 0 range 5 .. 5; L3HSBM0 at 0 range 6 .. 10; L3HDBM0 at 0 range 11 .. 15; L4PEN0 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; L4SPM0 at 0 range 18 .. 18; L4SPIM0 at 0 range 19 .. 19; L4DPM0 at 0 range 20 .. 20; L4DPIM0 at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype MACL4A0R_L4SP0_Field is HAL.UInt16; subtype MACL4A0R_L4DP0_Field is HAL.UInt16; -- Layer4 address filter 0 register type MACL4A0R_Register is record -- L4SP0 L4SP0 : MACL4A0R_L4SP0_Field := 16#0#; -- L4DP0 L4DP0 : MACL4A0R_L4DP0_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACL4A0R_Register use record L4SP0 at 0 range 0 .. 15; L4DP0 at 0 range 16 .. 31; end record; subtype MACL3L4C1R_L3HSBM1_Field is HAL.UInt5; subtype MACL3L4C1R_L3HDBM1_Field is HAL.UInt5; -- L3 and L4 control 1 register type MACL3L4C1R_Register is record -- L3PEN1 L3PEN1 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- L3SAM1 L3SAM1 : Boolean := False; -- L3SAIM1 L3SAIM1 : Boolean := False; -- L3DAM1 L3DAM1 : Boolean := False; -- L3DAIM1 L3DAIM1 : Boolean := False; -- L3HSBM1 L3HSBM1 : MACL3L4C1R_L3HSBM1_Field := 16#0#; -- L3HDBM1 L3HDBM1 : MACL3L4C1R_L3HDBM1_Field := 16#0#; -- L4PEN1 L4PEN1 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- L4SPM1 L4SPM1 : Boolean := False; -- L4SPIM1 L4SPIM1 : Boolean := False; -- L4DPM1 L4DPM1 : Boolean := False; -- L4DPIM1 L4DPIM1 : Boolean := False; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACL3L4C1R_Register use record L3PEN1 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; L3SAM1 at 0 range 2 .. 2; L3SAIM1 at 0 range 3 .. 3; L3DAM1 at 0 range 4 .. 4; L3DAIM1 at 0 range 5 .. 5; L3HSBM1 at 0 range 6 .. 10; L3HDBM1 at 0 range 11 .. 15; L4PEN1 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; L4SPM1 at 0 range 18 .. 18; L4SPIM1 at 0 range 19 .. 19; L4DPM1 at 0 range 20 .. 20; L4DPIM1 at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype MACL4A1R_L4SP1_Field is HAL.UInt16; subtype MACL4A1R_L4DP1_Field is HAL.UInt16; -- Layer 4 address filter 1 register type MACL4A1R_Register is record -- L4SP1 L4SP1 : MACL4A1R_L4SP1_Field := 16#0#; -- L4DP1 L4DP1 : MACL4A1R_L4DP1_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACL4A1R_Register use record L4SP1 at 0 range 0 .. 15; L4DP1 at 0 range 16 .. 31; end record; subtype MACTSCR_SNAPTYPSEL_Field is HAL.UInt2; -- Timestamp control Register type MACTSCR_Register is record -- TSENA TSENA : Boolean := False; -- TSCFUPDT TSCFUPDT : Boolean := False; -- TSINIT TSINIT : Boolean := False; -- TSUPDT TSUPDT : Boolean := False; -- unspecified Reserved_4_4 : HAL.Bit := 16#0#; -- TSADDREG TSADDREG : Boolean := False; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- TSENALL TSENALL : Boolean := False; -- TSCTRLSSR TSCTRLSSR : Boolean := True; -- TSVER2ENA TSVER2ENA : Boolean := False; -- TSIPENA TSIPENA : Boolean := False; -- TSIPV6ENA TSIPV6ENA : Boolean := False; -- TSIPV4ENA TSIPV4ENA : Boolean := False; -- TSEVNTENA TSEVNTENA : Boolean := False; -- TSMSTRENA TSMSTRENA : Boolean := False; -- SNAPTYPSEL SNAPTYPSEL : MACTSCR_SNAPTYPSEL_Field := 16#0#; -- TSENMACADDR TSENMACADDR : Boolean := False; -- Read-only. CSC CSC : Boolean := False; -- unspecified Reserved_20_23 : HAL.UInt4 := 16#0#; -- TXTSSTSM TXTSSTSM : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACTSCR_Register use record TSENA at 0 range 0 .. 0; TSCFUPDT at 0 range 1 .. 1; TSINIT at 0 range 2 .. 2; TSUPDT at 0 range 3 .. 3; Reserved_4_4 at 0 range 4 .. 4; TSADDREG at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; TSENALL at 0 range 8 .. 8; TSCTRLSSR at 0 range 9 .. 9; TSVER2ENA at 0 range 10 .. 10; TSIPENA at 0 range 11 .. 11; TSIPV6ENA at 0 range 12 .. 12; TSIPV4ENA at 0 range 13 .. 13; TSEVNTENA at 0 range 14 .. 14; TSMSTRENA at 0 range 15 .. 15; SNAPTYPSEL at 0 range 16 .. 17; TSENMACADDR at 0 range 18 .. 18; CSC at 0 range 19 .. 19; Reserved_20_23 at 0 range 20 .. 23; TXTSSTSM at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype MACSSIR_SNSINC_Field is HAL.UInt8; subtype MACSSIR_SSINC_Field is HAL.UInt8; -- Sub-second increment register type MACSSIR_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- SNSINC SNSINC : MACSSIR_SNSINC_Field := 16#0#; -- SSINC SSINC : MACSSIR_SSINC_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACSSIR_Register use record Reserved_0_7 at 0 range 0 .. 7; SNSINC at 0 range 8 .. 15; SSINC at 0 range 16 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype MACSTNR_TSSS_Field is HAL.UInt31; -- System time nanoseconds register type MACSTNR_Register is record -- Read-only. TSSS TSSS : MACSTNR_TSSS_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACSTNR_Register use record TSSS at 0 range 0 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype MACSTNUR_TSSS_Field is HAL.UInt31; -- System time nanoseconds update register type MACSTNUR_Register is record -- TSSS TSSS : MACSTNUR_TSSS_Field := 16#0#; -- ADDSUB ADDSUB : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACSTNUR_Register use record TSSS at 0 range 0 .. 30; ADDSUB at 0 range 31 .. 31; end record; subtype MACTSSR_ATSSTN_Field is HAL.UInt4; subtype MACTSSR_ATSNS_Field is HAL.UInt5; -- Timestamp status register type MACTSSR_Register is record -- Read-only. TSSOVF TSSOVF : Boolean; -- Read-only. TSTARGT0 TSTARGT0 : Boolean; -- Read-only. AUXTSTRIG AUXTSTRIG : Boolean; -- Read-only. TSTRGTERR0 TSTRGTERR0 : Boolean; -- unspecified Reserved_4_14 : HAL.UInt11; -- Read-only. TXTSSIS TXTSSIS : Boolean; -- Read-only. ATSSTN ATSSTN : MACTSSR_ATSSTN_Field; -- unspecified Reserved_20_23 : HAL.UInt4; -- Read-only. ATSSTM ATSSTM : Boolean; -- Read-only. ATSNS ATSNS : MACTSSR_ATSNS_Field; -- unspecified Reserved_30_31 : HAL.UInt2; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACTSSR_Register use record TSSOVF at 0 range 0 .. 0; TSTARGT0 at 0 range 1 .. 1; AUXTSTRIG at 0 range 2 .. 2; TSTRGTERR0 at 0 range 3 .. 3; Reserved_4_14 at 0 range 4 .. 14; TXTSSIS at 0 range 15 .. 15; ATSSTN at 0 range 16 .. 19; Reserved_20_23 at 0 range 20 .. 23; ATSSTM at 0 range 24 .. 24; ATSNS at 0 range 25 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; subtype MACTxTSSNR_TXTSSLO_Field is HAL.UInt31; -- Tx timestamp status nanoseconds register type MACTxTSSNR_Register is record -- Read-only. TXTSSLO TXTSSLO : MACTxTSSNR_TXTSSLO_Field; -- Read-only. TXTSSMIS TXTSSMIS : Boolean; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACTxTSSNR_Register use record TXTSSLO at 0 range 0 .. 30; TXTSSMIS at 0 range 31 .. 31; end record; -- MACACR_ATSEN array type MACACR_ATSEN_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for MACACR_ATSEN type MACACR_ATSEN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- ATSEN as a value Val : HAL.UInt4; when True => -- ATSEN as an array Arr : MACACR_ATSEN_Field_Array; end case; end record with Unchecked_Union, Size => 4; for MACACR_ATSEN_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Auxiliary control register type MACACR_Register is record -- ATSFC ATSFC : Boolean := False; -- unspecified Reserved_1_3 : HAL.UInt3 := 16#0#; -- ATSEN0 ATSEN : MACACR_ATSEN_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACACR_Register use record ATSFC at 0 range 0 .. 0; Reserved_1_3 at 0 range 1 .. 3; ATSEN at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype MACATSNR_AUXTSLO_Field is HAL.UInt31; -- Auxiliary timestamp nanoseconds register type MACATSNR_Register is record -- Read-only. AUXTSLO AUXTSLO : MACATSNR_AUXTSLO_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACATSNR_Register use record AUXTSLO at 0 range 0 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype MACPPSCR_PPSCTRL_Field is HAL.UInt4; subtype MACPPSCR_TRGTMODSEL0_Field is HAL.UInt2; -- PPS control register type MACPPSCR_Register is record -- PPSCTRL PPSCTRL : MACPPSCR_PPSCTRL_Field := 16#0#; -- PPSEN0 PPSEN0 : Boolean := False; -- TRGTMODSEL0 TRGTMODSEL0 : MACPPSCR_TRGTMODSEL0_Field := 16#0#; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACPPSCR_Register use record PPSCTRL at 0 range 0 .. 3; PPSEN0 at 0 range 4 .. 4; TRGTMODSEL0 at 0 range 5 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype MACPPSTTSR_TSTRH0_Field is HAL.UInt31; -- PPS target time seconds register type MACPPSTTSR_Register is record -- TSTRH0 TSTRH0 : MACPPSTTSR_TSTRH0_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACPPSTTSR_Register use record TSTRH0 at 0 range 0 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype MACPPSTTNR_TTSL0_Field is HAL.UInt31; -- PPS target time nanoseconds register type MACPPSTTNR_Register is record -- TTSL0 TTSL0 : MACPPSTTNR_TTSL0_Field := 16#0#; -- TRGTBUSY0 TRGTBUSY0 : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACPPSTTNR_Register use record TTSL0 at 0 range 0 .. 30; TRGTBUSY0 at 0 range 31 .. 31; end record; subtype MACPOCR_DN_Field is HAL.UInt8; -- PTP Offload control register type MACPOCR_Register is record -- PTOEN PTOEN : Boolean := False; -- ASYNCEN ASYNCEN : Boolean := False; -- APDREQEN APDREQEN : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- ASYNCTRIG ASYNCTRIG : Boolean := False; -- APDREQTRIG APDREQTRIG : Boolean := False; -- DRRDIS DRRDIS : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- DN DN : MACPOCR_DN_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACPOCR_Register use record PTOEN at 0 range 0 .. 0; ASYNCEN at 0 range 1 .. 1; APDREQEN at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; ASYNCTRIG at 0 range 4 .. 4; APDREQTRIG at 0 range 5 .. 5; DRRDIS at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DN at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MACSPI2R_SPI2_Field is HAL.UInt16; -- PTP Source port identity 2 register type MACSPI2R_Register is record -- SPI2 SPI2 : MACSPI2R_SPI2_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACSPI2R_Register use record SPI2 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype MACLMIR_LSI_Field is HAL.UInt8; subtype MACLMIR_DRSYNCR_Field is HAL.UInt3; subtype MACLMIR_LMPDRI_Field is HAL.UInt8; -- Log message interval register type MACLMIR_Register is record -- LSI LSI : MACLMIR_LSI_Field := 16#0#; -- DRSYNCR DRSYNCR : MACLMIR_DRSYNCR_Field := 16#0#; -- unspecified Reserved_11_23 : HAL.UInt13 := 16#0#; -- LMPDRI LMPDRI : MACLMIR_LMPDRI_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MACLMIR_Register use record LSI at 0 range 0 .. 7; DRSYNCR at 0 range 8 .. 10; Reserved_11_23 at 0 range 11 .. 23; LMPDRI at 0 range 24 .. 31; end record; -- Operating mode Register type MTLOMR_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- DTXSTS DTXSTS : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- CNTPRST CNTPRST : Boolean := False; -- CNTCLR CNTCLR : Boolean := False; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLOMR_Register use record Reserved_0_0 at 0 range 0 .. 0; DTXSTS at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; CNTPRST at 0 range 8 .. 8; CNTCLR at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- Interrupt status Register type MTLISR_Register is record -- Read-only. Queue interrupt status Q0IS : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLISR_Register use record Q0IS at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; subtype MTLTxQOMR_TXQEN_Field is HAL.UInt2; subtype MTLTxQOMR_TTC_Field is HAL.UInt3; subtype MTLTxQOMR_TQS_Field is HAL.UInt3; -- Tx queue operating mode Register type MTLTxQOMR_Register is record -- Flush Transmit Queue FTQ : Boolean := False; -- Transmit Store and Forward TSF : Boolean := False; -- Read-only. Transmit Queue Enable TXQEN : MTLTxQOMR_TXQEN_Field := 16#2#; -- Transmit Threshold Control TTC : MTLTxQOMR_TTC_Field := 16#0#; -- unspecified Reserved_7_15 : HAL.UInt9 := 16#0#; -- Transmit Queue Size TQS : MTLTxQOMR_TQS_Field := 16#7#; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLTxQOMR_Register use record FTQ at 0 range 0 .. 0; TSF at 0 range 1 .. 1; TXQEN at 0 range 2 .. 3; TTC at 0 range 4 .. 6; Reserved_7_15 at 0 range 7 .. 15; TQS at 0 range 16 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype MTLTxQUR_UFFRMCNT_Field is HAL.UInt11; -- Tx queue underflow register type MTLTxQUR_Register is record -- Read-only. Underflow Packet Counter UFFRMCNT : MTLTxQUR_UFFRMCNT_Field; -- Read-only. UFCNTOVF UFCNTOVF : Boolean; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLTxQUR_Register use record UFFRMCNT at 0 range 0 .. 10; UFCNTOVF at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype MTLTxQDR_TRCSTS_Field is HAL.UInt2; subtype MTLTxQDR_PTXQ_Field is HAL.UInt3; subtype MTLTxQDR_STXSTSF_Field is HAL.UInt3; -- Tx queue debug Register type MTLTxQDR_Register is record -- Read-only. TXQPAUSED TXQPAUSED : Boolean; -- Read-only. TRCSTS TRCSTS : MTLTxQDR_TRCSTS_Field; -- Read-only. TWCSTS TWCSTS : Boolean; -- Read-only. TXQSTS TXQSTS : Boolean; -- Read-only. TXSTSFSTS TXSTSFSTS : Boolean; -- unspecified Reserved_6_15 : HAL.UInt10; -- Read-only. PTXQ PTXQ : MTLTxQDR_PTXQ_Field; -- unspecified Reserved_19_19 : HAL.Bit; -- Read-only. STXSTSF STXSTSF : MTLTxQDR_STXSTSF_Field; -- unspecified Reserved_23_31 : HAL.UInt9; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLTxQDR_Register use record TXQPAUSED at 0 range 0 .. 0; TRCSTS at 0 range 1 .. 2; TWCSTS at 0 range 3 .. 3; TXQSTS at 0 range 4 .. 4; TXSTSFSTS at 0 range 5 .. 5; Reserved_6_15 at 0 range 6 .. 15; PTXQ at 0 range 16 .. 18; Reserved_19_19 at 0 range 19 .. 19; STXSTSF at 0 range 20 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; -- Queue interrupt control status Register type MTLQICSR_Register is record -- TXUNFIS TXUNFIS : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; -- TXUIE TXUIE : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- RXOVFIS RXOVFIS : Boolean := False; -- unspecified Reserved_17_23 : HAL.UInt7 := 16#0#; -- RXOIE RXOIE : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLQICSR_Register use record TXUNFIS at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; TXUIE at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; RXOVFIS at 0 range 16 .. 16; Reserved_17_23 at 0 range 17 .. 23; RXOIE at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype MTLRxQOMR_RTC_Field is HAL.UInt2; subtype MTLRxQOMR_RFA_Field is HAL.UInt3; subtype MTLRxQOMR_RFD_Field is HAL.UInt3; subtype MTLRxQOMR_RQS_Field is HAL.UInt3; -- Rx queue operating mode register type MTLRxQOMR_Register is record -- RTC RTC : MTLRxQOMR_RTC_Field := 16#0#; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- FUP FUP : Boolean := False; -- FEP FEP : Boolean := False; -- RSF RSF : Boolean := False; -- DIS_TCP_EF DIS_TCP_EF : Boolean := False; -- EHFC EHFC : Boolean := False; -- RFA RFA : MTLRxQOMR_RFA_Field := 16#0#; -- unspecified Reserved_11_13 : HAL.UInt3 := 16#0#; -- RFD RFD : MTLRxQOMR_RFD_Field := 16#0#; -- unspecified Reserved_17_19 : HAL.UInt3 := 16#0#; -- Read-only. RQS RQS : MTLRxQOMR_RQS_Field := 16#7#; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLRxQOMR_Register use record RTC at 0 range 0 .. 1; Reserved_2_2 at 0 range 2 .. 2; FUP at 0 range 3 .. 3; FEP at 0 range 4 .. 4; RSF at 0 range 5 .. 5; DIS_TCP_EF at 0 range 6 .. 6; EHFC at 0 range 7 .. 7; RFA at 0 range 8 .. 10; Reserved_11_13 at 0 range 11 .. 13; RFD at 0 range 14 .. 16; Reserved_17_19 at 0 range 17 .. 19; RQS at 0 range 20 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype MTLRxQMPOCR_OVFPKTCNT_Field is HAL.UInt11; subtype MTLRxQMPOCR_MISPKTCNT_Field is HAL.UInt11; -- Rx queue missed packet and overflow counter register type MTLRxQMPOCR_Register is record -- Read-only. OVFPKTCNT OVFPKTCNT : MTLRxQMPOCR_OVFPKTCNT_Field; -- Read-only. OVFCNTOVF OVFCNTOVF : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. MISPKTCNT MISPKTCNT : MTLRxQMPOCR_MISPKTCNT_Field; -- Read-only. MISCNTOVF MISCNTOVF : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLRxQMPOCR_Register use record OVFPKTCNT at 0 range 0 .. 10; OVFCNTOVF at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; MISPKTCNT at 0 range 16 .. 26; MISCNTOVF at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype MTLRxQDR_RRCSTS_Field is HAL.UInt2; subtype MTLRxQDR_RXQSTS_Field is HAL.UInt2; subtype MTLRxQDR_PRXQ_Field is HAL.UInt14; -- Rx queue debug register type MTLRxQDR_Register is record -- Read-only. RWCSTS RWCSTS : Boolean; -- Read-only. RRCSTS RRCSTS : MTLRxQDR_RRCSTS_Field; -- unspecified Reserved_3_3 : HAL.Bit; -- Read-only. RXQSTS RXQSTS : MTLRxQDR_RXQSTS_Field; -- unspecified Reserved_6_15 : HAL.UInt10; -- Read-only. PRXQ PRXQ : MTLRxQDR_PRXQ_Field; -- unspecified Reserved_30_31 : HAL.UInt2; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for MTLRxQDR_Register use record RWCSTS at 0 range 0 .. 0; RRCSTS at 0 range 1 .. 2; Reserved_3_3 at 0 range 3 .. 3; RXQSTS at 0 range 4 .. 5; Reserved_6_15 at 0 range 6 .. 15; PRXQ at 0 range 16 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Ethernet: DMA mode register (DMA) type Ethernet_DMA_Peripheral is record -- DMA mode register DMAMR : aliased DMAMR_Register; -- System bus mode register DMASBMR : aliased DMASBMR_Register; -- Interrupt status register DMAISR : aliased DMAISR_Register; -- Debug status register DMADSR : aliased DMADSR_Register; -- Channel control register DMACCR : aliased DMACCR_Register; -- Channel transmit control register DMACTxCR : aliased DMACTxCR_Register; -- Channel receive control register DMACRxCR : aliased DMACRxCR_Register; -- Channel Tx descriptor list address register DMACTxDLAR : aliased DMACTxDLAR_Register; -- Channel Rx descriptor list address register DMACRxDLAR : aliased DMACRxDLAR_Register; -- Channel Tx descriptor tail pointer register DMACTxDTPR : aliased DMACTxDTPR_Register; -- Channel Rx descriptor tail pointer register DMACRxDTPR : aliased DMACRxDTPR_Register; -- Channel Tx descriptor ring length register DMACTxRLR : aliased DMACTxRLR_Register; -- Channel Rx descriptor ring length register DMACRxRLR : aliased DMACRxRLR_Register; -- Channel interrupt enable register DMACIER : aliased DMACIER_Register; -- Channel Rx interrupt watchdog timer register DMACRxIWTR : aliased DMACRxIWTR_Register; -- Channel current application transmit descriptor register DMACCATxDR : aliased HAL.UInt32; -- Channel current application receive descriptor register DMACCARxDR : aliased HAL.UInt32; -- Channel current application transmit buffer register DMACCATxBR : aliased HAL.UInt32; -- Channel current application receive buffer register DMACCARxBR : aliased HAL.UInt32; -- Channel status register DMACSR : aliased DMACSR_Register; -- Channel missed frame count register DMACMFCR : aliased DMACMFCR_Register; end record with Volatile; for Ethernet_DMA_Peripheral use record DMAMR at 16#0# range 0 .. 31; DMASBMR at 16#4# range 0 .. 31; DMAISR at 16#8# range 0 .. 31; DMADSR at 16#C# range 0 .. 31; DMACCR at 16#100# range 0 .. 31; DMACTxCR at 16#104# range 0 .. 31; DMACRxCR at 16#108# range 0 .. 31; DMACTxDLAR at 16#114# range 0 .. 31; DMACRxDLAR at 16#11C# range 0 .. 31; DMACTxDTPR at 16#120# range 0 .. 31; DMACRxDTPR at 16#128# range 0 .. 31; DMACTxRLR at 16#12C# range 0 .. 31; DMACRxRLR at 16#130# range 0 .. 31; DMACIER at 16#134# range 0 .. 31; DMACRxIWTR at 16#138# range 0 .. 31; DMACCATxDR at 16#144# range 0 .. 31; DMACCARxDR at 16#14C# range 0 .. 31; DMACCATxBR at 16#154# range 0 .. 31; DMACCARxBR at 16#15C# range 0 .. 31; DMACSR at 16#160# range 0 .. 31; DMACMFCR at 16#16C# range 0 .. 31; end record; -- Ethernet: DMA mode register (DMA) Ethernet_DMA_Periph : aliased Ethernet_DMA_Peripheral with Import, Address => Ethernet_DMA_Base; -- Ethernet: media access control (MAC) type Ethernet_MAC_Peripheral is record -- Operating mode configuration register MACCR : aliased MACCR_Register; -- Extended operating mode configuration register MACECR : aliased MACECR_Register; -- Packet filtering control register MACPFR : aliased MACPFR_Register; -- Watchdog timeout register MACWTR : aliased MACWTR_Register; -- Hash Table 0 register MACHT0R : aliased HAL.UInt32; -- Hash Table 1 register MACHT1R : aliased HAL.UInt32; -- VLAN tag register MACVTR : aliased MACVTR_Register; -- VLAN Hash table register MACVHTR : aliased MACVHTR_Register; -- VLAN inclusion register MACVIR : aliased MACVIR_Register; -- Inner VLAN inclusion register MACIVIR : aliased MACIVIR_Register; -- Tx Queue flow control register MACQTxFCR : aliased MACQTxFCR_Register; -- Rx flow control register MACRxFCR : aliased MACRxFCR_Register; -- Interrupt status register MACISR : aliased MACISR_Register; -- Interrupt enable register MACIER : aliased MACIER_Register; -- Rx Tx status register MACRxTxSR : aliased MACRxTxSR_Register; -- PMT control status register MACPCSR : aliased MACPCSR_Register; -- Remove wakeup packet filter register MACRWKPFR : aliased HAL.UInt32; -- LPI control status register MACLCSR : aliased MACLCSR_Register; -- LPI timers control register MACLTCR : aliased MACLTCR_Register; -- LPI entry timer register MACLETR : aliased MACLETR_Register; -- 1-microsecond-tick counter register MAC1USTCR : aliased MAC1USTCR_Register; -- Version register MACVR : aliased MACVR_Register; -- Debug register MACDR : aliased MACDR_Register; -- HW feature 1 register MACHWF1R : aliased MACHWF1R_Register; -- HW feature 2 register MACHWF2R : aliased MACHWF2R_Register; -- MDIO address register MACMDIOAR : aliased MACMDIOAR_Register; -- MDIO data register MACMDIODR : aliased MACMDIODR_Register; -- Address 0 high register MACA0HR : aliased MACA0HR_Register; -- Address 0 low register MACA0LR : aliased HAL.UInt32; -- Address 1 high register MACA1HR : aliased MACA1HR_Register; -- Address 1 low register MACA1LR : aliased HAL.UInt32; -- Address 2 high register MACA2HR : aliased MACA2HR_Register; -- Address 2 low register MACA2LR : aliased HAL.UInt32; -- Address 3 high register MACA3HR : aliased MACA3HR_Register; -- Address 3 low register MACA3LR : aliased HAL.UInt32; -- MMC control register MMC_CONTROL : aliased MMC_CONTROL_Register; -- MMC Rx interrupt register MMC_RX_INTERRUPT : aliased MMC_RX_INTERRUPT_Register; -- MMC Tx interrupt register MMC_TX_INTERRUPT : aliased MMC_TX_INTERRUPT_Register; -- MMC Rx interrupt mask register MMC_RX_INTERRUPT_MASK : aliased MMC_RX_INTERRUPT_MASK_Register; -- MMC Tx interrupt mask register MMC_TX_INTERRUPT_MASK : aliased MMC_TX_INTERRUPT_MASK_Register; -- Tx single collision good packets register TX_SINGLE_COLLISION_GOOD_PACKETS : aliased HAL.UInt32; -- Tx multiple collision good packets register TX_MULTIPLE_COLLISION_GOOD_PACKETS : aliased HAL.UInt32; -- Tx packet count good register TX_PACKET_COUNT_GOOD : aliased HAL.UInt32; -- Rx CRC error packets register RX_CRC_ERROR_PACKETS : aliased HAL.UInt32; -- Rx alignment error packets register RX_ALIGNMENT_ERROR_PACKETS : aliased HAL.UInt32; -- Rx unicast packets good register RX_UNICAST_PACKETS_GOOD : aliased HAL.UInt32; -- Tx LPI microsecond timer register TX_LPI_USEC_CNTR : aliased HAL.UInt32; -- Tx LPI transition counter register TX_LPI_TRAN_CNTR : aliased HAL.UInt32; -- Rx LPI microsecond counter register RX_LPI_USEC_CNTR : aliased HAL.UInt32; -- Rx LPI transition counter register RX_LPI_TRAN_CNTR : aliased HAL.UInt32; -- L3 and L4 control 0 register MACL3L4C0R : aliased MACL3L4C0R_Register; -- Layer4 address filter 0 register MACL4A0R : aliased MACL4A0R_Register; -- MACL3A00R MACL3A00R : aliased HAL.UInt32; -- Layer3 address 1 filter 0 register MACL3A10R : aliased HAL.UInt32; -- Layer3 Address 2 filter 0 register MACL3A20 : aliased HAL.UInt32; -- Layer3 Address 3 filter 0 register MACL3A30 : aliased HAL.UInt32; -- L3 and L4 control 1 register MACL3L4C1R : aliased MACL3L4C1R_Register; -- Layer 4 address filter 1 register MACL4A1R : aliased MACL4A1R_Register; -- Layer3 address 0 filter 1 Register MACL3A01R : aliased HAL.UInt32; -- Layer3 address 1 filter 1 register MACL3A11R : aliased HAL.UInt32; -- Layer3 address 2 filter 1 Register MACL3A21R : aliased HAL.UInt32; -- Layer3 address 3 filter 1 register MACL3A31R : aliased HAL.UInt32; -- ARP address register MACARPAR : aliased HAL.UInt32; -- Timestamp control Register MACTSCR : aliased MACTSCR_Register; -- Sub-second increment register MACSSIR : aliased MACSSIR_Register; -- System time seconds register MACSTSR : aliased HAL.UInt32; -- System time nanoseconds register MACSTNR : aliased MACSTNR_Register; -- System time seconds update register MACSTSUR : aliased HAL.UInt32; -- System time nanoseconds update register MACSTNUR : aliased MACSTNUR_Register; -- Timestamp addend register MACTSAR : aliased HAL.UInt32; -- Timestamp status register MACTSSR : aliased MACTSSR_Register; -- Tx timestamp status nanoseconds register MACTxTSSNR : aliased MACTxTSSNR_Register; -- Tx timestamp status seconds register MACTxTSSSR : aliased HAL.UInt32; -- Auxiliary control register MACACR : aliased MACACR_Register; -- Auxiliary timestamp nanoseconds register MACATSNR : aliased MACATSNR_Register; -- Auxiliary timestamp seconds register MACATSSR : aliased HAL.UInt32; -- Timestamp Ingress asymmetric correction register MACTSIACR : aliased HAL.UInt32; -- Timestamp Egress asymmetric correction register MACTSEACR : aliased HAL.UInt32; -- Timestamp Ingress correction nanosecond register MACTSICNR : aliased HAL.UInt32; -- Timestamp Egress correction nanosecond register MACTSECNR : aliased HAL.UInt32; -- PPS control register MACPPSCR : aliased MACPPSCR_Register; -- PPS target time seconds register MACPPSTTSR : aliased MACPPSTTSR_Register; -- PPS target time nanoseconds register MACPPSTTNR : aliased MACPPSTTNR_Register; -- PPS interval register MACPPSIR : aliased HAL.UInt32; -- PPS width register MACPPSWR : aliased HAL.UInt32; -- PTP Offload control register MACPOCR : aliased MACPOCR_Register; -- PTP Source Port Identity 0 Register MACSPI0R : aliased HAL.UInt32; -- PTP Source port identity 1 register MACSPI1R : aliased HAL.UInt32; -- PTP Source port identity 2 register MACSPI2R : aliased MACSPI2R_Register; -- Log message interval register MACLMIR : aliased MACLMIR_Register; end record with Volatile; for Ethernet_MAC_Peripheral use record MACCR at 16#0# range 0 .. 31; MACECR at 16#4# range 0 .. 31; MACPFR at 16#8# range 0 .. 31; MACWTR at 16#C# range 0 .. 31; MACHT0R at 16#10# range 0 .. 31; MACHT1R at 16#14# range 0 .. 31; MACVTR at 16#50# range 0 .. 31; MACVHTR at 16#58# range 0 .. 31; MACVIR at 16#60# range 0 .. 31; MACIVIR at 16#64# range 0 .. 31; MACQTxFCR at 16#70# range 0 .. 31; MACRxFCR at 16#90# range 0 .. 31; MACISR at 16#B0# range 0 .. 31; MACIER at 16#B4# range 0 .. 31; MACRxTxSR at 16#B8# range 0 .. 31; MACPCSR at 16#C0# range 0 .. 31; MACRWKPFR at 16#C4# range 0 .. 31; MACLCSR at 16#D0# range 0 .. 31; MACLTCR at 16#D4# range 0 .. 31; MACLETR at 16#D8# range 0 .. 31; MAC1USTCR at 16#DC# range 0 .. 31; MACVR at 16#110# range 0 .. 31; MACDR at 16#114# range 0 .. 31; MACHWF1R at 16#120# range 0 .. 31; MACHWF2R at 16#124# range 0 .. 31; MACMDIOAR at 16#200# range 0 .. 31; MACMDIODR at 16#204# range 0 .. 31; MACA0HR at 16#300# range 0 .. 31; MACA0LR at 16#304# range 0 .. 31; MACA1HR at 16#308# range 0 .. 31; MACA1LR at 16#30C# range 0 .. 31; MACA2HR at 16#310# range 0 .. 31; MACA2LR at 16#314# range 0 .. 31; MACA3HR at 16#318# range 0 .. 31; MACA3LR at 16#31C# range 0 .. 31; MMC_CONTROL at 16#700# range 0 .. 31; MMC_RX_INTERRUPT at 16#704# range 0 .. 31; MMC_TX_INTERRUPT at 16#708# range 0 .. 31; MMC_RX_INTERRUPT_MASK at 16#70C# range 0 .. 31; MMC_TX_INTERRUPT_MASK at 16#710# range 0 .. 31; TX_SINGLE_COLLISION_GOOD_PACKETS at 16#74C# range 0 .. 31; TX_MULTIPLE_COLLISION_GOOD_PACKETS at 16#750# range 0 .. 31; TX_PACKET_COUNT_GOOD at 16#768# range 0 .. 31; RX_CRC_ERROR_PACKETS at 16#794# range 0 .. 31; RX_ALIGNMENT_ERROR_PACKETS at 16#798# range 0 .. 31; RX_UNICAST_PACKETS_GOOD at 16#7C4# range 0 .. 31; TX_LPI_USEC_CNTR at 16#7EC# range 0 .. 31; TX_LPI_TRAN_CNTR at 16#7F0# range 0 .. 31; RX_LPI_USEC_CNTR at 16#7F4# range 0 .. 31; RX_LPI_TRAN_CNTR at 16#7F8# range 0 .. 31; MACL3L4C0R at 16#900# range 0 .. 31; MACL4A0R at 16#904# range 0 .. 31; MACL3A00R at 16#910# range 0 .. 31; MACL3A10R at 16#914# range 0 .. 31; MACL3A20 at 16#918# range 0 .. 31; MACL3A30 at 16#91C# range 0 .. 31; MACL3L4C1R at 16#930# range 0 .. 31; MACL4A1R at 16#934# range 0 .. 31; MACL3A01R at 16#940# range 0 .. 31; MACL3A11R at 16#944# range 0 .. 31; MACL3A21R at 16#948# range 0 .. 31; MACL3A31R at 16#94C# range 0 .. 31; MACARPAR at 16#AE0# range 0 .. 31; MACTSCR at 16#B00# range 0 .. 31; MACSSIR at 16#B04# range 0 .. 31; MACSTSR at 16#B08# range 0 .. 31; MACSTNR at 16#B0C# range 0 .. 31; MACSTSUR at 16#B10# range 0 .. 31; MACSTNUR at 16#B14# range 0 .. 31; MACTSAR at 16#B18# range 0 .. 31; MACTSSR at 16#B20# range 0 .. 31; MACTxTSSNR at 16#B30# range 0 .. 31; MACTxTSSSR at 16#B34# range 0 .. 31; MACACR at 16#B40# range 0 .. 31; MACATSNR at 16#B48# range 0 .. 31; MACATSSR at 16#B4C# range 0 .. 31; MACTSIACR at 16#B50# range 0 .. 31; MACTSEACR at 16#B54# range 0 .. 31; MACTSICNR at 16#B58# range 0 .. 31; MACTSECNR at 16#B5C# range 0 .. 31; MACPPSCR at 16#B70# range 0 .. 31; MACPPSTTSR at 16#B80# range 0 .. 31; MACPPSTTNR at 16#B84# range 0 .. 31; MACPPSIR at 16#B88# range 0 .. 31; MACPPSWR at 16#B8C# range 0 .. 31; MACPOCR at 16#BC0# range 0 .. 31; MACSPI0R at 16#BC4# range 0 .. 31; MACSPI1R at 16#BC8# range 0 .. 31; MACSPI2R at 16#BCC# range 0 .. 31; MACLMIR at 16#BD0# range 0 .. 31; end record; -- Ethernet: media access control (MAC) Ethernet_MAC_Periph : aliased Ethernet_MAC_Peripheral with Import, Address => Ethernet_MAC_Base; -- Ethernet: MTL mode register (MTL) type Ethernet_MTL_Peripheral is record -- Operating mode Register MTLOMR : aliased MTLOMR_Register; -- Interrupt status Register MTLISR : aliased MTLISR_Register; -- Tx queue operating mode Register MTLTxQOMR : aliased MTLTxQOMR_Register; -- Tx queue underflow register MTLTxQUR : aliased MTLTxQUR_Register; -- Tx queue debug Register MTLTxQDR : aliased MTLTxQDR_Register; -- Queue interrupt control status Register MTLQICSR : aliased MTLQICSR_Register; -- Rx queue operating mode register MTLRxQOMR : aliased MTLRxQOMR_Register; -- Rx queue missed packet and overflow counter register MTLRxQMPOCR : aliased MTLRxQMPOCR_Register; -- Rx queue debug register MTLRxQDR : aliased MTLRxQDR_Register; end record with Volatile; for Ethernet_MTL_Peripheral use record MTLOMR at 16#0# range 0 .. 31; MTLISR at 16#20# range 0 .. 31; MTLTxQOMR at 16#100# range 0 .. 31; MTLTxQUR at 16#104# range 0 .. 31; MTLTxQDR at 16#108# range 0 .. 31; MTLQICSR at 16#12C# range 0 .. 31; MTLRxQOMR at 16#130# range 0 .. 31; MTLRxQMPOCR at 16#134# range 0 .. 31; MTLRxQDR at 16#138# range 0 .. 31; end record; -- Ethernet: MTL mode register (MTL) Ethernet_MTL_Periph : aliased Ethernet_MTL_Peripheral with Import, Address => Ethernet_MTL_Base; end STM32_SVD.Ethernet;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure In_Och_Utmatningar is I: Integer; F: Float; C: Character; S: String(1..6); begin Put("Skriv in en sträng med 3 tecken: "); Get_Line(S, I); Put(S(1..3)); New_Line(1); Put("Skriv in ett heltal och en sträng med 5 tecken: "); Get(I); Put("Du skrev in talet |"); Put(I,1); Put("| och strängen |"); Get_Line(S, I); Put(S(2..6)); Put("|."); New_Line(1); Put("Skriv in en sträng med 3 tecken och ett flyttal: "); --Skip_Line; Get_Line(S, I); --Get(F); Put_Line(S); --Put("Du skrev in """); Put(F, 3, 3, 0); Put(""" "); Put(S); end In_Och_Utmatningar;
-- This file only exists because of circular type dependencies in the C -- library. Types must therefore be collected here, imported and renamed -- in each package to prevent loops. with agar.core.tail_queue; with agar.core.types; with agar.gui.rect; with agar.gui.widget.box; with agar.gui.widget.button; with agar.gui.widget.label; with agar.gui.widget; package agar.gui.types is -- widget.icon type widget_icon_t is limited private; type widget_icon_access_t is access all widget_icon_t; pragma convention (c, widget_icon_access_t); type widget_icon_flags_t is new c.unsigned; pragma convention (c, widget_icon_flags_t); function widget_icon_widget (icon : widget_icon_access_t) return agar.gui.widget.widget_access_t; pragma inline (widget_icon_widget); -- window type window_t is limited private; type window_access_t is access all window_t; pragma convention (c, window_access_t); type window_flags_t is new c.unsigned; pragma convention (c, window_flags_t); package window_tail_queue is new agar.core.tail_queue (entry_type => window_access_t); type window_alignment_t is ( WINDOW_TL, WINDOW_TC, WINDOW_TR, WINDOW_ML, WINDOW_MC, WINDOW_MR, WINDOW_BL, WINDOW_BC, WINDOW_BR ); for window_alignment_t use ( WINDOW_TL => 0, WINDOW_TC => 1, WINDOW_TR => 2, WINDOW_ML => 3, WINDOW_MC => 4, WINDOW_MR => 5, WINDOW_BL => 6, WINDOW_BC => 7, WINDOW_BR => 8 ); for window_alignment_t'size use c.unsigned'size; pragma convention (c, window_alignment_t); window_caption_max : constant c.unsigned := 512; function window_widget (window : window_access_t) return agar.gui.widget.widget_access_t; pragma inline (window_widget); -- widget.titlebar type widget_titlebar_t is limited private; type widget_titlebar_access_t is access all widget_titlebar_t; pragma convention (c, widget_titlebar_access_t); type widget_titlebar_flags_t is new c.unsigned; function widget_titlebar_widget (titlebar : widget_titlebar_access_t) return agar.gui.widget.widget_access_t; pragma inline (widget_titlebar_widget); private type widget_icon_name_t is array (1 .. agar.gui.widget.label.max) of aliased c.char; pragma convention (c, widget_icon_name_t); type widget_icon_t is record widget : aliased agar.gui.widget.widget_t; flags : widget_icon_flags_t; surface : c.int; label_text : widget_icon_name_t; label_surface : c.int; label_pad : c.int; window : window_access_t; socket : agar.core.types.void_ptr_t; x_saved : c.int; y_saved : c.int; w_saved : c.int; h_saved : c.int; c_background : agar.core.types.uint32_t; end record; pragma convention (c, widget_icon_t); type window_caption_t is array (1 .. window_caption_max) of aliased c.char; pragma convention (c, window_caption_t); type window_t is record widget : aliased agar.gui.widget.widget_t; flags : window_flags_t; caption : window_caption_t; visible : c.int; tbar : widget_titlebar_access_t; alignment : window_alignment_t; spacing : c.int; tpad : c.int; bpad : c.int; lpad : c.int; rpad : c.int; reqw : c.int; reqh : c.int; minw : c.int; minh : c.int; border_bot : c.int; border_side : c.int; resize_ctrl : c.int; r_saved : agar.gui.rect.rect_t; min_pct : c.int; subwins : window_tail_queue.head_t; windows : window_tail_queue.entry_t; swins : window_tail_queue.entry_t; detach : window_tail_queue.entry_t; icon : widget_icon_access_t; r : agar.gui.rect.rect_t; end record; pragma convention (c, window_t); type widget_titlebar_t is record box : aliased agar.gui.widget.box.box_t; flags : widget_titlebar_flags_t; pressed : c.int; window : window_access_t; label : agar.gui.widget.label.label_access_t; close_button : agar.gui.widget.button.button_access_t; minimize_button : agar.gui.widget.button.button_access_t; maximize_button : agar.gui.widget.button.button_access_t; end record; pragma convention (c, widget_titlebar_t); end agar.gui.types;
-- { dg-do run } -- { dg-options "-gnatws" } procedure Small_Alignment is type My_Integer is new Integer; for My_Integer'Alignment use 1; function Set_A return My_Integer is begin return 12; end; function Set_B return My_Integer is begin return 6; end; C : Character; A : My_Integer := Set_A; B : My_Integer := Set_B; begin A := A * B / 2; if A /= 36 then raise Program_Error; end if; end;
with Ada.Integer_Text_IO; with Ada.Numerics.Long_Elementary_Functions; -- Copyright 2021 Melwyn Francis Carlo procedure A002 is use Ada.Integer_Text_IO; use Ada.Numerics.Long_Elementary_Functions; ---------------------------------------------------------------------------- function Binets_Formula (N_Val : in Integer) return Long_Float; function Binets_Formula (N_Val : in Integer) return Long_Float is begin return (1.0 / Sqrt (5.0)) * ((((1.0 + Sqrt (5.0)) / 2.0) ** N_Val) - (((1.0 - Sqrt (5.0)) / 2.0) ** N_Val)); end Binets_Formula; ---------------------------------------------------------------------------- N : Integer; Fn_Sum, Fn_Sum_Even : Long_Float; Fn_Max : constant Long_Float := 4.0E+6; ---------------------------------------------------------------------------- begin N := Integer (Log ((Fn_Max * Sqrt (5.0)) + 0.5) / Log ((1.0 + Sqrt (5.0)) / 2.0)); Fn_Sum := Binets_Formula (N + 2) - 1.0; Fn_Sum_Even := Fn_Sum / 2.0; Put (Integer (Fn_Sum_Even), Width => 0); end A002;
package body LATIN_FILE_NAMES is function ADD_FILE_NAME_EXTENSION(NAME, EXTENSION : STRING) return STRING is -- This is the version that creates a DOS file name -- One that has a name, a '.', and an extension no longer than 3 characters -- Arbitarily, we also truncate the NAME to 8 characters -- To port to another system, one needs to do this function appropriately NAME_LENGTH : INTEGER := NAME'LENGTH; EXTENSION_LENGTH : INTEGER := EXTENSION'LENGTH; begin if NAME_LENGTH >= 8 then NAME_LENGTH := 8; end if; if EXTENSION'LENGTH >= 3 then EXTENSION_LENGTH := 3; end if; return NAME(1..NAME_LENGTH) & '.' & EXTENSION(1..EXTENSION_LENGTH); end ADD_FILE_NAME_EXTENSION; end LATIN_FILE_NAMES;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Yaml.Lexer.Evaluation; package body Yaml.Lexer is use type Text.Reference; ----------------------------------------------------------------------------- -- Initialization and buffer handling -- ----------------------------------------------------------------------------- procedure Basic_Init (L : in out Instance; Pool : Text.Pool.Reference) is begin L.State := Outside_Doc'Access; L.Flow_Depth := 0; L.Annotation_Depth := 0; L.Line_Start_State := Outside_Doc'Access; L.Json_Enabling_State := After_Token'Access; L.Pool := Pool; L.Proposed_Indentation := -1; end Basic_Init; procedure Init (L : in out Instance; Input : Source.Pointer; Pool : Text.Pool.Reference; Initial_Buffer_Size : Positive := Default_Initial_Buffer_Size) is begin L.Init (Input, Initial_Buffer_Size); Basic_Init (L, Pool); L.Cur := Next (L); end Init; procedure Init (L : in out Instance; Input : String; Pool : Text.Pool.Reference) is begin L.Init (Input); Basic_Init (L, Pool); L.Cur := Next (L); end Init; ----------------------------------------------------------------------------- -- interface and utilities ----------------------------------------------------------------------------- function Escaped (S : String) return String is Ret : String (1 .. S'Length * 4 + 2) := (1 => '"', others => <>); Retpos : Positive := 2; procedure Add_Escape_Sequence (C : Character) with Inline is begin Ret (Retpos .. Retpos + 1) := "\" & C; Retpos := Retpos + 2; end Add_Escape_Sequence; begin for C of S loop case C is when Line_Feed => Add_Escape_Sequence ('l'); when Carriage_Return => Add_Escape_Sequence ('c'); when '"' | ''' | '\' => Add_Escape_Sequence (C); when Character'Val (9) => Add_Escape_Sequence ('t'); when Character'Val (0) .. Character'Val (8) | Character'Val (11) | Character'Val (12) | Character'Val (14) .. Character'Val (31) => Add_Escape_Sequence ('x'); declare type Byte is range 0 .. 255; Charpos : constant Byte := Character'Pos (C); begin Ret (Retpos .. Retpos + 1) := (Character'Val (Charpos / 16 + Character'Pos ('0'))) & (Character'Val (Charpos mod 16 + Character'Pos ('0'))); Retpos := Retpos + 2; end; when others => Ret (Retpos) := C; Retpos := Retpos + 1; end case; end loop; Ret (Retpos) := '"'; return Ret (1 .. Retpos); end Escaped; function Escaped (C : Character) return String is (Escaped ("" & C)); function Escaped (C : Text.Reference) return String is (Escaped (C.Value)); function Next_Is_Plain_Safe (L : Instance) return Boolean is (case L.Buffer (L.Pos) is when Space_Or_Line_End => False, when Flow_Indicator => L.Flow_Depth + L.Annotation_Depth = 0, when ')' => L.Annotation_Depth = 0, when others => True); function Next_Token (L : in out Instance) return Token is Ret : Token; begin loop exit when L.State.all (L, Ret); end loop; return Ret; end Next_Token; function Short_Lexeme (L : Instance) return String is (L.Buffer (L.Token_Start .. L.Pos - 2)); function Full_Lexeme (L : Instance) return String is (L.Buffer (L.Token_Start - 1 .. L.Pos - 2)); procedure Start_Token (L : in out Instance) is begin L.Token_Start := L.Pos; L.Token_Start_Mark := Cur_Mark (L); end Start_Token; function Cur_Mark (L : Instance; Offset : Integer := -1) return Mark is ((Line => L.Cur_Line, Column => L.Pos + 1 - L.Line_Start + Offset, Index => L.Prev_Lines_Chars + L.Pos + 1 - L.Line_Start + Offset)); function Current_Content (L : Instance) return Text.Reference is (L.Value); function Escaped_Current (L : Instance) return String is (Escaped (L.Value)); function Current_Indentation (L : Instance) return Indentation_Type is (L.Pos - L.Line_Start - 1); function Recent_Indentation (L : Instance) return Indentation_Type is (L.Indentation); function Last_Scalar_Was_Multiline (L : Instance) return Boolean is (L.Seen_Multiline); function Recent_Start_Mark (L : Instance) return Mark is (L.Token_Start_Mark); -- to be called whenever a '-' is read as first character in a line. this -- function checks for whether this is a directives end marker ('---'). if -- yes, the lexer position is updated to be after the marker. function Is_Directives_End (L : in out Instance) return Boolean is Peek : Positive := L.Pos; begin if L.Buffer (Peek) = '-' then Peek := Peek + 1; if L.Buffer (Peek) = '-' then Peek := Peek + 1; if L.Buffer (Peek) in Space_Or_Line_End then L.Pos := Peek; L.Cur := Next (L); return True; end if; end if; end if; return False; end Is_Directives_End; -- similar to Hyphen_Line_Type, this function checks whether, when a line -- begin with a '.', that line contains a document end marker ('...'). if -- yes, the lexer position is updated to be after the marker. function Is_Document_End (L : in out Instance) return Boolean is Peek : Positive := L.Pos; begin if L.Buffer (Peek) = '.' then Peek := Peek + 1; if L.Buffer (Peek) = '.' then Peek := Peek + 1; if L.Buffer (Peek) in Space_Or_Line_End then L.Pos := Peek; L.Cur := Next (L); return True; end if; end if; end if; return False; end Is_Document_End; function Start_Line (L : in out Instance) return Line_Start_Kind is begin case L.Cur is when '-' => return (if Is_Directives_End (L) then Directives_End_Marker else Content); when '.' => return (if Is_Document_End (L) then Document_End_Marker else Content); when others => while L.Cur = ' ' loop L.Cur := Next (L); end loop; return (case L.Cur is when '#' => Comment, when Line_Feed | Carriage_Return => Newline, when End_Of_Input => Stream_End, when others => Content); end case; end Start_Line; ----------------------------------------------------------------------------- -- Tokenization -- ----------------------------------------------------------------------------- function Outside_Doc (L : in out Instance; T : out Token) return Boolean is begin case L.Cur is when '%' => Start_Token (L); loop L.Cur := Next (L); exit when L.Cur in Space_Or_Line_End; end loop; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => <>); declare Name : constant String := Short_Lexeme (L); begin if Name = "YAML" then L.State := Yaml_Version'Access; T.Kind := Yaml_Directive; return True; elsif Name = "TAG" then L.State := Tag_Shorthand'Access; T.Kind := Tag_Directive; return True; else L.State := Unknown_Directive'Access; T.Kind := Unknown_Directive; return True; end if; end; when '-' => Start_Token (L); if Is_Directives_End (L) then L.State := After_Token'Access; T.Kind := Directives_End; else L.State := Indentation_Setting_Token'Access; T.Kind := Indentation; end if; T.Start_Pos := L.Token_Start_Mark; T.End_Pos := Cur_Mark (L); L.Indentation := -1; L.Line_Start_State := Line_Start'Access; return True; when '.' => Start_Token (L); if Is_Document_End (L) then L.State := Expect_Line_End'Access; T.Kind := Document_End; else L.State := Indentation_Setting_Token'Access; L.Line_Start_State := Line_Start'Access; L.Indentation := -1; T.Kind := Indentation; end if; T.Start_Pos := L.Token_Start_Mark; T.End_Pos := Cur_Mark (L); return True; when others => Start_Token (L); while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur in Comment_Or_Line_End then L.State := Expect_Line_End'Access; return False; end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Indentation); L.Indentation := -1; L.State := Indentation_Setting_Token'Access; L.Line_Start_State := Line_Start'Access; return True; end case; end Outside_Doc; function Yaml_Version (L : in out Instance; T : out Token) return Boolean is procedure Read_Numeric_Subtoken is begin if not (L.Cur in Digit) then raise Lexer_Error with "Illegal character in YAML version string: " & Escaped (L.Cur); end if; loop L.Cur := Next (L); exit when not (L.Cur in Digit); end loop; end Read_Numeric_Subtoken; begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; Start_Token (L); Read_Numeric_Subtoken; if L.Cur /= '.' then raise Lexer_Error with "Illegal character in YAML version string: " & Escaped (L.Cur); end if; L.Cur := Next (L); Read_Numeric_Subtoken; if not (L.Cur in Space_Or_Line_End) then raise Lexer_Error with "Illegal character in YAML version string: " & Escaped (L.Cur); end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Directive_Param); L.State := Expect_Line_End'Access; return True; end Yaml_Version; function Tag_Shorthand (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur /= '!' then raise Lexer_Error with "Illegal character, tag shorthand must start with ""!"":" & Escaped (L.Cur); end if; Start_Token (L); L.Cur := Next (L); if L.Cur /= ' ' then while L.Cur in Tag_Shorthand_Char loop L.Cur := Next (L); end loop; if L.Cur /= '!' then if L.Cur in Space_Or_Line_End then raise Lexer_Error with "Tag shorthand must end with ""!""."; else raise Lexer_Error with "Illegal character in tag shorthand: " & Escaped (L.Cur); end if; end if; L.Cur := Next (L); if L.Cur /= ' ' then raise Lexer_Error with "Missing space after tag shorthand"; end if; end if; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Tag_Handle); L.State := At_Tag_Uri'Access; return True; end Tag_Shorthand; function At_Tag_Uri (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; Start_Token (L); if L.Cur = '<' then raise Lexer_Error with "Illegal character in tag prefix: " & Escaped (L.Cur); end if; Evaluation.Read_URI (L, False); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Suffix); L.State := Expect_Line_End'Access; return True; end At_Tag_Uri; function Unknown_Directive (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur in Comment_Or_Line_End then L.State := Expect_Line_End'Access; return False; end if; Start_Token (L); loop L.Cur := Next (L); exit when L.Cur in Space_Or_Line_End; end loop; T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Directive_Param); return True; end Unknown_Directive; procedure End_Line (L : in out Instance) is begin loop case L.Cur is when Line_Feed => Handle_LF (L); L.Cur := L.Next; L.State := L.Line_Start_State; exit; when Carriage_Return => Handle_CR (L); L.Cur := L.Next; L.State := L.Line_Start_State; exit; when End_Of_Input => L.State := Stream_End'Access; exit; when '#' => loop L.Cur := Next (L); exit when L.Cur in Line_End; end loop; when others => null; -- forbidden by precondition end case; end loop; end End_Line; function Expect_Line_End (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if not (L.Cur in Comment_Or_Line_End) then raise Lexer_Error with "Unexpected character (expected line end): " & Escaped (L.Cur); end if; End_Line (L); return False; end Expect_Line_End; function Stream_End (L : in out Instance; T : out Token) return Boolean is begin Start_Token (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Stream_End); return True; end Stream_End; function Line_Start (L : in out Instance; T : out Token) return Boolean is begin case Start_Line (L) is when Directives_End_Marker => return Line_Dir_End (L, T); when Document_End_Marker => return Line_Doc_End (L, T); when Comment | Newline => End_Line (L); return False; when Stream_End => L.State := Stream_End'Access; return False; when Content => return Line_Indentation (L, T); end case; end Line_Start; function Flow_Line_Start (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); Indent : Natural; begin case L.Cur is when '-' => if Is_Directives_End (L) then raise Lexer_Error with "Directives end marker before end of flow content"; else Indent := 0; end if; when '.' => if Is_Document_End (L) then raise Lexer_Error with "Document end marker before end of flow content"; else Indent := 0; end if; when others => while L.Cur = ' ' loop L.Cur := Next (L); end loop; Indent := L.Pos - L.Line_Start - 1; end case; if Indent <= L.Indentation then raise Lexer_Error with "Too few indentation spaces (must surpass surrounding block element)" & L.Indentation'Img; end if; L.State := Inside_Line'Access; return False; end Flow_Line_Start; function Flow_Line_Indentation (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); begin if L.Pos - L.Line_Start - 1 < L.Indentation then raise Lexer_Error with "Too few indentation spaces (must surpass surrounding block element)"; end if; L.State := Inside_Line'Access; return False; end Flow_Line_Indentation; procedure Check_Indicator_Char (L : in out Instance; Kind : Token_Kind; T : out Token) is begin if Next_Is_Plain_Safe (L) then Evaluation.Read_Plain_Scalar (L, T); else Start_Token (L); L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); L.State := Before_Indentation_Setting_Token'Access; end if; end Check_Indicator_Char; procedure Enter_Flow_Collection (L : in out Instance; T : out Token; Kind : Token_Kind) is begin Start_Token (L); if L.Flow_Depth + L.Annotation_Depth = 0 then L.Json_Enabling_State := After_Json_Enabling_Token'Access; L.Line_Start_State := Flow_Line_Start'Access; L.Proposed_Indentation := -1; end if; L.Flow_Depth := L.Flow_Depth + 1; L.State := After_Token'Access; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); end Enter_Flow_Collection; procedure Leave_Flow_Collection (L : in out Instance; T : out Token; Kind : Token_Kind) is begin Start_Token (L); if L.Flow_Depth = 0 then raise Lexer_Error with "No flow collection to leave!"; end if; L.Flow_Depth := L.Flow_Depth - 1; if L.Flow_Depth + L.Annotation_Depth = 0 then L.Json_Enabling_State := After_Token'Access; L.Line_Start_State := Line_Start'Access; end if; L.State := L.Json_Enabling_State; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); end Leave_Flow_Collection; procedure Read_Namespace (L : in out Instance; T : out Token; NS_Char : Character; Kind : Token_Kind) with Pre => L.Cur = NS_Char is begin Start_Token (L); L.Cur := Next (L); if L.Cur = '<' then raise Lexer_Error with "Verbatim URIs not supported in YAML 1.3"; else -- we need to scan for a possible second NS_Char in case this is not a -- primary tag handle. We must lookahead here because there may be -- URI characters in the suffix that are not allowed in the handle. declare Handle_End : Positive := L.Token_Start; begin loop if L.Buffer (Handle_End) in Space_Or_Line_End | Flow_Indicator | Annotation_Param_Indicator then Handle_End := L.Token_Start; L.Pos := L.Pos - 1; exit; elsif L.Buffer (Handle_End) = NS_Char then Handle_End := Handle_End + 1; exit; else Handle_End := Handle_End + 1; end if; end loop; while L.Pos < Handle_End loop L.Cur := Next (L); if not (L.Cur in Tag_Shorthand_Char | NS_Char) then raise Lexer_Error with "Illegal character in tag handle: " & Escaped (L.Cur); end if; end loop; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Kind); L.State := At_Suffix'Access; end; end if; end Read_Namespace; procedure Read_Anchor_Name (L : in out Instance) is begin Start_Token (L); loop L.Cur := Next (L); exit when not (L.Cur in Ascii_Char | Digit | '-' | '_'); end loop; if not (L.Cur in Space_Or_Line_End | Flow_Indicator | ')') then raise Lexer_Error with "Illegal character in anchor: " & Escaped (L.Cur); elsif L.Pos = L.Token_Start + 1 then raise Lexer_Error with "Anchor name must not be empty"; end if; L.State := After_Token'Access; end Read_Anchor_Name; function Inside_Line (L : in out Instance; T : out Token) return Boolean is begin case L.Cur is when ':' => Check_Indicator_Char (L, Map_Value_Ind, T); if T.Kind = Map_Value_Ind and then L.Proposed_Indentation /= -1 then -- necessary in the case of an empty scalar with node props -- in an implicit block map key L.Indentation := L.Proposed_Indentation; L.Proposed_Indentation := -1; end if; return True; when '?' => Check_Indicator_Char (L, Map_Key_Ind, T); return True; when '-' => Check_Indicator_Char (L, Seq_Item_Ind, T); return True; when Comment_Or_Line_End => End_Line (L); return False; when '"' => Evaluation.Read_Double_Quoted_Scalar (L, T); L.State := L.Json_Enabling_State; return True; when ''' => Evaluation.Read_Single_Quoted_Scalar (L, T); L.State := L.Json_Enabling_State; return True; when '>' | '|' => if L.Flow_Depth + L.Annotation_Depth > 0 then Evaluation.Read_Plain_Scalar (L, T); else Evaluation.Read_Block_Scalar (L, T); end if; return True; when '{' => Enter_Flow_Collection (L, T, Flow_Map_Start); return True; when '}' => Leave_Flow_Collection (L, T, Flow_Map_End); return True; when '[' => Enter_Flow_Collection (L, T, Flow_Seq_Start); return True; when ']' => Leave_Flow_Collection (L, T, Flow_Seq_End); return True; when ')' => Start_Token (L); if L.Annotation_Depth > 0 then L.Annotation_Depth := L.Annotation_Depth - 1; if L.Flow_Depth + L.Annotation_Depth = 0 then L.Json_Enabling_State := After_Token'Access; L.Line_Start_State := Line_Start'Access; end if; L.State := After_Token'Access; L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Params_End); else Evaluation.Read_Plain_Scalar (L, T); end if; return True; when ',' => Start_Token (L); L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Flow_Separator); L.State := After_Token'Access; return True; when '!' => Read_Namespace (L, T, '!', Tag_Handle); return True; when '&' => Read_Anchor_Name (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Anchor); return True; when '*' => Read_Anchor_Name (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Alias); return True; when '@' => Read_Namespace (L, T, '@', Annotation_Handle); return True; when '`' => raise Lexer_Error with "Reserved characters cannot start a plain scalar."; when others => Evaluation.Read_Plain_Scalar (L, T); return True; end case; end Inside_Line; function Indentation_Setting_Token (L : in out Instance; T : out Token) return Boolean is Cached_Indentation : constant Natural := L.Pos - L.Line_Start - 1; begin return Ret : constant Boolean := Inside_Line (L, T) do if Ret and then L.Flow_Depth + L.Annotation_Depth = 0 then if T.Kind in Node_Property_Kind then L.Proposed_Indentation := Cached_Indentation; else L.Indentation := Cached_Indentation; end if; end if; end return; end Indentation_Setting_Token; function After_Token (L : in out Instance; T : out Token) return Boolean is pragma Unreferenced (T); begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; if L.Cur in Comment_Or_Line_End then End_Line (L); else L.State := Inside_Line'Access; end if; return False; end After_Token; function Before_Indentation_Setting_Token (L : in out Instance; T : out Token) return Boolean is begin if After_Token (L, T) then null; end if; if L.State = Inside_Line'Access then L.State := Indentation_Setting_Token'Access; end if; return False; end Before_Indentation_Setting_Token; function After_Json_Enabling_Token (L : in out Instance; T : out Token) return Boolean is begin while L.Cur = ' ' loop L.Cur := Next (L); end loop; loop case L.Cur is when ':' => Start_Token (L); L.Cur := Next (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Map_Value_Ind); L.State := After_Token'Access; return True; when '#' | Carriage_Return | Line_Feed => End_Line (L); if Flow_Line_Start (L, T) then null; end if; when End_Of_Input => L.State := Stream_End'Access; return False; when others => L.State := Inside_Line'Access; return False; end case; end loop; end After_Json_Enabling_Token; function Line_Indentation (L : in out Instance; T : out Token) return Boolean is begin T := (Start_Pos => (Line => L.Cur_Line, Column => 1, Index => L.Prev_Lines_Chars), End_Pos => Cur_Mark (L), Kind => Indentation); L.State := Indentation_Setting_Token'Access; return True; end Line_Indentation; function Line_Dir_End (L : in out Instance; T : out Token) return Boolean is begin T := (Start_Pos => (Line => L.Cur_Line, Column => 1, Index => L.Prev_Lines_Chars), End_Pos => Cur_Mark (L), Kind => Directives_End); L.State := After_Token'Access; L.Indentation := -1; L.Proposed_Indentation := -1; return True; end Line_Dir_End; -- similar to Indentation_After_Plain_Scalar, but used for a document end -- marker ending a plain scalar. function Line_Doc_End (L : in out Instance; T : out Token) return Boolean is begin T := (Start_Pos => (Line => L.Cur_Line, Column => 1, Index => L.Prev_Lines_Chars), End_Pos => Cur_Mark (L), Kind => Document_End); L.State := Expect_Line_End'Access; L.Line_Start_State := Outside_Doc'Access; return True; end Line_Doc_End; function At_Suffix (L : in out Instance; T : out Token) return Boolean is begin Start_Token (L); while L.Cur in Suffix_Char loop L.Cur := Next (L); end loop; L.Value := L.Pool.From_String (L.Full_Lexeme); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Suffix); L.State := After_Suffix'Access; return True; end At_Suffix; function After_Suffix (L : in out Instance; T : out Token) return Boolean is begin L.State := After_Token'Access; if L.Cur = '(' then Start_Token (L); T := (Start_Pos => L.Token_Start_Mark, End_Pos => Cur_Mark (L), Kind => Params_Start); L.Annotation_Depth := L.Annotation_Depth + 1; L.Proposed_Indentation := -1; L.Cur := Next (L); return True; else return False; end if; end After_Suffix; end Yaml.Lexer;
-- Motherlode -- Copyright (c) 2020 Fabien Chouteau package Sound is procedure Tick; procedure Play_Coin; procedure Play_Drill; procedure Play_Music; procedure Stop_Music; end Sound;
-- Ada_GUI implementation based on Gnoga. Adapted 2021 -- -- -- GNOGA - The GNU Omnificent GUI for Ada -- -- -- -- G N O G A . S E R V E R . T E M P L A T E _ P A R S E R -- -- -- -- S p e c -- -- -- -- -- -- Copyright (C) 2014 David Botton -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This 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. -- -- -- -- 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/>. -- -- -- -- 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. -- -- -- -- For more information please go to http://www.gnoga.com -- ------------------------------------------------------------------------------ with Ada.Finalization; with Ada.Strings.Unbounded; with Ada_GUI.Gnoga.Server.Database; with Ada_GUI.Gnoga.Server.Model.Queries; package Ada_GUI.Gnoga.Server.Template_Parser is -- Gnoga.Server.Template_Parser uses PHP, Python or Ada as template parsing -- engines. It also makes it possible to leverage and reuse existing -- web resources until they can be ported to Gnoga. To use Python instead -- of PHP see Gnoga.Server.Template_Parser.Python. If only simple parsing -- is needed (find and replace), use Ada_GUI.Gnoga.Server.Template_Parser.Simple -- that uses Ada.Text_IO -- -- Note: Template_Parser is not intended to be used for web site / app -- development but for tools or for use by apps to manipulate files. -- That doesn't mean you couldn't develop an entire site using it -- and production sites have been made with it. Keep in mind though -- that the security advantages of Gnoga are reduced if you are using -- a CGI like approach using a template_parser based on PHP or -- Python. type View_Data is new Ada.Finalization.Controlled with private; type View_Data_Array is array (Positive range <>) of View_Data; overriding procedure Finalize (Object : in out View_Data); procedure Variable_Name (Data : in out View_Data; Name : String); -- Sets the variable name used for the passed data -- by default the Name is "data" and so in the views -- accessed as - $data[key] (or data['key'] in python, or -- @@data.key@@ in the Simple parser). procedure Insert (Data : in out View_Data; Key : String; Value : Integer); -- Add Key/Value pair to View Data -- accessed in view as - $data[key], data['key'] or @@data.key@@ procedure Insert (Data : in out View_Data; Key : String; Value : String); -- Add Key/Value pair to View Data -- accessed in view as - $data[key], data['key'] or @@data.key@@ procedure Insert_Array (Data : in out View_Data; Vector : Gnoga.Data_Array_Type); -- Add an entire Array from a Data_Vector.Vector to View_Data -- access in view as $data[Index], data[Index] or @@data.Index@@ procedure Insert_Array_Item (Data : in out View_Data; Key : String; Vector : Gnoga.Data_Array_Type); -- Add an entire Array from a Data_Vector.Vector to View_Data -- as a single item. -- access in view as $data[Key][Array Index], data[Key][Index] or -- @@data.Key.Index@@ procedure Insert_Map (Data : in out View_Data; Map : Gnoga.Data_Map_Type); -- Add an entire Map of Key/Value pairs from a Gnoga.Data_Map_Type -- to View_Data each item will be accessed as - $data[key] where key is key -- in Map, or for Python and Simple parser data['key'] or @@data.key@@ procedure Insert_Map_Item (Data : in out View_Data; Key : String; Map : Gnoga.Data_Map_Type); -- Add an entire Map of Key/Value pairs from a Gnoga.Data_Map_Type -- to View_Data as a single item. -- access in view as $data[Key][Map's_Key], data['Key']['Map's_Key'] -- or @@data.Key.Map's_Key@@ procedure Insert_Record_Item (Data : in out View_Data; Key : String; Row : Gnoga.Server.Model.Active_Record'Class); -- Add field values of an Active_Record to View Data as a single item. -- access in view as $data[Key][Row's Field Name], -- data['Key']['Row's Field Name'] or @@data.Key.Row's Field Name@@ procedure Insert_Rows (Data : in out View_Data; Row : Gnoga.Server.Model.Queries.Active_Record_Array.Vector); -- Add a vector of Active_Records to View_Data. -- Each Active_Record is keyed by row number -- access in view as $data[Row Number][Row's Field Name] -- data[Row Number]['Row's Field Name'] or -- @@data.Row Number.Row's Field Name@@ procedure Insert_Recordset (Data : in out View_Data; RS : in out Gnoga.Server.Database.Recordset'Class); -- Add a recordset to View_Data. Each record is keyed by row number -- access in view as $data[Row Number][Row's Field Name] -- data[Row Number]['Row's Field Name'] or -- @@data.Row Number.Row's Field Name@@ procedure Insert_Query (Data : in out View_Data; C : Gnoga.Server.Database.Connection'Class; Query : String); -- Inserts the results of a SQL Query. Each record is keyed by row number procedure Clear (Data : in out View_Data); -- Clear contents of View_Data procedure Add_Error_Message (Message : String); -- Adds an error message to the error queue. The error queue is accessed -- in the view as $gnoga_errors[Row Number] procedure Clear_Error_Queue; -- Clears any error messages from the error queue procedure Add_Info_Message (Message : String); -- Adds an information message to the info queue. The info queue is -- accessed in the view as $gnoga_infos[Row Number] procedure Clear_Info_Queue; -- Clears any info messaes from the information queue Parser_Execution_Failure : exception; -- Raised if failed to execute parser application procedure Set_Template_Directory (Directory : String); -- Set the default extension for views. By default this is at -- Gnoga.Server.Templates_Directory procedure Write_String_To_File (File_Name : String; Value : String); -- Name is file name (no path is prefixed) to write Value to. -- File will be overwritten if exists. private type View_Data is new Ada.Finalization.Controlled with record Name : Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.To_Unbounded_String ("data"); String_Values : Gnoga.Data_Map_Type; Map_Values : Gnoga.Map_of_Data_Maps_Type; end record; function Parse_Name (Name : String) return String; -- prefix path from Set_Template_Directory to Name -- unless Name contains a ':' (as in C:) or starts -- with the OS separator ('/' or '\' on Windows) Error_Queue : Gnoga.Data_Array_Type; Info_Queue : Gnoga.Data_Array_Type; end Ada_GUI.Gnoga.Server.Template_Parser;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.PM is pragma Preelaborate; --------------- -- Registers -- --------------- -- Control A type PM_CTRLA_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- I/O Retention IORET : Boolean := False; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_CTRLA_Register use record Reserved_0_1 at 0 range 0 .. 1; IORET at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; end record; -- Sleep Mode type SLEEPCFG_SLEEPMODESelect is (-- CPU, AHBx, and APBx clocks are OFF IDLE, -- All Clocks are OFF STANDBY, -- Backup domain is ON as well as some PDRAMs HIBERNATE, -- Only Backup domain is powered ON BACKUP, -- All power domains are powered OFF OFF) with Size => 3; for SLEEPCFG_SLEEPMODESelect use (IDLE => 2, STANDBY => 4, HIBERNATE => 5, BACKUP => 6, OFF => 7); -- Sleep Configuration type PM_SLEEPCFG_Register is record -- Sleep Mode SLEEPMODE : SLEEPCFG_SLEEPMODESelect := SAM_SVD.PM.IDLE; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_SLEEPCFG_Register use record SLEEPMODE at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; end record; -- Interrupt Enable Clear type PM_INTENCLR_Register is record -- Sleep Mode Entry Ready Enable SLEEPRDY : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_INTENCLR_Register use record SLEEPRDY at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- Interrupt Enable Set type PM_INTENSET_Register is record -- Sleep Mode Entry Ready Enable SLEEPRDY : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_INTENSET_Register use record SLEEPRDY at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- Interrupt Flag Status and Clear type PM_INTFLAG_Register is record -- Sleep Mode Entry Ready SLEEPRDY : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_INTFLAG_Register use record SLEEPRDY at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- Ram Configuration type STDBYCFG_RAMCFGSelect is (-- All the system RAM is retained RET, -- Only the first 32Kbytes of the system RAM is retained PARTIAL, -- All the system RAM is turned OFF OFF) with Size => 2; for STDBYCFG_RAMCFGSelect use (RET => 0, PARTIAL => 1, OFF => 2); -- Fast Wakeup type STDBYCFG_FASTWKUPSelect is (-- Fast Wakeup is disabled NO, -- Fast Wakeup is enabled on NVM NVM, -- Fast Wakeup is enabled on the main voltage regulator (MAINVREG) MAINVREG, -- Fast Wakeup is enabled on both NVM and MAINVREG BOTH) with Size => 2; for STDBYCFG_FASTWKUPSelect use (NO => 0, NVM => 1, MAINVREG => 2, BOTH => 3); -- Standby Configuration type PM_STDBYCFG_Register is record -- Ram Configuration RAMCFG : STDBYCFG_RAMCFGSelect := SAM_SVD.PM.RET; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- Fast Wakeup FASTWKUP : STDBYCFG_FASTWKUPSelect := SAM_SVD.PM.NO; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_STDBYCFG_Register use record RAMCFG at 0 range 0 .. 1; Reserved_2_3 at 0 range 2 .. 3; FASTWKUP at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; end record; -- Ram Configuration type HIBCFG_RAMCFGSelect is (-- All the system RAM is retained RET, -- Only the first 32Kbytes of the system RAM is retained PARTIAL, -- All the system RAM is turned OFF OFF) with Size => 2; for HIBCFG_RAMCFGSelect use (RET => 0, PARTIAL => 1, OFF => 2); -- Backup Ram Configuration type HIBCFG_BRAMCFGSelect is (-- All the backup RAM is retained RET, -- Only the first 4Kbytes of the backup RAM is retained PARTIAL, -- All the backup RAM is turned OFF OFF) with Size => 2; for HIBCFG_BRAMCFGSelect use (RET => 0, PARTIAL => 1, OFF => 2); -- Hibernate Configuration type PM_HIBCFG_Register is record -- Ram Configuration RAMCFG : HIBCFG_RAMCFGSelect := SAM_SVD.PM.RET; -- Backup Ram Configuration BRAMCFG : HIBCFG_BRAMCFGSelect := SAM_SVD.PM.RET; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_HIBCFG_Register use record RAMCFG at 0 range 0 .. 1; BRAMCFG at 0 range 2 .. 3; Reserved_4_7 at 0 range 4 .. 7; end record; -- Ram Configuration type BKUPCFG_BRAMCFGSelect is (-- All the backup RAM is retained RET, -- Only the first 4Kbytes of the backup RAM is retained PARTIAL, -- All the backup RAM is turned OFF OFF) with Size => 2; for BKUPCFG_BRAMCFGSelect use (RET => 0, PARTIAL => 1, OFF => 2); -- Backup Configuration type PM_BKUPCFG_Register is record -- Ram Configuration BRAMCFG : BKUPCFG_BRAMCFGSelect := SAM_SVD.PM.RET; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_BKUPCFG_Register use record BRAMCFG at 0 range 0 .. 1; Reserved_2_7 at 0 range 2 .. 7; end record; subtype PM_PWSAKDLY_DLYVAL_Field is HAL.UInt7; -- Power Switch Acknowledge Delay type PM_PWSAKDLY_Register is record -- Delay Value DLYVAL : PM_PWSAKDLY_DLYVAL_Field := 16#0#; -- Ignore Acknowledge IGNACK : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for PM_PWSAKDLY_Register use record DLYVAL at 0 range 0 .. 6; IGNACK at 0 range 7 .. 7; end record; ----------------- -- Peripherals -- ----------------- -- Power Manager type PM_Peripheral is record -- Control A CTRLA : aliased PM_CTRLA_Register; -- Sleep Configuration SLEEPCFG : aliased PM_SLEEPCFG_Register; -- Interrupt Enable Clear INTENCLR : aliased PM_INTENCLR_Register; -- Interrupt Enable Set INTENSET : aliased PM_INTENSET_Register; -- Interrupt Flag Status and Clear INTFLAG : aliased PM_INTFLAG_Register; -- Standby Configuration STDBYCFG : aliased PM_STDBYCFG_Register; -- Hibernate Configuration HIBCFG : aliased PM_HIBCFG_Register; -- Backup Configuration BKUPCFG : aliased PM_BKUPCFG_Register; -- Power Switch Acknowledge Delay PWSAKDLY : aliased PM_PWSAKDLY_Register; end record with Volatile; for PM_Peripheral use record CTRLA at 16#0# range 0 .. 7; SLEEPCFG at 16#1# range 0 .. 7; INTENCLR at 16#4# range 0 .. 7; INTENSET at 16#5# range 0 .. 7; INTFLAG at 16#6# range 0 .. 7; STDBYCFG at 16#8# range 0 .. 7; HIBCFG at 16#9# range 0 .. 7; BKUPCFG at 16#A# range 0 .. 7; PWSAKDLY at 16#12# range 0 .. 7; end record; -- Power Manager PM_Periph : aliased PM_Peripheral with Import, Address => PM_Base; end SAM_SVD.PM;
with Ada.Unchecked_Conversion; with System.Machine_Code; use System.Machine_Code; with System; use System; with System.Storage_Elements; use System.Storage_Elements; with Interfaces; use Interfaces; with STM32_SVD; use STM32_SVD; with Flash; with STM32GD.Board; with STM32_SVD.RCC; procedure Bootloader is Line : array (Unsigned_32 range 0 .. 47) of Unsigned_8; Count : Unsigned_8; C : Byte; function W is new Ada.Unchecked_Conversion (Address, Unsigned_32); Reset_Vector_Address : constant Unsigned_32 := 16#0800_0004#; Bootloader: constant Storage_Element with Import, Convention => Asm, External_Name => "__bootloader"; User_Vector: constant Storage_Element with Import, Convention => Asm, External_Name => "__bootloader_data"; Flash_Segment_Size : constant Unsigned_32 := 1024; -- with Import, Convention => Asm, External_Name => "__page_size"; Bootloader_Address : constant Unsigned_32 := W (Bootloader'Address); User_Vector_Address : constant Unsigned_32 := W (User_Vector'Address); package Board renames STM32GD.Board; package USART renames Board.USART; procedure Erase is Addr : Unsigned_32 := 16#0800_0000#; Saved_Vector_Low : Unsigned_16; Saved_Vector_High : Unsigned_16; begin Saved_Vector_Low := Flash.Read (Reset_Vector_Address); Saved_Vector_High := Flash.Read (Reset_Vector_Address + 2); Flash.Unlock; while Addr < Bootloader_Address loop Flash.Erase (Addr); Addr := Addr + Flash_Segment_Size; end loop; Flash.Enable_Write; Flash.Write (Reset_Vector_Address, Saved_Vector_Low); Flash.Write (Reset_Vector_Address + 2, Saved_Vector_High); Flash.Lock; end Erase; function Nibble (N : Unsigned_8) return Unsigned_8 is begin return (if N >= 65 then N - 65 + 10 else N - 48); end Nibble; function From_Hex (I : Unsigned_32) return Unsigned_8 is begin return 16 * Nibble (Line (I)) + Nibble (Line (I + 1)); end From_Hex; procedure Write (Addr : Unsigned_32) is Value : Unsigned_16; Write_Addr : Unsigned_32 := Addr; J : Unsigned_32; begin Flash.Unlock; J := 9; for I in Unsigned_32 range 1 .. Unsigned_32 (Count) / 2 loop Flash.Enable_Write; Value := Unsigned_16 (From_Hex (J)) + 256 * Unsigned_16 (From_Hex (J + 2)); if Write_Addr = Reset_Vector_Address then Flash.Write (User_Vector_Address, Value); elsif Write_Addr = Reset_Vector_Address + 2 then Flash.Write (User_Vector_Address + 2, Value); else Flash.Write (Write_Addr, Value); end if; J := J + 4; Write_Addr := Write_Addr + Unsigned_32 (2); end loop; Flash.Lock; end Write; procedure Read_Lines is Record_Type : Unsigned_8; XON : constant Byte := 17; XOFF : constant Byte := 19; Offset : Unsigned_32 := 0; Addr : Unsigned_32; begin loop USART.Transmit (XON); for I in Line'Range loop Line (I) := Unsigned_8 (USART.Receive); exit when Line (I) = 10; end loop; USART.Transmit (XOFF); Count := From_Hex (1); Addr := Unsigned_32 (From_Hex (3)) * 256 + Unsigned_32 (From_Hex (5)); Record_Type := From_Hex (7); case Record_Type is when 16#00# => Write (Addr + Offset); when 16#04# => Offset := (Unsigned_32 (From_Hex (9)) * 256 + Unsigned_32 (From_Hex (11))) * 2 ** 16; when 16#80# => Flash.Erase (Addr + Offset); when others => null; end case; end loop; end Read_Lines; begin Board.TX.Enable; Board.RX.Enable; USART.Enable; Board.TX.Init; Board.RX.Init; USART.Init; loop USART.Transmit (Character'Pos ('?')); for I in 0 .. 16#0010_0000# loop if USART.Data_Available then loop C := USART.Receive; USART.Transmit (C); exit when not USART.Data_Available and then (C = 10 or else C = 13); end loop; USART.Transmit (Character'Pos ('F')); USART.Transmit (10); Flash.Init; Erase; Read_Lines; end if; end loop; if Flash.Read (User_Vector_Address) /= 16#FFFF# then USART.Transmit (Character'Pos ('R')); USART.Transmit (10); Asm ("movs r1, #0; ldr r1, [r1]; mov sp, r1", Volatile => True); Asm ("ldr r0, =__bootloader_data", Volatile => True); Asm ("ldr r0, [r0]; bx r0", Volatile => True); end if; end loop; end Bootloader;
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro> -- -- 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 Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Interfaces.C.Extensions; use Interfaces.C.Extensions; limited with DNSCatcher.DNS.Processor.Packet; with DNSCatcher.DNS; use DNSCatcher.DNS; with DNSCatcher.Types; use DNSCatcher.Types; -- @summary -- The RData Processor abstract class, used to implement all RData processors. -- This package is used to convert rdata to/from wire form. -- -- @description -- DNS RRtypes have differing binary encoding depending on the resource record -- type so this package acts as an abstraction layer for varying RData types -- which are implemented as subclasses of this. In certain cases however, it -- is necessary to get the derieved class and cast back to that. For example, -- retrieving the OPT record like that is essentially required. -- package DNSCatcher.DNS.Processor.RData is -- Abstract Parsed_Data object -- -- These values are part of the common header of all RRtypes -- -- @value RName -- Resource recode name -- -- @value RType -- Resource record type -- -- @value TTL -- Time to Live of a given record type Parsed_RData is abstract tagged record RName : Unbounded_String; RType : RR_Types; TTL : Unsigned_32; end record; type Parsed_RData_Access is access all Parsed_RData'Class; -- Constructor for RData subclasses -- -- To_Parsed_RData creates a Parsed_RData object from the correct derieved -- class and returns the common Parsed_RData class in response. -- -- @value DNS_Header -- DNS Packet Header used for some RType information -- -- @value Parsed_RR -- The initial logicial representation created by Packet Parser -- function To_Parsed_RData (DNS_Header : DNS_Packet_Header; Parsed_RR : DNSCatcher.DNS.Processor.Packet.Parsed_DNS_Resource_Record) return Parsed_RData_Access; -- Abstract class constructor -- -- @value This -- RData object being constructed -- -- @value DNS_Header -- DNS Packet Header -- -- @value Parsed_RR -- Parsed resource record from the packet parsing step -- procedure From_Parsed_RR (This : in out Parsed_RData; DNS_Header : DNS_Packet_Header; Parsed_RR : DNSCatcher.DNS.Processor.Packet .Parsed_DNS_Resource_Record) is abstract; -- Abstract conversion of RData to String -- -- @value This -- RData object -- -- @returns -- A string representation of RData -- function RData_To_String (This : in Parsed_RData) return String is abstract; -- Abstract pretty printer -- -- @value This -- RData object -- -- @returns -- String representation of nicely formatted RData information -- function Print_Packet (This : in Parsed_RData) return String is abstract; -- Deconstructor abstract method -- -- Releases all resources allocated by the RData object -- -- @value This -- Object to be deconstructed -- procedure Delete (This : in out Parsed_RData) is abstract; end DNSCatcher.DNS.Processor.RData;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . B O U N D E D _ S T R I N G S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2016-2020, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- A very simple implentation of bounded strings, used by tracebacks package System.Bounded_Strings is type Bounded_String (Max_Length : Natural) is limited private; -- A string whose length is bounded by Max_Length. The bounded string is -- empty at initialization. procedure Append (X : in out Bounded_String; C : Character); procedure Append (X : in out Bounded_String; S : String); -- Append a character or a string to X. If the bounded string is full, -- extra characters are simply dropped. function To_String (X : Bounded_String) return String; function "+" (X : Bounded_String) return String renames To_String; -- Convert to a normal string procedure Append_Address (X : in out Bounded_String; A : Address); -- Append an address to X function Is_Full (X : Bounded_String) return Boolean; -- Return True iff X is full and any character or string will be dropped -- if appended. private type Bounded_String (Max_Length : Natural) is limited record Length : Natural := 0; -- Current length of the string Chars : String (1 .. Max_Length); -- String content end record; end System.Bounded_Strings;
with Ada.Text_IO; use Ada.Text_IO; with Fibonacci; use Fibonacci; procedure Fibotest is C : Fibo_Cur; -- T : Fibo_Forward; -- R : Fibo_Reversible; F : Fibo_List; begin -- C := First (T); -- while Has_Element (C) loop -- Put_Line (Natural'Image (Element (C))); -- C := Next (T, C); -- end loop; -- C := Last (R); -- while Has_Element (C) loop -- Put_Line (Natural'Image (Element (C))); -- C := Previous (R, C); -- end loop; -- for I in F.Iterate loop -- Put_Line (Natural'Image (Element (I))); -- end loop; for I of F loop Put_Line (I); -- not a Put_Line from Text_IO, though. end loop; -- missing parts... -- for I of reverse F loop -- Put_Line (I); -- end loop; end Fibotest;
------------------------------------------------------------------------------ -- Copyright (c) 2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Time_Keys provides a concise but printable representation of -- -- time where lexicographical order matches chronological order. -- -- It is based on a base-64 symbol set that preserve order, picked from URL -- -- unreserved character set. -- -- It consists simply of time components in big-endian order, trimming -- -- tailing zeros, and using two base-64 digits for the year, which gives a -- -- 4096 year span. -- -- This means a second granularity can be achieved with 7 characters. The -- -- most compact way of encoding such a timestamp would be counting seconds, -- -- like UNIX time. The time covered by this format is rought 2^37 seconds, -- -- which would mean 5 bytes or 7 base-64 digits (though 6 would be enough -- -- for a useful time range). -- ------------------------------------------------------------------------------ with Ada.Calendar.Formatting; package Natools.Time_Keys is function Is_Valid (Key : String) return Boolean; -- Check whether Key is a valid encoded time. -- WARNING: this function returns true for invalid dates, -- like February 30th. function To_Key (Time : Ada.Calendar.Time; Max_Sub_Second_Digits : in Natural := 120) return String with Post => Is_Valid (To_Key'Result); -- Convert a time into a key function To_Key (Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; Hour : Ada.Calendar.Formatting.Hour_Number := 0; Minute : Ada.Calendar.Formatting.Minute_Number := 0; Second : Ada.Calendar.Formatting.Second_Number := 0; Sub_Second : Ada.Calendar.Formatting.Second_Duration := 0.0; Leap_Second : Boolean := False; Max_Sub_Second_Digits : Natural := 120) return String with Post => Is_Valid (To_Key'Result); -- Convert a split time representation into a key function To_Time (Key : String) return Ada.Calendar.Time with Pre => Is_Valid (Key); -- Convert a valid key into the original time private subtype Base_64_Digit is Character with Static_Predicate => Base_64_Digit in '0' .. '9' | 'A' .. 'Z' | '_' | 'a' .. 'z' | '~'; type Base_64_Value is mod 2 ** 6; Digit_Offset : constant := 48; -- Character'Pos ('0') Upper_Offset : constant := 55; -- Character'Pos ('A') - 10 Lower_Offset : constant := 60; -- Character'Pos ('a') - 37 function Value (Digit : Base_64_Digit) return Base_64_Value is (Base_64_Value (case Digit is when '0' .. '9' => Character'Pos (Digit) - Digit_Offset, when 'A' .. 'Z' => Character'Pos (Digit) - Upper_Offset, when '_' => 36, when 'a' .. 'z' => Character'Pos (Digit) - Lower_Offset, when '~' => 63)); function I_Value (Digit : Base_64_Digit) return Integer is (Integer (Value (Digit))); function Image (Digit : Base_64_Value) return Base_64_Digit is (case Digit is when 0 .. 9 => Character'Val (Natural (Digit) + Digit_Offset), when 10 .. 35 => Character'Val (Natural (Digit) + Upper_Offset), when 36 => '_', when 37 .. 62 => Character'Val (Natural (Digit) + Lower_Offset), when 63 => '~'); function I_Image (Digit : Integer) return Base_64_Digit is (Image (Base_64_Value (Digit))); function Is_Valid (Key : String) return Boolean is (Key'Length >= 4 and then Key (Key'First) in '0' .. '9' | 'A' .. 'Z' | '_' | 'a' .. 'z' | '~' and then Key (Key'First + 1) in '0' .. '9' | 'A' .. 'Z' | '_' | 'a' .. 'z' | '~' and then Key (Key'First + 2) in '1' .. '9' | 'A' .. 'C' and then Key (Key'First + 3) in '1' .. '9' | 'A' .. 'V' and then (Key'First + 4 not in Key'Range or else Key (Key'First + 4) in '0' .. '9' | 'A' .. 'N') and then (Key'First + 5 not in Key'Range or else Key (Key'First + 5) in '0' .. '9' | 'A' .. 'Z' | '_' | 'a' .. 'w') and then (Key'First + 6 not in Key'Range or else Key (Key'First + 6) in '0' .. '9' | 'A' .. 'Z' | '_' | 'a' .. 'x') and then (for all I in Key'First + 7 .. Key'Last => Key (I) in '0' .. '9' | 'A' .. 'Z' | '_' | 'a' .. 'z' | '~')); end Natools.Time_Keys;
with RASCAL.OS; use RASCAL.OS; package Controller_Internet is type TEL_ViewHomePage_Type is new Toolbox_UserEventListener(16#18#,-1,-1) with null record; type TEL_SendEmail_Type is new Toolbox_UserEventListener(16#19#,-1,-1) with null record; -- -- The user wants to view the homepage. -- procedure Handle (The : in TEL_ViewHomePage_Type); -- -- The user wants to send an email. -- procedure Handle (The : in TEL_SendEmail_Type); private end Controller_Internet;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with System; with Interfaces.C.Strings; private package CUPS.xlocale_h is -- Definition of locale datatype. -- Copyright (C) 1997-2016 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. -- The GNU C Library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- The GNU C Library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library; if not, see -- <http://www.gnu.org/licenses/>. -- Structure for reentrant locale using functions. This is an -- (almost) opaque type for the user level programs. The file and -- this data structure is not standardized. Don't rely on it. It can -- go away without warning. -- Note: LC_ALL is not a valid index into this array. -- 13 = __LC_LAST. type uu_locale_struct_uu_locales_array is array (0 .. 12) of System.Address; type uu_locale_struct_uu_names_array is array (0 .. 12) of Interfaces.C.Strings.chars_ptr; type uu_locale_struct is record uu_locales : uu_locale_struct_uu_locales_array; -- xlocale.h:30 uu_ctype_b : access unsigned_short; -- xlocale.h:33 uu_ctype_tolower : access int; -- xlocale.h:34 uu_ctype_toupper : access int; -- xlocale.h:35 uu_names : uu_locale_struct_uu_names_array; -- xlocale.h:38 end record; pragma Convention (C_Pass_By_Copy, uu_locale_struct); -- xlocale.h:27 -- skipped empty struct uu_locale_data -- To increase the speed of this solution we add some special members. -- Note: LC_ALL is not a valid index into this array. type uu_locale_t is access all uu_locale_struct; -- xlocale.h:39 -- POSIX 2008 makes locale_t official. subtype locale_t is uu_locale_t; -- xlocale.h:42 end CUPS.xlocale_h;
with Trendy_Locations; package Trendy_Test.Generics is use Trendy_Locations; -- A generic assertion of a discrete type, which can be compared using a -- binary operator. This operation includes a string which can be used -- during reporting. generic type T is (<>); Operand : String; -- An infix description of how to report this operand. with function Comparison(Left : T; Right : T) return Boolean; procedure Assert_Discrete( Op : in out Operation'Class; Left : T; Right : T; Loc : Source_Location := Make_Source_Location); -- A generic assertion which assumes that = and /= are opposite operations. generic type T is private; with function Image(Self : T) return String; procedure Assert_EQ( Op : in out Operation'Class; Left : T; Right : T; Loc : Source_Location := Make_Source_Location); end Trendy_Test.Generics;
-- { dg-do run } -- { dg-options "-gnatws" } with Unchecked_Conversion; procedure biased_uc is begin -- Case (f) target type is biased, source is unbiased declare type a is new integer range 0 .. 255; for a'size use 8; type b is new integer range 200 .. 455; for b'size use 8; av : a; bv : b; for av'size use 8; for bv'size use 8; function a2b is new Unchecked_Conversion (a,b); begin bv := a2b (200); if bv = 200 then raise Program_Error; end if; end; -- Case (g) target type is biased, source object is biased declare type a is new integer range 1 .. 256; for a'size use 16; type b is new integer range 1 .. 65536; for b'size use 16; av : a; bv : b; for av'size use 8; for bv'size use 16; function a2b is new Unchecked_Conversion (a,b); begin bv := a2b (1); if bv /= 2 then raise Program_Error; end if; end; end;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with League.Strings; with Incr.Lexers.Batch_Lexers; package Incr.Nodes.Tokens is -- @summary -- Token nodes of parse tree -- -- @description -- This package provides Token type. -- Tokens have no children, but usually contain some text of the document. -- Tokens provide support for incremental lexer by keeping related data -- such as -- * state - scanner's state at the end of the token -- * lookahead - number of characters after were seen by scanner after it -- * lookback - number of preceding tokens with lookahead over this one type Token is new Node with private; -- Token nodesof parse tree type Token_Access is access all Token'Class; overriding function Kind (Self : Token) return Node_Kind; -- Return type of the token. Kind is not expected to change not overriding function Text (Self : Token; Time : Version_Trees.Version) return League.Strings.Universal_String; -- Return text of the token not overriding procedure Set_Text (Self : in out Token; Value : League.Strings.Universal_String); -- Assign text to the token not overriding function Next_Token (Self : aliased Token; Time : Version_Trees.Version) return Token_Access; -- Find next token in the parse tree not overriding function Previous_Token (Self : aliased Token; Time : Version_Trees.Version) return Token_Access; -- Find previous token in the parse tree not overriding function Lookback (Self : Token; Time : Version_Trees.Version) return Natural; -- Get number of preceding tokens with lookahead extented over this one subtype Scanner_State is Lexers.Batch_Lexers.State; not overriding function State (Self : access Token; Time : Version_Trees.Version) return Scanner_State; package Constructors is procedure Initialize (Self : out Token'Class; Kind : Node_Kind; Value : League.Strings.Universal_String; State : Scanner_State; Lookahead : Natural); procedure Initialize_Ancient (Self : aliased in out Token'Class; Parent : Node_Access; Back : Natural); -- Initialize Self as token existent in initial version of the document. end Constructors; private package Versioned_Strings is new Version_Trees.Versioned_Values (League.Strings.Universal_String); package Versioned_Naturals is new Version_Trees.Versioned_Values (Natural); type Token is new Node_With_Parent with record Kind : Node_Kind; Text : Versioned_Strings.Container; Back : Versioned_Naturals.Container; Ahead : Versioned_Naturals.Container; States : Versioned_Naturals.Container; end record; overriding function Is_Token (Self : Token) return Boolean; overriding function Arity (Self : Token) return Natural; overriding function Child (Self : Token; Index : Positive; Time : Version_Trees.Version) return Node_Access; overriding procedure Set_Child (Self : aliased in out Token; Index : Positive; Value : Node_Access) is null; overriding function Nested_Changes (Self : Token; From : Version_Trees.Version; To : Version_Trees.Version) return Boolean; overriding function Nested_Errors (Self : Token; Unused : Version_Trees.Version) return Boolean is (False); overriding function Span (Self : aliased in out Token; Kind : Span_Kinds; Time : Version_Trees.Version) return Natural; overriding procedure Discard (Self : in out Token); end Incr.Nodes.Tokens;
------------------------------------------------------------------------------ -- 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) $ ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- 12 package Asis.Compilation_Units.Relations ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- package Asis.Compilation_Units.Relations is ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Asis.Compilation_Units.Relations encapsulates semantic relationship -- concepts used in ASIS. ------------------------------------------------------------------------------- -- 12.1 type Relationship ------------------------------------------------------------------------------- -- Relationship queries provide references to compilation units that are -- related, in some specific fashion, to one or more given compilation units. -- Compilation units located by these queries are returned as a set of -- ordered lists. type Relationship (Consistent_Length : Asis.ASIS_Natural; Inconsistent_Length : Asis.ASIS_Natural; Missing_Length : Asis.ASIS_Natural; Circular_Length : Asis.ASIS_Natural) is record Consistent : Asis.Compilation_Unit_List (1 .. Consistent_Length); Inconsistent : Asis.Compilation_Unit_List (1 .. Inconsistent_Length); Missing : Asis.Compilation_Unit_List (1 .. Missing_Length); Circular : Asis.Compilation_Unit_List (1 .. Circular_Length); end record; -- The following describes the semantics of the unit lists returned by the -- queries Semantic_Dependence_Order and Elaboration_Order: -- -- Each query returns a set of four lists. Every unit returned will have the -- same Enclosing_Context. The lists are: -- -- - Consistent: A list of consistent ordered units. -- -- - Inconsistent: A list of units that are inconsistent with one or more -- units on which they semantically depend. -- -- - Missing: A list of units that have missing (nonexistent) related units. -- -- - Circular: A list of circular semantic dependencies between units. -- -- These lists are further described as: -- -- a) Consistent units list: -- -- The semantics for the ordering of units in the first list are defined by -- the individual queries. -- -- Every unit in this list is unique. No duplicates are returned; no -- two units in the list are Is_Equal or Is_Identical. -- -- b) Inconsistent units list: -- -- The second list is made up of unit pairs. -- -- Each pairing defines an inconsistent semantic dependence relationship. -- The right unit of each pair semantically depends on the preceding left -- unit. All rightmost units of each pair are always inconsistent, and will -- not appear in the consistent units list. The leftmost unit can be -- either consistent or inconsistent. If a leftmost units is consistent, -- then it also appears in the consistent units list; otherwise the unit -- is part of an inconsistent transitive relationship. -- -- The unit pairs are ordered such that there are no forward semantic -- dependencies between the inconsistent units. Each inconsistent unit's -- supporters always precede it in the list. -- -- As an example, given four units, A withs B, B withs C, and C withs D; -- if D is replaced, the inconsistent list contains six units with the -- three pairs: -- -- DC CB BA -- -- The list indicates that units C, B, and A are inconsistent (the -- rightmost units of each pair). Semantic dependencies such as B depends -- on C also are indicated. The units C, B, and A are in an order that -- could be submitted to the compiler (a possible recompilation order). -- -- If a unit is inconsistent because the source for the unit has been -- edited (or otherwise been made inconsistent by some action of the user -- or implementation) then the unit references Nil_Compilation_Unit as the -- cause of the inconsistency (e.g., (Nil A Nil B) is a list of two -- inconsistent units, neither of which can point to a third unit as the -- cause for their being inconsistent). -- -- |IP Implementation Permissions -- |IP -- |IP An implementation is allowed to use Nil_Compilation_Unit value for -- |IP the first unit of each pair if it cannot determine the supporting unit -- |IP causing the inconsistent semantic dependence. -- -- For the above example, the list returned is: -- -- DC DB DA CB CA BA -- -- This list reports all dependencies: -- -- D withed by C withed by B withed by A => DC DB DA -- C withed by B withed by A => CB CA -- B withed by A => BA -- -- c) Missing dependence list: -- -- The third list is made up of unit pairs. Each pairing consists of a -- unit followed by a missing related unit needed by the first unit. -- A missing unit is a required Compilation_Unit, with a known name, with a -- Unit_Kind that is either A_Nonexistent_Declaration or -- A_Nonexistent_Body. -- -- For example: -- -- Given a list containing the units: AB AC -- -- If Unit_Kind(B) = A_Nonexistent_Declaration and -- Unit_Kind(C) = A_Nonexistent_Body then -- -- It can be deduced that: -- A is missing a needed supporter B (A depends semantically on B). -- A is missing a needed related unit body C (depending on the kind -- for A, C can be A's required body or some subunit of A). -- -- A unit is reported as missing only if the Post-Compilation Rules of Ada -- determine it to be needed. Reference Manual 10.2. -- -- d) Circular dependence list: -- -- Circular dependencies between compilation units are provided in the -- fourth list. There may be more than one set of circular dependencies. -- The ordering of distinct sets in the list is implementation-defined. -- This list will never contain nonexistent units. -- -- The list is made up of unit pairs. The second unit of each pair depends -- semantically on the first unit. A circularity is established when the -- first unit of a pair also appears as the second unit of a later pair. -- (See the unit A in the example below; it is the first unit of the first -- pair and is the second unit of the third pair). The next set of -- circular dependent units, if any, starts with the next unit in the list -- (the unit D in the example below). -- -- For example: -- -- Given a list containing the units: AC CB BA DG GF FE ED -- -- It can be determined that there are two sets of circularly dependent -- units: -- {A, B, C} and {D, E, F, G} -- -- The dependencies are: A depends on B, B depends on C, C depends on A. -- D depends on E, E depends on F, F depends on G, G depends on D. -- -- Each circle of dependence is reported exactly once. It is not reported -- once for each unit in the circle. -- ------------------------------------------------------------------------------- -- 12.2 constant Nil_Relationship ------------------------------------------------------------------------------- Nil_Relationship : constant Relationship := (Consistent_Length => 0, Inconsistent_Length => 0, Missing_Length => 0, Circular_Length => 0, Consistent => Asis.Nil_Compilation_Unit_List, Inconsistent => Asis.Nil_Compilation_Unit_List, Missing => Asis.Nil_Compilation_Unit_List, Circular => Asis.Nil_Compilation_Unit_List); ------------------------------------------------------------------------------- -- 12.3 function Semantic_Dependence_Order ------------------------------------------------------------------------------- -- Semantic Dependence Relationships - Reference Manual 10.1.1(24). -- Elaboration Dependence Relationships - Reference Manual 10.1.1(25). -- -- |AN Application Note: -- |AN -- |AN To properly determine unit consistency, use one of the two semantic -- |AN dependence queries: Elaboration_Order or Semantic_Dependence_Order. -- |AN These queries return a value of the type Relationship, which contains -- |AN lists of consistent, inconsistent, missing and circular units. -- |AN -- |AN For these two queries, the existence of units in one or more of the -- |AN inconsistent, missing, or circular units list means that the consistent -- |AN unit list may not be complete. -- |AN -- |AN Applications that do not check for inconsistent, missing, or circular -- |AN units before using the consistent list might not operate as expected. -- ------------------------------------------------------------------------------- function Semantic_Dependence_Order (Compilation_Units : in Asis.Compilation_Unit_List; Dependent_Units : in Asis.Compilation_Unit_List; The_Context : in Asis.Context; Relation : in Asis.Relation_Kinds) return Relationship; ------------------------------------------------------------------------------- -- Compilation_Units - Specifies a list of pertinent units -- Dependent_Units - Specifies dependents used to limit the query -- The_Context - Specifies a program Context for context -- Relation - Specifies the relationship to query -- -- Produces a Relationship value containing compilation_unit elements related -- to the given Compilation_Units by the specified relation. -- -- The compilation_unit elements in the consistent units list are ordered -- such that there are no forward semantic dependencies. -- -- Dependent_Units are ignored unless the Relation is Descendants or -- Dependents. The union of units in the needed units of the Dependent_Units -- list provide a limiting context for the query. Only members of these -- needed units are present in the result. -- -- If the Dependent_Units list is Is_Nil, the context for the search is the -- entire Context. The result of such a query is the full (unlimited) -- list of Dependents for the Compilation_Units. -- -- All units in the result will have an Enclosing_Context value that -- Is_Identical to The_Context. -- -- Appropriate Unit_Kinds: -- A_Procedure -- A_Function -- A_Package -- A_Generic_Procedure -- A_Generic_Function -- A_Generic_Package -- A_Procedure_Instance -- A_Function_Instance -- A_Package_Instance -- A_Procedure_Renaming -- A_Function_Renaming -- A_Package_Renaming -- A_Generic_Procedure_Renaming -- A_Generic_Function_Renaming -- A_Generic_Package_Renaming -- A_Procedure_Body -- A_Function_Body -- A_Package_Body -- A_Procedure_Body_Subunit -- A_Function_Body_Subunit -- A_Package_Body_Subunit -- A_Task_Body_Subunit -- A_Protected_Body_Subunit -- An_Unknown_Unit -- See Implementation Permissions -- -- The Semantic_Dependence_Order query should never raise an exception -- when processing inconsistent unit (sub)sets. This query is the only -- means for an application to know if a given unit is consistent with -- (some of) its supporters (dependents), and therefore the related -- semantic processing can give valuable results for this unit. -- -- |IP Implementation Permissions: -- |IP -- |IP The handling of An_Unknown_Unit is implementation specific. It can be -- |IP possible to obtain Semantic Dependence Relationships when starting -- |IP with a list containing one or more units that are An_Unknown_Unit. -- |IP However, results may vary across ASIS implementations. -- -- |AN Application Note: -- |AN -- |AN Semantic_Dependence_Order defines consistent units to be ordered such -- |AN that there are no forward semantic dependencies. -- ------------------------------------------------------------------------------- -- 12.4 function Elaboration_Order ------------------------------------------------------------------------------- function Elaboration_Order (Compilation_Units : in Asis.Compilation_Unit_List; The_Context : in Asis.Context) return Relationship; ------------------------------------------------------------------------------- -- Compilation_Units - Specifies a list of units to elaborate -- The_Context - Specifies a program Context for context -- -- Produces, in elaboration order, a Relationship value containing compilation -- units required to elaborate the given compilation units. -- -- The return value contains the set of ordered lists described above for the -- queries on Semantic Dependence Relationships. If the inconsistent, -- missing, and circular lists are empty, the consistent list will contain -- all units required to elaborate the arguments. -- -- |IP Implementation Permissions: -- |IP -- |IP The Relationship value may include any number of -- |IP implementation-specific runtime support packages. -- -- The first unit in the Consistent units list will always be the -- specification for package Standard. The list will contain all units -- required to elaborate the arguments. -- -- Use the Context_Clause_Elements query to get pragma Elaborate elements -- for a compilation unit. -- -- Appropriate Unit_Kinds: -- A_Procedure -- A_Function -- A_Package -- A_Generic_Procedure -- A_Generic_Function -- A_Generic_Package -- A_Procedure_Instance -- A_Function_Instance -- A_Package_Instance -- A_Procedure_Renaming -- A_Function_Renaming -- A_Package_Renaming -- A_Generic_Procedure_Renaming -- A_Generic_Function_Renaming -- A_Generic_Package_Renaming -- A_Procedure_Body -- A_Function_Body -- A_Package_Body -- A_Procedure_Body_Subunit -- A_Function_Body_Subunit -- A_Package_Body_Subunit -- A_Task_Body_Subunit -- A_Protected_Body_Subunit -- An_Unknown_Unit -- See Implementation Permissions -- -- |IP Implementation Permissions: -- |IP -- |IP The handling of An_Unknown_Unit is implementation specific. It can -- |IP be possible to obtain Semantic Dependence Relationships when starting -- |IP with a list containing one or more units that are An_Unknown_Unit. -- |IP However, results may vary across ASIS implementations. -- ------------------------------------------------------------------------------- end Asis.Compilation_Units.Relations; ------------------------------------------------------------------------------ -- 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. ------------------------------------------------------------------------------
package HAL.Touch_Panel is type TP_Touch_State is record X : Natural; Y : Natural; Weight : Natural; end record; type Swap_State is new UInt3; Invert_X : constant Swap_State; Invert_Y : constant Swap_State; Swap_XY : constant Swap_State; subtype Touch_Identifier is Natural range 0 .. 10; type TP_State is array (Touch_Identifier range <>) of TP_Touch_State; type Touch_Panel_Device is limited interface; type Touch_Panel_Ref is access all Touch_Panel_Device'Class; procedure Set_Bounds (This : in out Touch_Panel_Device; Width : Natural; Height : Natural; Swap : Swap_State) is abstract; -- Set screen bounds. Touch_State must should stay within screen bounds function Active_Touch_Points (This : in out Touch_Panel_Device) return Touch_Identifier is abstract; -- Retrieve the number of active touch points function Get_Touch_Point (This : in out Touch_Panel_Device; Touch_Id : Touch_Identifier) return TP_Touch_State is abstract; -- Retrieves the position and pressure information of the specified -- touch function Get_All_Touch_Points (This : in out Touch_Panel_Device) return TP_State is abstract; -- Retrieves the position and pressure information of every active touch -- points private Invert_X : constant Swap_State := 2#001#; Invert_Y : constant Swap_State := 2#010#; Swap_XY : constant Swap_State := 2#100#; end HAL.Touch_Panel;
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- 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. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 AUnit.Assertions; use AUnit.Assertions; with Keccak.Types; use Keccak.Types; package body KeccakF_Lane_Tests is -- Test that XORing bytes into a (zeroed) state, then extracting them -- yields the original data. -- -- This ensures that XOR_Bits_Into_State and Extract_Bits both use the -- same mapping to the internal state. procedure Test_XOR_Extract(T : in out Test) is State_Size_Bytes : constant Positive := State_Size_Bits / 8; S : State; Data_In : Byte_Array (1 .. State_Size_Bytes); Data_Out : Byte_Array (1 .. State_Size_Bytes); begin for I in Data_In'Range loop Data_In (I) := Keccak.Types.Byte (I mod 256); end loop; for N in 1 .. State_Size_Bytes loop Init_State (S); XOR_Bits_Into_State (A => S, Data => Data_In, Bit_Len => N * 8); Data_Out := (others => 16#AA#); Extract_Bits (A => S, Data => Data_Out (1 .. N), Bit_Len => N * 8); Assert (Data_In (1 .. N) = Data_Out (1 .. N), "Failed for N = " & Integer'Image (N)); end loop; end Test_XOR_Extract; end KeccakF_Lane_Tests;
-- Copyright 2016-2021 Bartek thindil Jasicki -- -- This file is part of Steam Sky. -- -- Steam Sky is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- Steam Sky is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with Steam Sky. If not, see <http://www.gnu.org/licenses/>. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Containers.Vectors; use Ada.Containers; with Ada.Containers.Indefinite_Vectors; with Game; use Game; with Crew; use Crew; with Factions; use Factions; with Items; use Items; with Missions; use Missions; with Ships; use Ships; -- ****h* Bases/Bases -- FUNCTION -- Provide code for manipulate sky bases -- SOURCE package Bases is -- **** -- ****s* Bases/Bases.Recruit_Data -- FUNCTION -- Data structure for recruits -- PARAMETERS -- Name - Name of recruit -- Gender - Gender of recruit -- Skills - Names indexes, levels and experience in skills of recruit -- Cost - Cost of enlist of recruit -- Attributes - Names indexes, levels and experience in attributes of -- recruit -- Inventory - Owned items by recruit -- Equipment - Items indexes from inventory used by recruit: 1 - weapon, -- 2 - shield, 3 - helmet, 4 - torso, 5 - arms, 6 - legs, -- 7 - tool -- Payment - How much money recruit will take as payment each day. -- Home_Base - Index of base from which recruit is -- Faction - Index of faction to which recruit belongs -- SOURCE type Recruit_Data is new Mob_Record with record Name: Unbounded_String; Gender: Character; Price: Positive; Inventory: UnboundedString_Container.Vector; Equipment: Equipment_Array; Payment: Positive; Home_Base: Bases_Range; Faction: Unbounded_String; end record; -- **** -- ****t* Bases/Bases.Recruit_Container -- FUNCTION -- Used to store sky bases recruits data -- SOURCE package Recruit_Container is new Indefinite_Vectors (Index_Type => Positive, Element_Type => Recruit_Data); -- **** -- ****s* Bases/Bases.Base_Cargo -- FUNCTION -- Data structure for bases cargo -- PARAMETERS -- Proto_Index - Index of item prototype -- Amount - Amount of items -- Durability - Durability of items -- Price - Current price of item -- SOURCE type Base_Cargo is record Proto_Index: Unbounded_String; Amount: Natural; Durability: Items_Durability; Price: Natural; end record; -- **** -- ****t* Bases/Bases.BaseCargo_Container -- FUNCTION -- Used to store sky bases cargos -- SOURCE package BaseCargo_Container is new Vectors (Index_Type => Positive, Element_Type => Base_Cargo); -- **** -- ****t* Bases/Bases.Bases_Size -- FUNCTION -- Bases sizes -- SOURCE type Bases_Size is (SMALL, MEDIUM, BIG, UNKNOWN) with Default_Value => MEDIUM; -- **** -- ****s* Bases/Bases.Base_Record -- FUNCTION -- Data structure for bases -- PARAMETERS -- Name - Base name -- Visited - Time when player last visited base -- Sky_X - X coordinate on sky map -- Sky_Y - Y coordinate on sky map -- Base_Type - Type of base -- Population - Amount of people in base -- Recruit_Date - Time when recruits was generated -- Recruits - List of available recruits -- Known - Did base is know to player -- Asked_For_Bases - Did player asked for bases in this base -- Asked_For_Events - Time when players asked for events in this base -- Reputation - Reputation level and progress of player -- Missions_Date - Time when missions was generated -- Missions - List of available missions -- Owner - Index of faction which own base -- Cargo - List of all cargo in base -- Size - Size of base -- SOURCE type Base_Record is record Name: Unbounded_String; Visited: Date_Record; Sky_X: Map_X_Range; Sky_Y: Map_Y_Range; Base_Type: Unbounded_String; Population: Natural; Recruit_Date: Date_Record; Recruits: Recruit_Container.Vector; Known: Boolean; Asked_For_Bases: Boolean; Asked_For_Events: Date_Record; Reputation: Reputation_Array; Missions_Date: Date_Record; Missions: Mission_Container.Vector; Owner: Unbounded_String; Cargo: BaseCargo_Container.Vector; Size: Bases_Size; end record; -- **** -- ****v* Bases/Bases.SkyBases -- FUNCTION -- List of sky bases -- SOURCE Sky_Bases: array(Bases_Range) of Base_Record; -- **** -- ****v* Bases/Bases.Base_Syllables_Pre -- FUNCTION -- List of pre syllables for generating bases names -- SOURCE Base_Syllables_Pre: UnboundedString_Container.Vector; -- **** -- ****v* Bases/Bases.Base_Syllables_Start -- FUNCTION -- List of first syllables for generating bases names -- SOURCE Base_Syllables_Start: UnboundedString_Container.Vector; -- **** -- ****v* Bases/Bases.Base_Syllables_End -- FUNCTION -- List of second syllables for generating bases names -- SOURCE Base_Syllables_End: UnboundedString_Container.Vector; -- **** -- ****v* Bases/Bases.Base_Syllables_Post -- FUNCTION -- List of post syllables for generating bases names -- SOURCE Base_Syllables_Post: UnboundedString_Container.Vector; -- **** -- ****f* Bases/Bases.Gain_Rep -- FUNCTION -- Gain reputation in selected base -- PARAMETERS -- Base_Index - Index of the base in which player gained or lose reputation -- Points - Amount of reputation points to gain or lose -- SOURCE procedure Gain_Rep(Base_Index: Bases_Range; Points: Integer) with Test_Case => (Name => "Test_GainRep", Mode => Robustness); -- **** -- ****f* Bases/Bases.Count_Price -- FUNCTION -- Count price for actions with bases (buying/selling/docking/ect) -- PARAMETERS -- Price - Cost of action with the base -- Trader_Index - Index of crew member assigned as trader or 0 if noone is -- assigned -- Reduce - If true, reduce cost of action, otherwise raise. Default -- is true -- RESULT -- Parameter Cost -- SOURCE procedure Count_Price (Price: in out Natural; Trader_Index: Crew_Container.Extended_Index; Reduce: Boolean := True) with Pre => Trader_Index <= Player_Ship.Crew.Last_Index, Test_Case => (Name => "Test_CountPrice", Mode => Nominal); -- **** -- ****f* Bases/Bases.Generate_Base_Name -- FUNCTION -- Generate random name for base based on faction -- PARAMETERS -- Faction_Index - Index of faction to which base belong -- RESULT -- Random name for the sky base -- SOURCE function Generate_Base_Name (Faction_Index: Unbounded_String) return Unbounded_String with Pre => Factions_Container.Contains (Container => Factions_List, Key => Faction_Index), Post => Length(Source => Generate_Base_Name'Result) > 0, Test_Case => (Name => "Test_GenerateBaseName", Mode => Nominal); -- **** -- ****f* Bases/Bases.Generate_Recruits -- FUNCTION -- Generate if needed new recruits in base -- SOURCE procedure Generate_Recruits with Test_Case => (Name => "Test_GenerateRecruits", Mode => Robustness); -- **** -- ****f* Bases/Bases.Ask_For_Bases -- FUNCTION -- Ask in base for direction for other bases -- SOURCE procedure Ask_For_Bases with Test_Case => (Name => "Test_AskForBases", Mode => Robustness); -- **** -- ****f* Bases/Bases.Ask_For_Events -- FUNCTION -- Ask in base for direction for random events -- SOURCE procedure Ask_For_Events with Test_Case => (Name => "Test_AskForEvents", Mode => Robustness); -- **** -- ****f* Bases/Bases.Update_Population -- FUNCTION -- Update base population if needed -- SOURCE procedure Update_Population with Test_Case => (Name => "Test_UpdatePopulation", Mode => Robustness); -- **** -- ****f* Bases/Bases.Update_Prices -- FUNCTION -- Random changes of items prices in base -- SOURCE procedure Update_Prices with Test_Case => (Name => "Test_UpdatePrices", Mode => Robustness); -- **** end Bases;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T C M D -- -- -- -- B o d y -- -- -- -- Copyright (C) 1996-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 GNAT.Directory_Operations; use GNAT.Directory_Operations; with Csets; with MLib.Tgt; use MLib.Tgt; with MLib.Utl; with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; with Output; with Prj; use Prj; with Prj.Env; with Prj.Ext; use Prj.Ext; with Prj.Pars; with Prj.Util; use Prj.Util; with Sinput.P; with Snames; use Snames; with Table; with Types; use Types; with Hostparm; use Hostparm; -- Used to determine if we are in VMS or not for error message purposes with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; with GNAT.OS_Lib; use GNAT.OS_Lib; with VMS_Conv; use VMS_Conv; procedure GNATCmd is Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data; Project_File : String_Access; Project : Prj.Project_Id; Current_Verbosity : Prj.Verbosity := Prj.Default; Tool_Package_Name : Name_Id := No_Name; Old_Project_File_Used : Boolean := False; -- This flag indicates a switch -p (for gnatxref and gnatfind) for -- an old fashioned project file. -p cannot be used in conjonction -- with -P. Max_Files_On_The_Command_Line : constant := 30; -- Arbitrary Temp_File_Name : String_Access := null; -- The name of the temporary text file to put a list of source/object -- files to pass to a tool, when there are more than -- Max_Files_On_The_Command_Line files. package First_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Gnatcmd.First_Switches"); -- A table to keep the switches from the project file package Carg_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Gnatcmd.Carg_Switches"); -- A table to keep the switches following -cargs for ASIS tools package Rules_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Gnatcmd.Rules_Switches"); -- A table to keep the switches following -rules for gnatcheck package Library_Paths is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Make.Library_Path"); -- Packages of project files to pass to Prj.Pars.Parse, depending on the -- tool. We allocate objects because we cannot declare aliased objects -- as we are in a procedure, not a library level package. Naming_String : constant String_Access := new String'("naming"); Binder_String : constant String_Access := new String'("binder"); Compiler_String : constant String_Access := new String'("compiler"); Check_String : constant String_Access := new String'("check"); Eliminate_String : constant String_Access := new String'("eliminate"); Finder_String : constant String_Access := new String'("finder"); Linker_String : constant String_Access := new String'("linker"); Gnatls_String : constant String_Access := new String'("gnatls"); Pretty_String : constant String_Access := new String'("pretty_printer"); Gnatstub_String : constant String_Access := new String'("gnatstub"); Metric_String : constant String_Access := new String'("metrics"); Xref_String : constant String_Access := new String'("cross_reference"); Packages_To_Check_By_Binder : constant String_List_Access := new String_List'((Naming_String, Binder_String)); Packages_To_Check_By_Check : constant String_List_Access := new String_List'((Naming_String, Check_String, Compiler_String)); Packages_To_Check_By_Eliminate : constant String_List_Access := new String_List'((Naming_String, Eliminate_String, Compiler_String)); Packages_To_Check_By_Finder : constant String_List_Access := new String_List'((Naming_String, Finder_String)); Packages_To_Check_By_Linker : constant String_List_Access := new String_List'((Naming_String, Linker_String)); Packages_To_Check_By_Gnatls : constant String_List_Access := new String_List'((Naming_String, Gnatls_String)); Packages_To_Check_By_Pretty : constant String_List_Access := new String_List'((Naming_String, Pretty_String, Compiler_String)); Packages_To_Check_By_Gnatstub : constant String_List_Access := new String_List'((Naming_String, Gnatstub_String, Compiler_String)); Packages_To_Check_By_Metric : constant String_List_Access := new String_List'((Naming_String, Metric_String, Compiler_String)); Packages_To_Check_By_Xref : constant String_List_Access := new String_List'((Naming_String, Xref_String)); Packages_To_Check : String_List_Access := Prj.All_Packages; ---------------------------------- -- Declarations for GNATCMD use -- ---------------------------------- The_Command : Command_Type; -- The command specified in the invocation of the GNAT driver Command_Arg : Positive := 1; -- The index of the command in the arguments of the GNAT driver My_Exit_Status : Exit_Status := Success; -- The exit status of the spawned tool. Used to set the correct VMS -- exit status. Current_Work_Dir : constant String := Get_Current_Dir; -- The path of the working directory All_Projects : Boolean := False; -- Flag used for GNAT PRETTY and GNAT METRIC to indicate that -- the underlying tool (gnatcheck, gnatpp or gnatmetric) should be invoked -- for all sources of all projects. ----------------------- -- Local Subprograms -- ----------------------- procedure Add_To_Carg_Switches (Switch : String_Access); -- Add a switch to the Carg_Switches table. If it is the first one, -- put the switch "-cargs" at the beginning of the table. procedure Add_To_Rules_Switches (Switch : String_Access); -- Add a switch to the Rules_Switches table. If it is the first one, -- put the switch "-crules" at the beginning of the table. procedure Check_Files; -- For GNAT LIST, GNAT PRETTY and GNAT METRIC, check if a project -- file is specified, without any file arguments. If it is the case, -- invoke the GNAT tool with the proper list of files, derived from -- the sources of the project. function Check_Project (Project : Project_Id; Root_Project : Project_Id) return Boolean; -- Returns True if Project = Root_Project. -- For GNAT METRIC, also returns True if Project is extended by -- Root_Project. procedure Check_Relative_Executable (Name : in out String_Access); -- Check if an executable is specified as a relative path. -- If it is, and the path contains directory information, fail. -- Otherwise, prepend the exec directory. -- This procedure is only used for GNAT LINK when a project file -- is specified. function Configuration_Pragmas_File return Name_Id; -- Return an argument, if there is a configuration pragmas file to be -- specified for Project, otherwise return No_Name. -- Used for gnatstub (GNAT STUB), gnatpp (GNAT PRETTY), gnatelim -- (GNAT ELIM), and gnatmetric (GNAT METRIC). procedure Delete_Temp_Config_Files; -- Delete all temporary config files function Index (Char : Character; Str : String) return Natural; -- Returns the first occurrence of Char in Str. -- Returns 0 if Char is not in Str. procedure Non_VMS_Usage; -- Display usage for platforms other than VMS procedure Process_Link; -- Process GNAT LINK, when there is a project file specified procedure Set_Library_For (Project : Project_Id; There_Are_Libraries : in out Boolean); -- If Project is a library project, add the correct -- -L and -l switches to the linker invocation. procedure Set_Libraries is new For_Every_Project_Imported (Boolean, Set_Library_For); -- Add the -L and -l switches to the linker for all -- of the library projects. procedure Test_If_Relative_Path (Switch : in out String_Access; Parent : String); -- Test if Switch is a relative search path switch. -- If it is and it includes directory information, prepend the path with -- Parent.This subprogram is only called when using project files. -------------------------- -- Add_To_Carg_Switches -- -------------------------- procedure Add_To_Carg_Switches (Switch : String_Access) is begin -- If the Carg_Switches table is empty, put "-cargs" at the beginning if Carg_Switches.Last = 0 then Carg_Switches.Increment_Last; Carg_Switches.Table (Carg_Switches.Last) := new String'("-cargs"); end if; Carg_Switches.Increment_Last; Carg_Switches.Table (Carg_Switches.Last) := Switch; end Add_To_Carg_Switches; --------------------------- -- Add_To_Rules_Switches -- --------------------------- procedure Add_To_Rules_Switches (Switch : String_Access) is begin -- If the Rules_Switches table is empty, put "-rules" at the beginning if Rules_Switches.Last = 0 then Rules_Switches.Increment_Last; Rules_Switches.Table (Rules_Switches.Last) := new String'("-rules"); end if; Rules_Switches.Increment_Last; Rules_Switches.Table (Rules_Switches.Last) := Switch; end Add_To_Rules_Switches; ----------------- -- Check_Files -- ----------------- procedure Check_Files is Add_Sources : Boolean := True; Unit_Data : Prj.Unit_Data; Subunit : Boolean := False; begin -- Check if there is at least one argument that is not a switch for Index in 1 .. Last_Switches.Last loop if Last_Switches.Table (Index) (1) /= '-' then Add_Sources := False; exit; end if; end loop; -- If all arguments were switches, add the path names of -- all the sources of the main project. if Add_Sources then declare Current_Last : constant Integer := Last_Switches.Last; begin for Unit in Unit_Table.First .. Unit_Table.Last (Project_Tree.Units) loop Unit_Data := Project_Tree.Units.Table (Unit); -- For gnatls, we only need to put the library units, -- body or spec, but not the subunits. if The_Command = List then if Unit_Data.File_Names (Body_Part).Name /= No_Name then -- There is a body; check if it is for this -- project. if Unit_Data.File_Names (Body_Part).Project = Project then Subunit := False; if Unit_Data.File_Names (Specification).Name = No_Name then -- We have a body with no spec: we need -- to check if this is a subunit, because -- gnatls will complain about subunits. declare Src_Ind : Source_File_Index; begin Src_Ind := Sinput.P.Load_Project_File (Get_Name_String (Unit_Data.File_Names (Body_Part).Path)); Subunit := Sinput.P.Source_File_Is_Subunit (Src_Ind); end; end if; if not Subunit then Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String' (Get_Name_String (Unit_Data.File_Names (Body_Part).Display_Name)); end if; end if; elsif Unit_Data.File_Names (Specification).Name /= No_Name then -- We have a spec with no body; check if it is -- for this project. if Unit_Data.File_Names (Specification).Project = Project then Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String' (Get_Name_String (Unit_Data.File_Names (Specification).Display_Name)); end if; end if; else -- For gnatcheck, gnatpp and gnatmetric, put all sources -- of the project, or of all projects if -U was specified. for Kind in Spec_Or_Body loop -- Put only sources that belong to the main -- project. if Check_Project (Unit_Data.File_Names (Kind).Project, Project) then Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String' (Get_Name_String (Unit_Data.File_Names (Kind).Display_Path)); end if; end loop; end if; end loop; -- If the list of files is too long, create a temporary -- text file that lists these files, and pass this temp -- file to gnatcheck, gnatpp or gnatmetric using switch -files=. if Last_Switches.Last - Current_Last > Max_Files_On_The_Command_Line then declare Temp_File_FD : File_Descriptor; Buffer : String (1 .. 1_000); Len : Natural; OK : Boolean := True; begin Create_Temp_File (Temp_File_FD, Temp_File_Name); if Temp_File_Name /= null then for Index in Current_Last + 1 .. Last_Switches.Last loop Len := Last_Switches.Table (Index)'Length; Buffer (1 .. Len) := Last_Switches.Table (Index).all; Len := Len + 1; Buffer (Len) := ASCII.LF; Buffer (Len + 1) := ASCII.NUL; OK := Write (Temp_File_FD, Buffer (1)'Address, Len) = Len; exit when not OK; end loop; if OK then Close (Temp_File_FD, OK); else Close (Temp_File_FD, OK); OK := False; end if; -- If there were any problem creating the temp -- file, then pass the list of files. if OK then -- Replace the list of files with -- "-files=<temp file name>". Last_Switches.Set_Last (Current_Last + 1); Last_Switches.Table (Last_Switches.Last) := new String'("-files=" & Temp_File_Name.all); end if; end if; end; end if; end; end if; end Check_Files; ------------------- -- Check_Project -- ------------------- function Check_Project (Project : Project_Id; Root_Project : Project_Id) return Boolean is begin if Project = No_Project then return False; elsif All_Projects or Project = Root_Project then return True; elsif The_Command = Metric then declare Data : Project_Data := Project_Tree.Projects.Table (Root_Project); begin while Data.Extends /= No_Project loop if Project = Data.Extends then return True; end if; Data := Project_Tree.Projects.Table (Data.Extends); end loop; end; end if; return False; end Check_Project; ------------------------------- -- Check_Relative_Executable -- ------------------------------- procedure Check_Relative_Executable (Name : in out String_Access) is Exec_File_Name : constant String := Name.all; begin if not Is_Absolute_Path (Exec_File_Name) then for Index in Exec_File_Name'Range loop if Exec_File_Name (Index) = Directory_Separator then Fail ("relative executable (""" & Exec_File_Name & """) with directory part not allowed " & "when using project files"); end if; end loop; Get_Name_String (Project_Tree.Projects.Table (Project).Exec_Directory); if Name_Buffer (Name_Len) /= Directory_Separator then Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Directory_Separator; end if; Name_Buffer (Name_Len + 1 .. Name_Len + Exec_File_Name'Length) := Exec_File_Name; Name_Len := Name_Len + Exec_File_Name'Length; Name := new String'(Name_Buffer (1 .. Name_Len)); end if; end Check_Relative_Executable; -------------------------------- -- Configuration_Pragmas_File -- -------------------------------- function Configuration_Pragmas_File return Name_Id is begin Prj.Env.Create_Config_Pragmas_File (Project, Project, Project_Tree, Include_Config_Files => False); return Project_Tree.Projects.Table (Project).Config_File_Name; end Configuration_Pragmas_File; ------------------------------ -- Delete_Temp_Config_Files -- ------------------------------ procedure Delete_Temp_Config_Files is Success : Boolean; begin if not Keep_Temporary_Files then if Project /= No_Project then for Prj in Project_Table.First .. Project_Table.Last (Project_Tree.Projects) loop if Project_Tree.Projects.Table (Prj).Config_File_Temp then if Verbose_Mode then Output.Write_Str ("Deleting temp configuration file """); Output.Write_Str (Get_Name_String (Project_Tree.Projects.Table (Prj).Config_File_Name)); Output.Write_Line (""""); end if; Delete_File (Name => Get_Name_String (Project_Tree.Projects.Table (Prj).Config_File_Name), Success => Success); end if; end loop; end if; -- If a temporary text file that contains a list of files for a tool -- has been created, delete this temporary file. if Temp_File_Name /= null then Delete_File (Temp_File_Name.all, Success); end if; end if; end Delete_Temp_Config_Files; ----------- -- Index -- ----------- function Index (Char : Character; Str : String) return Natural is begin for Index in Str'Range loop if Str (Index) = Char then return Index; end if; end loop; return 0; end Index; ------------------ -- Process_Link -- ------------------ procedure Process_Link is Look_For_Executable : Boolean := True; There_Are_Libraries : Boolean := False; Path_Option : constant String_Access := MLib.Linker_Library_Path_Option; Prj : Project_Id := Project; Arg : String_Access; Last : Natural := 0; Skip_Executable : Boolean := False; begin -- Add the default search directories, to be able to find -- libgnat in call to MLib.Utl.Lib_Directory. Add_Default_Search_Dirs; Library_Paths.Set_Last (0); -- Check if there are library project files if MLib.Tgt.Support_For_Libraries /= MLib.Tgt.None then Set_Libraries (Project, Project_Tree, There_Are_Libraries); end if; -- If there are, add the necessary additional switches if There_Are_Libraries then -- Add -L<lib_dir> -lgnarl -lgnat -Wl,-rpath,<lib_dir> Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-L" & MLib.Utl.Lib_Directory); Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-lgnarl"); Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-lgnat"); -- If Path_Option is not null, create the switch -- ("-Wl,-rpath," or equivalent) with all the library dirs -- plus the standard GNAT library dir. if Path_Option /= null then declare Option : String_Access; Length : Natural := Path_Option'Length; Current : Natural; begin -- First, compute the exact length for the switch for Index in Library_Paths.First .. Library_Paths.Last loop -- Add the length of the library dir plus one -- for the directory separator. Length := Length + Library_Paths.Table (Index)'Length + 1; end loop; -- Finally, add the length of the standard GNAT -- library dir. Length := Length + MLib.Utl.Lib_Directory'Length; Option := new String (1 .. Length); Option (1 .. Path_Option'Length) := Path_Option.all; Current := Path_Option'Length; -- Put each library dir followed by a dir separator for Index in Library_Paths.First .. Library_Paths.Last loop Option (Current + 1 .. Current + Library_Paths.Table (Index)'Length) := Library_Paths.Table (Index).all; Current := Current + Library_Paths.Table (Index)'Length + 1; Option (Current) := Path_Separator; end loop; -- Finally put the standard GNAT library dir Option (Current + 1 .. Current + MLib.Utl.Lib_Directory'Length) := MLib.Utl.Lib_Directory; -- And add the switch to the last switches Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := Option; end; end if; end if; -- Check if the first ALI file specified can be found, either -- in the object directory of the main project or in an object -- directory of a project file extended by the main project. -- If the ALI file can be found, replace its name with its -- absolute path. Skip_Executable := False; Switch_Loop : for J in 1 .. Last_Switches.Last loop -- If we have an executable just reset the flag if Skip_Executable then Skip_Executable := False; -- If -o, set flag so that next switch is not processed elsif Last_Switches.Table (J).all = "-o" then Skip_Executable := True; -- Normal case else declare Switch : constant String := Last_Switches.Table (J).all; ALI_File : constant String (1 .. Switch'Length + 4) := Switch & ".ali"; Test_Existence : Boolean := False; begin Last := Switch'Length; -- Skip real switches if Switch'Length /= 0 and then Switch (Switch'First) /= '-' then -- Append ".ali" if file name does not end with it if Switch'Length <= 4 or else Switch (Switch'Last - 3 .. Switch'Last) /= ".ali" then Last := ALI_File'Last; end if; -- If file name includes directory information, -- stop if ALI file exists. if Is_Absolute_Path (ALI_File (1 .. Last)) then Test_Existence := True; else for K in Switch'Range loop if Switch (K) = '/' or else Switch (K) = Directory_Separator then Test_Existence := True; exit; end if; end loop; end if; if Test_Existence then if Is_Regular_File (ALI_File (1 .. Last)) then exit Switch_Loop; end if; -- Look in object directories if ALI file exists else Project_Loop : loop declare Dir : constant String := Get_Name_String (Project_Tree.Projects.Table (Prj).Object_Directory); begin if Is_Regular_File (Dir & Directory_Separator & ALI_File (1 .. Last)) then -- We have found the correct project, so we -- replace the file with the absolute path. Last_Switches.Table (J) := new String' (Dir & Directory_Separator & ALI_File (1 .. Last)); -- And we are done exit Switch_Loop; end if; end; -- Go to the project being extended, -- if any. Prj := Project_Tree.Projects.Table (Prj).Extends; exit Project_Loop when Prj = No_Project; end loop Project_Loop; end if; end if; end; end if; end loop Switch_Loop; -- If a relative path output file has been specified, we add -- the exec directory. for J in reverse 1 .. Last_Switches.Last - 1 loop if Last_Switches.Table (J).all = "-o" then Check_Relative_Executable (Name => Last_Switches.Table (J + 1)); Look_For_Executable := False; exit; end if; end loop; if Look_For_Executable then for J in reverse 1 .. First_Switches.Last - 1 loop if First_Switches.Table (J).all = "-o" then Look_For_Executable := False; Check_Relative_Executable (Name => First_Switches.Table (J + 1)); exit; end if; end loop; end if; -- If no executable is specified, then find the name -- of the first ALI file on the command line and issue -- a -o switch with the absolute path of the executable -- in the exec directory. if Look_For_Executable then for J in 1 .. Last_Switches.Last loop Arg := Last_Switches.Table (J); Last := 0; if Arg'Length /= 0 and then Arg (Arg'First) /= '-' then if Arg'Length > 4 and then Arg (Arg'Last - 3 .. Arg'Last) = ".ali" then Last := Arg'Last - 4; elsif Is_Regular_File (Arg.all & ".ali") then Last := Arg'Last; end if; if Last /= 0 then Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-o"); Get_Name_String (Project_Tree.Projects.Table (Project).Exec_Directory); Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'(Name_Buffer (1 .. Name_Len) & Directory_Separator & Base_Name (Arg (Arg'First .. Last)) & Get_Executable_Suffix.all); exit; end if; end if; end loop; end if; end Process_Link; --------------------- -- Set_Library_For -- --------------------- procedure Set_Library_For (Project : Project_Id; There_Are_Libraries : in out Boolean) is Path_Option : constant String_Access := MLib.Linker_Library_Path_Option; begin -- Case of library project if Project_Tree.Projects.Table (Project).Library then There_Are_Libraries := True; -- Add the -L switch Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-L" & Get_Name_String (Project_Tree.Projects.Table (Project).Library_Dir)); -- Add the -l switch Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-l" & Get_Name_String (Project_Tree.Projects.Table (Project).Library_Name)); -- Add the directory to table Library_Paths, to be processed later -- if library is not static and if Path_Option is not null. if Project_Tree.Projects.Table (Project).Library_Kind /= Static and then Path_Option /= null then Library_Paths.Increment_Last; Library_Paths.Table (Library_Paths.Last) := new String'(Get_Name_String (Project_Tree.Projects.Table (Project).Library_Dir)); end if; end if; end Set_Library_For; --------------------------- -- Test_If_Relative_Path -- --------------------------- procedure Test_If_Relative_Path (Switch : in out String_Access; Parent : String) is begin if Switch /= null then declare Sw : String (1 .. Switch'Length); Start : Positive := 1; begin Sw := Switch.all; if Sw (1) = '-' then if Sw'Length >= 3 and then (Sw (2) = 'A' or else Sw (2) = 'I' or else Sw (2) = 'L') 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") then Start := 4; elsif Sw'Length >= 7 and then Sw (2 .. 6) = "-RTS=" then Start := 7; else return; end if; end if; -- If the path is relative, test if it includes directory -- information. If it does, prepend Parent to the path. if not Is_Absolute_Path (Sw (Start .. Sw'Last)) 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; end if; end; end if; end Test_If_Relative_Path; ------------------- -- Non_VMS_Usage -- ------------------- procedure Non_VMS_Usage is begin Output_Version; New_Line; Put_Line ("List of available commands"); New_Line; for C in Command_List'Range loop if not Command_List (C).VMS_Only then Put ("gnat " & To_Lower (Command_List (C).Cname.all)); Set_Col (25); Put (Command_List (C).Unixcmd.all); declare Sws : Argument_List_Access renames Command_List (C).Unixsws; begin if Sws /= null then for J in Sws'Range loop Put (' '); Put (Sws (J).all); end loop; end if; end; New_Line; end if; end loop; New_Line; Put_Line ("Commands find, list, metric, pretty, stub and xref accept " & "project file switches -vPx, -Pprj and -Xnam=val"); New_Line; end Non_VMS_Usage; ------------------------------------- -- Start of processing for GNATCmd -- ------------------------------------- begin -- Initializations Namet.Initialize; Csets.Initialize; Snames.Initialize; Prj.Initialize (Project_Tree); Last_Switches.Init; Last_Switches.Set_Last (0); First_Switches.Init; First_Switches.Set_Last (0); Carg_Switches.Init; Carg_Switches.Set_Last (0); Rules_Switches.Init; Rules_Switches.Set_Last (0); VMS_Conv.Initialize; -- Add the directory where the GNAT driver is invoked in front of the -- path, if the GNAT driver 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 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; -- If on VMS, or if VMS emulation is on, convert VMS style /qualifiers, -- filenames and pathnames to Unix style. if Hostparm.OpenVMS or else To_Lower (Getenv ("EMULATE_VMS").all) = "true" then VMS_Conversion (The_Command); -- If not on VMS, scan the command line directly else if Argument_Count = 0 then Non_VMS_Usage; return; else begin loop if Argument_Count > Command_Arg and then Argument (Command_Arg) = "-v" then Verbose_Mode := True; Command_Arg := Command_Arg + 1; elsif Argument_Count > Command_Arg and then Argument (Command_Arg) = "-dn" then Keep_Temporary_Files := True; Command_Arg := Command_Arg + 1; else exit; end if; end loop; The_Command := Real_Command_Type'Value (Argument (Command_Arg)); if Command_List (The_Command).VMS_Only then Non_VMS_Usage; Fail ("Command """, Command_List (The_Command).Cname.all, """ can only be used on VMS"); end if; exception when Constraint_Error => -- Check if it is an alternate command declare Alternate : Alternate_Command; begin Alternate := Alternate_Command'Value (Argument (Command_Arg)); The_Command := Corresponding_To (Alternate); exception when Constraint_Error => Non_VMS_Usage; Fail ("Unknown command: ", Argument (Command_Arg)); end; end; -- Get the arguments from the command line and from the eventual -- argument file(s) specified on the command line. for Arg in Command_Arg + 1 .. Argument_Count loop declare The_Arg : constant String := Argument (Arg); begin -- Check if an argument file is specified if The_Arg (The_Arg'First) = '@' then declare Arg_File : Ada.Text_IO.File_Type; Line : String (1 .. 256); Last : Natural; begin -- Open the file and fail if the file cannot be found begin Open (Arg_File, In_File, The_Arg (The_Arg'First + 1 .. The_Arg'Last)); exception when others => Put (Standard_Error, "Cannot open argument file """); Put (Standard_Error, The_Arg (The_Arg'First + 1 .. The_Arg'Last)); Put_Line (Standard_Error, """"); raise Error_Exit; end; -- Read line by line and put the content of each -- non empty line in the Last_Switches table. while not End_Of_File (Arg_File) loop Get_Line (Arg_File, Line, Last); if Last /= 0 then Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'(Line (1 .. Last)); end if; end loop; Close (Arg_File); end; else -- It is not an argument file; just put the argument in -- the Last_Switches table. Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'(The_Arg); end if; end; end loop; end if; end if; declare Program : constant String := Program_Name (Command_List (The_Command).Unixcmd.all).all; Exec_Path : String_Access; begin -- First deal with built-in command(s) if The_Command = Setup then Process_Setup : declare Arg_Num : Positive := 1; Argv : String_Access; begin while Arg_Num <= Last_Switches.Last loop Argv := Last_Switches.Table (Arg_Num); if Argv (Argv'First) /= '-' then Fail ("invalid parameter """, Argv.all, """"); else if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); end if; -- -vPx Specify verbosity while parsing project files if Argv'Length = 4 and then Argv (Argv'First + 1 .. Argv'First + 2) = "vP" then case Argv (Argv'Last) is when '0' => Current_Verbosity := Prj.Default; when '1' => Current_Verbosity := Prj.Medium; when '2' => Current_Verbosity := Prj.High; when others => Fail ("Invalid switch: ", Argv.all); end case; -- -Pproject_file Specify project file to be used elsif Argv (Argv'First + 1) = 'P' then -- Only one -P switch can be used if Project_File /= null then Fail (Argv.all, ": second project file forbidden (first is """, Project_File.all & """)"); elsif Argv'Length = 2 then -- There is space between -P and the project file -- name. -P cannot be the last option. if Arg_Num = Last_Switches.Last then Fail ("project file name missing after -P"); else Arg_Num := Arg_Num + 1; Argv := Last_Switches.Table (Arg_Num); -- After -P, there must be a project file name, -- not another switch. if Argv (Argv'First) = '-' then Fail ("project file name missing after -P"); else Project_File := new String'(Argv.all); end if; end if; else -- No space between -P and project file name Project_File := new String'(Argv (Argv'First + 2 .. Argv'Last)); end if; -- -Xexternal=value Specify an external reference to be -- used in project files elsif Argv'Length >= 5 and then Argv (Argv'First + 1) = 'X' then declare Equal_Pos : constant Natural := Index ('=', Argv (Argv'First + 2 .. Argv'Last)); begin if Equal_Pos >= Argv'First + 3 and then Equal_Pos /= Argv'Last then Add (External_Name => Argv (Argv'First + 2 .. Equal_Pos - 1), Value => Argv (Equal_Pos + 1 .. Argv'Last)); else Fail (Argv.all, " is not a valid external assignment."); end if; end; elsif Argv.all = "-v" then Verbose_Mode := True; elsif Argv.all = "-q" then Quiet_Output := True; else Fail ("invalid parameter """, Argv.all, """"); end if; end if; Arg_Num := Arg_Num + 1; end loop; if Project_File = null then Fail ("no project file specified"); end if; Setup_Projects := True; Prj.Pars.Set_Verbosity (To => Current_Verbosity); -- Missing directories are created during processing of the -- project tree. Prj.Pars.Parse (Project => Project, In_Tree => Project_Tree, Project_File_Name => Project_File.all, Packages_To_Check => All_Packages); if Project = Prj.No_Project then Fail ("""", Project_File.all, """ processing failed"); end if; -- Processing is done return; end Process_Setup; end if; -- Locate the executable for the command Exec_Path := Locate_Exec_On_Path (Program); if Exec_Path = null then Put_Line (Standard_Error, "could not locate " & Program); raise Error_Exit; end if; -- If there are switches for the executable, put them as first switches if Command_List (The_Command).Unixsws /= null then for J in Command_List (The_Command).Unixsws'Range loop First_Switches.Increment_Last; First_Switches.Table (First_Switches.Last) := Command_List (The_Command).Unixsws (J); end loop; end if; -- For BIND, CHECK, FIND, LINK, LIST, PRETTY ad XREF, look for project -- file related switches. if The_Command = Bind or else The_Command = Check or else The_Command = Elim or else The_Command = Find or else The_Command = Link or else The_Command = List or else The_Command = Xref or else The_Command = Pretty or else The_Command = Stub or else The_Command = Metric then case The_Command is when Bind => Tool_Package_Name := Name_Binder; Packages_To_Check := Packages_To_Check_By_Binder; when Check => Tool_Package_Name := Name_Check; Packages_To_Check := Packages_To_Check_By_Check; when Elim => Tool_Package_Name := Name_Eliminate; Packages_To_Check := Packages_To_Check_By_Eliminate; when Find => Tool_Package_Name := Name_Finder; Packages_To_Check := Packages_To_Check_By_Finder; when Link => Tool_Package_Name := Name_Linker; Packages_To_Check := Packages_To_Check_By_Linker; when List => Tool_Package_Name := Name_Gnatls; Packages_To_Check := Packages_To_Check_By_Gnatls; when Metric => Tool_Package_Name := Name_Metrics; Packages_To_Check := Packages_To_Check_By_Metric; when Pretty => Tool_Package_Name := Name_Pretty_Printer; Packages_To_Check := Packages_To_Check_By_Pretty; when Stub => Tool_Package_Name := Name_Gnatstub; Packages_To_Check := Packages_To_Check_By_Gnatstub; when Xref => Tool_Package_Name := Name_Cross_Reference; Packages_To_Check := Packages_To_Check_By_Xref; when others => null; end case; -- Check that the switches are consistent. -- Detect project file related switches. Inspect_Switches : declare Arg_Num : Positive := 1; Argv : String_Access; procedure Remove_Switch (Num : Positive); -- Remove a project related switch from table Last_Switches ------------------- -- Remove_Switch -- ------------------- procedure Remove_Switch (Num : Positive) is begin Last_Switches.Table (Num .. Last_Switches.Last - 1) := Last_Switches.Table (Num + 1 .. Last_Switches.Last); Last_Switches.Decrement_Last; end Remove_Switch; -- Start of processing for Inspect_Switches begin while Arg_Num <= Last_Switches.Last loop Argv := Last_Switches.Table (Arg_Num); if Argv (Argv'First) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); end if; -- The two style project files (-p and -P) cannot be used -- together if (The_Command = Find or else The_Command = Xref) and then Argv (2) = 'p' then Old_Project_File_Used := True; if Project_File /= null then Fail ("-P and -p cannot be used together"); end if; end if; -- -vPx Specify verbosity while parsing project files if Argv'Length = 4 and then Argv (Argv'First + 1 .. Argv'First + 2) = "vP" then case Argv (Argv'Last) is when '0' => Current_Verbosity := Prj.Default; when '1' => Current_Verbosity := Prj.Medium; when '2' => Current_Verbosity := Prj.High; when others => Fail ("Invalid switch: ", Argv.all); end case; Remove_Switch (Arg_Num); -- -Pproject_file Specify project file to be used elsif Argv (Argv'First + 1) = 'P' then -- Only one -P switch can be used if Project_File /= null then Fail (Argv.all, ": second project file forbidden (first is """, Project_File.all & """)"); -- The two style project files (-p and -P) cannot be -- used together. elsif Old_Project_File_Used then Fail ("-p and -P cannot be used together"); elsif Argv'Length = 2 then -- There is space between -P and the project file -- name. -P cannot be the last option. if Arg_Num = Last_Switches.Last then Fail ("project file name missing after -P"); else Remove_Switch (Arg_Num); Argv := Last_Switches.Table (Arg_Num); -- After -P, there must be a project file name, -- not another switch. if Argv (Argv'First) = '-' then Fail ("project file name missing after -P"); else Project_File := new String'(Argv.all); end if; end if; else -- No space between -P and project file name Project_File := new String'(Argv (Argv'First + 2 .. Argv'Last)); end if; Remove_Switch (Arg_Num); -- -Xexternal=value Specify an external reference to be -- used in project files elsif Argv'Length >= 5 and then Argv (Argv'First + 1) = 'X' then declare Equal_Pos : constant Natural := Index ('=', Argv (Argv'First + 2 .. Argv'Last)); begin if Equal_Pos >= Argv'First + 3 and then Equal_Pos /= Argv'Last then Add (External_Name => Argv (Argv'First + 2 .. Equal_Pos - 1), Value => Argv (Equal_Pos + 1 .. Argv'Last)); else Fail (Argv.all, " is not a valid external assignment."); end if; end; Remove_Switch (Arg_Num); elsif (The_Command = Check or else The_Command = Pretty or else The_Command = Metric) and then Argv'Length = 2 and then Argv (2) = 'U' then All_Projects := True; Remove_Switch (Arg_Num); else Arg_Num := Arg_Num + 1; end if; else Arg_Num := Arg_Num + 1; end if; end loop; end Inspect_Switches; end if; -- If there is a project file specified, parse it, get the switches -- for the tool and setup PATH environment variables. if Project_File /= null then Prj.Pars.Set_Verbosity (To => Current_Verbosity); Prj.Pars.Parse (Project => Project, In_Tree => Project_Tree, Project_File_Name => Project_File.all, Packages_To_Check => Packages_To_Check); if Project = Prj.No_Project then Fail ("""", Project_File.all, """ processing failed"); end if; -- Check if a package with the name of the tool is in the project -- file and if there is one, get the switches, if any, and scan them. declare Data : constant Prj.Project_Data := Project_Tree.Projects.Table (Project); Pkg : constant Prj.Package_Id := Prj.Util.Value_Of (Name => Tool_Package_Name, In_Packages => Data.Decl.Packages, In_Tree => Project_Tree); Element : Package_Element; Default_Switches_Array : Array_Element_Id; The_Switches : Prj.Variable_Value; Current : Prj.String_List_Id; The_String : String_Element; begin if Pkg /= No_Package then Element := Project_Tree.Packages.Table (Pkg); -- Packages Gnatls has a single attribute Switches, that is -- not an associative array. if The_Command = List then The_Switches := Prj.Util.Value_Of (Variable_Name => Snames.Name_Switches, In_Variables => Element.Decl.Attributes, In_Tree => Project_Tree); -- Packages Binder (for gnatbind), Cross_Reference (for -- gnatxref), Linker (for gnatlink) Finder (for gnatfind), -- Pretty_Printer (for gnatpp) Eliminate (for gnatelim), -- Check (for gnatcheck) and Metric (for gnatmetric) have -- an attributed Switches, an associative array, indexed -- by the name of the file. -- They also have an attribute Default_Switches, indexed -- by the name of the programming language. else if The_Switches.Kind = Prj.Undefined then Default_Switches_Array := Prj.Util.Value_Of (Name => Name_Default_Switches, In_Arrays => Element.Decl.Arrays, In_Tree => Project_Tree); The_Switches := Prj.Util.Value_Of (Index => Name_Ada, Src_Index => 0, In_Array => Default_Switches_Array, In_Tree => Project_Tree); end if; end if; -- If there are switches specified in the package of the -- project file corresponding to the tool, scan them. case The_Switches.Kind is when Prj.Undefined => null; when Prj.Single => declare Switch : constant String := Get_Name_String (The_Switches.Value); begin if Switch'Length > 0 then First_Switches.Increment_Last; First_Switches.Table (First_Switches.Last) := new String'(Switch); end if; end; when Prj.List => Current := The_Switches.Values; while Current /= Prj.Nil_String loop The_String := Project_Tree.String_Elements. Table (Current); declare Switch : constant String := Get_Name_String (The_String.Value); begin if Switch'Length > 0 then First_Switches.Increment_Last; First_Switches.Table (First_Switches.Last) := new String'(Switch); end if; end; Current := The_String.Next; end loop; end case; end if; end; if The_Command = Bind or else The_Command = Link or else The_Command = Elim then Change_Dir (Get_Name_String (Project_Tree.Projects.Table (Project).Object_Directory)); end if; -- Set up the env vars for project path files Prj.Env.Set_Ada_Paths (Project, Project_Tree, Including_Libraries => False); -- For gnatcheck, gnatstub, gnatmetric, gnatpp and gnatelim, create -- a configuration pragmas file, if necessary. if The_Command = Pretty or else The_Command = Metric or else The_Command = Stub or else The_Command = Elim or else The_Command = Check then -- If there are switches in package Compiler, put them in the -- Carg_Switches table. declare Data : constant Prj.Project_Data := Project_Tree.Projects.Table (Project); Pkg : constant Prj.Package_Id := Prj.Util.Value_Of (Name => Name_Compiler, In_Packages => Data.Decl.Packages, In_Tree => Project_Tree); Element : Package_Element; Default_Switches_Array : Array_Element_Id; The_Switches : Prj.Variable_Value; Current : Prj.String_List_Id; The_String : String_Element; begin if Pkg /= No_Package then Element := Project_Tree.Packages.Table (Pkg); Default_Switches_Array := Prj.Util.Value_Of (Name => Name_Default_Switches, In_Arrays => Element.Decl.Arrays, In_Tree => Project_Tree); The_Switches := Prj.Util.Value_Of (Index => Name_Ada, Src_Index => 0, In_Array => Default_Switches_Array, In_Tree => Project_Tree); -- If there are switches specified in the package of the -- project file corresponding to the tool, scan them. case The_Switches.Kind is when Prj.Undefined => null; when Prj.Single => declare Switch : constant String := Get_Name_String (The_Switches.Value); begin if Switch'Length > 0 then Add_To_Carg_Switches (new String'(Switch)); end if; end; when Prj.List => Current := The_Switches.Values; while Current /= Prj.Nil_String loop The_String := Project_Tree.String_Elements.Table (Current); declare Switch : constant String := Get_Name_String (The_String.Value); begin if Switch'Length > 0 then Add_To_Carg_Switches (new String'(Switch)); end if; end; Current := The_String.Next; end loop; end case; end if; end; -- If -cargs is one of the switches, move the following switches -- to the Carg_Switches table. for J in 1 .. First_Switches.Last loop if First_Switches.Table (J).all = "-cargs" then for K in J + 1 .. First_Switches.Last loop Add_To_Carg_Switches (First_Switches.Table (K)); end loop; First_Switches.Set_Last (J - 1); exit; end if; end loop; for J in 1 .. Last_Switches.Last loop if Last_Switches.Table (J).all = "-cargs" then for K in J + 1 .. Last_Switches.Last loop Add_To_Carg_Switches (Last_Switches.Table (K)); end loop; Last_Switches.Set_Last (J - 1); exit; end if; end loop; declare CP_File : constant Name_Id := Configuration_Pragmas_File; begin if CP_File /= No_Name then if The_Command = Elim then First_Switches.Increment_Last; First_Switches.Table (First_Switches.Last) := new String'("-C" & Get_Name_String (CP_File)); else Add_To_Carg_Switches (new String'("-gnatec=" & Get_Name_String (CP_File))); end if; end if; end; end if; if The_Command = Link then Process_Link; end if; if The_Command = Link or The_Command = Bind then -- For files that are specified as relative paths with directory -- information, we convert them to absolute paths, with parent -- being the current working directory if specified on the command -- line and the project directory if specified in the project -- file. This is what gnatmake is doing for linker and binder -- arguments. for J in 1 .. Last_Switches.Last loop Test_If_Relative_Path (Last_Switches.Table (J), Current_Work_Dir); end loop; Get_Name_String (Project_Tree.Projects.Table (Project).Directory); declare Project_Dir : constant String := Name_Buffer (1 .. Name_Len); begin for J in 1 .. First_Switches.Last loop Test_If_Relative_Path (First_Switches.Table (J), Project_Dir); end loop; end; elsif The_Command = Stub then declare Data : constant Prj.Project_Data := Project_Tree.Projects.Table (Project); File_Index : Integer := 0; Dir_Index : Integer := 0; Last : constant Integer := Last_Switches.Last; begin for Index in 1 .. Last loop if Last_Switches.Table (Index) (Last_Switches.Table (Index)'First) /= '-' then File_Index := Index; exit; end if; end loop; -- If the naming scheme of the project file is not standard, -- and if the file name ends with the spec suffix, then -- indicate to gnatstub the name of the body file with -- a -o switch. if Data.Naming.Ada_Spec_Suffix /= Prj.Default_Ada_Spec_Suffix then if File_Index /= 0 then declare Spec : constant String := Base_Name (Last_Switches.Table (File_Index).all); Last : Natural := Spec'Last; begin Get_Name_String (Data.Naming.Ada_Spec_Suffix); if Spec'Length > Name_Len and then Spec (Last - Name_Len + 1 .. Last) = Name_Buffer (1 .. Name_Len) then Last := Last - Name_Len; Get_Name_String (Data.Naming.Ada_Body_Suffix); Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'("-o"); Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String'(Spec (Spec'First .. Last) & Name_Buffer (1 .. Name_Len)); end if; end; end if; end if; -- Add the directory of the spec as the destination directory -- of the body, if there is no destination directory already -- specified. if File_Index /= 0 then for Index in File_Index + 1 .. Last loop if Last_Switches.Table (Index) (Last_Switches.Table (Index)'First) /= '-' then Dir_Index := Index; exit; end if; end loop; if Dir_Index = 0 then Last_Switches.Increment_Last; Last_Switches.Table (Last_Switches.Last) := new String' (Dir_Name (Last_Switches.Table (File_Index).all)); end if; end if; end; end if; -- For gnatmetric, the generated files should be put in the object -- directory. This must be the first switch, because it may be -- overriden by a switch in package Metrics in the project file or by -- a command line option. if The_Command = Metric then First_Switches.Increment_Last; First_Switches.Table (2 .. First_Switches.Last) := First_Switches.Table (1 .. First_Switches.Last - 1); First_Switches.Table (1) := new String'("-d=" & Get_Name_String (Project_Tree.Projects.Table (Project).Object_Directory)); end if; -- For gnat check, -rules and the following switches need to be the -- last options. So, we move all these switches to table -- Rules_Switches. if The_Command = Check then declare New_Last : Natural; -- Set to rank of options preceding "-rules" In_Rules_Switches : Boolean; -- Set to True when options "-rules" is found begin New_Last := First_Switches.Last; In_Rules_Switches := False; for J in 1 .. First_Switches.Last loop if In_Rules_Switches then Add_To_Rules_Switches (First_Switches.Table (J)); elsif First_Switches.Table (J).all = "-rules" then New_Last := J - 1; In_Rules_Switches := True; end if; end loop; if In_Rules_Switches then First_Switches.Set_Last (New_Last); end if; New_Last := Last_Switches.Last; In_Rules_Switches := False; for J in 1 .. Last_Switches.Last loop if In_Rules_Switches then Add_To_Rules_Switches (Last_Switches.Table (J)); elsif Last_Switches.Table (J).all = "-rules" then New_Last := J - 1; In_Rules_Switches := True; end if; end loop; if In_Rules_Switches then Last_Switches.Set_Last (New_Last); end if; end; end if; -- For gnat check, gnat pretty, gnat metric ands gnat list, -- if no file has been put on the command line, call tool with all -- the sources of the main project. if The_Command = Check or else The_Command = Pretty or else The_Command = Metric or else The_Command = List then Check_Files; end if; end if; -- Gather all the arguments and invoke the executable declare The_Args : Argument_List (1 .. First_Switches.Last + Last_Switches.Last + Carg_Switches.Last + Rules_Switches.Last); Arg_Num : Natural := 0; begin for J in 1 .. First_Switches.Last loop Arg_Num := Arg_Num + 1; The_Args (Arg_Num) := First_Switches.Table (J); end loop; for J in 1 .. Last_Switches.Last loop Arg_Num := Arg_Num + 1; The_Args (Arg_Num) := Last_Switches.Table (J); end loop; for J in 1 .. Carg_Switches.Last loop Arg_Num := Arg_Num + 1; The_Args (Arg_Num) := Carg_Switches.Table (J); end loop; for J in 1 .. Rules_Switches.Last loop Arg_Num := Arg_Num + 1; The_Args (Arg_Num) := Rules_Switches.Table (J); end loop; -- If Display_Command is on, only display the generated command if Display_Command then Put (Standard_Error, "generated command -->"); Put (Standard_Error, Exec_Path.all); for Arg in The_Args'Range loop Put (Standard_Error, " "); Put (Standard_Error, The_Args (Arg).all); end loop; Put (Standard_Error, "<--"); New_Line (Standard_Error); raise Normal_Exit; end if; if Verbose_Mode then Output.Write_Str (Exec_Path.all); for Arg in The_Args'Range loop Output.Write_Char (' '); Output.Write_Str (The_Args (Arg).all); end loop; Output.Write_Eol; end if; My_Exit_Status := Exit_Status (Spawn (Exec_Path.all, The_Args)); raise Normal_Exit; end; end; exception when Error_Exit => Prj.Env.Delete_All_Path_Files (Project_Tree); Delete_Temp_Config_Files; Set_Exit_Status (Failure); when Normal_Exit => Prj.Env.Delete_All_Path_Files (Project_Tree); Delete_Temp_Config_Files; -- Since GNATCmd is normally called from DCL (the VMS shell), it must -- return an understandable VMS exit status. However the exit status -- returned *to* GNATCmd is a Posix style code, so we test it and return -- just a simple success or failure on VMS. if Hostparm.OpenVMS and then My_Exit_Status /= Success then Set_Exit_Status (Failure); else Set_Exit_Status (My_Exit_Status); end if; end GNATCmd;
pragma License (Unrestricted); -- optional runtime unit with System.Unwind; package notb is pragma Preelaborate; Exception_Tracebacks : Integer with Export, Convention => C, External_Name => "__gl_exception_tracebacks"; procedure Call_Chain ( Current : in out System.Unwind.Exception_Occurrence) is null with Export, -- for weak linking Convention => Ada, External_Name => "ada__exceptions__call_chain"; procedure Backtrace_Information ( X : System.Unwind.Exception_Occurrence; Params : System.Address; Put : not null access procedure (S : String; Params : System.Address); New_Line : not null access procedure (Params : System.Address)) is null with Export, -- for weak linking Convention => Ada, External_Name => "__drake_backtrace_information"; end notb;
----------------------------------------------------------------------- -- asf -- XHTML Reader -- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Unicode; with Ada.Exceptions; with Ada.Strings.Fixed; with Util.Log.Loggers; with Util.Serialize.IO.XML; package body ASF.Views.Nodes.Reader is use Sax.Readers; use Sax.Exceptions; use Sax.Locators; use Sax.Attributes; use Unicode; use Unicode.CES; use Ada.Strings.Fixed; -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Views.Nodes.Reader"); procedure Free is new Ada.Unchecked_Deallocation (Element_Context_Array, Element_Context_Array_Access); procedure Push (Handler : in out Xhtml_Reader'Class); procedure Pop (Handler : in out Xhtml_Reader'Class); -- Freeze the current Text_Tag node, counting the number of elements it contains. procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class); -- ------------------------------ -- Push the current context when entering in an element. -- ------------------------------ procedure Push (Handler : in out Xhtml_Reader'Class) is begin if Handler.Stack = null then Handler.Stack := new Element_Context_Array (1 .. 100); elsif Handler.Stack_Pos = Handler.Stack'Last then declare Old : Element_Context_Array_Access := Handler.Stack; begin Handler.Stack := new Element_Context_Array (1 .. Old'Last + 100); Handler.Stack (1 .. Old'Last) := Old (1 .. Old'Last); Free (Old); end; end if; if Handler.Stack_Pos /= Handler.Stack'First then Handler.Stack (Handler.Stack_Pos + 1) := Handler.Stack (Handler.Stack_Pos); end if; Handler.Stack_Pos := Handler.Stack_Pos + 1; Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access; end Push; -- ------------------------------ -- Pop the context and restore the previous context when leaving an element -- ------------------------------ procedure Pop (Handler : in out Xhtml_Reader'Class) is begin Handler.Stack_Pos := Handler.Stack_Pos - 1; Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access; end Pop; -- ------------------------------ -- Find the function knowing its name. -- ------------------------------ overriding function Get_Function (Mapper : NS_Function_Mapper; Namespace : String; Name : String) return Function_Access is use NS_Mapping; Pos : constant NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Namespace); begin if Has_Element (Pos) then return Mapper.Mapper.Get_Function (Element (Pos), Name); end if; raise No_Function with "Function '" & Namespace & ':' & Name & "' not found"; end Get_Function; -- ------------------------------ -- Bind a name to a function in the given namespace. -- ------------------------------ overriding procedure Set_Function (Mapper : in out NS_Function_Mapper; Namespace : in String; Name : in String; Func : in Function_Access) is begin null; end Set_Function; -- ------------------------------ -- Find the create function bound to the name in the given namespace. -- Returns null if no such binding exist. -- ------------------------------ function Find (Mapper : NS_Function_Mapper; Namespace : String; Name : String) return ASF.Views.Nodes.Binding_Access is use NS_Mapping; begin return ASF.Factory.Find (Mapper.Factory.all, Namespace, Name); end Find; procedure Set_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String; URI : in String) is use NS_Mapping; begin Log.Debug ("Add namespace {0}:{1}", Prefix, URI); Mapper.Mapping.Include (Prefix, URI); end Set_Namespace; -- ------------------------------ -- Remove the namespace prefix binding. -- ------------------------------ procedure Remove_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String) is use NS_Mapping; Pos : NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Prefix); begin Log.Debug ("Remove namespace {0}", Prefix); if Has_Element (Pos) then NS_Mapping.Delete (Mapper.Mapping, Pos); end if; end Remove_Namespace; -- ------------------------------ -- Warning -- ------------------------------ overriding procedure Warning (Handler : in out Xhtml_Reader; Except : Sax.Exceptions.Sax_Parse_Exception'Class) is pragma Warnings (Off, Handler); begin Log.Warn ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except)); end Warning; -- ------------------------------ -- Error -- ------------------------------ overriding procedure Error (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is pragma Warnings (Off, Handler); begin Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except)); end Error; -- ------------------------------ -- Fatal_Error -- ------------------------------ overriding procedure Fatal_Error (Handler : in out Xhtml_Reader; Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is pragma Unreferenced (Handler); begin Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except)); end Fatal_Error; -- ------------------------------ -- Set_Document_Locator -- ------------------------------ overriding procedure Set_Document_Locator (Handler : in out Xhtml_Reader; Loc : in out Sax.Locators.Locator) is begin Handler.Locator := Loc; end Set_Document_Locator; -- ------------------------------ -- Start_Document -- ------------------------------ overriding procedure Start_Document (Handler : in out Xhtml_Reader) is begin null; end Start_Document; -- ------------------------------ -- End_Document -- ------------------------------ overriding procedure End_Document (Handler : in out Xhtml_Reader) is begin null; end End_Document; -- ------------------------------ -- Start_Prefix_Mapping -- ------------------------------ overriding procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader; Prefix : in Unicode.CES.Byte_Sequence; URI : in Unicode.CES.Byte_Sequence) is begin if Prefix = "" then Handler.Add_NS := To_Unbounded_String (URI); else Handler.Functions.Set_Namespace (Prefix => Prefix, URI => URI); end if; end Start_Prefix_Mapping; -- ------------------------------ -- End_Prefix_Mapping -- ------------------------------ overriding procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader; Prefix : in Unicode.CES.Byte_Sequence) is begin Handler.Functions.Remove_Namespace (Prefix => Prefix); end End_Prefix_Mapping; -- ------------------------------ -- Collect the text for an EL expression. The EL expression starts -- with either '#{' or with '${' and ends with the matching '}'. -- If the <b>Value</b> string does not contain the whole EL experssion -- the <b>Expr_Buffer</b> stored in the reader is used to collect -- that expression. -- ------------------------------ procedure Collect_Expression (Handler : in out Xhtml_Reader) is use Ada.Exceptions; Expr : constant String := To_String (Handler.Expr_Buffer); Content : constant Tag_Content_Access := Handler.Text.Last; begin Handler.Expr_Buffer := Null_Unbounded_String; Content.Expr := EL.Expressions.Create_Expression (Expr, Handler.ELContext.all); Content.Next := new Tag_Content; Handler.Text.Last := Content.Next; exception when E : EL.Functions.No_Function | EL.Expressions.Invalid_Expression => Log.Error ("{0}: Invalid expression: {1}", To_String (Handler.Locator), Exception_Message (E)); Log.Error ("{0}: {1}", To_String (Handler.Locator), Expr); when E : others => Log.Error ("{0}: Internal error: {1}:{2}", To_String (Handler.Locator), Exception_Name (E), Exception_Message (E)); end Collect_Expression; -- ------------------------------ -- Collect the raw-text in a buffer. The text must be flushed -- when a new element is started or when an exiting element is closed. -- ------------------------------ procedure Collect_Text (Handler : in out Xhtml_Reader; Value : in Unicode.CES.Byte_Sequence) is Pos : Natural := Value'First; C : Character; Content : Tag_Content_Access; Start_Pos : Natural; Last_Pos : Natural; begin while Pos <= Value'Last loop case Handler.State is -- Collect the white spaces and newlines in the 'Spaces' -- buffer to ignore empty lines but still honor indentation. when NO_CONTENT => loop C := Value (Pos); if C = ASCII.CR or C = ASCII.LF then Handler.Spaces := Null_Unbounded_String; elsif C = ' ' or C = ASCII.HT then Append (Handler.Spaces, C); else Handler.State := HAS_CONTENT; exit; end if; Pos := Pos + 1; exit when Pos > Value'Last; end loop; -- Collect an EL expression until the end of that -- expression. Evaluate the expression. when PARSE_EXPR => Start_Pos := Pos; loop C := Value (Pos); Last_Pos := Pos; Pos := Pos + 1; if C = '}' then Handler.State := HAS_CONTENT; exit; end if; exit when Pos > Value'Last; end loop; Append (Handler.Expr_Buffer, Value (Start_Pos .. Last_Pos)); if Handler.State /= PARSE_EXPR then Handler.Collect_Expression; end if; -- Collect the raw text in the current content buffer when HAS_CONTENT => if Handler.Text = null then Handler.Text := new Text_Tag_Node; Initialize (Handler.Text.all'Access, null, Handler.Line, Handler.Current.Parent, null); Handler.Text.Last := Handler.Text.Content'Access; elsif Length (Handler.Expr_Buffer) > 0 then Handler.Collect_Expression; Pos := Pos + 1; end if; Content := Handler.Text.Last; -- Scan until we find the start of an EL expression -- or we have a new line. Start_Pos := Pos; loop C := Value (Pos); -- Check for the EL start #{ or ${ if (C = '#' or C = '$') and then Pos + 1 <= Value'Last and then Value (Pos + 1) = '{' then Handler.State := PARSE_EXPR; Append (Handler.Expr_Buffer, C); Append (Handler.Expr_Buffer, '{'); Last_Pos := Pos - 1; Pos := Pos + 2; exit; -- Handle \#{ and \${ as escape sequence elsif C = '\' and then Pos + 2 <= Value'Last and then Value (Pos + 2) = '{' and then (Value (Pos + 1) = '#' or Value (Pos + 1) = '$') then -- Since we have to strip the '\', flush the spaces and append the text -- but ignore the '\'. Append (Content.Text, Handler.Spaces); Handler.Spaces := Null_Unbounded_String; if Start_Pos < Pos then Append (Content.Text, Value (Start_Pos .. Pos - 1)); end if; Start_Pos := Pos + 1; Pos := Pos + 2; elsif (C = ASCII.CR or C = ASCII.LF) and Handler.Ignore_Empty_Lines then Last_Pos := Pos; Handler.State := NO_CONTENT; exit; end if; Last_Pos := Pos; Pos := Pos + 1; exit when Pos > Value'Last; end loop; -- If we have some pending spaces, add them in the text stream. if Length (Handler.Spaces) > 0 then Append (Content.Text, Handler.Spaces); Handler.Spaces := Null_Unbounded_String; end if; -- If we have some text, append to the current content buffer. if Start_Pos <= Last_Pos then Append (Content.Text, Value (Start_Pos .. Last_Pos)); end if; end case; end loop; end Collect_Text; -- ------------------------------ -- Freeze the current Text_Tag node, counting the number of elements it contains. -- ------------------------------ procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class) is begin if Handler.Text /= null then Handler.Text.Freeze; Handler.Text := null; end if; end Finish_Text_Node; -- ------------------------------ -- Start_Element -- ------------------------------ overriding procedure Start_Element (Handler : in out Xhtml_Reader; Namespace_URI : in Unicode.CES.Byte_Sequence := ""; Local_Name : in Unicode.CES.Byte_Sequence := ""; Qname : in Unicode.CES.Byte_Sequence := ""; Atts : in Sax.Attributes.Attributes'Class) is use ASF.Factory; use Ada.Exceptions; Attr_Count : Natural; Attributes : Tag_Attribute_Array_Access; Node : Tag_Node_Access; Factory : ASF.Views.Nodes.Binding_Access; begin Handler.Line.Line := Sax.Locators.Get_Line_Number (Handler.Locator); Handler.Line.Column := Sax.Locators.Get_Column_Number (Handler.Locator); -- Push the current context to keep track where we are. Push (Handler); Attr_Count := Get_Length (Atts); Factory := Handler.Functions.Find (Namespace => Namespace_URI, Name => Local_Name); if Factory /= null then if Length (Handler.Add_NS) > 0 then Attributes := new Tag_Attribute_Array (0 .. Attr_Count); Attributes (0).Name := To_Unbounded_String ("xmlns"); Attributes (0).Value := Handler.Add_NS; Handler.Add_NS := To_Unbounded_String (""); else Attributes := new Tag_Attribute_Array (1 .. Attr_Count); end if; for I in 0 .. Attr_Count - 1 loop declare Attr : constant Tag_Attribute_Access := Attributes (I + 1)'Access; Value : constant String := Get_Value (Atts, I); Name : constant String := Get_Qname (Atts, I); Expr : EL.Expressions.Expression_Access; begin Attr.Name := To_Unbounded_String (Name); if Index (Value, "#{") > 0 or Index (Value, "${") > 0 then begin Expr := new EL.Expressions.Expression; Attr.Binding := Expr.all'Access; EL.Expressions.Expression (Expr.all) := EL.Expressions.Create_Expression (Value, Handler.ELContext.all); exception when E : EL.Functions.No_Function => Log.Error ("{0}: Invalid expression: {1}", To_String (Handler.Locator), Exception_Message (E)); Attr.Binding := null; Attr.Value := To_Unbounded_String (""); when E : EL.Expressions.Invalid_Expression => Log.Error ("{0}: Invalid expression: {1}", To_String (Handler.Locator), Exception_Message (E)); Attr.Binding := null; Attr.Value := To_Unbounded_String (""); end; else Attr.Value := To_Unbounded_String (Value); end if; end; end loop; Node := Factory.Tag (Binding => Factory, Line => Handler.Line, Parent => Handler.Current.Parent, Attributes => Attributes); Handler.Current.Parent := Node; Handler.Current.Text := False; Finish_Text_Node (Handler); Handler.Spaces := Null_Unbounded_String; Handler.State := Handler.Default_State; else declare Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0; begin -- Optimization: we know in which state we are. Handler.State := HAS_CONTENT; Handler.Current.Text := True; if Is_Unknown then Log.Error ("{0}: Element '{1}' not found", To_String (Handler.Locator), Qname); end if; if Handler.Escape_Unknown_Tags and Is_Unknown then Handler.Collect_Text ("&lt;"); else Handler.Collect_Text ("<"); end if; Handler.Collect_Text (Qname); if Length (Handler.Add_NS) > 0 then Handler.Collect_Text (" xmlns="""); Handler.Collect_Text (To_String (Handler.Add_NS)); Handler.Collect_Text (""""); Handler.Add_NS := To_Unbounded_String (""); end if; if Attr_Count /= 0 then for I in 0 .. Attr_Count - 1 loop Handler.Collect_Text (" "); Handler.Collect_Text (Get_Qname (Atts, I)); Handler.Collect_Text ("="""); declare Value : constant String := Get_Value (Atts, I); begin Handler.Collect_Text (Value); end; Handler.Collect_Text (""""); end loop; end if; if Handler.Escape_Unknown_Tags and Is_Unknown then Handler.Collect_Text ("&gt;"); else Handler.Collect_Text (">"); end if; end; end if; end Start_Element; -- ------------------------------ -- End_Element -- ------------------------------ overriding procedure End_Element (Handler : in out Xhtml_Reader; Namespace_URI : in Unicode.CES.Byte_Sequence := ""; Local_Name : in Unicode.CES.Byte_Sequence := ""; Qname : in Unicode.CES.Byte_Sequence := "") is pragma Unreferenced (Local_Name); begin if Handler.Current.Parent = null then Finish_Text_Node (Handler); elsif not Handler.Current.Text then Finish_Text_Node (Handler); Handler.Current.Parent.Freeze; end if; if Handler.Current.Text or Handler.Text /= null then declare Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0; begin -- Optimization: we know in which state we are. Handler.State := HAS_CONTENT; if Handler.Escape_Unknown_Tags and Is_Unknown then Handler.Collect_Text ("&lt;/"); Handler.Collect_Text (Qname); Handler.Collect_Text ("&gt;"); else Handler.Collect_Text ("</"); Handler.Collect_Text (Qname); Handler.Collect_Text (">"); end if; end; else Handler.Spaces := Null_Unbounded_String; end if; -- Pop the current context to restore the last context. Pop (Handler); end End_Element; -- ------------------------------ -- Characters -- ------------------------------ overriding procedure Characters (Handler : in out Xhtml_Reader; Ch : in Unicode.CES.Byte_Sequence) is begin Collect_Text (Handler, Ch); end Characters; -- ------------------------------ -- Ignorable_Whitespace -- ------------------------------ overriding procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader; Ch : in Unicode.CES.Byte_Sequence) is begin if not Handler.Ignore_White_Spaces then Collect_Text (Handler, Ch); end if; end Ignorable_Whitespace; -- ------------------------------ -- Processing_Instruction -- ------------------------------ overriding procedure Processing_Instruction (Handler : in out Xhtml_Reader; Target : in Unicode.CES.Byte_Sequence; Data : in Unicode.CES.Byte_Sequence) is pragma Unreferenced (Handler); begin Log.Error ("Processing instruction: {0}: {1}", Target, Data); null; end Processing_Instruction; -- ------------------------------ -- Skipped_Entity -- ------------------------------ overriding procedure Skipped_Entity (Handler : in out Xhtml_Reader; Name : in Unicode.CES.Byte_Sequence) is pragma Unmodified (Handler); begin null; end Skipped_Entity; -- ------------------------------ -- Start_Cdata -- ------------------------------ overriding procedure Start_Cdata (Handler : in out Xhtml_Reader) is pragma Unreferenced (Handler); begin Log.Info ("Start CDATA"); end Start_Cdata; -- ------------------------------ -- End_Cdata -- ------------------------------ overriding procedure End_Cdata (Handler : in out Xhtml_Reader) is pragma Unreferenced (Handler); begin Log.Info ("End CDATA"); end End_Cdata; -- ------------------------------ -- Resolve_Entity -- ------------------------------ overriding function Resolve_Entity (Handler : Xhtml_Reader; Public_Id : Unicode.CES.Byte_Sequence; System_Id : Unicode.CES.Byte_Sequence) return Input_Sources.Input_Source_Access is pragma Unreferenced (Handler); begin Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id); return null; end Resolve_Entity; overriding procedure Start_DTD (Handler : in out Xhtml_Reader; Name : Unicode.CES.Byte_Sequence; Public_Id : Unicode.CES.Byte_Sequence := ""; System_Id : Unicode.CES.Byte_Sequence := "") is begin if Handler.Text = null then Handler.Text := new Text_Tag_Node; Initialize (Handler.Text.all'Access, null, Handler.Line, Handler.Current.Parent, null); Handler.Text.Last := Handler.Text.Content'Access; end if; declare Content : constant Tag_Content_Access := Handler.Text.Last; begin Append (Content.Text, "<!DOCTYPE "); Append (Content.Text, Name); Append (Content.Text, " "); if Public_Id'Length > 0 then Append (Content.Text, " PUBLIC """); Append (Content.Text, Public_Id); Append (Content.Text, """ "); if System_Id'Length > 0 then Append (Content.Text, '"'); Append (Content.Text, System_Id); Append (Content.Text, '"'); end if; elsif System_Id'Length > 0 then Append (Content.Text, " SYSTEM """); Append (Content.Text, System_Id); Append (Content.Text, """ "); end if; Append (Content.Text, " >" & ASCII.LF); end; end Start_DTD; -- ------------------------------ -- Get the root node that was created upon parsing of the XHTML file. -- ------------------------------ function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access is begin return Reader.Root; end Get_Root; -- ------------------------------ -- Set the XHTML reader to ignore or not the white spaces. -- When set to True, the ignorable white spaces will not be kept. -- ------------------------------ procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader; Value : in Boolean) is begin Reader.Ignore_White_Spaces := Value; end Set_Ignore_White_Spaces; -- ------------------------------ -- Set the XHTML reader to ignore empty lines. -- ------------------------------ procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader; Value : in Boolean) is begin Reader.Ignore_Empty_Lines := Value; end Set_Ignore_Empty_Lines; -- ------------------------------ -- Set the XHTML reader to escape or not the unknown tags. -- When set to True, the tags which are not recognized will be -- emitted as a raw text component and they will be escaped using -- the XML escape rules. -- ------------------------------ procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader; Value : in Boolean) is begin Reader.Escape_Unknown_Tags := Value; end Set_Escape_Unknown_Tags; -- ------------------------------ -- Parse an XML stream, and calls the appropriate SAX callbacks for each -- event. -- This is not re-entrant: you can not call Parse with the same Parser -- argument in one of the SAX callbacks. This has undefined behavior. -- ------------------------------ procedure Parse (Parser : in out Xhtml_Reader; Name : in ASF.Views.File_Info_Access; Input : in out Input_Sources.Input_Source'Class; Factory : access ASF.Factory.Component_Factory; Context : in EL.Contexts.ELContext_Access) is begin Parser.Stack_Pos := 1; Push (Parser); Parser.Line.File := Name; Parser.Root := new Tag_Node; Parser.Functions.Factory := Factory; Parser.Current.Parent := Parser.Root; Parser.ELContext := Parser.Context'Unchecked_Access; Parser.Context.Set_Function_Mapper (Parser.Functions'Unchecked_Access); Parser.Functions.Mapper := Context.Get_Function_Mapper; if Parser.Functions.Mapper = null then Log.Warn ("There is no function mapper"); end if; Sax.Readers.Reader (Parser).Parse (Input); Finish_Text_Node (Parser); Parser.Functions.Factory := null; Parser.ELContext := null; if Parser.Ignore_Empty_Lines then Parser.Default_State := NO_CONTENT; else Parser.Default_State := HAS_CONTENT; end if; Parser.State := Parser.Default_State; Free (Parser.Stack); exception when others => Free (Parser.Stack); raise; end Parse; end ASF.Views.Nodes.Reader;
with Ada.Text_IO, Spec; use Ada.Text_IO, Spec; package Both with Ada_2012 is --@description Just a simple test package --@version 1.0 type TestInt is range 0 .. 1; type TestMod is mod 8; type TestFloat is digits 8; type TestFloatRange is digits 8 range 0.0 .. 12.0; type TestFixed is delta 0.01 range 0.0 .. 8.0; type TestDecimal is delta 0.1 digits 8; type TestDecimalRange is delta 0.1 digits 8 range 0.0 .. 10.0; end Both;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . M E M O R Y -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-2021, 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. -- -- -- -- -- -- -- -- -- -- -- -- 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 is a simplified version of this package, for use with a configurable -- run-time library that does not provide Ada tasking. It does not provide -- any deallocation routine. -- This package provides the low level memory allocation/deallocation -- mechanisms used by GNAT. package System.Memory is pragma Elaborate_Body; type size_t is mod 2 ** Standard'Address_Size; -- Note: the reason we redefine this here instead of using the -- definition in Interfaces.C is that we do not want to drag in -- all of Interfaces.C just because System.Memory is used. function Alloc (Size : size_t) return System.Address; -- This is the low level allocation routine. Given a size in storage -- units, it returns the address of a maximally aligned block of -- memory. -- -- A first check is performed to discard memory allocations that are -- obviously too big, preventing problems of memory wraparound. If Size is -- greater than the maximum number of storage elements (taking into account -- the maximum alignment) in the machine, then a Storage_Error exception is -- raised before trying to perform the memory allocation. -- -- If Size is set to zero on entry, then a minimal (but non-zero) -- size block is allocated. -- -- If there is not enough free memory on the heap for the requested -- allocation then a Storage_Error exception is raised and the heap remains -- unchanged. -- -- Note: this is roughly equivalent to the standard C malloc call -- with the additional semantics as described above. private -- The following names are used from the generated compiler code pragma Export (C, Alloc, "__gnat_malloc"); end System.Memory;
package body logger is procedure debug(output : string) is begin -- affichage sur console if show_debug then put_line(output); end if; -- écriture fichier if is_open(log_file) then put_line(log_file, output); end if; end; procedure initialize(console : boolean; file : string) is begin show_debug := console; if file'length /= 0 then begin -- Ouverture du fichier open(log_file, append_file, file); exception -- si le fichier n'existe pas when name_error => -- creation du fichier create(log_file, out_file, file); end; end if; end; procedure close is begin -- si le fichier est ouvert on ferme if is_open(log_file) then close(log_file); end if; end; end logger;
with STM32_SVD; use STM32_SVD; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.PWR; use STM32_SVD.PWR; package body STM32GD.Clock.Tree is function Frequency (Clock : Clock_Type) return Integer is begin case Clock is when STM32GD.Clock.RTCCLK => return RTCCLK; when STM32GD.Clock.SYSCLK => return SYSCLK; when STM32GD.Clock.PCLK => return PCLK; when STM32GD.Clock.HSI => return HSI_Value; when STM32GD.Clock.LSI => return LSI_Value; when STM32GD.Clock.LSE => return LSE_Value; when STM32GD.Clock.PLLCLK => return PLL_Output_Value; when STM32GD.Clock.HCLK => return HCLK; end case; end Frequency; procedure Init is begin if LSI_Enabled then RCC_Periph.CSR.LSION := 1; while RCC_Periph.CSR.LSIRDY = 0 loop null; end loop; end if; if LSE_Enabled then RCC_Periph.APB1ENR.PWREN := 1; PWR_Periph.CR.DBP := 1; RCC_Periph.BDCR.LSEON := 1; while RCC_Periph.BDCR.LSERDY = 0 loop null; end loop; end if; end Init; end STM32GD.Clock.Tree;
with Ada.Numerics; with Gtk.Widget; use Gtk.Widget; with PortAudioAda; use PortAudioAda; package GA_Waves_Globals is Frames_Per_Buffer : Long_Float := 64.0; Sample_Rate : Long_Float := 44_100.0; stream : aliased PA_Stream_Ptr; Two_Pi : Long_Float := Ada.Numerics.Pi * 2.0; type Float_Array is array (Integer range <>) of aliased Float; pragma Convention (C, Float_Array); type User_Data is record amplitude : aliased Long_Float := 0.5; frequency : aliased Long_Float := 440.0; phase : aliased Long_Float := 0.0; end record; pragma Convention (C, User_Data); type User_Data_Ptr is access all User_Data; pragma Convention (C, User_Data_Ptr); pragma No_Strict_Aliasing (User_Data_Ptr); gUserData : aliased User_Data; type Option_Use is (OU_Before, OU_After, OU_NoMatter); type One_Option is record optionWidget : access Gtk_Widget_Record'Class; optionUse : Option_Use; end record; type Enum_Options is (EO_Start, EO_Frames_Per_Buffer, EO_Sample_Rate, EO_Wave_Type, EO_Amplitude, EO_Frequency); options : array (Enum_Options) of One_Option; type Samples is record numRate : Long_Float; txtRate : String (1 .. 6); end record; sample_Rates : array (Natural range <>) of Samples := ((8000.0, " 8000"), (9600.0, " 9600"), (1025.0, " 11025"), (12000.0, " 12000"), (16000.0, " 16000"), (22050.0, " 22050"), (24000.0, " 24000"), (32000.0, " 32000"), (44100.0, " 44100"), (48000.0, " 48000"), (88200.0, " 88200"), (96000.0, " 96000"), (192000.0, "192000")); type Wave_Types is (Sine, Square, Sawtooth, Triangle, WhiteNoise, PinkNoise, BrownNoise); wave_Type : Wave_Types := Sine; ----------------------------------------------------------------------------- procedure Toggle_Options (started : Boolean); end GA_Waves_Globals;
-- 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 GL.Low_Level; with Orka.Containers.Bounded_Vectors; with Orka.Resources; package Orka.glTF.Buffers is pragma Preelaborate; use Orka.Resources; type Buffer_Kind is (Array_Buffer, Element_Array_Buffer); for Buffer_Kind use (Array_Buffer => 16#8892#, Element_Array_Buffer => 16#8893#); for Buffer_Kind'Size use GL.Low_Level.Enum'Size; Target_Kinds : constant array (Integer range <>) of Buffer_Kind := (34962 => Array_Buffer, 34963 => Element_Array_Buffer); subtype Buffer is Byte_Array_Pointers.Pointer; package Buffer_Vectors is new Orka.Containers.Bounded_Vectors (Natural, Buffer); function Get_Buffers (Buffers : Types.JSON_Value; Load_Path : not null access function (Path : String) return Byte_Array_Pointers.Pointer) return Buffer_Vectors.Vector; subtype Stride_Natural is Natural range 4 .. 252; type Buffer_View (Packed : Boolean := True) is record Buffer : Natural; Offset : Natural; -- Offset in bytes Length : Positive; -- Length in bytes Target : Buffer_Kind; case Packed is when False => Stride : Stride_Natural; when others => null; end case; end record; package Buffer_View_Vectors is new Orka.Containers.Bounded_Vectors (Natural, Buffer_View); generic type Element_Type is private; type Element_Array is array (GL.Types.Size range <>) of aliased Element_Type; procedure Extract_From_Buffer (Buffers : Buffer_Vectors.Vector; View : Buffer_View; Data : out Element_Array); function Get_Buffer_Views (Buffers : Buffer_Vectors.Vector; Views : Types.JSON_Value) return Buffer_View_Vectors.Vector; end Orka.glTF.Buffers;
with STM32GD.SPI; with STM32GD.SPI.Peripheral; with STM32GD.GPIO; with STM32GD.GPIO.Pin; with STM32GD.Board; use STM32GD.Board; with STM32_SVD.RCC; use STM32_SVD.RCC; procedure Main is package SPI is new STM32GD.SPI.Peripheral (SPI => STM32GD.SPI.SPI_1); Data : STM32GD.SPI.SPI_Data_8b := (0, 1, 2, 3, 4, 5, 6, 7); begin Init; RCC_Periph.APB2ENR.SPI1EN := 1; SCLK.Init; MOSI.Init; MISO.Init; CSN.Init; SPI.Init; loop CSN.Clear; SPI.Send (Data); CSN.Set; end loop; end Main;
-- SPDX-FileCopyrightText: 2019-2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Strings.Wide_Wide_Unbounded; with Program.Element_Vector_Factories; with Program.Element_Vectors; with Program.Elements.Aspect_Specifications; with Program.Elements.Case_Paths; with Program.Elements.Component_Definitions; with Program.Elements.Constraints; with Program.Elements.Defining_Identifiers; with Program.Elements.Defining_Names; with Program.Elements.Definitions; with Program.Elements.Discrete_Ranges; with Program.Elements.Discriminant_Specifications; with Program.Elements.Enumeration_Literal_Specifications; with Program.Elements.Exception_Handlers; with Program.Elements.Expressions; with Program.Elements.Identifiers; with Program.Elements.Operator_Symbols; with Program.Elements.Package_Declarations; with Program.Elements.Parameter_Associations; with Program.Elements.Parameter_Specifications; with Program.Elements.Procedure_Body_Declarations; with Program.Elements.Real_Range_Specifications; with Program.Elements.Record_Component_Associations; with Program.Elements.Subtype_Indications; with Program.Elements.Variants; with Program.Nodes.Proxy_Associations; with Program.Nodes.Proxy_Calls; with Program.Safe_Element_Visitors; with Program.Storage_Pools; with Program.Units.Bodies; with Program.Units.Declarations; with Program.Plain_Lexical_Elements; with Program.Symbols; package body Program.Parsers.Nodes is type Unit_Declaration_Access is access all Program.Units.Declarations.Unit_Declaration with Storage_Pool => Program.Storage_Pools.Pool; type Unit_Body_Access is access all Program.Units.Bodies.Unit_Body with Storage_Pool => Program.Storage_Pools.Pool; generic type Vector_Access is private; with function Create_Vector (Self : Program.Element_Vector_Factories.Element_Vector_Factory; Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class) return Vector_Access; function Generic_Vector_Cast (Value : access constant Element_Vectors.Vector; Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle) return Vector_Access; type Forward_Iterator; function Iter (V : access constant Element_Vectors.Vector) return Forward_Iterator; type Forward_Iterator is new Program.Element_Vectors.Iterators.Forward_Iterator with record Vector : access constant Element_Vectors.Vector; end record; overriding function First (Self : Forward_Iterator) return Program.Element_Vectors.Element_Cursor; overriding function Next (Self : Forward_Iterator; Position : Program.Element_Vectors.Element_Cursor) return Program.Element_Vectors.Element_Cursor; function New_Element_Sequence (Self : Node_Factory'Class) return Node; procedure Prepend (Self : Node_Factory'Class; List : in out Node; Item : Node); procedure Append (Self : Node_Factory'Class; List : in out Node; Item : Node); -- procedure Destroy (Value : Node) is null; -- This is called for a temporary node used during AST construction. ----------- -- First -- ----------- overriding function First (Self : Forward_Iterator) return Program.Element_Vectors.Element_Cursor is begin return (Element => (if Self.Vector.Is_Empty then null else Self.Vector.Element (1)), Delimiter => null, Index => 1, Is_Last => Self.Vector.Last_Index = 1); end First; ---------- -- Next -- ---------- overriding function Next (Self : Forward_Iterator; Position : Program.Element_Vectors.Element_Cursor) return Program.Element_Vectors.Element_Cursor is Index : constant Positive := Position.Index + 1; begin if Self.Vector.Last_Index < Index then return (null, null, Index, False); else return (Element => Self.Vector.Element (Index), Delimiter => null, Index => Index, Is_Last => Self.Vector.Last_Index = Index); end if; end Next; ---------- -- Iter -- ---------- function Iter (V : access constant Element_Vectors.Vector) return Forward_Iterator is begin return (Vector => V); end Iter; ------------------------- -- Generic_Vector_Cast -- ------------------------- function Generic_Vector_Cast (Value : access constant Element_Vectors.Vector; Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle) return Vector_Access is Fact : Program.Element_Vector_Factories.Element_Vector_Factory (Subpool); begin return Create_Vector (Fact, Iter (Value)); end Generic_Vector_Cast; function To_Aspect_Specification_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements .Aspect_Specifications.Aspect_Specification_Vector_Access, Create_Vector => Program.Element_Vector_Factories.Create_Aspect_Specification_Vector); function To_Case_Path_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Case_Paths.Case_Path_Vector_Access, Create_Vector => Program.Element_Vector_Factories .Create_Case_Path_Vector); function To_Defining_Identifier_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements .Defining_Identifiers.Defining_Identifier_Vector_Access, Create_Vector => Program.Element_Vector_Factories.Create_Defining_Identifier_Vector); function To_Discrete_Range_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access, Create_Vector => Program.Element_Vector_Factories .Create_Discrete_Range_Vector); function To_Discriminant_Specification_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Discriminant_Specifications .Discriminant_Specification_Vector_Access, Create_Vector => Program.Element_Vector_Factories .Create_Discriminant_Specification_Vector); function To_Enumeration_Literal_Specification_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements .Enumeration_Literal_Specifications .Enumeration_Literal_Specification_Vector_Access, Create_Vector => Program.Element_Vector_Factories .Create_Enumeration_Literal_Specification_Vector); function To_Exception_Handler_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Exception_Handlers. Exception_Handler_Vector_Access, Create_Vector => Program.Element_Vector_Factories. Create_Exception_Handler_Vector); function To_Expression_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Expressions.Expression_Vector_Access, Create_Vector => Program.Element_Vector_Factories.Create_Expression_Vector); function To_Parameter_Specification_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Parameter_Specifications. Parameter_Specification_Vector_Access, Create_Vector => Program.Element_Vector_Factories. Create_Parameter_Specification_Vector); function To_Record_Component_Association_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Record_Component_Associations. Record_Component_Association_Vector_Access, Create_Vector => Program.Element_Vector_Factories. Create_Record_Component_Association_Vector); pragma Unreferenced (To_Record_Component_Association_Vector); function To_Variant_Vector is new Generic_Vector_Cast (Vector_Access => Program.Elements.Variants. Variant_Vector_Access, Create_Vector => Program.Element_Vector_Factories. Create_Variant_Vector); function To_Element_Vector is new Generic_Vector_Cast (Vector_Access => Program.Element_Vectors.Element_Vector_Access, Create_Vector => Program.Element_Vector_Factories.Create_Element_Vector); pragma Warnings (Off); --------------------- -- Abort_Statement -- --------------------- function Abort_Statement (Self : Node_Factory'Class; Abort_Token : Node; Aborted_Tasks : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Abort_Statement unimplemented"); return raise Program_Error with "Unimplemented function Abort_Statement"; end Abort_Statement; ---------------------- -- Accept_Statement -- ---------------------- function Accept_Statement (Self : Node_Factory'Class; Accept_Token : Node; Accept_Entry_Direct_Name : Node; Left_Parenthesis_Token : Node; Accept_Entry_Index : Node; Right_Parenthesis_Token : Node; Lp_Token : Node; Accept_Parameters : Node; Rp_Token : Node; Do_Token : Node; Accept_Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Accept_Statement unimplemented"); return raise Program_Error with "Unimplemented function Accept_Statement"; end Accept_Statement; ----------------------------------- -- Access_To_Function_Definition -- ----------------------------------- function Access_To_Function_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Function_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Access_To_Function_Result_Subtype : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Access_To_Function_Definition unimplemented"); return raise Program_Error with "Unimplemented function Access_To_Function_Definition"; end Access_To_Function_Definition; --------------------------------- -- Access_To_Object_Definition -- --------------------------------- function Access_To_Object_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Constant_Token : Node; Subtype_Indication : Node) return Node is use all type Program.Lexical_Elements.Lexical_Element_Kind; All_Token : Program.Lexical_Elements.Lexical_Element_Access; Const_Token : Program.Lexical_Elements.Lexical_Element_Access; begin if Constant_Token.Token.Assigned and then Constant_Token.Token.Kind = All_Keyword then All_Token := Constant_Token.Token; else Const_Token := Constant_Token.Token; end if; return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Object_Access_Type (Not_Token => Not_Token.Token, Null_Token => Null_Token.Token, Access_Token => Access_Token.Token, All_Token => All_Token, Constant_Token => Const_Token, Subtype_Indication => Subtype_Indication.Element .To_Subtype_Indication))); end Access_To_Object_Definition; ------------------------------------ -- Access_To_Procedure_Definition -- ------------------------------------ function Access_To_Procedure_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Procedure_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Access_To_Procedure_Definition unimplemented"); return raise Program_Error with "Unimplemented function Access_To_Procedure_Definition"; end Access_To_Procedure_Definition; --------------- -- Allocator -- --------------- function Allocator (Self : Node_Factory'Class; New_Token : Node; Left_Parenthesis_Token : Node; Subpool_Name : Node; Right_Parenthesis_Token : Node; Subtype_Or_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Allocator unimplemented"); return raise Program_Error with "Unimplemented function Allocator"; end Allocator; --------------------------------------------- -- Anonymous_Access_To_Function_Definition -- --------------------------------------------- function Anonymous_Access_To_Function_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Function_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Access_To_Function_Result_Subtype : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Anonymous_Access_To_Function_Definition unimplemented"); return raise Program_Error with "Unimplemented function Anonymous_Access_To_Function_Definition"; end Anonymous_Access_To_Function_Definition; ------------------------------------------- -- Anonymous_Access_To_Object_Definition -- ------------------------------------------- function Anonymous_Access_To_Object_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Constant_Token : Node; Anonymous_Access_To_Object_Subtype_Mark : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Anonymous_Access_To_Object_Definition unimplemented"); return raise Program_Error with "Unimplemented function Anonymous_Access_To_Object_Definition"; end Anonymous_Access_To_Object_Definition; ---------------------------------------------- -- Anonymous_Access_To_Procedure_Definition -- ---------------------------------------------- function Anonymous_Access_To_Procedure_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Procedure_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Anonymous_Access_To_Procedure_Definition unimplemented"); return raise Program_Error with "Unimplemented function Anonymous_Access_To_Procedure_Definition"; end Anonymous_Access_To_Procedure_Definition; procedure Append (Self : Node_Factory'Class; List : in out Node; Item : Node) is begin List.Vector.Append (Item.Element); end Append; --------------------------------- -- Append_Aspect_Specification -- --------------------------------- procedure Append_Aspect_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------ -- Append_Association -- ------------------------ procedure Append_Association (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------------------------- -- Append_Basic_Declarative_Item -- ----------------------------------- procedure Append_Basic_Declarative_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; --------------------------------- -- Append_Case_Expression_Path -- --------------------------------- procedure Append_Case_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ---------------------- -- Append_Case_Path -- ---------------------- procedure Append_Case_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------------------- -- Append_Clause_Or_Pragma -- ----------------------------- procedure Append_Clause_Or_Pragma (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------------------- -- Append_Compilation_Unit -- ----------------------------- procedure Append_Compilation_Unit (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; --------------------------- -- Append_Component_Item -- --------------------------- procedure Append_Component_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------- -- Append_Context_Item -- ------------------------- procedure Append_Context_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------------------- -- Append_Declarative_Item -- ----------------------------- procedure Append_Declarative_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; -------------------------------- -- Append_Defining_Identifier -- -------------------------------- procedure Append_Defining_Identifier (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ---------------------------- -- Append_Discrete_Choice -- ---------------------------- procedure Append_Discrete_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ---------------------------------------- -- Append_Discrete_Subtype_Definition -- ---------------------------------------- procedure Append_Discrete_Subtype_Definition (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; --------------------------------------- -- Append_Discriminant_Specification -- --------------------------------------- procedure Append_Discriminant_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ---------------------------------------------- -- Append_Enumeration_Literal_Specification -- ---------------------------------------------- procedure Append_Enumeration_Literal_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------------------- -- Append_Exception_Choice -- ----------------------------- procedure Append_Exception_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------ -- Append_Exception_Handler -- ------------------------------ procedure Append_Exception_Handler (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; -------------------------------- -- Append_Generic_Association -- -------------------------------- procedure Append_Generic_Association (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; --------------------------- -- Append_Generic_Formal -- --------------------------- procedure Append_Generic_Formal (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------------ -- Append_If_Else_Expression_Path -- ------------------------------------ procedure Append_If_Else_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------- -- Append_If_Elsif_Else_Path -- ------------------------------- procedure Append_If_Elsif_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------ -- Append_Membership_Choice -- ------------------------------ procedure Append_Membership_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------- -- Append_Name -- ----------------- procedure Append_Name (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------------ -- Append_Parameter_Specification -- ------------------------------------ procedure Append_Parameter_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ---------------------------------------- -- Append_Pragma_Argument_Association -- ---------------------------------------- procedure Append_Pragma_Argument_Association (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------ -- Append_Program_Unit_Name -- ------------------------------ procedure Append_Program_Unit_Name (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------------------ -- Append_Protected_Element_Declaration -- ------------------------------------------ procedure Append_Protected_Element_Declaration (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; -------------------------------------------- -- Append_Protected_Operation_Declaration -- -------------------------------------------- procedure Append_Protected_Operation_Declaration (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------------------- -- Append_Protected_Operation_Item -- ------------------------------------- procedure Append_Protected_Operation_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; -------------------------------- -- Append_Select_Or_Else_Path -- -------------------------------- procedure Append_Select_Or_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ----------------------------------- -- Append_Select_Then_Abort_Path -- ----------------------------------- procedure Append_Select_Then_Abort_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ---------------------- -- Append_Statement -- ---------------------- procedure Append_Statement (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; ------------------------- -- Append_Subtype_Mark -- ------------------------- procedure Append_Subtype_Mark (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; -------------------- -- Append_Variant -- -------------------- procedure Append_Variant (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Append; -------------------------- -- Aspect_Specification -- -------------------------- function Aspect_Specification (Self : Node_Factory'Class; Aspect_Mark : Node; Arrow_Token : Node; Aspect_Definition : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Aspect_Specification unimplemented"); return raise Program_Error with "Unimplemented function Aspect_Specification"; end Aspect_Specification; ----------------------------------- -- Aspect_Specification_Sequence -- ----------------------------------- function Aspect_Specification_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------------- -- Assignment_Statement -- -------------------------- function Assignment_Statement (Self : Node_Factory'Class; Assignment_Variable_Name : Node; Assignment_Token : Node; Assignment_Expression : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Assignment_Statement (Variable_Name => Program.Elements.Expressions .Expression_Access (Assignment_Variable_Name.Element), Assignment_Token => Assignment_Token.Token, Expression => Program.Elements.Expressions .Expression_Access (Assignment_Expression.Element), Semicolon_Token => Semicolon_Token.Token))); end Assignment_Statement; ----------------- -- Association -- ----------------- function Association (Self : Node_Factory'Class; Array_Component_Choices : Node; Arrow_Token : Node; Component_Expression : Node; Box_Token : Node) return Node is Result : constant Program.Nodes.Proxy_Associations.Proxy_Association_Access := new (Self.Subpool) Program.Nodes.Proxy_Associations.Proxy_Association' (Program.Nodes.Proxy_Associations.Create (Choices => To_Element_Vector (Array_Component_Choices.Vector'Unchecked_Access, Self.Subpool), Arrow_Token => Arrow_Token.Token, Expression => Component_Expression.Element.To_Expression, Box_Token => Box_Token.Token)); begin return (Element_Node, Program.Elements.Element_Access (Result)); end Association; ---------------------- -- Association_List -- ---------------------- function Association_List (Self : Node_Factory'Class; Left_Token : Node; Record_Component_Associations : Node; Right_Token : Node) return Node is Result : constant Program.Nodes.Proxy_Calls.Proxy_Call_Access := new (Self.Subpool) Program.Nodes.Proxy_Calls.Proxy_Call' (Program.Nodes.Proxy_Calls.Create (Called_Name => null, Left_Bracket_Token => Left_Token.Token, Parameters => To_Element_Vector (Record_Component_Associations.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Right_Token.Token)); begin return (Element_Node, Program.Elements.Element_Access (Result)); end Association_List; -------------------------- -- Association_Sequence -- -------------------------- function Association_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------- -- Asynchronous_Select -- ------------------------- function Asynchronous_Select (Self : Node_Factory'Class; Select_Token : Node; Asynchronous_Statement_Paths : Node; End_Token : Node; End_Select : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Asynchronous_Select unimplemented"); return raise Program_Error with "Unimplemented function Asynchronous_Select"; end Asynchronous_Select; --------------- -- At_Clause -- --------------- function At_Clause (Self : Node_Factory'Class; For_Token : Node; Representation_Clause_Name : Node; Use_Token : Node; At_Token : Node; Representation_Clause_Expression : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "At_Clause unimplemented"); return raise Program_Error with "Unimplemented function At_Clause"; end At_Clause; --------------------------------- -- Attribute_Definition_Clause -- --------------------------------- function Attribute_Definition_Clause (Self : Node_Factory'Class; For_Token : Node; Representation_Clause_Name : Node; Use_Token : Node; Representation_Clause_Expression : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Attribute_Definition_Clause unimplemented"); return raise Program_Error with "Unimplemented function Attribute_Definition_Clause"; end Attribute_Definition_Clause; ------------------------- -- Attribute_Reference -- ------------------------- function Attribute_Reference (Self : Node_Factory'Class; Prefix : Node; Apostrophe_Token : Node; Attribute_Designator_Identifier : Node; Attribute_Designator_Expressions : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Attribute_Reference (Prefix => Program.Elements.Expressions.Expression_Access (Prefix.Element), Apostrophe_Token => Apostrophe_Token.Token, Attribute_Designator => Program.Elements.Identifiers.Identifier_Access (Attribute_Designator_Identifier.Element), Left_Bracket_Token => null, -- ??? Expressions => null, -- ??? Right_Bracket_Token => null))); -- ??? end Attribute_Reference; ------------------------------------- -- Basic_Declarative_Item_Sequence -- ------------------------------------- function Basic_Declarative_Item_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------- -- Block_Statement -- --------------------- function Block_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; Declare_Token : Node; Block_Declarative_Items : Node; Begin_Token : Node; Block_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Assert (not Identifier_Token.Token.Assigned); return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Block_Statement (Statement_Identifier => Statement_Identifier.Element .To_Defining_Identifier, Colon_Token => Colon_Token.Token, Declare_Token => Declare_Token.Token, Declarations => To_Element_Vector (Block_Declarative_Items.Vector'Unchecked_Access, Self.Subpool), Begin_Token => Begin_Token.Token, Statements => To_Element_Vector (Block_Statements.Vector'Unchecked_Access, Self.Subpool), Exception_Token => Exception_Token.Token, Exception_Handlers => To_Exception_Handler_Vector (Exception_Handlers.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, End_Statement_Identifier => null, Semicolon_Token => Semicolon_Token.Token))); end Block_Statement; --------------------- -- Case_Expression -- --------------------- function Case_Expression (Self : Node_Factory'Class; Case_Token : Node; Expression : Node; Is_Token : Node; Case_Expression_Paths : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Case_Expression unimplemented"); return raise Program_Error with "Unimplemented function Case_Expression"; end Case_Expression; -------------------------- -- Case_Expression_Path -- -------------------------- function Case_Expression_Path (Self : Node_Factory'Class; When_Token : Node; Case_Path_Alternative_Choices : Node; Arrow_Token : Node; Dependent_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Case_Expression_Path unimplemented"); return raise Program_Error with "Unimplemented function Case_Expression_Path"; end Case_Expression_Path; ----------------------------------- -- Case_Expression_Path_Sequence -- ----------------------------------- function Case_Expression_Path_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------- -- Case_Path -- --------------- function Case_Path (Self : Node_Factory'Class; When_Token : Node; Variant_Choices : Node; Arrow_Token : Node; Sequence_Of_Statements : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Case_Path (When_Token => When_Token.Token, Choices => To_Element_Vector (Variant_Choices.Vector'Unchecked_Access, Self.Subpool), Arrow_Token => Arrow_Token.Token, Statements => To_Element_Vector (Sequence_Of_Statements.Vector'Unchecked_Access, Self.Subpool)))); end Case_Path; ------------------------ -- Case_Path_Sequence -- ------------------------ function Case_Path_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------- -- Case_Statement -- -------------------- function Case_Statement (Self : Node_Factory'Class; Case_Token : Node; Case_Expression : Node; Is_Token : Node; Case_Statement_Paths : Node; End_Token : Node; Endcase : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Case_Statement (Case_Token => Case_Token.Token, Selecting_Expression => Case_Expression.Element.To_Expression, Is_Token => Is_Token.Token, Paths => To_Case_Path_Vector (Case_Statement_Paths.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, Case_Token_2 => Endcase.Token, Semicolon_Token => Semicolon_Token.Token))); end Case_Statement; ----------------------- -- Character_Literal -- ----------------------- function Character_Literal (Self : Node_Factory'Class; Character_Literal_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Character_Literal unimplemented"); return raise Program_Error with "Unimplemented function Character_Literal"; end Character_Literal; ------------------------------------ -- Choice_Parameter_Specification -- ------------------------------------ function Choice_Parameter_Specification (Self : Node_Factory'Class; Names : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Choice_Parameter_Specification unimplemented"); return raise Program_Error with "Unimplemented function Choice_Parameter_Specification"; end Choice_Parameter_Specification; ------------------------------- -- Clause_Or_Pragma_Sequence -- ------------------------------- function Clause_Or_Pragma_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ----------------- -- Compilation -- ----------------- function Compilation (Self : Node_Factory'Class; Units : Node; Compilation_Pragmas : Node) return Node is begin return (Compilation_Node, Units.Units, Compilation_Pragmas.Vector); end Compilation; --------------------------- -- Compilation_Unit_Body -- --------------------------- function Compilation_Unit_Body (Self : Node_Factory'Class; Context_Clause_Elements : Node; Unit_Declaration : Node) return Node is Result : Unit_Body_Access := new (Self.Subpool) Program.Units.Bodies.Unit_Body; Clause : Program.Element_Vectors.Element_Vector_Access := To_Element_Vector (Context_Clause_Elements.Vector'Unchecked_Access, Self.Subpool); begin Result.Initialize (Compilation => Self.Comp, Full_Name => Self.Get_Unit_Name (Unit_Declaration), Context_Clause => Clause, Unit_Declaration => Unit_Declaration.Element, Parent => null, Declaration => null); return (Unit_Node, Program.Compilation_Units.Compilation_Unit_Access (Result)); end Compilation_Unit_Body; ---------------------------------- -- Compilation_Unit_Declaration -- ---------------------------------- function Compilation_Unit_Declaration (Self : Node_Factory'Class; Context_Clause_Elements : Node; Private_Token : Node; Unit_Declaration : Node) return Node is Result : Unit_Declaration_Access := new (Self.Subpool) Program.Units.Declarations.Unit_Declaration; Clause : Program.Element_Vectors.Element_Vector_Access := To_Element_Vector (Context_Clause_Elements.Vector'Unchecked_Access, Self.Subpool); begin Result.Initialize (Compilation => Self.Comp, Full_Name => Self.Get_Unit_Name (Unit_Declaration), Context_Clause => Clause, Declaration => Unit_Declaration.Element, Parent => null); return (Unit_Node, Program.Compilation_Units.Compilation_Unit_Access (Result)); end Compilation_Unit_Declaration; ------------------------------- -- Compilation_Unit_Sequence -- ------------------------------- function Compilation_Unit_Sequence (Self : Node_Factory'Class) return Node is begin return (Unit_Sequence_Node, Unit_Vectors.Empty_Vector); end Compilation_Unit_Sequence; ---------------------- -- Component_Clause -- ---------------------- function Component_Clause (Self : Node_Factory'Class; Representation_Clause_Name : Node; At_Token : Node; Component_Clause_Position : Node; Range_Token : Node; Component_Clause_Range : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Component_Clause unimplemented"); return raise Program_Error with "Unimplemented function Component_Clause"; end Component_Clause; --------------------------- -- Component_Declaration -- --------------------------- function Component_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Component_Declaration (Names => To_Defining_Identifier_Vector (Names.Vector'Unchecked_Access, Self.Subpool), Colon_Token => Colon_Token.Token, Object_Subtype => Object_Declaration_Subtype.Element. To_Component_Definition, Assignment_Token => Assignment_Token.Token, Default_Expression => Initialization_Expression.Element. To_Expression, With_Token => null, Aspects => null, Semicolon_Token => Semicolon_Token.Token))); end Component_Declaration; -------------------------- -- Component_Definition -- -------------------------- function Component_Definition (Self : Node_Factory'Class; Aliased_Token : Node; Subtype_Indication : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Component_Definition (Aliased_Token => Aliased_Token.Token, Subtype_Indication => Subtype_Indication.Element))); end Component_Definition; ----------------------------- -- Component_Item_Sequence -- ----------------------------- function Component_Item_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ---------------------------------- -- Constrained_Array_Definition -- ---------------------------------- function Constrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Discrete_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Constrained_Array_Type (Array_Token => Array_Token.Token, Left_Bracket_Token => Left_Token.Token, Index_Subtypes => To_Discrete_Range_Vector (Discrete_Subtype_Definitions.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Right_Token.Token, Of_Token => Of_Token.Token, Component_Definition => Array_Component_Definition.Element .To_Component_Definition))); end Constrained_Array_Definition; --------------------------- -- Context_Item_Sequence -- --------------------------- function Context_Item_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------------------ -- Decimal_Fixed_Point_Definition -- ------------------------------------ function Decimal_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Delta_Expression : Node; Digits_Token : Node; Digits_Expression : Node; Real_Range_Constraint : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Decimal_Fixed_Point_Definition unimplemented"); return raise Program_Error with "Unimplemented function Decimal_Fixed_Point_Definition"; end Decimal_Fixed_Point_Definition; ------------------------------- -- Declarative_Item_Sequence -- ------------------------------- function Declarative_Item_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------------------- -- Defining_Character_Literal -- -------------------------------- function Defining_Character_Literal (Self : Node_Factory'Class; Character_Literal : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Defining_Character_Literal (Character_Literal.Token))); end Defining_Character_Literal; ---------------------------------- -- Defining_Enumeration_Literal -- ---------------------------------- function Defining_Enumeration_Literal (Self : Node_Factory'Class; Identifier : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Defining_Identifier (Identifier.Token))); end Defining_Enumeration_Literal; ------------------------- -- Defining_Identifier -- ------------------------- function Defining_Identifier (Self : Node_Factory'Class; Identifier_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Defining_Identifier (Identifier_Token.Token))); end Defining_Identifier; ---------------------------------- -- Defining_Identifier_Sequence -- ---------------------------------- function Defining_Identifier_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------------ -- Defining_Operator_Symbol -- ------------------------------ function Defining_Operator_Symbol (Self : Node_Factory'Class; Operator_Symbol_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Defining_Operator_Symbol unimplemented"); return raise Program_Error with "Unimplemented function Defining_Operator_Symbol"; end Defining_Operator_Symbol; --------------------- -- Delay_Statement -- --------------------- function Delay_Statement (Self : Node_Factory'Class; Delay_Token : Node; Until_Token : Node; Delay_Expression : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Delay_Statement unimplemented"); return raise Program_Error with "Unimplemented function Delay_Statement"; end Delay_Statement; ---------------------- -- Delta_Constraint -- ---------------------- function Delta_Constraint (Self : Node_Factory'Class; Delta_Token : Node; Delta_Expression : Node; Real_Range_Constraint : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Delta_Constraint unimplemented"); return raise Program_Error with "Unimplemented function Delta_Constraint"; end Delta_Constraint; ------------------------------- -- Derived_Record_Definition -- ------------------------------- function Derived_Record_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; New_Token : Node; Parent_Subtype_Indication : Node; Progenitor_List : Node; With_Token : Node; Record_Definition : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Derived_Record_Definition unimplemented"); return raise Program_Error with "Unimplemented function Derived_Record_Definition"; end Derived_Record_Definition; ----------------------------- -- Derived_Type_Definition -- ----------------------------- function Derived_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; New_Token : Node; Parent_Subtype_Indication : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Derived_Type (Abstract_Token => Abstract_Token.Token, Limited_Token => Limited_Token.Token, New_Token => New_Token.Token, Parent => Parent_Subtype_Indication.Element .To_Subtype_Indication))); end Derived_Type_Definition; ----------------------- -- Digits_Constraint -- ----------------------- function Digits_Constraint (Self : Node_Factory'Class; Digits_Token : Node; Digits_Expression : Node; Real_Range_Constraint : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Digits_Constraint unimplemented"); return raise Program_Error with "Unimplemented function Digits_Constraint"; end Digits_Constraint; ------------------------------ -- Discrete_Choice_Sequence -- ------------------------------ function Discrete_Choice_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ---------------------------------------- -- Discrete_Range_Attribute_Reference -- ---------------------------------------- function Discrete_Range_Attribute_Reference (Self : Node_Factory'Class; Range_Attribute : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Discrete_Range_Attribute_Reference unimplemented"); return raise Program_Error with "Unimplemented function Discrete_Range_Attribute_Reference"; end Discrete_Range_Attribute_Reference; -------------------------------------- -- Discrete_Simple_Expression_Range -- -------------------------------------- function Discrete_Simple_Expression_Range (Self : Node_Factory'Class; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Discrete_Simple_Expression_Range (Lower_Bound => Lower_Bound.Element.To_Expression, Double_Dot_Token => Double_Dot_Token.Token, Upper_Bound => Upper_Bound.Element.To_Expression, Is_Discrete_Subtype_Definition => True))); -- ??? end Discrete_Simple_Expression_Range; ------------------------------------------ -- Discrete_Subtype_Definition_Sequence -- ------------------------------------------ function Discrete_Subtype_Definition_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------------- -- Discrete_Subtype_Indication -- --------------------------------- function Discrete_Subtype_Indication (Self : Node_Factory'Class; Subtype_Mark : Node; Subtype_Constraint : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Discrete_Subtype_Indication unimplemented"); return raise Program_Error with "Unimplemented function Discrete_Subtype_Indication"; end Discrete_Subtype_Indication; ------------------------------------ -- Discrete_Subtype_Indication_Dr -- ------------------------------------ function Discrete_Subtype_Indication_Dr (Self : Node_Factory'Class; Subtype_Mark : Node; Subtype_Constraint : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Discrete_Subtype_Indication_Dr unimplemented"); return raise Program_Error with "Unimplemented function Discrete_Subtype_Indication_Dr"; end Discrete_Subtype_Indication_Dr; -------------------------------- -- Discriminant_Specification -- -------------------------------- function Discriminant_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Discriminant_Specification (Names => To_Defining_Identifier_Vector (Names.Vector'Unchecked_Access, Self.Subpool), Colon_Token => Colon_Token.Token, Not_Token => Not_Token.Token, Null_Token => Null_Token.Token, Object_Subtype => Object_Declaration_Subtype.Element, Assignment_Token => Assignment_Token.Token, Default_Expression => Initialization_Expression.Element. To_Expression))); end Discriminant_Specification; ----------------------------------------- -- Discriminant_Specification_Sequence -- ----------------------------------------- function Discriminant_Specification_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------------------ -- Element_Iterator_Specification -- ------------------------------------ function Element_Iterator_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Subtype_Indication : Node; Of_Token : Node; Reverse_Token : Node; Iteration_Scheme_Name : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Element_Iterator_Specification unimplemented"); return raise Program_Error with "Unimplemented function Element_Iterator_Specification"; end Element_Iterator_Specification; -------------------------- -- Else_Expression_Path -- -------------------------- function Else_Expression_Path (Self : Node_Factory'Class; Else_Token : Node; Dependent_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Else_Expression_Path unimplemented"); return raise Program_Error with "Unimplemented function Else_Expression_Path"; end Else_Expression_Path; --------------- -- Else_Path -- --------------- function Else_Path (Self : Node_Factory'Class; Else_Token : Node; Sequence_Of_Statements : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Else_Path unimplemented"); return raise Program_Error with "Unimplemented function Else_Path"; end Else_Path; --------------------------- -- Elsif_Expression_Path -- --------------------------- function Elsif_Expression_Path (Self : Node_Factory'Class; Elsif_Token : Node; Condition_Expression : Node; Then_Token : Node; Dependent_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Elsif_Expression_Path unimplemented"); return raise Program_Error with "Unimplemented function Elsif_Expression_Path"; end Elsif_Expression_Path; ---------------- -- Elsif_Path -- ---------------- function Elsif_Path (Self : Node_Factory'Class; Elsif_Token : Node; Condition_Expression : Node; Then_Token : Node; Sequence_Of_Statements : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Elsif_Path unimplemented"); return raise Program_Error with "Unimplemented function Elsif_Path"; end Elsif_Path; ---------------- -- Entry_Body -- ---------------- function Entry_Body (Self : Node_Factory'Class; Entry_Token : Node; Names : Node; Left_Parenthesis_Token : Node; Entry_Index_Specification : Node; Right_Parenthesis_Token : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; When_Token : Node; Entry_Barrier : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Entry_Body unimplemented"); return raise Program_Error with "Unimplemented function Entry_Body"; end Entry_Body; ----------------------- -- Entry_Declaration -- ----------------------- function Entry_Declaration (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Entry_Token : Node; Names : Node; Left_Parenthesis_Token : Node; Entry_Family_Definition : Node; Right_Parenthesis_Token : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Entry_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Entry_Declaration"; end Entry_Declaration; ------------------------------- -- Entry_Index_Specification -- ------------------------------- function Entry_Index_Specification (Self : Node_Factory'Class; For_Token : Node; Names : Node; In_Token : Node; Specification_Subtype_Definition : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Entry_Index_Specification unimplemented"); return raise Program_Error with "Unimplemented function Entry_Index_Specification"; end Entry_Index_Specification; --------------------------------------- -- Enumeration_Literal_Specification -- --------------------------------------- function Enumeration_Literal_Specification (Self : Node_Factory'Class; Names : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Enumeration_Literal_Specification (Names.Element.To_Defining_Name))); end Enumeration_Literal_Specification; ------------------------------------------------ -- Enumeration_Literal_Specification_Sequence -- ------------------------------------------------ function Enumeration_Literal_Specification_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------------- -- Enumeration_Type_Definition -- --------------------------------- function Enumeration_Type_Definition (Self : Node_Factory'Class; Left_Token : Node; Literals : Node; Right_Token : Node) return Node is List : Program.Elements.Enumeration_Literal_Specifications .Enumeration_Literal_Specification_Vector_Access := To_Enumeration_Literal_Specification_Vector (Literals.Vector'Unchecked_Access, Self.Subpool); begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Enumeration_Type (Left_Token.Token, List, Right_Token.Token))); end Enumeration_Type_Definition; ------------------------------- -- Exception_Choice_Sequence -- ------------------------------- function Exception_Choice_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------- -- Exception_Declaration -- --------------------------- function Exception_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Exception_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Exception_Declaration (Names => To_Defining_Identifier_Vector (Names.Vector'Unchecked_Access, Self.Subpool), Colon_Token => Colon_Token.Token, Exception_Token => Exception_Token.Token, With_Token => null, Aspects => To_Aspect_Specification_Vector (Aspect_Specifications.Vector'Unchecked_Access, Self.Subpool), Semicolon_Token => Semicolon_Token.Token))); end Exception_Declaration; ----------------------- -- Exception_Handler -- ----------------------- function Exception_Handler (Self : Node_Factory'Class; When_Token : Node; Choice_Parameter_Specification : Node; Colon_Token : Node; Exception_Choices : Node; Arrow_Token : Node; Handler_Statements : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Exception_Handler (When_Token => When_Token.Token, Choice_Parameter => Choice_Parameter_Specification.Element .To_Choice_Parameter_Specification, Choices => To_Element_Vector (Exception_Choices.Vector'Unchecked_Access, Self.Subpool), Arrow_Token => Arrow_Token.Token, Statements => To_Element_Vector (Handler_Statements.Vector'Unchecked_Access, Self.Subpool)))); end Exception_Handler; -------------------------------- -- Exception_Handler_Sequence -- -------------------------------- function Exception_Handler_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------------------ -- Exception_Renaming_Declaration -- ------------------------------------ function Exception_Renaming_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Exception_Token : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Exception_Renaming_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Exception_Renaming_Declaration"; end Exception_Renaming_Declaration; -------------------- -- Exit_Statement -- -------------------- function Exit_Statement (Self : Node_Factory'Class; Exit_Token : Node; Exit_Loop_Name : Node; When_Token : Node; Exit_Condition : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Exit_Statement unimplemented"); return raise Program_Error with "Unimplemented function Exit_Statement"; end Exit_Statement; -------------------------- -- Explicit_Dereference -- -------------------------- function Explicit_Dereference (Self : Node_Factory'Class; Prefix : Node; Dot_Token : Node; All_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Explicit_Dereference unimplemented"); return raise Program_Error with "Unimplemented function Explicit_Dereference"; end Explicit_Dereference; ------------------------------- -- Extended_Return_Statement -- ------------------------------- function Extended_Return_Statement (Self : Node_Factory'Class; Return_Token : Node; Return_Object_Specification : Node; Do_Token : Node; Extended_Return_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Return : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Extended_Return_Statement unimplemented"); return raise Program_Error with "Unimplemented function Extended_Return_Statement"; end Extended_Return_Statement; ------------------------- -- Extension_Aggregate -- ------------------------- function Extension_Aggregate (Self : Node_Factory'Class; Left_Token : Node; Extension_Aggregate_Expression : Node; With_Token : Node; Record_Component_Associations : Node; Right_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Extension_Aggregate unimplemented"); return raise Program_Error with "Unimplemented function Extension_Aggregate"; end Extension_Aggregate; ------------------------------- -- Floating_Point_Definition -- ------------------------------- function Floating_Point_Definition (Self : Node_Factory'Class; Digits_Token : Node; Digits_Expression : Node; Real_Range_Constraint : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Floating_Point_Type (Digits_Token => Digits_Token.Token, Digits_Expression => Program.Elements.Expressions.Expression_Access (Digits_Expression.Element), Real_Range => Program.Elements.Real_Range_Specifications .Real_Range_Specification_Access (Real_Range_Constraint.Element)))); end Floating_Point_Definition; ------------------------ -- For_Loop_Statement -- ------------------------ function For_Loop_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; For_Token : Node; Loop_Parameter_Specification : Node; Loop_Token : Node; Loop_Statements : Node; End_Token : Node; End_Loop : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "For_Loop_Statement unimplemented"); return raise Program_Error with "Unimplemented function For_Loop_Statement"; end For_Loop_Statement; ------------------------------------------ -- Formal_Access_To_Function_Definition -- ------------------------------------------ function Formal_Access_To_Function_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Function_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Access_To_Function_Result_Subtype : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Access_To_Function_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Access_To_Function_Definition"; end Formal_Access_To_Function_Definition; ---------------------------------------- -- Formal_Access_To_Object_Definition -- ---------------------------------------- function Formal_Access_To_Object_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Constant_Token : Node; Subtype_Indication : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Access_To_Object_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Access_To_Object_Definition"; end Formal_Access_To_Object_Definition; ------------------------------------------- -- Formal_Access_To_Procedure_Definition -- ------------------------------------------- function Formal_Access_To_Procedure_Definition (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Access_Token : Node; Protected_Token : Node; Procedure_Token : Node; Lp_Token : Node; Access_To_Subprogram_Parameter_Profile : Node; Rp_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Access_To_Procedure_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Access_To_Procedure_Definition"; end Formal_Access_To_Procedure_Definition; ----------------------------------------- -- Formal_Constrained_Array_Definition -- ----------------------------------------- function Formal_Constrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Discrete_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Constrained_Array_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Constrained_Array_Definition"; end Formal_Constrained_Array_Definition; ------------------------------------------- -- Formal_Decimal_Fixed_Point_Definition -- ------------------------------------------- function Formal_Decimal_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Delta_Box : Node; Digits_Token : Node; Digits_Box : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Decimal_Fixed_Point_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Decimal_Fixed_Point_Definition"; end Formal_Decimal_Fixed_Point_Definition; ------------------------------------ -- Formal_Derived_Type_Definition -- ------------------------------------ function Formal_Derived_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; Synchronized_Token : Node; New_Token : Node; Subtype_Mark : Node; And_Token : Node; Progenitor_List : Node; With_Token : Node; Private_Token : Node; Aspect_Specifications : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Derived_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Derived_Type_Definition"; end Formal_Derived_Type_Definition; ------------------------------------- -- Formal_Discrete_Type_Definition -- ------------------------------------- function Formal_Discrete_Type_Definition (Self : Node_Factory'Class; Left_Parenthesis_Token : Node; Box_Token : Node; Right_Parenthesis_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Discrete_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Discrete_Type_Definition"; end Formal_Discrete_Type_Definition; -------------------------------------- -- Formal_Floating_Point_Definition -- -------------------------------------- function Formal_Floating_Point_Definition (Self : Node_Factory'Class; Digits_Token : Node; Box_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Floating_Point_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Floating_Point_Definition"; end Formal_Floating_Point_Definition; --------------------------------- -- Formal_Function_Declaration -- --------------------------------- function Formal_Function_Declaration (Self : Node_Factory'Class; With_Token : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Is_Token : Node; Abstract_Token : Node; Formal_Subprogram_Default : Node; Box_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Function_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Formal_Function_Declaration"; end Formal_Function_Declaration; ---------------------------------------- -- Formal_Incomplete_Type_Declaration -- ---------------------------------------- function Formal_Incomplete_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Tagged_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Incomplete_Type_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Formal_Incomplete_Type_Declaration"; end Formal_Incomplete_Type_Declaration; -------------------------------------- -- Formal_Interface_Type_Definition -- -------------------------------------- function Formal_Interface_Type_Definition (Self : Node_Factory'Class; Kind_Token : Node; Interface_Token : Node; Progenitor_List : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Interface_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Interface_Type_Definition"; end Formal_Interface_Type_Definition; ------------------------------------ -- Formal_Modular_Type_Definition -- ------------------------------------ function Formal_Modular_Type_Definition (Self : Node_Factory'Class; Mod_Token : Node; Box_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Modular_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Modular_Type_Definition"; end Formal_Modular_Type_Definition; ------------------------------- -- Formal_Object_Declaration -- ------------------------------- function Formal_Object_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; In_Token : Node; Out_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Object_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Formal_Object_Declaration"; end Formal_Object_Declaration; -------------------------------------------- -- Formal_Ordinary_Fixed_Point_Definition -- -------------------------------------------- function Formal_Ordinary_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Box_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Ordinary_Fixed_Point_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Ordinary_Fixed_Point_Definition"; end Formal_Ordinary_Fixed_Point_Definition; -------------------------------- -- Formal_Package_Declaration -- -------------------------------- function Formal_Package_Declaration (Self : Node_Factory'Class; With_Token : Node; Package_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Package_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Formal_Package_Declaration"; end Formal_Package_Declaration; ------------------------------------ -- Formal_Private_Type_Definition -- ------------------------------------ function Formal_Private_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Tagged_Token : Node; Limited_Token : Node; Private_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Private_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Private_Type_Definition"; end Formal_Private_Type_Definition; ---------------------------------- -- Formal_Procedure_Declaration -- ---------------------------------- function Formal_Procedure_Declaration (Self : Node_Factory'Class; With_Token : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Is_Token : Node; Abstract_Token : Node; Box_Token : Node; Null_Token : Node; Formal_Subprogram_Default : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Procedure_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Formal_Procedure_Declaration"; end Formal_Procedure_Declaration; ------------------------------------------- -- Formal_Signed_Integer_Type_Definition -- ------------------------------------------- function Formal_Signed_Integer_Type_Definition (Self : Node_Factory'Class; Range_Token : Node; Box_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Signed_Integer_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Signed_Integer_Type_Definition"; end Formal_Signed_Integer_Type_Definition; ----------------------------- -- Formal_Type_Declaration -- ----------------------------- function Formal_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Type_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Formal_Type_Declaration"; end Formal_Type_Declaration; ------------------------------------------- -- Formal_Unconstrained_Array_Definition -- ------------------------------------------- function Formal_Unconstrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Index_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Formal_Unconstrained_Array_Definition unimplemented"); return raise Program_Error with "Unimplemented function Formal_Unconstrained_Array_Definition"; end Formal_Unconstrained_Array_Definition; --------------------------- -- Full_Type_Declaration -- --------------------------- function Full_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Type_Declaration (Type_Token => Type_Token.Token, Name => Program.Elements.Defining_Identifiers .Defining_Identifier_Access (Names.Element), Discriminant_Part => Program.Elements.Definitions .Definition_Access (Discriminant_Part.Element), Is_Token => Is_Token.Token, Definition => Program.Elements.Definitions .Definition_Access (Type_Declaration_View.Element), With_Token => null, -- FIXME Aspects => To_Aspect_Specification_Vector (Aspect_Specifications.Vector'Unchecked_Access, Self.Subpool), Semicolon_Token => Semicolon_Token.Token))); end Full_Type_Declaration; ------------------- -- Function_Body -- ------------------- function Function_Body (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Function_Body unimplemented"); return raise Program_Error with "Unimplemented function Function_Body"; end Function_Body; ------------------- -- Function_Call -- ------------------- function Function_Call (Self : Node_Factory'Class; Prefix : Node; Function_Call_Parameters : Node) return Node is Args : constant Program.Nodes.Proxy_Calls.Proxy_Call_Access := Program.Nodes.Proxy_Calls.Proxy_Call_Access (Function_Call_Parameters.Element); begin Args.Turn_To_Function_Call (Prefix.Element.To_Expression); return Function_Call_Parameters; end Function_Call; -------------------------- -- Function_Declaration -- -------------------------- function Function_Declaration (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Is_Token : Node; Abstract_Token : Node; Result_Expression : Node; Renames_Token : Node; Renamed_Entity : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin if Renames_Token.Token.Assigned or Separate_Token.Token.Assigned then raise Program_Error with "Procedure_Declaration unimpl"; else return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Function_Declaration (Not_Token => Not_Token.Token, Overriding_Token => Overriding_Token.Token, Function_Token => Function_Token.Token, Name => Names.Element.To_Defining_Name, Left_Bracket_Token => Lp_Token.Token, Parameters => To_Parameter_Specification_Vector (Parameter_Profile.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Rp_Token.Token, Return_Token => Return_Token.Token, Not_Token_2 => Return_Not_Token.Token, Null_Token => Return_Null_Token.Token, Result_Subtype => Result_Subtype.Element, Is_Token => Is_Token.Token, Result_Expression => Result_Expression.Element. To_Parenthesized_Expression, Abstract_Token => Abstract_Token.Token, With_Token => null, Aspects => null, Semicolon_Token => Semicolon_Token.Token))); end if; end Function_Declaration; ---------------------------- -- Function_Instantiation -- ---------------------------- function Function_Instantiation (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Function_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Function_Instantiation unimplemented"); return raise Program_Error with "Unimplemented function Function_Instantiation"; end Function_Instantiation; ------------------------- -- Generic_Association -- ------------------------- function Generic_Association (Self : Node_Factory'Class; Formal_Parameter : Node; Arrow_Token : Node; Actual_Parameter : Node; Box_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Association unimplemented"); return raise Program_Error with "Unimplemented function Generic_Association"; end Generic_Association; ---------------------------------- -- Generic_Association_Sequence -- ---------------------------------- function Generic_Association_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ----------------------------- -- Generic_Formal_Sequence -- ----------------------------- function Generic_Formal_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ---------------------------------- -- Generic_Function_Declaration -- ---------------------------------- function Generic_Function_Declaration (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Function_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Return_Token : Node; Return_Not_Token : Node; Return_Null_Token : Node; Result_Subtype : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Function_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Generic_Function_Declaration"; end Generic_Function_Declaration; ------------------------------- -- Generic_Function_Renaming -- ------------------------------- function Generic_Function_Renaming (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Function_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Function_Renaming unimplemented"); return raise Program_Error with "Unimplemented function Generic_Function_Renaming"; end Generic_Function_Renaming; --------------------------------- -- Generic_Package_Declaration -- --------------------------------- function Generic_Package_Declaration (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Package_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Visible_Part_Declarative_Items : Node; Private_Token : Node; Private_Part_Declarative_Items : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Package_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Generic_Package_Declaration"; end Generic_Package_Declaration; ------------------------------ -- Generic_Package_Renaming -- ------------------------------ function Generic_Package_Renaming (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Package_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Package_Renaming unimplemented"); return raise Program_Error with "Unimplemented function Generic_Package_Renaming"; end Generic_Package_Renaming; ----------------------------------- -- Generic_Procedure_Declaration -- ----------------------------------- function Generic_Procedure_Declaration (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Procedure_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Generic_Procedure_Declaration"; end Generic_Procedure_Declaration; -------------------------------- -- Generic_Procedure_Renaming -- -------------------------------- function Generic_Procedure_Renaming (Self : Node_Factory'Class; Generic_Token : Node; Generic_Formal_Part : Node; Procedure_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Generic_Procedure_Renaming unimplemented"); return raise Program_Error with "Unimplemented function Generic_Procedure_Renaming"; end Generic_Procedure_Renaming; --------------------------- -- Get_Compilation_Units -- --------------------------- procedure Get_Compilation_Units (Value : Node; Units : out Program.Parsers.Unit_Vectors.Vector; Pragmas : out Program.Parsers.Element_Vectors.Vector) is begin Units := Value.Root_Units; Pragmas := Value.Pragmas; end Get_Compilation_Units; ------------------- -- Get_Unit_Name -- ------------------- function Get_Unit_Name (Self : Node_Factory'Class; Unit : Node) return Text is function Name (Element : Program.Elements.Element_Access) return Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; type Visitor is new Program.Safe_Element_Visitors.Safe_Element_Visitor with record Name : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; end record; overriding procedure Package_Declaration (Self : in out Visitor; Element : not null Program.Elements.Package_Declarations .Package_Declaration_Access); overriding procedure Procedure_Body_Declaration (Self : in out Visitor; Element : not null Program.Elements.Procedure_Body_Declarations .Procedure_Body_Declaration_Access); overriding procedure Package_Declaration (Self : in out Visitor; Element : not null Program.Elements.Package_Declarations .Package_Declaration_Access) is begin Self.Name := Ada.Strings.Wide_Wide_Unbounded.To_Unbounded_Wide_Wide_String (Element.Name.Image); end Package_Declaration; overriding procedure Procedure_Body_Declaration (Self : in out Visitor; Element : not null Program.Elements.Procedure_Body_Declarations .Procedure_Body_Declaration_Access) is begin Self.Name := Ada.Strings.Wide_Wide_Unbounded.To_Unbounded_Wide_Wide_String (Element.Name.Image); end Procedure_Body_Declaration; ---------- -- Name -- ---------- function Name (Element : Program.Elements.Element_Access) return Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String is Getter : Visitor; begin Getter.Visit (Element); return Getter.Name; end Name; begin if Self.Standard then return ""; elsif Unit.Kind /= Element_Node then raise Program_Error; else return Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String (Name (Unit.Element)); end if; end Get_Unit_Name; -------------------- -- Goto_Statement -- -------------------- function Goto_Statement (Self : Node_Factory'Class; Exit_Token : Node; Goto_Label : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Goto_Statement unimplemented"); return raise Program_Error with "Unimplemented function Goto_Statement"; end Goto_Statement; ---------------- -- Identifier -- ---------------- function Identifier (Self : Node_Factory'Class; Identifier_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Identifier (Identifier_Token.Token))); end Identifier; -------------------------------------- -- If_Else_Expression_Path_Sequence -- -------------------------------------- function If_Else_Expression_Path_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------------- -- If_Elsif_Else_Path_Sequence -- --------------------------------- function If_Elsif_Else_Path_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------- -- If_Expression -- ------------------- function If_Expression (Self : Node_Factory'Class; Expression_Paths : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "If_Expression unimplemented"); return raise Program_Error with "Unimplemented function If_Expression"; end If_Expression; ------------------------ -- If_Expression_Path -- ------------------------ function If_Expression_Path (Self : Node_Factory'Class; If_Token : Node; Condition_Expression : Node; Then_Token : Node; Dependent_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "If_Expression_Path unimplemented"); return raise Program_Error with "Unimplemented function If_Expression_Path"; end If_Expression_Path; ------------- -- If_Path -- ------------- function If_Path (Self : Node_Factory'Class; If_Token : Node; Condition_Expression : Node; Then_Token : Node; Sequence_Of_Statements : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "If_Path unimplemented"); return raise Program_Error with "Unimplemented function If_Path"; end If_Path; ------------------ -- If_Statement -- ------------------ function If_Statement (Self : Node_Factory'Class; Statement_Paths : Node; End_Token : Node; If_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "If_Statement unimplemented"); return raise Program_Error with "Unimplemented function If_Statement"; end If_Statement; --------------------------------- -- Incomplete_Type_Declaration -- --------------------------------- function Incomplete_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Type_Declaration (Type_Token => Type_Token.Token, Name => Program.Elements.Defining_Identifiers .Defining_Identifier_Access (Names.Element), Discriminant_Part => Program.Elements.Definitions .Definition_Access (Discriminant_Part.Element), Is_Token => Is_Token.Token, Definition => Type_Declaration_View.Element .To_Definition, With_Token => null, Aspects => null, Semicolon_Token => Semicolon_Token.Token))); end Incomplete_Type_Declaration; -------------------------------- -- Incomplete_Type_Definition -- -------------------------------- function Incomplete_Type_Definition (Self : Node_Factory'Class; Tagged_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Incomplete_Type_Definition (Tagged_Token => Tagged_Token.Token))); end Incomplete_Type_Definition; ---------------- -- Infix_Call -- ---------------- function Infix_Call (Self : Node_Factory'Class; Prefix, Left, Right : Node) return Node is Operator : Program.Elements.Operator_Symbols.Operator_Symbol_Access := Self.EF.Create_Operator_Symbol (Prefix.Token); begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Infix_Operator (Left => Program.Elements.Expressions.Expression_Access (Left.Element), Operator => Operator, Right => Program.Elements.Expressions.Expression_Access (Right.Element)))); end Infix_Call; ------------------------------- -- Interface_Type_Definition -- ------------------------------- function Interface_Type_Definition (Self : Node_Factory'Class; Kind_Token : Node; Interface_Token : Node; Progenitor_List : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Interface_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Interface_Type_Definition"; end Interface_Type_Definition; ----------------------------- -- Known_Discriminant_Part -- ----------------------------- function Known_Discriminant_Part (Self : Node_Factory'Class; Left_Parenthesis_Token : Node; Discriminants : Node; Right_Parenthesis_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Known_Discriminant_Part (Left_Bracket_Token => Left_Parenthesis_Token.Token, Discriminants => To_Discriminant_Specification_Vector (Discriminants.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Right_Parenthesis_Token.Token))); end Known_Discriminant_Part; --------------------- -- Label_Decorator -- --------------------- function Label_Decorator (Self : Node_Factory'Class; Label_Names : Node; Unlabeled_Statement : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Label_Decorator unimplemented"); return raise Program_Error with "Unimplemented function Label_Decorator"; end Label_Decorator; ---------------------------------- -- Loop_Parameter_Specification -- ---------------------------------- function Loop_Parameter_Specification (Self : Node_Factory'Class; Names : Node; In_Token : Node; Reverse_Token : Node; Specification_Subtype_Definition : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Loop_Parameter_Specification unimplemented"); return raise Program_Error with "Unimplemented function Loop_Parameter_Specification"; end Loop_Parameter_Specification; -------------------- -- Loop_Statement -- -------------------- function Loop_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; Loop_Token : Node; Loop_Statements : Node; End_Token : Node; End_Loop : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Loop_Statement unimplemented"); return raise Program_Error with "Unimplemented function Loop_Statement"; end Loop_Statement; -------------------------------- -- Membership_Choice_Sequence -- -------------------------------- function Membership_Choice_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------- -- Membership_Test -- --------------------- function Membership_Test (Self : Node_Factory'Class; Membership_Test_Expression : Node; Not_Token : Node; In_Token : Node; Membership_Test_Choices : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Membership_Test unimplemented"); return raise Program_Error with "Unimplemented function Membership_Test"; end Membership_Test; ----------------------------- -- Modular_Type_Definition -- ----------------------------- function Modular_Type_Definition (Self : Node_Factory'Class; Mod_Token : Node; Mod_Static_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Modular_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Modular_Type_Definition"; end Modular_Type_Definition; -------------------------- -- New_Element_Sequence -- -------------------------- function New_Element_Sequence (Self : Node_Factory'Class) return Node is begin return (Element_Sequence_Node, Element_Vectors.Empty_Vector); end New_Element_Sequence; ------------------- -- Name_Sequence -- ------------------- function Name_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------- -- Null_Component -- -------------------- function Null_Component (Self : Node_Factory'Class; Null_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Null_Component unimplemented"); return raise Program_Error with "Unimplemented function Null_Component"; end Null_Component; ------------------ -- Null_Literal -- ------------------ function Null_Literal (Self : Node_Factory'Class; Null_Literal_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Null_Literal unimplemented"); return raise Program_Error with "Unimplemented function Null_Literal"; end Null_Literal; ---------------------------- -- Null_Record_Definition -- ---------------------------- function Null_Record_Definition (Self : Node_Factory'Class; Null_Token : Node; Record_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Null_Record_Definition unimplemented"); return raise Program_Error with "Unimplemented function Null_Record_Definition"; end Null_Record_Definition; -------------------- -- Null_Statement -- -------------------- function Null_Statement (Self : Node_Factory'Class; Null_Token : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Null_Statement (Null_Token => Null_Token.Token, Semicolon_Token => Semicolon_Token.Token))); end Null_Statement; ------------------------ -- Number_Declaration -- ------------------------ function Number_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Constant_Token : Node; Assignment_Token : Node; Initialization_Expression : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Number_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Number_Declaration"; end Number_Declaration; --------------------- -- Numeric_Literal -- --------------------- function Numeric_Literal (Self : Node_Factory'Class; Numeric_Literal_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Numeric_Literal (Numeric_Literal_Token.Token))); end Numeric_Literal; ------------------------ -- Object_Declaration -- ------------------------ function Object_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Aliased_Token : Node; Constant_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Object_Declaration (Names => To_Defining_Identifier_Vector (Names.Vector'Unchecked_Access, Self.Subpool), Colon_Token => Colon_Token.Token, Aliased_Token => Aliased_Token.Token, Constant_Token => Constant_Token.Token, Object_Subtype => Object_Declaration_Subtype.Element. To_Definition, Assignment_Token => Assignment_Token.Token, Initialization_Expression => Initialization_Expression.Element. To_Expression, With_Token => null, Aspects => null, Semicolon_Token => Semicolon_Token.Token))); end Object_Declaration; --------------------------------- -- Object_Renaming_Declaration -- --------------------------------- function Object_Renaming_Declaration (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Object_Renaming_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Object_Renaming_Declaration"; end Object_Renaming_Declaration; --------------------- -- Operator_Symbol -- --------------------- function Operator_Symbol (Self : Node_Factory'Class; Operator_Symbol_Token : Node) return Node is Symbol : constant Program.Symbols.Symbol := Program.Plain_Lexical_Elements.Lexical_Element (Operator_Symbol_Token.Token.all).Symbol; begin if Program.Symbols.Is_Operator (Symbol) then return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Operator_Symbol (Operator_Symbol_Token.Token))); else return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_String_Literal (Operator_Symbol_Token.Token))); end if; end Operator_Symbol; ------------------------------------- -- Ordinary_Fixed_Point_Definition -- ------------------------------------- function Ordinary_Fixed_Point_Definition (Self : Node_Factory'Class; Delta_Token : Node; Delta_Expression : Node; Real_Range_Constraint : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Ordinary_Fixed_Point_Type (Delta_Token => Delta_Token.Token, Delta_Expression => Program.Elements.Expressions.Expression_Access (Delta_Expression.Element), Real_Range => Program.Elements.Real_Range_Specifications .Real_Range_Specification_Access (Real_Range_Constraint.Element)))); end Ordinary_Fixed_Point_Definition; ------------------- -- Others_Choice -- ------------------- function Others_Choice (Self : Node_Factory'Class; Others_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Others_Choice unimplemented"); return raise Program_Error with "Unimplemented function Others_Choice"; end Others_Choice; ------------------ -- Package_Body -- ------------------ function Package_Body (Self : Node_Factory'Class; Package_Token : Node; Body_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Package_Body_Declaration (Package_Token => Package_Token.Token, Body_Token => Body_Token.Token, Name => Names.Element.To_Defining_Name, With_Token => null, Aspects => null, Is_Token => Is_Token.Token, Declarations => To_Element_Vector (Body_Declarative_Items.Vector'Unchecked_Access, Self.Subpool), Begin_Token => Begin_Token.Token, Statements => To_Element_Vector (Body_Statements.Vector'Unchecked_Access, Self.Subpool), Exception_Token => Exception_Token.Token, Exception_Handlers => To_Exception_Handler_Vector (Exception_Handlers.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, End_Name => End_Name.Element.To_Expression, Semicolon_Token => Semicolon_Token.Token))); end Package_Body; ----------------------- -- Package_Body_Stub -- ----------------------- function Package_Body_Stub (Self : Node_Factory'Class; Package_Token : Node; Body_Token : Node; Names : Node; Is_Token : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Package_Body_Stub unimplemented"); return raise Program_Error with "Unimplemented function Package_Body_Stub"; end Package_Body_Stub; ------------------------- -- Package_Declaration -- ------------------------- function Package_Declaration (Self : Node_Factory'Class; Package_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Visible_Part_Declarative_Items : Node; Private_Token : Node; Private_Part_Declarative_Items : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Package_Declaration (Package_Token => Package_Token.Token, Name => Names.Element.To_Defining_Name, With_Token => null, Aspects => To_Aspect_Specification_Vector (Aspect_Specifications.Vector'Unchecked_Access, Self.Subpool), Is_Token => Is_Token.Token, Visible_Declarations => To_Element_Vector (Visible_Part_Declarative_Items.Vector'Unchecked_Access, Self.Subpool), Private_Token => Private_Token.Token, Private_Declarations => To_Element_Vector (Private_Part_Declarative_Items.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, End_Name => Program.Elements.Expressions.Expression_Access (End_Name.Element), Semicolon_Token => Semicolon_Token.Token))); end Package_Declaration; --------------------------- -- Package_Instantiation -- --------------------------- function Package_Instantiation (Self : Node_Factory'Class; Package_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Package_Instantiation unimplemented"); return raise Program_Error with "Unimplemented function Package_Instantiation"; end Package_Instantiation; ---------------------------------- -- Package_Renaming_Declaration -- ---------------------------------- function Package_Renaming_Declaration (Self : Node_Factory'Class; Package_Token : Node; Names : Node; Renames_Token : Node; Renamed_Entity : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Package_Renaming_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Package_Renaming_Declaration"; end Package_Renaming_Declaration; ----------------------------- -- Parameter_Specification -- ----------------------------- function Parameter_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Aliased_Token : Node; In_Token : Node; Out_Token : Node; Not_Token : Node; Null_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Parameter_Specification (Names => To_Defining_Identifier_Vector (Names.Vector'Unchecked_Access, Self.Subpool), Colon_Token => Colon_Token.Token, Aliased_Token => Aliased_Token.Token, In_Token => In_Token.Token, Out_Token => Out_Token.Token, Not_Token => Not_Token.Token, Null_Token => Null_Token.Token, Parameter_Subtype => Object_Declaration_Subtype.Element, Assignment_Token => Assignment_Token.Token, Default_Expression => Initialization_Expression.Element. To_Expression))); end Parameter_Specification; -------------------------------------- -- Parameter_Specification_Sequence -- -------------------------------------- function Parameter_Specification_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------------- -- Pragma_Argument_Association -- --------------------------------- function Pragma_Argument_Association (Self : Node_Factory'Class; Formal_Parameter : Node; Arrow_Token : Node; Actual_Parameter : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Pragma_Argument_Association unimplemented"); return raise Program_Error with "Unimplemented function Pragma_Argument_Association"; end Pragma_Argument_Association; ------------------------------------------ -- Pragma_Argument_Association_Sequence -- ------------------------------------------ function Pragma_Argument_Association_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ----------------- -- Pragma_Node -- ----------------- function Pragma_Node (Self : Node_Factory'Class; Pragma_Token : Node; Formal_Parameter : Node; Left_Token : Node; Pragma_Argument_Associations : Node; Right_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Pragma_Node unimplemented"); return raise Program_Error with "Unimplemented function Pragma_Node"; end Pragma_Node; ------------- -- Prepend -- ------------- procedure Prepend (Self : Node_Factory'Class; List : in out Node; Item : Node) is begin List.Vector.Prepend (Item.Element); end Prepend; ---------------------------------- -- Prepend_Aspect_Specification -- ---------------------------------- procedure Prepend_Aspect_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------- -- Prepend_Association -- ------------------------- procedure Prepend_Association (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ---------------------------------- -- Prepend_Case_Expression_Path -- ---------------------------------- procedure Prepend_Case_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------- -- Prepend_Case_Path -- ----------------------- procedure Prepend_Case_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------ -- Prepend_Compilation_Unit -- ------------------------------ procedure Prepend_Compilation_Unit (Self : Node_Factory'Class; List : in out Node; Item : Node) is begin List.Units.Prepend (Item.Unit); end Prepend_Compilation_Unit; ---------------------------- -- Prepend_Component_Item -- ---------------------------- procedure Prepend_Component_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------ -- Prepend_Declarative_Item -- ------------------------------ procedure Prepend_Declarative_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; --------------------------------- -- Prepend_Defining_Identifier -- --------------------------------- procedure Prepend_Defining_Identifier (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------------- -- Prepend_Discrete_Choice -- ----------------------------- procedure Prepend_Discrete_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------------------------- -- Prepend_Discrete_Subtype_Definition -- ----------------------------------------- procedure Prepend_Discrete_Subtype_Definition (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ---------------------------------------- -- Prepend_Discriminant_Specification -- ---------------------------------------- procedure Prepend_Discriminant_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------------------------------- -- Prepend_Enumeration_Literal_Specification -- ----------------------------------------------- procedure Prepend_Enumeration_Literal_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------ -- Prepend_Exception_Choice -- ------------------------------ procedure Prepend_Exception_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------- -- Prepend_Exception_Handler -- ------------------------------- procedure Prepend_Exception_Handler (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; --------------------------------- -- Prepend_Generic_Association -- --------------------------------- procedure Prepend_Generic_Association (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------------- -- Prepend_If_Else_Expression_Path -- ------------------------------------- procedure Prepend_If_Else_Expression_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; -------------------------------- -- Prepend_If_Elsif_Else_Path -- -------------------------------- procedure Prepend_If_Elsif_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------- -- Prepend_Membership_Choice -- ------------------------------- procedure Prepend_Membership_Choice (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------ -- Prepend_Name -- ------------------ procedure Prepend_Name (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------------- -- Prepend_Parameter_Specification -- ------------------------------------- procedure Prepend_Parameter_Specification (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------------------------- -- Prepend_Pragma_Argument_Association -- ----------------------------------------- procedure Prepend_Pragma_Argument_Association (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ------------------------------- -- Prepend_Program_Unit_Name -- ------------------------------- procedure Prepend_Program_Unit_Name (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; --------------------------------- -- Prepend_Select_Or_Else_Path -- --------------------------------- procedure Prepend_Select_Or_Else_Path (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------- -- Prepend_Statement -- ----------------------- procedure Prepend_Statement (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; -------------------------- -- Prepend_Subtype_Mark -- -------------------------- procedure Prepend_Subtype_Mark (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------- -- Prepend_Task_Item -- ----------------------- procedure Prepend_Task_Item (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; --------------------- -- Prepend_Variant -- --------------------- procedure Prepend_Variant (Self : Node_Factory'Class; List : in out Node; Item : Node) renames Prepend; ----------------------------------- -- Private_Extension_Declaration -- ----------------------------------- function Private_Extension_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Private_Extension_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Private_Extension_Declaration"; end Private_Extension_Declaration; ---------------------------------- -- Private_Extension_Definition -- ---------------------------------- function Private_Extension_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Limited_Token : Node; Synchronized_Token : Node; New_Token : Node; Ancestor_Subtype_Indication : Node; Progenitor_List : Node; With_Token : Node; Private_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Private_Extension_Definition unimplemented"); return raise Program_Error with "Unimplemented function Private_Extension_Definition"; end Private_Extension_Definition; ------------------------------ -- Private_Type_Declaration -- ------------------------------ function Private_Type_Declaration (Self : Node_Factory'Class; Type_Token : Node; Names : Node; Discriminant_Part : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Private_Type_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Private_Type_Declaration"; end Private_Type_Declaration; ----------------------------- -- Private_Type_Definition -- ----------------------------- function Private_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Tagged_Token : Node; Limited_Token : Node; Private_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Private_Type_Definition unimplemented"); return raise Program_Error with "Unimplemented function Private_Type_Definition"; end Private_Type_Definition; -------------------- -- Procedure_Body -- -------------------- function Procedure_Body (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; End_Name : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Procedure_Body_Declaration (Not_Token => Not_Token.Token, Overriding_Token => Overriding_Token.Token, Procedure_Token => Procedure_Token.Token, Name => Names.Element.To_Defining_Name, Left_Bracket_Token => Lp_Token.Token, Parameters => To_Parameter_Specification_Vector (Parameter_Profile.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Rp_Token.Token, With_Token => null, Aspects => null, Is_Token => Is_Token.Token, Declarations => To_Element_Vector (Body_Declarative_Items.Vector'Unchecked_Access, Self.Subpool), Begin_Token => Begin_Token.Token, Statements => To_Element_Vector (Body_Statements.Vector'Unchecked_Access, Self.Subpool), Exception_Token => Exception_Token.Token, Exception_Handlers => To_Exception_Handler_Vector (Exception_Handlers.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, End_Name => End_Name.Element.To_Expression, Semicolon_Token => Semicolon_Token.Token))); end Procedure_Body; ------------------------------ -- Procedure_Call_Statement -- ------------------------------ function Procedure_Call_Statement (Self : Node_Factory'Class; Function_Call : Node; Semicolon_Token : Node) return Node is begin if Function_Call.Element.all in Program.Nodes.Proxy_Calls.Proxy_Call then declare Call : constant Program.Nodes.Proxy_Calls.Proxy_Call_Access := Program.Nodes.Proxy_Calls.Proxy_Call_Access (Function_Call.Element); begin Call.Turn_To_Procedure_Call (Semicolon_Token.Token); return Function_Call; end; else return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Call_Statement (Called_Name => Function_Call.Element.To_Expression, Left_Bracket_Token => null, Parameters => null, Right_Bracket_Token => null, Semicolon_Token => Semicolon_Token.Token))); end if; end Procedure_Call_Statement; --------------------------- -- Procedure_Declaration -- --------------------------- function Procedure_Declaration (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Procedure_Token : Node; Names : Node; Lp_Token : Node; Parameter_Profile : Node; Rp_Token : Node; Is_Token : Node; Abstract_Token : Node; Renames_Token : Node; Renamed_Entity : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin if Renames_Token.Token.Assigned or Separate_Token.Token.Assigned then raise Program_Error with "Procedure_Declaration unimpl"; else return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Procedure_Declaration (Not_Token => Not_Token.Token, Overriding_Token => Overriding_Token.Token, Procedure_Token => Procedure_Token.Token, Name => Names.Element.To_Defining_Name, Left_Bracket_Token => Lp_Token.Token, Parameters => To_Parameter_Specification_Vector (Parameter_Profile.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Rp_Token.Token, Is_Token => Is_Token.Token, Abstract_Token => Abstract_Token.Token, With_Token => null, Aspects => null, Semicolon_Token => Semicolon_Token.Token))); end if; end Procedure_Declaration; ----------------------------- -- Procedure_Instantiation -- ----------------------------- function Procedure_Instantiation (Self : Node_Factory'Class; Not_Token : Node; Overriding_Token : Node; Procedure_Token : Node; Names : Node; Is_Token : Node; New_Token : Node; Generic_Unit_Name : Node; Left_Parenthesis_Token : Node; Generic_Actual_Part : Node; Right_Parenthesis_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Procedure_Instantiation unimplemented"); return raise Program_Error with "Unimplemented function Procedure_Instantiation"; end Procedure_Instantiation; -------------------------------- -- Program_Unit_Name_Sequence -- -------------------------------- function Program_Unit_Name_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------- -- Protected_Body -- -------------------- function Protected_Body (Self : Node_Factory'Class; Protected_Token : Node; Body_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Protected_Operation_Items : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Protected_Body unimplemented"); return raise Program_Error with "Unimplemented function Protected_Body"; end Protected_Body; ------------------------- -- Protected_Body_Stub -- ------------------------- function Protected_Body_Stub (Self : Node_Factory'Class; Protected_Token : Node; Body_Token : Node; Names : Node; Is_Token : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Protected_Body_Stub unimplemented"); return raise Program_Error with "Unimplemented function Protected_Body_Stub"; end Protected_Body_Stub; -------------------------- -- Protected_Definition -- -------------------------- function Protected_Definition (Self : Node_Factory'Class; Visible_Protected_Items : Node; Private_Token : Node; Private_Protected_Items : Node; End_Token : Node; Identifier_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Protected_Definition unimplemented"); return raise Program_Error with "Unimplemented function Protected_Definition"; end Protected_Definition; -------------------------------------------- -- Protected_Element_Declaration_Sequence -- -------------------------------------------- function Protected_Element_Declaration_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ---------------------------------------------- -- Protected_Operation_Declaration_Sequence -- ---------------------------------------------- function Protected_Operation_Declaration_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------------------- -- Protected_Operation_Item_Sequence -- --------------------------------------- function Protected_Operation_Item_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------------------- -- Protected_Type_Declaration -- -------------------------------- function Protected_Type_Declaration (Self : Node_Factory'Class; Protected_Token : Node; Type_Token : Node; Names : Node; Discriminant_Part : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Type_Declaration_View : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Protected_Type_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Protected_Type_Declaration"; end Protected_Type_Declaration; -------------------------- -- Qualified_Expression -- -------------------------- function Qualified_Expression (Self : Node_Factory'Class; Converted_Or_Qualified_Subtype_Mark : Node; Apostrophe_Token : Node; Left_Parenthesis_Token : Node; Converted_Or_Qualified_Expression : Node; Right_Parenthesis_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Qualified_Expression unimplemented"); return raise Program_Error with "Unimplemented function Qualified_Expression"; end Qualified_Expression; --------------------------- -- Quantified_Expression -- --------------------------- function Quantified_Expression (Self : Node_Factory'Class; For_Token : Node; Quantifier_Token : Node; Iterator_Specification : Node; Arrow_Token : Node; Predicate : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Quantified_Expression unimplemented"); return raise Program_Error with "Unimplemented function Quantified_Expression"; end Quantified_Expression; --------------------- -- Raise_Statement -- --------------------- function Raise_Statement (Self : Node_Factory'Class; Raise_Token : Node; Raised_Exception : Node; With_Token : Node; Raise_Statement_Message : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Raise_Statement unimplemented"); return raise Program_Error with "Unimplemented function Raise_Statement"; end Raise_Statement; ------------------------------- -- Range_Attribute_Reference -- ------------------------------- function Range_Attribute_Reference (Self : Node_Factory'Class; Range_Attribute : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Range_Attribute_Reference unimplemented"); return raise Program_Error with "Unimplemented function Range_Attribute_Reference"; end Range_Attribute_Reference; ---------------------------------- -- Range_Attribute_Reference_Dr -- ---------------------------------- function Range_Attribute_Reference_Dr (Self : Node_Factory'Class; Range_Attribute : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Range_Attribute_Reference_Dr unimplemented"); return raise Program_Error with "Unimplemented function Range_Attribute_Reference_Dr"; end Range_Attribute_Reference_Dr; ------------------------------ -- Real_Range_Specification -- ------------------------------ function Real_Range_Specification (Self : Node_Factory'Class; Range_Token : Node; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Real_Range_Specification (Range_Token => Range_Token.Token, Lower_Bound => Program.Elements.Expressions.Expression_Access (Lower_Bound.Element), Double_Dot_Token => Double_Dot_Token.Token, Upper_Bound => Program.Elements.Expressions.Expression_Access (Upper_Bound.Element)))); end Real_Range_Specification; ----------------------- -- Record_Definition -- ----------------------- function Record_Definition (Self : Node_Factory'Class; Record_Token : Node; Record_Components : Node; End_Token : Node; End_Record_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Record_Definition (Record_Token => Record_Token.Token, Components => To_Element_Vector (Record_Components.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, Record_Token_2 => End_Record_Token.Token))); end Record_Definition; ---------------------------------- -- Record_Representation_Clause -- ---------------------------------- function Record_Representation_Clause (Self : Node_Factory'Class; For_Token : Node; Representation_Clause_Name : Node; Use_Token : Node; Record_Token : Node; At_Token : Node; Mod_Token : Node; Mod_Clause_Expression : Node; Mod_Semicolon : Node; Component_Clauses : Node; End_Token : Node; End_Record : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Record_Representation_Clause unimplemented"); return raise Program_Error with "Unimplemented function Record_Representation_Clause"; end Record_Representation_Clause; ---------------------------- -- Record_Type_Definition -- ---------------------------- function Record_Type_Definition (Self : Node_Factory'Class; Abstract_Token : Node; Tagged_Token : Node; Limited_Token : Node; Record_Definition : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Record_Type (Abstract_Token => Abstract_Token.Token, Tagged_Token => Tagged_Token.Token, Limited_Token => Limited_Token.Token, Record_Definition => Record_Definition.Element.To_Definition))); end Record_Type_Definition; ----------------------- -- Requeue_Statement -- ----------------------- function Requeue_Statement (Self : Node_Factory'Class; Requeue_Token : Node; Requeue_Entry_Name : Node; With_Token : Node; Abort_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Requeue_Statement unimplemented"); return raise Program_Error with "Unimplemented function Requeue_Statement"; end Requeue_Statement; --------------------------------- -- Return_Object_Specification -- --------------------------------- function Return_Object_Specification (Self : Node_Factory'Class; Names : Node; Colon_Token : Node; Aliased_Token : Node; Constant_Token : Node; Object_Declaration_Subtype : Node; Assignment_Token : Node; Initialization_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Return_Object_Specification unimplemented"); return raise Program_Error with "Unimplemented function Return_Object_Specification"; end Return_Object_Specification; ---------------------------------- -- Select_Or_Else_Path_Sequence -- ---------------------------------- function Select_Or_Else_Path_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------- -- Select_Or_Path -- -------------------- function Select_Or_Path (Self : Node_Factory'Class; Or_Token : Node; When_Token : Node; Guard : Node; Arrow_Token : Node; Sequence_Of_Statements : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Select_Or_Path unimplemented"); return raise Program_Error with "Unimplemented function Select_Or_Path"; end Select_Or_Path; ------------------------------------- -- Select_Then_Abort_Path_Sequence -- ------------------------------------- function Select_Then_Abort_Path_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------ -- Selected_Component -- ------------------------ function Selected_Component (Self : Node_Factory'Class; Prefix : Node; Dot_Token : Node; Selector : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Selected_Component unimplemented"); return raise Program_Error with "Unimplemented function Selected_Component"; end Selected_Component; ------------------------- -- Selected_Identifier -- ------------------------- function Selected_Identifier (Self : Node_Factory'Class; Prefix : Node; Dot_Token : Node; Selector : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Selected_Identifier unimplemented"); return raise Program_Error with "Unimplemented function Selected_Identifier"; end Selected_Identifier; ---------------------- -- Selective_Accept -- ---------------------- function Selective_Accept (Self : Node_Factory'Class; Select_Token : Node; Selective_Statement_Paths : Node; End_Token : Node; End_Select : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Selective_Accept unimplemented"); return raise Program_Error with "Unimplemented function Selective_Accept"; end Selective_Accept; ------------------- -- Short_Circuit -- ------------------- function Short_Circuit (Self : Node_Factory'Class; Short_Circuit_Operation_Left_Expression : Node; And_Token : Node; Then_Token : Node; Short_Circuit_Operation_Right_Expression : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Short_Circuit unimplemented"); return raise Program_Error with "Unimplemented function Short_Circuit"; end Short_Circuit; ------------------------------------ -- Signed_Integer_Type_Definition -- ------------------------------------ function Signed_Integer_Type_Definition (Self : Node_Factory'Class; Range_Token : Node; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Signed_Integer_Type (Range_Token => Range_Token.Token, Lower_Bound => Program.Elements.Expressions.Expression_Access (Lower_Bound.Element), Double_Dot_Token => Double_Dot_Token.Token, Upper_Bound => Program.Elements.Expressions.Expression_Access (Upper_Bound.Element)))); end Signed_Integer_Type_Definition; ----------------------------- -- Simple_Expression_Range -- ----------------------------- function Simple_Expression_Range (Self : Node_Factory'Class; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Simple_Expression_Range (Lower_Bound => Program.Elements.Expressions.Expression_Access (Lower_Bound.Element), Double_Dot_Token => Double_Dot_Token.Token, Upper_Bound => Program.Elements.Expressions.Expression_Access (Upper_Bound.Element)))); end Simple_Expression_Range; -------------------------------- -- Simple_Expression_Range_Dr -- -------------------------------- function Simple_Expression_Range_Dr (Self : Node_Factory'Class; Lower_Bound : Node; Double_Dot_Token : Node; Upper_Bound : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Discrete_Simple_Expression_Range (Lower_Bound => Program.Elements.Expressions.Expression_Access (Lower_Bound.Element), Double_Dot_Token => Double_Dot_Token.Token, Upper_Bound => Program.Elements.Expressions.Expression_Access (Upper_Bound.Element)))); end Simple_Expression_Range_Dr; ----------------------------- -- Simple_Return_Statement -- ----------------------------- function Simple_Return_Statement (Self : Node_Factory'Class; Return_Token : Node; Return_Expression : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Simple_Return_Statement unimplemented"); return raise Program_Error with "Unimplemented function Simple_Return_Statement"; end Simple_Return_Statement; ---------------------------------- -- Single_Protected_Declaration -- ---------------------------------- function Single_Protected_Declaration (Self : Node_Factory'Class; Protected_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Object_Declaration_Subtype : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Single_Protected_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Single_Protected_Declaration"; end Single_Protected_Declaration; ----------------------------- -- Single_Task_Declaration -- ----------------------------- function Single_Task_Declaration (Self : Node_Factory'Class; Task_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Object_Declaration_Subtype : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Single_Task_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Single_Task_Declaration"; end Single_Task_Declaration; ------------------------ -- Statement_Sequence -- ------------------------ function Statement_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------------------- -- Subtype_Declaration -- ------------------------- function Subtype_Declaration (Self : Node_Factory'Class; Subtype_Token : Node; Names : Node; Is_Token : Node; Type_Declaration_View : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Subtype_Declaration (Subtype_Token => Subtype_Token.Token, Name => Program.Elements.Defining_Identifiers .Defining_Identifier_Access (Names.Element), Is_Token => Is_Token.Token, Subtype_Indication => Program.Elements.Subtype_Indications .Subtype_Indication_Access (Type_Declaration_View.Element), With_Token => null, Aspects => To_Aspect_Specification_Vector (Aspect_Specifications.Vector'Unchecked_Access, Self.Subpool), Semicolon_Token => Semicolon_Token.Token))); end Subtype_Declaration; --------------------------- -- Subtype_Mark_Sequence -- --------------------------- function Subtype_Mark_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; ------------- -- Subunit -- ------------- function Subunit (Self : Node_Factory'Class; Context_Clause_Elements : Node; Separate_Token : Node; Left_Parenthesis_Token : Node; Parent_Unit_Name : Node; Right_Parenthesis_Token : Node; Unit_Declaration : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Subunit unimplemented"); return raise Program_Error with "Unimplemented function Subunit"; end Subunit; --------------- -- Task_Body -- --------------- function Task_Body (Self : Node_Factory'Class; Task_Token : Node; Body_Token : Node; Names : Node; Aspect_Specifications : Node; Is_Token : Node; Body_Declarative_Items : Node; Begin_Token : Node; Body_Statements : Node; Exception_Token : Node; Exception_Handlers : Node; End_Token : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Task_Body unimplemented"); return raise Program_Error with "Unimplemented function Task_Body"; end Task_Body; -------------------- -- Task_Body_Stub -- -------------------- function Task_Body_Stub (Self : Node_Factory'Class; Task_Token : Node; Body_Token : Node; Names : Node; Is_Token : Node; Separate_Token : Node; Aspect_Specifications : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Task_Body_Stub unimplemented"); return raise Program_Error with "Unimplemented function Task_Body_Stub"; end Task_Body_Stub; --------------------- -- Task_Definition -- --------------------- function Task_Definition (Self : Node_Factory'Class; Visible_Task_Items : Node; Private_Token : Node; Private_Task_Items : Node; End_Token : Node; Identifier_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Task_Definition unimplemented"); return raise Program_Error with "Unimplemented function Task_Definition"; end Task_Definition; ------------------------ -- Task_Item_Sequence -- ------------------------ function Task_Item_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; --------------------------- -- Task_Type_Declaration -- --------------------------- function Task_Type_Declaration (Self : Node_Factory'Class; Task_Token : Node; Type_Token : Node; Names : Node; Discriminant_Part : Node; Aspect_Specifications : Node; Is_Token : Node; New_Token : Node; Progenitor_List : Node; With_Token : Node; Type_Declaration_View : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Task_Type_Declaration unimplemented"); return raise Program_Error with "Unimplemented function Task_Type_Declaration"; end Task_Type_Declaration; ------------------------------------- -- Terminate_Alternative_Statement -- ------------------------------------- function Terminate_Alternative_Statement (Self : Node_Factory'Class; Terminate_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Terminate_Alternative_Statement unimplemented"); return raise Program_Error with "Unimplemented function Terminate_Alternative_Statement"; end Terminate_Alternative_Statement; --------------------- -- Then_Abort_Path -- --------------------- function Then_Abort_Path (Self : Node_Factory'Class; Then_Token : Node; Abort_Token : Node; Sequence_Of_Statements : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Then_Abort_Path unimplemented"); return raise Program_Error with "Unimplemented function Then_Abort_Path"; end Then_Abort_Path; -------------------------------- -- To_Aggregate_Or_Expression -- -------------------------------- function To_Aggregate_Or_Expression (Self : Node_Factory'Class; Association_List : Node) return Node is Element : constant Program.Nodes.Proxy_Calls.Proxy_Call_Access := Program.Nodes.Proxy_Calls.Proxy_Call_Access (Association_List.Element); begin if Element.Can_Be_Parenthesized_Expression then Element.Turn_To_Parenthesized_Expression; end if; return Association_List; end To_Aggregate_Or_Expression; ----------------------------------- -- To_Defining_Program_Unit_Name -- ----------------------------------- function To_Defining_Program_Unit_Name (Self : Node_Factory'Class; Selected_Identifier : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "To_Defining_Program_Unit_Name unimplemented"); return raise Program_Error with "Unimplemented function To_Defining_Program_Unit_Name"; end To_Defining_Program_Unit_Name; --------------------------- -- To_Subtype_Indication -- --------------------------- function To_Subtype_Indication (Self : Node_Factory'Class; Not_Token : Node; Null_Token : Node; Mark : Node; Constraint : Node) return Node is Prefix : Program.Elements.Expressions.Expression_Access; Constr : Program.Elements.Constraints.Constraint_Access; begin if Mark.Element.all in Program.Nodes.Proxy_Calls.Proxy_Call then declare Call : constant Program.Nodes.Proxy_Calls.Proxy_Call_Access := Program.Nodes.Proxy_Calls.Proxy_Call_Access (Mark.Element); begin Call.Turn_To_Discriminant_Constraint (Prefix); Constr := Program.Elements.Constraints.Constraint_Access (Call); end; else Prefix := Program.Elements.Expressions.Expression_Access (Mark.Element); Constr := Program.Elements.Constraints.Constraint_Access (Constraint.Element); end if; return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Subtype_Indication (Not_Token => Not_Token.Token, Null_Token => Null_Token.Token, Subtype_Mark => Prefix, Constraint => Constr))); end To_Subtype_Indication; ----------- -- Token -- ----------- function Token (Self : Node_Factory'Class; Value : not null Program.Lexical_Elements.Lexical_Element_Access) return Node is begin return (Token_Node, Value); end Token; ------------------------------------ -- Unconstrained_Array_Definition -- ------------------------------------ function Unconstrained_Array_Definition (Self : Node_Factory'Class; Array_Token : Node; Left_Token : Node; Index_Subtype_Definitions : Node; Right_Token : Node; Of_Token : Node; Array_Component_Definition : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Unconstrained_Array_Type (Array_Token => Array_Token.Token, Left_Bracket_Token => Left_Token.Token, Index_Subtypes => To_Expression_Vector (Index_Subtype_Definitions.Vector'Unchecked_Access, Self.Subpool), Right_Bracket_Token => Right_Token.Token, Of_Token => Of_Token.Token, Component_Definition => Program.Elements.Component_Definitions .Component_Definition_Access (Array_Component_Definition.Element)))); end Unconstrained_Array_Definition; ------------------------------- -- Unknown_Discriminant_Part -- ------------------------------- function Unknown_Discriminant_Part (Self : Node_Factory'Class; Left_Token : Node; Box_Token : Node; Right_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Unknown_Discriminant_Part unimplemented"); return raise Program_Error with "Unimplemented function Unknown_Discriminant_Part"; end Unknown_Discriminant_Part; ------------------------ -- Use_Package_Clause -- ------------------------ function Use_Package_Clause (Self : Node_Factory'Class; Use_Token : Node; Clause_Names : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Use_Clause (Use_Token => Use_Token.Token, All_Token => null, Type_Token => null, Clause_Names => To_Expression_Vector (Clause_Names.Vector'Unchecked_Access, Self.Subpool), Semicolon_Token => Semicolon_Token.Token))); end Use_Package_Clause; --------------------- -- Use_Type_Clause -- --------------------- function Use_Type_Clause (Self : Node_Factory'Class; Use_Token : Node; All_Token : Node; Type_Token : Node; Type_Clause_Names : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "Use_Type_Clause unimplemented"); return raise Program_Error with "Unimplemented function Use_Type_Clause"; end Use_Type_Clause; ------------- -- Variant -- ------------- function Variant (Self : Node_Factory'Class; When_Token : Node; Variant_Choices : Node; Arrow_Token : Node; Record_Components : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Variant (When_Token => When_Token.Token, Choices => To_Element_Vector (Variant_Choices.Vector'Unchecked_Access, Self.Subpool), Arrow_Token => Arrow_Token.Token, Components => To_Element_Vector (Record_Components.Vector'Unchecked_Access, Self.Subpool)))); end Variant; ------------------ -- Variant_Part -- ------------------ function Variant_Part (Self : Node_Factory'Class; Case_Token : Node; Discriminant_Direct_Name : Node; Is_Token : Node; Variants : Node; End_Token : Node; End_Case_Token : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_Variant_Part (Case_Token => Case_Token.Token, Discriminant => Discriminant_Direct_Name.Element .To_Identifier, Is_Token => Is_Token.Token, Variants => To_Variant_Vector (Variants.Vector'Unchecked_Access, Self.Subpool), End_Token => End_Token.Token, Case_Token_2 => End_Case_Token.Token, Semicolon_Token => Semicolon_Token.Token))); end Variant_Part; ---------------------- -- Variant_Sequence -- ---------------------- function Variant_Sequence (Self : Node_Factory'Class) return Node renames New_Element_Sequence; -------------------------- -- While_Loop_Statement -- -------------------------- function While_Loop_Statement (Self : Node_Factory'Class; Statement_Identifier : Node; Colon_Token : Node; While_Token : Node; While_Condition : Node; Loop_Token : Node; Loop_Statements : Node; End_Token : Node; End_Loop : Node; Identifier_Token : Node; Semicolon_Token : Node) return Node is begin pragma Compile_Time_Warning (Standard.True, "While_Loop_Statement unimplemented"); return raise Program_Error with "Unimplemented function While_Loop_Statement"; end While_Loop_Statement; ----------------- -- With_Clause -- ----------------- function With_Clause (Self : Node_Factory'Class; Limited_Token : Node; Private_Token : Node; With_Token : Node; With_Clause_Names : Node; Semicolon_Token : Node) return Node is begin return (Element_Node, Program.Elements.Element_Access (Self.EF.Create_With_Clause (Limited_Token => Limited_Token.Token, Private_Token => Private_Token.Token, With_Token => With_Token.Token, Clause_Names => To_Expression_Vector (With_Clause_Names.Vector'Unchecked_Access, Self.Subpool), Semicolon_Token => Semicolon_Token.Token))); end With_Clause; end Program.Parsers.Nodes;
-- MIT License -- Copyright (c) 2021 Stephen Merrony -- 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 Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with DG_Types; use DG_Types; package Devices is -- Device IDs and PMBs -- Standard device codes in octal, Priority Mask Bits in decimal -- as per DG docs! PWRFL : constant Dev_Num_T := 8#00#; WCS : constant Dev_Num_T := 8#01#; MAP : constant Dev_Num_T := 8#03#; PSC : constant Dev_Num_T := 8#04#; BMC : constant Dev_Num_T := 8#05#; TTI : constant Dev_Num_T := 8#10#; TTO : constant Dev_Num_T := 8#11#; RTC : constant Dev_Num_T := 8#14#; LPT : constant Dev_Num_T := 8#17#; MTB : constant Dev_Num_T := 8#22#; MTJ : constant Dev_Num_T := 8#23#; DSKP : constant Dev_Num_T := 8#24#; DPF : constant Dev_Num_T := 8#27#; ISC : constant Dev_Num_T := 8#34#; PIT : constant Dev_Num_T := 8#43#; SCP : constant Dev_Num_T := 8#45#; IAC1 : constant Dev_Num_T := 8#50#; MTB1 : constant Dev_Num_T := 8#62#; MTJ1 : constant Dev_Num_T := 8#63#; DSKP1 : constant Dev_Num_T := 8#64#; IAC : constant Dev_Num_T := 8#65#; DPF1 : constant Dev_Num_T := 8#67#; FPU : constant Dev_Num_T := 8#76#; CPU : constant Dev_Num_T := 8#77#; type Reset_Proc_T is access protected procedure; type Data_Out_Proc_T is access protected procedure (Datum : in Word_T; ABC : in IO_Reg_T; Flag : in IO_Flag_T); type Data_In_Proc_T is access protected procedure (ABC : in IO_Reg_T; Flag : in IO_Flag_T; Datum : out Word_T); type Device_Rec is record Mnemonic : Unbounded_String; PMB : Integer; IO_Device : Boolean; Bootable : Boolean; Connected : Boolean; Reset_Proc : Reset_Proc_T; Data_Out_Proc : Data_Out_Proc_T; Data_In_Proc : Data_In_Proc_T; Sim_Image_Attached : Boolean; Sim_Image_Name : Unbounded_String; -- Busy : Boolean; -- Done : Boolean; end record; type Devices_Arr_T is array (Dev_Num_T'Range) of Device_Rec; type State_Rec is record Busy : Boolean; Done : Boolean; end record; type State_Arr_T is array (Dev_Num_T'Range) of State_Rec; type PMB_Arr_T is array (Dev_Num_T'Range) of Integer; -- function Mnemonic_Or_Octal (Dev_Num : Dev_Num_T) return Unbounded_String; end Devices;
----------------------------------------------------------------------- -- keystore-io-files -- Ada keystore IO for files -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers.Ordered_Sets; with Ada.Containers.Hashed_Maps; with Ada.Strings.Unbounded; with Util.Streams.Raw; private with Keystore.IO.Headers; private with Util.Systems.Types; private with Ada.Finalization; private with Keystore.Random; package Keystore.IO.Files is type Wallet_Stream is limited new Keystore.IO.Wallet_Stream with private; type Wallet_Stream_Access is access all Wallet_Stream'Class; -- Open the wallet stream. procedure Open (Stream : in out Wallet_Stream; Path : in String; Data_Path : in String); procedure Create (Stream : in out Wallet_Stream; Path : in String; Data_Path : in String; Config : in Wallet_Config); -- Get information about the keystore file. function Get_Info (Stream : in out Wallet_Stream) return Wallet_Info; -- Read from the wallet stream the block identified by the number and -- call the `Process` procedure with the data block content. overriding procedure Read (Stream : in out Wallet_Stream; Block : in Storage_Block; Process : not null access procedure (Data : in IO_Block_Type)); -- Write in the wallet stream the block identified by the block number. overriding procedure Write (Stream : in out Wallet_Stream; Block : in Storage_Block; Process : not null access procedure (Data : out IO_Block_Type)); -- Allocate a new block and return the block number in `Block`. overriding procedure Allocate (Stream : in out Wallet_Stream; Kind : in Block_Kind; Block : out Storage_Block); -- Release the block number. overriding procedure Release (Stream : in out Wallet_Stream; Block : in Storage_Block); overriding function Is_Used (Stream : in out Wallet_Stream; Block : in Storage_Block) return Boolean; overriding procedure Set_Header_Data (Stream : in out Wallet_Stream; Index : in Header_Slot_Index_Type; Kind : in Header_Slot_Type; Data : in Ada.Streams.Stream_Element_Array); overriding procedure Get_Header_Data (Stream : in out Wallet_Stream; Index : in Header_Slot_Index_Type; Kind : out Header_Slot_Type; Data : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); -- Add up to Count data storage files associated with the wallet. procedure Add_Storage (Stream : in out Wallet_Stream; Count : in Positive); -- Close the wallet stream and release any resource. procedure Close (Stream : in out Wallet_Stream); private use type Block_Number; use type Storage_Identifier; subtype Wallet_Storage is Keystore.IO.Headers.Wallet_Storage; subtype Wallet_Header is Keystore.IO.Headers.Wallet_Header; package Block_Number_Sets is new Ada.Containers.Ordered_Sets (Element_Type => Block_Number, "<" => "<", "=" => "="); protected type File_Stream is procedure Open (File_Descriptor : in Util.Systems.Types.File_Type; Storage : in Storage_Identifier; Sign : in Secret_Key; File_Size : in Block_Count; UUID : out UUID_Type); procedure Create (File_Descriptor : in Util.Systems.Types.File_Type; Storage : in Storage_Identifier; UUID : in UUID_Type; Sign : in Secret_Key); function Get_Info return Wallet_Info; -- Read from the wallet stream the block identified by the number and -- call the `Process` procedure with the data block content. procedure Read (Block : in Block_Number; Process : not null access procedure (Data : in IO_Block_Type)); -- Write in the wallet stream the block identified by the block number. procedure Write (Block : in Block_Number; Process : not null access procedure (Data : out IO_Block_Type)); -- Allocate a new block and return the block number in `Block`. procedure Allocate (Block : out Block_Number); -- Release the block number. procedure Release (Block : in Block_Number); function Is_Used (Block : in Block_Number) return Boolean; procedure Set_Header_Data (Index : in Header_Slot_Index_Type; Kind : in Header_Slot_Type; Data : in Ada.Streams.Stream_Element_Array; Sign : in Secret_Key); procedure Get_Header_Data (Index : in Header_Slot_Index_Type; Kind : out Header_Slot_Type; Data : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Add_Storage (Identifier : in Storage_Identifier; Sign : in Secret_Key); procedure Scan_Storage (Process : not null access procedure (Storage : in Wallet_Storage)); procedure Close; private File : Util.Streams.Raw.Raw_Stream; Current_Pos : Util.Systems.Types.off_t; Size : Block_Count; Data : IO_Block_Type; Free_Blocks : Block_Number_Sets.Set; Header : Wallet_Header; end File_Stream; type File_Stream_Access is access all File_Stream; function Hash (Value : Storage_Identifier) return Ada.Containers.Hash_Type; package File_Stream_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Storage_Identifier, Element_Type => File_Stream_Access, Hash => Hash, Equivalent_Keys => "=", "=" => "="); protected type Stream_Descriptor is procedure Open (Path : in String; Data_Path : in String; Sign : in Secret_Key); procedure Create (Path : in String; Data_Path : in String; Config : in Wallet_Config; Sign : in Secret_Key); procedure Add_Storage (Count : in Positive; Sign : in Secret_Key); procedure Get (Storage : in Storage_Identifier; File : out File_Stream_Access); procedure Allocate (Kind : in Block_Kind; Storage : out Storage_Identifier; File : out File_Stream_Access); procedure Close; private Random : Keystore.Random.Generator; Directory : Ada.Strings.Unbounded.Unbounded_String; UUID : UUID_Type; Files : File_Stream_Maps.Map; Alloc_Id : Storage_Identifier := DEFAULT_STORAGE_ID; Last_Id : Storage_Identifier := DEFAULT_STORAGE_ID; end Stream_Descriptor; type Wallet_Stream is limited new Ada.Finalization.Limited_Controlled and Keystore.IO.Wallet_Stream with record Descriptor : Stream_Descriptor; Sign : Secret_Key (Length => 32); end record; end Keystore.IO.Files;
-- --------------------------------------------------------------------------- -- -- -- BLACKBOARD constant and type definitions and management services -- -- -- -- --------------------------------------------------------------------------- with APEX.Processes; package APEX.Blackboards is Max_Number_Of_Blackboards : constant := System_Limit_Number_Of_Blackboards; subtype Blackboard_Name_Type is Name_Type; type Blackboard_Id_Type is private; Null_Blackboard_Id : constant Blackboard_Id_Type; type Empty_Indicator_Type is (Empty, Occupied); type Blackboard_Status_Type is record Empty_Indicator : Empty_Indicator_Type; Max_Message_Size : Message_Size_Type; Waiting_Processes : APEX.Processes.Waiting_Range_Type; end record; procedure Create_Blackboard (Blackboard_Name : in Blackboard_Name_Type; Max_Message_Size : in Message_Size_Type; Blackboard_Id : out Blackboard_Id_Type; Return_Code : out Return_Code_Type); procedure Display_Blackboard (Blackboard_Id : in Blackboard_Id_Type; Message_Addr : in Message_Addr_Type; Length : in Message_Size_Type; Return_Code : out Return_Code_Type); procedure Read_Blackboard (Blackboard_Id : in Blackboard_Id_Type; Time_Out : in System_Time_Type; Message_Addr : in Message_Addr_Type; -- The message address is passed IN, although the respective message is -- passed OUT Length : out Message_Size_Type; Return_Code : out Return_Code_Type); procedure Clear_Blackboard (Blackboard_Id : in Blackboard_Id_Type; Return_Code : out Return_Code_Type); procedure Get_Blackboard_Id (Blackboard_Name : in Blackboard_Name_Type; Blackboard_Id : out Blackboard_Id_Type; Return_Code : out Return_Code_Type); procedure Get_Blackboard_Status (Blackboard_Id : in Blackboard_Id_Type; Blackboard_Status : out Blackboard_Status_Type; Return_Code : out Return_Code_Type); private type Blackboard_Id_Type is new APEX_Integer; Null_Blackboard_Id : constant Blackboard_Id_Type := 0; pragma Convention (C, Empty_Indicator_Type); pragma Convention (C, Blackboard_Status_Type); -- POK BINDINGS pragma Import (C, Create_Blackboard, "CREATE_BLACKBOARD"); pragma Import (C, Display_Blackboard, "DISPLAY_BLACKBOARD"); pragma Import (C, Read_Blackboard, "READ_BLACKBOARD"); pragma Import (C, Clear_Blackboard, "CLEAR_BLACKBOARD"); pragma Import (C, Get_Blackboard_Id, "GET_BLACKBOARD_ID"); pragma Import (C, Get_Blackboard_Status, "GET_BLACKBOARD_STATUS"); -- END OF POK BINDINGS end APEX.Blackboards;
----------------------------------------------------------------------- -- util-texts-builders_tests -- Unit tests for text builders -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Text_IO; with Util.Test_Caller; with Util.Texts.Builders; with Util.Measures; package body Util.Texts.Builders_Tests is package String_Builder is new Util.Texts.Builders (Element_Type => Character, Input => String, Chunk_Size => 100); package Caller is new Util.Test_Caller (Test, "Texts.Builders"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Texts.Builders.Length", Test_Length'Access); Caller.Add_Test (Suite, "Test Util.Texts.Builders.Append", Test_Append'Access); Caller.Add_Test (Suite, "Test Util.Texts.Builders.Clear", Test_Clear'Access); Caller.Add_Test (Suite, "Test Util.Texts.Builders.Iterate", Test_Iterate'Access); Caller.Add_Test (Suite, "Test Util.Texts.Builders.Perf", Test_Perf'Access); end Add_Tests; -- ------------------------------ -- Test the length operation. -- ------------------------------ procedure Test_Length (T : in out Test) is B : String_Builder.Builder (10); begin Util.Tests.Assert_Equals (T, 0, String_Builder.Length (B), "Invalid length"); Util.Tests.Assert_Equals (T, 10, String_Builder.Capacity (B), "Invalid capacity"); end Test_Length; -- ------------------------------ -- Test the append operation. -- ------------------------------ procedure Test_Append (T : in out Test) is S : constant String := "0123456789"; B : String_Builder.Builder (3); begin String_Builder.Append (B, "a string"); Util.Tests.Assert_Equals (T, 8, String_Builder.Length (B), "Invalid length"); Util.Tests.Assert_Equals (T, "a string", String_Builder.To_Array (B), "Invalid content"); Util.Tests.Assert_Equals (T, 100 + 3, String_Builder.Capacity (B), "Invalid capacity"); -- Append new string and check content. String_Builder.Append (B, " b string"); Util.Tests.Assert_Equals (T, 17, String_Builder.Length (B), "Invalid length"); Util.Tests.Assert_Equals (T, "a string b string", String_Builder.To_Array (B), "Invalid content"); Util.Tests.Assert_Equals (T, 100 + 3, String_Builder.Capacity (B), "Invalid capacity"); String_Builder.Clear (B); for I in S'Range loop String_Builder.Append (B, S (I)); end loop; Util.Tests.Assert_Equals (T, 10, String_Builder.Length (B), "Invalid length"); Util.Tests.Assert_Equals (T, S, String_Builder.To_Array (B), "Invalid append"); end Test_Append; -- ------------------------------ -- Test the clear operation. -- ------------------------------ procedure Test_Clear (T : in out Test) is B : String_Builder.Builder (7); begin for I in 1 .. 10 loop String_Builder.Append (B, "a string"); end loop; Util.Tests.Assert_Equals (T, 8 * 10, String_Builder.Length (B), "Invalid length"); Util.Tests.Assert_Equals (T, 100 + 7, String_Builder.Capacity (B), "Invalid capacity"); String_Builder.Clear (B); Util.Tests.Assert_Equals (T, 0, String_Builder.Length (B), "Invalid length after clear"); Util.Tests.Assert_Equals (T, 7, String_Builder.Capacity (B), "Invalid capacity after clear"); end Test_Clear; -- ------------------------------ -- Test the iterate operation. -- ------------------------------ procedure Test_Iterate (T : in out Test) is procedure Process (S : in String); B : String_Builder.Builder (13); R : Ada.Strings.Unbounded.Unbounded_String; procedure Process (S : in String) is begin Ada.Strings.Unbounded.Append (R, S); end Process; begin for I in 1 .. 100 loop String_Builder.Append (B, "The Iterate procedure avoids the string copy " & "on the secondary stack"); end loop; String_Builder.Iterate (B, Process'Access); Util.Tests.Assert_Equals (T, String_Builder.Length (B), Ada.Strings.Unbounded.Length (R), "Invalid length in iterate string"); Util.Tests.Assert_Equals (T, String_Builder.To_Array (B), Ada.Strings.Unbounded.To_String (R), "Invalid Iterate"); end Test_Iterate; -- ------------------------------ -- Test the append and iterate performance. -- ------------------------------ procedure Test_Perf (T : in out Test) is Perf : Ada.Text_IO.File_Type; begin Ada.Text_IO.Create (File => Perf, Name => Util.Tests.Get_Test_Path ("string-append.csv")); Ada.Text_IO.Put_Line (Perf, "Block_Size,Append Time,To_Array Time,Iterate Time"); for Block_Size in 1 .. 300 loop declare B : String_Builder.Builder (10); N : constant String := Natural'Image (Block_Size * 10) & ","; begin String_Builder.Set_Block_Size (B, Block_Size * 10); declare S : Util.Measures.Stamp; begin for I in 1 .. 1000 loop String_Builder.Append (B, "some item"); end loop; Util.Measures.Report (S, Perf, N, Util.Measures.Microseconds); end; declare S : Util.Measures.Stamp; R : constant String := String_Builder.To_Array (B); begin Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); T.Assert (R'Length > 0, "Invalid string length"); end; declare Count : Natural := 0; procedure Process (Item : in String); procedure Process (Item : in String) is pragma Unreferenced (Item); begin Count := Count + 1; end Process; S : Util.Measures.Stamp; begin String_Builder.Iterate (B, Process'Access); Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); T.Assert (Count > 0, "The string builder was empty"); end; end; Ada.Text_IO.New_Line (Perf); end loop; Ada.Text_IO.Close (Perf); Ada.Text_IO.Create (File => Perf, Name => Util.Tests.Get_Test_Path ("string.csv")); Ada.Text_IO.Put_Line (Perf, "Size,Append (100),Append (512)," & "Append (1024),Unbounded,Iterate Time"); for I in 1 .. 4000 loop declare N : constant String := Natural'Image (I) & ","; B : String_Builder.Builder (10); B2 : String_Builder.Builder (10); B3 : String_Builder.Builder (10); U : Ada.Strings.Unbounded.Unbounded_String; S : Util.Measures.Stamp; begin for J in 1 .. I loop String_Builder.Append (B, "some item"); end loop; Util.Measures.Report (S, Perf, N, Util.Measures.Microseconds); String_Builder.Set_Block_Size (B2, 512); for J in 1 .. I loop String_Builder.Append (B2, "some item"); end loop; Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); String_Builder.Set_Block_Size (B3, 1024); for J in 1 .. I loop String_Builder.Append (B3, "some item"); end loop; Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); for J in 1 .. I loop Ada.Strings.Unbounded.Append (U, "some item"); end loop; Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); declare R : constant String := String_Builder.To_Array (B); pragma Unreferenced (R); begin Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); end; declare R : constant String := Ada.Strings.Unbounded.To_String (U); pragma Unreferenced (R); begin Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds); end; end; Ada.Text_IO.New_Line (Perf); end loop; end Test_Perf; end Util.Texts.Builders_Tests;
-- ************************************************************************************* -- -- The recipient is warned that this code should be handled in accordance -- with the HM Government Security Classification indicated throughout. -- -- This code and its contents shall not be used for other than UK Government -- purposes. -- -- The copyright in this code is the property of BAE SYSTEMS Electronic Systems Limited. -- The Code is supplied by BAE SYSTEMS on the express terms that it is to be treated in -- confidence and that it may not be copied, used or disclosed to others for any -- purpose except in accordance with DEFCON 91 (Edn 10/92). -- -- File Name: One_To_Many_Associative.adb -- Version: As detailed by ClearCase -- Version Date: As detailed by ClearCase -- Creation Date: 11-11-99 -- Security Classification: Unclassified -- Project: SRLE (Sting Ray Life Extension) -- Author: J Mann -- Section: Tactical Software/ Software Architecture -- Division: Underwater Systems Division -- Description: Generic implementation of 1-1:M relationship -- Comments: -- -- MODIFICATION RECORD -- -------------------- -- NAME DATE ECR No MODIFICATION -- -- jmm 11/11/99 008310/9SR056 Order of instance specification in Unlink is wrong. Reverse it. -- -- jmm 25/04/00 PILOT_0000_0325 Increase length of role to 32 characters for compatibility with -- type base_text_type. -- -- jmm 28/06/00 PILOT_0000_0423 Include diagnostic references. -- -- jmm 26/01/01 PILOT_0000_0701 Comment out a line which was erroneously left uncommented. -- -- db 09/08/01 PILOT_0000_1422 Illegal navigation should return null instance. -- -- DB 24/09/01 PILOT_0000_2473 Rename Link, Unlink & Unassociate parameters -- to match those for 1:1 type relationships, -- at the request of George. -- -- db 17/04/02 SRLE100003005 Correlated associative navigations supported. -- -- db 22/04/02 SRLE100002907 Procedure initialise removed as surplus to requirements -- -- db 09/05/02 SRLE100002899 Role phrase string is limited to 32 characters -- by calling routine, no checks necessary here. -- -- db 10/10/02 SRLE100003929 Remove exit condition from within Check_List_For_Multiple -- and Check_List_For_Associative and rearrange loop -- conditions accordingly. -- -- db 11/10/02 SRLE100003928 Remove null checks on source navigates and -- calls to log. -- -- DNS 20/05/15 CR 10265 For Navigate procedures returning a list, -- the Return is now an "in" parameter -- -- ************************************************************************************** with Application_Types; with Root_Object; use type Root_Object.Object_Access; use type Root_Object.Object_List.Node_Access_Type; with Ada.Tags; use type Ada.Tags.Tag; with Ada.Unchecked_Deallocation; package body One_To_Many_Associative is ------------------------------------------------------------------------ -- -- 'Minor' element -- type Relationship_Pair_Type; type Relationship_Pair_Access_Type is access all Relationship_Pair_Type; type Relationship_Pair_Type is record Multiple : Root_Object.Object_Access; Associative : Root_Object.Object_Access; Next : Relationship_Pair_Access_Type; Previous : Relationship_Pair_Access_Type; end record; procedure Remove_Pair is new Ada.Unchecked_Deallocation ( Relationship_Pair_Type, Relationship_Pair_Access_Type); -- -- 'Major' element -- type Relationship_Entry_Type; type Relationship_Entry_Access_Type is access all Relationship_Entry_Type; type Relationship_Entry_Type is record Single : Root_Object.Object_Access; Completion_List : Relationship_Pair_Access_Type; Next : Relationship_Entry_Access_Type; Previous : Relationship_Entry_Access_Type; end record; procedure Remove_Entry is new Ada.Unchecked_Deallocation ( Relationship_Entry_Type, Relationship_Entry_Access_Type); ------------------------------------------------------------------------ The_Relationship_List: Relationship_Entry_Access_Type; subtype Role_Phrase_Type is string (1 .. Application_Types.Maximum_Number_Of_Characters_In_String); Multiple_Side : Ada.Tags.Tag; Multiple_Side_Role : Role_Phrase_Type; Multiple_Side_Role_Length : Natural; Single_Side : Ada.Tags.Tag; Single_Side_Role : Role_Phrase_Type; Single_Side_Role_Length : Natural; Associative_Side : Ada.Tags.Tag; Associative_Side_Role : Role_Phrase_Type; Associative_Side_Role_Length : Natural; -- -- A = LEFT = MULTIPLE -- B = RIGHT = SINGLE -- ------------------------------------------------------------------------ procedure Check_List_For_Multiple ( Multiple_Instance : in Root_Object.Object_Access; Associative_Instance : out Root_Object.Object_Access; Single_Instance : out Root_Object.Object_Access; Multiple_Instance_Found : out Boolean) is Temp_Minor_Pointer : Relationship_Pair_Access_Type; Temp_Major_Pointer : Relationship_Entry_Access_Type; begin Multiple_Instance_Found := False; Temp_Major_Pointer := The_Relationship_List; Major_Loop: while (not Multiple_Instance_Found) and then Temp_Major_Pointer /= null loop Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List; Minor_Loop: while (not Multiple_Instance_Found) and then Temp_Minor_Pointer /= null loop Multiple_Instance_Found := (Temp_Minor_Pointer.Multiple = Multiple_Instance); if Multiple_Instance_Found then Associative_Instance := Temp_Minor_Pointer.Associative; Single_Instance := Temp_Major_Pointer.Single; else -- Prevent access if we have got what we are after -- Bailing out of the search loop is a neater solution, but test team defects -- have been raised against this sort of thing. Temp_Minor_Pointer := Temp_Minor_Pointer.Next; end if; end loop Minor_Loop; -- Prevent the possibility that the next entry in the major queue is null causing an access error if not Multiple_Instance_Found then Temp_Major_Pointer := Temp_Major_Pointer.Next; end if; end loop Major_Loop; end Check_List_For_Multiple; ------------------------------------------------------------------------ procedure Check_List_For_Associative ( Associative_Instance : in Root_Object.Object_Access; Multiple_Instance : out Root_Object.Object_Access; Single_Instance : out Root_Object.Object_Access; Associative_Instance_Found : out Boolean) is Temp_Minor_Pointer : Relationship_Pair_Access_Type; Temp_Major_Pointer : Relationship_Entry_Access_Type; begin Associative_Instance_Found := False; Temp_Major_Pointer := The_Relationship_List; Major_Loop: while (not Associative_Instance_Found) and then Temp_Major_Pointer /= null loop Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List; Minor_Loop: while (not Associative_Instance_Found) and then Temp_Minor_Pointer /= null loop Associative_Instance_Found := (Temp_Minor_Pointer.Associative = Associative_Instance); if Associative_Instance_Found then Multiple_Instance := Temp_Minor_Pointer.Multiple; Single_Instance := Temp_Major_Pointer.Single; else -- Prevent access if we have got what we are after -- Bailing out of the search loop is a neater solution, but test team defects -- have been raised against this sort of thing. Temp_Minor_Pointer := Temp_Minor_Pointer.Next; end if; end loop Minor_Loop; -- Prevent the possibility that the next entry in the major queue is null causing an access error if not Associative_Instance_Found then Temp_Major_Pointer := Temp_Major_Pointer.Next; end if; end loop Major_Loop; end Check_List_For_Associative; ----------------------------------------------------------------------- procedure Do_Link ( Multiple_Instance : in Root_Object.Object_Access; Single_Instance : in Root_Object.Object_Access; Associative_Instance : in Root_Object.Object_Access) is Temp_Minor_Pointer : Relationship_Pair_Access_Type; Temp_Major_Pointer : Relationship_Entry_Access_Type; Found : Boolean := False; begin Temp_Major_Pointer := The_Relationship_List; while (not Found) and then Temp_Major_Pointer /= null loop Found := (Temp_Major_Pointer.Single = Single_Instance); if not Found then -- grab the next item Temp_Major_Pointer := Temp_Major_Pointer.Next; end if; end loop; if not Found then Temp_Major_Pointer := new Relationship_Entry_Type; Temp_Major_Pointer.Single := Single_Instance; Temp_Major_Pointer.Completion_List := null; Temp_Major_Pointer.Previous := null; Temp_Major_Pointer.Next := The_Relationship_List; if The_Relationship_List /= null then The_Relationship_List.Previous := Temp_Major_Pointer; end if; The_Relationship_List := Temp_Major_Pointer; end if; Temp_Minor_Pointer := new Relationship_Pair_Type; Temp_Minor_Pointer.Multiple := Multiple_Instance; Temp_Minor_Pointer.Associative := Associative_Instance; Temp_Minor_Pointer.Previous := null; Temp_Minor_Pointer.Next := Temp_Major_Pointer.Completion_List; if Temp_Major_Pointer.Completion_List /= null then Temp_Major_Pointer.Completion_List.Previous := Temp_Minor_Pointer; end if; Temp_Major_Pointer.Completion_List := Temp_Minor_Pointer; end Do_Link; ----------------------------------------------------------------------- procedure Do_Unlink ( Left_Instance : in Root_Object.Object_Access; Right_Instance : in Root_Object.Object_Access) is Temp_Minor_Pointer : Relationship_Pair_Access_Type; Temp_Major_Pointer : Relationship_Entry_Access_Type; Delete_List : Boolean := False; begin Temp_Major_Pointer := The_Relationship_List; Major_Loop: while Temp_Major_Pointer /= null loop if Temp_Major_Pointer.Single = Left_Instance then Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List; Minor_Loop: while Temp_Minor_Pointer /= null loop if Temp_Minor_Pointer.Multiple = Right_Instance then if Temp_Minor_Pointer.Previous = null then -- -- first instance in list -- Temp_Major_Pointer.Completion_List := Temp_Minor_Pointer.Next; -- -- it's also the last and only instance in list -- So we're going to delete the whole relationship instance -- (but not just yet) -- Delete_List := (Temp_Minor_Pointer.Next = null); end if; if Temp_Minor_Pointer.Next /= null then -- -- there are more instances following in the list -- Temp_Minor_Pointer.Next.Previous := Temp_Minor_Pointer.Previous; end if; if Temp_Minor_Pointer.Previous /= null then -- -- there are more instances previous in the list -- Temp_Minor_Pointer.Previous.Next := Temp_Minor_Pointer.Next; end if; Remove_Pair (Temp_Minor_Pointer); exit Major_Loop; end if; Temp_Minor_Pointer := Temp_Minor_Pointer.Next; end loop Minor_Loop; end if; Temp_Major_Pointer := Temp_Major_Pointer.Next; end loop Major_Loop; -- -- if needed, now delete the list -- the same logic applies -- if Delete_List then if Temp_Major_Pointer.Previous = null then -- -- first instance in list -- The_Relationship_List := Temp_Major_Pointer.Next; end if; if Temp_Major_Pointer.Next /= null then -- -- there are more instances following in the list -- Temp_Major_Pointer.Next.Previous := Temp_Major_Pointer.Previous; end if; if Temp_Major_Pointer.Previous /= null then -- -- there are more instances previous in the list -- Temp_Major_Pointer.Previous.Next := Temp_Major_Pointer.Next; end if; Remove_Entry (Temp_Major_Pointer); end if; end Do_Unlink; ------------------------------------------------------------------------- procedure Register_Multiple_End_Class (Multiple_Instance : in Ada.Tags.Tag) is begin Multiple_Side := Multiple_Instance; end Register_Multiple_End_Class; --------------------------------------------------------------------- procedure Register_Multiple_End_Role (Multiple_Role : in String) is begin Multiple_Side_Role (1 .. Multiple_Role'Length) := Multiple_Role; Multiple_Side_Role_Length := Multiple_Role'Length; end Register_Multiple_End_Role; --------------------------------------------------------------------- procedure Register_Single_End_Class (Single_Instance : in Ada.Tags.Tag) is begin Single_Side := Single_Instance; end Register_Single_End_Class; --------------------------------------------------------------------- procedure Register_Single_End_Role (Single_Role : in String) is begin Single_Side_Role (1..Single_Role'Length) := Single_Role; Single_Side_Role_Length := Single_Role'Length; end Register_Single_End_Role; --------------------------------------------------------------------- procedure Register_Associative_End_Class (Associative_Instance : in Ada.Tags.Tag) is begin Associative_Side := Associative_Instance; end Register_Associative_End_Class; --------------------------------------------------------------------- procedure Register_Associative_End_Role (Associative_Role : in String) is begin Associative_Side_Role (1 .. Associative_Role'Length) := Associative_Role; Associative_Side_Role_Length := Associative_Role'Length; end Register_Associative_End_Role; --------------------------------------------------------------------- procedure Link ( A_Instance : in Root_Object.Object_Access; B_Instance : in Root_Object.Object_Access; Using : in Root_Object.Object_Access) is begin if Using.all'Tag = Associative_Side then if A_Instance.all'Tag = Multiple_Side then Do_Link ( Multiple_Instance => A_Instance, Single_Instance => B_Instance, Associative_Instance => Using); -- -- PILOT_0000_0423 Include diagnostic references. -- Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships + 1; elsif A_Instance.all'Tag = Single_Side then Do_Link ( Multiple_Instance => B_Instance, Single_Instance => A_Instance, Associative_Instance => Using); -- -- PILOT_0000_0423 Include diagnostic references. -- Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships + 1; end if; end if; -- Using.all'tag /= Associative_Side end Link; ----------------------------------------------------------------------- procedure Unassociate ( A_Instance : in Root_Object.Object_Access; B_Instance : in Root_Object.Object_Access; From : in Root_Object.Object_Access) is begin null; end Unassociate; ----------------------------------------------------------------------- procedure Unlink ( A_Instance : in Root_Object.Object_Access; B_Instance : in Root_Object.Object_Access) is begin if A_Instance.all'Tag = Multiple_Side then Do_Unlink ( Left_Instance => B_Instance, Right_Instance => A_Instance); -- -- PILOT_0000_0423 Include diagnostic references. -- Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships - 1; elsif A_Instance.all'Tag = Single_Side then -- Do_Unlink ( Left_Instance => A_Instance, Right_Instance => B_Instance); -- -- PILOT_0000_0423 Include diagnostic references. -- Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships - 1; end if; end Unlink; ----------------------------------------------------------------------- procedure Navigate ( From : in Root_Object.Object_List.List_Header_Access_Type; Class : in Ada.Tags.Tag; To : in Root_Object.Object_List.List_Header_Access_Type) is Source_Instance: Root_Object.Object_Access; Temp_Node: Root_Object.Object_List.Node_Access_Type; Temp_Instance: Root_Object.Object_Access; --Temp_Single: Root_Object.Object_Access; --Temp_Associative: Root_Object.Object_Access; --Temp_Multiple: Root_Object.Object_Access; begin Temp_Node := Root_Object.Object_List.First_Entry_Of (From); while Temp_Node /= null loop Source_Instance := Temp_Node.Item; if Source_Instance.all'Tag = Multiple_Side then Navigate ( From => Source_Instance, Class => Class, To => Temp_Instance); if Temp_Instance /= null then Root_Object.Object_List.Insert ( New_Item => Temp_Instance, On_To => To ); end if; -- elsif Source_Instance.all'Tag = Single_Side then Navigate ( From => Source_Instance, Class => Class, To => To); -- elsif Source_Instance.all'Tag = Associative_Side then Navigate ( From => Source_Instance, Class => Class, To => Temp_Instance); if Temp_Instance /= null then Root_Object.Object_List.Insert ( New_Item => Temp_Instance, On_To => To ); end if; -- end if; Temp_Node := Root_Object.Object_List.Next_Entry_Of (From); end loop; end Navigate; ----------------------------------------------------------------------- procedure Navigate ( From : in Root_Object.Object_Access; Class : in Ada.Tags.Tag; To : out Root_Object.Object_Access) is -- -- navigate from a single to a single -- valid for: -- A -> M -- A -> S -- M -> S -- M -> A -- Temp_Single: Root_Object.Object_Access; Temp_Associative: Root_Object.Object_Access; Temp_Multiple: Root_Object.Object_Access; Found: Boolean; begin -- PILOT_0000_1422 -- Defaulting the return parameter ensures that if an attempt -- is made to navigate this type of one to many associative -- without having linked it, the correct null parameter is -- returned. This relationship mechanism relies on the link -- operation to sort out all the tags. We can't rely on that -- happening in all cases. To := null; if From.all'Tag = Multiple_Side then -- Check_List_For_Multiple ( Multiple_Instance => From, Associative_Instance => Temp_Associative, Single_Instance => Temp_Single, Multiple_Instance_Found => Found); if Found then -- if Class = Single_Side then To := Temp_Single; elsif Class = Associative_Side then To := Temp_Associative; end if; -- end if; -- elsif From.all'Tag = Associative_Side then Check_List_For_Associative ( Associative_Instance => From, Multiple_Instance => Temp_Multiple, Single_Instance => Temp_Single, Associative_Instance_Found => Found); if Found then -- if Class = Single_Side then To := Temp_Single; elsif Class = Multiple_Side then To := Temp_Multiple; end if; end if; end if; end Navigate; --------------------------------------------------------------------- procedure Navigate ( From : in Root_Object.Object_Access; Class : in Ada.Tags.Tag; To : in Root_Object.Object_List.List_Header_Access_Type) is -- -- navigate from a single to a set -- valid for: -- S -> M -- S -> A -- Temp_Minor_Pointer: Relationship_Pair_Access_Type; Temp_Major_Pointer: Relationship_Entry_Access_Type; begin if From.all'Tag = Single_Side then Temp_Major_Pointer := The_Relationship_List; Major_Loop: while Temp_Major_Pointer /= null loop if Temp_Major_Pointer.Single = From then Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List; Minor_Loop: while Temp_Minor_Pointer /= null loop if Class = Multiple_Side then Root_Object.Object_List.Insert ( New_Item => Temp_Minor_Pointer.Multiple, On_To => To); elsif Class = Associative_Side then Root_Object.Object_List.Insert ( New_Item => Temp_Minor_Pointer.Associative, On_To => To); end if; Temp_Minor_Pointer := Temp_Minor_Pointer.Next; end loop Minor_Loop; exit Major_Loop; end if; Temp_Major_Pointer := Temp_Major_Pointer.Next; end loop Major_Loop; -- end if; end Navigate; ------------------------------------------------------------------------ -- associative correlated navigation procedure Navigate ( From : in Root_Object.Object_Access; Also : in Root_Object.Object_Access; Class : in Ada.Tags.Tag; To : out Root_Object.Object_Access) is -- navigate from two singles to a single -- valid for: -- M and S -> A -- S and M -> A Temp_Single, Single_Side_Source , Multiple_Side_Source, Temp_Associative_Multiple, Temp_Associative_Single : Root_Object.Object_Access := null; Assoc_Set : Root_Object.Object_List.List_Header_Access_Type := Root_Object.Object_List.Initialise; Found, Tags_Correct : Boolean := FALSE; begin -- Reset the output pointer to null so that if we don't find anything -- useful, the caller can check for it. To := null; Tags_Correct := ((( From.all'Tag = Multiple_Side) and then ( Also.all'Tag = Single_Side)) or else ((( From.all'Tag = Single_Side) and then ( Also.all'Tag = Multiple_Side)))) ; if Tags_Correct then if From.all'Tag = Multiple_Side then Multiple_Side_Source := From; Single_Side_Source := Also; else Multiple_Side_Source := Also; Single_Side_Source := From; end if; -- Do the navigations now, all is correct. -- Navigate from multiple side to associative side. Check_List_For_Multiple ( Multiple_Instance => Multiple_Side_Source, Associative_Instance => Temp_Associative_Multiple, Single_Instance => Temp_Single, Multiple_Instance_Found => Found); -- Navigate from single side to associative side. if Found then -- do the navigation declare Input_List : Root_Object.Object_List.List_Header_Access_Type; begin Input_List := Root_Object.Object_List.Initialise; Root_Object.Object_List.Clear(Assoc_Set); Root_Object.Object_List.Insert ( New_Item => Single_Side_Source, On_To => Input_List); Navigate( From => Input_List, Class => Class, To => Assoc_Set); Root_Object.Object_List.Destroy_List(Input_List); end; -- Extract out the instance from the set by looping through the -- set and looking for a match with the instance found from the -- multiple side navigation. declare use type Root_Object.Object_List.Node_Access_Type; Temp_Entry : Root_Object.Object_List.Node_Access_Type; begin -- Grab the first entry of the set Temp_Entry := Root_Object.Object_List.First_Entry_Of(Assoc_Set); -- While the set is not empty, and the entry does not match the -- assoc instance already found, loop while (Temp_Entry /= null) and then (Temp_Associative_Single /= Temp_Associative_Multiple) loop Temp_Associative_Single := Temp_Entry.Item; Temp_Entry := Root_Object.Object_List.Next_Entry_Of(Assoc_Set); end loop; end; if Temp_Associative_Single = Temp_Associative_Multiple then To := Temp_Associative_Single; end if; end if; end if; end Navigate; ----------------------------------------------------------------------- end One_To_Many_Associative;
with Ada.Containers.Vectors; with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Sockets; use Sockets; procedure Chat_Server is package Client_Vectors is new Ada.Containers.Vectors (Element_Type => Socket_FD, Index_Type => Positive); All_Clients : Client_Vectors.Vector; procedure Write (S : String) is procedure Output (Position : Client_Vectors.Cursor) is Sock : Socket_FD := Client_Vectors.Element (Position); begin Put_Line (Sock, S); end Output; begin All_Clients.Iterate (Output'Access); end Write; task type Client_Task is entry Start (FD : Socket_FD); end Client_Task; task body Client_Task is Sock : Socket_FD; Sock_ID : Positive; Name : Unbounded_String; begin select accept Start (FD : Socket_FD) do Sock := FD; end Start; or terminate; end select; while Name = Null_Unbounded_String loop Put (Sock, "Enter Name:"); Name := To_Unbounded_String (Get_Line (Sock)); end loop; Write (To_String (Name) & " joined."); All_Clients.Append (Sock); Sock_ID := All_Clients.Find_Index (Sock); loop declare Input : String := Get_Line (Sock); begin Write (To_String (Name) & ": " & Input); end; end loop; exception when Connection_Closed => Put_Line ("Connection closed"); Shutdown (Sock, Both); All_Clients.Delete (Sock_ID); Write (To_String (Name) & " left."); end Client_Task; Accepting_Socket : Socket_FD; Incoming_Socket : Socket_FD; type Client_Access is access Client_Task; Dummy : Client_Access; begin if Argument_Count /= 1 then Raise_Exception (Constraint_Error'Identity, "Usage: " & Command_Name & " port"); end if; Socket (Accepting_Socket, PF_INET, SOCK_STREAM); Setsockopt (Accepting_Socket, SOL_SOCKET, SO_REUSEADDR, 1); Bind (Accepting_Socket, Positive'Value (Argument (1))); Listen (Accepting_Socket); loop Put_Line ("Waiting for new connection"); Accept_Socket (Accepting_Socket, Incoming_Socket); Put_Line ("New connection acknowledged"); Dummy := new Client_Task; Dummy.Start (Incoming_Socket); end loop; end Chat_Server;
with FLTK.Widgets.Groups.Windows; private with Interfaces.C; package FLTK.Static is type Awake_Handler is access procedure; type Timeout_Handler is access procedure; type Idle_Handler is access procedure; type Buffer_Kind is (Selection, Clipboard); type Clipboard_Notify_Handler is access procedure (Kind : in Buffer_Kind); type File_Descriptor is new Integer; type File_Mode is (Read, Write, Except); type File_Handler is access procedure (FD : in File_Descriptor); type Box_Draw_Function is access procedure (X, Y, W, H : in Integer; My_Color : in Color); type Option is (Arrow_Focus, Visible_Focus, DND_Text, Show_Tooltips, FNFC_Uses_GTK, Last); procedure Add_Awake_Handler (Func : in Awake_Handler); function Get_Awake_Handler return Awake_Handler; procedure Add_Check (Func : in Timeout_Handler); function Has_Check (Func : in Timeout_Handler) return Boolean; procedure Remove_Check (Func : in Timeout_Handler); procedure Add_Timeout (Seconds : in Long_Float; Func : in Timeout_Handler); function Has_Timeout (Func : in Timeout_Handler) return Boolean; procedure Remove_Timeout (Func : in Timeout_Handler); procedure Repeat_Timeout (Seconds : in Long_Float; Func : in Timeout_Handler); procedure Add_Clipboard_Notify (Func : in Clipboard_Notify_Handler); procedure Remove_Clipboard_Notify (Func : in Clipboard_Notify_Handler); procedure Add_File_Descriptor (FD : in File_Descriptor; Func : in File_Handler); procedure Add_File_Descriptor (FD : in File_Descriptor; Mode : in File_Mode; Func : in File_Handler); procedure Remove_File_Descriptor (FD : in File_Descriptor); procedure Remove_File_Descriptor (FD : in File_Descriptor; Mode : in File_Mode); procedure Add_Idle (Func : in Idle_Handler); function Has_Idle (Func : in Idle_Handler) return Boolean; procedure Remove_Idle (Func : in Idle_Handler); procedure Get_Color (From : in Color; R, G, B : out Color_Component); procedure Set_Color (To : in Color; R, G, B : in Color_Component); procedure Free_Color (Value : in Color; Overlay : in Boolean := False); procedure Own_Colormap; procedure Set_Foreground (R, G, B : in Color_Component); procedure Set_Background (R, G, B : in Color_Component); procedure Set_Alt_Background (R, G, B : in Color_Component); procedure System_Colors; function Font_Image (Kind : in Font_Kind) return String; function Font_Family_Image (Kind : in Font_Kind) return String; procedure Set_Font_Kind (To, From : in Font_Kind); function Font_Sizes (Kind : in Font_Kind) return Font_Size_Array; procedure Setup_Fonts (How_Many_Set_Up : out Natural); function Get_Box_Height_Offset (Kind : in Box_Kind) return Integer; function Get_Box_Width_Offset (Kind : in Box_Kind) return Integer; function Get_Box_X_Offset (Kind : in Box_Kind) return Integer; function Get_Box_Y_Offset (Kind : in Box_Kind) return Integer; procedure Set_Box_Kind (To, From : in Box_Kind); function Draw_Box_Active return Boolean; -- function Get_Box_Draw_Function -- (Kind : in Box_Kind) -- return Box_Draw_Function; -- procedure Set_Box_Draw_Function -- (Kind : in Box_Kind; -- Func : in Box_Draw_Function; -- Offset_X, Offset_Y : in Integer := 0; -- Offset_W, Offset_H : in Integer := 0); procedure Copy (Text : in String; Dest : in Buffer_Kind); procedure Paste (Receiver : in FLTK.Widgets.Widget'Class; Source : in Buffer_Kind); procedure Selection (Owner : in FLTK.Widgets.Widget'Class; Text : in String); procedure Drag_Drop_Start; function Get_Drag_Drop_Text_Support return Boolean; procedure Set_Drag_Drop_Text_Support (To : in Boolean); procedure Enable_System_Input; procedure Disable_System_Input; function Has_Visible_Focus return Boolean; procedure Set_Visible_Focus (To : in Boolean); procedure Default_Window_Close (Item : in out FLTK.Widgets.Widget'Class); function Get_First_Window return access FLTK.Widgets.Groups.Windows.Window'Class; procedure Set_First_Window (To : in FLTK.Widgets.Groups.Windows.Window'Class); function Get_Next_Window (From : in FLTK.Widgets.Groups.Windows.Window'Class) return access FLTK.Widgets.Groups.Windows.Window'Class; function Get_Top_Modal return access FLTK.Widgets.Groups.Windows.Window'Class; function Read_Queue return access FLTK.Widgets.Widget'Class; procedure Do_Widget_Deletion; function Get_Scheme return String; procedure Set_Scheme (To : in String); function Is_Scheme (Scheme : in String) return Boolean; procedure Reload_Scheme; function Get_Option (Opt : in Option) return Boolean; procedure Set_Option (Opt : in Option; To : in Boolean); function Get_Default_Scrollbar_Size return Natural; procedure Set_Default_Scrollbar_Size (To : in Natural); private File_Mode_Codes : array (File_Mode) of Interfaces.C.int := (Read => 1, Write => 4, Except => 8); pragma Import (C, Own_Colormap, "fl_static_own_colormap"); pragma Import (C, System_Colors, "fl_static_get_system_colors"); pragma Import (C, Drag_Drop_Start, "fl_static_dnd"); pragma Import (C, Enable_System_Input, "fl_static_enable_im"); pragma Import (C, Disable_System_Input, "fl_static_disable_im"); pragma Import (C, Do_Widget_Deletion, "fl_static_do_widget_deletion"); pragma Import (C, Reload_Scheme, "fl_static_reload_scheme"); pragma Inline (Add_Awake_Handler); pragma Inline (Get_Awake_Handler); pragma Inline (Add_Check); pragma Inline (Has_Check); pragma Inline (Remove_Check); pragma Inline (Add_Timeout); pragma Inline (Has_Timeout); pragma Inline (Remove_Timeout); pragma Inline (Repeat_Timeout); pragma Inline (Add_Clipboard_Notify); pragma Inline (Remove_Clipboard_Notify); pragma Inline (Add_File_Descriptor); pragma Inline (Remove_File_Descriptor); pragma Inline (Add_Idle); pragma Inline (Has_Idle); pragma Inline (Remove_Idle); pragma Inline (Get_Color); pragma Inline (Set_Color); pragma Inline (Free_Color); pragma Inline (Own_Colormap); pragma Inline (Set_Foreground); pragma Inline (Set_Background); pragma Inline (Set_Alt_Background); pragma Inline (System_Colors); pragma Inline (Font_Image); pragma Inline (Font_Family_Image); pragma Inline (Set_Font_Kind); pragma Inline (Font_Sizes); pragma Inline (Setup_Fonts); pragma Inline (Get_Box_Height_Offset); pragma Inline (Get_Box_Width_Offset); pragma Inline (Get_Box_X_Offset); pragma Inline (Get_Box_Y_Offset); pragma Inline (Set_Box_Kind); pragma Inline (Draw_Box_Active); -- pragma Inline (Get_Box_Draw_Function); -- pragma Inline (Set_Box_Draw_Function); pragma Inline (Copy); pragma Inline (Paste); pragma Inline (Selection); pragma Inline (Drag_Drop_Start); pragma Inline (Get_Drag_Drop_Text_Support); pragma Inline (Set_Drag_Drop_Text_Support); pragma Inline (Enable_System_Input); pragma Inline (Disable_System_Input); pragma Inline (Has_Visible_Focus); pragma Inline (Set_Visible_Focus); pragma Inline (Default_Window_Close); pragma Inline (Get_First_Window); pragma Inline (Set_First_Window); pragma Inline (Get_Next_Window); pragma Inline (Get_Top_Modal); pragma Inline (Read_Queue); pragma Inline (Do_Widget_Deletion); pragma Inline (Get_Scheme); pragma Inline (Set_Scheme); pragma Inline (Is_Scheme); pragma Inline (Reload_Scheme); pragma Inline (Get_Option); pragma Inline (Set_Option); pragma Inline (Get_Default_Scrollbar_Size); pragma Inline (Set_Default_Scrollbar_Size); end FLTK.Static;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . D E B U G _ P O O L 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. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Unchecked_Conversion; with GNAT.HTable; with System.Memory; pragma Elaborate_All (GNAT.HTable); package body GNAT.Debug_Pools is use System; use System.Memory; use System.Storage_Elements; -- Definition of a H-table storing the status of each storage chunck -- used by this pool type State is (Not_Allocated, Deallocated, Allocated); type Header is range 1 .. 1023; function H (F : Address) return Header; package Table is new GNAT.HTable.Simple_HTable ( Header_Num => Header, Element => State, No_Element => Not_Allocated, Key => Address, Hash => H, Equal => "="); -------------- -- Allocate -- -------------- procedure Allocate (Pool : in out Debug_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Count; Alignment : Storage_Count) is begin Storage_Address := Alloc (size_t (Size_In_Storage_Elements)); if Storage_Address = Null_Address then raise Storage_Error; else Table.Set (Storage_Address, Allocated); Pool.Allocated := Pool.Allocated + Size_In_Storage_Elements; if Pool.Allocated - Pool.Deallocated > Pool.High_Water then Pool.High_Water := Pool.Allocated - Pool.Deallocated; end if; end if; end Allocate; ---------------- -- Deallocate -- ---------------- procedure Deallocate (Pool : in out Debug_Pool; Storage_Address : Address; Size_In_Storage_Elements : Storage_Count; Alignment : Storage_Count) is procedure Free (Address : System.Address; Siz : Storage_Count); -- Faked free, that reset all the deallocated storage to "DEADBEEF" procedure Free (Address : System.Address; Siz : Storage_Count) is DB1 : constant Integer := 16#DEAD#; DB2 : constant Integer := 16#BEEF#; type Dead_Memory is array (1 .. Siz / 4) of Integer; type Mem_Ptr is access all Dead_Memory; function From_Ptr is new Unchecked_Conversion (System.Address, Mem_Ptr); J : Storage_Offset; begin J := Dead_Memory'First; while J < Dead_Memory'Last loop From_Ptr (Address) (J) := DB1; From_Ptr (Address) (J + 1) := DB2; J := J + 2; end loop; if J = Dead_Memory'Last then From_Ptr (Address) (J) := DB1; end if; end Free; S : State := Table.Get (Storage_Address); -- Start of processing for Deallocate begin case S is when Not_Allocated => raise Freeing_Not_Allocated_Storage; when Deallocated => raise Freeing_Deallocated_Storage; when Allocated => Free (Storage_Address, Size_In_Storage_Elements); Table.Set (Storage_Address, Deallocated); Pool.Deallocated := Pool.Deallocated + Size_In_Storage_Elements; end case; end Deallocate; ----------------- -- Dereference -- ----------------- procedure Dereference (Pool : in out Debug_Pool; Storage_Address : Address; Size_In_Storage_Elements : Storage_Count; Alignment : Storage_Count) is S : State := Table.Get (Storage_Address); Max_Dim : constant := 3; Dim : Integer := 1; begin -- If this is not a known address, maybe it is because is is an -- unconstained array. In which case, the bounds have used the -- 2 first words (per dimension) of the allocated spot. while S = Not_Allocated and then Dim <= Max_Dim loop S := Table.Get (Storage_Address - Storage_Offset (Dim * 2 * 4)); Dim := Dim + 1; end loop; case S is when Not_Allocated => raise Accessing_Not_Allocated_Storage; when Deallocated => raise Accessing_Deallocated_Storage; when Allocated => null; end case; end Dereference; ------- -- H -- ------- function H (F : Address) return Header is begin return Header (1 + (To_Integer (F) mod Integer_Address (Header'Last))); end H; ---------------- -- Print_Info -- ---------------- procedure Print_Info (Pool : Debug_Pool) is use System.Storage_Elements; begin Put_Line ("Debug Pool info:"); Put_Line (" Total allocated bytes : " & Storage_Offset'Image (Pool.Allocated)); Put_Line (" Total deallocated bytes : " & Storage_Offset'Image (Pool.Deallocated)); Put_Line (" Current Water Mark: " & Storage_Offset'Image (Pool.Allocated - Pool.Deallocated)); Put_Line (" High Water Mark: " & Storage_Offset'Image (Pool.High_Water)); Put_Line (""); end Print_Info; ------------------ -- Storage_Size -- ------------------ function Storage_Size (Pool : Debug_Pool) return Storage_Count is begin return Storage_Count'Last; end Storage_Size; end GNAT.Debug_Pools;
-- Standard Ada library specification -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Real_Time; with Ada.Task_Identification; package System.Multiprocessors.Dispatching_Domains is Dispatching_Domain_Error : exception; type Dispatching_Domain (<>) is limited private; System_Dispatching_Domain : constant Dispatching_Domain; function Create (First : CPU; Last : CPU_Range) return Dispatching_Domain; function Get_First_CPU (Domain : Dispatching_Domain) return CPU; function Get_Last_CPU (Domain : Dispatching_Domain) return CPU_Range; type CPU_Set is array(CPU range <>) of Boolean; function Create (Set : CPU_Set) return Dispatching_Domain; function Get_CPU_Set (Domain : Dispatching_Domain) return CPU_Set; function Get_Dispatching_Domain (T : Ada.Task_Identification.Task_Id := Ada.Task_Identification.Current_Task) return Dispatching_Domain; procedure Assign_Task (Domain : in out Dispatching_Domain; CPU : in CPU_Range := Not_A_Specific_CPU; T : in Ada.Task_Identification.Task_Id := Ada.Task_Identification.Current_Task); procedure Set_CPU (CPU : in CPU_Range; T : in Ada.Task_Identification.Task_Id := Ada.Task_Identification.Current_Task); function Get_CPU (T : Ada.Task_Identification.Task_Id := Ada.Task_Identification.Current_Task) return CPU_Range; procedure Delay_Until_And_Set_CPU (Delay_Until_Time : in Ada.Real_Time.Time; CPU : in CPU_Range); private -- not specified by the language end System.Multiprocessors.Dispatching_Domains;
--PRÁCTICA 2: César Borao Moratinos (chat_admin) with Ada.Text_IO; with Chat_Messages; with Lower_Layer_UDP; with Ada.Command_Line; with Client_Collections; with Ada.Strings.Unbounded; procedure Chat_Admin is package ATI renames Ada.Text_IO; package CM renames Chat_Messages; package LLU renames Lower_Layer_UDP; package ACL renames Ada.Command_Line; package CC renames Client_Collections; package ASU renames Ada.Strings.Unbounded; use type CM.Message_Type; Server_Host: ASU.Unbounded_String; Server_Port: Integer; Server_IP: ASU.Unbounded_String; Password: ASU.Unbounded_String; Option: Integer; Mess: CM.Message_Type; Nick: ASU.Unbounded_String; Buffer: aliased LLU.Buffer_Type(1024); Admin_EP: LLU.End_Point_Type; Server_EP: LLU.End_Point_Type; Expired: Boolean; Data: ASU.Unbounded_String; Incorrect_Pass: Boolean; begin Server_Host := ASU.To_Unbounded_String(ACL.Argument(1)); Server_Port := Integer'Value(ACL.Argument(2)); Password := ASU.To_Unbounded_String(ACL.Argument(3)); LLU.Bind_Any(Admin_EP); Server_IP := ASU.To_Unbounded_String(LLU.To_IP(ASU.To_String(Server_Host))); Server_EP := LLU.Build(ASU.To_String(Server_IP), Server_Port); Incorrect_Pass := False; loop ATI.Put_Line("Options"); ATI.Put_Line("1 Show writers collection"); ATI.Put_Line("2 Ban writer"); ATI.Put_Line("3 Shutdown Server"); ATI.Put_Line("4 Quit"); ATI.New_Line; ATI.Put("Your option? "); Option := Integer'Value(ATI.Get_Line); case Option is when 1 => Mess := CM.Collection_Request; --Collection Request Message CM.Message_Type'Output(Buffer'Access, Mess); LLU.End_Point_Type'Output(Buffer'Access, Admin_EP); ASU.Unbounded_String'Output(Buffer'Access, Password); LLU.Send(Server_EP, Buffer'Access); LLU.Reset(Buffer); LLU.Receive(Admin_EP, Buffer'Access, 5.0, Expired); if Expired then ATI.Put_Line("Incorrect password"); Incorrect_Pass := True; else Mess := CM.Message_Type'Input (Buffer'Access); Data := ASU.Unbounded_String'Input (Buffer'Access); ATI.Put_Line(ASU.To_String(Data)); end if; ATI.New_Line; LLU.Reset(Buffer); when 2 => Mess := CM.Ban; ATI.Put("Nick to ban? "); Nick := ASU.To_Unbounded_String(ATI.Get_Line); ATI.New_Line; --Ban Message CM.Message_Type'Output(Buffer'Access, Mess); ASU.Unbounded_String'Output(Buffer'Access, Password); ASU.Unbounded_String'Output(Buffer'Access, Nick); LLU.Send(Server_EP, Buffer'Access); LLU.Reset(Buffer); when 3 => Mess := CM.Shutdown; ATI.Put_Line("Server shutdown sent"); ATI.New_Line; --Shutdown Message CM.Message_Type'Output(Buffer'Access, Mess); ASU.Unbounded_String'Output(Buffer'Access, Password); LLU.Send(Server_EP, Buffer'Access); LLU.Reset(Buffer); when 4 => ATI.New_Line; when others => ATI.Put_Line("Not implemented"); end case; exit when Option = 4 or Incorrect_Pass; end loop; LLU.Finalize; end Chat_Admin;
-- MIT License -- -- Copyright (c) 2020 Max Reznik -- -- 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 Ada.Containers.Hashed_Maps; with Ada.Containers.Ordered_Sets; with Ada_Pretty; with League.Strings; with League.Strings.Hash; with Google.Protobuf.Descriptor; with Google.Protobuf.Compiler.Plugin; with PB_Support.Universal_String_Vectors; package Compiler.Context is Is_Proto_2 : Boolean := True; -- Proto version of current file Factory : aliased Ada_Pretty.Factory; -- Node factory for pretty printing generated sources package String_Sets is new Ada.Containers.Ordered_Sets (League.Strings.Universal_String, "<" => League.Strings."<", "=" => League.Strings."="); -- Set of strings Fake : String_Sets.Set; -- Set of id for each field that breaks circular usage. type Ada_Type_Name is record Package_Name : League.Strings.Universal_String; Type_Name : League.Strings.Universal_String; end record; function "+" (Self : Ada_Type_Name) return League.Strings.Universal_String; -- Join package name (if any) and type name into selected name. function Compound_Name (Self : Ada_Type_Name; Current_Package : League.Strings.Universal_String) return League.Strings.Universal_String; -- Join package name (if any) and type name using "_" for new identifiers. function Relative_Name (Full_Name : League.Strings.Universal_String; Current_Package : League.Strings.Universal_String) return League.Strings.Universal_String; -- Try to avoid wrong interpretation of selected Full_Name when it's -- used from Current_Package. Example: -- Full_Name => Conformance.Conformance.Type_Name -- Current_Package => Conformance.Conformance -- Result => Conformance.Type_Name type Enumeration_Information is record Min, Max : Integer; -- Minimum and maximum representation value Default : League.Strings.Universal_String; -- Default value end record; type Named_Type (Is_Enumeration : Boolean := False) is record Ada_Type : Ada_Type_Name; Optional_Type : League.Strings.Universal_String; -- Name of optional type, usually "Optional_" & Ada_Type.Type_Name case Is_Enumeration is when True => Enum : Enumeration_Information; when False => null; -- Message : Google.Protobuf.Descriptor_Proto; end case; end record; package Named_Type_Maps is new Ada.Containers.Hashed_Maps (League.Strings.Universal_String, Named_Type, League.Strings.Hash, League.Strings."="); Named_Types : Named_Type_Maps.Map; procedure Populate_Named_Types (Request : Google.Protobuf.Compiler.Plugin.Code_Generator_Request; Map : in out Compiler.Context.Named_Type_Maps.Map); -- Fill Map with type information found in Request function Get_File (Request : Google.Protobuf.Compiler.Plugin.Code_Generator_Request; Name : League.Strings.Universal_String) return Google.Protobuf.Descriptor.File_Descriptor_Proto; -- Find file by Name in the Request function To_Ada_Name (Text : League.Strings.Universal_String) return League.Strings.Universal_String; -- Convert text to look like an Ada Name function To_Selected_Ada_Name (Text : League.Strings.Universal_String) return League.Strings.Universal_String; -- Convert text to look like a selected Ada Name function Join (Prefix : League.Strings.Universal_String; Name : PB_Support.Universal_String_Vectors.Option) return League.Strings.Universal_String; -- Return "prefix . name" function New_Type_Name (Name : PB_Support.Universal_String_Vectors.Option; Default : League.Strings.Universal_String; Prefix : League.Strings.Universal_String; Local : Compiler.Context.Named_Type_Maps.Map; Used : Compiler.Context.String_Sets.Set) return League.Strings.Universal_String; function Is_Reserved_Word (Name : League.Strings.Universal_String) return Boolean; end Compiler.Context;
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Containers.Doubly_Linked_Lists; with Ada.Calendar.Formatting; with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Text_IO; procedure Tabula.Users.Lists.Dump ( Users_Directory : in not null Static_String_Access; Users_Log_File_Name : in not null Static_String_Access) is use type Ada.Strings.Unbounded.Unbounded_String; Input_File_Name : aliased Ada.Strings.Unbounded.Unbounded_String := +Users_Log_File_Name.all; type Item_Type is record Id : aliased Ada.Strings.Unbounded.Unbounded_String; Remote_Addr : aliased Ada.Strings.Unbounded.Unbounded_String; Remote_Host : aliased Ada.Strings.Unbounded.Unbounded_String; Time : Ada.Calendar.Time; end record; package Item_Lists is new Ada.Containers.Doubly_Linked_Lists (Item_Type); use Item_Lists; Items : aliased Item_Lists.List; begin if Ada.Command_Line.Argument_Count > 0 then Input_File_Name := +Ada.Command_Line.Argument (1); end if; declare use Ada.Text_IO; procedure Process ( Id : in String; Remote_Addr : in String; Remote_Host : in String; Time : in Ada.Calendar.Time) is begin Put (Id); Put (','); Put (Remote_Addr); Put (','); Put (Remote_Host); Put (','); Put (Ada.Calendar.Formatting.Image (Time)); New_Line; Append (Items, ( Id => +Id, Remote_Addr => +Remote_Addr, Remote_Host => +Remote_Host, Time => Time)); end Process; List : User_List := Create ( Directory => Users_Directory, Log_File_Name => Input_File_Name.Constant_Reference.Element); begin Iterate_Log (List, Process'Access); New_Line; end; if Items.Length >= 2 then for I in Items.Iterate (Items.First, Previous (Items.Last)) loop declare I_Ref : constant Item_Lists.Constant_Reference_Type := Items.Constant_Reference (I); begin for J in Items.Iterate (Next (I), Items.Last) loop declare use Ada.Text_IO; J_Ref : constant Item_Lists.Constant_Reference_Type := Items.Constant_Reference (J); begin if I_Ref.Remote_Addr = J_Ref.Remote_Addr or else ( I_Ref.Remote_Host = J_Ref.Remote_Host and then not J_Ref.Remote_Host.Is_Null) then Put (I_Ref.Id.Constant_Reference); Put (','); Put (I_Ref.Remote_Addr.Constant_Reference); Put (','); Put (I_Ref.Remote_Host.Constant_Reference); Put (','); Put (Ada.Calendar.Formatting.Image (I_Ref.Time)); New_Line; Put (J_Ref.Id.Constant_Reference); Put (','); Put (J_Ref.Remote_Addr.Constant_Reference); Put (','); Put (J_Ref.Remote_Host.Constant_Reference); Put (','); Put (Ada.Calendar.Formatting.Image (J_Ref.Time)); New_Line; end if; end; end loop; end; end loop; end if; end Tabula.Users.Lists.Dump;
with Ada.Text_IO; use Ada.Text_IO; procedure owo is begin Put_Line (" *Notices Bulge*"); Put_Line ("__ ___ _ _ _ _ _"); Put_Line ("\ \ / / |__ __ _| |_ ( ) ___ | |_| |__ (_) ___"); Put_Line (" \ \ /\ / /| '_ \ / _\`| __|// / __| | __| '_ \| |/ __|"); Put_Line (" \ V V / | | | | (_| | |_ \__ \ | |_| | | | |\__ \"); Put_Line (" \_/\_/ |_| |_|\__,_|\__| |___/ \___|_| |_|_|/___/"); end owo;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- I N T E R F A C E S . L E O N 3 . U A R T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2006 The European Space Agency -- -- Copyright (C) 2003-2018, 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. -- -- -- ------------------------------------------------------------------------------ with System.BB.Board_Parameters; package Interfaces.Leon3.Uart is pragma No_Elaboration_Code_All; pragma Preelaborate; -------------------- -- UART Registers -- -------------------- type Scaler_12 is mod 2 ** 12; for Scaler_12'Size use 12; -- 12-bit scaler type FIFO_Count is mod 64; for FIFO_Count'Size use 6; type Parity_Kind is (Even, Odd); type UART_Data_Register is record FIFO : Character; -- Reading and writing accesses receiver resp. transmitter FIFOs Reserved : Reserved_24; -- Not used r end record; for UART_Data_Register use record Reserved at 0 range Bit31 .. Bit08; FIFO at 0 range Bit07 .. Bit00; end record; for UART_Data_Register'Size use 32; pragma Suppress_Initialization (UART_Data_Register); type UART_Status_Register is record Data_Ready : Boolean; Transmitter_Shift_Register_Empty : Boolean; Transmitter_FIFO_Empty : Boolean; Break_Received : Boolean; Overrun : Boolean; Parity_Error : Boolean; Framing_Error : Boolean; Transmitter_FIFO_Half_Full : Boolean; Receiver_FIFO_Half_Full : Boolean; Transmitter_FIFO_Full : Boolean; Receiver_FIFO_Full : Boolean; Reserved : Reserved_9; Transmitter_FIFO_Count : FIFO_Count; Receiver_FIFO_Count : FIFO_Count; end record; for UART_Status_Register use record Receiver_FIFO_Count at 0 range Bit31 .. Bit26; Transmitter_FIFO_Count at 0 range Bit25 .. Bit20; Reserved at 0 range Bit19 .. Bit11; Receiver_FIFO_Full at 0 range Bit10 .. Bit10; Transmitter_FIFO_Full at 0 range Bit09 .. Bit09; Receiver_FIFO_Half_Full at 0 range Bit08 .. Bit08; Transmitter_FIFO_Half_Full at 0 range Bit07 .. Bit07; Framing_Error at 0 range Bit06 .. Bit06; Parity_Error at 0 range Bit05 .. Bit05; Overrun at 0 range Bit04 .. Bit04; Break_Received at 0 range Bit03 .. Bit03; Transmitter_FIFO_Empty at 0 range Bit02 .. Bit02; Transmitter_Shift_Register_Empty at 0 range Bit01 .. Bit01; Data_Ready at 0 range Bit00 .. Bit00; end record; for UART_Status_Register'Size use 32; pragma Suppress_Initialization (UART_Status_Register); pragma Volatile_Full_Access (UART_Status_Register); type UART_Control_Register is record Receiver_Enable : Boolean; Transmitter_Enable : Boolean; -- Transmitter enable Receiver_Interrupt_Enable : Boolean; Transmitter_Interrupt_Enable : Boolean; Parity_Select : Parity_Kind; Parity_Enable : Boolean; Reserved_1 : Boolean; Loop_Back : Boolean; Reserved_2 : Boolean; Receiver_FIFO_Interrupt_Enable : Boolean; Transmitter_FIFO_Interrupt_Enable : Boolean; Reserved_3 : Reserved_20; FIFO_Available : Boolean; end record; for UART_Control_Register use record FIFO_Available at 0 range Bit31 .. Bit31; Reserved_3 at 0 range Bit30 .. Bit11; Receiver_FIFO_Interrupt_Enable at 0 range Bit10 .. Bit10; Transmitter_FIFO_Interrupt_Enable at 0 range Bit09 .. Bit09; Reserved_2 at 0 range Bit08 .. Bit08; Loop_Back at 0 range Bit07 .. Bit07; Reserved_1 at 0 range Bit06 .. Bit06; Parity_Enable at 0 range Bit05 .. Bit05; Parity_Select at 0 range Bit04 .. Bit04; Transmitter_Interrupt_Enable at 0 range Bit03 .. Bit03; Receiver_Interrupt_Enable at 0 range Bit02 .. Bit02; Transmitter_Enable at 0 range Bit01 .. Bit01; Receiver_Enable at 0 range Bit00 .. Bit00; end record; for UART_Control_Register'Size use 32; pragma Suppress_Initialization (UART_Control_Register); pragma Volatile_Full_Access (UART_Control_Register); type UART_Scaler_Register is record UART_Scaler : Scaler_12; -- 1 - 4095 : Divide factor -- 0 : stops the UART clock Reserved : Reserved_20; end record; for UART_Scaler_Register use record Reserved at 0 range Bit31 .. Bit12; UART_Scaler at 0 range Bit11 .. Bit00; end record; for UART_Scaler_Register'Size use 32; pragma Suppress_Initialization (UART_Scaler_Register); pragma Volatile_Full_Access (UART_Scaler_Register); ---------- -- UART -- ---------- UART_Base : constant := System.BB.Board_Parameters.UART_Base; UART_Data : UART_Data_Register; for UART_Data'Address use System'To_Address (UART_Base + 16#00#); UART_Status : UART_Status_Register; for UART_Status'Address use System'To_Address (UART_Base + 16#04#); UART_Control : UART_Control_Register; for UART_Control'Address use System'To_Address (UART_Base + 16#08#); UART_Scaler : UART_Scaler_Register; for UART_Scaler'Address use System'To_Address (UART_Base + 16#0C#); end Interfaces.Leon3.Uart;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Definitions; with Program.Lexical_Elements; package Program.Elements.Incomplete_Type_Definitions is pragma Pure (Program.Elements.Incomplete_Type_Definitions); type Incomplete_Type_Definition is limited interface and Program.Elements.Definitions.Definition; type Incomplete_Type_Definition_Access is access all Incomplete_Type_Definition'Class with Storage_Size => 0; not overriding function Has_Tagged (Self : Incomplete_Type_Definition) return Boolean is abstract; type Incomplete_Type_Definition_Text is limited interface; type Incomplete_Type_Definition_Text_Access is access all Incomplete_Type_Definition_Text'Class with Storage_Size => 0; not overriding function To_Incomplete_Type_Definition_Text (Self : aliased in out Incomplete_Type_Definition) return Incomplete_Type_Definition_Text_Access is abstract; not overriding function Tagged_Token (Self : Incomplete_Type_Definition_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Incomplete_Type_Definitions;
with Ada.Text_IO; with Prime_Numbers; procedure Parallel is package Integer_Primes is new Prime_Numbers ( Number => Integer, -- use Large_Integer for longer numbers Zero => 0, One => 1, Two => 2, Image => Integer'Image); My_List : Integer_Primes.Number_List := ( 12757923, 12878611, 12757923, 15808973, 15780709, 197622519); Decomposers : array (My_List'Range) of Integer_Primes.Calculate_Factors; Lengths : array (My_List'Range) of Natural; Max_Length : Natural := 0; begin for I in My_List'Range loop -- starts the tasks Decomposers (I).Start (My_List (I)); end loop; for I in My_List'Range loop -- wait until task has reached Get_Size entry Decomposers (I).Get_Size (Lengths (I)); if Lengths (I) > Max_Length then Max_Length := Lengths (I); end if; end loop; declare Results : array (My_List'Range) of Integer_Primes.Number_List (1 .. Max_Length); Largest_Minimal_Factor : Integer := 0; Winning_Index : Positive; begin for I in My_List'Range loop -- after Get_Result, the tasks terminate Decomposers (I).Get_Result (Results (I)); if Results (I) (1) > Largest_Minimal_Factor then Largest_Minimal_Factor := Results (I) (1); Winning_Index := I; end if; end loop; Ada.Text_IO.Put_Line ("Number" & Integer'Image (My_List (Winning_Index)) & " has largest minimal factor:"); Integer_Primes.Put (Results (Winning_Index) (1 .. Lengths (Winning_Index))); Ada.Text_IO.New_Line; end; end Parallel;
with Ada.Text_IO; use Ada.Text_IO; -- Should be counted as only five lines procedure Hello is begin Put_Line ("Hello WORLD!"); -- the classic example end Hello;
with openGL.Display, openGL.Screen, OSMesa_C; package openGL.surface_Profile -- -- Models an openGL surface profile. -- is type Item is tagged private; type View is access all Item'Class; type Items is array (Positive range <>) of Item; ------------------- -- Surface Quality -- Irrelevant : constant Natural := Natural'Last; type color_Buffer is record Bits_red : Natural := Irrelevant; Bits_green : Natural := Irrelevant; Bits_blue : Natural := Irrelevant; Bits_luminence : Natural := Irrelevant; Bits_alpha : Natural := Irrelevant; Bits_alpha_mask : Natural := Irrelevant; end record; function Image (Self : in color_Buffer) return String; type Qualities is record color_Buffer : surface_Profile.color_Buffer; depth_buffer_Bits : Natural := Irrelevant; stencil_buffer_Bits : Natural := Irrelevant; end record; default_Qualities : constant Qualities; function Image (Self : in Qualities) return String; --------- -- Forge -- desired_Qualitites_unavailable : exception; procedure define (Self : in out Item; the_Display : access openGL.Display.item'Class; Screen : access openGL.Screen .item'Class; Desired : in Qualities := default_Qualities); function fetch_All (the_Display : access openGL.Display.item'class) return surface_Profile.items; -------------- -- Attributes -- function Quality (Self : in Item) return Qualities; -- function get_Visual (Self : in Item) return access GLX.XVisualInfo; private type Item is tagged record -- glx_Config : GLX.GLXFBConfig; Display : access openGL.Display.item'Class; -- Visual : access GLX.XVisualInfo; end record; default_Qualities : constant Qualities := (color_Buffer => (Bits_red => 8, Bits_green => 8, Bits_blue => 8, Bits_luminence => Irrelevant, Bits_alpha => Irrelevant, Bits_alpha_mask => Irrelevant), depth_buffer_Bits => 24, stencil_buffer_Bits => Irrelevant); end openGL.surface_Profile;
with agar.core.timeout; with agar.core.types; package agar.gui.widget.editable is use type c.unsigned; type encoding_t is (ENCODING_UTF8, ENCODING_ASCII); for encoding_t use (ENCODING_UTF8 => 0, ENCODING_ASCII => 1); for encoding_t'size use c.unsigned'size; pragma convention (c, encoding_t); type flags_t is new c.unsigned; EDITABLE_HFILL : constant flags_t := 16#00001#; EDITABLE_VFILL : constant flags_t := 16#00002#; EDITABLE_EXPAND : constant flags_t := EDITABLE_HFILL or EDITABLE_VFILL; EDITABLE_MULTILINE : constant flags_t := 16#00004#; EDITABLE_BLINK_ON : constant flags_t := 16#00008#; EDITABLE_PASSWORD : constant flags_t := 16#00010#; EDITABLE_ABANDON_FOCUS : constant flags_t := 16#00020#; EDITABLE_INT_ONLY : constant flags_t := 16#00040#; EDITABLE_FLT_ONLY : constant flags_t := 16#00080#; EDITABLE_CATCH_TAB : constant flags_t := 16#00100#; EDITABLE_CURSOR_MOVING : constant flags_t := 16#00200#; EDITABLE_NOSCROLL : constant flags_t := 16#00800#; EDITABLE_NOSCROLL_ONCE : constant flags_t := 16#01000#; EDITABLE_MARKPREF : constant flags_t := 16#02000#; EDITABLE_STATIC : constant flags_t := 16#04000#; EDITABLE_NOEMACS : constant flags_t := 16#08000#; EDITABLE_NOWORDSEEK : constant flags_t := 16#10000#; EDITABLE_NOLATIN1 : constant flags_t := 16#20000#; string_max : constant := 1024; type string_t is array (1 .. string_max) of aliased c.char; pragma convention (c, string_t); type editable_t is limited private; type editable_access_t is access all editable_t; pragma convention (c, editable_access_t); type cursor_pos_t is (CURSOR_BEFORE, CURSOR_IN, CURSOR_AFTER); for cursor_pos_t use (CURSOR_BEFORE => -1, CURSOR_IN => 0, CURSOR_AFTER => 1); -- API function allocate (parent : widget_access_t; flags : flags_t) return editable_access_t; pragma import (c, allocate, "AG_EditableNew"); -- missing: bind_utf8 - unsure of how to bind -- missing: bind_ascii procedure set_static (editable : editable_access_t; enable : boolean); pragma inline (set_static); procedure set_password (editable : editable_access_t; enable : boolean); pragma inline (set_password); procedure set_integer_only (editable : editable_access_t; enable : boolean); pragma inline (set_integer_only); procedure set_float_only (editable : editable_access_t; enable : boolean); pragma inline (set_float_only); procedure size_hint (editable : editable_access_t; text : string); pragma inline (size_hint); procedure size_hint_pixels (editable : editable_access_t; width : positive; height : positive); pragma inline (size_hint_pixels); -- cursor manipulation procedure map_position (editable : editable_access_t; x : integer; y : integer; index : out natural; pos : out cursor_pos_t; absolute : boolean); pragma inline (map_position); procedure move_cursor (editable : editable_access_t; x : integer; y : integer; absolute : boolean); pragma inline (move_cursor); function get_cursor_position (editable : editable_access_t) return natural; pragma inline (get_cursor_position); function set_cursor_position (editable : editable_access_t; index : integer) return integer; pragma inline (set_cursor_position); -- text manipulation procedure set_string (editable : editable_access_t; text : string); pragma inline (set_string); procedure clear_string (editable : editable_access_t); pragma import (c, clear_string, "AG_EditableClearString"); procedure buffer_changed (editable : editable_access_t); pragma import (c, buffer_changed, "AG_EditableBufferChanged"); function get_integer (editable : editable_access_t) return integer; pragma inline (get_integer); function get_float (editable : editable_access_t) return float; pragma inline (get_float); function get_long_float (editable : editable_access_t) return long_float; pragma inline (get_long_float); function widget (editable : editable_access_t) return widget_access_t; pragma inline (widget); private type editable_t is record widget : aliased widget_t; flags : flags_t; encoding : encoding_t; str : string_t; width_pre : c.int; height_pre : c.int; pos : c.int; compose : agar.core.types.uint32_t; x_cursor : c.int; y_cursor : c.int; x_cursor_pref : c.int; x_sel1 : c.int; x_sel2 : c.int; sel_edit : c.int; to_delay : agar.core.timeout.timeout_t; to_repeat : agar.core.timeout.timeout_t; to_blink : agar.core.timeout.timeout_t; x : c.int; x_max : c.int; y : c.int; y_max : c.int; y_vis : c.int; wheel_ticks : agar.core.types.uint32_t; repeat_key : c.int; repeat_mod : c.int; repeat_unicode : agar.core.types.uint32_t; ucs_buffer : access agar.core.types.uint32_t; ucs_length : c.unsigned; r : agar.gui.rect.rect_t; end record; pragma convention (c, editable_t); end agar.gui.widget.editable;
----------------------------------------------------------------------- -- files.tests -- Unit tests for files -- Copyright (C) 2009, 2010, 2011, 2012, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log; with Util.Test_Caller; with ASF.Tests; with AWA.Users.Models; with AWA.Tests.Helpers.Users; with ASF.Requests.Mockup; with ASF.Responses.Mockup; with ASF.Principals; package body AWA.Users.Tests is use ASF.Tests; package Caller is new Util.Test_Caller (Test, "Users.Tests"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Users.Tests.Create_User (/users/register.xhtml)", Test_Create_User'Access); Caller.Add_Test (Suite, "Test AWA.Users.Services.Close_Session", Test_Logout_User'Access); Caller.Add_Test (Suite, "Test AWA.Users.Tests.Login_User (/users/login.xhtml)", Test_Login_User'Access); Caller.Add_Test (Suite, "Test AWA.Users.Services.Lost_Password, Reset_Password", Test_Reset_Password_User'Access); end Add_Tests; -- ------------------------------ -- Test creation of user by simulating web requests. -- ------------------------------ procedure Test_Create_User (T : in out Test) is use type ASF.Principals.Principal_Access; Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; Email : constant String := "Joe-" & Util.Tests.Get_Uuid & "@gmail.com"; Principal : AWA.Tests.Helpers.Users.Test_User; begin AWA.Tests.Helpers.Users.Initialize (Principal); Do_Get (Request, Reply, "/auth/register.html", "create-user-1.html"); Request.Set_Parameter ("email", Email); Request.Set_Parameter ("password", "asdf"); Request.Set_Parameter ("password2", "asdf"); Request.Set_Parameter ("firstName", "joe"); Request.Set_Parameter ("lastName", "dalton"); Request.Set_Parameter ("register", "1"); Request.Set_Parameter ("register-button", "1"); Do_Post (Request, Reply, "/auth/register.html", "create-user-2.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY, "Invalid response"); -- Check that the user is NOT logged. T.Assert (Request.Get_User_Principal = null, "A user principal should not be defined"); -- Now, get the access key and simulate a click on the validation link. declare Key : AWA.Users.Models.Access_Key_Ref; begin AWA.Tests.Helpers.Users.Find_Access_Key (Principal, Email, Key); T.Assert (not Key.Is_Null, "There is no access key associated with the user"); Do_Get (Request, Reply, "/auth/validate.html?key=" & Key.Get_Access_Key, "validate-user-1.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY, "Invalid response"); end; -- Check that the user is logged and we have a user principal now. T.Assert (Request.Get_User_Principal /= null, "A user principal should be defined"); end Test_Create_User; procedure Test_Logout_User (T : in out Test) is begin null; end Test_Logout_User; -- ------------------------------ -- Test user authentication by simulating a web request. -- ------------------------------ procedure Test_Login_User (T : in out Test) is use type ASF.Principals.Principal_Access; Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; Principal : AWA.Tests.Helpers.Users.Test_User; begin AWA.Tests.Set_Application_Context; AWA.Tests.Get_Application.Dump_Routes (Util.Log.INFO_LEVEL); begin AWA.Tests.Helpers.Users.Create_User (Principal, "Joe@gmail.com"); -- It sometimes happen that Joe's password is changed by another test. -- Recover the password and make sure it is 'admin'. exception when others => T.Recover_Password ("Joe@gmail.com", "admin"); end; Do_Get (Request, Reply, "/auth/login.html", "login-user-1.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_OK, "Invalid response"); -- Check that the user is NOT logged. T.Assert (Request.Get_User_Principal = null, "A user principal should not be defined"); Request.Set_Parameter ("email", "Joe@gmail.com"); Request.Set_Parameter ("password", "admin"); Request.Set_Parameter ("login", "1"); Request.Set_Parameter ("login-button", "1"); Do_Post (Request, Reply, "/auth/login.html", "login-user-2.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY, "Invalid response"); -- Check that the user is logged and we have a user principal now. T.Assert (Request.Get_User_Principal /= null, "A user principal should be defined"); end Test_Login_User; -- ------------------------------ -- Run the recovery password process for the given user and change the password. -- ------------------------------ procedure Recover_Password (T : in out Test; Email : in String; Password : in String) is use type ASF.Principals.Principal_Access; Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; begin Do_Get (Request, Reply, "/auth/lost-password.html", "lost-password-1.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_OK, "Invalid response"); Request.Set_Parameter ("email", Email); Request.Set_Parameter ("lost-password", "1"); Request.Set_Parameter ("lost-password-button", "1"); Do_Post (Request, Reply, "/auth/lost-password.html", "lost-password-2.html"); ASF.Tests.Assert_Redirect (T, "/asfunit/auth/login.html", Reply, "Invalid redirect after lost password"); -- Now, get the access key and simulate a click on the reset password link. declare Principal : AWA.Tests.Helpers.Users.Test_User; Key : AWA.Users.Models.Access_Key_Ref; begin AWA.Tests.Set_Application_Context; AWA.Tests.Helpers.Users.Find_Access_Key (Principal, Email, Key); T.Assert (not Key.Is_Null, "There is no access key associated with the user"); -- Simulate user clicking on the reset password link. -- This verifies the key, login the user and redirect him to the change-password page Request.Set_Parameter ("key", Key.Get_Access_Key); Request.Set_Parameter ("password", Password); Request.Set_Parameter ("reset-password", "1"); Do_Post (Request, Reply, "/auth/change-password.html", "reset-password-2.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY, "Invalid response"); -- Check that the user is logged and we have a user principal now. T.Assert (Request.Get_User_Principal /= null, "A user principal should be defined"); end; end Recover_Password; -- ------------------------------ -- Test the reset password by simulating web requests. -- ------------------------------ procedure Test_Reset_Password_User (T : in out Test) is begin T.Recover_Password ("Joe@gmail.com", "asf"); T.Recover_Password ("Joe@gmail.com", "admin"); end Test_Reset_Password_User; end AWA.Users.Tests;
with Gtk.Main; with Glib; with Gtk.Window; use Gtk.Window; with Gtk.Enums; use Gtk.Enums; with Ada.Text_IO; use Ada.Text_IO; procedure Max_Size is Win : Gtk_Window; Win_W, Win_H : Glib.Gint; package Int_Io is new Integer_IO (Glib.Gint); Hid : Gtk.Main.Quit_Handler_Id; begin Gtk.Main.Init; Gtk_New (Win); Initialize (Win, Window_Toplevel); Maximize (Win); Show (Win); Get_Size (Win, Win_W, Win_H); Put ("Maximum dimensions of window : W "); Int_Io.Put (Win_W, Width => 4); Put (" x H "); Int_Io.Put (Win_H, Width => 4); New_Line; Hid := Gtk.Main.Quit_Add_Destroy (0, Win); end Max_Size;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ A U X -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2010, 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. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Package containing utility procedures used throughout the compiler, -- and also by ASIS so dependencies are limited to ASIS included packages. -- Historical note. Many of the routines here were originally in Einfo, but -- Einfo is supposed to be a relatively low level package dealing with the -- content of entities in the tree, so this package is used for routines that -- require more than minimal semantic knowledge. with Alloc; use Alloc; with Table; with Types; use Types; package Sem_Aux is -------------------------------- -- Obsolescent Warnings Table -- -------------------------------- -- This table records entities for which a pragma Obsolescent with a -- message argument has been processed. type OWT_Record is record Ent : Entity_Id; -- The entity to which the pragma applies Msg : String_Id; -- The string containing the message end record; package Obsolescent_Warnings is new Table.Table ( Table_Component_Type => OWT_Record, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => Alloc.Obsolescent_Warnings_Initial, Table_Increment => Alloc.Obsolescent_Warnings_Increment, Table_Name => "Obsolescent_Warnings"); procedure Initialize; -- Called at the start of compilation of each new main source file to -- initialize the allocation of the Obsolescent_Warnings table. Note that -- Initialize must not be called if Tree_Read is used. procedure Tree_Read; -- Initializes Obsolescent_Warnings table from current tree file using the -- relevant Table.Tree_Read routine. procedure Tree_Write; -- Writes out Obsolescent_Warnings table to current tree file using the -- relevant Table.Tree_Write routine. ----------------- -- Subprograms -- ----------------- function Ancestor_Subtype (Typ : Entity_Id) return Entity_Id; -- The argument Id is a type or subtype entity. If the argument is a -- subtype then it returns the subtype or type from which the subtype was -- obtained, otherwise it returns Empty. function Available_View (Typ : Entity_Id) return Entity_Id; -- Typ is typically a type that has the With_Type flag set. Returns the -- non-limited view of the type, if available, otherwise the type itself. -- For class-wide types, there is no direct link in the tree, so we have -- to retrieve the class-wide type of the non-limited view of the Etype. -- Returns the argument unchanged if it is not one of these cases. function Constant_Value (Ent : Entity_Id) return Node_Id; -- Id is a variable, constant, named integer, or named real entity. This -- call obtains the initialization expression for the entity. Will return -- Empty for for a deferred constant whose full view is not available or -- in some other cases of internal entities, which cannot be treated as -- constants from the point of view of constant folding. Empty is also -- returned for variables with no initialization expression. function Enclosing_Dynamic_Scope (Ent : Entity_Id) return Entity_Id; -- For any entity, Ent, returns the closest dynamic scope in which the -- entity is declared or Standard_Standard for library-level entities function First_Discriminant (Typ : Entity_Id) return Entity_Id; -- Typ is a type with discriminants. The discriminants are the first -- entities declared in the type, so normally this is equivalent to -- First_Entity. The exception arises for tagged types, where the tag -- itself is prepended to the front of the entity chain, so the -- First_Discriminant function steps past the tag if it is present. function First_Stored_Discriminant (Typ : Entity_Id) return Entity_Id; -- Typ is a type with discriminants. Gives the first discriminant stored -- in an object of this type. In many cases, these are the same as the -- normal visible discriminants for the type, but in the case of renamed -- discriminants, this is not always the case. -- -- For tagged types, and untagged types which are root types or derived -- types but which do not rename discriminants in their root type, the -- stored discriminants are the same as the actual discriminants of the -- type, and hence this function is the same as First_Discriminant. -- -- For derived non-tagged types that rename discriminants in the root type -- this is the first of the discriminants that occur in the root type. To -- be precise, in this case stored discriminants are entities attached to -- the entity chain of the derived type which are a copy of the -- discriminants of the root type. Furthermore their Is_Completely_Hidden -- flag is set since although they are actually stored in the object, they -- are not in the set of discriminants that is visible in the type. -- -- For derived untagged types, the set of stored discriminants are the real -- discriminants from Gigi's standpoint, i.e. those that will be stored in -- actual objects of the type. function First_Subtype (Typ : Entity_Id) return Entity_Id; -- Applies to all types and subtypes. For types, yields the first subtype -- of the type. For subtypes, yields the first subtype of the base type of -- the subtype. function First_Tag_Component (Typ : Entity_Id) return Entity_Id; -- Typ must be a tagged record type. This function returns the Entity for -- the first _Tag field in the record type. function Is_By_Copy_Type (Ent : Entity_Id) return Boolean; -- Ent is any entity. Returns True if Ent is a type entity where the type -- is required to be passed by copy, as defined in (RM 6.2(3)). function Is_By_Reference_Type (Ent : Entity_Id) return Boolean; -- Ent is any entity. Returns True if Ent is a type entity where the type -- is required to be passed by reference, as defined in (RM 6.2(4-9)). function Is_Derived_Type (Ent : Entity_Id) return Boolean; -- Determines if the given entity Ent is a derived type. Result is always -- false if argument is not a type. function Is_Generic_Formal (E : Entity_Id) return Boolean; -- Determine whether E is a generic formal parameter. In particular this is -- used to set the visibility of generic formals of a generic package -- declared with a box or with partial parametrization. function Is_Indefinite_Subtype (Ent : Entity_Id) return Boolean; -- Ent is any entity. Determines if given entity is an unconstrained array -- type or subtype, a discriminated record type or subtype with no initial -- discriminant values or a class wide type or subtype and returns True if -- so. False for other type entities, or any entities that are not types. function Is_Immutably_Limited_Type (Ent : Entity_Id) return Boolean; -- Ent is any entity. True for a type that is "inherently" limited (i.e. -- cannot become nonlimited). From the Ada 2005 RM-7.5(8.1/2), "a type with -- a part that is of a task, protected, or explicitly limited record type". -- These are the types that are defined as return-by-reference types in Ada -- 95 (see RM95-6.5(11-16)). In Ada 2005, these are the types that require -- build-in-place for function calls. Note that build-in-place is allowed -- for other types, too. This is also used for identifying pure procedures -- whose calls should not be eliminated (RM 10.2.1(18/2)). function Is_Limited_Type (Ent : Entity_Id) return Boolean; -- Ent is any entity. Returns true if Ent is a limited type (limited -- private type, limited interface type, task type, protected type, -- composite containing a limited component, or a subtype of any of -- these types). function Nearest_Ancestor (Typ : Entity_Id) return Entity_Id; -- Given a subtype Typ, this function finds out the nearest ancestor from -- which constraints and predicates are inherited. There is no simple link -- for doing this, consider: -- -- subtype R is Integer range 1 .. 10; -- type T is new R; -- -- In this case the nearest ancestor is R, but the Etype of T'Base will -- point to R'Base, so we have to go rummaging in the declarations to get -- this information. It is used for making sure we freeze this before we -- freeze Typ, and also for retrieving inherited predicate information. -- For the case of base types or first subtypes, there is no useful entity -- to return, so Empty is returned. -- -- Note: this is similar to Ancestor_Subtype except that it also deals -- with the case of derived types. function Nearest_Dynamic_Scope (Ent : Entity_Id) return Entity_Id; -- This is similar to Enclosing_Dynamic_Scope except that if Ent is itself -- a dynamic scope, then it is returned. Otherwise the result is the same -- as that returned by Enclosing_Dynamic_Scope. function Next_Tag_Component (Tag : Entity_Id) return Entity_Id; -- Tag must be an entity representing a _Tag field of a tagged record. -- The result returned is the next _Tag field in this record, or Empty -- if this is the last such field. function Number_Discriminants (Typ : Entity_Id) return Pos; -- Typ is a type with discriminants, yields number of discriminants in type function Ultimate_Alias (Prim : Entity_Id) return Entity_Id; pragma Inline (Ultimate_Alias); -- Return the last entity in the chain of aliased entities of Prim. If Prim -- has no alias return Prim. end Sem_Aux;
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2011, Stefan Berghofer -- Copyright (C) 2011, secunet Security Networks AG -- 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 author nor the names of its contributors may be -- used to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.Types; with LSC.Internal.Math_Int; use type LSC.Internal.Math_Int.Math_Int; use type LSC.Internal.Types.Word32; use type LSC.Internal.Types.Word64; package LSC.Internal.Bignum is pragma Pure; function Base return Math_Int.Math_Int is (Math_Int.From_Word32 (2) ** 32) with Ghost; subtype Big_Int_Range is Natural range Natural'First .. Natural'Last - 1; type Big_Int is array (Big_Int_Range range <>) of Types.Word32; function Num_Of_Big_Int (A : Big_Int; F, L : Natural) return Math_Int.Math_Int with Ghost, Import, Global => null; function Num_Of_Boolean (B : Boolean) return Math_Int.Math_Int with Ghost, Import, Global => null; function Inverse (M, A : Math_Int.Math_Int) return Math_Int.Math_Int with Ghost, Import, Global => null; procedure Initialize (A : out Big_Int; A_First : in Natural; A_Last : in Natural) with Depends => (A => (A_First, A_Last)), Pre => A_First in A'Range and A_Last in A'Range and A_First <= A_Last, Post => (for all K in Natural range A_First .. A_Last => (A (K) = 0)); procedure Copy (A : in Big_Int; A_First : in Natural; A_Last : in Natural; B : in out Big_Int; B_First : in Natural) with Depends => (B =>+ (A, A_First, A_Last, B_First)), Pre => A_First in A'Range and A_Last in A'Range and A_First <= A_Last and B_First in B'Range and B_First + (A_Last - A_First) in B'Range, Post => (for all K in Natural range B'Range => ((if K in B_First .. B_First + A_Last - A_First then B (K) = A (A_First + K - B_First)) and (if K not in B_First .. B_First + A_Last - A_First then B (K) = B'Old (K)))); procedure Native_To_BE (A : in Big_Int; A_First : in Natural; A_Last : in Natural; B : out Big_Int; B_First : in Natural) with Depends => (B => (A, A_First, A_Last, B_First)), Pre => A_First in A'Range and A_Last in A'Range and A_First <= A_Last and B_First in B'Range and B_First + (A_Last - A_First) in B'Range; procedure Double_Inplace (A : in out Big_Int; A_First : in Natural; A_Last : in Natural; Carry : out Boolean) with Depends => ((A, Carry) => (A, A_First, A_Last)), Pre => A_First in A'Range and A_Last in A'Range and A_First <= A_Last, Post => Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) * Math_Int.From_Word32 (2) = Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) + Base ** (A_Last - A_First + 1) * Num_Of_Boolean (Carry); procedure SHR_Inplace (A : in out Big_Int; A_First : in Natural; A_Last : in Natural; K : in Natural) with Depends => (A =>+ (A_First, A_Last, K)), Pre => A_First in A'Range and A_Last in A'Range and A_First <= A_Last and K <= 32, Post => Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) / Math_Int.From_Word32 (2) ** K = Num_Of_Big_Int (A, A_First, A_Last - A_First + 1); procedure Add_Inplace (A : in out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; Carry : out Boolean) with Depends => ((A, Carry) => (A, A_First, A_Last, B, B_First)), Pre => A_First in A'Range and A_Last in A'Range and B_First in B'Range and B_First + (A_Last - A_First) in B'Range and A_First <= A_Last, Post => Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) + Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) = Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) + Base ** (A_Last - A_First + 1) * Num_Of_Boolean (Carry); procedure Add (A : out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; C : in Big_Int; C_First : in Natural; Carry : out Boolean) with Depends => ((A, Carry) => (A_First, A_Last, B, B_First, C, C_First)), Pre => A_First in A'Range and A_Last in A'Range and B_First in B'Range and B_First + (A_Last - A_First) in B'Range and C_First in C'Range and C_First + (A_Last - A_First) in C'Range and A_First <= A_Last, Post => Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) + Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) = Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) + Base ** (A_Last - A_First + 1) * Num_Of_Boolean (Carry); procedure Sub_Inplace (A : in out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; Carry : out Boolean) with Depends => ((A, Carry) => (A, A_First, A_Last, B, B_First)), Pre => A_First in A'Range and A_Last in A'Range and B_First in B'Range and B_First + (A_Last - A_First) in B'Range and A_First <= A_Last, Post => Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) - Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) = Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) - Base ** (A_Last - A_First + 1) * Num_Of_Boolean (Carry); procedure Sub (A : out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; C : in Big_Int; C_First : in Natural; Carry : out Boolean) with Depends => ((A, Carry) => (A_First, A_Last, B, B_First, C, C_First)), Pre => A_First in A'Range and A_Last in A'Range and B_First in B'Range and B_First + (A_Last - A_First) in B'Range and C_First in C'Range and C_First + (A_Last - A_First) in C'Range and A_First <= A_Last, Post => Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) - Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) = Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) - Base ** (A_Last - A_First + 1) * Num_Of_Boolean (Carry); procedure Mod_Add_Inplace (A : in out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; M : in Big_Int; M_First : in Natural) with Depends => (A =>+ (A_First, A_Last, B, B_First, M, M_First)), Pre => A_First in A'Range and then A_Last in A'Range and then B_First in B'Range and then B_First + (A_Last - A_First) in B'Range and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then A_First <= A_Last and then (Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) <= Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) or Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) <= Num_Of_Big_Int (M, M_First, A_Last - A_First + 1)), Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) + Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) - Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) * Num_Of_Boolean (Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) + Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) >= Base ** (A_Last - A_First + 1)); procedure Mod_Add (A : out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; C : in Big_Int; C_First : in Natural; M : in Big_Int; M_First : in Natural) with Depends => (A =>+ (A_First, A_Last, B, B_First, C, C_First, M, M_First)), Pre => A_First in A'Range and then A_Last in A'Range and then B_First in B'Range and then B_First + (A_Last - A_First) in B'Range and then C_First in C'Range and then C_First + (A_Last - A_First) in C'Range and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then A_First <= A_Last and then (Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) <= Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) or Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) <= Num_Of_Big_Int (M, M_First, A_Last - A_First + 1)), Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) + Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) - Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) * Num_Of_Boolean (Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) + Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) >= Base ** (A_Last - A_First + 1)); procedure Mod_Sub_Inplace (A : in out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; M : in Big_Int; M_First : in Natural) with Depends => (A =>+ (A_First, A_Last, B, B_First, M, M_First)), Pre => A_First in A'Range and then A_Last in A'Range and then B_First in B'Range and then B_First + (A_Last - A_First) in B'Range and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then A_First <= A_Last and then Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) <= Num_Of_Big_Int (M, M_First, A_Last - A_First + 1), Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) - Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) + Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) * Num_Of_Boolean (Num_Of_Big_Int (A'Old, A_First, A_Last - A_First + 1) < Num_Of_Big_Int (B, B_First, A_Last - A_First + 1)); procedure Mod_Sub (A : out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; C : in Big_Int; C_First : in Natural; M : in Big_Int; M_First : in Natural) with Depends => (A =>+ (A_First, A_Last, B, B_First, C, C_First, M, M_First)), Pre => A_First in A'Range and then A_Last in A'Range and then B_First in B'Range and then B_First + (A_Last - A_First) in B'Range and then C_First in C'Range and then C_First + (A_Last - A_First) in C'Range and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then A_First <= A_Last and then Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) <= Num_Of_Big_Int (M, M_First, A_Last - A_First + 1), Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) - Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) + Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) * Num_Of_Boolean (Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) < Num_Of_Big_Int (C, C_First, A_Last - A_First + 1)); function Is_Zero (A : Big_Int; A_First : Natural; A_Last : Natural) return Boolean with Pre => A_First in A'Range and A_Last in A'Range and A_First <= A_Last, Post => Is_Zero'Result = (Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Math_Int.From_Word32 (0)); function Equal (A : Big_Int; A_First : Natural; A_Last : Natural; B : Big_Int; B_First : Natural) return Boolean with Pre => A_First in A'Range and A_Last in A'Range and B_First in B'Range and B_First + (A_Last - A_First) in B'Range and A_First <= A_Last, Post => Equal'Result = (Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (B, B_First, A_Last - A_First + 1)); function Less (A : Big_Int; A_First : Natural; A_Last : Natural; B : Big_Int; B_First : Natural) return Boolean with Pre => A_First in A'Range and A_Last in A'Range and B_First in B'Range and B_First + (A_Last - A_First) in B'Range and A_First <= A_Last, Post => Less'Result = (Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) < Num_Of_Big_Int (B, B_First, A_Last - A_First + 1)); procedure Size_Square_Mod (M : in Big_Int; M_First : in Natural; M_Last : in Natural; R : out Big_Int; R_First : in Natural) with Depends => (R =>+ (M, M_First, M_Last, R_First)), Pre => M_First in M'Range and then M_Last in M'Range and then M_First <= M_Last and then R_First in R'Range and then R_First + (M_Last - M_First) in R'Range and then Math_Int.From_Word32 (1) < Num_Of_Big_Int (M, M_First, M_Last - M_First + 1), Post => Num_Of_Big_Int (R, R_First, M_Last - M_First + 1) = Base ** (Math_Int.From_Integer (2) * Math_Int.From_Integer (M_Last - M_First + 1)) mod Num_Of_Big_Int (M, M_First, M_Last - M_First + 1); function Word_Inverse (M : Types.Word32) return Types.Word32 with Pre => M mod 2 = 1, Post => 1 + Word_Inverse'Result * M = 0; procedure Mont_Mult (A : out Big_Int; A_First : in Natural; A_Last : in Natural; B : in Big_Int; B_First : in Natural; C : in Big_Int; C_First : in Natural; M : in Big_Int; M_First : in Natural; M_Inv : in Types.Word32) with Depends => (A =>+ (A_First, A_Last, B, B_First, C, C_First, M, M_First, M_Inv)), Pre => A_First in A'Range and then A_Last in A'Range and then A_First < A_Last and then B_First in B'Range and then B_First + (A_Last - A_First) in B'Range and then C_First in C'Range and then C_First + (A_Last - A_First) in C'Range and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) < Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) and then Math_Int.From_Word32 (1) < Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) and then 1 + M_Inv * M (M_First) = 0, Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = (Num_Of_Big_Int (B, B_First, A_Last - A_First + 1) * Num_Of_Big_Int (C, C_First, A_Last - A_First + 1) * Inverse (Num_Of_Big_Int (M, M_First, A_Last - A_First + 1), Base) ** (A_Last - A_First + 1)) mod Num_Of_Big_Int (M, M_First, A_Last - A_First + 1); procedure Mont_Exp (A : out Big_Int; A_First : in Natural; A_Last : in Natural; X : in Big_Int; X_First : in Natural; E : in Big_Int; E_First : in Natural; E_Last : in Natural; M : in Big_Int; M_First : in Natural; Aux1 : out Big_Int; Aux1_First : in Natural; Aux2 : out Big_Int; Aux2_First : in Natural; Aux3 : out Big_Int; Aux3_First : in Natural; R : in Big_Int; R_First : in Natural; M_Inv : in Types.Word32) with Depends => (A =>+ (A_First, A_Last, X, X_First, E, E_First, E_Last, M, M_First, Aux1, Aux1_First, Aux2, Aux2_First, Aux3, Aux3_First, R, R_First, M_Inv), Aux1 => (A_First, A_Last, Aux1_First), Aux2 =>+ (A_First, A_Last, Aux2_First, X, X_First, R, R_First, M, M_First, M_Inv), Aux3 =>+ (A, A_First, A_Last, X, X_First, E, E_First, E_Last, M, M_First, Aux1, Aux1_First, Aux2, Aux2_First, Aux3_First, R, R_First, M_Inv)), Pre => A_First in A'Range and then A_Last in A'Range and then A_First < A_Last and then X_First in X'Range and then X_First + (A_Last - A_First) in X'Range and then E_First in E'Range and then E_Last in E'Range and then E_First <= E_Last and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then Aux1_First in Aux1'Range and then Aux1_First + (A_Last - A_First) in Aux1'Range and then Aux2_First in Aux2'Range and then Aux2_First + (A_Last - A_First) in Aux2'Range and then Aux3_First in Aux3'Range and then Aux3_First + (A_Last - A_First) in Aux3'Range and then R_First in R'Range and then R_First + (A_Last - A_First) in R'Range and then Num_Of_Big_Int (R, R_First, A_Last - A_First + 1) = Base ** (Math_Int.From_Integer (2) * Math_Int.From_Integer (A_Last - A_First + 1)) mod Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) and then Math_Int.From_Word32 (1) < Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) and then 1 + M_Inv * M (M_First) = 0, Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (X, X_First, A_Last - A_First + 1) ** Num_Of_Big_Int (E, E_First, E_Last - E_First + 1) mod Num_Of_Big_Int (M, M_First, A_Last - A_First + 1); procedure Mont_Exp_Window (A : out Big_Int; A_First : in Natural; A_Last : in Natural; X : in Big_Int; X_First : in Natural; E : in Big_Int; E_First : in Natural; E_Last : in Natural; M : in Big_Int; M_First : in Natural; K : in Natural; Aux1 : out Big_Int; Aux1_First : in Natural; Aux2 : out Big_Int; Aux2_First : in Natural; Aux3 : out Big_Int; Aux3_First : in Natural; Aux4 : out Big_Int; Aux4_First : in Natural; R : in Big_Int; R_First : in Natural; M_Inv : in Types.Word32) with Depends => (A =>+ (A_First, A_Last, X, X_First, E, E_First, E_Last, M, M_First, Aux1, Aux1_First, Aux2, Aux2_First, Aux3, Aux3_First, Aux4, Aux4_First, R, R_First, M_Inv, K), Aux1 => (A_First, A_Last, Aux1_First), Aux2 =>+ (A_First, A_Last, Aux2_First, Aux4, Aux4_First, X, X_First, R, R_First, M, M_First, M_Inv), Aux3 =>+ (A, A_First, A_Last, X, X_First, E, E_First, E_Last, M, M_First, Aux1, Aux1_First, Aux2, Aux2_First, Aux3_First, Aux4, Aux4_First, R, R_First, M_Inv, K), Aux4 =>+ (A, A_First, A_Last, X, X_First, Aux2, Aux2_First, Aux4_First, M, M_First, R, R_First, M_Inv, K)), Pre => A_First in A'Range and then A_Last in A'Range and then A_First < A_Last and then X_First in X'Range and then X_First + (A_Last - A_First) in X'Range and then E_First in E'Range and then E_Last in E'Range and then E_First <= E_Last and then M_First in M'Range and then M_First + (A_Last - A_First) in M'Range and then Aux1_First in Aux1'Range and then Aux1_First + (A_Last - A_First) in Aux1'Range and then Aux2_First in Aux2'Range and then Aux2_First + (A_Last - A_First) in Aux2'Range and then Aux3_First in Aux3'Range and then Aux3_First + (A_Last - A_First) in Aux3'Range and then Aux4_First in Aux4'Range and then Aux4_First + (2 ** K * (A_Last - A_First + 1) - 1) in Aux4'Range and then K <= 30 and then R_First in R'Range and then R_First + (A_Last - A_First) in R'Range and then Num_Of_Big_Int (R, R_First, A_Last - A_First + 1) = Base ** (Math_Int.From_Integer (2) * Math_Int.From_Integer (A_Last - A_First + 1)) mod Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) and then Math_Int.From_Word32 (1) < Num_Of_Big_Int (M, M_First, A_Last - A_First + 1) and then 1 + M_Inv * M (M_First) = 0, Post => Num_Of_Big_Int (A, A_First, A_Last - A_First + 1) = Num_Of_Big_Int (X, X_First, A_Last - A_First + 1) ** Num_Of_Big_Int (E, E_First, E_Last - E_First + 1) mod Num_Of_Big_Int (M, M_First, A_Last - A_First + 1); end LSC.Internal.Bignum;
-- { dg-do compile { target *-*-linux* } } -- { dg-options "-gdwarf-2" } procedure Return3 is begin return; end; -- { dg-final { scan-assembler "loc 1 6" } }
---------------------------------------------------------------------------- -- Symbolic Expressions (symexpr) -- -- Copyright (C) 2012, Riccardo Bernardini -- -- This file is part of symexpr. -- -- symexpr is free software: you can redistribute it and/or modify -- it under the terms of the Lesser GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- symexpr 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 Lesser GNU General Public License -- along with gclp. If not, see <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- with Symbolic_Expressions; package Test is function Get_Int (X : String) return String; type Int_Array is array (Positive range <>) of Integer; function Call (Name : String; Param : Int_Array) return Integer; package Int_Expr is new Symbolic_Expressions (Scalar_Type => Integer, Scalar_Array => Int_Array, Read_Scalar => Get_Int, Value => Integer'Value, Image => Integer'Image); end Test;
pragma Ada_2012; package body GStreamer.rtsp.G_range is ----------- -- parse -- ----------- function parse (rangestr : String) return GstRTSPTimeRange is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "parse unimplemented"); return raise Program_Error with "Unimplemented function parse"; end parse; ------------ -- string -- ------------ function To_string (c_range : GstRTSPTimeRange) return access GLIB.gchar is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "string unimplemented"); return raise Program_Error with "Unimplemented function string"; end To_string; ---------- -- free -- ---------- procedure free (c_range : GstRTSPTimeRange) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "free unimplemented"); raise Program_Error with "Unimplemented procedure free"; end free; end GStreamer.rtsp.G_range;
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Incr.Documents; with Incr.Nodes; with Incr.Parsers.Incremental; package Ada_LSP.Ada_Parser_Data is package P renames Incr.Parsers.Incremental.Parser_Data_Providers; type Provider is abstract new P.Parser_Data_Provider with null record; type Provider_Access is access constant Provider'Class; overriding function Actions (Self : Provider) return P.Action_Table_Access; overriding function Part_Counts (Self : Provider) return P.Parts_Count_Table_Access; overriding function States (Self : Provider) return P.State_Table_Access; overriding function Kind_Image (Self : Provider; Kind : Incr.Nodes.Node_Kind) return Wide_Wide_String; not overriding function Is_Defining_Name (Self : Provider; Kind : Incr.Nodes.Node_Kind) return Boolean is abstract; type Node_Factory (Document : Incr.Documents.Document_Access) is new P.Node_Factory with null record; overriding procedure Create_Node (Self : aliased in out Node_Factory; Prod : P.Production_Index; Children : Incr.Nodes.Node_Array; Node : out Incr.Nodes.Node_Access; Kind : out Incr.Nodes.Node_Kind); private type Node_Kind_Array is array (P.Production_Index range <>) of Incr.Nodes.Node_Kind; end Ada_LSP.Ada_Parser_Data;
package body System.Formatting.Address is pragma Suppress (All_Checks); subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; subtype Long_Long_Unsigned is Long_Long_Integer_Types.Long_Long_Unsigned; -- implementation procedure Image ( Value : System.Address; Item : out Address_String; Set : Type_Set := Upper_Case) is Use_Longest : constant Boolean := Standard'Address_Size > Standard'Word_Size; Last : Natural; -- ignore Error : Boolean; -- ignore begin if Use_Longest then Image ( Long_Long_Unsigned (Value), Item, Last, Base => 16, Set => Set, Width => Address_String'Length, Error => Error); else Image ( Word_Unsigned (Value), Item, Last, Base => 16, Set => Set, Width => Address_String'Length, Error => Error); end if; end Image; procedure Value ( Item : Address_String; Result : out System.Address; Error : out Boolean) is Use_Longest : constant Boolean := Standard'Address_Size > Standard'Word_Size; Last : Natural; begin if Use_Longest then Value ( Item, Last, Long_Long_Unsigned (Result), Base => 16, Error => Error); else Value ( Item, Last, Word_Unsigned (Result), Base => 16, Error => Error); end if; Error := Error or else Last /= Item'Last; end Value; end System.Formatting.Address;
with GNAT.OS_Lib, Ada.Strings.Fixed, Ada.Strings.Maps, Ada.Characters.Handling, Ada.Exceptions, Ada.Unchecked_Deallocation, Ada.Unchecked_Conversion; package body Shell.Commands is --- Strings -- function To_String_Vector (Strings : String_Array) return String_Vector is use String_Vectors; Vector : String_Vector; begin for Each of Strings loop Vector.Append (Each); end loop; return Vector; end To_String_Vector; function To_String_Array (Strings : String_Vector) return String_Array is use String_Vectors; The_Array : String_Array (1 .. Natural (Strings.Length)); begin for i in The_Array'Range loop The_Array (i) := Strings.Element (i); end loop; return The_Array; end To_String_Array; function To_Arguments (All_Arguments : in String) return String_Array is use GNAT.OS_Lib; Command_Name : constant String := "Command_Name"; -- 'Argument_String_To_List' expects the command name to be -- the 1st piece of the string, so we provide a dummy name. Arguments : Argument_List_Access := Argument_String_To_List (Command_Name & " " & All_Arguments); Result : String_Array (1 .. Arguments'Length - 1); begin for i in Result'Range loop Result (i) := +Arguments (i + 1).all; end loop; Free (Arguments); return Result; end To_Arguments; --- Commands -- function Image (The_Command : in Command) return String is use String_Vectors; Result : Unbounded_String; begin Append (Result, "(" & The_Command.Name & ", ("); for Each of The_Command.Arguments loop Append (Result, Each); if Each = Last_Element (The_Command.Arguments) then Append (Result, ")"); else Append (Result, ", "); end if; end loop; Append (Result, ", Input_Pipe => " & Image (The_Command.Input_Pipe)); Append (Result, ", Output_Pipe => " & Image (The_Command.Output_Pipe)); Append (Result, ", Error_Pipe => " & Image (The_Command.Error_Pipe)); Append (Result, ")"); return To_String (Result); end Image; procedure Define (The_Command : out Command; Command_Line : in String) is use Ada.Strings.Fixed; I : constant Natural := Index (Command_Line, " "); begin The_Command.Copy_Count := new Count' (1); if I = 0 then The_Command.Name := +Command_Line; return; end if; declare Name : constant String := Command_Line (Command_Line'First .. I - 1); Arguments : constant String_Array := To_Arguments (Command_Line (I + 1 .. Command_Line'Last)); begin The_Command.Name := +(Name); The_Command.Arguments := To_String_Vector (Arguments); end; end Define; package body Forge is function To_Command (Command_Line : in String) return Command is use Ada.Strings.Fixed; I : constant Natural := Index (Command_Line, " "); begin if I = 0 then return Result : Command do Result.Name := +Command_Line; Result.Copy_Count := new Count' (1); end return; end if; declare Name : constant String := Command_Line (Command_Line'First .. I - 1); Arguments : constant String_Array := To_Arguments (Command_Line (I + 1 .. Command_Line'Last)); begin return Result : Command do Result.Name := +(Name); Result.Arguments := To_String_Vector (Arguments); Result.Copy_Count := new Count' (1); end return; end; end to_Command; function To_Commands (Pipeline : in String) return Command_Array is use Ada.Strings.Fixed; Cursor : Positive := Pipeline'First; First, Last : Positive; Count : Natural := 0; Max_Commands_In_Pipeline : constant := 50; -- Arbitrary. All_Commands : String_Array (1 .. Max_Commands_In_Pipeline); begin loop Find_Token (Source => Pipeline, Set => Ada.Strings.Maps.To_Set ('|'), From => Cursor, Test => Ada.Strings.Outside, First => First, Last => Last); declare Full_Command : constant String := Trim (Pipeline (First .. Last), Ada.Strings.Both); begin Count := Count + 1; All_Commands (Count) := +Full_Command; end; exit when Last = Pipeline'Last; Cursor := Last + 1; end loop; return Result : Command_Array (1 .. Count) do for i in 1 .. Count loop Define ( Result (i), +All_Commands (i)); end loop; end return; end To_Commands; end Forge; procedure Connect (From, To : in out Command) is Pipe : constant Shell.Pipe := To_Pipe; begin From.Output_Pipe := Pipe; To. Input_Pipe := Pipe; From.Owns_Input_Pipe := True; To. Owns_Output_Pipe := True; end Connect; procedure Connect (Commands : in out Command_Array) is begin for i in Commands'First .. Commands'Last - 1 loop Connect (From => Commands (i), To => Commands (i + 1)); end loop; end Connect; procedure Close_Pipe_Write_Ends (The_Command : in out Command) is begin if The_Command.Output_Pipe /= Standard_Output then Close_Write_End (The_Command.Output_Pipe); end if; if The_Command.Error_Pipe /= Standard_Error then Close_Write_End (The_Command.Error_Pipe); end if; end Close_Pipe_Write_Ends; function Input_Pipe (The_Command : in Command) return Pipe is begin return The_Command.Input_Pipe; end Input_Pipe; function Output_Pipe (The_Command : in Command) return Pipe is begin return The_Command.Output_Pipe; end Output_Pipe; function Error_Pipe (The_Command : in Command) return Pipe is begin return The_Command.Error_Pipe; end Error_Pipe; function Name (The_Command : in Command) return String is begin return +The_Command.Name; end Name; function Arguments (The_Command : in Command) return String is All_Arguments : Unbounded_String; Last : constant Natural := Natural (The_Command.Arguments.Length); begin for i in 1 .. Last loop Append (All_Arguments, The_Command.Arguments.Element (i)); if i /= Last then Append (All_Arguments, " "); end if; end loop; return To_String (All_Arguments); end Arguments; function Process (The_Command : in out Command) return access Shell.Process is begin return The_Command.Process'Unchecked_Access; end Process; --- Start -- procedure Start (The_Command : in out Command; Input : in Data := No_Data; Pipeline : in Boolean := False) is begin if Input /= No_Data then The_Command.Input_Pipe := To_Pipe; Write_To (The_Command.Input_Pipe, Input); end if; if The_Command.Output_Pipe = Null_Pipe then The_Command.Owns_Output_Pipe := True; The_Command.Output_Pipe := To_Pipe (Blocking => False); end if; if The_Command.Error_Pipe = Null_Pipe then The_Command. Error_Pipe := To_Pipe (Blocking => False); end if; The_Command.Process := Start (Program => +The_Command.Name, Arguments => To_String_Array (The_Command.Arguments), Input => The_Command.Input_Pipe, Output => The_Command.Output_Pipe, Errors => The_Command.Error_Pipe, Pipeline => Pipeline); end Start; procedure Start (Commands : in out Command_Array; Input : in Data := No_Data; Pipeline : in Boolean := True) is begin if not Pipeline then for Each of Commands loop Start (Each, Input); end loop; return; end if; Connect (Commands); for i in Commands'Range loop if i = Commands'First then Start (Commands (i), Input, Pipeline => True); else Start (Commands (i), Pipeline => True); end if; -- Since we are making a pipeline, we need to close the write ends of -- the Output & Errors pipes ourselves. -- if i /= Commands'First then Close_Pipe_Write_Ends (Commands (i - 1)); -- Close ends for the prior command. end if; end loop; Close_Pipe_Write_Ends (Commands (Commands'Last)); -- Close ends for the final command. end Start; --- Run -- procedure Gather_Results (The_Command : in out Command) is begin declare The_Output : constant Data := Output_Of (The_Command.Output_Pipe); begin if The_Output'Length /= 0 then The_Command.Output.Append (The_Output); end if; end; declare The_Errors : constant Data := Output_Of (The_Command.Error_Pipe); begin if The_Errors'Length /= 0 then The_Command.Errors.Append (The_Errors); end if; end; end Gather_Results; procedure Run (The_Command : in out Command; Input : in Data := No_Data; Raise_Error : in Boolean := False) is begin Start (The_Command, Input); loop Gather_Results (The_Command); -- Gather on-going results. exit when Has_Terminated (The_Command.Process); end loop; Gather_Results (The_Command); -- Gather any final results. if not Normal_Exit (The_Command.Process) and Raise_Error then declare Error : constant String := +Output_Of (The_Command.Error_Pipe); begin raise Command_Error with Error; end; end if; end Run; function Run (The_Command : in out Command; Input : in Data := No_Data; Raise_Error : in Boolean := False) return Command_Results is begin Run (The_Command, Input, Raise_Error); return Results_Of (The_Command); end Run; procedure Run (The_Pipeline : in out Command_Array; Input : in Data := No_Data; Raise_Error : in Boolean := False) is Last_Command : Command renames The_Pipeline (The_Pipeline'Last); i : Positive := 1; begin Last_Command.Output_Pipe := To_Pipe; Start (The_Pipeline, Input); loop Gather_Results (Last_Command); -- Gather on-going results. if Has_Terminated (The_Pipeline (i).Process) then if Normal_Exit (The_Pipeline (i).Process) then i := i + 1; if i > The_Pipeline'Last then Gather_Results (Last_Command); -- Gather any final results. exit; end if; else declare Error : constant String := "Pipeline command" & Integer'Image (i) & " '" & (+The_Pipeline (i).Name) & "' failed."; begin -- Stop the pipeline. -- while i <= The_Pipeline'Last loop Stop (The_Pipeline (i)); i := i + 1; end loop; if Raise_Error then raise Command_Error with Error; else exit; end if; end; end if; end if; end loop; end Run; function Run (The_Pipeline : in out Command_Array; Input : in Data := No_Data; Raise_Error : in Boolean := False) return Command_Results is Last_Command : Command renames The_Pipeline (The_Pipeline'Last); begin Run (The_Pipeline, Input, Raise_Error); return Results_Of (Last_Command); end Run; function Run (Command_Line : in String; Input : in Data := No_Data) return Command_Results is use Ada.Strings.Fixed, Shell.Commands.Forge; The_Index : constant Natural := Index (Command_Line, " | "); Is_Pipeline : constant Boolean := The_Index /= 0; begin if Is_Pipeline then declare The_Commands : Command_Array := To_Commands (Command_Line); begin return Run (The_Commands, Input); end; else declare The_Command : Command := To_Command (Command_Line); begin return Run (The_Command, Input); end; end if; end Run; procedure Run (Command_Line : in String; Input : in Data := No_Data) is Results : Command_Results := Run (Command_Line, Input) with Unreferenced; begin null; end Run; procedure Stop (The_Command : in out Command) is use Ada.Characters.Handling, Ada.Exceptions; begin The_Command.Gather_Results; Close (The_Command. Input_Pipe); Close (The_Command.Output_Pipe); Close (The_Command. Error_Pipe); begin Kill (The_Command); exception when E : POSIX.POSIX_Error => if To_Upper (Exception_Message (E)) /= "NO_SUCH_PROCESS" then Log ("Unable to kill process" & Image (The_Command.Process)); raise; end if; end; begin Wait_On (The_Command.Process); -- Reap zombies. exception when E : POSIX.POSIX_Error => if To_Upper (Exception_Message (E)) /= "NO_CHILD_PROCESS" then Log ("Unable to wait on process" & Image (The_Command.Process)); raise; end if; end; end Stop; function Failed (The_Command : in Command) return Boolean is begin return not Normal_Exit (The_Command.Process); end Failed; function Failed (The_Pipeline : in Command_Array) return Boolean is begin for Each of The_Pipeline loop if Failed (Each) then return True; end if; end loop; return False; end Failed; function Which_Failed (The_Pipeline : in Command_Array) return Natural is begin for i in The_Pipeline'Range loop if not Normal_Exit (The_Pipeline (i).Process) then return i; end if; end loop; return 0; end Which_Failed; -- Command Results -- function Results_Of (The_Command : in out Command) return Command_Results is use Data_Vectors; Output_Size : Data_Offset := 0; Errors_Size : Data_Offset := 0; begin Gather_Results (The_Command); for Each of The_Command.Output loop Output_Size := Output_Size + Each'Length; end loop; for Each of The_Command.Errors loop Errors_Size := Errors_Size + Each'Length; end loop; declare Output : Data (1 .. Output_Size); Errors : Data (1 .. Errors_Size); procedure Set_Data (From : in out Data_Vector; To : out Data) is First : Data_Index := 1; Last : Data_Index; begin for Each of From loop Last := First + Each'Length - 1; To (First .. Last) := Each; First := Last + 1; end loop; From.Clear; end Set_Data; begin Set_Data (The_Command.Output, Output); Set_Data (The_Command.Errors, Errors); return (Output_Size => Output_Size, Error_Size => Errors_Size, Output => Output, Errors => Errors); end; exception when Storage_Error => raise Command_Error with "Command output exceeds stack capacity. " & "Increase the stack limit via 'ulimit -s'."; end Results_Of; function Output_Of (The_Results : in Command_Results) return Data is begin return The_Results.Output; end Output_Of; function Errors_Of (The_Results : in Command_Results) return Data is begin return The_Results.Errors; end Errors_Of; procedure Wait_On (The_Command : in out Command) is begin Wait_On (The_Command.Process); end Wait_On; function Has_Terminated (The_Command : in out Command) return Boolean is begin return Has_Terminated (The_Command.Process); end Has_Terminated; function Normal_Exit (The_Command : in Command) return Boolean is begin return Normal_Exit (The_Command.Process); end Normal_Exit; procedure Kill (The_Command : in Command) is begin Kill (The_Command.Process); end Kill; procedure Interrupt (The_Command : in Command) is begin Interrupt (The_Command.Process); end Interrupt; procedure Pause (The_Command : in Command) is begin Pause (The_Command.Process); end Pause; procedure Resume (The_Command : in Command) is begin Resume (The_Command.Process); end Resume; --- Controlled -- overriding procedure Adjust (The_Command : in out Command) is begin The_Command.Copy_Count.all := The_Command.Copy_Count.all + 1; end Adjust; overriding procedure Finalize (The_Command : in out Command) is procedure Deallocate is new Ada.Unchecked_Deallocation (Count, Count_Access); begin The_Command.Copy_Count.all := The_Command.Copy_Count.all - 1; if The_Command.Copy_Count.all = 0 then if The_Command.Owns_Input_Pipe then Close (The_Command.Input_Pipe); end if; if The_Command.Owns_Output_Pipe then Close (The_Command.Output_Pipe); end if; Close (The_Command.Error_Pipe); Deallocate (The_Command.Copy_Count); end if; end Finalize; function Hash (Id : in Command_Id) return Ada.Containers.Hash_Type is begin return Ada.Containers.Hash_Type (Id); end Hash; end Shell.Commands;
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32G474xx.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package STM32_SVD.CORDIC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CSR_FUNC_Field is HAL.UInt4; subtype CSR_PRECISION_Field is HAL.UInt4; subtype CSR_SCALE_Field is HAL.UInt3; -- CORDIC Control Status register type CSR_Register is record -- FUNC FUNC : CSR_FUNC_Field := 16#0#; -- PRECISION PRECISION : CSR_PRECISION_Field := 16#0#; -- SCALE SCALE : CSR_SCALE_Field := 16#0#; -- unspecified Reserved_11_15 : HAL.UInt5 := 16#0#; -- IEN IEN : Boolean := False; -- DMAREN DMAREN : Boolean := False; -- DMAWEN DMAWEN : Boolean := False; -- NRES NRES : Boolean := False; -- NARGS NARGS : Boolean := False; -- RESSIZE RESSIZE : Boolean := False; -- ARGSIZE ARGSIZE : Boolean := False; -- unspecified Reserved_23_30 : HAL.UInt8 := 16#0#; -- RRDY RRDY : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record FUNC at 0 range 0 .. 3; PRECISION at 0 range 4 .. 7; SCALE at 0 range 8 .. 10; Reserved_11_15 at 0 range 11 .. 15; IEN at 0 range 16 .. 16; DMAREN at 0 range 17 .. 17; DMAWEN at 0 range 18 .. 18; NRES at 0 range 19 .. 19; NARGS at 0 range 20 .. 20; RESSIZE at 0 range 21 .. 21; ARGSIZE at 0 range 22 .. 22; Reserved_23_30 at 0 range 23 .. 30; RRDY at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- CORDIC Co-processor type CORDIC_Peripheral is record -- CORDIC Control Status register CSR : aliased CSR_Register; -- FMAC Write Data register WDATA : aliased HAL.UInt32; -- FMAC Read Data register RDATA : aliased HAL.UInt32; end record with Volatile; for CORDIC_Peripheral use record CSR at 16#0# range 0 .. 31; WDATA at 16#4# range 0 .. 31; RDATA at 16#8# range 0 .. 31; end record; -- CORDIC Co-processor CORDIC_Periph : aliased CORDIC_Peripheral with Import, Address => CORDIC_Base; end STM32_SVD.CORDIC;
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; with glib.Values; with System; -- with GStreamer.GST_Low_Level.glib_2_0_gobject_gobject_h; with glib; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_interfaces_tunernorm_h is -- unsupported macro: GST_TYPE_TUNER_NORM (gst_tuner_norm_get_type ()) -- arg-macro: function GST_TUNER_NORM (obj) -- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TUNER_NORM, GstTunerNorm); -- arg-macro: function GST_TUNER_NORM_CLASS (klass) -- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TUNER_NORM, GstTunerNormClass); -- arg-macro: function GST_IS_TUNER_NORM (obj) -- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_NORM); -- arg-macro: function GST_IS_TUNER_NORM_CLASS (klass) -- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_NORM); -- GStreamer Tuner -- * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net> -- * -- * tunernorm.h: tuner norm object design -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library 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 -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library 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. -- type GstTunerNorm; --subtype GstTunerNorm is u_GstTunerNorm; -- gst/interfaces/tunernorm.h:40 type GstTunerNormClass; type u_GstTunerNormClass_u_gst_reserved_array is array (0 .. 3) of System.Address; --subtype GstTunerNormClass is u_GstTunerNormClass; -- gst/interfaces/tunernorm.h:41 --* -- * GstTunerNorm: -- * @label: A string containing a descriptive name for the norm -- * @framerate: A GValue containing the framerate associated with this norm, -- * if any. (May be unset). -- type GstTunerNorm is record parent : aliased GLIB.Object.GObject; -- gst/interfaces/tunernorm.h:50 label : access GLIB.gchar; -- gst/interfaces/tunernorm.h:53 framerate : aliased Glib.Values.GValue; -- gst/interfaces/tunernorm.h:54 end record; pragma Convention (C_Pass_By_Copy, GstTunerNorm); -- gst/interfaces/tunernorm.h:49 --< public > type GstTunerNormClass is record parent : aliased GLIB.Object.GObject_Class; -- gst/interfaces/tunernorm.h:58 u_gst_reserved : u_GstTunerNormClass_u_gst_reserved_array; -- gst/interfaces/tunernorm.h:60 end record; pragma Convention (C_Pass_By_Copy, GstTunerNormClass); -- gst/interfaces/tunernorm.h:57 function gst_tuner_norm_get_type return GLIB.GType; -- gst/interfaces/tunernorm.h:63 pragma Import (C, gst_tuner_norm_get_type, "gst_tuner_norm_get_type"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_interfaces_tunernorm_h;
--////////////////////////////////////////////////////////// -- SFML - Simple and Fast Multimedia Library -- Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) -- This software is provided 'as-is', without any express or implied warranty. -- In no event will the authors be held liable for any damages arising from the use of this software. -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it freely, -- subject to the following restrictions: -- 1. The origin of this software must not be misrepresented; -- you must not claim that you wrote the original software. -- If you use this software in a product, an acknowledgment -- in the product documentation would be appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, -- and must not be misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// with Sf.Graphics.PrimitiveType; with Sf.Graphics.Vertex; package Sf.Graphics.VertexBuffer is --////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////// --/ @brief Usage specifiers --/ --/ If data is going to be updated once or more every frame, --/ set the usage to sfVertexBufferStream. If data is going --/ to be set once and used for a long time without being --/ modified, set the usage to sfVertexBufferUsageStatic. --/ For everything else sfVertexBufferUsageDynamic should --/ be a good compromise. --/ --////////////////////////////////////////////////////////// --/< Constantly changing data --/< Occasionally changing data --/< Rarely changing data type sfVertexBufferUsage is (sfVertexBufferStream, sfVertexBufferDynamic, sfVertexBufferStatic); --////////////////////////////////////////////////////////// --/ @brief Create a new vertex buffer with a specific --/ sfPrimitiveType and usage specifier. --/ --/ Creates the vertex buffer, allocating enough graphcis --/ memory to hold @p vertexCount vertices, and sets its --/ primitive type to @p type and usage to @p usage. --/ --/ @param vertexCount Amount of vertices --/ @param primitiveType Type of primitive --/ @param usage Usage specifier --/ --/ @return A new sfVertexBuffer object --/ --////////////////////////////////////////////////////////// function create (vertexCount : sfUint32; primitiveType : Sf.Graphics.PrimitiveType.sfPrimitiveType; usage : sfVertexBufferUsage) return sfVertexBuffer_Ptr; --////////////////////////////////////////////////////////// --/ @brief Copy an existing vertex buffer --/ --/ @param vertexBuffer Vertex buffer to copy --/ --/ @return Copied object --/ --////////////////////////////////////////////////////////// function copy (vertexBuffer : sfVertexBuffer_Ptr) return sfVertexBuffer_Ptr; --////////////////////////////////////////////////////////// --/ @brief Destroy an existing vertex buffer --/ --/ @param vertexBuffer Vertex buffer to delete --/ --////////////////////////////////////////////////////////// procedure destroy (vertexBuffer : sfVertexBuffer_Ptr); --////////////////////////////////////////////////////////// --/ @brief Return the vertex count --/ --/ @param vertexBuffer Vertex buffer object --/ --/ @return Number of vertices in the vertex buffer --/ --////////////////////////////////////////////////////////// function getVertexCount (vertexBuffer : sfVertexBuffer_Ptr) return sfUint32; --////////////////////////////////////////////////////////// --/ @brief Update a part of the buffer from an array of vertices --/ --/ @p offset is specified as the number of vertices to skip --/ from the beginning of the buffer. --/ --/ If @p offset is 0 and @p vertexCount is equal to the size of --/ the currently created buffer, its whole contents are replaced. --/ --/ If @p offset is 0 and @p vertexCount is greater than the --/ size of the currently created buffer, a new buffer is created --/ containing the vertex data. --/ --/ If @p offset is 0 and @p vertexCount is less than the size of --/ the currently created buffer, only the corresponding region --/ is updated. --/ --/ If @p offset is not 0 and @p offset + @p vertexCount is greater --/ than the size of the currently created buffer, the update fails. --/ --/ No additional check is performed on the size of the vertex --/ array, passing invalid arguments will lead to undefined --/ behavior. --/ --/ @param vertices Array of vertices to copy to the buffer --/ @param vertexCount Number of vertices to copy --/ @param offset Offset in the buffer to copy to --/ --/ @return sfTrue if the update was successful --/ --////////////////////////////////////////////////////////// function update (vertexBuffer : sfVertexBuffer_Ptr; vertices : sfVertex_Ptr; vertexCount : access constant Sf.Graphics.Vertex.sfVertex; offset : sfUint32) return sfBool; --////////////////////////////////////////////////////////// --/ @brief Copy the contents of another buffer into this buffer --/ --/ @param vertexBuffer Vertex buffer object --/ @param other Vertex buffer whose contents to copy into first vertex buffer --/ --/ @return sfTrue if the copy was successful --/ --////////////////////////////////////////////////////////// function updateFromVertexBuffer (vertexBuffer : sfVertexBuffer_Ptr; other : sfVertexBuffer_Ptr) return sfBool; --////////////////////////////////////////////////////////// --/ @brief Swap the contents of this vertex buffer with those of another --/ --/ @param left Instance to swap --/ @param right Instance to swap with --/ --////////////////////////////////////////////////////////// procedure swap (left : sfVertexBuffer_Ptr; right : sfVertexBuffer_Ptr); --////////////////////////////////////////////////////////// --/ @brief Get the underlying OpenGL handle of the vertex buffer. --/ --/ You shouldn't need to use this function, unless you have --/ very specific stuff to implement that SFML doesn't support, --/ or implement a temporary workaround until a bug is fixed. --/ --/ @return OpenGL handle of the vertex buffer or 0 if not yet created --/ --////////////////////////////////////////////////////////// function getNativeHandle (vertexBuffer : sfVertexBuffer_Ptr) return sfUint32; --////////////////////////////////////////////////////////// --/ @brief Set the type of primitives to draw --/ --/ This function defines how the vertices must be interpreted --/ when it's time to draw them. --/ --/ The default primitive type is sf::Points. --/ --/ @param vertexBuffer Vertex buffer object --/ @param primitiveType Type of primitive --/ --////////////////////////////////////////////////////////// procedure setPrimitiveType (vertexBuffer : sfVertexBuffer_Ptr; primitiveType : Sf.Graphics.PrimitiveType.sfPrimitiveType); --////////////////////////////////////////////////////////// --/ @brief Get the type of primitives drawn by the vertex buffer --/ --/ @param vertexBuffer Vertex buffer object --/ --/ @return Primitive type --/ --////////////////////////////////////////////////////////// function getPrimitiveType (vertexBuffer : sfVertexBuffer_Ptr) return Sf.Graphics.PrimitiveType.sfPrimitiveType; --////////////////////////////////////////////////////////// --/ @brief Set the usage specifier of this vertex buffer --/ --/ This function provides a hint about how this vertex buffer is --/ going to be used in terms of data update frequency. --/ --/ After changing the usage specifier, the vertex buffer has --/ to be updated with new data for the usage specifier to --/ take effect. --/ --/ The default primitive type is sfVertexBufferStream. --/ --/ @param vertexBuffer Vertex buffer object --/ @param usage Usage specifier --/ --////////////////////////////////////////////////////////// procedure setUsage (vertexBuffer : sfVertexBuffer_Ptr; usage : sfVertexBufferUsage); --////////////////////////////////////////////////////////// --/ @brief Get the usage specifier of this vertex buffer --/ --/ @param vertexBuffer Vertex buffer object --/ --/ @return Usage specifier --/ --////////////////////////////////////////////////////////// function getUsage (vertexBuffer : sfVertexBuffer_Ptr) return sfVertexBufferUsage; --////////////////////////////////////////////////////////// --/ @brief Bind a vertex buffer for rendering --/ --/ This function is not part of the graphics API, it mustn't be --/ used when drawing SFML entities. It must be used only if you --/ mix sfVertexBuffer with OpenGL code. --/ --/ @code --/ sfVertexBuffer* vb1, vb2; --/ ... --/ sfVertexBuffer_bind(vb1); --/ // draw OpenGL stuff that use vb1... --/ sfVertexBuffer_bind(vb2); --/ // draw OpenGL stuff that use vb2... --/ sfVertexBuffer_bind(NULL); --/ // draw OpenGL stuff that use no vertex buffer... --/ @endcode --/ --/ @param vertexBuffer Pointer to the vertex buffer to bind, can be null to use no vertex buffer --/ --////////////////////////////////////////////////////////// procedure bind (vertexBuffer : sfVertexBuffer_Ptr); --////////////////////////////////////////////////////////// --/ @brief Tell whether or not the system supports vertex buffers --/ --/ This function should always be called before using --/ the vertex buffer features. If it returns false, then --/ any attempt to use sf::VertexBuffer will fail. --/ --/ @return True if vertex buffers are supported, false otherwise --/ --////////////////////////////////////////////////////////// function isAvailable return sfBool; private pragma Convention (C, sfVertexBufferUsage); pragma Import (C, create, "sfVertexBuffer_create"); pragma Import (C, copy, "sfVertexBuffer_copy"); pragma Import (C, destroy, "sfVertexBuffer_destroy"); pragma Import (C, getVertexCount, "sfVertexBuffer_getVertexCount"); pragma Import (C, update, "sfVertexBuffer_update"); pragma Import (C, updateFromVertexBuffer, "sfVertexBuffer_updateFromVertexBuffer"); pragma Import (C, swap, "sfVertexBuffer_swap"); pragma Import (C, getNativeHandle, "sfVertexBuffer_getNativeHandle"); pragma Import (C, setPrimitiveType, "sfVertexBuffer_setPrimitiveType"); pragma Import (C, getPrimitiveType, "sfVertexBuffer_getPrimitiveType"); pragma Import (C, setUsage, "sfVertexBuffer_setUsage"); pragma Import (C, getUsage, "sfVertexBuffer_getUsage"); pragma Import (C, bind, "sfVertexBuffer_bind"); pragma Import (C, isAvailable, "sfVertexBuffer_isAvailable"); end Sf.Graphics.VertexBuffer;
with Accumulator; with Ada.Text_IO; use Ada.Text_IO; procedure Example is package A is new Accumulator; package B is new Accumulator; begin Put_Line (Integer'Image (A.The_Function (5))); Put_Line (Integer'Image (B.The_Function (3))); Put_Line (Float'Image (A.The_Function (2.3))); end;
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Real_Time; with System; package Ada.Dispatching.Round_Robin is Default_Quantum : constant Ada.Real_Time.Time_Span := implementation_defined; procedure Set_Quantum (Pri : in System.Priority; Quantum : in Ada.Real_Time.Time_Span); procedure Set_Quantum (Low : in System.Priority; High : in System.Priority; Quantum : in Ada.Real_Time.Time_Span); function Actual_Quantum (Pri : in System.Priority) return Ada.Real_Time.Time_Span; function Is_Round_Robin (Pri : in System.Priority) return Boolean; end Ada.Dispatching.Round_Robin;
pragma Ada_2012; with Protypo.Api.Engine_Values.Constant_Wrappers; package body Protypo.Api.Engine_Values.Handlers is function Create (Val : Array_Interface_Access) return Engine_Value is (Engine_Value'(Class => Array_Handler, Array_Object => Val)); function Create (Val : Record_Interface_Access) return Engine_Value is (Engine_Value'(Class => Record_Handler, Record_Object => Val)); function Create (Val : Ambivalent_Interface_Access) return Engine_Value is (Engine_Value'(Class => Ambivalent_Handler, Ambivalent_Object => Val)); function Create (Val : Iterator_Interface_Access) return Engine_Value is (Engine_Value'(Class => Iterator, Iteration_Object => Val)); function Create (Val : Function_Interface_Access) return Engine_Value is (Engine_Value'(Class => Function_Handler, Function_Object => Val)); function Create (Val : Callback_Function_Access; N_Parameters : Natural := 1) return Engine_Value is (Create (new Callback_Based_Handler'(Callback => Val, Min_Parameters => N_Parameters, Max_Parameters => N_Parameters, With_Varargin => False))); function Create (Val : Callback_Function_Access; Min_Parameters : Natural; Max_Parameters : Natural; With_Varargin : Boolean := False) return Engine_Value is (Create (new Callback_Based_Handler'(Callback => Val, Min_Parameters => Min_Parameters, Max_Parameters => Max_Parameters, With_Varargin => With_Varargin))); function Create (Val : Reference_Interface_Access) return Engine_Value is (Engine_Value'(Class => Reference_Handler, Reference_Object => Val)); function Create (Val : Constant_Interface_Access) return Engine_Value is (Engine_Value'(Class => Constant_Handler, Constant_Object => Val)); function Get_Array (Val : Array_Value) return Array_Interface_Access is (Val.Array_Object); function Get_Record (Val : Record_Value) return Record_Interface_Access is (Val.Record_Object); function Get_Ambivalent (Val : Ambivalent_Value) return Ambivalent_Interface_Access is (Val.Ambivalent_Object); function Get_Iterator (Val : Iterator_Value) return Iterator_Interface_Access is (Val.Iteration_Object); function Get_Function (Val : Function_Value) return Function_Interface_Access is (Val.Function_Object); function Get_Reference (Val : Reference_Value) return Reference_Interface_Access is (Val.Reference_Object); function Get_Constant (Val : Constant_Value) return Constant_Interface_Access is (Val.Constant_Object); function Force_Handler (Item : Engine_Value) return Handler_Value is (case Item.Class is when Handler_Classes => Item, when Int => Constant_Wrappers.To_Handler_Value (Get_Integer (Item)), when Real => Constant_Wrappers.To_Handler_Value (Get_Float (Item)), when Text => Constant_Wrappers.To_Handler_Value (Get_String (Item)), when Void | Iterator => raise Constraint_Error); --------------- function Signature (Fun : Callback_Based_Handler) return Parameter_Signature is Tot_Parameters : constant Natural := Fun.Max_Parameters + (if Fun.With_Varargin then 1 else 0); Result : Parameter_Signature (2 .. Tot_Parameters + 1) := (others => No_Spec); -- Result is initialized to an invalid Parameter_Signature, so that -- if there is some bug, it will be (with large probability) -- caught by the contract of Signature Last_Mandatory : constant Natural := Result'First + Fun.Min_Parameters - 1; Last_Optional : constant Natural := Result'First + Fun.Max_Parameters - 1; begin if Fun.Min_Parameters > 0 then Result (Result'First .. Last_Mandatory) := (others => Mandatory); end if; if Fun.Max_Parameters > Fun.Min_Parameters then Result (Last_Mandatory + 1 .. Last_Optional) := (others => Optional (Void_Value)); end if; if Fun.With_Varargin then Result (Result'Last) := Varargin; end if; return Result; end Signature; end Protypo.Api.Engine_Values.Handlers;
-- This file is generated by SWIG. Please do *not* modify by hand. -- with gmp_c.Pointers; with Interfaces.C; package gmp_c.pointer_Pointers is -- mp_limb_t_Pointer_Pointer -- type mp_limb_t_Pointer_Pointer is access all gmp_c.Pointers.mp_limb_t_Pointer; -- mp_limb_signed_t_Pointer_Pointer -- type mp_limb_signed_t_Pointer_Pointer is access all gmp_c.Pointers.mp_limb_signed_t_Pointer; -- mp_bitcnt_t_Pointer_Pointer -- type mp_bitcnt_t_Pointer_Pointer is access all gmp_c.Pointers.mp_bitcnt_t_Pointer; -- mp_size_t_Pointer_Pointer -- type mp_size_t_Pointer_Pointer is access all gmp_c.Pointers.mp_size_t_Pointer; -- mp_exp_t_Pointer_Pointer -- type mp_exp_t_Pointer_Pointer is access all gmp_c.Pointers.mp_exp_t_Pointer; -- gmp_randalg_t_Pointer_Pointer -- type gmp_randalg_t_Pointer_Pointer is access all gmp_c.Pointers.gmp_randalg_t_Pointer; -- anonymous_enum_1_Pointer_Pointer -- type anonymous_enum_1_Pointer_Pointer is access all gmp_c.Pointers.anonymous_enum_1_Pointer; end gmp_c.pointer_Pointers;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . A R I T H _ 3 2 -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2021, 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. -- -- -- -- -- -- -- -- -- -- -- -- 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 Ada.Unchecked_Conversion; package body System.Arith_32 is pragma Suppress (Overflow_Check); pragma Suppress (Range_Check); subtype Uns32 is Interfaces.Unsigned_32; subtype Uns64 is Interfaces.Unsigned_64; use Interfaces; function To_Int is new Ada.Unchecked_Conversion (Uns32, Int32); ----------------------- -- Local Subprograms -- ----------------------- function "abs" (X : Int32) return Uns32 is (if X = Int32'First then 2**31 else Uns32 (Int32'(abs X))); -- Convert absolute value of X to unsigned. Note that we can't just use -- the expression of the Else since it overflows for X = Int32'First. function Hi (A : Uns64) return Uns32 is (Uns32 (Shift_Right (A, 32))); -- High order half of 64-bit value function To_Neg_Int (A : Uns32) return Int32; -- Convert to negative integer equivalent. If the input is in the range -- 0 .. 2**31, then the corresponding nonpositive signed integer (obtained -- by negating the given value) is returned, otherwise constraint error is -- raised. function To_Pos_Int (A : Uns32) return Int32; -- Convert to positive integer equivalent. If the input is in the range -- 0 .. 2**31 - 1, then the corresponding nonnegative signed integer is -- returned, otherwise constraint error is raised. procedure Raise_Error; pragma No_Return (Raise_Error); -- Raise constraint error with appropriate message ----------------- -- Raise_Error -- ----------------- procedure Raise_Error is begin raise Constraint_Error with "32-bit arithmetic overflow"; end Raise_Error; ------------------- -- Scaled_Divide -- ------------------- procedure Scaled_Divide32 (X, Y, Z : Int32; Q, R : out Int32; Round : Boolean) is Xu : constant Uns32 := abs X; Yu : constant Uns32 := abs Y; Zu : constant Uns32 := abs Z; D : Uns64; -- The dividend Qu : Uns32; Ru : Uns32; -- Unsigned quotient and remainder begin -- First do the 64-bit multiplication D := Uns64 (Xu) * Uns64 (Yu); -- If dividend is too large, raise error if Hi (D) >= Zu then Raise_Error; -- Then do the 64-bit division else Qu := Uns32 (D / Uns64 (Zu)); Ru := Uns32 (D rem Uns64 (Zu)); end if; -- Deal with rounding case if Round and then Ru > (Zu - Uns32'(1)) / Uns32'(2) then -- Protect against wrapping around when rounding, by signaling -- an overflow when the quotient is too large. if Qu = Uns32'Last then Raise_Error; end if; Qu := Qu + Uns32'(1); end if; -- Set final signs (RM 4.5.5(27-30)) -- Case of dividend (X * Y) sign positive if (X >= 0 and then Y >= 0) or else (X < 0 and then Y < 0) then R := To_Pos_Int (Ru); Q := (if Z > 0 then To_Pos_Int (Qu) else To_Neg_Int (Qu)); -- Case of dividend (X * Y) sign negative else R := To_Neg_Int (Ru); Q := (if Z > 0 then To_Neg_Int (Qu) else To_Pos_Int (Qu)); end if; end Scaled_Divide32; ---------------- -- To_Neg_Int -- ---------------- function To_Neg_Int (A : Uns32) return Int32 is R : constant Int32 := (if A = 2**31 then Int32'First else -To_Int (A)); -- Note that we can't just use the expression of the Else, because it -- overflows for A = 2**31. begin if R <= 0 then return R; else Raise_Error; end if; end To_Neg_Int; ---------------- -- To_Pos_Int -- ---------------- function To_Pos_Int (A : Uns32) return Int32 is R : constant Int32 := To_Int (A); begin if R >= 0 then return R; else Raise_Error; end if; end To_Pos_Int; end System.Arith_32;
pragma License (Unrestricted); with Ada; package GNAT.Source_Info is pragma Pure; function File return String renames Ada.Debug.File; function Line return Integer renames Ada.Debug.Line; function Source_Location return String renames Ada.Debug.Source_Location; function Enclosing_Entity return String renames Ada.Debug.Enclosing_Entity; end GNAT.Source_Info;
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with League.Strings.Hash; with Ada.Containers.Hashed_Maps; with WebIDL.Scanner_Handlers; with WebIDL.Scanners; with WebIDL.Scanner_Types; with WebIDL.Tokens; package WebIDL.Token_Handlers is pragma Preelaborate; type Handler is limited new WebIDL.Scanner_Handlers.Handler with private; procedure Initialize (Self : in out Handler'Class); overriding procedure Delimiter (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Ellipsis (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Integer (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Decimal (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Identifier (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure String (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Whitespace (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Line_Comment (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Comment_Start (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Comment_End (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); overriding procedure Comment_Text (Self : not null access Handler; Scanner : not null access WebIDL.Scanners.Scanner'Class; Rule : WebIDL.Scanner_Types.Rule_Index; Token : out WebIDL.Tokens.Token_Kind; Skip : in out Boolean); private package Keyword_Maps is new Ada.Containers.Hashed_Maps (Key_Type => League.Strings.Universal_String, Element_Type => WebIDL.Tokens.Token_Kind, Hash => League.Strings.Hash, Equivalent_Keys => League.Strings."=", "=" => WebIDL.Tokens."="); type Handler is limited new WebIDL.Scanner_Handlers.Handler with record Map : Keyword_Maps.Map; end record; end WebIDL.Token_Handlers;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.SysTick is pragma Preelaborate; --------------- -- Registers -- --------------- -- SysTick Counter Enable type CSR_ENABLESelect is (-- Counter disabled VALUE_0, -- Counter enabled VALUE_1) with Size => 1; for CSR_ENABLESelect use (VALUE_0 => 0, VALUE_1 => 1); -- SysTick Exception Request Enable type CSR_TICKINTSelect is (-- Counting down to 0 does not assert the SysTick exception request VALUE_0, -- Counting down to 0 asserts the SysTick exception request VALUE_1) with Size => 1; for CSR_TICKINTSelect use (VALUE_0 => 0, VALUE_1 => 1); -- Clock Source 0=external, 1=processor type CSR_CLKSOURCESelect is (-- External clock VALUE_0, -- Processor clock VALUE_1) with Size => 1; for CSR_CLKSOURCESelect use (VALUE_0 => 0, VALUE_1 => 1); -- SysTick Control and Status Register type SysTick_CSR_Register is record -- SysTick Counter Enable ENABLE : CSR_ENABLESelect := SAM_SVD.SysTick.VALUE_0; -- SysTick Exception Request Enable TICKINT : CSR_TICKINTSelect := SAM_SVD.SysTick.VALUE_0; -- Clock Source 0=external, 1=processor CLKSOURCE : CSR_CLKSOURCESelect := SAM_SVD.SysTick.VALUE_1; -- unspecified Reserved_3_15 : HAL.UInt13 := 16#0#; -- Timer counted to 0 since last read of register COUNTFLAG : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SysTick_CSR_Register use record ENABLE at 0 range 0 .. 0; TICKINT at 0 range 1 .. 1; CLKSOURCE at 0 range 2 .. 2; Reserved_3_15 at 0 range 3 .. 15; COUNTFLAG at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype SysTick_RVR_RELOAD_Field is HAL.UInt24; -- SysTick Reload Value Register type SysTick_RVR_Register is record -- Value to load into the SysTick Current Value Register when the -- counter reaches 0 RELOAD : SysTick_RVR_RELOAD_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SysTick_RVR_Register use record RELOAD at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype SysTick_CVR_CURRENT_Field is HAL.UInt24; -- SysTick Current Value Register type SysTick_CVR_Register is record -- Current value at the time the register is accessed CURRENT : SysTick_CVR_CURRENT_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SysTick_CVR_Register use record CURRENT at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype SysTick_CALIB_TENMS_Field is HAL.UInt24; -- TENMS is rounded from non-integer ratio type CALIB_SKEWSelect is (-- 10ms calibration value is exact VALUE_0, -- 10ms calibration value is inexact, because of the clock frequency VALUE_1) with Size => 1; for CALIB_SKEWSelect use (VALUE_0 => 0, VALUE_1 => 1); -- No Separate Reference Clock type CALIB_NOREFSelect is (-- The reference clock is provided VALUE_0, -- The reference clock is not provided VALUE_1) with Size => 1; for CALIB_NOREFSelect use (VALUE_0 => 0, VALUE_1 => 1); -- SysTick Calibration Value Register type SysTick_CALIB_Register is record -- Read-only. Reload value to use for 10ms timing TENMS : SysTick_CALIB_TENMS_Field; -- unspecified Reserved_24_29 : HAL.UInt6; -- Read-only. TENMS is rounded from non-integer ratio SKEW : CALIB_SKEWSelect; -- Read-only. No Separate Reference Clock NOREF : CALIB_NOREFSelect; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SysTick_CALIB_Register use record TENMS at 0 range 0 .. 23; Reserved_24_29 at 0 range 24 .. 29; SKEW at 0 range 30 .. 30; NOREF at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- System timer type SysTick_Peripheral is record -- SysTick Control and Status Register CSR : aliased SysTick_CSR_Register; -- SysTick Reload Value Register RVR : aliased SysTick_RVR_Register; -- SysTick Current Value Register CVR : aliased SysTick_CVR_Register; -- SysTick Calibration Value Register CALIB : aliased SysTick_CALIB_Register; end record with Volatile; for SysTick_Peripheral use record CSR at 16#0# range 0 .. 31; RVR at 16#4# range 0 .. 31; CVR at 16#8# range 0 .. 31; CALIB at 16#C# range 0 .. 31; end record; -- System timer SysTick_Periph : aliased SysTick_Peripheral with Import, Address => SysTick_Base; end SAM_SVD.SysTick;
with Interfaces; package ACO.Utils.Byte_Order is pragma Preelaborate; use Interfaces; type Octets is array (Natural range <>) of Unsigned_8; type Octets_2 is array (0 .. 1) of Unsigned_8; type Octets_4 is array (0 .. 3) of Unsigned_8; type Octets_8 is array (0 .. 7) of Unsigned_8; function Swap_Bus (X : Unsigned_16) return Unsigned_16; pragma Inline (Swap_Bus); function Swap_Bus (X : Unsigned_32) return Unsigned_32; pragma Inline (Swap_Bus); function Swap_Bus (X : Octets_2) return Unsigned_16; pragma Inline (Swap_Bus); function Swap_Bus (X : Octets_4) return Unsigned_32; pragma Inline (Swap_Bus); function Swap_Bus (X : Unsigned_16) return Octets_2; pragma Inline (Swap_Bus); function Swap_Bus (X : Unsigned_32) return Octets_4; pragma Inline (Swap_Bus); procedure Swap (X : in out Octets); pragma Inline (Swap); function Swap_Bus (X : in Octets) return Octets; pragma Inline (Swap_Bus); end ACO.Utils.Byte_Order;
----------------------------------------------------------------------- -- serialize-io-csv-tests -- Unit tests for CSV parser -- Copyright (C) 2011, 2016, 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams.Stream_IO; with Util.Test_Caller; with Util.Streams.Files; with Util.Serialize.Mappers.Tests; with Util.Serialize.IO.JSON.Tests; package body Util.Serialize.IO.CSV.Tests is package Caller is new Util.Test_Caller (Test, "Serialize.IO.CSV"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Serialize.IO.CSV.Parse (parse Ok)", Test_Parser'Access); Caller.Add_Test (Suite, "Test Util.Serialize.IO.CSV.Write", Test_Output'Access); end Add_Tests; -- ------------------------------ -- Check various (basic) JSON valid strings (no mapper). -- ------------------------------ procedure Test_Parser (T : in out Test) is use Util.Serialize.Mappers.Tests; procedure Check_Parse (Content : in String; Expect : in Integer); Mapping : aliased Util.Serialize.Mappers.Tests.Map_Test_Mapper.Mapper; Vector_Mapper : aliased Util.Serialize.Mappers.Tests.Map_Test_Vector_Mapper.Mapper; procedure Check_Parse (Content : in String; Expect : in Integer) is P : Parser; Value : aliased Map_Test_Vector.Vector; Mapper : Util.Serialize.Mappers.Processing; begin Mapper.Add_Mapping ("", Vector_Mapper'Unchecked_Access); Map_Test_Vector_Mapper.Set_Context (Mapper, Value'Unchecked_Access); P.Parse_String (Content, Mapper); T.Assert (not P.Has_Error, "Parse error for: " & Content); Util.Tests.Assert_Equals (T, 1, Integer (Value.Length), "Invalid result length"); Util.Tests.Assert_Equals (T, Expect, Integer (Value.Element (1).Value), "Invalid value"); end Check_Parse; HDR : constant String := "name,status,value,bool" & ASCII.CR & ASCII.LF; begin Mapping.Add_Mapping ("name", FIELD_NAME); Mapping.Add_Mapping ("value", FIELD_VALUE); Mapping.Add_Mapping ("status", FIELD_BOOL); Mapping.Add_Mapping ("bool", FIELD_BOOL); Vector_Mapper.Set_Mapping (Mapping'Unchecked_Access); Check_Parse (HDR & "joe,false,23,true", 23); Check_Parse (HDR & "billy,false,""12"",true", 12); Check_Parse (HDR & """John Potter"",false,""1234"",true", 1234); Check_Parse (HDR & """John" & ASCII.CR & "Potter"",False,""3234"",True", 3234); Check_Parse (HDR & """John" & ASCII.LF & "Potter"",False,""3234"",True", 3234); end Test_Parser; -- ------------------------------ -- Test the CSV output stream generation. -- ------------------------------ procedure Test_Output (T : in out Test) is File : aliased Util.Streams.Files.File_Stream; Stream : Util.Serialize.IO.CSV.Output_Stream; Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-stream.csv"); Path : constant String := Util.Tests.Get_Test_Path ("test-stream.csv"); begin File.Create (Mode => Ada.Streams.Stream_IO.Out_File, Name => Path); Stream.Initialize (Output => File'Unchecked_Access, Size => 10000); Util.Serialize.IO.JSON.Tests.Write_Stream (Stream); Stream.Close; Util.Tests.Assert_Equal_Files (T => T, Expect => Expect, Test => Path, Message => "CSV output serialization"); end Test_Output; end Util.Serialize.IO.CSV.Tests;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Statements; with Program.Elements.Defining_Identifiers; with Program.Lexical_Elements; with Program.Element_Vectors; with Program.Elements.Identifiers; package Program.Elements.Loop_Statements is pragma Pure (Program.Elements.Loop_Statements); type Loop_Statement is limited interface and Program.Elements.Statements.Statement; type Loop_Statement_Access is access all Loop_Statement'Class with Storage_Size => 0; not overriding function Statement_Identifier (Self : Loop_Statement) return Program.Elements.Defining_Identifiers.Defining_Identifier_Access is abstract; not overriding function Statements (Self : Loop_Statement) return not null Program.Element_Vectors.Element_Vector_Access is abstract; not overriding function End_Statement_Identifier (Self : Loop_Statement) return Program.Elements.Identifiers.Identifier_Access is abstract; type Loop_Statement_Text is limited interface; type Loop_Statement_Text_Access is access all Loop_Statement_Text'Class with Storage_Size => 0; not overriding function To_Loop_Statement_Text (Self : aliased in out Loop_Statement) return Loop_Statement_Text_Access is abstract; not overriding function Colon_Token (Self : Loop_Statement_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Loop_Token (Self : Loop_Statement_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function End_Token (Self : Loop_Statement_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Loop_Token_2 (Self : Loop_Statement_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Loop_Statement_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Loop_Statements;
-- { dg-do compile } -- { dg-options "-O -gnatws" } procedure Opt63 is type T_MOD is mod 2**32; subtype T_INDEX is T_MOD range 3_000_000_000 .. 4_000_000_000; type T_ARRAY is array(T_INDEX range <>) of INTEGER; function Build_Crash(First : T_INDEX; Length : NATURAL) return T_ARRAY is R : T_ARRAY(First .. T_Index'Val (T_Index'Pos (First) + Length)) := (others => -1); -- Crash here begin return R; end; begin null; end;