content
stringlengths
23
1.05M
with Ada.Command_Line; with Ada.Exceptions; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; procedure hexlo is begin Put_Line("Ada hexlo program: begin"); Put_line("Ada hexlo program: end"); end hexlo;
package body Ada.Text_IO.Generic_Bounded_IO is procedure Put ( File : File_Type; Item : Bounded.Bounded_String) is begin Put (File, Item.Element (1 .. Item.Length)); -- checking the predicate end Put; procedure Put ( Item : Bounded.Bounded_String) is begin Put (Current_Output.all, Item); end Put; procedure Put_Line ( File : File_Type; Item : Bounded.Bounded_String) is begin Put_Line ( File, -- checking the predicate Item.Element (1 .. Item.Length)); end Put_Line; procedure Put_Line ( Item : Bounded.Bounded_String) is begin Put_Line (Current_Output.all, Item); end Put_Line; function Get_Line ( File : File_Type) return Bounded.Bounded_String is begin return Result : Bounded.Bounded_String do Get_Line (File, Result); -- checking the predicate end return; end Get_Line; function Get_Line return Bounded.Bounded_String is begin return Get_Line (Current_Input.all); end Get_Line; procedure Get_Line ( File : File_Type; Item : out Bounded.Bounded_String) is begin Get_Line (File, Item.Element, Item.Length); -- checking the predicate end Get_Line; procedure Get_Line ( Item : out Bounded.Bounded_String) is begin Get_Line (Current_Input.all, Item); end Get_Line; end Ada.Text_IO.Generic_Bounded_IO;
-- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 Lionel Draghi <lionel.draghi@free.fr> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- 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. -- ----------------------------------------------------------------------------- -- ----------------------------------------------------------------------------- -- Purpose: -- This package manages global settings, hard coded or from cmd line. -- ----------------------------------------------------------------------------- private package Smk.Settings is Smk_Version : constant String := "0.4.0"; -- -------------------------------------------------------------------------- Build_Missing_Targets : Boolean := False; Always_Make : Boolean := False; Explain : Boolean := False; Dry_Run : Boolean := False; Keep_Going : Boolean := False; Ignore_Errors : Boolean := False; Long_Listing_Format : Boolean := False; Warnings_As_Errors : Boolean := False; Shorten_File_Names : Boolean := True; Filter_Sytem_Files : Boolean := True; type Commands is (Build, Read_Smkfile, Status, Whatsnew, List_Previous_Runs, List_Sources, List_Targets, List_Unused, Clean, Reset, Version, Help, Add, Run, Dump, None) with Default_Value => None; Current_Command : Commands; -- -------------------------------------------------------------------------- Smk_File_Prefix : constant String := ".smk."; Strace_Outfile_Prefix : constant String := "/tmp/"; Strace_Outfile_Suffix : constant String := ".strace_output"; Default_Smkfile_Name : constant String := "default.smk"; Shell_Cmd : constant String := "/bin/sh"; Shell_Opt : constant String := "-c "; -- no space before -c! Strace_Cmd : constant String := "/usr/bin/strace -y -q -qq -f -s 100 -e trace=file -o "; -- -y : print paths associated with file descriptor arguments (between <>) -- -q : suppress messages about attaching, detaching, etc. -- -qq : suppress messages about process exit status. -- -f : follow forks -- -s : maximum string size to print (the default is 32) -- Filenames are not considered strings and are always printed in full. -- -------------------------------------------------------------------------- function Initial_Directory return String; -- returns Ada.Directories.Current_Directory at smk launch. -- -------------------------------------------------------------------------- type Print_Out_Level is (Debug, Verbose, Normal, Quiet); -- default: Normal messages are displayed, verbose messages are not -- displayed. -- quiet: Neither normal messages nor verbose messages are displayed. -- This mode can be achieved using option --quiet. -- verbose: Both normal messages and verbose messages are displayed. -- This mode can be achieved using option --verbose. Verbosity : Print_Out_Level := Normal; -- -------------------------------------------------------------------------- function Debug_Mode return Boolean is (Verbosity = Debug); -- -------------------------------------------------------------------------- function Is_System (File_Name : in String) return Boolean; function In_Ignore_List (File_Name : in String) return Boolean; -- Return True for files like /etc/ld.so.cache that are updated -- on each execution, or like /dev/* that are not "normal" files -- in a build context. type Filter_List is array (Positive range <>) of access String; function System_Files return Filter_List; function Ignore_List return Filter_List; -- -------------------------------------------------------------------------- -- Smkfile_Name = "../hello.c/Makefile.txt" -- Runfile_Name = ".smk.Makefile.txt" -- that is Runfile_Name = "Prefix + Simple_Name (Smkfile_Name)" procedure Set_Smkfile_Name (Name : in String); function Smkfile_Name return String; -- Smkfile_Name returns "" if Smkfile has not been set function Is_Smkfile_Name_Set return Boolean; function Run_Dir_Name return String; function Strace_Outfile_Name return String; -- -------------------------------------------------------------------------- procedure Set_Runfile_Name (Name : in String); function Runfile_Name return String; function To_Runfile_Name (Smkfile_Name : in String) return String; -- -------------------------------------------------------------------------- procedure Set_Section_Name (Name : in String); function Section_Name return String; -- -------------------------------------------------------------------------- procedure Add_To_Command_Line (Text : in String); function Command_Line return String; -- -------------------------------------------------------------------------- procedure Set_Target_Name (Target : in String); function Target_Name return String; end Smk.Settings;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2014, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Directories; with Ada.Text_IO; with GNAT.Expect; with GNAT.OS_Lib; with Configure.Instantiate; with Configure.Internals; package body Configure.Builder is use GNAT.Expect; function To_String (Args : GNAT.OS_Lib.Argument_List) return String; -- Converts argument list into printable string. function Build (Report_Log : not null access procedure (Message : String); Directory : String) return Boolean; -- Common code for both variants of procedure. ----------- -- Build -- ----------- function Build (Report_Log : not null access procedure (Message : String); Directory : String) return Boolean is Args : constant GNAT.OS_Lib.Argument_List := (1 => new String'("-p"), 2 => new String'("-P" & Directory & "/check.gpr")); Result : Boolean; begin -- Generate project file from template when necessary. if Ada.Directories.Exists (Directory & "check.gpr.in") then Configure.Instantiate (Directory & "check.gpr", True); end if; -- Run builder. Report_Log ("gnatmake" & To_String (Args)); begin declare Status : aliased Integer; Output : constant String := Get_Command_Output ("gnatmake", Args, "", Status'Access, True); begin Report_Log (Output); Result := Status = 0; end; exception when GNAT.Expect.Invalid_Process => Result := False; end; -- Cleanup build directory. if Ada.Directories.Exists (Directory & "_build") then Ada.Directories.Delete_Tree (Directory & "_build"); end if; -- Remove generated project file when necessary. if Ada.Directories.Exists (Directory & "check.gpr.in") and Ada.Directories.Exists (Directory & "check.gpr") then Ada.Directories.Delete_File (Directory & "check.gpr"); end if; return Result; end Build; ----------- -- Build -- ----------- function Build (Test : Configure.Abstract_Tests.Abstract_Test'Class; Directory : String) return Boolean is procedure Report_Log (Message : String); -- Reports message using test's log stream. ---------------- -- Report_Log -- ---------------- procedure Report_Log (Message : String) is begin Test.Report_Log (Message); end Report_Log; begin return Build (Report_Log'Access, Directory); end Build; ----------- -- Build -- ----------- function Build (Directory : String) return Boolean is procedure Report_Log (Message : String); -- Reports message using global log stream. ---------------- -- Report_Log -- ---------------- procedure Report_Log (Message : String) is begin Ada.Text_IO.Put_Line (Configure.Internals.Log_Output, Message); Ada.Text_IO.Flush (Configure.Internals.Log_Output); end Report_Log; begin return Build (Report_Log'Access, Directory); end Build; --------------- -- To_String -- --------------- function To_String (Args : GNAT.OS_Lib.Argument_List) return String is Result : Unbounded_String; begin for Index in Args'Range loop Append (Result, ' '); Append (Result, Args (Index).all); end loop; return To_String (Result); end To_String; end Configure.Builder;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 1 1 -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for chapter 11 constructs with Types; use Types; package Exp_Ch11 is procedure Expand_N_Exception_Declaration (N : Node_Id); procedure Expand_N_Handled_Sequence_Of_Statements (N : Node_Id); procedure Expand_N_Raise_Constraint_Error (N : Node_Id); procedure Expand_N_Raise_Program_Error (N : Node_Id); procedure Expand_N_Raise_Statement (N : Node_Id); procedure Expand_N_Raise_Storage_Error (N : Node_Id); procedure Expand_N_Subprogram_Info (N : Node_Id); -- Data structures for gathering information to build exception tables -- See runtime routine Ada.Exceptions for full details on the format and -- content of these tables. procedure Initialize; -- Initializes these data structures for a new main unit file procedure Expand_At_End_Handler (HSS : Node_Id; Block : Node_Id); -- Given a handled statement sequence, HSS, for which the At_End_Proc -- field is set, and which currently has no exception handlers, this -- procedure expands the special exception handler required. -- This procedure also create a new scope for the given Block, if -- Block is not Empty. procedure Expand_Exception_Handlers (HSS : Node_Id); -- This procedure expands exception handlers, and is called as part -- of the processing for Expand_N_Handled_Sequence_Of_Statements and -- is also called from Expand_At_End_Handler. N is the handled sequence -- of statements that has the exception handler(s) to be expanded. This -- is also called to expand the special exception handler built for -- accept bodies (see Exp_Ch9.Build_Accept_Body). procedure Generate_Unit_Exception_Table; -- Procedure called by main driver to generate unit exception table if -- zero cost exceptions are enabled. See System.Exceptions for details. function Is_Non_Ada_Error (E : Entity_Id) return Boolean; -- This function is provided for Gigi use. It returns True if operating on -- VMS, and the argument E is the entity for System.Aux_Dec.Non_Ada_Error. -- This is used to generate the special matching code for this exception. procedure Remove_Handler_Entries (N : Node_Id); -- This procedure is called when optimization circuits determine that -- an entire subtree can be removed. If the subtree contains handler -- entries in zero cost exception mode, then such removal can lead to -- dangling references to non-existent handlers in the handler table. -- This procedure removes such references. -------------------------------------- -- Subprogram_Descriptor Generation -- -------------------------------------- -- Subprogram descriptors are required for all subprograms, including -- explicit subprograms defined in the program, subprograms that are -- imported via pragma Import, and also for the implicit elaboration -- subprograms used to elaborate package specs and bodies. procedure Generate_Subprogram_Descriptor_For_Package (N : Node_Id; Spec : Entity_Id); -- This is used to create a descriptor for the implicit elaboration -- procedure for a package spec of body. The compiler only generates -- such descriptors if the package spec or body contains exception -- handlers (either explicitly in the case of a body, or from generic -- package instantiations). N is the node for the package body or -- spec, and Spec is the package body or package entity respectively. -- N must be a compilation unit, and the descriptor is placed at -- the end of the actions for the auxiliary compilation unit node. procedure Generate_Subprogram_Descriptor_For_Subprogram (N : Node_Id; Spec : Entity_Id); -- This is used to create a desriptor for a subprogram, both those -- present in the source, and those implicitly generated by code -- expansion. N is the subprogram body node, and Spec is the entity -- for the subprogram. The descriptor is placed at the end of the -- Last exception handler, or, if there are no handlers, at the end -- of the statement sequence. procedure Generate_Subprogram_Descriptor_For_Imported_Subprogram (Spec : Entity_Id; Slist : List_Id); -- This is used to create a descriptor for an imported subprogram. -- Such descriptors are needed for propagation of exceptions through -- such subprograms. The descriptor never references any handlers, -- and is appended to the given Slist. end Exp_Ch11;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; -- Piloter un drone au moyen d'un menu textuel. procedure Drone is Demarrage: Boolean; -- True si le drone est demarré Altitude: Integer; -- Valeur de l'altitude Choix: Character; -- Choix de l'utilisateur begin Altitude := 0; loop Put("Altitude : "); Put(Altitude, 1); New_Line; New_Line; Put_Line("Que faire ?"); Put_Line(" d -- Démarrer"); Put_Line(" m -- Monter"); Put_Line(" s -- Descendre"); Put_Line(" q -- Quitter"); Put("Votre choix : "); Get(Choix); if Choix = 'd' or Choix = 'D' then Demarrage := True; elsif Choix = 'm' or Choix = 'M' then if Demarrage then Altitude := Altitude + 1; else Put_Line("Le drone n'est pas démarré."); end if; elsif Choix = 's' or Choix = 'S' then if Demarrage then if Altitude = 0 then Put_Line("Le drone est déjà posé."); else Altitude := Altitude - 1; end if; else Put_Line("Le drone n'est pas démarré."); end if; elsif Choix = 'q' or Choix = 'Q' then exit; else Put_Line("Je n'ai pas compris !"); end if; if Altitude > 4 then New_Line; Put_Line("Le drone est hors de portée... et donc perdu !"); return; end if; New_Line; end loop; New_Line; if Demarrage then Put_Line("Au revoir..."); else Put_Line("Vous n'avez pas réussi à le mettre en route ?"); end if; end Drone;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 7 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routines to process package specifications and -- bodies. The most important semantic aspects of package processing are the -- handling of private and full declarations, and the construction of dispatch -- tables for tagged types. with Aspects; use Aspects; with Atree; use Atree; with Contracts; use Contracts; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Disp; use Exp_Disp; with Exp_Dist; use Exp_Dist; with Exp_Dbug; use Exp_Dbug; with Freeze; use Freeze; with Ghost; use Ghost; with GNAT_CUDA; use GNAT_CUDA; with Lib; use Lib; with Lib.Xref; use Lib.Xref; with Namet; use Namet; with Nmake; use Nmake; with Nlists; use Nlists; with Opt; use Opt; with Output; use Output; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Cat; use Sem_Cat; with Sem_Ch3; use Sem_Ch3; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; with Sem_Ch10; use Sem_Ch10; with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Disp; use Sem_Disp; with Sem_Eval; use Sem_Eval; with Sem_Prag; use Sem_Prag; with Sem_Util; use Sem_Util; with Sem_Warn; use Sem_Warn; with Snames; use Snames; with Stand; use Stand; with Sinfo; use Sinfo; with Sinput; use Sinput; with Style; with Uintp; use Uintp; with GNAT.HTable; package body Sem_Ch7 is ----------------------------------- -- Handling private declarations -- ----------------------------------- -- The principle that each entity has a single defining occurrence clashes -- with the presence of two separate definitions for private types: the -- first is the private type declaration, and the second is the full type -- declaration. It is important that all references to the type point to -- the same defining occurrence, namely the first one. To enforce the two -- separate views of the entity, the corresponding information is swapped -- between the two declarations. Outside of the package, the defining -- occurrence only contains the private declaration information, while in -- the private part and the body of the package the defining occurrence -- contains the full declaration. To simplify the swap, the defining -- occurrence that currently holds the private declaration points to the -- full declaration. During semantic processing the defining occurrence -- also points to a list of private dependents, that is to say access types -- or composite types whose designated types or component types are -- subtypes or derived types of the private type in question. After the -- full declaration has been seen, the private dependents are updated to -- indicate that they have full definitions. ----------------------- -- Local Subprograms -- ----------------------- procedure Analyze_Package_Body_Helper (N : Node_Id); -- Does all the real work of Analyze_Package_Body procedure Check_Anonymous_Access_Types (Spec_Id : Entity_Id; P_Body : Node_Id); -- If the spec of a package has a limited_with_clause, it may declare -- anonymous access types whose designated type is a limited view, such an -- anonymous access return type for a function. This access type cannot be -- elaborated in the spec itself, but it may need an itype reference if it -- is used within a nested scope. In that case the itype reference is -- created at the beginning of the corresponding package body and inserted -- before other body declarations. procedure Declare_Inherited_Private_Subprograms (Id : Entity_Id); -- Called upon entering the private part of a public child package and the -- body of a nested package, to potentially declare certain inherited -- subprograms that were inherited by types in the visible part, but whose -- declaration was deferred because the parent operation was private and -- not visible at that point. These subprograms are located by traversing -- the visible part declarations looking for non-private type extensions -- and then examining each of the primitive operations of such types to -- find those that were inherited but declared with a special internal -- name. Each such operation is now declared as an operation with a normal -- name (using the name of the parent operation) and replaces the previous -- implicit operation in the primitive operations list of the type. If the -- inherited private operation has been overridden, then it's replaced by -- the overriding operation. procedure Install_Package_Entity (Id : Entity_Id); -- Supporting procedure for Install_{Visible,Private}_Declarations. Places -- one entity on its visibility chain, and recurses on the visible part if -- the entity is an inner package. function Is_Private_Base_Type (E : Entity_Id) return Boolean; -- True for a private type that is not a subtype function Is_Visible_Dependent (Dep : Entity_Id) return Boolean; -- If the private dependent is a private type whose full view is derived -- from the parent type, its full properties are revealed only if we are in -- the immediate scope of the private dependent. Should this predicate be -- tightened further??? function Requires_Completion_In_Body (Id : Entity_Id; Pack_Id : Entity_Id; Do_Abstract_States : Boolean := False) return Boolean; -- Subsidiary to routines Unit_Requires_Body and Unit_Requires_Body_Info. -- Determine whether entity Id declared in package spec Pack_Id requires -- completion in a package body. Flag Do_Abstract_Stats should be set when -- abstract states are to be considered in the completion test. procedure Unit_Requires_Body_Info (Pack_Id : Entity_Id); -- Outputs info messages showing why package Pack_Id requires a body. The -- caller has checked that the switch requesting this information is set, -- and that the package does indeed require a body. -------------------------- -- Analyze_Package_Body -- -------------------------- procedure Analyze_Package_Body (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); begin if Debug_Flag_C then Write_Str ("==> package body "); Write_Name (Chars (Defining_Entity (N))); Write_Str (" from "); Write_Location (Loc); Write_Eol; Indent; end if; -- The real work is split out into the helper, so it can do "return;" -- without skipping the debug output. Analyze_Package_Body_Helper (N); if Debug_Flag_C then Outdent; Write_Str ("<== package body "); Write_Name (Chars (Defining_Entity (N))); Write_Str (" from "); Write_Location (Loc); Write_Eol; end if; end Analyze_Package_Body; ------------------------------------------------------ -- Analyze_Package_Body_Helper Data and Subprograms -- ------------------------------------------------------ Entity_Table_Size : constant := 4093; -- Number of headers in hash table subtype Entity_Header_Num is Integer range 0 .. Entity_Table_Size - 1; -- Range of headers in hash table function Node_Hash (Id : Entity_Id) return Entity_Header_Num; -- Simple hash function for Entity_Ids package Subprogram_Table is new GNAT.Htable.Simple_HTable (Header_Num => Entity_Header_Num, Element => Boolean, No_Element => False, Key => Entity_Id, Hash => Node_Hash, Equal => "="); -- Hash table to record which subprograms are referenced. It is declared -- at library level to avoid elaborating it for every call to Analyze. package Traversed_Table is new GNAT.Htable.Simple_HTable (Header_Num => Entity_Header_Num, Element => Boolean, No_Element => False, Key => Node_Id, Hash => Node_Hash, Equal => "="); -- Hash table to record which nodes we have traversed, so we can avoid -- traversing the same nodes repeatedly. ----------------- -- Node_Hash -- ----------------- function Node_Hash (Id : Entity_Id) return Entity_Header_Num is begin return Entity_Header_Num (Id mod Entity_Table_Size); end Node_Hash; --------------------------------- -- Analyze_Package_Body_Helper -- --------------------------------- -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos which jump to the end of the routine and restore the -- Ghost mode. procedure Analyze_Package_Body_Helper (N : Node_Id) is procedure Hide_Public_Entities (Decls : List_Id); -- Attempt to hide all public entities found in declarative list Decls -- by resetting their Is_Public flag to False depending on whether the -- entities are not referenced by inlined or generic bodies. This kind -- of processing is a conservative approximation and will still leave -- entities externally visible if the package is not simple enough. procedure Install_Composite_Operations (P : Entity_Id); -- Composite types declared in the current scope may depend on types -- that were private at the point of declaration, and whose full view -- is now in scope. Indicate that the corresponding operations on the -- composite type are available. -------------------------- -- Hide_Public_Entities -- -------------------------- procedure Hide_Public_Entities (Decls : List_Id) is function Has_Referencer (Decls : List_Id; In_Nested_Instance : Boolean; Has_Outer_Referencer_Of_Non_Subprograms : Boolean) return Boolean; -- A "referencer" is a construct which may reference a previous -- declaration. Examine all declarations in list Decls in reverse -- and determine whether one such referencer exists. All entities -- in the range Last (Decls) .. Referencer are hidden from external -- visibility. function Scan_Subprogram_Ref (N : Node_Id) return Traverse_Result; -- Determine whether a node denotes a reference to a subprogram procedure Traverse_And_Scan_Subprogram_Refs is new Traverse_Proc (Scan_Subprogram_Ref); -- Subsidiary to routine Has_Referencer. Determine whether a node -- contains references to a subprogram and record them. -- WARNING: this is a very expensive routine as it performs a full -- tree traversal. procedure Scan_Subprogram_Refs (Node : Node_Id); -- If we haven't already traversed Node, then mark it and traverse -- it. -------------------- -- Has_Referencer -- -------------------- function Has_Referencer (Decls : List_Id; In_Nested_Instance : Boolean; Has_Outer_Referencer_Of_Non_Subprograms : Boolean) return Boolean is Decl : Node_Id; Decl_Id : Entity_Id; Spec : Node_Id; Has_Referencer_Of_Non_Subprograms : Boolean := Has_Outer_Referencer_Of_Non_Subprograms; -- Set if an inlined subprogram body was detected as a referencer. -- In this case, we do not return True immediately but keep hiding -- subprograms from external visibility. begin if No (Decls) then return False; end if; -- Examine all declarations in reverse order, hiding all entities -- from external visibility until a referencer has been found. The -- algorithm recurses into nested packages. Decl := Last (Decls); while Present (Decl) loop -- A stub is always considered a referencer if Nkind (Decl) in N_Body_Stub then return True; -- Package declaration elsif Nkind (Decl) = N_Package_Declaration then Spec := Specification (Decl); Decl_Id := Defining_Entity (Spec); -- Inspect the declarations of a non-generic package to try -- and hide more entities from external visibility. if not Is_Generic_Unit (Decl_Id) then if Has_Referencer (Private_Declarations (Spec), In_Nested_Instance or else Is_Generic_Instance (Decl_Id), Has_Referencer_Of_Non_Subprograms) or else Has_Referencer (Visible_Declarations (Spec), In_Nested_Instance or else Is_Generic_Instance (Decl_Id), Has_Referencer_Of_Non_Subprograms) then return True; end if; end if; -- Package body elsif Nkind (Decl) = N_Package_Body and then Present (Corresponding_Spec (Decl)) then Decl_Id := Corresponding_Spec (Decl); -- A generic package body is a referencer. It would seem -- that we only have to consider generics that can be -- exported, i.e. where the corresponding spec is the -- spec of the current package, but because of nested -- instantiations, a fully private generic body may export -- other private body entities. Furthermore, regardless of -- whether there was a previous inlined subprogram, (an -- instantiation of) the generic package may reference any -- entity declared before it. if Is_Generic_Unit (Decl_Id) then return True; -- Inspect the declarations of a non-generic package body to -- try and hide more entities from external visibility. elsif Has_Referencer (Declarations (Decl), In_Nested_Instance or else Is_Generic_Instance (Decl_Id), Has_Referencer_Of_Non_Subprograms) then return True; end if; -- Subprogram body elsif Nkind (Decl) = N_Subprogram_Body then if Present (Corresponding_Spec (Decl)) then Decl_Id := Corresponding_Spec (Decl); -- A generic subprogram body acts as a referencer if Is_Generic_Unit (Decl_Id) then return True; end if; -- An inlined subprogram body acts as a referencer -- unless we generate C code since inlining is then -- handled by the C compiler. -- Note that we test Has_Pragma_Inline here in addition -- to Is_Inlined. We are doing this for a client, since -- we are computing which entities should be public, and -- it is the client who will decide if actual inlining -- should occur, so we need to catch all cases where the -- subprogram may be inlined by the client. if not Generate_C_Code and then (Is_Inlined (Decl_Id) or else Has_Pragma_Inline (Decl_Id)) then Has_Referencer_Of_Non_Subprograms := True; -- Inspect the statements of the subprogram body -- to determine whether the body references other -- subprograms. Scan_Subprogram_Refs (Decl); end if; -- Otherwise this is a stand alone subprogram body else Decl_Id := Defining_Entity (Decl); -- An inlined subprogram body acts as a referencer -- unless we generate C code since inlining is then -- handled by the C compiler. if not Generate_C_Code and then (Is_Inlined (Decl_Id) or else Has_Pragma_Inline (Decl_Id)) then Has_Referencer_Of_Non_Subprograms := True; -- Inspect the statements of the subprogram body -- to determine whether the body references other -- subprograms. Scan_Subprogram_Refs (Decl); -- Otherwise we can reset Is_Public right away elsif not Subprogram_Table.Get (Decl_Id) then Set_Is_Public (Decl_Id, False); end if; end if; -- Freeze node elsif Nkind (Decl) = N_Freeze_Entity then declare Discard : Boolean; pragma Unreferenced (Discard); begin -- Inspect the actions to find references to subprograms. -- We assume that the actions do not contain other kinds -- of references and, therefore, we do not stop the scan -- or set Has_Referencer_Of_Non_Subprograms here. Doing -- it would pessimize common cases for which the actions -- contain the declaration of an init procedure, since -- such a procedure is automatically marked inline. Discard := Has_Referencer (Actions (Decl), In_Nested_Instance, Has_Referencer_Of_Non_Subprograms); end; -- Exceptions, objects and renamings do not need to be public -- if they are not followed by a construct which can reference -- and export them. elsif Nkind (Decl) in N_Exception_Declaration | N_Object_Declaration | N_Object_Renaming_Declaration then Decl_Id := Defining_Entity (Decl); if not In_Nested_Instance and then not Is_Imported (Decl_Id) and then not Is_Exported (Decl_Id) and then No (Interface_Name (Decl_Id)) and then not Has_Referencer_Of_Non_Subprograms then Set_Is_Public (Decl_Id, False); end if; -- Likewise for subprograms and renamings, but we work harder -- for them to see whether they are referenced on an individual -- basis by looking into the table of referenced subprograms. elsif Nkind (Decl) in N_Subprogram_Declaration | N_Subprogram_Renaming_Declaration then Decl_Id := Defining_Entity (Decl); -- We cannot say anything for subprograms declared in nested -- instances because instantiations are not done yet so the -- bodies are not visible and could contain references to -- them, except if we still have no subprograms at all which -- are referenced by an inlined body. if (not In_Nested_Instance or else not Subprogram_Table.Get_First) and then not Is_Imported (Decl_Id) and then not Is_Exported (Decl_Id) and then No (Interface_Name (Decl_Id)) and then not Subprogram_Table.Get (Decl_Id) then Set_Is_Public (Decl_Id, False); end if; -- For a subprogram renaming, if the entity is referenced, -- then so is the renamed subprogram. But there is an issue -- with generic bodies because instantiations are not done -- yet and, therefore, cannot be scanned for referencers. -- That's why we use an approximation and test that we have -- at least one subprogram referenced by an inlined body -- instead of precisely the entity of this renaming. if Nkind (Decl) = N_Subprogram_Renaming_Declaration and then Subprogram_Table.Get_First and then Is_Entity_Name (Name (Decl)) and then Present (Entity (Name (Decl))) and then Is_Subprogram (Entity (Name (Decl))) then Subprogram_Table.Set (Entity (Name (Decl)), True); end if; end if; Prev (Decl); end loop; return Has_Referencer_Of_Non_Subprograms; end Has_Referencer; ------------------------- -- Scan_Subprogram_Ref -- ------------------------- function Scan_Subprogram_Ref (N : Node_Id) return Traverse_Result is begin -- Detect a reference of the form -- Subp_Call if Nkind (N) in N_Subprogram_Call and then Is_Entity_Name (Name (N)) and then Present (Entity (Name (N))) and then Is_Subprogram (Entity (Name (N))) then Subprogram_Table.Set (Entity (Name (N)), True); -- Detect a reference of the form -- Subp'Some_Attribute elsif Nkind (N) = N_Attribute_Reference and then Is_Entity_Name (Prefix (N)) and then Present (Entity (Prefix (N))) and then Is_Subprogram (Entity (Prefix (N))) then Subprogram_Table.Set (Entity (Prefix (N)), True); -- Constants can be substituted by their value in gigi, which may -- contain a reference, so scan the value recursively. elsif Is_Entity_Name (N) and then Present (Entity (N)) and then Ekind (Entity (N)) = E_Constant then declare Val : constant Node_Id := Constant_Value (Entity (N)); begin if Present (Val) and then not Compile_Time_Known_Value (Val) then Scan_Subprogram_Refs (Val); end if; end; end if; return OK; end Scan_Subprogram_Ref; -------------------------- -- Scan_Subprogram_Refs -- -------------------------- procedure Scan_Subprogram_Refs (Node : Node_Id) is begin if not Traversed_Table.Get (Node) then Traversed_Table.Set (Node, True); Traverse_And_Scan_Subprogram_Refs (Node); end if; end Scan_Subprogram_Refs; -- Local variables Discard : Boolean; pragma Unreferenced (Discard); -- Start of processing for Hide_Public_Entities begin -- The algorithm examines the top level declarations of a package -- body in reverse looking for a construct that may export entities -- declared prior to it. If such a scenario is encountered, then all -- entities in the range Last (Decls) .. construct are hidden from -- external visibility. Consider: -- package Pack is -- generic -- package Gen is -- end Gen; -- end Pack; -- package body Pack is -- External_Obj : ...; -- (1) -- package body Gen is -- (2) -- ... External_Obj ... -- (3) -- end Gen; -- Local_Obj : ...; -- (4) -- end Pack; -- In this example Local_Obj (4) must not be externally visible as -- it cannot be exported by anything in Pack. The body of generic -- package Gen (2) on the other hand acts as a "referencer" and may -- export anything declared before it. Since the compiler does not -- perform flow analysis, it is not possible to determine precisely -- which entities will be exported when Gen is instantiated. In the -- example above External_Obj (1) is exported at (3), but this may -- not always be the case. The algorithm takes a conservative stance -- and leaves entity External_Obj public. -- This very conservative algorithm is supplemented by a more precise -- processing for inlined bodies. For them, we traverse the syntactic -- tree and record which subprograms are actually referenced from it. -- This makes it possible to compute a much smaller set of externally -- visible subprograms in the absence of generic bodies, which can -- have a significant impact on the inlining decisions made in the -- back end and the removal of out-of-line bodies from the object -- code. We do it only for inlined bodies because they are supposed -- to be reasonably small and tree traversal is very expensive. -- Note that even this special processing is not optimal for inlined -- bodies, because we treat all inlined subprograms alike. An optimal -- algorithm would require computing the transitive closure of the -- inlined subprograms that can really be referenced from other units -- in the source code. -- We could extend this processing for inlined bodies and record all -- entities, not just subprograms, referenced from them, which would -- make it possible to compute a much smaller set of all externally -- visible entities in the absence of generic bodies. But this would -- mean implementing a more thorough tree traversal of the bodies, -- i.e. not just syntactic, and the gain would very likely be worth -- neither the hassle nor the slowdown of the compiler. -- Finally, an important thing to be aware of is that, at this point, -- instantiations are not done yet so we cannot directly see inlined -- bodies coming from them. That's not catastrophic because only the -- actual parameters of the instantiations matter here, and they are -- present in the declarations list of the instantiated packages. Traversed_Table.Reset; Subprogram_Table.Reset; Discard := Has_Referencer (Decls, False, False); end Hide_Public_Entities; ---------------------------------- -- Install_Composite_Operations -- ---------------------------------- procedure Install_Composite_Operations (P : Entity_Id) is Id : Entity_Id; begin Id := First_Entity (P); while Present (Id) loop if Is_Type (Id) and then (Is_Limited_Composite (Id) or else Is_Private_Composite (Id)) and then No (Private_Component (Id)) then Set_Is_Limited_Composite (Id, False); Set_Is_Private_Composite (Id, False); end if; Next_Entity (Id); end loop; end Install_Composite_Operations; -- Local variables Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; Saved_EA : constant Boolean := Expander_Active; Saved_ISMP : constant Boolean := Ignore_SPARK_Mode_Pragmas_In_Instance; -- Save the Ghost and SPARK mode-related data to restore on exit Body_Id : Entity_Id; HSS : Node_Id; Last_Spec_Entity : Entity_Id; New_N : Node_Id; Pack_Decl : Node_Id; Spec_Id : Entity_Id; -- Start of processing for Analyze_Package_Body_Helper begin -- Find corresponding package specification, and establish the current -- scope. The visible defining entity for the package is the defining -- occurrence in the spec. On exit from the package body, all body -- declarations are attached to the defining entity for the body, but -- the later is never used for name resolution. In this fashion there -- is only one visible entity that denotes the package. -- Set Body_Id. Note that this will be reset to point to the generic -- copy later on in the generic case. Body_Id := Defining_Entity (N); -- Body is body of package instantiation. Corresponding spec has already -- been set. if Present (Corresponding_Spec (N)) then Spec_Id := Corresponding_Spec (N); Pack_Decl := Unit_Declaration_Node (Spec_Id); else Spec_Id := Current_Entity_In_Scope (Defining_Entity (N)); if Present (Spec_Id) and then Is_Package_Or_Generic_Package (Spec_Id) then Pack_Decl := Unit_Declaration_Node (Spec_Id); if Nkind (Pack_Decl) = N_Package_Renaming_Declaration then Error_Msg_N ("cannot supply body for package renaming", N); return; elsif Present (Corresponding_Body (Pack_Decl)) then Error_Msg_N ("redefinition of package body", N); return; end if; else Error_Msg_N ("missing specification for package body", N); return; end if; if Is_Package_Or_Generic_Package (Spec_Id) and then (Scope (Spec_Id) = Standard_Standard or else Is_Child_Unit (Spec_Id)) and then not Unit_Requires_Body (Spec_Id) then if Ada_Version = Ada_83 then Error_Msg_N ("optional package body (not allowed in Ada 95)??", N); else Error_Msg_N ("spec of this package does not allow a body", N); end if; end if; end if; -- A [generic] package body freezes the contract of the nearest -- enclosing package body and all other contracts encountered in -- the same declarative part up to and excluding the package body: -- package body Nearest_Enclosing_Package -- with Refined_State => (State => Constit) -- is -- Constit : ...; -- package body Freezes_Enclosing_Package_Body -- with Refined_State => (State_2 => Constit_2) -- is -- Constit_2 : ...; -- procedure Proc -- with Refined_Depends => (Input => (Constit, Constit_2)) ... -- This ensures that any annotations referenced by the contract of a -- [generic] subprogram body declared within the current package body -- are available. This form of freezing is decoupled from the usual -- Freeze_xxx mechanism because it must also work in the context of -- generics where normal freezing is disabled. -- Only bodies coming from source should cause this type of freezing. -- Instantiated generic bodies are excluded because their processing is -- performed in a separate compilation pass which lacks enough semantic -- information with respect to contract analysis. It is safe to suppress -- the freezing of contracts in this case because this action already -- took place at the end of the enclosing declarative part. if Comes_From_Source (N) and then not Is_Generic_Instance (Spec_Id) then Freeze_Previous_Contracts (N); end if; -- A package body is Ghost when the corresponding spec is Ghost. Set -- the mode now to ensure that any nodes generated during analysis and -- expansion are properly flagged as ignored Ghost. Mark_And_Set_Ghost_Body (N, Spec_Id); -- Deactivate expansion inside the body of ignored Ghost entities, -- as this code will ultimately be ignored. This avoids requiring the -- presence of run-time units which are not needed. Only do this for -- user entities, as internally generated entities might still need -- to be expanded (e.g. those generated for types). if Present (Ignored_Ghost_Region) and then Comes_From_Source (Body_Id) then Expander_Active := False; end if; -- If the body completes the initial declaration of a compilation unit -- which is subject to pragma Elaboration_Checks, set the model of the -- pragma because it applies to all parts of the unit. Install_Elaboration_Model (Spec_Id); Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id)); Style.Check_Identifier (Body_Id, Spec_Id); if Is_Child_Unit (Spec_Id) then if Nkind (Parent (N)) /= N_Compilation_Unit then Error_Msg_NE ("body of child unit& cannot be an inner package", N, Spec_Id); end if; Set_Is_Child_Unit (Body_Id); end if; -- Generic package case if Ekind (Spec_Id) = E_Generic_Package then -- Disable expansion and perform semantic analysis on copy. The -- unannotated body will be used in all instantiations. Body_Id := Defining_Entity (N); Set_Ekind (Body_Id, E_Package_Body); Set_Scope (Body_Id, Scope (Spec_Id)); Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Spec_Id)); Set_Body_Entity (Spec_Id, Body_Id); Set_Spec_Entity (Body_Id, Spec_Id); New_N := Copy_Generic_Node (N, Empty, Instantiating => False); Rewrite (N, New_N); -- Once the contents of the generic copy and the template are -- swapped, do the same for their respective aspect specifications. Exchange_Aspects (N, New_N); -- Collect all contract-related source pragmas found within the -- template and attach them to the contract of the package body. -- This contract is used in the capture of global references within -- annotations. Create_Generic_Contract (N); -- Update Body_Id to point to the copied node for the remainder of -- the processing. Body_Id := Defining_Entity (N); Start_Generic; end if; -- The Body_Id is that of the copied node in the generic case, the -- current node otherwise. Note that N was rewritten above, so we must -- be sure to get the latest Body_Id value. Set_Ekind (Body_Id, E_Package_Body); Set_Body_Entity (Spec_Id, Body_Id); Set_Spec_Entity (Body_Id, Spec_Id); -- Defining name for the package body is not a visible entity: Only the -- defining name for the declaration is visible. Set_Etype (Body_Id, Standard_Void_Type); Set_Scope (Body_Id, Scope (Spec_Id)); Set_Corresponding_Spec (N, Spec_Id); Set_Corresponding_Body (Pack_Decl, Body_Id); -- The body entity is not used for semantics or code generation, but -- it is attached to the entity list of the enclosing scope to simplify -- the listing of back-annotations for the types it main contain. if Scope (Spec_Id) /= Standard_Standard then Append_Entity (Body_Id, Scope (Spec_Id)); end if; -- Indicate that we are currently compiling the body of the package Set_In_Package_Body (Spec_Id); Set_Has_Completion (Spec_Id); Last_Spec_Entity := Last_Entity (Spec_Id); if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Body_Id); end if; Push_Scope (Spec_Id); -- Set SPARK_Mode only for non-generic package if Ekind (Spec_Id) = E_Package then Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma); Set_SPARK_Aux_Pragma (Body_Id, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Body_Id); Set_SPARK_Aux_Pragma_Inherited (Body_Id); -- A package body may be instantiated or inlined at a later pass. -- Restore the state of Ignore_SPARK_Mode_Pragmas_In_Instance when -- it applied to the package spec. if Ignore_SPARK_Mode_Pragmas (Spec_Id) then Ignore_SPARK_Mode_Pragmas_In_Instance := True; end if; end if; Set_Categorization_From_Pragmas (N); Install_Visible_Declarations (Spec_Id); Install_Private_Declarations (Spec_Id); Install_Private_With_Clauses (Spec_Id); Install_Composite_Operations (Spec_Id); Check_Anonymous_Access_Types (Spec_Id, N); if Ekind (Spec_Id) = E_Generic_Package then Set_Use (Generic_Formal_Declarations (Pack_Decl)); end if; Set_Use (Visible_Declarations (Specification (Pack_Decl))); Set_Use (Private_Declarations (Specification (Pack_Decl))); -- This is a nested package, so it may be necessary to declare certain -- inherited subprograms that are not yet visible because the parent -- type's subprograms are now visible. -- Note that for child units these operations were generated when -- analyzing the package specification. if Ekind (Scope (Spec_Id)) = E_Package and then Scope (Spec_Id) /= Standard_Standard and then not Is_Child_Unit (Spec_Id) then Declare_Inherited_Private_Subprograms (Spec_Id); end if; if Present (Declarations (N)) then Analyze_Declarations (Declarations (N)); Inspect_Deferred_Constant_Completion (Declarations (N)); end if; -- Verify that the SPARK_Mode of the body agrees with that of its spec if Present (SPARK_Pragma (Body_Id)) then if Present (SPARK_Aux_Pragma (Spec_Id)) then if Get_SPARK_Mode_From_Annotation (SPARK_Aux_Pragma (Spec_Id)) = Off and then Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Body_Id)) = On then Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id)); Error_Msg_N ("incorrect application of SPARK_Mode#", N); Error_Msg_Sloc := Sloc (SPARK_Aux_Pragma (Spec_Id)); Error_Msg_NE ("\value Off was set for SPARK_Mode on & #", N, Spec_Id); end if; -- SPARK_Mode Off could complete no SPARK_Mode in a generic, either -- as specified in source code, or because SPARK_Mode On is ignored -- in an instance where the context is SPARK_Mode Off/Auto. elsif Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Body_Id)) = Off and then (Is_Generic_Unit (Spec_Id) or else In_Instance) then null; else Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id)); Error_Msg_N ("incorrect application of SPARK_Mode#", N); Error_Msg_Sloc := Sloc (Spec_Id); Error_Msg_NE ("\no value was set for SPARK_Mode on & #", N, Spec_Id); end if; end if; -- Analyze_Declarations has caused freezing of all types. Now generate -- bodies for RACW primitives and stream attributes, if any. if Ekind (Spec_Id) = E_Package and then Has_RACW (Spec_Id) then -- Attach subprogram bodies to support RACWs declared in spec Append_RACW_Bodies (Declarations (N), Spec_Id); Analyze_List (Declarations (N)); end if; -- If procedures marked with CUDA_Global have been defined within N, we -- need to register them with the CUDA runtime at program startup. This -- requires multiple declarations and function calls which need to be -- appended to N's declarations. Build_And_Insert_CUDA_Initialization (N); HSS := Handled_Statement_Sequence (N); if Present (HSS) then Process_End_Label (HSS, 't', Spec_Id); Analyze (HSS); -- Check that elaboration code in a preelaborable package body is -- empty other than null statements and labels (RM 10.2.1(6)). Validate_Null_Statement_Sequence (N); end if; Validate_Categorization_Dependency (N, Spec_Id); Check_Completion (Body_Id); -- Generate start of body reference. Note that we do this fairly late, -- because the call will use In_Extended_Main_Source_Unit as a check, -- and we want to make sure that Corresponding_Stub links are set Generate_Reference (Spec_Id, Body_Id, 'b', Set_Ref => False); -- For a generic package, collect global references and mark them on -- the original body so that they are not resolved again at the point -- of instantiation. if Ekind (Spec_Id) /= E_Package then Save_Global_References (Original_Node (N)); End_Generic; end if; -- The entities of the package body have so far been chained onto the -- declaration chain for the spec. That's been fine while we were in the -- body, since we wanted them to be visible, but now that we are leaving -- the package body, they are no longer visible, so we remove them from -- the entity chain of the package spec entity, and copy them to the -- entity chain of the package body entity, where they will never again -- be visible. if Present (Last_Spec_Entity) then Set_First_Entity (Body_Id, Next_Entity (Last_Spec_Entity)); Set_Next_Entity (Last_Spec_Entity, Empty); Set_Last_Entity (Body_Id, Last_Entity (Spec_Id)); Set_Last_Entity (Spec_Id, Last_Spec_Entity); else Set_First_Entity (Body_Id, First_Entity (Spec_Id)); Set_Last_Entity (Body_Id, Last_Entity (Spec_Id)); Set_First_Entity (Spec_Id, Empty); Set_Last_Entity (Spec_Id, Empty); end if; Update_Use_Clause_Chain; End_Package_Scope (Spec_Id); -- All entities declared in body are not visible declare E : Entity_Id; begin E := First_Entity (Body_Id); while Present (E) loop Set_Is_Immediately_Visible (E, False); Set_Is_Potentially_Use_Visible (E, False); Set_Is_Hidden (E); -- Child units may appear on the entity list (e.g. if they appear -- in the context of a subunit) but they are not body entities. if not Is_Child_Unit (E) then Set_Is_Package_Body_Entity (E); end if; Next_Entity (E); end loop; end; Check_References (Body_Id); -- For a generic unit, check that the formal parameters are referenced, -- and that local variables are used, as for regular packages. if Ekind (Spec_Id) = E_Generic_Package then Check_References (Spec_Id); end if; -- At this point all entities of the package body are externally visible -- to the linker as their Is_Public flag is set to True. This proactive -- approach is necessary because an inlined or a generic body for which -- code is generated in other units may need to see these entities. Cut -- down the number of global symbols that do not need public visibility -- as this has two beneficial effects: -- (1) It makes the compilation process more efficient. -- (2) It gives the code generator more leeway to optimize within each -- unit, especially subprograms. -- This is done only for top-level library packages or child units as -- the algorithm does a top-down traversal of the package body. This is -- also done for instances because instantiations are still pending by -- the time the enclosing package body is analyzed. if (Scope (Spec_Id) = Standard_Standard or else Is_Child_Unit (Spec_Id) or else Is_Generic_Instance (Spec_Id)) and then not Is_Generic_Unit (Spec_Id) then Hide_Public_Entities (Declarations (N)); end if; -- If expander is not active, then here is where we turn off the -- In_Package_Body flag, otherwise it is turned off at the end of the -- corresponding expansion routine. If this is an instance body, we need -- to qualify names of local entities, because the body may have been -- compiled as a preliminary to another instantiation. if not Expander_Active then Set_In_Package_Body (Spec_Id, False); if Is_Generic_Instance (Spec_Id) and then Operating_Mode = Generate_Code then Qualify_Entity_Names (N); end if; end if; if Present (Ignored_Ghost_Region) then Expander_Active := Saved_EA; end if; Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP; Restore_Ghost_Region (Saved_GM, Saved_IGR); end Analyze_Package_Body_Helper; --------------------------------- -- Analyze_Package_Declaration -- --------------------------------- procedure Analyze_Package_Declaration (N : Node_Id) is Id : constant Node_Id := Defining_Entity (N); Is_Comp_Unit : constant Boolean := Nkind (Parent (N)) = N_Compilation_Unit; Body_Required : Boolean; -- True when this package declaration requires a corresponding body begin if Debug_Flag_C then Write_Str ("==> package spec "); Write_Name (Chars (Id)); Write_Str (" from "); Write_Location (Sloc (N)); Write_Eol; Indent; end if; Generate_Definition (Id); Enter_Name (Id); Set_Ekind (Id, E_Package); Set_Etype (Id, Standard_Void_Type); -- Set SPARK_Mode from context Set_SPARK_Pragma (Id, SPARK_Mode_Pragma); Set_SPARK_Aux_Pragma (Id, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Id); Set_SPARK_Aux_Pragma_Inherited (Id); -- Save the state of flag Ignore_SPARK_Mode_Pragmas_In_Instance in case -- the body of this package is instantiated or inlined later and out of -- context. The body uses this attribute to restore the value of the -- global flag. if Ignore_SPARK_Mode_Pragmas_In_Instance then Set_Ignore_SPARK_Mode_Pragmas (Id); end if; -- Analyze aspect specifications immediately, since we need to recognize -- things like Pure early enough to diagnose violations during analysis. if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Id); end if; -- Ada 2005 (AI-217): Check if the package has been illegally named in -- a limited-with clause of its own context. In this case the error has -- been previously notified by Analyze_Context. -- limited with Pkg; -- ERROR -- package Pkg is ... if From_Limited_With (Id) then return; end if; Push_Scope (Id); Set_Is_Pure (Id, Is_Pure (Enclosing_Lib_Unit_Entity)); Set_Categorization_From_Pragmas (N); Analyze (Specification (N)); Validate_Categorization_Dependency (N, Id); -- Determine whether the package requires a body. Abstract states are -- intentionally ignored because they do require refinement which can -- only come in a body, but at the same time they do not force the need -- for a body on their own (SPARK RM 7.1.4(4) and 7.2.2(3)). Body_Required := Unit_Requires_Body (Id); if not Body_Required then -- If the package spec does not require an explicit body, then there -- are not entities requiring completion in the language sense. Call -- Check_Completion now to ensure that nested package declarations -- that require an implicit body get one. (In the case where a body -- is required, Check_Completion is called at the end of the body's -- declarative part.) Check_Completion; -- If the package spec does not require an explicit body, then all -- abstract states declared in nested packages cannot possibly get -- a proper refinement (SPARK RM 7.2.2(3)). This check is performed -- only when the compilation unit is the main unit to allow for -- modular SPARK analysis where packages do not necessarily have -- bodies. if Is_Comp_Unit then Check_State_Refinements (Context => N, Is_Main_Unit => Parent (N) = Cunit (Main_Unit)); end if; end if; -- Set Body_Required indication on the compilation unit node if Is_Comp_Unit then Set_Body_Required (Parent (N), Body_Required); if Legacy_Elaboration_Checks and not Body_Required then Set_Suppress_Elaboration_Warnings (Id); end if; end if; End_Package_Scope (Id); -- For the declaration of a library unit that is a remote types package, -- check legality rules regarding availability of stream attributes for -- types that contain non-remote access values. This subprogram performs -- visibility tests that rely on the fact that we have exited the scope -- of Id. if Is_Comp_Unit then Validate_RT_RAT_Component (N); end if; if Debug_Flag_C then Outdent; Write_Str ("<== package spec "); Write_Name (Chars (Id)); Write_Str (" from "); Write_Location (Sloc (N)); Write_Eol; end if; end Analyze_Package_Declaration; ----------------------------------- -- Analyze_Package_Specification -- ----------------------------------- -- Note that this code is shared for the analysis of generic package specs -- (see Sem_Ch12.Analyze_Generic_Package_Declaration for details). procedure Analyze_Package_Specification (N : Node_Id) is Id : constant Entity_Id := Defining_Entity (N); Orig_Decl : constant Node_Id := Original_Node (Parent (N)); Vis_Decls : constant List_Id := Visible_Declarations (N); Priv_Decls : constant List_Id := Private_Declarations (N); E : Entity_Id; L : Entity_Id; Public_Child : Boolean; Private_With_Clauses_Installed : Boolean := False; -- In Ada 2005, private with_clauses are visible in the private part -- of a nested package, even if it appears in the public part of the -- enclosing package. This requires a separate step to install these -- private_with_clauses, and remove them at the end of the nested -- package. procedure Clear_Constants (Id : Entity_Id; FE : Entity_Id); -- Clears constant indications (Never_Set_In_Source, Constant_Value, and -- Is_True_Constant) on all variables that are entities of Id, and on -- the chain whose first element is FE. A recursive call is made for all -- packages and generic packages. procedure Generate_Parent_References; -- For a child unit, generate references to parent units, for -- GNAT Studio navigation purposes. function Is_Public_Child (Child, Unit : Entity_Id) return Boolean; -- Child and Unit are entities of compilation units. True if Child -- is a public child of Parent as defined in 10.1.1 procedure Inspect_Unchecked_Union_Completion (Decls : List_Id); -- Reject completion of an incomplete or private type declarations -- having a known discriminant part by an unchecked union. procedure Install_Parent_Private_Declarations (Inst_Id : Entity_Id); -- Given the package entity of a generic package instantiation or -- formal package whose corresponding generic is a child unit, installs -- the private declarations of each of the child unit's parents. -- This has to be done at the point of entering the instance package's -- private part rather than being done in Sem_Ch12.Install_Parent -- (which is where the parents' visible declarations are installed). --------------------- -- Clear_Constants -- --------------------- procedure Clear_Constants (Id : Entity_Id; FE : Entity_Id) is E : Entity_Id; begin -- Ignore package renamings, not interesting and they can cause self -- referential loops in the code below. if Nkind (Parent (Id)) = N_Package_Renaming_Declaration then return; end if; -- Note: in the loop below, the check for Next_Entity pointing back -- to the package entity may seem odd, but it is needed, because a -- package can contain a renaming declaration to itself, and such -- renamings are generated automatically within package instances. E := FE; while Present (E) and then E /= Id loop if Is_Assignable (E) then Set_Never_Set_In_Source (E, False); Set_Is_True_Constant (E, False); Set_Current_Value (E, Empty); Set_Is_Known_Null (E, False); Set_Last_Assignment (E, Empty); if not Can_Never_Be_Null (E) then Set_Is_Known_Non_Null (E, False); end if; elsif Is_Package_Or_Generic_Package (E) then Clear_Constants (E, First_Entity (E)); Clear_Constants (E, First_Private_Entity (E)); end if; Next_Entity (E); end loop; end Clear_Constants; -------------------------------- -- Generate_Parent_References -- -------------------------------- procedure Generate_Parent_References is Decl : constant Node_Id := Parent (N); begin if Id = Cunit_Entity (Main_Unit) or else Parent (Decl) = Library_Unit (Cunit (Main_Unit)) then Generate_Reference (Id, Scope (Id), 'k', False); elsif Nkind (Unit (Cunit (Main_Unit))) not in N_Subprogram_Body | N_Subunit then -- If current unit is an ancestor of main unit, generate a -- reference to its own parent. declare U : Node_Id; Main_Spec : Node_Id := Unit (Cunit (Main_Unit)); begin if Nkind (Main_Spec) = N_Package_Body then Main_Spec := Unit (Library_Unit (Cunit (Main_Unit))); end if; U := Parent_Spec (Main_Spec); while Present (U) loop if U = Parent (Decl) then Generate_Reference (Id, Scope (Id), 'k', False); exit; elsif Nkind (Unit (U)) = N_Package_Body then exit; else U := Parent_Spec (Unit (U)); end if; end loop; end; end if; end Generate_Parent_References; --------------------- -- Is_Public_Child -- --------------------- function Is_Public_Child (Child, Unit : Entity_Id) return Boolean is begin if not Is_Private_Descendant (Child) then return True; else if Child = Unit then return not Private_Present ( Parent (Unit_Declaration_Node (Child))); else return Is_Public_Child (Scope (Child), Unit); end if; end if; end Is_Public_Child; ---------------------------------------- -- Inspect_Unchecked_Union_Completion -- ---------------------------------------- procedure Inspect_Unchecked_Union_Completion (Decls : List_Id) is Decl : Node_Id; begin Decl := First (Decls); while Present (Decl) loop -- We are looking at an incomplete or private type declaration -- with a known_discriminant_part whose full view is an -- Unchecked_Union. The seemingly useless check with Is_Type -- prevents cascaded errors when routines defined only for type -- entities are called with non-type entities. if Nkind (Decl) in N_Incomplete_Type_Declaration | N_Private_Type_Declaration and then Is_Type (Defining_Identifier (Decl)) and then Has_Discriminants (Defining_Identifier (Decl)) and then Present (Full_View (Defining_Identifier (Decl))) and then Is_Unchecked_Union (Full_View (Defining_Identifier (Decl))) then Error_Msg_N ("completion of discriminated partial view " & "cannot be an unchecked union", Full_View (Defining_Identifier (Decl))); end if; Next (Decl); end loop; end Inspect_Unchecked_Union_Completion; ----------------------------------------- -- Install_Parent_Private_Declarations -- ----------------------------------------- procedure Install_Parent_Private_Declarations (Inst_Id : Entity_Id) is Inst_Par : Entity_Id; Gen_Par : Entity_Id; Inst_Node : Node_Id; begin Inst_Par := Inst_Id; Gen_Par := Generic_Parent (Specification (Unit_Declaration_Node (Inst_Par))); while Present (Gen_Par) and then Is_Child_Unit (Gen_Par) loop Inst_Node := Get_Unit_Instantiation_Node (Inst_Par); if Nkind (Inst_Node) in N_Package_Instantiation | N_Formal_Package_Declaration and then Nkind (Name (Inst_Node)) = N_Expanded_Name then Inst_Par := Entity (Prefix (Name (Inst_Node))); if Present (Renamed_Entity (Inst_Par)) then Inst_Par := Renamed_Entity (Inst_Par); end if; -- The instance may appear in a sibling generic unit, in -- which case the prefix must include the common (generic) -- ancestor, which is treated as a current instance. if Inside_A_Generic and then Ekind (Inst_Par) = E_Generic_Package then Gen_Par := Inst_Par; pragma Assert (In_Open_Scopes (Gen_Par)); else Gen_Par := Generic_Parent (Specification (Unit_Declaration_Node (Inst_Par))); end if; -- Install the private declarations and private use clauses -- of a parent instance of the child instance, unless the -- parent instance private declarations have already been -- installed earlier in Analyze_Package_Specification, which -- happens when a generic child is instantiated, and the -- instance is a child of the parent instance. -- Installing the use clauses of the parent instance twice -- is both unnecessary and wrong, because it would cause the -- clauses to be chained to themselves in the use clauses -- list of the scope stack entry. That in turn would cause -- an endless loop from End_Use_Clauses upon scope exit. -- The parent is now fully visible. It may be a hidden open -- scope if we are currently compiling some child instance -- declared within it, but while the current instance is being -- compiled the parent is immediately visible. In particular -- its entities must remain visible if a stack save/restore -- takes place through a call to Rtsfind. if Present (Gen_Par) then if not In_Private_Part (Inst_Par) then Install_Private_Declarations (Inst_Par); Set_Use (Private_Declarations (Specification (Unit_Declaration_Node (Inst_Par)))); Set_Is_Hidden_Open_Scope (Inst_Par, False); end if; -- If we've reached the end of the generic instance parents, -- then finish off by looping through the nongeneric parents -- and installing their private declarations. -- If one of the non-generic parents is itself on the scope -- stack, do not install its private declarations: they are -- installed in due time when the private part of that parent -- is analyzed. else while Present (Inst_Par) and then Inst_Par /= Standard_Standard and then (not In_Open_Scopes (Inst_Par) or else not In_Private_Part (Inst_Par)) loop if Nkind (Inst_Node) = N_Formal_Package_Declaration or else not Is_Ancestor_Package (Inst_Par, Cunit_Entity (Current_Sem_Unit)) then Install_Private_Declarations (Inst_Par); Set_Use (Private_Declarations (Specification (Unit_Declaration_Node (Inst_Par)))); Inst_Par := Scope (Inst_Par); else exit; end if; end loop; exit; end if; else exit; end if; end loop; end Install_Parent_Private_Declarations; -- Start of processing for Analyze_Package_Specification begin if Present (Vis_Decls) then Analyze_Declarations (Vis_Decls); end if; -- Inspect the entities defined in the package and ensure that all -- incomplete types have received full declarations. Build default -- initial condition and invariant procedures for all qualifying types. E := First_Entity (Id); while Present (E) loop -- Check on incomplete types -- AI05-0213: A formal incomplete type has no completion, and neither -- does the corresponding subtype in an instance. if Is_Incomplete_Type (E) and then No (Full_View (E)) and then not Is_Generic_Type (E) and then not From_Limited_With (E) and then not Is_Generic_Actual_Type (E) then Error_Msg_N ("no declaration in visible part for incomplete}", E); end if; Next_Entity (E); end loop; if Is_Remote_Call_Interface (Id) and then Nkind (Parent (Parent (N))) = N_Compilation_Unit then Validate_RCI_Declarations (Id); end if; -- Save global references in the visible declarations, before installing -- private declarations of parent unit if there is one, because the -- privacy status of types defined in the parent will change. This is -- only relevant for generic child units, but is done in all cases for -- uniformity. if Ekind (Id) = E_Generic_Package and then Nkind (Orig_Decl) = N_Generic_Package_Declaration then declare Orig_Spec : constant Node_Id := Specification (Orig_Decl); Save_Priv : constant List_Id := Private_Declarations (Orig_Spec); begin -- Insert the freezing nodes after the visible declarations to -- ensure that we analyze its aspects; needed to ensure that -- global entities referenced in the aspects are properly handled. if Ada_Version >= Ada_2012 and then Is_Non_Empty_List (Vis_Decls) and then Is_Empty_List (Priv_Decls) then Insert_List_After_And_Analyze (Last (Vis_Decls), Freeze_Entity (Id, Last (Vis_Decls))); end if; Set_Private_Declarations (Orig_Spec, Empty_List); Save_Global_References (Orig_Decl); Set_Private_Declarations (Orig_Spec, Save_Priv); end; end if; -- If package is a public child unit, then make the private declarations -- of the parent visible. Public_Child := False; declare Par : Entity_Id; Pack_Decl : Node_Id; Par_Spec : Node_Id; begin Par := Id; Par_Spec := Parent_Spec (Parent (N)); -- If the package is formal package of an enclosing generic, it is -- transformed into a local generic declaration, and compiled to make -- its spec available. We need to retrieve the original generic to -- determine whether it is a child unit, and install its parents. if No (Par_Spec) and then Nkind (Original_Node (Parent (N))) = N_Formal_Package_Declaration then Par := Entity (Name (Original_Node (Parent (N)))); Par_Spec := Parent_Spec (Unit_Declaration_Node (Par)); end if; if Present (Par_Spec) then Generate_Parent_References; while Scope (Par) /= Standard_Standard and then Is_Public_Child (Id, Par) and then In_Open_Scopes (Par) loop Public_Child := True; Par := Scope (Par); Install_Private_Declarations (Par); Install_Private_With_Clauses (Par); Pack_Decl := Unit_Declaration_Node (Par); Set_Use (Private_Declarations (Specification (Pack_Decl))); end loop; end if; end; if Is_Compilation_Unit (Id) then Install_Private_With_Clauses (Id); else -- The current compilation unit may include private with_clauses, -- which are visible in the private part of the current nested -- package, and have to be installed now. This is not done for -- nested instantiations, where the private with_clauses of the -- enclosing unit have no effect once the instantiation info is -- established and we start analyzing the package declaration. declare Comp_Unit : constant Entity_Id := Cunit_Entity (Current_Sem_Unit); begin if Is_Package_Or_Generic_Package (Comp_Unit) and then not In_Private_Part (Comp_Unit) and then not In_Instance then Install_Private_With_Clauses (Comp_Unit); Private_With_Clauses_Installed := True; end if; end; end if; -- If this is a package associated with a generic instance or formal -- package, then the private declarations of each of the generic's -- parents must be installed at this point. if Is_Generic_Instance (Id) then Install_Parent_Private_Declarations (Id); end if; -- Analyze private part if present. The flag In_Private_Part is reset -- in End_Package_Scope. L := Last_Entity (Id); if Present (Priv_Decls) then Set_In_Private_Part (Id); -- Upon entering a public child's private part, it may be necessary -- to declare subprograms that were derived in the package's visible -- part but not yet made visible. if Public_Child then Declare_Inherited_Private_Subprograms (Id); end if; Analyze_Declarations (Priv_Decls); -- Check the private declarations for incomplete deferred constants Inspect_Deferred_Constant_Completion (Priv_Decls); -- The first private entity is the immediate follower of the last -- visible entity, if there was one. if Present (L) then Set_First_Private_Entity (Id, Next_Entity (L)); else Set_First_Private_Entity (Id, First_Entity (Id)); end if; -- There may be inherited private subprograms that need to be declared, -- even in the absence of an explicit private part. If there are any -- public declarations in the package and the package is a public child -- unit, then an implicit private part is assumed. elsif Present (L) and then Public_Child then Set_In_Private_Part (Id); Declare_Inherited_Private_Subprograms (Id); Set_First_Private_Entity (Id, Next_Entity (L)); end if; E := First_Entity (Id); while Present (E) loop -- Check rule of 3.6(11), which in general requires waiting till all -- full types have been seen. if Ekind (E) = E_Record_Type or else Ekind (E) = E_Array_Type then Check_Aliased_Component_Types (E); end if; -- Check preelaborable initialization for full type completing a -- private type for which pragma Preelaborable_Initialization given. if Is_Type (E) and then Must_Have_Preelab_Init (E) and then not Has_Preelaborable_Initialization (E) then Error_Msg_N ("full view of & does not have preelaborable initialization", E); end if; Next_Entity (E); end loop; -- Ada 2005 (AI-216): The completion of an incomplete or private type -- declaration having a known_discriminant_part shall not be an -- unchecked union type. if Present (Vis_Decls) then Inspect_Unchecked_Union_Completion (Vis_Decls); end if; if Present (Priv_Decls) then Inspect_Unchecked_Union_Completion (Priv_Decls); end if; if Ekind (Id) = E_Generic_Package and then Nkind (Orig_Decl) = N_Generic_Package_Declaration and then Present (Priv_Decls) then -- Save global references in private declarations, ignoring the -- visible declarations that were processed earlier. declare Orig_Spec : constant Node_Id := Specification (Orig_Decl); Save_Vis : constant List_Id := Visible_Declarations (Orig_Spec); Save_Form : constant List_Id := Generic_Formal_Declarations (Orig_Decl); begin -- Insert the freezing nodes after the private declarations to -- ensure that we analyze its aspects; needed to ensure that -- global entities referenced in the aspects are properly handled. if Ada_Version >= Ada_2012 and then Is_Non_Empty_List (Priv_Decls) then Insert_List_After_And_Analyze (Last (Priv_Decls), Freeze_Entity (Id, Last (Priv_Decls))); end if; Set_Visible_Declarations (Orig_Spec, Empty_List); Set_Generic_Formal_Declarations (Orig_Decl, Empty_List); Save_Global_References (Orig_Decl); Set_Generic_Formal_Declarations (Orig_Decl, Save_Form); Set_Visible_Declarations (Orig_Spec, Save_Vis); end; end if; Process_End_Label (N, 'e', Id); -- Remove private_with_clauses of enclosing compilation unit, if they -- were installed. if Private_With_Clauses_Installed then Remove_Private_With_Clauses (Cunit (Current_Sem_Unit)); end if; -- For the case of a library level package, we must go through all the -- entities clearing the indications that the value may be constant and -- not modified. Why? Because any client of this package may modify -- these values freely from anywhere. This also applies to any nested -- packages or generic packages. -- For now we unconditionally clear constants for packages that are -- instances of generic packages. The reason is that we do not have the -- body yet, and we otherwise think things are unreferenced when they -- are not. This should be fixed sometime (the effect is not terrible, -- we just lose some warnings, and also some cases of value propagation) -- ??? if Is_Library_Level_Entity (Id) or else Is_Generic_Instance (Id) then Clear_Constants (Id, First_Entity (Id)); Clear_Constants (Id, First_Private_Entity (Id)); end if; -- Output relevant information as to why the package requires a body. -- Do not consider generated packages as this exposes internal symbols -- and leads to confusing messages. if List_Body_Required_Info and then In_Extended_Main_Source_Unit (Id) and then Unit_Requires_Body (Id) and then Comes_From_Source (Id) then Unit_Requires_Body_Info (Id); end if; -- Nested package specs that do not require bodies are not checked for -- ineffective use clauses due to the possibility of subunits. This is -- because at this stage it is impossible to tell whether there will be -- a separate body. if not Unit_Requires_Body (Id) and then Is_Compilation_Unit (Id) and then not Is_Private_Descendant (Id) then Update_Use_Clause_Chain; end if; end Analyze_Package_Specification; -------------------------------------- -- Analyze_Private_Type_Declaration -- -------------------------------------- procedure Analyze_Private_Type_Declaration (N : Node_Id) is Id : constant Entity_Id := Defining_Identifier (N); PF : constant Boolean := Is_Pure (Enclosing_Lib_Unit_Entity); begin Generate_Definition (Id); Set_Is_Pure (Id, PF); Init_Size_Align (Id); if not Is_Package_Or_Generic_Package (Current_Scope) or else In_Private_Part (Current_Scope) then Error_Msg_N ("invalid context for private declaration", N); end if; New_Private_Type (N, Id, N); Set_Depends_On_Private (Id); -- Set the SPARK mode from the current context Set_SPARK_Pragma (Id, SPARK_Mode_Pragma); Set_SPARK_Pragma_Inherited (Id); if Has_Aspects (N) then Analyze_Aspect_Specifications (N, Id); end if; end Analyze_Private_Type_Declaration; ---------------------------------- -- Check_Anonymous_Access_Types -- ---------------------------------- procedure Check_Anonymous_Access_Types (Spec_Id : Entity_Id; P_Body : Node_Id) is E : Entity_Id; IR : Node_Id; begin -- Itype references are only needed by gigi, to force elaboration of -- itypes. In the absence of code generation, they are not needed. if not Expander_Active then return; end if; E := First_Entity (Spec_Id); while Present (E) loop if Ekind (E) = E_Anonymous_Access_Type and then From_Limited_With (E) then IR := Make_Itype_Reference (Sloc (P_Body)); Set_Itype (IR, E); if No (Declarations (P_Body)) then Set_Declarations (P_Body, New_List (IR)); else Prepend (IR, Declarations (P_Body)); end if; end if; Next_Entity (E); end loop; end Check_Anonymous_Access_Types; ------------------------------------------- -- Declare_Inherited_Private_Subprograms -- ------------------------------------------- procedure Declare_Inherited_Private_Subprograms (Id : Entity_Id) is function Is_Primitive_Of (T : Entity_Id; S : Entity_Id) return Boolean; -- Check whether an inherited subprogram S is an operation of an -- untagged derived type T. --------------------- -- Is_Primitive_Of -- --------------------- function Is_Primitive_Of (T : Entity_Id; S : Entity_Id) return Boolean is Formal : Entity_Id; begin -- If the full view is a scalar type, the type is the anonymous base -- type, but the operation mentions the first subtype, so check the -- signature against the base type. if Base_Type (Etype (S)) = Base_Type (T) then return True; else Formal := First_Formal (S); while Present (Formal) loop if Base_Type (Etype (Formal)) = Base_Type (T) then return True; end if; Next_Formal (Formal); end loop; return False; end if; end Is_Primitive_Of; -- Local variables E : Entity_Id; Op_List : Elist_Id; Op_Elmt : Elmt_Id; Op_Elmt_2 : Elmt_Id; Prim_Op : Entity_Id; New_Op : Entity_Id := Empty; Parent_Subp : Entity_Id; Tag : Entity_Id; -- Start of processing for Declare_Inherited_Private_Subprograms begin E := First_Entity (Id); while Present (E) loop -- If the entity is a nonprivate type extension whose parent type -- is declared in an open scope, then the type may have inherited -- operations that now need to be made visible. Ditto if the entity -- is a formal derived type in a child unit. if ((Is_Derived_Type (E) and then not Is_Private_Type (E)) or else (Nkind (Parent (E)) = N_Private_Extension_Declaration and then Is_Generic_Type (E))) and then In_Open_Scopes (Scope (Etype (E))) and then Is_Base_Type (E) then if Is_Tagged_Type (E) then Op_List := Primitive_Operations (E); New_Op := Empty; Tag := First_Tag_Component (E); Op_Elmt := First_Elmt (Op_List); while Present (Op_Elmt) loop Prim_Op := Node (Op_Elmt); -- Search primitives that are implicit operations with an -- internal name whose parent operation has a normal name. if Present (Alias (Prim_Op)) and then Find_Dispatching_Type (Alias (Prim_Op)) /= E and then not Comes_From_Source (Prim_Op) and then Is_Internal_Name (Chars (Prim_Op)) and then not Is_Internal_Name (Chars (Alias (Prim_Op))) then Parent_Subp := Alias (Prim_Op); -- Case 1: Check if the type has also an explicit -- overriding for this primitive. Op_Elmt_2 := Next_Elmt (Op_Elmt); while Present (Op_Elmt_2) loop -- Skip entities with attribute Interface_Alias since -- they are not overriding primitives (these entities -- link an interface primitive with their covering -- primitive) if Chars (Node (Op_Elmt_2)) = Chars (Parent_Subp) and then Type_Conformant (Prim_Op, Node (Op_Elmt_2)) and then No (Interface_Alias (Node (Op_Elmt_2))) then -- The private inherited operation has been -- overridden by an explicit subprogram: -- replace the former by the latter. New_Op := Node (Op_Elmt_2); Replace_Elmt (Op_Elmt, New_Op); Remove_Elmt (Op_List, Op_Elmt_2); Set_Overridden_Operation (New_Op, Parent_Subp); -- We don't need to inherit its dispatching slot. -- Set_All_DT_Position has previously ensured that -- the same slot was assigned to the two primitives if Present (Tag) and then Present (DTC_Entity (New_Op)) and then Present (DTC_Entity (Prim_Op)) then pragma Assert (DT_Position (New_Op) = DT_Position (Prim_Op)); null; end if; goto Next_Primitive; end if; Next_Elmt (Op_Elmt_2); end loop; -- Case 2: We have not found any explicit overriding and -- hence we need to declare the operation (i.e., make it -- visible). Derive_Subprogram (New_Op, Alias (Prim_Op), E, Etype (E)); -- Inherit the dispatching slot if E is already frozen if Is_Frozen (E) and then Present (DTC_Entity (Alias (Prim_Op))) then Set_DTC_Entity_Value (E, New_Op); Set_DT_Position_Value (New_Op, DT_Position (Alias (Prim_Op))); end if; pragma Assert (Is_Dispatching_Operation (New_Op) and then Node (Last_Elmt (Op_List)) = New_Op); -- Substitute the new operation for the old one in the -- type's primitive operations list. Since the new -- operation was also just added to the end of list, -- the last element must be removed. -- (Question: is there a simpler way of declaring the -- operation, say by just replacing the name of the -- earlier operation, reentering it in the in the symbol -- table (how?), and marking it as private???) Replace_Elmt (Op_Elmt, New_Op); Remove_Last_Elmt (Op_List); end if; <<Next_Primitive>> Next_Elmt (Op_Elmt); end loop; -- Generate listing showing the contents of the dispatch table if Debug_Flag_ZZ then Write_DT (E); end if; else -- For untagged type, scan forward to locate inherited hidden -- operations. Prim_Op := Next_Entity (E); while Present (Prim_Op) loop if Is_Subprogram (Prim_Op) and then Present (Alias (Prim_Op)) and then not Comes_From_Source (Prim_Op) and then Is_Internal_Name (Chars (Prim_Op)) and then not Is_Internal_Name (Chars (Alias (Prim_Op))) and then Is_Primitive_Of (E, Prim_Op) then Derive_Subprogram (New_Op, Alias (Prim_Op), E, Etype (E)); end if; Next_Entity (Prim_Op); -- Derived operations appear immediately after the type -- declaration (or the following subtype indication for -- a derived scalar type). Further declarations cannot -- include inherited operations of the type. if Present (Prim_Op) then exit when Ekind (Prim_Op) not in Overloadable_Kind; end if; end loop; end if; end if; Next_Entity (E); end loop; end Declare_Inherited_Private_Subprograms; ----------------------- -- End_Package_Scope -- ----------------------- procedure End_Package_Scope (P : Entity_Id) is begin Uninstall_Declarations (P); Pop_Scope; end End_Package_Scope; --------------------------- -- Exchange_Declarations -- --------------------------- procedure Exchange_Declarations (Id : Entity_Id) is Full_Id : constant Entity_Id := Full_View (Id); H1 : constant Entity_Id := Homonym (Id); Next1 : constant Entity_Id := Next_Entity (Id); H2 : Entity_Id; Next2 : Entity_Id; begin -- If missing full declaration for type, nothing to exchange if No (Full_Id) then return; end if; -- Otherwise complete the exchange, and preserve semantic links Next2 := Next_Entity (Full_Id); H2 := Homonym (Full_Id); -- Reset full declaration pointer to reflect the switched entities and -- readjust the next entity chains. Exchange_Entities (Id, Full_Id); Link_Entities (Id, Next1); Set_Homonym (Id, H1); Set_Full_View (Full_Id, Id); Link_Entities (Full_Id, Next2); Set_Homonym (Full_Id, H2); end Exchange_Declarations; ---------------------------- -- Install_Package_Entity -- ---------------------------- procedure Install_Package_Entity (Id : Entity_Id) is begin if not Is_Internal (Id) then if Debug_Flag_E then Write_Str ("Install: "); Write_Name (Chars (Id)); Write_Eol; end if; if Is_Child_Unit (Id) then null; -- Do not enter implicitly inherited non-overridden subprograms of -- a tagged type back into visibility if they have non-conformant -- homographs (Ada RM 8.3 12.3/2). elsif Is_Hidden_Non_Overridden_Subpgm (Id) then null; else Set_Is_Immediately_Visible (Id); end if; end if; end Install_Package_Entity; ---------------------------------- -- Install_Private_Declarations -- ---------------------------------- procedure Install_Private_Declarations (P : Entity_Id) is Id : Entity_Id; Full : Entity_Id; Priv_Deps : Elist_Id; procedure Swap_Private_Dependents (Priv_Deps : Elist_Id); -- When the full view of a private type is made available, we do the -- same for its private dependents under proper visibility conditions. -- When compiling a child unit this needs to be done recursively. ----------------------------- -- Swap_Private_Dependents -- ----------------------------- procedure Swap_Private_Dependents (Priv_Deps : Elist_Id) is Cunit : Entity_Id; Deps : Elist_Id; Priv : Entity_Id; Priv_Elmt : Elmt_Id; Is_Priv : Boolean; begin Priv_Elmt := First_Elmt (Priv_Deps); while Present (Priv_Elmt) loop Priv := Node (Priv_Elmt); -- Before the exchange, verify that the presence of the Full_View -- field. This field will be empty if the entity has already been -- installed due to a previous call. if Present (Full_View (Priv)) and then Is_Visible_Dependent (Priv) then if Is_Private_Type (Priv) then Cunit := Cunit_Entity (Current_Sem_Unit); Deps := Private_Dependents (Priv); Is_Priv := True; else Is_Priv := False; end if; -- For each subtype that is swapped, we also swap the reference -- to it in Private_Dependents, to allow access to it when we -- swap them out in End_Package_Scope. Replace_Elmt (Priv_Elmt, Full_View (Priv)); -- Ensure that both views of the dependent private subtype are -- immediately visible if within some open scope. Check full -- view before exchanging views. if In_Open_Scopes (Scope (Full_View (Priv))) then Set_Is_Immediately_Visible (Priv); end if; Exchange_Declarations (Priv); Set_Is_Immediately_Visible (Priv, In_Open_Scopes (Scope (Priv))); Set_Is_Potentially_Use_Visible (Priv, Is_Potentially_Use_Visible (Node (Priv_Elmt))); -- Recurse for child units, except in generic child units, -- which unfortunately handle private_dependents separately. -- Note that the current unit may not have been analyzed, -- for example a package body, so we cannot rely solely on -- the Is_Child_Unit flag, but that's only an optimization. if Is_Priv and then (No (Etype (Cunit)) or else Is_Child_Unit (Cunit)) and then not Is_Empty_Elmt_List (Deps) and then not Inside_A_Generic then Swap_Private_Dependents (Deps); end if; end if; Next_Elmt (Priv_Elmt); end loop; end Swap_Private_Dependents; -- Start of processing for Install_Private_Declarations begin -- First exchange declarations for private types, so that the full -- declaration is visible. For each private type, we check its -- Private_Dependents list and also exchange any subtypes of or derived -- types from it. Finally, if this is a Taft amendment type, the -- incomplete declaration is irrelevant, and we want to link the -- eventual full declaration with the original private one so we -- also skip the exchange. Id := First_Entity (P); while Present (Id) and then Id /= First_Private_Entity (P) loop if Is_Private_Base_Type (Id) and then Present (Full_View (Id)) and then Comes_From_Source (Full_View (Id)) and then Scope (Full_View (Id)) = Scope (Id) and then Ekind (Full_View (Id)) /= E_Incomplete_Type then -- If there is a use-type clause on the private type, set the full -- view accordingly. Set_In_Use (Full_View (Id), In_Use (Id)); Full := Full_View (Id); if Is_Private_Base_Type (Full) and then Has_Private_Declaration (Full) and then Nkind (Parent (Full)) = N_Full_Type_Declaration and then In_Open_Scopes (Scope (Etype (Full))) and then In_Package_Body (Current_Scope) and then not Is_Private_Type (Etype (Full)) then -- This is the completion of a private type by a derivation -- from another private type which is not private anymore. This -- can only happen in a package nested within a child package, -- when the parent type is defined in the parent unit. At this -- point the current type is not private either, and we have -- to install the underlying full view, which is now visible. -- Save the current full view as well, so that all views can be -- restored on exit. It may seem that after compiling the child -- body there are not environments to restore, but the back-end -- expects those links to be valid, and freeze nodes depend on -- them. if No (Full_View (Full)) and then Present (Underlying_Full_View (Full)) then Set_Full_View (Id, Underlying_Full_View (Full)); Set_Underlying_Full_View (Id, Full); Set_Is_Underlying_Full_View (Full); Set_Underlying_Full_View (Full, Empty); Set_Is_Frozen (Full_View (Id)); end if; end if; Priv_Deps := Private_Dependents (Id); Exchange_Declarations (Id); Set_Is_Immediately_Visible (Id); Swap_Private_Dependents (Priv_Deps); end if; Next_Entity (Id); end loop; -- Next make other declarations in the private part visible as well Id := First_Private_Entity (P); while Present (Id) loop Install_Package_Entity (Id); Set_Is_Hidden (Id, False); Next_Entity (Id); end loop; -- An abstract state is partially refined when it has at least one -- Part_Of constituent. Since these constituents are being installed -- into visibility, update the partial refinement status of any state -- defined in the associated package, subject to at least one Part_Of -- constituent. if Is_Package_Or_Generic_Package (P) then declare States : constant Elist_Id := Abstract_States (P); State_Elmt : Elmt_Id; State_Id : Entity_Id; begin if Present (States) then State_Elmt := First_Elmt (States); while Present (State_Elmt) loop State_Id := Node (State_Elmt); if Present (Part_Of_Constituents (State_Id)) then Set_Has_Partial_Visible_Refinement (State_Id); end if; Next_Elmt (State_Elmt); end loop; end if; end; end if; -- Indicate that the private part is currently visible, so it can be -- properly reset on exit. Set_In_Private_Part (P); end Install_Private_Declarations; ---------------------------------- -- Install_Visible_Declarations -- ---------------------------------- procedure Install_Visible_Declarations (P : Entity_Id) is Id : Entity_Id; Last_Entity : Entity_Id; begin pragma Assert (Is_Package_Or_Generic_Package (P) or else Is_Record_Type (P)); if Is_Package_Or_Generic_Package (P) then Last_Entity := First_Private_Entity (P); else Last_Entity := Empty; end if; Id := First_Entity (P); while Present (Id) and then Id /= Last_Entity loop Install_Package_Entity (Id); Next_Entity (Id); end loop; end Install_Visible_Declarations; -------------------------- -- Is_Private_Base_Type -- -------------------------- function Is_Private_Base_Type (E : Entity_Id) return Boolean is begin return Ekind (E) = E_Private_Type or else Ekind (E) = E_Limited_Private_Type or else Ekind (E) = E_Record_Type_With_Private; end Is_Private_Base_Type; -------------------------- -- Is_Visible_Dependent -- -------------------------- function Is_Visible_Dependent (Dep : Entity_Id) return Boolean is S : constant Entity_Id := Scope (Dep); begin -- Renamings created for actual types have the visibility of the actual if Ekind (S) = E_Package and then Is_Generic_Instance (S) and then (Is_Generic_Actual_Type (Dep) or else Is_Generic_Actual_Type (Full_View (Dep))) then return True; elsif not (Is_Derived_Type (Dep)) and then Is_Derived_Type (Full_View (Dep)) then -- When instantiating a package body, the scope stack is empty, so -- check instead whether the dependent type is defined in the same -- scope as the instance itself. return In_Open_Scopes (S) or else (Is_Generic_Instance (Current_Scope) and then Scope (Dep) = Scope (Current_Scope)); else return True; end if; end Is_Visible_Dependent; ---------------------------- -- May_Need_Implicit_Body -- ---------------------------- procedure May_Need_Implicit_Body (E : Entity_Id) is P : constant Node_Id := Unit_Declaration_Node (E); S : constant Node_Id := Parent (P); B : Node_Id; Decls : List_Id; begin if not Has_Completion (E) and then Nkind (P) = N_Package_Declaration and then (Present (Activation_Chain_Entity (P)) or else Has_RACW (E)) then B := Make_Package_Body (Sloc (E), Defining_Unit_Name => Make_Defining_Identifier (Sloc (E), Chars => Chars (E)), Declarations => New_List); if Nkind (S) = N_Package_Specification then if Present (Private_Declarations (S)) then Decls := Private_Declarations (S); else Decls := Visible_Declarations (S); end if; else Decls := Declarations (S); end if; Append (B, Decls); Analyze (B); end if; end May_Need_Implicit_Body; ---------------------- -- New_Private_Type -- ---------------------- procedure New_Private_Type (N : Node_Id; Id : Entity_Id; Def : Node_Id) is begin -- For other than Ada 2012, enter the name in the current scope if Ada_Version < Ada_2012 then Enter_Name (Id); -- Ada 2012 (AI05-0162): Enter the name in the current scope. Note that -- there may be an incomplete previous view. else declare Prev : Entity_Id; begin Prev := Find_Type_Name (N); pragma Assert (Prev = Id or else (Ekind (Prev) = E_Incomplete_Type and then Present (Full_View (Prev)) and then Full_View (Prev) = Id)); end; end if; if Limited_Present (Def) then Set_Ekind (Id, E_Limited_Private_Type); else Set_Ekind (Id, E_Private_Type); end if; Set_Etype (Id, Id); Set_Has_Delayed_Freeze (Id); Set_Is_First_Subtype (Id); Init_Size_Align (Id); Set_Is_Constrained (Id, No (Discriminant_Specifications (N)) and then not Unknown_Discriminants_Present (N)); -- Set tagged flag before processing discriminants, to catch illegal -- usage. Set_Is_Tagged_Type (Id, Tagged_Present (Def)); Set_Discriminant_Constraint (Id, No_Elist); Set_Stored_Constraint (Id, No_Elist); if Present (Discriminant_Specifications (N)) then Push_Scope (Id); Process_Discriminants (N); End_Scope; elsif Unknown_Discriminants_Present (N) then Set_Has_Unknown_Discriminants (Id); end if; Set_Private_Dependents (Id, New_Elmt_List); if Tagged_Present (Def) then Set_Ekind (Id, E_Record_Type_With_Private); Set_Direct_Primitive_Operations (Id, New_Elmt_List); Set_Is_Abstract_Type (Id, Abstract_Present (Def)); Set_Is_Limited_Record (Id, Limited_Present (Def)); Set_Has_Delayed_Freeze (Id, True); -- Recognize Ada.Real_Time.Timing_Events.Timing_Events here if Is_RTE (Id, RE_Timing_Event) then Set_Has_Timing_Event (Id); end if; -- Create a class-wide type with the same attributes Make_Class_Wide_Type (Id); elsif Abstract_Present (Def) then Error_Msg_N ("only a tagged type can be abstract", N); end if; end New_Private_Type; --------------------------------- -- Requires_Completion_In_Body -- --------------------------------- function Requires_Completion_In_Body (Id : Entity_Id; Pack_Id : Entity_Id; Do_Abstract_States : Boolean := False) return Boolean is begin -- Always ignore child units. Child units get added to the entity list -- of a parent unit, but are not original entities of the parent, and -- so do not affect whether the parent needs a body. if Is_Child_Unit (Id) then return False; -- Ignore formal packages and their renamings elsif Ekind (Id) = E_Package and then Nkind (Original_Node (Unit_Declaration_Node (Id))) = N_Formal_Package_Declaration then return False; -- Otherwise test to see if entity requires a completion. Note that -- subprogram entities whose declaration does not come from source are -- ignored here on the basis that we assume the expander will provide an -- implicit completion at some point. elsif (Is_Overloadable (Id) and then Ekind (Id) not in E_Enumeration_Literal | E_Operator and then not Is_Abstract_Subprogram (Id) and then not Has_Completion (Id) and then Comes_From_Source (Parent (Id))) or else (Ekind (Id) = E_Package and then Id /= Pack_Id and then not Has_Completion (Id) and then Unit_Requires_Body (Id, Do_Abstract_States)) or else (Ekind (Id) = E_Incomplete_Type and then No (Full_View (Id)) and then not Is_Generic_Type (Id)) or else (Ekind (Id) in E_Task_Type | E_Protected_Type and then not Has_Completion (Id)) or else (Ekind (Id) = E_Generic_Package and then Id /= Pack_Id and then not Has_Completion (Id) and then Unit_Requires_Body (Id, Do_Abstract_States)) or else (Is_Generic_Subprogram (Id) and then not Has_Completion (Id)) then return True; -- Otherwise the entity does not require completion in a package body else return False; end if; end Requires_Completion_In_Body; ---------------------------- -- Uninstall_Declarations -- ---------------------------- procedure Uninstall_Declarations (P : Entity_Id) is Decl : constant Node_Id := Unit_Declaration_Node (P); Id : Entity_Id; Full : Entity_Id; procedure Preserve_Full_Attributes (Priv : Entity_Id; Full : Entity_Id); -- Copy to the private declaration the attributes of the full view that -- need to be available for the partial view also. procedure Swap_Private_Dependents (Priv_Deps : Elist_Id); -- When the full view of a private type is made unavailable, we do the -- same for its private dependents under proper visibility conditions. -- When compiling a child unit this needs to be done recursively. function Type_In_Use (T : Entity_Id) return Boolean; -- Check whether type or base type appear in an active use_type clause ------------------------------ -- Preserve_Full_Attributes -- ------------------------------ procedure Preserve_Full_Attributes (Priv : Entity_Id; Full : Entity_Id) is Full_Base : constant Entity_Id := Base_Type (Full); Priv_Is_Base_Type : constant Boolean := Is_Base_Type (Priv); begin Set_Size_Info (Priv, Full); Set_RM_Size (Priv, RM_Size (Full)); Set_Size_Known_At_Compile_Time (Priv, Size_Known_At_Compile_Time (Full)); Set_Is_Volatile (Priv, Is_Volatile (Full)); Set_Treat_As_Volatile (Priv, Treat_As_Volatile (Full)); Set_Is_Ada_2005_Only (Priv, Is_Ada_2005_Only (Full)); Set_Is_Ada_2012_Only (Priv, Is_Ada_2012_Only (Full)); Set_Has_Pragma_Unmodified (Priv, Has_Pragma_Unmodified (Full)); Set_Has_Pragma_Unreferenced (Priv, Has_Pragma_Unreferenced (Full)); Set_Has_Pragma_Unreferenced_Objects (Priv, Has_Pragma_Unreferenced_Objects (Full)); Set_Predicates_Ignored (Priv, Predicates_Ignored (Full)); if Is_Unchecked_Union (Full) then Set_Is_Unchecked_Union (Base_Type (Priv)); end if; -- Why is atomic not copied here ??? if Referenced (Full) then Set_Referenced (Priv); end if; if Priv_Is_Base_Type then Set_Is_Controlled_Active (Priv, Is_Controlled_Active (Full_Base)); Set_Finalize_Storage_Only (Priv, Finalize_Storage_Only (Full_Base)); Set_Has_Controlled_Component (Priv, Has_Controlled_Component (Full_Base)); Propagate_Concurrent_Flags (Priv, Base_Type (Full)); end if; -- As explained in Freeze_Entity, private types are required to point -- to the same freeze node as their corresponding full view, if any. -- But we ought not to overwrite a node already inserted in the tree. pragma Assert (Serious_Errors_Detected /= 0 or else No (Freeze_Node (Priv)) or else No (Parent (Freeze_Node (Priv))) or else Freeze_Node (Priv) = Freeze_Node (Full)); Set_Freeze_Node (Priv, Freeze_Node (Full)); -- Propagate Default_Initial_Condition-related attributes from the -- full view to the private view. Propagate_DIC_Attributes (Priv, From_Typ => Full); -- Propagate invariant-related attributes from the full view to the -- private view. Propagate_Invariant_Attributes (Priv, From_Typ => Full); -- Propagate predicate-related attributes from the full view to the -- private view. Propagate_Predicate_Attributes (Priv, From_Typ => Full); if Is_Tagged_Type (Priv) and then Is_Tagged_Type (Full) and then not Error_Posted (Full) then if Is_Tagged_Type (Priv) then -- If the type is tagged, the tag itself must be available on -- the partial view, for expansion purposes. Set_First_Entity (Priv, First_Entity (Full)); -- If there are discriminants in the partial view, these remain -- visible. Otherwise only the tag itself is visible, and there -- are no nameable components in the partial view. if No (Last_Entity (Priv)) then Set_Last_Entity (Priv, First_Entity (Priv)); end if; end if; Set_Has_Discriminants (Priv, Has_Discriminants (Full)); if Has_Discriminants (Full) then Set_Discriminant_Constraint (Priv, Discriminant_Constraint (Full)); end if; end if; end Preserve_Full_Attributes; ----------------------------- -- Swap_Private_Dependents -- ----------------------------- procedure Swap_Private_Dependents (Priv_Deps : Elist_Id) is Cunit : Entity_Id; Deps : Elist_Id; Priv : Entity_Id; Priv_Elmt : Elmt_Id; Is_Priv : Boolean; begin Priv_Elmt := First_Elmt (Priv_Deps); while Present (Priv_Elmt) loop Priv := Node (Priv_Elmt); -- Before we do the swap, we verify the presence of the Full_View -- field, which may be empty due to a swap by a previous call to -- End_Package_Scope (e.g. from the freezing mechanism). if Present (Full_View (Priv)) then if Is_Private_Type (Priv) then Cunit := Cunit_Entity (Current_Sem_Unit); Deps := Private_Dependents (Priv); Is_Priv := True; else Is_Priv := False; end if; if Scope (Priv) = P or else not In_Open_Scopes (Scope (Priv)) then Set_Is_Immediately_Visible (Priv, False); end if; if Is_Visible_Dependent (Priv) then Preserve_Full_Attributes (Priv, Full_View (Priv)); Replace_Elmt (Priv_Elmt, Full_View (Priv)); Exchange_Declarations (Priv); -- Recurse for child units, except in generic child units, -- which unfortunately handle private_dependents separately. -- Note that the current unit may not have been analyzed, -- for example a package body, so we cannot rely solely on -- the Is_Child_Unit flag, but that's only an optimization. if Is_Priv and then (No (Etype (Cunit)) or else Is_Child_Unit (Cunit)) and then not Is_Empty_Elmt_List (Deps) and then not Inside_A_Generic then Swap_Private_Dependents (Deps); end if; end if; end if; Next_Elmt (Priv_Elmt); end loop; end Swap_Private_Dependents; ----------------- -- Type_In_Use -- ----------------- function Type_In_Use (T : Entity_Id) return Boolean is begin return Scope (Base_Type (T)) = P and then (In_Use (T) or else In_Use (Base_Type (T))); end Type_In_Use; -- Start of processing for Uninstall_Declarations begin Id := First_Entity (P); while Present (Id) and then Id /= First_Private_Entity (P) loop if Debug_Flag_E then Write_Str ("unlinking visible entity "); Write_Int (Int (Id)); Write_Eol; end if; -- On exit from the package scope, we must preserve the visibility -- established by use clauses in the current scope. Two cases: -- a) If the entity is an operator, it may be a primitive operator of -- a type for which there is a visible use-type clause. -- b) For other entities, their use-visibility is determined by a -- visible use clause for the package itself or a use-all-type clause -- applied directly to the entity's type. For a generic instance, -- the instantiation of the formals appears in the visible part, -- but the formals are private and remain so. if Ekind (Id) = E_Function and then Is_Operator_Symbol_Name (Chars (Id)) and then not Is_Hidden (Id) and then not Error_Posted (Id) then Set_Is_Potentially_Use_Visible (Id, In_Use (P) or else Type_In_Use (Etype (Id)) or else Type_In_Use (Etype (First_Formal (Id))) or else (Present (Next_Formal (First_Formal (Id))) and then Type_In_Use (Etype (Next_Formal (First_Formal (Id)))))); else if In_Use (P) and then not Is_Hidden (Id) then -- A child unit of a use-visible package remains use-visible -- only if it is itself a visible child unit. Otherwise it -- would remain visible in other contexts where P is use- -- visible, because once compiled it stays in the entity list -- of its parent unit. if Is_Child_Unit (Id) then Set_Is_Potentially_Use_Visible (Id, Is_Visible_Lib_Unit (Id)); else Set_Is_Potentially_Use_Visible (Id); end if; -- We need to avoid incorrectly marking enumeration literals as -- non-visible when a visible use-all-type clause is in effect. elsif Type_In_Use (Etype (Id)) and then Nkind (Current_Use_Clause (Etype (Id))) = N_Use_Type_Clause and then All_Present (Current_Use_Clause (Etype (Id))) then null; else Set_Is_Potentially_Use_Visible (Id, False); end if; end if; -- Local entities are not immediately visible outside of the package Set_Is_Immediately_Visible (Id, False); -- If this is a private type with a full view (for example a local -- subtype of a private type declared elsewhere), ensure that the -- full view is also removed from visibility: it may be exposed when -- swapping views in an instantiation. Similarly, ensure that the -- use-visibility is properly set on both views. if Is_Type (Id) and then Present (Full_View (Id)) then Set_Is_Immediately_Visible (Full_View (Id), False); Set_Is_Potentially_Use_Visible (Full_View (Id), Is_Potentially_Use_Visible (Id)); end if; if Is_Tagged_Type (Id) and then Ekind (Id) = E_Record_Type then Check_Abstract_Overriding (Id); Check_Conventions (Id); end if; if Ekind (Id) in E_Private_Type | E_Limited_Private_Type and then No (Full_View (Id)) and then not Is_Generic_Type (Id) and then not Is_Derived_Type (Id) then Error_Msg_N ("missing full declaration for private type&", Id); elsif Ekind (Id) = E_Record_Type_With_Private and then not Is_Generic_Type (Id) and then No (Full_View (Id)) then if Nkind (Parent (Id)) = N_Private_Type_Declaration then Error_Msg_N ("missing full declaration for private type&", Id); else Error_Msg_N ("missing full declaration for private extension", Id); end if; -- Case of constant, check for deferred constant declaration with -- no full view. Likely just a matter of a missing expression, or -- accidental use of the keyword constant. elsif Ekind (Id) = E_Constant -- OK if constant value present and then No (Constant_Value (Id)) -- OK if full view present and then No (Full_View (Id)) -- OK if imported, since that provides the completion and then not Is_Imported (Id) -- OK if object declaration replaced by renaming declaration as -- a result of OK_To_Rename processing (e.g. for concatenation) and then Nkind (Parent (Id)) /= N_Object_Renaming_Declaration -- OK if object declaration with the No_Initialization flag set and then not (Nkind (Parent (Id)) = N_Object_Declaration and then No_Initialization (Parent (Id))) then -- If no private declaration is present, we assume the user did -- not intend a deferred constant declaration and the problem -- is simply that the initializing expression is missing. if not Has_Private_Declaration (Etype (Id)) then -- We assume that the user did not intend a deferred constant -- declaration, and the expression is just missing. Error_Msg_N ("constant declaration requires initialization expression", Parent (Id)); if Is_Limited_Type (Etype (Id)) then Error_Msg_N ("\if variable intended, remove CONSTANT from declaration", Parent (Id)); end if; -- Otherwise if a private declaration is present, then we are -- missing the full declaration for the deferred constant. else Error_Msg_N ("missing full declaration for deferred constant (RM 7.4)", Id); if Is_Limited_Type (Etype (Id)) then Error_Msg_N ("\if variable intended, remove CONSTANT from declaration", Parent (Id)); end if; end if; end if; Next_Entity (Id); end loop; -- If the specification was installed as the parent of a public child -- unit, the private declarations were not installed, and there is -- nothing to do. if not In_Private_Part (P) then return; else Set_In_Private_Part (P, False); end if; -- Make private entities invisible and exchange full and private -- declarations for private types. Id is now the first private entity -- in the package. while Present (Id) loop if Debug_Flag_E then Write_Str ("unlinking private entity "); Write_Int (Int (Id)); Write_Eol; end if; if Is_Tagged_Type (Id) and then Ekind (Id) = E_Record_Type then Check_Abstract_Overriding (Id); Check_Conventions (Id); end if; Set_Is_Immediately_Visible (Id, False); if Is_Private_Base_Type (Id) and then Present (Full_View (Id)) then Full := Full_View (Id); -- If the partial view is not declared in the visible part of the -- package (as is the case when it is a type derived from some -- other private type in the private part of the current package), -- no exchange takes place. if No (Parent (Id)) or else List_Containing (Parent (Id)) /= Visible_Declarations (Specification (Decl)) then goto Next_Id; end if; -- The entry in the private part points to the full declaration, -- which is currently visible. Exchange them so only the private -- type declaration remains accessible, and link private and full -- declaration in the opposite direction. Before the actual -- exchange, we copy back attributes of the full view that must -- be available to the partial view too. Preserve_Full_Attributes (Id, Full); Set_Is_Potentially_Use_Visible (Id, In_Use (P)); -- The following test may be redundant, as this is already -- diagnosed in sem_ch3. ??? if not Is_Definite_Subtype (Full) and then Is_Definite_Subtype (Id) then Error_Msg_Sloc := Sloc (Parent (Id)); Error_Msg_NE ("full view of& not compatible with declaration#", Full, Id); end if; -- Swap out the subtypes and derived types of Id that -- were compiled in this scope, or installed previously -- by Install_Private_Declarations. Swap_Private_Dependents (Private_Dependents (Id)); -- Now restore the type itself to its private view Exchange_Declarations (Id); -- If we have installed an underlying full view for a type derived -- from a private type in a child unit, restore the proper views -- of private and full view. See corresponding code in -- Install_Private_Declarations. -- After the exchange, Full denotes the private type in the -- visible part of the package. if Is_Private_Base_Type (Full) and then Present (Full_View (Full)) and then Present (Underlying_Full_View (Full)) and then In_Package_Body (Current_Scope) then Set_Full_View (Full, Underlying_Full_View (Full)); Set_Underlying_Full_View (Full, Empty); end if; elsif Ekind (Id) = E_Incomplete_Type and then Comes_From_Source (Id) and then No (Full_View (Id)) then -- Mark Taft amendment types. Verify that there are no primitive -- operations declared for the type (3.10.1(9)). Set_Has_Completion_In_Body (Id); declare Elmt : Elmt_Id; Subp : Entity_Id; begin Elmt := First_Elmt (Private_Dependents (Id)); while Present (Elmt) loop Subp := Node (Elmt); -- Is_Primitive is tested because there can be cases where -- nonprimitive subprograms (in nested packages) are added -- to the Private_Dependents list. if Is_Overloadable (Subp) and then Is_Primitive (Subp) then Error_Msg_NE ("type& must be completed in the private part", Parent (Subp), Id); -- The result type of an access-to-function type cannot be a -- Taft-amendment type, unless the version is Ada 2012 or -- later (see AI05-151). elsif Ada_Version < Ada_2012 and then Ekind (Subp) = E_Subprogram_Type then if Etype (Subp) = Id or else (Is_Class_Wide_Type (Etype (Subp)) and then Etype (Etype (Subp)) = Id) then Error_Msg_NE ("type& must be completed in the private part", Associated_Node_For_Itype (Subp), Id); end if; end if; Next_Elmt (Elmt); end loop; end; -- For subtypes of private types the frontend generates two entities: -- one associated with the partial view and the other associated with -- the full view. When the subtype declaration is public the frontend -- places the former entity in the list of public entities of the -- package and the latter entity in the private part of the package. -- When the subtype declaration is private it generates these two -- entities but both are placed in the private part of the package -- (and the full view has the same source location as the partial -- view and no parent; see Prepare_Private_Subtype_Completion). elsif Ekind (Id) in E_Private_Subtype | E_Limited_Private_Subtype and then Present (Full_View (Id)) and then Sloc (Id) = Sloc (Full_View (Id)) and then No (Parent (Full_View (Id))) then Set_Is_Hidden (Id); Set_Is_Potentially_Use_Visible (Id, False); elsif not Is_Child_Unit (Id) and then (not Is_Private_Type (Id) or else No (Full_View (Id))) then Set_Is_Hidden (Id); Set_Is_Potentially_Use_Visible (Id, False); end if; <<Next_Id>> Next_Entity (Id); end loop; end Uninstall_Declarations; ------------------------ -- Unit_Requires_Body -- ------------------------ function Unit_Requires_Body (Pack_Id : Entity_Id; Do_Abstract_States : Boolean := False) return Boolean is E : Entity_Id; Requires_Body : Boolean := False; -- Flag set when the unit has at least one construct that requires -- completion in a body. begin -- Imported entity never requires body. Right now, only subprograms can -- be imported, but perhaps in the future we will allow import of -- packages. if Is_Imported (Pack_Id) then return False; -- Body required if library package with pragma Elaborate_Body elsif Has_Pragma_Elaborate_Body (Pack_Id) then return True; -- Body required if subprogram elsif Is_Subprogram_Or_Generic_Subprogram (Pack_Id) then return True; -- Treat a block as requiring a body elsif Ekind (Pack_Id) = E_Block then return True; elsif Ekind (Pack_Id) = E_Package and then Nkind (Parent (Pack_Id)) = N_Package_Specification and then Present (Generic_Parent (Parent (Pack_Id))) then declare G_P : constant Entity_Id := Generic_Parent (Parent (Pack_Id)); begin if Has_Pragma_Elaborate_Body (G_P) then return True; end if; end; end if; -- Traverse the entity chain of the package and look for constructs that -- require a completion in a body. E := First_Entity (Pack_Id); while Present (E) loop -- Skip abstract states because their completion depends on several -- criteria (see below). if Ekind (E) = E_Abstract_State then null; elsif Requires_Completion_In_Body (E, Pack_Id, Do_Abstract_States) then Requires_Body := True; exit; end if; Next_Entity (E); end loop; -- A [generic] package that defines at least one non-null abstract state -- requires a completion only when at least one other construct requires -- a completion in a body (SPARK RM 7.1.4(4) and (5)). This check is not -- performed if the caller requests this behavior. if Do_Abstract_States and then Is_Package_Or_Generic_Package (Pack_Id) and then Has_Non_Null_Abstract_State (Pack_Id) and then Requires_Body then return True; end if; return Requires_Body; end Unit_Requires_Body; ----------------------------- -- Unit_Requires_Body_Info -- ----------------------------- procedure Unit_Requires_Body_Info (Pack_Id : Entity_Id) is E : Entity_Id; begin -- An imported entity never requires body. Right now, only subprograms -- can be imported, but perhaps in the future we will allow import of -- packages. if Is_Imported (Pack_Id) then return; -- Body required if library package with pragma Elaborate_Body elsif Has_Pragma_Elaborate_Body (Pack_Id) then Error_Msg_N ("info: & requires body (Elaborate_Body)?Y?", Pack_Id); -- Body required if subprogram elsif Is_Subprogram_Or_Generic_Subprogram (Pack_Id) then Error_Msg_N ("info: & requires body (subprogram case)?Y?", Pack_Id); -- Body required if generic parent has Elaborate_Body elsif Ekind (Pack_Id) = E_Package and then Nkind (Parent (Pack_Id)) = N_Package_Specification and then Present (Generic_Parent (Parent (Pack_Id))) then declare G_P : constant Entity_Id := Generic_Parent (Parent (Pack_Id)); begin if Has_Pragma_Elaborate_Body (G_P) then Error_Msg_N ("info: & requires body (generic parent Elaborate_Body)?Y?", Pack_Id); end if; end; -- A [generic] package that introduces at least one non-null abstract -- state requires completion. However, there is a separate rule that -- requires that such a package have a reason other than this for a -- body being required (if necessary a pragma Elaborate_Body must be -- provided). If Ignore_Abstract_State is True, we don't do this check -- (so we can use Unit_Requires_Body to check for some other reason). elsif Is_Package_Or_Generic_Package (Pack_Id) and then Present (Abstract_States (Pack_Id)) and then not Is_Null_State (Node (First_Elmt (Abstract_States (Pack_Id)))) then Error_Msg_N ("info: & requires body (non-null abstract state aspect)?Y?", Pack_Id); end if; -- Otherwise search entity chain for entity requiring completion E := First_Entity (Pack_Id); while Present (E) loop if Requires_Completion_In_Body (E, Pack_Id) then Error_Msg_Node_2 := E; Error_Msg_NE ("info: & requires body (& requires completion)?Y?", E, Pack_Id); end if; Next_Entity (E); end loop; end Unit_Requires_Body_Info; end Sem_Ch7;
private with SAM.DMAC; private with SAM.Clock_Generator; private with SAM.Clock_Setup_120Mhz; package PyGamer is pragma Elaborate_Body; private use SAM.Clock_Generator; Clk_CPU : constant Generator_Id := SAM.Clock_Setup_120Mhz.Clk_CPU; Clk_120Mhz : constant Generator_Id := SAM.Clock_Setup_120Mhz.Clk_120Mhz; Clk_48Mhz : constant Generator_Id := SAM.Clock_Setup_120Mhz.Clk_48Mhz; Clk_32Khz : constant Generator_Id := SAM.Clock_Setup_120Mhz.Clk_32Khz; Clk_2Mhz : constant Generator_Id := SAM.Clock_Setup_120Mhz.Clk_2Mhz; DMA_Descs : aliased SAM.DMAC.Descriptor_Section; DMA_WB : aliased SAM.DMAC.Descriptor_Section; DMA_DAC_0 : constant SAM.DMAC.Channel_Id := 0; DMA_DAC_1 : constant SAM.DMAC.Channel_Id := 1; DMA_Screen_SPI : constant SAM.DMAC.Channel_Id := 2; end PyGamer;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <contact@flyx.org> -- -- 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.API.Uniforms.Singles; with GL.API.Uniforms.Doubles; with GL.API.Uniforms.Ints; with GL.API.Uniforms.UInts; with GL.Low_Level; package body GL.Objects.Programs.Uniforms is function Create_Uniform (Object : Program; Location : Int) return Uniform is begin return Uniform'(Program => Object, Location => Location); end Create_Uniform; ----------------------------------------------------------------------------- -- Singles -- ----------------------------------------------------------------------------- procedure Set_Single (Location : Uniform; Value : Single) is begin API.Uniforms.Singles.Uniform1.Ref (Location.Program.Reference.GL_Id, Location.Location, Value); end Set_Single; procedure Set_Single_Vector (Location : Uniform; Value : Singles.Vector2) is begin API.Uniforms.Singles.Uniform2v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Single_Vector; procedure Set_Single_Vector (Location : Uniform; Value : Singles.Vector3) is begin API.Uniforms.Singles.Uniform3v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Single_Vector; procedure Set_Single_Vector (Location : Uniform; Value : Singles.Vector4) is begin API.Uniforms.Singles.Uniform4v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Single_Vector; procedure Set_Single_Matrix (Location : Uniform; Value : Singles.Matrix4) is begin API.Uniforms.Singles.Uniform_Matrix4.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, Low_Level.False, (1 => Value)); end Set_Single_Matrix; ----------------------------------------------------------------------------- -- Doubles -- ----------------------------------------------------------------------------- procedure Set_Double (Location : Uniform; Value : Double) is begin API.Uniforms.Doubles.Uniform1.Ref (Location.Program.Reference.GL_Id, Location.Location, Value); end Set_Double; procedure Set_Double_Vector (Location : Uniform; Value : Doubles.Vector2) is begin API.Uniforms.Doubles.Uniform2v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Double_Vector; procedure Set_Double_Vector (Location : Uniform; Value : Doubles.Vector3) is begin API.Uniforms.Doubles.Uniform3v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Double_Vector; procedure Set_Double_Vector (Location : Uniform; Value : Doubles.Vector4) is begin API.Uniforms.Doubles.Uniform4v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Double_Vector; procedure Set_Double_Matrix (Location : Uniform; Value : Doubles.Matrix4) is begin API.Uniforms.Doubles.Uniform_Matrix4.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, Low_Level.False, (1 => Value)); end Set_Double_Matrix; ----------------------------------------------------------------------------- -- Integers -- ----------------------------------------------------------------------------- procedure Set_Int (Location : Uniform; Value : Int) is begin API.Uniforms.Ints.Uniform1.Ref (Location.Program.Reference.GL_Id, Location.Location, Value); end Set_Int; procedure Set_Int_Vector (Location : Uniform; Value : Ints.Vector2) is begin API.Uniforms.Ints.Uniform2v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Int_Vector; procedure Set_Int_Vector (Location : Uniform; Value : Ints.Vector3) is begin API.Uniforms.Ints.Uniform3v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Int_Vector; procedure Set_Int_Vector (Location : Uniform; Value : Ints.Vector4) is begin API.Uniforms.Ints.Uniform4v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_Int_Vector; ----------------------------------------------------------------------------- -- Unsigned Integers -- ----------------------------------------------------------------------------- procedure Set_UInt (Location : Uniform; Value : UInt) is begin API.Uniforms.UInts.Uniform1.Ref (Location.Program.Reference.GL_Id, Location.Location, Value); end Set_UInt; procedure Set_UInt_Vector (Location : Uniform; Value : UInts.Vector2) is begin API.Uniforms.UInts.Uniform2v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_UInt_Vector; procedure Set_UInt_Vector (Location : Uniform; Value : UInts.Vector3) is begin API.Uniforms.UInts.Uniform3v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_UInt_Vector; procedure Set_UInt_Vector (Location : Uniform; Value : UInts.Vector4) is begin API.Uniforms.UInts.Uniform4v.Ref (Location.Program.Reference.GL_Id, Location.Location, 1, (1 => Value)); end Set_UInt_Vector; end GL.Objects.Programs.Uniforms;
package body Opt57 is type Phase_Enum is (None_Phase, FE_Init_Phase, FE_Phase); type Message_State is (No_Messages, Some_Messages); type Module_List_Array is array (Phase_Enum, Message_State) of List; type Private_Module_Factory is limited record Module_Lists : Module_List_Array; end record; type Element_Array is array (Positive range <>) of Module_Factory_Ptr; type Hash_Table is array (Positive range <>) of aliased Module_Factory_Ptr; type Heap_Data_Rec (Table_Last : Positive) is limited record Number_Of_Elements : Positive; Table : Hash_Table (1 .. Table_Last); end record; type Heap_Data_Ptr is access Heap_Data_Rec; type Table is limited record Data : Heap_Data_Ptr; end record; function All_Elements (M : Table) return Element_Array is Result : Element_Array (1 .. Natural (M.Data.Number_Of_Elements)); Last : Natural := 0; begin for H in M.Data.Table'Range loop Last := Last + 1; Result (Last) := M.Data.Table(H); end loop; return Result; end; The_Factories : Table; subtype Language_Array is Element_Array; type Language_Array_Ptr is access Language_Array; All_Languages : Language_Array_Ptr := null; procedure Init is begin if All_Languages = null then All_Languages := new Language_Array'(All_Elements (The_Factories)); end if; end; function Is_Empty (L : List) return Boolean is begin return Link_Constant (L.Next) = L'Unchecked_Access; end; function First (L : List) return Linkable_Ptr is begin return Links_Type (L.Next.all).Container.all'Access; end; procedure Update is Check_New_Dependences : Boolean := False; begin loop for Lang_Index in All_Languages'Range loop for Has_Messages in Message_State loop declare L : List renames All_Languages (Lang_Index).Priv.Module_Lists (FE_Init_Phase, Has_Messages); begin while not Is_Empty (L) loop declare Module_In_Init_State : constant Module_Ptr := Module_Ptr (First (L)); Pin_Dependence : Pinned (Module_In_Init_State); begin Check_New_Dependences := True; end; end loop; end; end loop; end loop; exit when not Check_New_Dependences; end loop; end; end Opt57;
with VisitablePackage, EnvironmentPackage; use VisitablePackage, EnvironmentPackage; with Ada.Text_IO; use Ada.Text_IO; package body IdentityStrategy is ---------------------------------------------------------------------------- -- Object implementation ---------------------------------------------------------------------------- overriding function toString(o: Identity) return String is begin return "Identity()"; end; ---------------------------------------------------------------------------- -- Strategy implementation ---------------------------------------------------------------------------- overriding function visitLight(str:access Identity; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is begin return any; end; overriding function visit(str: access Identity; i: access Introspector'Class) return Integer is begin return EnvironmentPackage.SUCCESS; end; ---------------------------------------------------------------------------- procedure makeIdentity(i : in out Identity) is begin initSubterm(i); end; function newIdentity return StrategyPtr is id : StrategyPtr := new Identity; begin makeIdentity(Identity(id.all)); return id; end; ---------------------------------------------------------------------------- end IdentityStrategy;
-------------------------------------------------------------------------- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with HAL.GPIO; with HAL.UART; with Cortex_M.NVIC; with RP2040_SVD.Interrupts; with RP.Device; with RP.Clock; with RP.GPIO; with RP.Timer; with RP.UART; with Pico; with Pico_UART_Interrupt_Handlers; procedure Pico_Interrupt_Main is Port : RP.UART.UART_Port renames RP.Device.UART_0; Config : constant RP.UART.UART_Configuration := (Loopback => False, Enable_FIFOs => False, others => <>); Status : HAL.UART.UART_Status; Data : HAL.UART.UART_Data_8b (1 .. 1) := (others => 16#55#); Delays : RP.Timer.Delays; use HAL; begin RP.Clock.Initialize (Pico.XOSC_Frequency); RP.Clock.Enable (RP.Clock.PERI); Pico.LED.Configure (RP.GPIO.Output); RP.Device.Timer.Enable; Port.Configure (Config); -- Port.Enable_IRQ (RP.UART.Transmit); Port.Enable_IRQ (RP.UART.Receive); Port.Clear_IRQ (RP.UART.Transmit); Port.Clear_IRQ (RP.UART.Receive); Cortex_M.NVIC.Clear_Pending (RP2040_SVD.Interrupts.UART0_Interrupt); Cortex_M.NVIC.Enable_Interrupt (RP2040_SVD.Interrupts.UART0_Interrupt); loop Port.Transmit (Data, Status); while not Pico_UART_Interrupt_Handlers.UART0_Data_Received loop null; end loop; Port.Receive (Data, Status); Data (1) := Data (1) + 1; end loop; Cortex_M.NVIC.Disable_Interrupt (RP2040_SVD.Interrupts.UART0_Interrupt); end Pico_Interrupt_Main;
with Animals.Humans; with Animals.Flying_Horses; use Animals; with Ada.Text_IO; use Ada.Text_IO; procedure Test_Humans_Horses is Rider : Humans.Human := Humans.Make ("Knight Rider", Humans.Male); Pegasus : Flying_Horses.Flying_Horse := Flying_Horses.Make (Flying_Horses.Snow_White); procedure Transform_Accordingly (O : in out Animal) is begin O.Add_Wings (2); O.Add_Legs (1); end Transform_Accordingly; procedure Transform_Accordingly_OK (O : in out Animal'Class) is begin O.Add_Wings (2); O.Add_Legs (1); end Transform_Accordingly_OK; NL : constant Character := Character'Val (10); begin Put_Line("Original Rider" & NL & Integer'Image (Rider.Wings) & " wings" & NL & Integer'Image (Rider.Legs) & " legs"); Put_Line("Original Pegasus" & NL & Integer'Image (Pegasus.Wings) & " wings" & NL & Integer'Image (Pegasus.Legs) & " legs"); -- This isn't what we want --Transform_Accordingly (Animal (Rider)); --Transform_Accordingly (Animal (Pegasus)); Transform_Accordingly_OK (Rider); Transform_Accordingly_OK (Pegasus); Put_Line("Trans Rider" & NL & Integer'Image (Rider.Wings) & " wings" & NL & Integer'Image (Rider.Legs) & " legs"); Put_Line("Trans Pegasus" & NL & Integer'Image (Pegasus.Wings) & " wings" & NL & Integer'Image (Pegasus.Legs) & " legs"); end Test_Humans_Horses;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Yaml.Dom.Dumping.Test; package body Yaml.Dumping_Tests.Suite is Result : aliased AUnit.Test_Suites.Test_Suite; Dom_Dumping_TC : aliased Dom.Dumping.Test.TC; function Suite return AUnit.Test_Suites.Access_Test_Suite is begin AUnit.Test_Suites.Add_Test (Result'Access, Dom_Dumping_TC'Access); return Result'Access; end Suite; end Yaml.Dumping_Tests.Suite;
----------------------------------------------------------------------- -- bean - A simple bean example -- Copyright (C) 2009, 2010 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with EL.Objects; with Util.Beans.Basic; with Util.Beans.Methods; with Ada.Strings.Unbounded; package Bean is use Ada.Strings.Unbounded; type Person is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with private; type Person_Access is access all Person'Class; function Create_Person (First_Name, Last_Name : String; Age : Natural) return Person_Access; -- Get the value identified by the name. function Get_Value (From : Person; Name : String) return EL.Objects.Object; -- Set the value identified by the name. procedure Set_Value (From : in out Person; Name : in String; Value : in EL.Objects.Object); -- This bean provides some methods that can be used in a Method_Expression overriding function Get_Method_Bindings (From : in Person) return Util.Beans.Methods.Method_Binding_Array_Access; -- function Save (P : in Person; Name : in Unbounded_String) return Unbounded_String; function Print (P : in Person; Title : in String) return String; function Compute (B : Util.Beans.Basic.Bean'Class; P1 : EL.Objects.Object) return EL.Objects.Object; -- Function to format a string function Format (Arg : EL.Objects.Object) return EL.Objects.Object; procedure Free (Object : in out Person_Access); private type Person is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record Last_Name : Unbounded_String; First_Name : Unbounded_String; Age : Natural; end record; end Bean;
with RTCH.Maths.Tuples; with RTCH.Maths.Points; package RTCH.Maths.Vectors with Preelaborate is subtype Vector is Tuples.Tuple; -- TODO - Make this a type? function Make_Vector (X, Y, Z : Float) return Vector is (Vector'(X => X, Y => Y, Z => Z, W => 0.0)); function "-" (Left, Right : in Points.Point) return Vector is (Vector'(X => Left.X - Right.X, Y => Left.Y - Right.Y, Z => Left.Z - Right.Z, W => Left.W - Right.W)); -- TODO - Ada 2022: Add with Static. function Magnitude (V : in Vector) return Float is (Sqrt (V.X ** 2 + V.Y ** 2 + V.Z ** 2 + V.W ** 2)); function Normalise (V : in Vector) return Vector; function Dot (V1, V2 : in Vector) return Float is (V1.X * V2.X + V1.Y * V2.Y + V1.Z * V2.Z + V1.W * V2.W); function Cross (A, B : in Vector) return Vector is (Make_Vector (X => A.Y * B.Z - A.Z * B.Y, Y => A.Z * B.X - A.X * B.Z, Z => A.X * B.Y - A.Y * B.X)); end RTCH.Maths.Vectors;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Containers.Hashed_Maps; with League.Strings.Hash; package body Incr.Ada_Lexers is package body Tables is separate; package Maps is new Ada.Containers.Hashed_Maps (Key_Type => League.Strings.Universal_String, Element_Type => Token, Hash => League.Strings.Hash, Equivalent_Keys => League.Strings."=", "=" => Lexers.Batch_Lexers."="); Default : constant Lexers.Batch_Lexers.State := 0; Apostrophe : constant Lexers.Batch_Lexers.State := 87; Map : Maps.Map; -- Our batch lexer return token codes in this order: Convert : constant array (Token range 1 .. 107) of Token := (Arrow_Token, Double_Dot_Token, Double_Star_Token, Assignment_Token, Inequality_Token, Greater_Or_Equal_Token, Less_Or_Equal_Token, Left_Label_Token, Right_Label_Token, Box_Token, Ampersand_Token, Apostrophe_Token, Left_Parenthesis_Token, Right_Parenthesis_Token, Star_Token, Plus_Token, Comma_Token, Hyphen_Token, Dot_Token, Slash_Token, Colon_Token, Semicolon_Token, Less_Token, Equal_Token, Greater_Token, Vertical_Line_Token, Identifier_Token, Numeric_Literal_Token, Character_Literal_Token, String_Literal_Token, Comment_Token, Space_Token, New_Line_Token, Error_Token, Abort_Token, Abs_Token, Abstract_Token, Accept_Token, Access_Token, Aliased_Token, All_Token, And_Token, Array_Token, At_Token, Begin_Token, Body_Token, Case_Token, Constant_Token, Declare_Token, Delay_Token, Delta_Token, Digits_Token, Do_Token, Else_Token, Elsif_Token, End_Token, Entry_Token, Exception_Token, Exit_Token, For_Token, Function_Token, Generic_Token, Goto_Token, If_Token, In_Token, Interface_Token, Is_Token, Limited_Token, Loop_Token, Mod_Token, New_Token, Not_Token, Null_Token, Of_Token, Or_Token, Others_Token, Out_Token, Overriding_Token, Package_Token, Pragma_Token, Private_Token, Procedure_Token, Protected_Token, Raise_Token, Range_Token, Record_Token, Rem_Token, Renames_Token, Requeue_Token, Return_Token, Reverse_Token, Select_Token, Separate_Token, Some_Token, Subtype_Token, Synchronized_Token, Tagged_Token, Task_Token, Terminate_Token, Then_Token, Type_Token, Until_Token, Use_Token, When_Token, While_Token, With_Token, Xor_Token); overriding procedure Get_Token (Self : access Batch_Lexer; Result : out Lexers.Batch_Lexers.Rule_Index) is use type Lexers.Batch_Lexers.Rule_Index; use type Lexers.Batch_Lexers.State; Start : constant Lexers.Batch_Lexers.State := Self.Get_Start_Condition; begin if Start = Apostrophe then Self.Set_Start_Condition (Default); end if; Base_Lexers.Batch_Lexer (Self.all).Get_Token (Result); if Result = 34 then Result := Vertical_Line_Token; elsif Result = 35 then Result := Numeric_Literal_Token; elsif Result = 36 then Result := String_Literal_Token; elsif Result > 36 then Result := Error_Token; elsif Result = 27 then declare Text : constant League.Strings.Universal_String := Self.Get_Text.To_Casefold; Cursor : constant Maps.Cursor := Map.Find (Text); begin if Maps.Has_Element (Cursor) then Result := Maps.Element (Cursor); if Start = Apostrophe and Result /= Range_Token then Result := Identifier_Token; end if; else Result := Identifier_Token; end if; end; elsif Result > 0 then Result := Convert (Result); end if; if Result = Apostrophe_Token then Self.Set_Start_Condition (Apostrophe); else Self.Set_Start_Condition (Default); end if; end Get_Token; function "+" (V : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; begin Map.Insert (+"abort", Abort_Token); Map.Insert (+"abs", Abs_Token); Map.Insert (+"abstract", Abstract_Token); Map.Insert (+"accept", Accept_Token); Map.Insert (+"access", Access_Token); Map.Insert (+"aliased", Aliased_Token); Map.Insert (+"all", All_Token); Map.Insert (+"and", And_Token); Map.Insert (+"array", Array_Token); Map.Insert (+"at", At_Token); Map.Insert (+"begin", Begin_Token); Map.Insert (+"body", Body_Token); Map.Insert (+"case", Case_Token); Map.Insert (+"constant", Constant_Token); Map.Insert (+"declare", Declare_Token); Map.Insert (+"delay", Delay_Token); Map.Insert (+"delta", Delta_Token); Map.Insert (+"digits", Digits_Token); Map.Insert (+"do", Do_Token); Map.Insert (+"else", Else_Token); Map.Insert (+"elsif", Elsif_Token); Map.Insert (+"end", End_Token); Map.Insert (+"entry", Entry_Token); Map.Insert (+"exception", Exception_Token); Map.Insert (+"exit", Exit_Token); Map.Insert (+"for", For_Token); Map.Insert (+"function", Function_Token); Map.Insert (+"generic", Generic_Token); Map.Insert (+"goto", Goto_Token); Map.Insert (+"if", If_Token); Map.Insert (+"in", In_Token); Map.Insert (+"interface", Interface_Token); Map.Insert (+"is", Is_Token); Map.Insert (+"limited", Limited_Token); Map.Insert (+"loop", Loop_Token); Map.Insert (+"mod", Mod_Token); Map.Insert (+"new", New_Token); Map.Insert (+"not", Not_Token); Map.Insert (+"null", Null_Token); Map.Insert (+"of", Of_Token); Map.Insert (+"or", Or_Token); Map.Insert (+"others", Others_Token); Map.Insert (+"out", Out_Token); Map.Insert (+"overriding", Overriding_Token); Map.Insert (+"package", Package_Token); Map.Insert (+"pragma", Pragma_Token); Map.Insert (+"private", Private_Token); Map.Insert (+"procedure", Procedure_Token); Map.Insert (+"protected", Protected_Token); Map.Insert (+"raise", Raise_Token); Map.Insert (+"range", Range_Token); Map.Insert (+"record", Record_Token); Map.Insert (+"rem", Rem_Token); Map.Insert (+"renames", Renames_Token); Map.Insert (+"requeue", Requeue_Token); Map.Insert (+"return", Return_Token); Map.Insert (+"reverse", Reverse_Token); Map.Insert (+"select", Select_Token); Map.Insert (+"separate", Separate_Token); Map.Insert (+"some", Some_Token); Map.Insert (+"subtype", Subtype_Token); Map.Insert (+"synchronized", Synchronized_Token); Map.Insert (+"tagged", Tagged_Token); Map.Insert (+"task", Task_Token); Map.Insert (+"terminate", Terminate_Token); Map.Insert (+"then", Then_Token); Map.Insert (+"type", Type_Token); Map.Insert (+"until", Until_Token); Map.Insert (+"use", Use_Token); Map.Insert (+"when", When_Token); Map.Insert (+"while", While_Token); Map.Insert (+"with", With_Token); Map.Insert (+"xor", Xor_Token); end Incr.Ada_Lexers;
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -- -- SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from rp2040.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package RP_SVD.PLL_SYS is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CS_REFDIV_Field is HAL.UInt6; -- Control and Status\n GENERAL CONSTRAINTS:\n Reference clock frequency -- min=5MHz, max=800MHz\n Feedback divider min=16, max=320\n VCO frequency -- min=400MHz, max=1600MHz type CS_Register is record -- Divides the PLL input reference clock.\n Behaviour is undefined for -- div=0.\n PLL output will be unpredictable during refdiv changes, wait -- for lock=1 before using it. REFDIV : CS_REFDIV_Field := 16#1#; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- Passes the reference clock to the output instead of the divided VCO. -- The VCO continues to run so the user can switch between the reference -- clock and the divided VCO but the output will glitch when doing so. BYPASS : Boolean := False; -- unspecified Reserved_9_30 : HAL.UInt22 := 16#0#; -- Read-only. PLL is locked LOCK : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CS_Register use record REFDIV at 0 range 0 .. 5; Reserved_6_7 at 0 range 6 .. 7; BYPASS at 0 range 8 .. 8; Reserved_9_30 at 0 range 9 .. 30; LOCK at 0 range 31 .. 31; end record; -- Controls the PLL power modes. type PWR_Register is record -- PLL powerdown\n To save power set high when PLL output not required. PD : Boolean := True; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- PLL DSM powerdown\n Nothing is achieved by setting this low. DSMPD : Boolean := True; -- PLL post divider powerdown\n To save power set high when PLL output -- not required or bypass=1. POSTDIVPD : Boolean := True; -- unspecified Reserved_4_4 : HAL.Bit := 16#0#; -- PLL VCO powerdown\n To save power set high when PLL output not -- required or bypass=1. VCOPD : Boolean := True; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PWR_Register use record PD at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DSMPD at 0 range 2 .. 2; POSTDIVPD at 0 range 3 .. 3; Reserved_4_4 at 0 range 4 .. 4; VCOPD at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; subtype FBDIV_INT_FBDIV_INT_Field is HAL.UInt12; -- Feedback divisor\n (note: this PLL does not support fractional division) type FBDIV_INT_Register is record -- see ctrl reg description for constraints FBDIV_INT : FBDIV_INT_FBDIV_INT_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 FBDIV_INT_Register use record FBDIV_INT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype PRIM_POSTDIV2_Field is HAL.UInt3; subtype PRIM_POSTDIV1_Field is HAL.UInt3; -- Controls the PLL post dividers for the primary output\n (note: this PLL -- does not have a secondary output)\n the primary output is driven from -- VCO divided by postdiv1*postdiv2 type PRIM_Register is record -- unspecified Reserved_0_11 : HAL.UInt12 := 16#0#; -- divide by 1-7 POSTDIV2 : PRIM_POSTDIV2_Field := 16#7#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- divide by 1-7 POSTDIV1 : PRIM_POSTDIV1_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 PRIM_Register use record Reserved_0_11 at 0 range 0 .. 11; POSTDIV2 at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; POSTDIV1 at 0 range 16 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ----------------- -- Peripherals -- ----------------- type PLL_SYS_Peripheral is record -- Control and Status\n GENERAL CONSTRAINTS:\n Reference clock frequency -- min=5MHz, max=800MHz\n Feedback divider min=16, max=320\n VCO -- frequency min=400MHz, max=1600MHz CS : aliased CS_Register; -- Controls the PLL power modes. PWR : aliased PWR_Register; -- Feedback divisor\n (note: this PLL does not support fractional -- division) FBDIV_INT : aliased FBDIV_INT_Register; -- Controls the PLL post dividers for the primary output\n (note: this -- PLL does not have a secondary output)\n the primary output is driven -- from VCO divided by postdiv1*postdiv2 PRIM : aliased PRIM_Register; end record with Volatile; for PLL_SYS_Peripheral use record CS at 16#0# range 0 .. 31; PWR at 16#4# range 0 .. 31; FBDIV_INT at 16#8# range 0 .. 31; PRIM at 16#C# range 0 .. 31; end record; PLL_SYS_Periph : aliased PLL_SYS_Peripheral with Import, Address => PLL_SYS_Base; end RP_SVD.PLL_SYS;
----------------------------------------------------------------------- -- awa-modules-beans -- Module beans factory -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body AWA.Modules.Beans is -- Register under the given name a function to create the bean instance when -- it is accessed for a first time. The scope defines the scope of the bean. -- bean procedure Register (Plugin : in out Module'Class; Name : in String; Handler : in Create_Bean_Access) is Binding : constant Module_Binding_Access := new Module_Binding; begin Binding.Module := Plugin'Unchecked_Access; Binding.Create := Handler; Plugin.Register (Name, Binding.all'Access); end Register; -- ------------------------------ -- Binding record -- ------------------------------ -- procedure Create (Factory : in Module_Binding; Name : in Ada.Strings.Unbounded.Unbounded_String; Result : out Util.Beans.Basic.Readonly_Bean_Access) is pragma Unreferenced (Name); begin Result := Factory.Create.all (Factory.Module); end Create; end AWA.Modules.Beans;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Compilation_Units; with Program.Visibility; with Program.Elements.Defining_Names; with Program.Symbols; private package Program.Resolvers is pragma Preelaborate; procedure Resolve_Names (Env : aliased in out Program.Visibility.Context; Unit : not null Program.Compilation_Units.Compilation_Unit_Access); function To_Symbol (Name : access Program.Elements.Defining_Names.Defining_Name'Class) return Program.Symbols.Symbol; -- Return a symbol for given defining name. Return symbol of the -- selector for expanded defining name. end Program.Resolvers;
with any_Math.any_Algebra.any_Linear; package float_Math.Algebra.linear is new float_Math.Algebra.any_linear; pragma Pure (float_Math.Algebra.linear);
-- ----------------------------------------------------------------- -- -- AdaSDL -- -- Binding to Simple Direct Media Layer -- -- Copyright (C) 2001 A.M.F.Vargas -- -- Antonio M. F. Vargas -- -- Ponta Delgada - Azores - Portugal -- -- http://www.adapower.net/~avargas -- -- E-mail: avargas@adapower.net -- -- ----------------------------------------------------------------- -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- -- ----------------------------------------------------------------- -- -- **************************************************************** -- -- This is an Ada binding to SDL ( Simple DirectMedia Layer from -- -- Sam Lantinga - www.libsld.org ) -- -- **************************************************************** -- -- In order to help the Ada programmer, the comments in this file -- -- are, in great extent, a direct copy of the original text in the -- -- SDL header files. -- -- **************************************************************** -- with SDL.Types; use SDL.Types; with SDL.Keysym; -- use SDL.Keysym; with Interfaces.C.Strings; package SDL.Keyboard is package Ks renames SDL.Keysym; package C renames Interfaces.C; -- Keysym structure -- - The scancode is hardware dependent, and should not be used by general -- applications. If no hardware scancode is available, it will be 0. -- -- - The 'unicode' translated character is only available when character -- translation is enabled by the EnableUNICODE API. If non-zero, -- this is a UNICODE character corresponding to the keypress. If the -- high 9 bits of the character are 0, then this maps to the equivalent -- ASCII character: -- ch : Character; -- if (keysym.unicode and 0xFF80) = 0 then -- ch := keysym.unicode and 0x7F; -- else -- An international character.. -- end if; -- type keysym is record scancode : Uint8; sym : Ks.Key; the_mod : Ks.SDLMod; unicode : Uint16; end record; for keysym'Size use 8*16; -- A practical adjust pragma Convention (C, keysym); type keysym_ptr is access all keysym; pragma Convention (C, keysym_ptr); type keysym_Const_ptr is access constant keysym; pragma Convention (C, keysym_Const_ptr); -- This is the mask which refers to all hotkey bindings SDL_ALL_HOTKEYS : constant Ks.SDLMod := 16#FFFFFFFF#; -- --------------------- -- -- Function prototypes -- -- --------------------- -- -- Enable/Disable UNICODE translation of keyboard input. -- This translation has some overhead, so translation defaults off. -- If 'enable' is 1, translation is enabled. -- If 'enable' is 0, translation is disabled. -- If 'enable' is -1, the translation state is not changed. -- It returns the previous state of keyboard translation. function EnableUNICODE (enable : C.int) return C.int; procedure EnableUNICODE (enable : C.int); pragma Import (C, EnableUNICODE, "SDL_EnableUNICODE"); -- Enable/Disable keyboard repeat. Keyboard repeat defaults to off. -- 'delay' is the initial delay in ms between the time when a key is -- pressed, and keyboard repeat begins. -- 'interval' is the time in ms between keyboard repeat events. DEFAULT_REPEAT_DELAY : constant := 500; DEFAULT_REPEAT_INTERVAL : constant := 30; -- If 'delay' is set to 0, keyboard repeat is disabled. function EnableKeyRepeat ( the_delay : C.int; interval : C.int) return C.int; procedure EnableKeyRepeat ( the_delay : C.int; interval : C.int); pragma Import (C, EnableKeyRepeat, "SDL_EnableKeyRepeat"); -- Get a snapshot of the current state of the keyboard. -- Returns an array of keystates, indexed by the K_* syms. -- Used: -- keystates = GetKeyState(NULL); -- if keystates(K_RETURN) ... <RETURN> is pressed. type KeyStates_Array is array (Ks.Key range Ks.K_FIRST .. Ks.K_LAST) of Uint8; pragma Convention (C, KeyStates_Array); function GetKeyState (numkeys : int_ptr) return Uint8_ptr; pragma Import (C, GetKeyState, "SDL_GetKeyState"); -- This function is not part of the original SDL API function Is_Key_Pressed (ref_Keys : Uint8_ptr; The_Key : Ks.Key) return Boolean; pragma Inline (Is_Key_Pressed); -- Get the current key modifier state function GetModState return Ks.SDLMod; pragma Import (C, GetModState, "SDL_GetModState"); -- Set the current key modifier state -- This does not change the keyboard state, only the key modifier flags. procedure SetModState (modstate : Ks.SDLMod); pragma Import (C, SetModState, "SDL_SetModState"); -- Get the name of an SDL virtual keysym function GetKeyName (the_key : Ks.Key) return C.Strings.chars_ptr; pragma Import (C, GetKeyName, "SDL_GetKeyName"); end SDL.Keyboard;
-- The Village of Vampire by YT, このソースコードはNYSLです function Tabula.Casts.Load (Name : String) return Cast_Collection;
----------------------------------------------------------------------- -- awa-wikis-modules-tests -- Unit tests for wikis service -- Copyright (C) 2015, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Strings; with ASF.Tests; with ASF.Requests.Mockup; with ASF.Responses.Mockup; with AWA.Tests.Helpers; with AWA.Tests.Helpers.Users; with AWA.Services.Contexts; with Security.Contexts; package body AWA.Wikis.Modules.Tests is use ASF.Tests; use Util.Tests; package Caller is new Util.Test_Caller (Test, "Wikis.Modules"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Wikis.Modules.Create_Wiki_Space", Test_Create_Wiki_Space'Access); Caller.Add_Test (Suite, "Test AWA.Wikis.Modules.Create_Wiki_Page", Test_Create_Wiki_Page'Access); Caller.Add_Test (Suite, "Test AWA.Wikis.Modules.Create_Wiki_Content", Test_Create_Wiki_Content'Access); Caller.Add_Test (Suite, "Test AWA.Wikis.Modules.Wiki_Page", Test_Wiki_Page'Access); Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Save", Test_Update_Page'Access); end Add_Tests; -- ------------------------------ -- Test creation of a wiki space. -- ------------------------------ procedure Test_Create_Wiki_Space (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; W : AWA.Wikis.Models.Wiki_Space_Ref; W2 : AWA.Wikis.Models.Wiki_Space_Ref; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-wiki@test.com"); T.Manager := AWA.Wikis.Modules.Get_Wiki_Module; T.Assert (T.Manager /= null, "There is no wiki manager"); W.Set_Name ("Test wiki space"); T.Manager.Create_Wiki_Space (W); T.Assert (W.Is_Inserted, "The new wiki space was not created"); W.Set_Name ("Test wiki space update"); W.Set_Is_Public (True); T.Manager.Save_Wiki_Space (W); T.Manager.Load_Wiki_Space (Wiki => W2, Id => W.Get_Id); Util.Tests.Assert_Equals (T, "Test wiki space update", String '(W2.Get_Name), "Invalid wiki space name"); end Test_Create_Wiki_Space; -- ------------------------------ -- Test creation of a wiki page. -- ------------------------------ procedure Test_Create_Wiki_Page (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; W : AWA.Wikis.Models.Wiki_Space_Ref; P : AWA.Wikis.Models.Wiki_Page_Ref; C : AWA.Wikis.Models.Wiki_Content_Ref; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-wiki@test.com"); W.Set_Name ("Test wiki space"); T.Manager.Create_Wiki_Space (W); P.Set_Name ("Private"); P.Set_Title ("The page title"); T.Manager.Create_Wiki_Page (W, P, C); T.Assert (P.Is_Inserted, "The new wiki page was not created"); C := AWA.Wikis.Models.Null_Wiki_Content; P := AWA.Wikis.Models.Null_Wiki_Page; P.Set_Name ("Public"); P.Set_Title ("The page title (public)"); P.Set_Is_Public (True); T.Manager.Create_Wiki_Page (W, P, C); T.Assert (P.Is_Inserted, "The new wiki page was not created"); T.Assert (P.Get_Is_Public, "The new wiki page is not public"); end Test_Create_Wiki_Page; -- ------------------------------ -- Test creation of a wiki page content. -- ------------------------------ procedure Test_Create_Wiki_Content (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; W : AWA.Wikis.Models.Wiki_Space_Ref; P : AWA.Wikis.Models.Wiki_Page_Ref; C : AWA.Wikis.Models.Wiki_Content_Ref; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-wiki@test.com"); W.Set_Name ("Test wiki space"); T.Manager.Create_Wiki_Space (W); T.Wiki_Id := W.Get_Id; P.Set_Name ("PrivatePage"); P.Set_Title ("The page title"); P.Set_Is_Public (False); T.Manager.Create_Wiki_Page (W, P, C); T.Private_Id := P.Get_Id; C := AWA.Wikis.Models.Null_Wiki_Content; C.Set_Format (AWA.Wikis.Models.FORMAT_MARKDOWN); C.Set_Content ("-- Title" & ASCII.LF & "A paragraph"); C.Set_Save_Comment ("A first version"); T.Manager.Create_Wiki_Content (P, C); T.Assert (C.Is_Inserted, "The new wiki content was not created"); T.Assert (not C.Get_Author.Is_Null, "The wiki content has an author"); T.Assert (not C.Get_Page.Is_Null, "The wiki content is associated with the wiki page"); P := AWA.Wikis.Models.Null_Wiki_Page; C := AWA.Wikis.Models.Null_Wiki_Content; P.Set_Name ("PublicPage"); P.Set_Title ("The public page title"); P.Set_Is_Public (True); T.Manager.Create_Wiki_Page (W, P, C); T.Public_Id := P.Get_Id; C.Set_Format (AWA.Wikis.Models.FORMAT_MARKDOWN); C.Set_Content ("-- Title" & ASCII.LF & "A paragraph" & ASCII.LF & "[Link](http://mylink.com)" & ASCII.LF & "[Image](my-image.png)"); C.Set_Save_Comment ("A first version"); T.Manager.Create_Wiki_Content (P, C); T.Assert (C.Is_Inserted, "The new wiki content was not created"); T.Assert (not C.Get_Author.Is_Null, "The wiki content has an author"); T.Assert (not C.Get_Page.Is_Null, "The wiki content is associated with the wiki page"); end Test_Create_Wiki_Content; -- ------------------------------ -- Test getting the wiki page as well as info, history pages. -- ------------------------------ procedure Test_Wiki_Page (T : in out Test) is Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; Ident : constant String := Util.Strings.Image (Natural (T.Wiki_Id)); Pub_Ident : constant String := Util.Strings.Image (Natural (T.Public_Id)); begin ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Ident & "/PublicPage", "wiki-public-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (PublicPage)"); Assert_Matches (T, ".*The public page title.*", Reply, "Invalid PublicPage page returned", Status => ASF.Responses.SC_OK); ASF.Tests.Do_Get (Request, Reply, "/wikis/info/" & Ident & "/" & Pub_Ident, "wiki-public-info-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (PublicPage info)"); Assert_Matches (T, ".*The public page title.*", Reply, "Invalid PublicPage info page returned", Status => ASF.Responses.SC_OK); ASF.Tests.Do_Get (Request, Reply, "/wikis/history/" & Ident & "/" & Pub_Ident, "wiki-public-history-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (PublicPage history)"); Assert_Matches (T, ".*The public page title.*", Reply, "Invalid PublicPage info page returned", Status => ASF.Responses.SC_OK); Request.Remove_Attribute ("wikiView"); ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Ident & "/PrivatePage", "wiki-private-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (PrivatePage)"); Assert_Matches (T, ".*Protected Wiki Page.*", Reply, "Invalid PrivatePage page returned", Status => ASF.Responses.SC_OK); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Ident & "/recent", "wiki-list-recent-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (list/recent)"); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Ident & "/recent/grid", "wiki-list-grid-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (list/recent/grid)"); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Ident & "/popular", "wiki-list-popular-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (list/popular)"); ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Ident & "/popular/grid", "wiki-list-popular-1.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (list/popular/grid)"); end Test_Wiki_Page; -- ------------------------------ -- Test updating the wiki page through a POST request. -- ------------------------------ procedure Test_Update_Page (T : in out Test) is Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; Ident : constant String := Util.Strings.Image (Natural (T.Wiki_Id)); Pub_Ident : constant String := Util.Strings.Image (Natural (T.Public_Id)); begin AWA.Tests.Helpers.Users.Login ("test-wiki@test.com", Request); Request.Set_Parameter ("title", "The Blog Title"); Request.Set_Parameter ("page-id", Pub_Ident); Request.Set_Parameter ("page-wiki-id", Ident); Request.Set_Parameter ("name", "NewPageName"); Request.Set_Parameter ("page-title", "New Page Title"); Request.Set_Parameter ("text", "== Title ==" & ASCII.LF & "A paragraph" & ASCII.LF & "[[http://mylink.com|Link]]" & ASCII.LF & "[[Image:my-image.png|My Picture]]" & ASCII.LF & "== Last header ==" & ASCII.LF); Request.Set_Parameter ("comment", "Update through test post simulation"); Request.Set_Parameter ("page-is-public", "TRUE"); Request.Set_Parameter ("wiki-format", "FORMAT_MEDIAWIKI"); Request.Set_Parameter ("qtags[1]", "Test-Tag"); Request.Set_Parameter ("save", "1"); Request.Set_Parameter ("post", "1"); ASF.Tests.Do_Post (Request, Reply, "/wikis/edit/" & Ident & "/PublicPage", "update-wiki.html"); T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY, "Invalid response after wiki update"); declare Result : constant String := AWA.Tests.Helpers.Extract_Redirect (Reply, "/asfunit/wikis/view/"); begin Util.Tests.Assert_Equals (T, Ident & "/NewPageName", Result, "The page name was not updated"); ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Result, "wiki-public-2.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (NewPageName)"); Assert_Matches (T, ".*Last header.*", Reply, "Last header is present in the response", Status => ASF.Responses.SC_OK); ASF.Tests.Do_Get (Request, Reply, "/wikis/info/" & Ident & "/" & Pub_Ident, "wiki-info-2.html"); Assert_Equals (T, ASF.Responses.SC_OK, Reply.Get_Status, "Invalid response (info NewPageName)"); Assert_Matches (T, ".*wiki-image-name.*my-image.png.*", Reply, "The info page must list the image", Status => ASF.Responses.SC_OK); end; end Test_Update_Page; end AWA.Wikis.Modules.Tests;
-- //////////////////////////////////////////////////////////// -- // -- // SFML - Simple and Fast Multimedia Library -- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -- // -- // This software is provided 'as-is', without any express or implied warranty. -- // In no event will the authors be held liable for any damages arising from the use of this software. -- // -- // Permission is granted to anyone to use this software for any purpose, -- // including commercial applications, and to alter it and redistribute it freely, -- // subject to the following restrictions: -- // -- // 1. The origin of this software must not be misrepresented; -- // you must not claim that you wrote the original software. -- // If you use this software in a product, an acknowledgment -- // in the product documentation would be appreciated but is not required. -- // -- // 2. Altered source versions must be plainly marked as such, -- // and must not be misrepresented as being the original software. -- // -- // 3. This notice may not be removed or altered from any source distribution. -- // -- //////////////////////////////////////////////////////////// -- //////////////////////////////////////////////////////////// -- // Headers -- //////////////////////////////////////////////////////////// with Sf.Config; with Sf.Graphics.BlendMode; with Sf.Graphics.Color; with Sf.Graphics.Rect; with Sf.Graphics.Types; package Sf.Graphics.String is use Sf.Config; use Sf.Graphics.BlendMode; use Sf.Graphics.Color; use Sf.Graphics.Rect; use Sf.Graphics.Types; -- //////////////////////////////////////////////////////////// -- /// sfString styles -- //////////////////////////////////////////////////////////// subtype sfStringStyle is sfUint32; sfStringRegular : constant sfStringStyle := 0; sfStringBold : constant sfStringStyle := 1; sfStringItalic : constant sfStringStyle := 2; sfStringUnderlined : constant sfStringStyle := 4; -- //////////////////////////////////////////////////////////// -- /// Create a new string -- /// -- /// \return A new sfString object, or NULL if it failed -- /// -- //////////////////////////////////////////////////////////// function sfString_Create return sfString_Ptr; -- //////////////////////////////////////////////////////////// -- /// Destroy an existing string -- /// -- /// \param String : String to delete -- /// -- //////////////////////////////////////////////////////////// procedure sfString_Destroy (Str : sfString_Ptr); -- //////////////////////////////////////////////////////////// -- /// Set the X position of a string -- /// -- /// \param String : String to modify -- /// \param X : New X coordinate -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetX (Str : sfString_Ptr; X : Float); -- //////////////////////////////////////////////////////////// -- /// Set the Y position of a string -- /// -- /// \param String : String to modify -- /// \param Y : New Y coordinate -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetY (Str : sfString_Ptr; Y : Float); -- //////////////////////////////////////////////////////////// -- /// Set the position of a string -- /// -- /// \param String : String to modify -- /// \param Left : New left coordinate -- /// \param Top : New top coordinate -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetPosition (Str : sfString_Ptr; Left, Top : Float); -- //////////////////////////////////////////////////////////// -- /// Set the horizontal scale of a string -- /// -- /// \param String : String to modify -- /// \param Scale : New scale (must be strictly positive) -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetScaleX (Str : sfString_Ptr; Scale : Float); -- //////////////////////////////////////////////////////////// -- /// Set the vertical scale of a string -- /// -- /// \param String : String to modify -- /// \param Scale : New scale (must be strictly positive) -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetScaleY (Str : sfString_Ptr; Scale : Float); -- //////////////////////////////////////////////////////////// -- /// Set the scale of a string -- /// -- /// \param String : String to modify -- /// \param ScaleX : New horizontal scale (must be strictly positive) -- /// \param ScaleY : New vertical scale (must be strictly positive) -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetScale (Str : sfString_Ptr; ScaleX, ScaleY : Float); -- //////////////////////////////////////////////////////////// -- /// Set the orientation of a string -- /// -- /// \param String : String to modify -- /// \param Rotation : Angle of rotation, in degrees -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetRotation (Str : sfString_Ptr; Rotation : Float); -- //////////////////////////////////////////////////////////// -- /// Set the center of a string, in coordinates -- /// relative to its left-top corner -- /// -- /// \param String : String to modify -- /// \param X : X coordinate of the center -- /// \param Y : Y coordinate of the center -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetCenter (Str : sfString_Ptr; X, Y : Float); -- //////////////////////////////////////////////////////////// -- /// Set the color of a string -- /// -- /// \param String : String to modify -- /// \param Color : New color -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetColor (Str : sfString_Ptr; Color : sfColor); -- //////////////////////////////////////////////////////////// -- /// Set the blending mode for a string -- /// -- /// \param String : String to modify -- /// \param Mode : New blending mode -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetBlendMode (Str : sfString_Ptr; Mode : sfBlendMode); -- //////////////////////////////////////////////////////////// -- /// Get the X position of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current X position -- /// -- //////////////////////////////////////////////////////////// function sfString_GetX (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the top Y of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current Y position -- /// -- //////////////////////////////////////////////////////////// function sfString_GetY (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the horizontal scale of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current X scale factor (always positive) -- /// -- //////////////////////////////////////////////////////////// function sfString_GetScaleX (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the vertical scale of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current Y scale factor (always positive) -- /// -- //////////////////////////////////////////////////////////// function sfString_GetScaleY (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the orientation of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current rotation, in degrees -- /// -- //////////////////////////////////////////////////////////// function sfString_GetRotation (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the X position of the center a string -- /// -- /// \param String : String to read -- /// -- /// \return Current X center position -- /// -- //////////////////////////////////////////////////////////// function sfString_GetCenterX (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the top Y of the center of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current Y center position -- /// -- //////////////////////////////////////////////////////////// function sfString_GetCenterY (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the color of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current color -- /// -- //////////////////////////////////////////////////////////// function sfString_GetColor (Str : sfString_Ptr) return sfColor; -- //////////////////////////////////////////////////////////// -- /// Get the current blending mode of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current blending mode -- /// -- //////////////////////////////////////////////////////////// function sfString_GetBlendMode (Str : sfString_Ptr) return sfBlendMode; -- //////////////////////////////////////////////////////////// -- /// Move a string -- /// -- /// \param String : String to modify -- /// \param OffsetX : Offset on the X axis -- /// \param OffsetY : Offset on the Y axis -- /// -- //////////////////////////////////////////////////////////// procedure sfString_Move (Str : sfString_Ptr; OffsetX, OffsetY : Float); -- //////////////////////////////////////////////////////////// -- /// Scale a string -- /// -- /// \param String : String to modify -- /// \param FactorX : Horizontal scaling factor (must be strictly positive) -- /// \param FactorY : Vertical scaling factor (must be strictly positive) -- /// -- //////////////////////////////////////////////////////////// procedure sfString_Scale (Str : sfString_Ptr; FactorX, FactorY : Float); -- //////////////////////////////////////////////////////////// -- /// Rotate a string -- /// -- /// \param String : String to modify -- /// \param Angle : Angle of rotation, in degrees -- /// -- //////////////////////////////////////////////////////////// procedure sfString_Rotate (Str : sfString_Ptr; Angle : Float); -- //////////////////////////////////////////////////////////// -- /// Transform a point from global coordinates into the string's local coordinates -- /// (ie it applies the inverse of object's center, translation, rotation and scale to the point) -- /// -- /// \param String : String object -- /// \param PointX : X coordinate of the point to transform -- /// \param PointY : Y coordinate of the point to transform -- /// \param X : Value to fill with the X coordinate of the converted point -- /// \param Y : Value to fill with the y coordinate of the converted point -- /// -- //////////////////////////////////////////////////////////// procedure sfString_TransformToLocal (Str : sfString_Ptr; PointX, PointY : Float; X, Y : access Float); -- //////////////////////////////////////////////////////////// -- /// Transform a point from the string's local coordinates into global coordinates -- /// (ie it applies the object's center, translation, rotation and scale to the point) -- /// -- /// \param String : String object -- /// \param PointX : X coordinate of the point to transform -- /// \param PointY : Y coordinate of the point to transform -- /// \param X : Value to fill with the X coordinate of the converted point -- /// \param Y : Value to fill with the y coordinate of the converted point -- /// -- //////////////////////////////////////////////////////////// procedure sfString_TransformToGlobal (Str : sfString_Ptr; PointX, PointY : Float; X, Y : access Float); -- //////////////////////////////////////////////////////////// -- /// Set the text of a string (from a multibyte string) -- /// -- /// \param String : String to modify -- /// \param Text : New text -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetText (Str : sfString_Ptr; Text : Standard.String); -- //////////////////////////////////////////////////////////// -- /// Set the text of a string (from a unicode string) -- /// -- /// \param String : String to modify -- /// \param Text : New text -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetUnicodeText (Str : sfString_Ptr; Text : sfUint32_Ptr); -- //////////////////////////////////////////////////////////// -- /// Set the font of a string -- /// -- /// \param String : String to modify -- /// \param Font : Font to use -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetFont (Str : sfString_Ptr; Font : sfFont_Ptr); -- //////////////////////////////////////////////////////////// -- /// Set the size of a string -- /// -- /// \param String : String to modify -- /// \param Size : New size, in pixels -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetSize (Str : sfString_Ptr; Size : Float); -- //////////////////////////////////////////////////////////// -- /// Set the style of a string -- /// -- /// \param String : String to modify -- /// \param Size : New style (see sfStringStyle enum) -- /// -- //////////////////////////////////////////////////////////// procedure sfString_SetStyle (Str : sfString_Ptr; Style : sfStringStyle); -- //////////////////////////////////////////////////////////// -- /// Get the text of a string (returns a unicode string) -- /// -- /// \param String : String to read -- /// -- /// \return Text as UTF-32 -- /// -- //////////////////////////////////////////////////////////// function sfString_GetUnicodeText (Str : sfString_Ptr) return sfUint32_Ptr; -- //////////////////////////////////////////////////////////// -- /// Get the text of a string (returns an ANSI string) -- /// -- /// \param String : String to read -- /// -- /// \return Text an a locale-dependant ANSI string -- /// -- //////////////////////////////////////////////////////////// function sfString_GetText (Str : sfString_Ptr) return Standard.String; -- //////////////////////////////////////////////////////////// -- /// Get the font used by a string -- /// -- /// \param String : String to read -- /// -- /// \return Pointer to the font -- /// -- //////////////////////////////////////////////////////////// function sfString_GetFont (Str : sfString_Ptr) return sfFont_Ptr; -- //////////////////////////////////////////////////////////// -- /// Get the size of the characters of a string -- /// -- /// \param String : String to read -- /// -- /// \return Size of the characters -- /// -- //////////////////////////////////////////////////////////// function sfString_GetSize (Str : sfString_Ptr) return Float; -- //////////////////////////////////////////////////////////// -- /// Get the style of a string -- /// -- /// \param String : String to read -- /// -- /// \return Current string style (see sfStringStyle enum) -- /// -- //////////////////////////////////////////////////////////// function sfString_GetStyle (Str : sfString_Ptr) return sfStringStyle; -- //////////////////////////////////////////////////////////// -- /// Return the visual position of the Index-th character of the string, -- /// in coordinates relative to the string -- /// (note : translation, center, rotation and scale are not applied) -- /// -- /// \param String : String to read -- /// \param Index : Index of the character -- /// \param X : Value to fill with the X coordinate of the position -- /// \param Y : Value to fill with the y coordinate of the position -- /// -- //////////////////////////////////////////////////////////// procedure sfString_GetCharacterPos (Str : sfString_Ptr; Index : sfSize_t; X, Y : access Float); -- //////////////////////////////////////////////////////////// -- /// Get the bounding rectangle of a string on screen -- /// -- /// \param String : String to read -- /// -- /// \return Rectangle contaning the string in screen coordinates -- /// -- //////////////////////////////////////////////////////////// function sfString_GetRect (Str : sfString_Ptr) return sfFloatRect; private pragma Import (C, sfString_Create, "sfString_Create"); pragma Import (C, sfString_Destroy, "sfString_Destroy"); pragma Import (C, sfString_SetX, "sfString_SetX"); pragma Import (C, sfString_SetY, "sfString_SetY"); pragma Import (C, sfString_SetPosition, "sfString_SetPosition"); pragma Import (C, sfString_SetScaleX, "sfString_SetScaleX"); pragma Import (C, sfString_SetScaleY, "sfString_SetScaleY"); pragma Import (C, sfString_SetScale, "sfString_SetScale"); pragma Import (C, sfString_SetRotation, "sfString_SetRotation"); pragma Import (C, sfString_SetCenter, "sfString_SetCenter"); pragma Import (C, sfString_SetColor, "sfString_SetColor"); pragma Import (C, sfString_SetBlendMode, "sfString_SetBlendMode"); pragma Import (C, sfString_GetX, "sfString_GetX"); pragma Import (C, sfString_GetY, "sfString_GetY"); pragma Import (C, sfString_GetScaleX, "sfString_GetScaleX"); pragma Import (C, sfString_GetScaleY, "sfString_GetScaleY"); pragma Import (C, sfString_GetRotation, "sfString_GetRotation"); pragma Import (C, sfString_GetCenterX, "sfString_GetCenterX"); pragma Import (C, sfString_GetCenterY, "sfString_GetCenterY"); pragma Import (C, sfString_GetColor, "sfString_GetColor"); pragma Import (C, sfString_GetBlendMode, "sfString_GetBlendMode"); pragma Import (C, sfString_Move, "sfString_Move"); pragma Import (C, sfString_Scale, "sfString_Scale"); pragma Import (C, sfString_Rotate, "sfString_Rotate"); pragma Import (C, sfString_TransformToLocal, "sfString_TransformToLocal"); pragma Import (C, sfString_TransformToGlobal, "sfString_TransformToGlobal"); pragma Import (C, sfString_SetUnicodeText, "sfString_SetUnicodeText"); pragma Import (C, sfString_SetFont, "sfString_SetFont"); pragma Import (C, sfString_SetSize, "sfString_SetSize"); pragma Import (C, sfString_SetStyle, "sfString_SetStyle"); pragma Import (C, sfString_GetUnicodeText, "sfString_GetUnicodeText"); pragma Import (C, sfString_GetFont, "sfString_GetFont"); pragma Import (C, sfString_GetSize, "sfString_GetSize"); pragma Import (C, sfString_GetStyle, "sfString_GetStyle"); pragma Import (C, sfString_GetCharacterPos, "sfString_GetCharacterPos"); pragma Import (C, sfString_GetRect, "sfString_GetRect"); end Sf.Graphics.String;
package Discr15_Pkg is type Moment is new Positive; type Multi_Moment_History is array (Natural range <>, Moment range <>) of Float; type Rec_Multi_Moment_History (Len : Natural; Size : Moment) is record Moments : Multi_Moment_History(0..Len, 1..Size); Last : Natural; end record; function Sub_History_Of (History : Rec_Multi_Moment_History) return Rec_Multi_Moment_History; end Discr15_Pkg;
with SDL.Keysym; use SDL.Keysym; with Ada.Text_IO; with Interfaces.C; procedure Test_Enumerations is package C renames Interfaces.C; package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); package Text_IO renames Ada.Text_IO; Index : Key := Key'First; begin Text_IO.Put_Line ("Identifier name Position Representation"); for Index in Key loop Text_IO.Put (Key'Image (Index)); Integer_IO.Put (Key'Pos (Index), 15); Integer_IO.Put (Key'Enum_Rep (Index), 15); Text_IO.New_Line; end loop; Text_IO.New_Line; Text_IO.Put ("The size of Key is: "); Integer_IO.Put (Key'Size / C.CHAR_BIT); Text_IO.Put_Line (" Bytes"); end Test_Enumerations;
with Trendy_Terminal.Histories; with Trendy_Terminal.IO; with Trendy_Terminal.Lines; -- Things which can affect editing of lines within Trendy Terminal. -- -- Line editing involves formatting, completion and handling of command history. -- package Trendy_Terminal.IO.Line_Editors is -- Updates a line to be a formatted line. type Format_Function is access function (L : Lines.Line) return Lines.Line; -- Attempts to complete a line. -- -- Completion_Index is the N'th attempted completion of the line. -- Shift-tab should decrease the Completion_Index, -- tab should increase the Completion_Index. type Completion_Function is access function (L : Lines.Line) return Lines.Line_Vectors.Vector; -- Line editing -- -- A description of the elements involved to modify a line of text. type Line_Editor is interface; function Get_Line (Editor : in out Line_Editor'Class) return String; function Format (E : in out Line_Editor; L : Lines.Line) return Lines.Line is abstract; function Complete (E : in out Line_Editor; L : Lines.Line) return Lines.Line_Vectors.Vector is abstract; procedure Submit (E : in out Line_Editor; L : Lines.Line) is abstract; function Line_History (E : in out Line_Editor) return Trendy_Terminal.Histories.History_Access is abstract; type Stateless_Line_Editor is new Line_Editor with record Format_Fn : Format_Function; Completion_Fn : Completion_Function; Line_History : Histories.History_Access; end record; overriding function Format (E : in out Stateless_Line_Editor; L : Lines.Line) return Lines.Line; overriding function Complete (E : in out Stateless_Line_Editor; L : Lines.Line) return Lines.Line_Vectors.Vector; overriding procedure Submit (E: in out Stateless_Line_Editor; L : Lines.Line); overriding function Line_History (E : in out Stateless_Line_Editor) return Trendy_Terminal.Histories.History_Access is (E.Line_History); -- Helper to implicitly use a Stateless_Line_Editor function Get_Line (Format_Fn : Format_Function := null; Completion_Fn : Completion_Function := null; Line_History : Histories.History_Access := null) return String; end Trendy_Terminal.IO.Line_Editors;
pragma License (Unrestricted); with Ada.Numerics.Generic_Complex_Elementary_Functions; with Ada.Numerics.Long_Complex_Types; package Ada.Numerics.Long_Complex_Elementary_Functions is new Generic_Complex_Elementary_Functions (Long_Complex_Types); pragma Pure (Ada.Numerics.Long_Complex_Elementary_Functions);
package body env is function validate_variable (s : string) return boolean is begin return gnat.regexp.match(s, variable_regexp); end validate_variable; end env;
-- This spec has been automatically generated from STM32F7x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.USB_OTG_FS is pragma Preelaborate; --------------- -- Registers -- --------------- subtype OTG_FS_DCFG_DSPD_Field is HAL.UInt2; subtype OTG_FS_DCFG_DAD_Field is HAL.UInt7; subtype OTG_FS_DCFG_PFIVL_Field is HAL.UInt2; -- OTG_FS device configuration register (OTG_FS_DCFG) type OTG_FS_DCFG_Register is record -- Device speed DSPD : OTG_FS_DCFG_DSPD_Field := 16#0#; -- Non-zero-length status OUT handshake NZLSOHSK : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Device address DAD : OTG_FS_DCFG_DAD_Field := 16#0#; -- Periodic frame interval PFIVL : OTG_FS_DCFG_PFIVL_Field := 16#0#; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#1100#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DCFG_Register use record DSPD at 0 range 0 .. 1; NZLSOHSK at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; DAD at 0 range 4 .. 10; PFIVL at 0 range 11 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; subtype OTG_FS_DCTL_TCTL_Field is HAL.UInt3; -- OTG_FS device control register (OTG_FS_DCTL) type OTG_FS_DCTL_Register is record -- Remote wakeup signaling RWUSIG : Boolean := False; -- Soft disconnect SDIS : Boolean := False; -- Read-only. Global IN NAK status GINSTS : Boolean := False; -- Read-only. Global OUT NAK status GONSTS : Boolean := False; -- Test control TCTL : OTG_FS_DCTL_TCTL_Field := 16#0#; -- Set global IN NAK SGINAK : Boolean := False; -- Clear global IN NAK CGINAK : Boolean := False; -- Set global OUT NAK SGONAK : Boolean := False; -- Clear global OUT NAK CGONAK : Boolean := False; -- Power-on programming done POPRGDNE : Boolean := False; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DCTL_Register use record RWUSIG at 0 range 0 .. 0; SDIS at 0 range 1 .. 1; GINSTS at 0 range 2 .. 2; GONSTS at 0 range 3 .. 3; TCTL at 0 range 4 .. 6; SGINAK at 0 range 7 .. 7; CGINAK at 0 range 8 .. 8; SGONAK at 0 range 9 .. 9; CGONAK at 0 range 10 .. 10; POPRGDNE at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype OTG_FS_DSTS_ENUMSPD_Field is HAL.UInt2; subtype OTG_FS_DSTS_FNSOF_Field is HAL.UInt14; -- OTG_FS device status register (OTG_FS_DSTS) type OTG_FS_DSTS_Register is record -- Read-only. Suspend status SUSPSTS : Boolean; -- Read-only. Enumerated speed ENUMSPD : OTG_FS_DSTS_ENUMSPD_Field; -- Read-only. Erratic error EERR : Boolean; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. Frame number of the received SOF FNSOF : OTG_FS_DSTS_FNSOF_Field; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DSTS_Register use record SUSPSTS at 0 range 0 .. 0; ENUMSPD at 0 range 1 .. 2; EERR at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; FNSOF at 0 range 8 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- OTG_FS device IN endpoint common interrupt mask register -- (OTG_FS_DIEPMSK) type OTG_FS_DIEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition mask (Non-isochronous endpoints) TOM : Boolean := False; -- IN token received when TxFIFO empty mask ITTXFEMSK : Boolean := False; -- IN token received with EP mismatch mask INEPNMM : Boolean := False; -- IN endpoint NAK effective mask INEPNEM : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOM at 0 range 3 .. 3; ITTXFEMSK at 0 range 4 .. 4; INEPNMM at 0 range 5 .. 5; INEPNEM at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- OTG_FS device OUT endpoint common interrupt mask register -- (OTG_FS_DOEPMSK) type OTG_FS_DOEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- SETUP phase done mask STUPM : Boolean := False; -- OUT token received when endpoint disabled mask OTEPDM : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DOEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUPM at 0 range 3 .. 3; OTEPDM at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype OTG_FS_DAINT_IEPINT_Field is HAL.UInt16; subtype OTG_FS_DAINT_OEPINT_Field is HAL.UInt16; -- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT) type OTG_FS_DAINT_Register is record -- Read-only. IN endpoint interrupt bits IEPINT : OTG_FS_DAINT_IEPINT_Field; -- Read-only. OUT endpoint interrupt bits OEPINT : OTG_FS_DAINT_OEPINT_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DAINT_Register use record IEPINT at 0 range 0 .. 15; OEPINT at 0 range 16 .. 31; end record; subtype OTG_FS_DAINTMSK_IEPM_Field is HAL.UInt16; subtype OTG_FS_DAINTMSK_OEPM_Field is HAL.UInt16; -- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK) type OTG_FS_DAINTMSK_Register is record -- IN EP interrupt mask bits IEPM : OTG_FS_DAINTMSK_IEPM_Field := 16#0#; -- OUT EP interrupt mask bits OEPM : OTG_FS_DAINTMSK_OEPM_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DAINTMSK_Register use record IEPM at 0 range 0 .. 15; OEPM at 0 range 16 .. 31; end record; subtype OTG_FS_DVBUSDIS_VBUSDT_Field is HAL.UInt16; -- OTG_FS device VBUS discharge time register type OTG_FS_DVBUSDIS_Register is record -- Device VBUS discharge time VBUSDT : OTG_FS_DVBUSDIS_VBUSDT_Field := 16#17D7#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DVBUSDIS_Register use record VBUSDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_DVBUSPULSE_DVBUSP_Field is HAL.UInt12; -- OTG_FS device VBUS pulsing time register type OTG_FS_DVBUSPULSE_Register is record -- Device VBUS pulsing time DVBUSP : OTG_FS_DVBUSPULSE_DVBUSP_Field := 16#5B8#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DVBUSPULSE_Register use record DVBUSP at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype OTG_FS_DIEPEMPMSK_INEPTXFEM_Field is HAL.UInt16; -- OTG_FS device IN endpoint FIFO empty interrupt mask register type OTG_FS_DIEPEMPMSK_Register is record -- IN EP Tx FIFO empty interrupt mask bits INEPTXFEM : OTG_FS_DIEPEMPMSK_INEPTXFEM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPEMPMSK_Register use record INEPTXFEM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_DIEPCTL0_MPSIZ_Field is HAL.UInt2; subtype OTG_FS_DIEPCTL0_EPTYP_Field is HAL.UInt2; subtype OTG_FS_DIEPCTL0_TXFNUM_Field is HAL.UInt4; -- OTG_FS device control IN endpoint 0 control register (OTG_FS_DIEPCTL0) type OTG_FS_DIEPCTL0_Register is record -- Maximum packet size MPSIZ : OTG_FS_DIEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USB active endpoint USBAEP : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAK status NAKSTS : Boolean := False; -- Read-only. Endpoint type EPTYP : OTG_FS_DIEPCTL0_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- STALL handshake STALL : Boolean := False; -- TxFIFO number TXFNUM : OTG_FS_DIEPCTL0_TXFNUM_Field := 16#0#; -- Write-only. Clear NAK CNAK : Boolean := False; -- Write-only. Set NAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. Endpoint disable EPDIS : Boolean := False; -- Read-only. Endpoint enable EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; STALL at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; -- device endpoint-x interrupt register type OTG_FS_DIEPINT_Register is record -- XFRC XFRC : Boolean := False; -- EPDISD EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- TOC TOC : Boolean := False; -- ITTXFE ITTXFE : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- INEPNE INEPNE : Boolean := False; -- Read-only. TXFE TXFE : Boolean := True; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOC at 0 range 3 .. 3; ITTXFE at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; INEPNE at 0 range 6 .. 6; TXFE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype OTG_FS_DIEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype OTG_FS_DIEPTSIZ0_PKTCNT_Field is HAL.UInt2; -- device endpoint-0 transfer size register type OTG_FS_DIEPTSIZ0_Register is record -- Transfer size XFRSIZ : OTG_FS_DIEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : OTG_FS_DIEPTSIZ0_PKTCNT_Field := 16#0#; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype OTG_FS_DTXFSTS_INEPTFSAV_Field is HAL.UInt16; -- OTG_FS device IN endpoint transmit FIFO status register type OTG_FS_DTXFSTS_Register is record -- Read-only. IN endpoint TxFIFO space available INEPTFSAV : OTG_FS_DTXFSTS_INEPTFSAV_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DTXFSTS_Register use record INEPTFSAV at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_DIEPCTL1_MPSIZ_Field is HAL.UInt11; subtype OTG_FS_DIEPCTL1_EPTYP_Field is HAL.UInt2; subtype OTG_FS_DIEPCTL1_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-1 control register type OTG_FS_DIEPCTL1_Register is record -- MPSIZ MPSIZ : OTG_FS_DIEPCTL1_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : OTG_FS_DIEPCTL1_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Stall Stall : Boolean := False; -- TXFNUM TXFNUM : OTG_FS_DIEPCTL1_TXFNUM_Field := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM/SD1PID SODDFRM_SD1PID : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPCTL1_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM_SD1PID at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype OTG_FS_DIEPTSIZ_XFRSIZ_Field is HAL.UInt19; subtype OTG_FS_DIEPTSIZ_PKTCNT_Field is HAL.UInt10; subtype OTG_FS_DIEPTSIZ_MCNT_Field is HAL.UInt2; -- device endpoint-1 transfer size register type OTG_FS_DIEPTSIZ_Register is record -- Transfer size XFRSIZ : OTG_FS_DIEPTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : OTG_FS_DIEPTSIZ_PKTCNT_Field := 16#0#; -- Multi count MCNT : OTG_FS_DIEPTSIZ_MCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; MCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype OTG_FS_DIEPCTL_MPSIZ_Field is HAL.UInt11; subtype OTG_FS_DIEPCTL_EPTYP_Field is HAL.UInt2; subtype OTG_FS_DIEPCTL_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-2 control register type OTG_FS_DIEPCTL_Register is record -- MPSIZ MPSIZ : OTG_FS_DIEPCTL_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : OTG_FS_DIEPCTL_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Stall Stall : Boolean := False; -- TXFNUM TXFNUM : OTG_FS_DIEPCTL_TXFNUM_Field := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM SODDFRM : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype OTG_FS_DOEPCTL0_MPSIZ_Field is HAL.UInt2; subtype OTG_FS_DOEPCTL0_EPTYP_Field is HAL.UInt2; -- device endpoint-0 control register type OTG_FS_DOEPCTL0_Register is record -- Read-only. MPSIZ MPSIZ : OTG_FS_DOEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USBAEP USBAEP : Boolean := True; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- Read-only. EPTYP EPTYP : OTG_FS_DOEPCTL0_EPTYP_Field := 16#0#; -- SNPM SNPM : Boolean := False; -- Stall Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. EPDIS EPDIS : Boolean := False; -- Write-only. EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DOEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; -- device endpoint-0 interrupt register type OTG_FS_DOEPINT_Register is record -- XFRC XFRC : Boolean := False; -- EPDISD EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STUP STUP : Boolean := False; -- OTEPDIS OTEPDIS : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- B2BSTUP B2BSTUP : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#1#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DOEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUP at 0 range 3 .. 3; OTEPDIS at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; B2BSTUP at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype OTG_FS_DOEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype OTG_FS_DOEPTSIZ0_STUPCNT_Field is HAL.UInt2; -- device OUT endpoint-0 transfer size register type OTG_FS_DOEPTSIZ0_Register is record -- Transfer size XFRSIZ : OTG_FS_DOEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : Boolean := False; -- unspecified Reserved_20_28 : HAL.UInt9 := 16#0#; -- SETUP packet count STUPCNT : OTG_FS_DOEPTSIZ0_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DOEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 19; Reserved_20_28 at 0 range 20 .. 28; STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype OTG_FS_DOEPCTL_MPSIZ_Field is HAL.UInt11; subtype OTG_FS_DOEPCTL_EPTYP_Field is HAL.UInt2; -- device endpoint-1 control register type OTG_FS_DOEPCTL_Register is record -- MPSIZ MPSIZ : OTG_FS_DOEPCTL_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : OTG_FS_DOEPCTL_EPTYP_Field := 16#0#; -- SNPM SNPM : Boolean := False; -- Stall Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM SODDFRM : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DOEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype OTG_FS_DOEPTSIZ_XFRSIZ_Field is HAL.UInt19; subtype OTG_FS_DOEPTSIZ_PKTCNT_Field is HAL.UInt10; subtype OTG_FS_DOEPTSIZ_RXDPID_STUPCNT_Field is HAL.UInt2; -- device OUT endpoint-1 transfer size register type OTG_FS_DOEPTSIZ_Register is record -- Transfer size XFRSIZ : OTG_FS_DOEPTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : OTG_FS_DOEPTSIZ_PKTCNT_Field := 16#0#; -- Received data PID/SETUP packet count RXDPID_STUPCNT : OTG_FS_DOEPTSIZ_RXDPID_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DOEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; RXDPID_STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_FS control and status register (OTG_FS_GOTGCTL) type OTG_FS_GOTGCTL_Register is record -- Read-only. Session request success SRQSCS : Boolean := False; -- Session request SRQ : Boolean := False; -- VBUS valid override enable VBVALOEN : Boolean := False; -- VBUS valid override value VBVALOVAL : Boolean := False; -- A-peripheral session valid override enable AVALOEN : Boolean := False; -- A-peripheral session valid override value AVALOVAL : Boolean := False; -- B-peripheral session valid override enable BVALOEN : Boolean := False; -- B-peripheral session valid override value BVALOVAL : Boolean := False; -- Read-only. Host negotiation success HNGSCS : Boolean := False; -- HNP request HNPRQ : Boolean := False; -- Host set HNP enable HSHNPEN : Boolean := False; -- Device HNP enabled DHNPEN : Boolean := True; -- Embedded host enable EHEN : Boolean := False; -- unspecified Reserved_13_15 : HAL.UInt3 := 16#0#; -- Read-only. Connector ID status CIDSTS : Boolean := False; -- Read-only. Long/short debounce time DBCT : Boolean := False; -- Read-only. A-session valid ASVLD : Boolean := False; -- Read-only. B-session valid BSVLD : Boolean := False; -- OTG version OTGVER : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GOTGCTL_Register use record SRQSCS at 0 range 0 .. 0; SRQ at 0 range 1 .. 1; VBVALOEN at 0 range 2 .. 2; VBVALOVAL at 0 range 3 .. 3; AVALOEN at 0 range 4 .. 4; AVALOVAL at 0 range 5 .. 5; BVALOEN at 0 range 6 .. 6; BVALOVAL at 0 range 7 .. 7; HNGSCS at 0 range 8 .. 8; HNPRQ at 0 range 9 .. 9; HSHNPEN at 0 range 10 .. 10; DHNPEN at 0 range 11 .. 11; EHEN at 0 range 12 .. 12; Reserved_13_15 at 0 range 13 .. 15; CIDSTS at 0 range 16 .. 16; DBCT at 0 range 17 .. 17; ASVLD at 0 range 18 .. 18; BSVLD at 0 range 19 .. 19; OTGVER at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; -- OTG_FS interrupt register (OTG_FS_GOTGINT) type OTG_FS_GOTGINT_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Session end detected SEDET : Boolean := False; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Session request success status change SRSSCHG : Boolean := False; -- Host negotiation success status change HNSSCHG : Boolean := False; -- unspecified Reserved_10_16 : HAL.UInt7 := 16#0#; -- Host negotiation detected HNGDET : Boolean := False; -- A-device timeout change ADTOCHG : Boolean := False; -- Debounce done DBCDNE : Boolean := False; -- ID input pin changed IDCHNG : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GOTGINT_Register use record Reserved_0_1 at 0 range 0 .. 1; SEDET at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; SRSSCHG at 0 range 8 .. 8; HNSSCHG at 0 range 9 .. 9; Reserved_10_16 at 0 range 10 .. 16; HNGDET at 0 range 17 .. 17; ADTOCHG at 0 range 18 .. 18; DBCDNE at 0 range 19 .. 19; IDCHNG at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; -- OTG_FS AHB configuration register (OTG_FS_GAHBCFG) type OTG_FS_GAHBCFG_Register is record -- Global interrupt mask GINT : Boolean := False; -- unspecified Reserved_1_6 : HAL.UInt6 := 16#0#; -- TxFIFO empty level TXFELVL : Boolean := False; -- Periodic TxFIFO empty level PTXFELVL : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GAHBCFG_Register use record GINT at 0 range 0 .. 0; Reserved_1_6 at 0 range 1 .. 6; TXFELVL at 0 range 7 .. 7; PTXFELVL at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype OTG_FS_GUSBCFG_TOCAL_Field is HAL.UInt3; subtype OTG_FS_GUSBCFG_TRDT_Field is HAL.UInt4; -- OTG_FS USB configuration register (OTG_FS_GUSBCFG) type OTG_FS_GUSBCFG_Register is record -- FS timeout calibration TOCAL : OTG_FS_GUSBCFG_TOCAL_Field := 16#0#; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Write-only. Full Speed serial transceiver select PHYSEL : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- SRP-capable SRPCAP : Boolean := False; -- HNP-capable HNPCAP : Boolean := True; -- USB turnaround time TRDT : OTG_FS_GUSBCFG_TRDT_Field := 16#2#; -- unspecified Reserved_14_28 : HAL.UInt15 := 16#0#; -- Force host mode FHMOD : Boolean := False; -- Force device mode FDMOD : Boolean := False; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GUSBCFG_Register use record TOCAL at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; PHYSEL at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; SRPCAP at 0 range 8 .. 8; HNPCAP at 0 range 9 .. 9; TRDT at 0 range 10 .. 13; Reserved_14_28 at 0 range 14 .. 28; FHMOD at 0 range 29 .. 29; FDMOD at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype OTG_FS_GRSTCTL_TXFNUM_Field is HAL.UInt5; -- OTG_FS reset register (OTG_FS_GRSTCTL) type OTG_FS_GRSTCTL_Register is record -- Core soft reset CSRST : Boolean := False; -- HCLK soft reset HSRST : Boolean := False; -- Host frame counter reset FCRST : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- RxFIFO flush RXFFLSH : Boolean := False; -- TxFIFO flush TXFFLSH : Boolean := False; -- TxFIFO number TXFNUM : OTG_FS_GRSTCTL_TXFNUM_Field := 16#0#; -- unspecified Reserved_11_30 : HAL.UInt20 := 16#40000#; -- Read-only. AHB master idle AHBIDL : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GRSTCTL_Register use record CSRST at 0 range 0 .. 0; HSRST at 0 range 1 .. 1; FCRST at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; RXFFLSH at 0 range 4 .. 4; TXFFLSH at 0 range 5 .. 5; TXFNUM at 0 range 6 .. 10; Reserved_11_30 at 0 range 11 .. 30; AHBIDL at 0 range 31 .. 31; end record; -- OTG_FS core interrupt register (OTG_FS_GINTSTS) type OTG_FS_GINTSTS_Register is record -- Read-only. Current mode of operation CMOD : Boolean := False; -- Mode mismatch interrupt MMIS : Boolean := False; -- Read-only. OTG interrupt OTGINT : Boolean := False; -- Start of frame SOF : Boolean := False; -- Read-only. RxFIFO non-empty RXFLVL : Boolean := False; -- Read-only. Non-periodic TxFIFO empty NPTXFE : Boolean := True; -- Read-only. Global IN non-periodic NAK effective GINAKEFF : Boolean := False; -- Read-only. Global OUT NAK effective GOUTNAKEFF : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend ESUSP : Boolean := False; -- USB suspend USBSUSP : Boolean := False; -- USB reset USBRST : Boolean := False; -- Enumeration done ENUMDNE : Boolean := False; -- Isochronous OUT packet dropped interrupt ISOODRP : Boolean := False; -- End of periodic frame interrupt EOPF : Boolean := False; -- unspecified Reserved_16_17 : HAL.UInt2 := 16#0#; -- Read-only. IN endpoint interrupt IEPINT : Boolean := False; -- Read-only. OUT endpoint interrupt OEPINT : Boolean := False; -- Incomplete isochronous IN transfer IISOIXFR : Boolean := False; -- Incomplete periodic transfer(Host mode)/Incomplete isochronous OUT -- transfer(Device mode) IPXFR_INCOMPISOOUT : Boolean := False; -- unspecified Reserved_22_22 : HAL.Bit := 16#0#; -- Reset detected interrupt RSTDET : Boolean := False; -- Read-only. Host port interrupt HPRTINT : Boolean := False; -- Read-only. Host channels interrupt HCINT : Boolean := False; -- Read-only. Periodic TxFIFO empty PTXFE : Boolean := True; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change CIDSCHG : Boolean := False; -- Disconnect detected interrupt DISCINT : Boolean := False; -- Session request/new session detected interrupt SRQINT : Boolean := False; -- Resume/remote wakeup detected interrupt WKUPINT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GINTSTS_Register use record CMOD at 0 range 0 .. 0; MMIS at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOF at 0 range 3 .. 3; RXFLVL at 0 range 4 .. 4; NPTXFE at 0 range 5 .. 5; GINAKEFF at 0 range 6 .. 6; GOUTNAKEFF at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSP at 0 range 10 .. 10; USBSUSP at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNE at 0 range 13 .. 13; ISOODRP at 0 range 14 .. 14; EOPF at 0 range 15 .. 15; Reserved_16_17 at 0 range 16 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFR at 0 range 20 .. 20; IPXFR_INCOMPISOOUT at 0 range 21 .. 21; Reserved_22_22 at 0 range 22 .. 22; RSTDET at 0 range 23 .. 23; HPRTINT at 0 range 24 .. 24; HCINT at 0 range 25 .. 25; PTXFE at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHG at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQINT at 0 range 30 .. 30; WKUPINT at 0 range 31 .. 31; end record; -- OTG_FS interrupt mask register (OTG_FS_GINTMSK) type OTG_FS_GINTMSK_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Mode mismatch interrupt mask MMISM : Boolean := False; -- OTG interrupt mask OTGINT : Boolean := False; -- Start of frame mask SOFM : Boolean := False; -- Receive FIFO non-empty mask RXFLVLM : Boolean := False; -- Non-periodic TxFIFO empty mask NPTXFEM : Boolean := False; -- Global non-periodic IN NAK effective mask GINAKEFFM : Boolean := False; -- Global OUT NAK effective mask GONAKEFFM : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend mask ESUSPM : Boolean := False; -- USB suspend mask USBSUSPM : Boolean := False; -- USB reset mask USBRST : Boolean := False; -- Enumeration done mask ENUMDNEM : Boolean := False; -- Isochronous OUT packet dropped interrupt mask ISOODRPM : Boolean := False; -- End of periodic frame interrupt mask EOPFM : Boolean := False; -- unspecified Reserved_16_17 : HAL.UInt2 := 16#0#; -- IN endpoints interrupt mask IEPINT : Boolean := False; -- OUT endpoints interrupt mask OEPINT : Boolean := False; -- Incomplete isochronous IN transfer mask IISOIXFRM : Boolean := False; -- Incomplete periodic transfer mask(Host mode)/Incomplete isochronous -- OUT transfer mask(Device mode) IPXFRM_IISOOXFRM : Boolean := False; -- unspecified Reserved_22_22 : HAL.Bit := 16#0#; -- Reset detected interrupt mask RSTDETM : Boolean := False; -- Read-only. Host port interrupt mask PRTIM : Boolean := False; -- Host channels interrupt mask HCIM : Boolean := False; -- Periodic TxFIFO empty mask PTXFEM : Boolean := False; -- LPM interrupt mask LPMIN : Boolean := False; -- Connector ID status change mask CIDSCHGM : Boolean := False; -- Disconnect detected interrupt mask DISCINT : Boolean := False; -- Session request/new session detected interrupt mask SRQIM : Boolean := False; -- Resume/remote wakeup detected interrupt mask WUIM : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GINTMSK_Register use record Reserved_0_0 at 0 range 0 .. 0; MMISM at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOFM at 0 range 3 .. 3; RXFLVLM at 0 range 4 .. 4; NPTXFEM at 0 range 5 .. 5; GINAKEFFM at 0 range 6 .. 6; GONAKEFFM at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSPM at 0 range 10 .. 10; USBSUSPM at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNEM at 0 range 13 .. 13; ISOODRPM at 0 range 14 .. 14; EOPFM at 0 range 15 .. 15; Reserved_16_17 at 0 range 16 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFRM at 0 range 20 .. 20; IPXFRM_IISOOXFRM at 0 range 21 .. 21; Reserved_22_22 at 0 range 22 .. 22; RSTDETM at 0 range 23 .. 23; PRTIM at 0 range 24 .. 24; HCIM at 0 range 25 .. 25; PTXFEM at 0 range 26 .. 26; LPMIN at 0 range 27 .. 27; CIDSCHGM at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQIM at 0 range 30 .. 30; WUIM at 0 range 31 .. 31; end record; subtype OTG_FS_GRXSTSR_Device_EPNUM_Field is HAL.UInt4; subtype OTG_FS_GRXSTSR_Device_BCNT_Field is HAL.UInt11; subtype OTG_FS_GRXSTSR_Device_DPID_Field is HAL.UInt2; subtype OTG_FS_GRXSTSR_Device_PKTSTS_Field is HAL.UInt4; subtype OTG_FS_GRXSTSR_Device_FRMNUM_Field is HAL.UInt4; -- OTG_FS Receive status debug read(Device mode) type OTG_FS_GRXSTSR_Device_Register is record -- Read-only. Endpoint number EPNUM : OTG_FS_GRXSTSR_Device_EPNUM_Field; -- Read-only. Byte count BCNT : OTG_FS_GRXSTSR_Device_BCNT_Field; -- Read-only. Data PID DPID : OTG_FS_GRXSTSR_Device_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_FS_GRXSTSR_Device_PKTSTS_Field; -- Read-only. Frame number FRMNUM : OTG_FS_GRXSTSR_Device_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GRXSTSR_Device_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype OTG_FS_GRXSTSR_Host_CHNUM_Field is HAL.UInt4; subtype OTG_FS_GRXSTSR_Host_BCNT_Field is HAL.UInt11; subtype OTG_FS_GRXSTSR_Host_DPID_Field is HAL.UInt2; subtype OTG_FS_GRXSTSR_Host_PKTSTS_Field is HAL.UInt4; -- OTG_FS Receive status debug read(Host mode) type OTG_FS_GRXSTSR_Host_Register is record -- Read-only. Endpoint number CHNUM : OTG_FS_GRXSTSR_Host_CHNUM_Field; -- Read-only. Byte count BCNT : OTG_FS_GRXSTSR_Host_BCNT_Field; -- Read-only. Data PID DPID : OTG_FS_GRXSTSR_Host_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_FS_GRXSTSR_Host_PKTSTS_Field; -- unspecified Reserved_21_31 : HAL.UInt11; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GRXSTSR_Host_Register use record CHNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype OTG_FS_GRXSTSP_Device_EPNUM_Field is HAL.UInt4; subtype OTG_FS_GRXSTSP_Device_BCNT_Field is HAL.UInt11; subtype OTG_FS_GRXSTSP_Device_DPID_Field is HAL.UInt2; subtype OTG_FS_GRXSTSP_Device_PKTSTS_Field is HAL.UInt4; subtype OTG_FS_GRXSTSP_Device_FRMNUM_Field is HAL.UInt4; -- OTG status read and pop register (Device mode) type OTG_FS_GRXSTSP_Device_Register is record -- Read-only. Endpoint number EPNUM : OTG_FS_GRXSTSP_Device_EPNUM_Field; -- Read-only. Byte count BCNT : OTG_FS_GRXSTSP_Device_BCNT_Field; -- Read-only. Data PID DPID : OTG_FS_GRXSTSP_Device_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_FS_GRXSTSP_Device_PKTSTS_Field; -- Read-only. Frame number FRMNUM : OTG_FS_GRXSTSP_Device_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GRXSTSP_Device_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype OTG_FS_GRXSTSP_Host_CHNUM_Field is HAL.UInt4; subtype OTG_FS_GRXSTSP_Host_BCNT_Field is HAL.UInt11; subtype OTG_FS_GRXSTSP_Host_DPID_Field is HAL.UInt2; subtype OTG_FS_GRXSTSP_Host_PKTSTS_Field is HAL.UInt4; -- OTG status read and pop register (Host mode) type OTG_FS_GRXSTSP_Host_Register is record -- Read-only. Channel number CHNUM : OTG_FS_GRXSTSP_Host_CHNUM_Field; -- Read-only. Byte count BCNT : OTG_FS_GRXSTSP_Host_BCNT_Field; -- Read-only. Data PID DPID : OTG_FS_GRXSTSP_Host_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_FS_GRXSTSP_Host_PKTSTS_Field; -- unspecified Reserved_21_31 : HAL.UInt11; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GRXSTSP_Host_Register use record CHNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype OTG_FS_GRXFSIZ_RXFD_Field is HAL.UInt16; -- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) type OTG_FS_GRXFSIZ_Register is record -- RxFIFO depth RXFD : OTG_FS_GRXFSIZ_RXFD_Field := 16#200#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GRXFSIZ_Register use record RXFD at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_DIEPTXF0_Device_TX0FSA_Field is HAL.UInt16; subtype OTG_FS_DIEPTXF0_Device_TX0FD_Field is HAL.UInt16; -- OTG_FS Endpoint 0 Transmit FIFO size type OTG_FS_DIEPTXF0_Device_Register is record -- Endpoint 0 transmit RAM start address TX0FSA : OTG_FS_DIEPTXF0_Device_TX0FSA_Field := 16#200#; -- Endpoint 0 TxFIFO depth TX0FD : OTG_FS_DIEPTXF0_Device_TX0FD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPTXF0_Device_Register use record TX0FSA at 0 range 0 .. 15; TX0FD at 0 range 16 .. 31; end record; subtype OTG_FS_HNPTXFSIZ_Host_NPTXFSA_Field is HAL.UInt16; subtype OTG_FS_HNPTXFSIZ_Host_NPTXFD_Field is HAL.UInt16; -- OTG_FS Host non-periodic transmit FIFO size register type OTG_FS_HNPTXFSIZ_Host_Register is record -- Non-periodic transmit RAM start address NPTXFSA : OTG_FS_HNPTXFSIZ_Host_NPTXFSA_Field := 16#200#; -- Non-periodic TxFIFO depth NPTXFD : OTG_FS_HNPTXFSIZ_Host_NPTXFD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HNPTXFSIZ_Host_Register use record NPTXFSA at 0 range 0 .. 15; NPTXFD at 0 range 16 .. 31; end record; subtype OTG_FS_HNPTXSTS_NPTXFSAV_Field is HAL.UInt16; subtype OTG_FS_HNPTXSTS_NPTQXSAV_Field is HAL.UInt8; subtype OTG_FS_HNPTXSTS_NPTXQTOP_Field is HAL.UInt7; -- OTG_FS non-periodic transmit FIFO/queue status register -- (OTG_FS_GNPTXSTS) type OTG_FS_HNPTXSTS_Register is record -- Read-only. Non-periodic TxFIFO space available NPTXFSAV : OTG_FS_HNPTXSTS_NPTXFSAV_Field; -- Read-only. Non-periodic transmit request queue space available NPTQXSAV : OTG_FS_HNPTXSTS_NPTQXSAV_Field; -- Read-only. Top of the non-periodic transmit request queue NPTXQTOP : OTG_FS_HNPTXSTS_NPTXQTOP_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HNPTXSTS_Register use record NPTXFSAV at 0 range 0 .. 15; NPTQXSAV at 0 range 16 .. 23; NPTXQTOP at 0 range 24 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype OTG_FS_GI2CCTL_RWDATA_Field is HAL.UInt8; subtype OTG_FS_GI2CCTL_REGADDR_Field is HAL.UInt8; subtype OTG_FS_GI2CCTL_ADDR_Field is HAL.UInt7; subtype OTG_FS_GI2CCTL_I2CDEVADR_Field is HAL.UInt2; -- OTG I2C access register type OTG_FS_GI2CCTL_Register is record -- I2C Read/Write Data RWDATA : OTG_FS_GI2CCTL_RWDATA_Field := 16#0#; -- I2C Register Address REGADDR : OTG_FS_GI2CCTL_REGADDR_Field := 16#4#; -- I2C Address ADDR : OTG_FS_GI2CCTL_ADDR_Field := 16#0#; -- I2C Enable I2CEN : Boolean := False; -- I2C ACK ACK : Boolean := False; -- unspecified Reserved_25_25 : HAL.Bit := 16#1#; -- I2C Device Address I2CDEVADR : OTG_FS_GI2CCTL_I2CDEVADR_Field := 16#0#; -- I2C DatSe0 USB mode I2CDATSE0 : Boolean := False; -- unspecified Reserved_29_29 : HAL.Bit := 16#0#; -- Read/Write Indicator RW : Boolean := False; -- I2C Busy/Done BSYDNE : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GI2CCTL_Register use record RWDATA at 0 range 0 .. 7; REGADDR at 0 range 8 .. 15; ADDR at 0 range 16 .. 22; I2CEN at 0 range 23 .. 23; ACK at 0 range 24 .. 24; Reserved_25_25 at 0 range 25 .. 25; I2CDEVADR at 0 range 26 .. 27; I2CDATSE0 at 0 range 28 .. 28; Reserved_29_29 at 0 range 29 .. 29; RW at 0 range 30 .. 30; BSYDNE at 0 range 31 .. 31; end record; -- OTG_FS general core configuration register (OTG_FS_GCCFG) type OTG_FS_GCCFG_Register is record -- Data contact detection (DCD) status DCDET : Boolean := False; -- Primary detection (PD) status PDET : Boolean := False; -- Secondary detection (SD) status SDET : Boolean := False; -- DM pull-up detection status PS2DET : Boolean := False; -- unspecified Reserved_4_15 : HAL.UInt12 := 16#0#; -- Power down PWRDWN : Boolean := False; -- Battery charging detector (BCD) enable BCDEN : Boolean := False; -- Data contact detection (DCD) mode enable DCDEN : Boolean := False; -- Primary detection (PD) mode enable PDEN : Boolean := False; -- Secondary detection (SD) mode enable SDEN : Boolean := False; -- USB VBUS detection enable VBDEN : Boolean := False; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GCCFG_Register use record DCDET at 0 range 0 .. 0; PDET at 0 range 1 .. 1; SDET at 0 range 2 .. 2; PS2DET at 0 range 3 .. 3; Reserved_4_15 at 0 range 4 .. 15; PWRDWN at 0 range 16 .. 16; BCDEN at 0 range 17 .. 17; DCDEN at 0 range 18 .. 18; PDEN at 0 range 19 .. 19; SDEN at 0 range 20 .. 20; VBDEN at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype OTG_FS_GLPMCFG_BESL_Field is HAL.UInt4; subtype OTG_FS_GLPMCFG_BESLTHRS_Field is HAL.UInt4; subtype OTG_FS_GLPMCFG_LPMRST_Field is HAL.UInt2; subtype OTG_FS_GLPMCFG_LPMCHIDX_Field is HAL.UInt4; subtype OTG_FS_GLPMCFG_LPMRCNT_Field is HAL.UInt3; subtype OTG_FS_GLPMCFG_LPMRCNTSTS_Field is HAL.UInt3; -- OTG core LPM configuration register type OTG_FS_GLPMCFG_Register is record -- LPM support enable LPMEN : Boolean := False; -- LPM token acknowledge enable LPMACK : Boolean := False; -- Best effort service latency BESL : OTG_FS_GLPMCFG_BESL_Field := 16#0#; -- bRemoteWake value REMWAKE : Boolean := False; -- L1 Shallow Sleep enable L1SSEN : Boolean := False; -- BESL threshold BESLTHRS : OTG_FS_GLPMCFG_BESLTHRS_Field := 16#4#; -- L1 deep sleep enable L1DSEN : Boolean := False; -- Read-only. LPM response LPMRST : OTG_FS_GLPMCFG_LPMRST_Field := 16#0#; -- Read-only. Port sleep status SLPSTS : Boolean := False; -- Read-only. Sleep State Resume OK L1RSMOK : Boolean := False; -- LPM Channel Index LPMCHIDX : OTG_FS_GLPMCFG_LPMCHIDX_Field := 16#0#; -- LPM retry count LPMRCNT : OTG_FS_GLPMCFG_LPMRCNT_Field := 16#0#; -- Send LPM transaction SNDLPM : Boolean := False; -- Read-only. LPM retry count status LPMRCNTSTS : OTG_FS_GLPMCFG_LPMRCNTSTS_Field := 16#1#; -- Enable best effort service latency ENBESL : Boolean := False; -- unspecified Reserved_29_31 : HAL.UInt3 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GLPMCFG_Register use record LPMEN at 0 range 0 .. 0; LPMACK at 0 range 1 .. 1; BESL at 0 range 2 .. 5; REMWAKE at 0 range 6 .. 6; L1SSEN at 0 range 7 .. 7; BESLTHRS at 0 range 8 .. 11; L1DSEN at 0 range 12 .. 12; LPMRST at 0 range 13 .. 14; SLPSTS at 0 range 15 .. 15; L1RSMOK at 0 range 16 .. 16; LPMCHIDX at 0 range 17 .. 20; LPMRCNT at 0 range 21 .. 23; SNDLPM at 0 range 24 .. 24; LPMRCNTSTS at 0 range 25 .. 27; ENBESL at 0 range 28 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; -- OTG power down register type OTG_FS_GPWRDN_Register is record -- ADP module enable ADPMEN : Boolean := False; -- unspecified Reserved_1_22 : HAL.UInt22 := 16#200#; -- ADP interrupt flag ADPIF : Boolean := False; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#2#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GPWRDN_Register use record ADPMEN at 0 range 0 .. 0; Reserved_1_22 at 0 range 1 .. 22; ADPIF at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype OTG_FS_GADPCTL_PRBDSCHG_Field is HAL.UInt2; subtype OTG_FS_GADPCTL_PRBDELTA_Field is HAL.UInt2; subtype OTG_FS_GADPCTL_PRBPER_Field is HAL.UInt2; subtype OTG_FS_GADPCTL_RTIM_Field is HAL.UInt11; subtype OTG_FS_GADPCTL_AR_Field is HAL.UInt2; -- OTG ADP timer, control and status register type OTG_FS_GADPCTL_Register is record -- Probe discharge PRBDSCHG : OTG_FS_GADPCTL_PRBDSCHG_Field := 16#0#; -- Probe delta PRBDELTA : OTG_FS_GADPCTL_PRBDELTA_Field := 16#0#; -- Probe period PRBPER : OTG_FS_GADPCTL_PRBPER_Field := 16#0#; -- Read-only. Ramp time RTIM : OTG_FS_GADPCTL_RTIM_Field := 16#10#; -- Enable probe ENAPRB : Boolean := False; -- Enable sense ENASNS : Boolean := False; -- Read-only. ADP reset ADPRST : Boolean := False; -- ADP enable ADPEN : Boolean := False; -- ADP probe interrupt flag ADPPRBIF : Boolean := False; -- ADP sense interrupt flag ADPSNSIF : Boolean := False; -- ADP timeout interrupt flag ADPTOIF : Boolean := False; -- ADP probe interrupt mask ADPPRBIM : Boolean := False; -- ADP sense interrupt mask ADPSNSIM : Boolean := True; -- ADP timeout interrupt mask ADPTOIM : Boolean := False; -- Access request AR : OTG_FS_GADPCTL_AR_Field := 16#0#; -- unspecified Reserved_29_31 : HAL.UInt3 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_GADPCTL_Register use record PRBDSCHG at 0 range 0 .. 1; PRBDELTA at 0 range 2 .. 3; PRBPER at 0 range 4 .. 5; RTIM at 0 range 6 .. 16; ENAPRB at 0 range 17 .. 17; ENASNS at 0 range 18 .. 18; ADPRST at 0 range 19 .. 19; ADPEN at 0 range 20 .. 20; ADPPRBIF at 0 range 21 .. 21; ADPSNSIF at 0 range 22 .. 22; ADPTOIF at 0 range 23 .. 23; ADPPRBIM at 0 range 24 .. 24; ADPSNSIM at 0 range 25 .. 25; ADPTOIM at 0 range 26 .. 26; AR at 0 range 27 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; subtype OTG_FS_HPTXFSIZ_PTXSA_Field is HAL.UInt16; subtype OTG_FS_HPTXFSIZ_PTXFSIZ_Field is HAL.UInt16; -- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ) type OTG_FS_HPTXFSIZ_Register is record -- Host periodic TxFIFO start address PTXSA : OTG_FS_HPTXFSIZ_PTXSA_Field := 16#600#; -- Host periodic TxFIFO depth PTXFSIZ : OTG_FS_HPTXFSIZ_PTXFSIZ_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HPTXFSIZ_Register use record PTXSA at 0 range 0 .. 15; PTXFSIZ at 0 range 16 .. 31; end record; subtype OTG_FS_DIEPTXF_INEPTXSA_Field is HAL.UInt16; subtype OTG_FS_DIEPTXF_INEPTXFD_Field is HAL.UInt16; -- OTG_FS device IN endpoint transmit FIFO size register (OTG_FS_DIEPTXF1) type OTG_FS_DIEPTXF_Register is record -- IN endpoint FIFO2 transmit RAM start address INEPTXSA : OTG_FS_DIEPTXF_INEPTXSA_Field := 16#400#; -- IN endpoint TxFIFO depth INEPTXFD : OTG_FS_DIEPTXF_INEPTXFD_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_DIEPTXF_Register use record INEPTXSA at 0 range 0 .. 15; INEPTXFD at 0 range 16 .. 31; end record; subtype OTG_FS_HCFG_FSLSPCS_Field is HAL.UInt2; -- OTG_FS host configuration register (OTG_FS_HCFG) type OTG_FS_HCFG_Register is record -- FS/LS PHY clock select FSLSPCS : OTG_FS_HCFG_FSLSPCS_Field := 16#0#; -- Read-only. FS- and LS-only support FSLSS : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HCFG_Register use record FSLSPCS at 0 range 0 .. 1; FSLSS at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype OTG_FS_HFIR_FRIVL_Field is HAL.UInt16; -- OTG_FS Host frame interval register type OTG_FS_HFIR_Register is record -- Frame interval FRIVL : OTG_FS_HFIR_FRIVL_Field := 16#EA60#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HFIR_Register use record FRIVL at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_HFNUM_FRNUM_Field is HAL.UInt16; subtype OTG_FS_HFNUM_FTREM_Field is HAL.UInt16; -- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM) type OTG_FS_HFNUM_Register is record -- Read-only. Frame number FRNUM : OTG_FS_HFNUM_FRNUM_Field; -- Read-only. Frame time remaining FTREM : OTG_FS_HFNUM_FTREM_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HFNUM_Register use record FRNUM at 0 range 0 .. 15; FTREM at 0 range 16 .. 31; end record; subtype OTG_FS_HPTXSTS_PTXFSAVL_Field is HAL.UInt16; subtype OTG_FS_HPTXSTS_PTXQSAV_Field is HAL.UInt8; subtype OTG_FS_HPTXSTS_PTXQTOP_Field is HAL.UInt8; -- OTG_FS_Host periodic transmit FIFO/queue status register -- (OTG_FS_HPTXSTS) type OTG_FS_HPTXSTS_Register is record -- Periodic transmit data FIFO space available PTXFSAVL : OTG_FS_HPTXSTS_PTXFSAVL_Field := 16#100#; -- Read-only. Periodic transmit request queue space available PTXQSAV : OTG_FS_HPTXSTS_PTXQSAV_Field := 16#8#; -- Read-only. Top of the periodic transmit request queue PTXQTOP : OTG_FS_HPTXSTS_PTXQTOP_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HPTXSTS_Register use record PTXFSAVL at 0 range 0 .. 15; PTXQSAV at 0 range 16 .. 23; PTXQTOP at 0 range 24 .. 31; end record; subtype OTG_FS_HAINT_HAINT_Field is HAL.UInt16; -- OTG_FS Host all channels interrupt register type OTG_FS_HAINT_Register is record -- Read-only. Channel interrupts HAINT : OTG_FS_HAINT_HAINT_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HAINT_Register use record HAINT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_HAINTMSK_HAINTM_Field is HAL.UInt16; -- OTG_FS host all channels interrupt mask register type OTG_FS_HAINTMSK_Register is record -- Channel interrupt mask HAINTM : OTG_FS_HAINTMSK_HAINTM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HAINTMSK_Register use record HAINTM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_FS_HPRT_PLSTS_Field is HAL.UInt2; subtype OTG_FS_HPRT_PTCTL_Field is HAL.UInt4; subtype OTG_FS_HPRT_PSPD_Field is HAL.UInt2; -- OTG_FS host port control and status register (OTG_FS_HPRT) type OTG_FS_HPRT_Register is record -- Read-only. Port connect status PCSTS : Boolean := False; -- Port connect detected PCDET : Boolean := False; -- Port enable PENA : Boolean := False; -- Port enable/disable change PENCHNG : Boolean := False; -- Read-only. Port overcurrent active POCA : Boolean := False; -- Port overcurrent change POCCHNG : Boolean := False; -- Port resume PRES : Boolean := False; -- Port suspend PSUSP : Boolean := False; -- Port reset PRST : Boolean := False; -- unspecified Reserved_9_9 : HAL.Bit := 16#0#; -- Read-only. Port line status PLSTS : OTG_FS_HPRT_PLSTS_Field := 16#0#; -- Port power PPWR : Boolean := False; -- Port test control PTCTL : OTG_FS_HPRT_PTCTL_Field := 16#0#; -- Read-only. Port speed PSPD : OTG_FS_HPRT_PSPD_Field := 16#0#; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HPRT_Register use record PCSTS at 0 range 0 .. 0; PCDET at 0 range 1 .. 1; PENA at 0 range 2 .. 2; PENCHNG at 0 range 3 .. 3; POCA at 0 range 4 .. 4; POCCHNG at 0 range 5 .. 5; PRES at 0 range 6 .. 6; PSUSP at 0 range 7 .. 7; PRST at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; PLSTS at 0 range 10 .. 11; PPWR at 0 range 12 .. 12; PTCTL at 0 range 13 .. 16; PSPD at 0 range 17 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype OTG_FS_HCCHAR_MPSIZ_Field is HAL.UInt11; subtype OTG_FS_HCCHAR_EPNUM_Field is HAL.UInt4; subtype OTG_FS_HCCHAR_EPTYP_Field is HAL.UInt2; subtype OTG_FS_HCCHAR_MCNT_Field is HAL.UInt2; subtype OTG_FS_HCCHAR_DAD_Field is HAL.UInt7; -- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0) type OTG_FS_HCCHAR_Register is record -- Maximum packet size MPSIZ : OTG_FS_HCCHAR_MPSIZ_Field := 16#0#; -- Endpoint number EPNUM : OTG_FS_HCCHAR_EPNUM_Field := 16#0#; -- Endpoint direction EPDIR : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Low-speed device LSDEV : Boolean := False; -- Endpoint type EPTYP : OTG_FS_HCCHAR_EPTYP_Field := 16#0#; -- Multicount MCNT : OTG_FS_HCCHAR_MCNT_Field := 16#0#; -- Device address DAD : OTG_FS_HCCHAR_DAD_Field := 16#0#; -- Odd frame ODDFRM : Boolean := False; -- Channel disable CHDIS : Boolean := False; -- Channel enable CHENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HCCHAR_Register use record MPSIZ at 0 range 0 .. 10; EPNUM at 0 range 11 .. 14; EPDIR at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; LSDEV at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; MCNT at 0 range 20 .. 21; DAD at 0 range 22 .. 28; ODDFRM at 0 range 29 .. 29; CHDIS at 0 range 30 .. 30; CHENA at 0 range 31 .. 31; end record; -- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0) type OTG_FS_HCINT_Register is record -- Transfer completed XFRC : Boolean := False; -- Channel halted CHH : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STALL response received interrupt STALL : Boolean := False; -- NAK response received interrupt NAK : Boolean := False; -- ACK response received/transmitted interrupt ACK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Transaction error TXERR : Boolean := False; -- Babble error BBERR : Boolean := False; -- Frame overrun FRMOR : Boolean := False; -- Data toggle error DTERR : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HCINT_Register use record XFRC at 0 range 0 .. 0; CHH at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STALL at 0 range 3 .. 3; NAK at 0 range 4 .. 4; ACK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; TXERR at 0 range 7 .. 7; BBERR at 0 range 8 .. 8; FRMOR at 0 range 9 .. 9; DTERR at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; -- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0) type OTG_FS_HCINTMSK_Register is record -- Transfer completed mask XFRCM : Boolean := False; -- Channel halted mask CHHM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STALL response received interrupt mask STALLM : Boolean := False; -- NAK response received interrupt mask NAKM : Boolean := False; -- ACK response received/transmitted interrupt mask ACKM : Boolean := False; -- response received interrupt mask NYET : Boolean := False; -- Transaction error mask TXERRM : Boolean := False; -- Babble error mask BBERRM : Boolean := False; -- Frame overrun mask FRMORM : Boolean := False; -- Data toggle error mask DTERRM : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HCINTMSK_Register use record XFRCM at 0 range 0 .. 0; CHHM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STALLM at 0 range 3 .. 3; NAKM at 0 range 4 .. 4; ACKM at 0 range 5 .. 5; NYET at 0 range 6 .. 6; TXERRM at 0 range 7 .. 7; BBERRM at 0 range 8 .. 8; FRMORM at 0 range 9 .. 9; DTERRM at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; subtype OTG_FS_HCTSIZ_XFRSIZ_Field is HAL.UInt19; subtype OTG_FS_HCTSIZ_PKTCNT_Field is HAL.UInt10; subtype OTG_FS_HCTSIZ_DPID_Field is HAL.UInt2; -- OTG_FS host channel-0 transfer size register type OTG_FS_HCTSIZ_Register is record -- Transfer size XFRSIZ : OTG_FS_HCTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : OTG_FS_HCTSIZ_PKTCNT_Field := 16#0#; -- Data PID DPID : OTG_FS_HCTSIZ_DPID_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_HCTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; DPID at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) type OTG_FS_PCGCCTL_Register is record -- Stop PHY clock STPPCLK : Boolean := False; -- Gate HCLK GATEHCLK : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- PHY Suspended PHYSUSP : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_FS_PCGCCTL_Register use record STPPCLK at 0 range 0 .. 0; GATEHCLK at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; PHYSUSP at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- USB on the go full speed type OTG_FS_DEVICE_Peripheral is record -- OTG_FS device configuration register (OTG_FS_DCFG) OTG_FS_DCFG : aliased OTG_FS_DCFG_Register; -- OTG_FS device control register (OTG_FS_DCTL) OTG_FS_DCTL : aliased OTG_FS_DCTL_Register; -- OTG_FS device status register (OTG_FS_DSTS) OTG_FS_DSTS : aliased OTG_FS_DSTS_Register; -- OTG_FS device IN endpoint common interrupt mask register -- (OTG_FS_DIEPMSK) OTG_FS_DIEPMSK : aliased OTG_FS_DIEPMSK_Register; -- OTG_FS device OUT endpoint common interrupt mask register -- (OTG_FS_DOEPMSK) OTG_FS_DOEPMSK : aliased OTG_FS_DOEPMSK_Register; -- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT) OTG_FS_DAINT : aliased OTG_FS_DAINT_Register; -- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK) OTG_FS_DAINTMSK : aliased OTG_FS_DAINTMSK_Register; -- OTG_FS device VBUS discharge time register OTG_FS_DVBUSDIS : aliased OTG_FS_DVBUSDIS_Register; -- OTG_FS device VBUS pulsing time register OTG_FS_DVBUSPULSE : aliased OTG_FS_DVBUSPULSE_Register; -- OTG_FS device IN endpoint FIFO empty interrupt mask register OTG_FS_DIEPEMPMSK : aliased OTG_FS_DIEPEMPMSK_Register; -- OTG_FS device control IN endpoint 0 control register -- (OTG_FS_DIEPCTL0) OTG_FS_DIEPCTL0 : aliased OTG_FS_DIEPCTL0_Register; -- device endpoint-x interrupt register OTG_FS_DIEPINT0 : aliased OTG_FS_DIEPINT_Register; -- device endpoint-0 transfer size register OTG_FS_DIEPTSIZ0 : aliased OTG_FS_DIEPTSIZ0_Register; -- OTG_FS device IN endpoint transmit FIFO status register OTG_FS_DTXFSTS0 : aliased OTG_FS_DTXFSTS_Register; -- OTG device endpoint-1 control register OTG_FS_DIEPCTL1 : aliased OTG_FS_DIEPCTL1_Register; -- device endpoint-1 interrupt register OTG_FS_DIEPINT1 : aliased OTG_FS_DIEPINT_Register; -- device endpoint-1 transfer size register OTG_FS_DIEPTSIZ1 : aliased OTG_FS_DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register OTG_FS_DTXFSTS1 : aliased OTG_FS_DTXFSTS_Register; -- OTG device endpoint-2 control register OTG_FS_DIEPCTL2 : aliased OTG_FS_DIEPCTL_Register; -- device endpoint-2 interrupt register OTG_FS_DIEPINT2 : aliased OTG_FS_DIEPINT_Register; -- device endpoint-2 transfer size register OTG_FS_DIEPTSIZ2 : aliased OTG_FS_DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register OTG_FS_DTXFSTS2 : aliased OTG_FS_DTXFSTS_Register; -- OTG device endpoint-3 control register OTG_FS_DIEPCTL3 : aliased OTG_FS_DIEPCTL_Register; -- device endpoint-3 interrupt register OTG_FS_DIEPINT3 : aliased OTG_FS_DIEPINT_Register; -- device endpoint-3 transfer size register OTG_FS_DIEPTSIZ3 : aliased OTG_FS_DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register OTG_FS_DTXFSTS3 : aliased OTG_FS_DTXFSTS_Register; -- OTG device endpoint-4 control register OTG_FS_DIEPCTL4 : aliased OTG_FS_DIEPCTL_Register; -- device endpoint-4 interrupt register OTG_FS_DIEPINT4 : aliased OTG_FS_DIEPINT_Register; -- device endpoint-4 transfer size register OTG_FS_DIEPTSIZ4 : aliased OTG_FS_DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register OTG_FS_DTXFSTS4 : aliased OTG_FS_DTXFSTS_Register; -- OTG device endpoint-5 control register OTG_FS_DIEPCTL5 : aliased OTG_FS_DIEPCTL_Register; -- device endpoint-5 interrupt register OTG_FS_DIEPINT5 : aliased OTG_FS_DIEPINT_Register; -- device endpoint-5 transfer size register OTG_FS_DIEPTSIZ55 : aliased OTG_FS_DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register OTG_FS_DTXFSTS55 : aliased OTG_FS_DTXFSTS_Register; -- device endpoint-0 control register OTG_FS_DOEPCTL0 : aliased OTG_FS_DOEPCTL0_Register; -- device endpoint-0 interrupt register OTG_FS_DOEPINT0 : aliased OTG_FS_DOEPINT_Register; -- device OUT endpoint-0 transfer size register OTG_FS_DOEPTSIZ0 : aliased OTG_FS_DOEPTSIZ0_Register; -- device endpoint-1 control register OTG_FS_DOEPCTL1 : aliased OTG_FS_DOEPCTL_Register; -- device endpoint-1 interrupt register OTG_FS_DOEPINT1 : aliased OTG_FS_DOEPINT_Register; -- device OUT endpoint-1 transfer size register OTG_FS_DOEPTSIZ1 : aliased OTG_FS_DOEPTSIZ_Register; -- device endpoint-2 control register OTG_FS_DOEPCTL2 : aliased OTG_FS_DOEPCTL_Register; -- device endpoint-2 interrupt register OTG_FS_DOEPINT2 : aliased OTG_FS_DOEPINT_Register; -- device OUT endpoint-2 transfer size register OTG_FS_DOEPTSIZ2 : aliased OTG_FS_DOEPTSIZ_Register; -- device endpoint-3 control register OTG_FS_DOEPCTL3 : aliased OTG_FS_DOEPCTL_Register; -- device endpoint-3 interrupt register OTG_FS_DOEPINT3 : aliased OTG_FS_DOEPINT_Register; -- device OUT endpoint-3 transfer size register OTG_FS_DOEPTSIZ3 : aliased OTG_FS_DOEPTSIZ_Register; -- device endpoint-4 control register OTG_FS_DOEPCTL4 : aliased OTG_FS_DOEPCTL_Register; -- device endpoint-4 interrupt register OTG_FS_DOEPINT4 : aliased OTG_FS_DOEPINT_Register; -- device OUT endpoint-4 transfer size register OTG_FS_DOEPTSIZ4 : aliased OTG_FS_DOEPTSIZ_Register; -- device endpoint-5 control register OTG_FS_DOEPCTL5 : aliased OTG_FS_DOEPCTL_Register; -- device endpoint-5 interrupt register OTG_FS_DOEPINT5 : aliased OTG_FS_DOEPINT_Register; -- device OUT endpoint-5 transfer size register OTG_FS_DOEPTSIZ5 : aliased OTG_FS_DOEPTSIZ_Register; end record with Volatile; for OTG_FS_DEVICE_Peripheral use record OTG_FS_DCFG at 16#0# range 0 .. 31; OTG_FS_DCTL at 16#4# range 0 .. 31; OTG_FS_DSTS at 16#8# range 0 .. 31; OTG_FS_DIEPMSK at 16#10# range 0 .. 31; OTG_FS_DOEPMSK at 16#14# range 0 .. 31; OTG_FS_DAINT at 16#18# range 0 .. 31; OTG_FS_DAINTMSK at 16#1C# range 0 .. 31; OTG_FS_DVBUSDIS at 16#28# range 0 .. 31; OTG_FS_DVBUSPULSE at 16#2C# range 0 .. 31; OTG_FS_DIEPEMPMSK at 16#34# range 0 .. 31; OTG_FS_DIEPCTL0 at 16#100# range 0 .. 31; OTG_FS_DIEPINT0 at 16#108# range 0 .. 31; OTG_FS_DIEPTSIZ0 at 16#110# range 0 .. 31; OTG_FS_DTXFSTS0 at 16#118# range 0 .. 31; OTG_FS_DIEPCTL1 at 16#120# range 0 .. 31; OTG_FS_DIEPINT1 at 16#128# range 0 .. 31; OTG_FS_DIEPTSIZ1 at 16#130# range 0 .. 31; OTG_FS_DTXFSTS1 at 16#138# range 0 .. 31; OTG_FS_DIEPCTL2 at 16#140# range 0 .. 31; OTG_FS_DIEPINT2 at 16#148# range 0 .. 31; OTG_FS_DIEPTSIZ2 at 16#150# range 0 .. 31; OTG_FS_DTXFSTS2 at 16#158# range 0 .. 31; OTG_FS_DIEPCTL3 at 16#160# range 0 .. 31; OTG_FS_DIEPINT3 at 16#168# range 0 .. 31; OTG_FS_DIEPTSIZ3 at 16#170# range 0 .. 31; OTG_FS_DTXFSTS3 at 16#178# range 0 .. 31; OTG_FS_DIEPCTL4 at 16#180# range 0 .. 31; OTG_FS_DIEPINT4 at 16#188# range 0 .. 31; OTG_FS_DIEPTSIZ4 at 16#194# range 0 .. 31; OTG_FS_DTXFSTS4 at 16#19C# range 0 .. 31; OTG_FS_DIEPCTL5 at 16#1A0# range 0 .. 31; OTG_FS_DIEPINT5 at 16#1A8# range 0 .. 31; OTG_FS_DIEPTSIZ55 at 16#1B0# range 0 .. 31; OTG_FS_DTXFSTS55 at 16#1B8# range 0 .. 31; OTG_FS_DOEPCTL0 at 16#300# range 0 .. 31; OTG_FS_DOEPINT0 at 16#308# range 0 .. 31; OTG_FS_DOEPTSIZ0 at 16#310# range 0 .. 31; OTG_FS_DOEPCTL1 at 16#320# range 0 .. 31; OTG_FS_DOEPINT1 at 16#328# range 0 .. 31; OTG_FS_DOEPTSIZ1 at 16#330# range 0 .. 31; OTG_FS_DOEPCTL2 at 16#340# range 0 .. 31; OTG_FS_DOEPINT2 at 16#348# range 0 .. 31; OTG_FS_DOEPTSIZ2 at 16#350# range 0 .. 31; OTG_FS_DOEPCTL3 at 16#360# range 0 .. 31; OTG_FS_DOEPINT3 at 16#368# range 0 .. 31; OTG_FS_DOEPTSIZ3 at 16#370# range 0 .. 31; OTG_FS_DOEPCTL4 at 16#378# range 0 .. 31; OTG_FS_DOEPINT4 at 16#380# range 0 .. 31; OTG_FS_DOEPTSIZ4 at 16#388# range 0 .. 31; OTG_FS_DOEPCTL5 at 16#390# range 0 .. 31; OTG_FS_DOEPINT5 at 16#398# range 0 .. 31; OTG_FS_DOEPTSIZ5 at 16#3A0# range 0 .. 31; end record; -- USB on the go full speed OTG_FS_DEVICE_Periph : aliased OTG_FS_DEVICE_Peripheral with Import, Address => System'To_Address (16#50000800#); type OTG_FS_GLOBAL_Disc is ( Device, Host, Dieptxf0_Device, Hnptxfsiz_Host); -- USB on the go full speed type OTG_FS_GLOBAL_Peripheral (Discriminent : OTG_FS_GLOBAL_Disc := Device) is record -- OTG_FS control and status register (OTG_FS_GOTGCTL) OTG_FS_GOTGCTL : aliased OTG_FS_GOTGCTL_Register; -- OTG_FS interrupt register (OTG_FS_GOTGINT) OTG_FS_GOTGINT : aliased OTG_FS_GOTGINT_Register; -- OTG_FS AHB configuration register (OTG_FS_GAHBCFG) OTG_FS_GAHBCFG : aliased OTG_FS_GAHBCFG_Register; -- OTG_FS USB configuration register (OTG_FS_GUSBCFG) OTG_FS_GUSBCFG : aliased OTG_FS_GUSBCFG_Register; -- OTG_FS reset register (OTG_FS_GRSTCTL) OTG_FS_GRSTCTL : aliased OTG_FS_GRSTCTL_Register; -- OTG_FS core interrupt register (OTG_FS_GINTSTS) OTG_FS_GINTSTS : aliased OTG_FS_GINTSTS_Register; -- OTG_FS interrupt mask register (OTG_FS_GINTMSK) OTG_FS_GINTMSK : aliased OTG_FS_GINTMSK_Register; -- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) OTG_FS_GRXFSIZ : aliased OTG_FS_GRXFSIZ_Register; -- OTG_FS non-periodic transmit FIFO/queue status register -- (OTG_FS_GNPTXSTS) OTG_FS_HNPTXSTS : aliased OTG_FS_HNPTXSTS_Register; -- OTG I2C access register OTG_FS_GI2CCTL : aliased OTG_FS_GI2CCTL_Register; -- OTG_FS general core configuration register (OTG_FS_GCCFG) OTG_FS_GCCFG : aliased OTG_FS_GCCFG_Register; -- core ID register OTG_FS_CID : aliased HAL.UInt32; -- OTG core LPM configuration register OTG_FS_GLPMCFG : aliased OTG_FS_GLPMCFG_Register; -- OTG power down register OTG_FS_GPWRDN : aliased OTG_FS_GPWRDN_Register; -- OTG ADP timer, control and status register OTG_FS_GADPCTL : aliased OTG_FS_GADPCTL_Register; -- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ) OTG_FS_HPTXFSIZ : aliased OTG_FS_HPTXFSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF1) OTG_FS_DIEPTXF1 : aliased OTG_FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF2) OTG_FS_DIEPTXF2 : aliased OTG_FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF3) OTG_FS_DIEPTXF3 : aliased OTG_FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF4) OTG_FS_DIEPTXF4 : aliased OTG_FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF5) OTG_FS_DIEPTXF5 : aliased OTG_FS_DIEPTXF_Register; case Discriminent is when Device => -- OTG_FS Receive status debug read(Device mode) OTG_FS_GRXSTSR_Device : aliased OTG_FS_GRXSTSR_Device_Register; -- OTG status read and pop register (Device mode) OTG_FS_GRXSTSP_Device : aliased OTG_FS_GRXSTSP_Device_Register; when Host => -- OTG_FS Receive status debug read(Host mode) OTG_FS_GRXSTSR_Host : aliased OTG_FS_GRXSTSR_Host_Register; -- OTG status read and pop register (Host mode) OTG_FS_GRXSTSP_Host : aliased OTG_FS_GRXSTSP_Host_Register; when Dieptxf0_Device => -- OTG_FS Endpoint 0 Transmit FIFO size OTG_FS_DIEPTXF0_Device : aliased OTG_FS_DIEPTXF0_Device_Register; when Hnptxfsiz_Host => -- OTG_FS Host non-periodic transmit FIFO size register OTG_FS_HNPTXFSIZ_Host : aliased OTG_FS_HNPTXFSIZ_Host_Register; end case; end record with Unchecked_Union, Volatile; for OTG_FS_GLOBAL_Peripheral use record OTG_FS_GOTGCTL at 16#0# range 0 .. 31; OTG_FS_GOTGINT at 16#4# range 0 .. 31; OTG_FS_GAHBCFG at 16#8# range 0 .. 31; OTG_FS_GUSBCFG at 16#C# range 0 .. 31; OTG_FS_GRSTCTL at 16#10# range 0 .. 31; OTG_FS_GINTSTS at 16#14# range 0 .. 31; OTG_FS_GINTMSK at 16#18# range 0 .. 31; OTG_FS_GRXFSIZ at 16#24# range 0 .. 31; OTG_FS_HNPTXSTS at 16#2C# range 0 .. 31; OTG_FS_GI2CCTL at 16#30# range 0 .. 31; OTG_FS_GCCFG at 16#38# range 0 .. 31; OTG_FS_CID at 16#3C# range 0 .. 31; OTG_FS_GLPMCFG at 16#54# range 0 .. 31; OTG_FS_GPWRDN at 16#58# range 0 .. 31; OTG_FS_GADPCTL at 16#60# range 0 .. 31; OTG_FS_HPTXFSIZ at 16#100# range 0 .. 31; OTG_FS_DIEPTXF1 at 16#104# range 0 .. 31; OTG_FS_DIEPTXF2 at 16#108# range 0 .. 31; OTG_FS_DIEPTXF3 at 16#10C# range 0 .. 31; OTG_FS_DIEPTXF4 at 16#110# range 0 .. 31; OTG_FS_DIEPTXF5 at 16#114# range 0 .. 31; OTG_FS_GRXSTSR_Device at 16#1C# range 0 .. 31; OTG_FS_GRXSTSP_Device at 16#20# range 0 .. 31; OTG_FS_GRXSTSR_Host at 16#1C# range 0 .. 31; OTG_FS_GRXSTSP_Host at 16#20# range 0 .. 31; OTG_FS_DIEPTXF0_Device at 16#28# range 0 .. 31; OTG_FS_HNPTXFSIZ_Host at 16#28# range 0 .. 31; end record; -- USB on the go full speed OTG_FS_GLOBAL_Periph : aliased OTG_FS_GLOBAL_Peripheral with Import, Address => System'To_Address (16#50000000#); -- USB on the go full speed type OTG_FS_HOST_Peripheral is record -- OTG_FS host configuration register (OTG_FS_HCFG) OTG_FS_HCFG : aliased OTG_FS_HCFG_Register; -- OTG_FS Host frame interval register OTG_FS_HFIR : aliased OTG_FS_HFIR_Register; -- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM) OTG_FS_HFNUM : aliased OTG_FS_HFNUM_Register; -- OTG_FS_Host periodic transmit FIFO/queue status register -- (OTG_FS_HPTXSTS) OTG_FS_HPTXSTS : aliased OTG_FS_HPTXSTS_Register; -- OTG_FS Host all channels interrupt register OTG_FS_HAINT : aliased OTG_FS_HAINT_Register; -- OTG_FS host all channels interrupt mask register OTG_FS_HAINTMSK : aliased OTG_FS_HAINTMSK_Register; -- OTG_FS host port control and status register (OTG_FS_HPRT) OTG_FS_HPRT : aliased OTG_FS_HPRT_Register; -- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0) OTG_FS_HCCHAR0 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0) OTG_FS_HCINT0 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0) OTG_FS_HCINTMSK0 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-0 transfer size register OTG_FS_HCTSIZ0 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-1 characteristics register (OTG_FS_HCCHAR1) OTG_FS_HCCHAR1 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-1 interrupt register (OTG_FS_HCINT1) OTG_FS_HCINT1 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-1 mask register (OTG_FS_HCINTMSK1) OTG_FS_HCINTMSK1 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-1 transfer size register OTG_FS_HCTSIZ1 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-2 characteristics register (OTG_FS_HCCHAR2) OTG_FS_HCCHAR2 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-2 interrupt register (OTG_FS_HCINT2) OTG_FS_HCINT2 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-2 mask register (OTG_FS_HCINTMSK2) OTG_FS_HCINTMSK2 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-2 transfer size register OTG_FS_HCTSIZ2 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-3 characteristics register (OTG_FS_HCCHAR3) OTG_FS_HCCHAR3 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-3 interrupt register (OTG_FS_HCINT3) OTG_FS_HCINT3 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-3 mask register (OTG_FS_HCINTMSK3) OTG_FS_HCINTMSK3 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-3 transfer size register OTG_FS_HCTSIZ3 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-4 characteristics register (OTG_FS_HCCHAR4) OTG_FS_HCCHAR4 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-4 interrupt register (OTG_FS_HCINT4) OTG_FS_HCINT4 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-4 mask register (OTG_FS_HCINTMSK4) OTG_FS_HCINTMSK4 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-x transfer size register OTG_FS_HCTSIZ4 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-5 characteristics register (OTG_FS_HCCHAR5) OTG_FS_HCCHAR5 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-5 interrupt register (OTG_FS_HCINT5) OTG_FS_HCINT5 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-5 mask register (OTG_FS_HCINTMSK5) OTG_FS_HCINTMSK5 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-5 transfer size register OTG_FS_HCTSIZ5 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-6 characteristics register (OTG_FS_HCCHAR6) OTG_FS_HCCHAR6 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-6 interrupt register (OTG_FS_HCINT6) OTG_FS_HCINT6 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-6 mask register (OTG_FS_HCINTMSK6) OTG_FS_HCINTMSK6 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-6 transfer size register OTG_FS_HCTSIZ6 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-7 characteristics register (OTG_FS_HCCHAR7) OTG_FS_HCCHAR7 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-7 interrupt register (OTG_FS_HCINT7) OTG_FS_HCINT7 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-7 mask register (OTG_FS_HCINTMSK7) OTG_FS_HCINTMSK7 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-7 transfer size register OTG_FS_HCTSIZ7 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-8 characteristics register OTG_FS_HCCHAR8 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-8 interrupt register OTG_FS_HCINT8 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-8 mask register OTG_FS_HCINTMSK8 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-8 transfer size register OTG_FS_HCTSIZ8 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-9 characteristics register OTG_FS_HCCHAR9 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-9 interrupt register OTG_FS_HCINT9 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-9 mask register OTG_FS_HCINTMSK9 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-9 transfer size register OTG_FS_HCTSIZ9 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-10 characteristics register OTG_FS_HCCHAR10 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-10 interrupt register OTG_FS_HCINT10 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-10 mask register OTG_FS_HCINTMSK10 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-10 transfer size register OTG_FS_HCTSIZ10 : aliased OTG_FS_HCTSIZ_Register; -- OTG_FS host channel-11 characteristics register OTG_FS_HCCHAR11 : aliased OTG_FS_HCCHAR_Register; -- OTG_FS host channel-11 interrupt register OTG_FS_HCINT11 : aliased OTG_FS_HCINT_Register; -- OTG_FS host channel-11 mask register OTG_FS_HCINTMSK11 : aliased OTG_FS_HCINTMSK_Register; -- OTG_FS host channel-11 transfer size register OTG_FS_HCTSIZ11 : aliased OTG_FS_HCTSIZ_Register; end record with Volatile; for OTG_FS_HOST_Peripheral use record OTG_FS_HCFG at 16#0# range 0 .. 31; OTG_FS_HFIR at 16#4# range 0 .. 31; OTG_FS_HFNUM at 16#8# range 0 .. 31; OTG_FS_HPTXSTS at 16#10# range 0 .. 31; OTG_FS_HAINT at 16#14# range 0 .. 31; OTG_FS_HAINTMSK at 16#18# range 0 .. 31; OTG_FS_HPRT at 16#40# range 0 .. 31; OTG_FS_HCCHAR0 at 16#100# range 0 .. 31; OTG_FS_HCINT0 at 16#108# range 0 .. 31; OTG_FS_HCINTMSK0 at 16#10C# range 0 .. 31; OTG_FS_HCTSIZ0 at 16#110# range 0 .. 31; OTG_FS_HCCHAR1 at 16#120# range 0 .. 31; OTG_FS_HCINT1 at 16#128# range 0 .. 31; OTG_FS_HCINTMSK1 at 16#12C# range 0 .. 31; OTG_FS_HCTSIZ1 at 16#130# range 0 .. 31; OTG_FS_HCCHAR2 at 16#140# range 0 .. 31; OTG_FS_HCINT2 at 16#148# range 0 .. 31; OTG_FS_HCINTMSK2 at 16#14C# range 0 .. 31; OTG_FS_HCTSIZ2 at 16#150# range 0 .. 31; OTG_FS_HCCHAR3 at 16#160# range 0 .. 31; OTG_FS_HCINT3 at 16#168# range 0 .. 31; OTG_FS_HCINTMSK3 at 16#16C# range 0 .. 31; OTG_FS_HCTSIZ3 at 16#170# range 0 .. 31; OTG_FS_HCCHAR4 at 16#180# range 0 .. 31; OTG_FS_HCINT4 at 16#188# range 0 .. 31; OTG_FS_HCINTMSK4 at 16#18C# range 0 .. 31; OTG_FS_HCTSIZ4 at 16#190# range 0 .. 31; OTG_FS_HCCHAR5 at 16#1A0# range 0 .. 31; OTG_FS_HCINT5 at 16#1A8# range 0 .. 31; OTG_FS_HCINTMSK5 at 16#1AC# range 0 .. 31; OTG_FS_HCTSIZ5 at 16#1B0# range 0 .. 31; OTG_FS_HCCHAR6 at 16#1C0# range 0 .. 31; OTG_FS_HCINT6 at 16#1C8# range 0 .. 31; OTG_FS_HCINTMSK6 at 16#1CC# range 0 .. 31; OTG_FS_HCTSIZ6 at 16#1D0# range 0 .. 31; OTG_FS_HCCHAR7 at 16#1E0# range 0 .. 31; OTG_FS_HCINT7 at 16#1E8# range 0 .. 31; OTG_FS_HCINTMSK7 at 16#1EC# range 0 .. 31; OTG_FS_HCTSIZ7 at 16#1F0# range 0 .. 31; OTG_FS_HCCHAR8 at 16#1F4# range 0 .. 31; OTG_FS_HCINT8 at 16#1F8# range 0 .. 31; OTG_FS_HCINTMSK8 at 16#1FC# range 0 .. 31; OTG_FS_HCTSIZ8 at 16#200# range 0 .. 31; OTG_FS_HCCHAR9 at 16#204# range 0 .. 31; OTG_FS_HCINT9 at 16#208# range 0 .. 31; OTG_FS_HCINTMSK9 at 16#20C# range 0 .. 31; OTG_FS_HCTSIZ9 at 16#210# range 0 .. 31; OTG_FS_HCCHAR10 at 16#214# range 0 .. 31; OTG_FS_HCINT10 at 16#218# range 0 .. 31; OTG_FS_HCINTMSK10 at 16#21C# range 0 .. 31; OTG_FS_HCTSIZ10 at 16#220# range 0 .. 31; OTG_FS_HCCHAR11 at 16#224# range 0 .. 31; OTG_FS_HCINT11 at 16#228# range 0 .. 31; OTG_FS_HCINTMSK11 at 16#22C# range 0 .. 31; OTG_FS_HCTSIZ11 at 16#230# range 0 .. 31; end record; -- USB on the go full speed OTG_FS_HOST_Periph : aliased OTG_FS_HOST_Peripheral with Import, Address => System'To_Address (16#50000400#); -- USB on the go full speed type OTG_FS_PWRCLK_Peripheral is record -- OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) OTG_FS_PCGCCTL : aliased OTG_FS_PCGCCTL_Register; end record with Volatile; for OTG_FS_PWRCLK_Peripheral use record OTG_FS_PCGCCTL at 0 range 0 .. 31; end record; -- USB on the go full speed OTG_FS_PWRCLK_Periph : aliased OTG_FS_PWRCLK_Peripheral with Import, Address => System'To_Address (16#50000E00#); end STM32_SVD.USB_OTG_FS;
pragma License (Unrestricted); -- runtime unit with System.Unwind.Representation; package System.Runtime_Context is pragma Preelaborate; -- equivalent to TSD (s-soflin.ads) type Task_Local_Storage is record Secondary_Stack : aliased Address; Overlaid_Allocation : Address; -- for System.Storage_Pools.Overlaps SEH : Address; -- Win32 only Machine_Occurrence : Unwind.Representation.Machine_Occurrence_Access; Secondary_Occurrence : aliased Unwind.Representation.Machine_Occurrence; Triggered_By_Abort : Boolean; No_Discrete_Value_Failure_Propagation : Boolean; Discrete_Value_Failure : Boolean; end record; pragma Suppress_Initialization (Task_Local_Storage); type Task_Local_Storage_Access is access all Task_Local_Storage; for Task_Local_Storage_Access'Storage_Size use 0; function Get_Environment_Task_Local_Storage return not null Task_Local_Storage_Access; type Get_Task_Local_Storage_Handler is access function return not null Task_Local_Storage_Access; pragma Favor_Top_Level (Get_Task_Local_Storage_Handler); Get_Task_Local_Storage_Hook : not null Get_Task_Local_Storage_Handler := Get_Environment_Task_Local_Storage'Access; function Get_Task_Local_Storage return not null Task_Local_Storage_Access; end System.Runtime_Context;
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Ada_Pretty.Joins is -------------- -- Document -- -------------- overriding function Document (Self : Join; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is pragma Unreferenced (Pad); Count : Positive := 1; Next : Node_Access := Self.Left; Max : Natural := Self.Right.Max_Pad; begin while Next.all in Join loop Count := Count + 1; Max := Natural'Max (Max, Join (Next.all).Right.Max_Pad); Next := Join (Next.all).Left; end loop; Max := Natural'Max (Max, Next.Max_Pad); declare List : Node_Access_Array (1 .. Count) := (others => Self.Right); begin List (Count) := Self.Right; Next := Self.Left; for J in reverse 1 .. Count - 1 loop List (J) := Join (Next.all).Right; Next := Join (Next.all).Left; end loop; return Next.Join (List, Max, Printer); end; end Document; -------------- -- New_Join -- -------------- function New_Join (Left : not null Node_Access; Right : not null Node_Access) return Node'Class is begin return Join'(Left, Right); end New_Join; end Ada_Pretty.Joins;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2020, Fabien Chouteau -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with AGATE.Traces_Output; use AGATE.Traces_Output; with AGATE.Timer; with AGATE_Types_Data.Traces; use AGATE_Types_Data.Traces; package body AGATE.Traces is Next_String_Token : String_Token := 0; Next_Wire_Token : Wire_Token := 0; Next_Reg_Token : Reg_Token := 0; Next_Event_Token : Event_Token := 0; Running_Task_Token : String_Token; Context_Switch_Token : Event_Token; Registration_Done : Boolean := False; procedure Initialize; procedure Put_Line (Str : String); procedure End_Of_Registration; function Timestamp (Now : Time := 0) return String; procedure Put_State_Change (Token : Reg_Token; Value : Word; Now : Time := 0); procedure Put_State_Change (Token : Wire_Token; Value : Boolean; Now : Time := 0); procedure Put_State_Change (Token : String_Token; Value : String; Now : Time := 0); procedure Put_State_Change (Token : Event_Token; Now : Time := 0); function Create return String_Token; function Create return Wire_Token; function Create return Reg_Token; function Create return Event_Token; function Image (Val : Natural) return String; function Image (Tok : String_Token) return String; function Image (Tok : Wire_Token) return String; function Image (Tok : Reg_Token) return String; function Image (Tok : Event_Token) return String; procedure Declare_Var (Tok : String_Token; Name : String); procedure Declare_Var (Tok : Wire_Token; Name : String); procedure Declare_Var (Tok : Reg_Token; Name : String); procedure Declare_Var (Tok : Event_Token; Name : String); function Clean (Name : String) return String; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Traces_Output.Initialize ("agate_traces.vcd"); Put_Line ("$timescale 1 us $end"); Put_Line ("$scope module AGATE $end"); Running_Task_Token := Create; Declare_Var (Running_Task_Token, "Running_Task"); Context_Switch_Token := Create; Declare_Var (Context_Switch_Token, "Context_Switch"); end Initialize; -------------- -- Put_Line -- -------------- procedure Put_Line (Str : String) is To_Put : constant String := Str & ASCII.CR & ASCII.LF; begin if Traces_Output.Write (To_Put (To_Put'First)'Address, To_Put'Length) /= To_Put'Length then raise Program_Error; end if; end Put_Line; ------------------------- -- End_Of_Registration -- ------------------------- procedure End_Of_Registration is begin Put_Line ("$upscope $end"); Put_Line ("$enddefinitions $end"); -- Print initial values for X in Wire_Token'First .. Next_Wire_Token - 1 loop Put_Line ("#0 0" & Image (X)); end loop; for X in Reg_Token'First .. Next_Reg_Token - 1 loop Put_Line ("#0 b0 " & Image (X)); end loop; Registration_Done := True; end End_Of_Registration; --------------- -- Timestamp -- --------------- function Timestamp (Now : Time := 0) return String is T : constant Time := (if Now /= 0 then Now else Timer.Clock); Img : constant String := T'Img; begin return "#" & Img (Img'First + 1 .. Img'Last); end Timestamp; ---------------------- -- Put_State_Change -- ---------------------- procedure Put_State_Change (Token : Reg_Token; Value : Word; Now : Time := 0) is Bin : String (1 .. 32); Val : Word := Value; begin if not Registration_Done then End_Of_Registration; end if; for C of reverse Bin loop C := (if (Val and 1) = 0 then '0' else '1'); Val := Shift_Right (Val, 1); end loop; -- TODO: print the boolean value of the integer (e.g. b100101) Put_Line (Timestamp (Now) & " b" & Bin & " " & Image (Token)); end Put_State_Change; ---------------------- -- Put_State_Change -- ---------------------- procedure Put_State_Change (Token : Wire_Token; Value : Boolean; Now : Time := 0) is begin if not Registration_Done then End_Of_Registration; end if; Put_Line (Timestamp (Now) & (if Value then " 1" else " 0") & Image (Token)); end Put_State_Change; ---------------------- -- Put_State_Change -- ---------------------- procedure Put_State_Change (Token : String_Token; Value : String; Now : Time := 0) is begin if not Registration_Done then End_Of_Registration; end if; Put_Line (Timestamp (Now) & " s" & Value & " " & Image (Token)); end Put_State_Change; ---------------------- -- Put_State_Change -- ---------------------- procedure Put_State_Change (Token : Event_Token; Now : Time := 0) is begin if not Registration_Done then End_Of_Registration; end if; Put_Line (Timestamp (Now) & " x" & Image (Token)); end Put_State_Change; ----------- -- Clean -- ----------- function Clean (Name : String) return String is Ret : String := Name; begin for C of Ret loop if C in ASCII.NUL .. ' ' then C := '_'; end if; end loop; return Ret; end Clean; ------------ -- Create -- ------------ function Create return String_Token is Ret : constant String_Token := Next_String_Token; begin Next_String_Token := Next_String_Token + 1; return Ret; end Create; ------------ -- Create -- ------------ function Create return Wire_Token is Ret : constant Wire_Token := Next_Wire_Token; begin Next_Wire_Token := Next_Wire_Token + 1; return Ret; end Create; ------------ -- Create -- ------------ function Create return Reg_Token is Ret : constant Reg_Token := Next_Reg_Token; begin Next_Reg_Token := Next_Reg_Token + 1; return Ret; end Create; ------------ -- Create -- ------------ function Create return Event_Token is Ret : constant Event_Token := Next_Event_Token; begin Next_Event_Token := Next_Event_Token + 1; return Ret; end Create; ----------- -- Image -- ----------- function Image (Val : Natural) return String is Ret : constant String := Val'Img; begin return Ret (Ret'First + 1 .. Ret'Last); end Image; ----------- -- Image -- ----------- function Image (Tok : String_Token) return String is ("s" & Image (Natural (Tok))); ----------- -- Image -- ----------- function Image (Tok : Wire_Token) return String is ("w" & Image (Natural (Tok))); ----------- -- Image -- ----------- function Image (Tok : Reg_Token) return String is ("r" & Image (Natural (Tok))); ----------- -- Image -- ----------- function Image (Tok : Event_Token) return String is ("e" & Image (Natural (Tok))); ----------------- -- Declare_Var -- ----------------- procedure Declare_Var (Tok : String_Token; Name : String) is begin Put_Line ("$var string 1 " & Image (Tok) & " " & Name & " $end"); end Declare_Var; ----------------- -- Declare_Var -- ----------------- procedure Declare_Var (Tok : Wire_Token; Name : String) is begin Put_Line ("$var wire 1 " & Image (Tok) & " " & Name & " $end"); end Declare_Var; ----------------- -- Declare_Var -- ----------------- procedure Declare_Var (Tok : Reg_Token; Name : String) is begin Put_Line ("$var reg 32 " & Image (Tok) & " " & Name & " $end"); end Declare_Var; ----------------- -- Declare_Var -- ----------------- procedure Declare_Var (Tok : Event_Token; Name : String) is begin Put_Line ("$var event 1 " & Image (Tok) & " " & Name & " $end"); end Declare_Var; -------------- -- Register -- -------------- procedure Register (ID : Task_ID; Name : String) is begin ID.Trace_Data.Running := Create; ID.Trace_Data.Status := Create; ID.Trace_Data.Prio := Create; Declare_Var (ID.Trace_Data.Running, Clean (Name)); Declare_Var (ID.Trace_Data.Status, Clean (Name) & "_Status"); Declare_Var (ID.Trace_Data.Prio, Clean (Name) & "_Priority"); end Register; ------------ -- Resume -- ------------ procedure Resume (ID : Task_ID) is begin Put_State_Change (ID.Trace_Data.Status, Clean (Image (ID.Status))); Put_State_Change (ID.Trace_Data.Prio, Word (ID.Current_Prio)); end Resume; ------------- -- Suspend -- ------------- procedure Suspend (ID : Task_ID) is begin Put_State_Change (ID.Trace_Data.Status, Clean (Image (ID.Status))); end Suspend; ----------- -- Fault -- ----------- procedure Fault (ID : Task_ID) is begin Put_State_Change (ID.Trace_Data.Status, Clean (Image (ID.Status))); end Fault; ------------- -- Running -- ------------- procedure Running (ID : Task_ID) is begin Put_State_Change (ID.Trace_Data.Status, Clean (Image (ID.Status))); end Running; --------------------- -- Change_Priority -- --------------------- procedure Change_Priority (ID : Task_ID; New_Prio : Internal_Task_Priority) is begin Put_State_Change (ID.Trace_Data.Prio, Word (New_Prio)); end Change_Priority; -------------------- -- Context_Switch -- -------------------- procedure Context_Switch (Old, Next : Task_ID) is Now : constant Time := Timer.Clock; begin Put_State_Change (Old.Trace_Data.Running, False, Now); Put_State_Change (Next.Trace_Data.Running, True, Now); Put_State_Change (Running_Task_Token, Clean (Next.Name), Now); Put_State_Change (Context_Switch_Token, Now); end Context_Switch; -------------- -- Register -- -------------- procedure Register (ID : Semaphore_ID; Name : String) is begin ID.Trace_Data.Token := Create; Declare_Var (ID.Trace_Data.Token, Clean (Name)); end Register; ------------------- -- Value_Changed -- ------------------- procedure Value_Changed (ID : Semaphore_ID; Count : Semaphore_Count; By : Task_ID) is pragma Unreferenced (By); begin Put_State_Change (ID.Trace_Data.Token, Word (Count)); end Value_Changed; -------------- -- Register -- -------------- procedure Register (ID : Mutex_ID; Name : String) is begin ID.Trace_Data.Token := Create; Declare_Var (ID.Trace_Data.Token, Clean (Name) & "_Owner"); end Register; ---------- -- Lock -- ---------- procedure Lock (ID : Mutex_ID; By : Task_ID) is begin Put_State_Change (ID.Trace_Data.Token, Clean (By.Name)); end Lock; ------------- -- Release -- ------------- procedure Release (ID : Mutex_ID; By : Task_ID) is pragma Unreferenced (By); begin Put_State_Change (ID.Trace_Data.Token, "unlocked"); end Release; -------------- -- Shutdown -- -------------- procedure Shutdown is begin Traces_Output.Finalize; end Shutdown; begin Initialize; end AGATE.Traces;
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . -- -- H A S H _ T A B L E S . G E N E R I C _ O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-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. -- -- -- -- 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. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ -- This body needs commenting ??? with Ada.Containers.Prime_Numbers; with Ada.Unchecked_Deallocation; with System; use type System.Address; package body Ada.Containers.Hash_Tables.Generic_Operations is procedure Free is new Ada.Unchecked_Deallocation (Buckets_Type, Buckets_Access); ------------ -- Adjust -- ------------ procedure Adjust (HT : in out Hash_Table_Type) is Src_Buckets : constant Buckets_Access := HT.Buckets; N : constant Count_Type := HT.Length; Src_Node : Node_Access; Dst_Prev : Node_Access; begin HT.Buckets := null; HT.Length := 0; if N = 0 then return; end if; HT.Buckets := new Buckets_Type (Src_Buckets'Range); -- TODO: allocate minimum size req'd. (See note below.) -- NOTE: see note below about these comments. -- Probably we have to duplicate the Size (Src), too, in order -- to guarantee that -- Dst := Src; -- Dst = Src is true -- The only quirk is that we depend on the hash value of a dst key -- to be the same as the src key from which it was copied. -- If we relax the requirement that the hash value must be the -- same, then of course we can't guarantee that following -- assignment that Dst = Src is true ??? -- -- NOTE: 17 Apr 2005 -- What I said above is no longer true. The semantics of (map) equality -- changed, such that we use key in the left map to look up the -- equivalent key in the right map, and then compare the elements (using -- normal equality) of the equivalent keys. So it doesn't matter that -- the maps have different capacities (i.e. the hash tables have -- different lengths), since we just look up the key, irrespective of -- its map's hash table length. All the RM says we're required to do -- it arrange for the target map to "=" the source map following an -- assignment (that is, following an Adjust), so it doesn't matter -- what the capacity of the target map is. What I'll probably do is -- allocate a new hash table that has the minimum size necessary, -- instead of allocating a new hash table whose size exactly matches -- that of the source. (See the assignment that immediately precedes -- these comments.) What we really need is a special Assign operation -- (not unlike what we have already for Vector) that allows the user to -- choose the capacity of the target. -- END NOTE. for Src_Index in Src_Buckets'Range loop Src_Node := Src_Buckets (Src_Index); if Src_Node /= null then declare Dst_Node : constant Node_Access := Copy_Node (Src_Node); -- See note above pragma Assert (Index (HT, Dst_Node) = Src_Index); begin HT.Buckets (Src_Index) := Dst_Node; HT.Length := HT.Length + 1; Dst_Prev := Dst_Node; end; Src_Node := Next (Src_Node); while Src_Node /= null loop declare Dst_Node : constant Node_Access := Copy_Node (Src_Node); -- See note above pragma Assert (Index (HT, Dst_Node) = Src_Index); begin Set_Next (Node => Dst_Prev, Next => Dst_Node); HT.Length := HT.Length + 1; Dst_Prev := Dst_Node; end; Src_Node := Next (Src_Node); end loop; end if; end loop; pragma Assert (HT.Length = N); end Adjust; -------------- -- Capacity -- -------------- function Capacity (HT : Hash_Table_Type) return Count_Type is begin if HT.Buckets = null then return 0; end if; return HT.Buckets'Length; end Capacity; ----------- -- Clear -- ----------- procedure Clear (HT : in out Hash_Table_Type) is Index : Hash_Type := 0; Node : Node_Access; begin if HT.Busy > 0 then raise Program_Error; end if; while HT.Length > 0 loop while HT.Buckets (Index) = null loop Index := Index + 1; end loop; declare Bucket : Node_Access renames HT.Buckets (Index); begin loop Node := Bucket; Bucket := Next (Bucket); HT.Length := HT.Length - 1; Free (Node); exit when Bucket = null; end loop; end; end loop; end Clear; --------------------------- -- Delete_Node_Sans_Free -- --------------------------- procedure Delete_Node_Sans_Free (HT : in out Hash_Table_Type; X : Node_Access) is pragma Assert (X /= null); Indx : Hash_Type; Prev : Node_Access; Curr : Node_Access; begin if HT.Length = 0 then raise Program_Error; end if; Indx := Index (HT, X); Prev := HT.Buckets (Indx); if Prev = null then raise Program_Error; end if; if Prev = X then HT.Buckets (Indx) := Next (Prev); HT.Length := HT.Length - 1; return; end if; if HT.Length = 1 then raise Program_Error; end if; loop Curr := Next (Prev); if Curr = null then raise Program_Error; end if; if Curr = X then Set_Next (Node => Prev, Next => Next (Curr)); HT.Length := HT.Length - 1; return; end if; Prev := Curr; end loop; end Delete_Node_Sans_Free; -------------- -- Finalize -- -------------- procedure Finalize (HT : in out Hash_Table_Type) is begin Clear (HT); Free (HT.Buckets); end Finalize; ----------- -- First -- ----------- function First (HT : Hash_Table_Type) return Node_Access is Indx : Hash_Type; begin if HT.Length = 0 then return null; end if; Indx := HT.Buckets'First; loop if HT.Buckets (Indx) /= null then return HT.Buckets (Indx); end if; Indx := Indx + 1; end loop; end First; --------------------- -- Free_Hash_Table -- --------------------- procedure Free_Hash_Table (Buckets : in out Buckets_Access) is Node : Node_Access; begin if Buckets = null then return; end if; for J in Buckets'Range loop while Buckets (J) /= null loop Node := Buckets (J); Buckets (J) := Next (Node); Free (Node); end loop; end loop; Free (Buckets); end Free_Hash_Table; ------------------- -- Generic_Equal -- ------------------- function Generic_Equal (L, R : Hash_Table_Type) return Boolean is L_Index : Hash_Type; L_Node : Node_Access; N : Count_Type; begin if L'Address = R'Address then return True; end if; if L.Length /= R.Length then return False; end if; if L.Length = 0 then return True; end if; L_Index := 0; loop L_Node := L.Buckets (L_Index); exit when L_Node /= null; L_Index := L_Index + 1; end loop; N := L.Length; loop if not Find (HT => R, Key => L_Node) then return False; end if; N := N - 1; L_Node := Next (L_Node); if L_Node = null then if N = 0 then return True; end if; loop L_Index := L_Index + 1; L_Node := L.Buckets (L_Index); exit when L_Node /= null; end loop; end if; end loop; end Generic_Equal; ----------------------- -- Generic_Iteration -- ----------------------- procedure Generic_Iteration (HT : Hash_Table_Type) is Busy : Natural renames HT'Unrestricted_Access.all.Busy; begin if HT.Length = 0 then return; end if; Busy := Busy + 1; declare Node : Node_Access; begin for Indx in HT.Buckets'Range loop Node := HT.Buckets (Indx); while Node /= null loop Process (Node); Node := Next (Node); end loop; end loop; exception when others => Busy := Busy - 1; raise; end; Busy := Busy - 1; end Generic_Iteration; ------------------ -- Generic_Read -- ------------------ procedure Generic_Read (Stream : access Root_Stream_Type'Class; HT : out Hash_Table_Type) is X, Y : Node_Access; Last, I : Hash_Type; N, M : Count_Type'Base; begin Clear (HT); Hash_Type'Read (Stream, Last); Count_Type'Base'Read (Stream, N); pragma Assert (N >= 0); if N = 0 then return; end if; if HT.Buckets = null or else HT.Buckets'Last /= Last then Free (HT.Buckets); HT.Buckets := new Buckets_Type (0 .. Last); end if; -- TODO: should we rewrite this algorithm so that it doesn't -- depend on preserving the exactly length of the hash table -- array? We would prefer to not have to (re)allocate a -- buckets array (the array that HT already has might be large -- enough), and to not have to stream the count of the number -- of nodes in each bucket. The algorithm below is vestigial, -- as it was written prior to the meeting in Palma, when the -- semantics of equality were changed (and which obviated the -- need to preserve the hash table length). loop Hash_Type'Read (Stream, I); pragma Assert (I in HT.Buckets'Range); pragma Assert (HT.Buckets (I) = null); Count_Type'Base'Read (Stream, M); pragma Assert (M >= 1); pragma Assert (M <= N); HT.Buckets (I) := New_Node (Stream); pragma Assert (HT.Buckets (I) /= null); pragma Assert (Next (HT.Buckets (I)) = null); Y := HT.Buckets (I); HT.Length := HT.Length + 1; for J in Count_Type range 2 .. M loop X := New_Node (Stream); pragma Assert (X /= null); pragma Assert (Next (X) = null); Set_Next (Node => Y, Next => X); Y := X; HT.Length := HT.Length + 1; end loop; N := N - M; exit when N = 0; end loop; end Generic_Read; ------------------- -- Generic_Write -- ------------------- procedure Generic_Write (Stream : access Root_Stream_Type'Class; HT : Hash_Table_Type) is M : Count_Type'Base; X : Node_Access; begin if HT.Buckets = null then Hash_Type'Write (Stream, 0); else Hash_Type'Write (Stream, HT.Buckets'Last); end if; Count_Type'Base'Write (Stream, HT.Length); if HT.Length = 0 then return; end if; -- TODO: see note in Generic_Read??? for Indx in HT.Buckets'Range loop X := HT.Buckets (Indx); if X /= null then M := 1; loop X := Next (X); exit when X = null; M := M + 1; end loop; Hash_Type'Write (Stream, Indx); Count_Type'Base'Write (Stream, M); X := HT.Buckets (Indx); for J in Count_Type range 1 .. M loop Write (Stream, X); X := Next (X); end loop; pragma Assert (X = null); end if; end loop; end Generic_Write; ----------- -- Index -- ----------- function Index (Buckets : Buckets_Type; Node : Node_Access) return Hash_Type is begin return Hash_Node (Node) mod Buckets'Length; end Index; function Index (Hash_Table : Hash_Table_Type; Node : Node_Access) return Hash_Type is begin return Index (Hash_Table.Buckets.all, Node); end Index; ---------- -- Move -- ---------- procedure Move (Target, Source : in out Hash_Table_Type) is begin if Target'Address = Source'Address then return; end if; if Source.Busy > 0 then raise Program_Error; end if; Clear (Target); declare Buckets : constant Buckets_Access := Target.Buckets; begin Target.Buckets := Source.Buckets; Source.Buckets := Buckets; end; Target.Length := Source.Length; Source.Length := 0; end Move; ---------- -- Next -- ---------- function Next (HT : Hash_Table_Type; Node : Node_Access) return Node_Access is Result : Node_Access := Next (Node); begin if Result /= null then return Result; end if; for Indx in Index (HT, Node) + 1 .. HT.Buckets'Last loop Result := HT.Buckets (Indx); if Result /= null then return Result; end if; end loop; return null; end Next; ---------------------- -- Reserve_Capacity -- ---------------------- procedure Reserve_Capacity (HT : in out Hash_Table_Type; N : Count_Type) is NN : Hash_Type; begin if HT.Buckets = null then if N > 0 then NN := Prime_Numbers.To_Prime (N); HT.Buckets := new Buckets_Type (0 .. NN - 1); end if; return; end if; if HT.Length = 0 then if N = 0 then Free (HT.Buckets); return; end if; if N = HT.Buckets'Length then return; end if; NN := Prime_Numbers.To_Prime (N); if NN = HT.Buckets'Length then return; end if; declare X : Buckets_Access := HT.Buckets; begin HT.Buckets := new Buckets_Type (0 .. NN - 1); Free (X); end; return; end if; if N = HT.Buckets'Length then return; end if; if N < HT.Buckets'Length then if HT.Length >= HT.Buckets'Length then return; end if; NN := Prime_Numbers.To_Prime (HT.Length); if NN >= HT.Buckets'Length then return; end if; else NN := Prime_Numbers.To_Prime (Count_Type'Max (N, HT.Length)); if NN = HT.Buckets'Length then -- can't expand any more return; end if; end if; if HT.Busy > 0 then raise Program_Error; end if; Rehash : declare Dst_Buckets : Buckets_Access := new Buckets_Type (0 .. NN - 1); Src_Buckets : Buckets_Access := HT.Buckets; L : Count_Type renames HT.Length; LL : constant Count_Type := L; Src_Index : Hash_Type := Src_Buckets'First; begin while L > 0 loop declare Src_Bucket : Node_Access renames Src_Buckets (Src_Index); begin while Src_Bucket /= null loop declare Src_Node : constant Node_Access := Src_Bucket; Dst_Index : constant Hash_Type := Index (Dst_Buckets.all, Src_Node); Dst_Bucket : Node_Access renames Dst_Buckets (Dst_Index); begin Src_Bucket := Next (Src_Node); Set_Next (Src_Node, Dst_Bucket); Dst_Bucket := Src_Node; end; pragma Assert (L > 0); L := L - 1; end loop; exception when others => -- If there's an error computing a hash value during a -- rehash, then AI-302 says the nodes "become lost." The -- issue is whether to actually deallocate these lost nodes, -- since they might be designated by extant cursors. Here -- we decide to deallocate the nodes, since it's better to -- solve real problems (storage consumption) rather than -- imaginary ones (the user might, or might not, dereference -- a cursor designating a node that has been deallocated), -- and because we have a way to vet a dangling cursor -- reference anyway, and hence can actually detect the -- problem. for Dst_Index in Dst_Buckets'Range loop declare B : Node_Access renames Dst_Buckets (Dst_Index); X : Node_Access; begin while B /= null loop X := B; B := Next (X); Free (X); end loop; end; end loop; Free (Dst_Buckets); raise Program_Error; end; Src_Index := Src_Index + 1; end loop; HT.Buckets := Dst_Buckets; HT.Length := LL; Free (Src_Buckets); end Rehash; end Reserve_Capacity; end Ada.Containers.Hash_Tables.Generic_Operations;
-- nymph.ada - Package file for the NymphRPC package. -- -- Revision 0 -- -- 2018/09/24, Maya Posch package NymphClient is -- end NymphClient;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_adc.c -- -- @author MCD Application Team -- -- @version V1.3.1 -- -- @date 25-March-2015 -- -- @brief Header file of ADC HAL module. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ with STM32_SVD.ADC; use STM32_SVD.ADC; package body STM32.ADC is procedure Set_Sequence_Position (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Rank : Regular_Channel_Rank) with Inline; procedure Set_Sampling_Time (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Sample_Time : Channel_Sampling_Times) with Inline; procedure Set_Injected_Channel_Sequence_Position (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Rank : Injected_Channel_Rank) with Inline; procedure Set_Injected_Channel_Offset (This : in out Analog_To_Digital_Converter; Rank : Injected_Channel_Rank; Offset : Injected_Data_Offset) with Inline; ------------ -- Enable -- ------------ procedure Enable (This : in out Analog_To_Digital_Converter) is begin if not This.CR2.ADON then This.CR2.ADON := True; delay until Clock + ADC_Stabilization; end if; end Enable; ------------- -- Disable -- ------------- procedure Disable (This : in out Analog_To_Digital_Converter) is begin This.CR2.ADON := False; end Disable; ------------- -- Enabled -- ------------- function Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR2.ADON); ---------------------- -- Conversion_Value -- ---------------------- function Conversion_Value (This : Analog_To_Digital_Converter) return UInt16 is begin return This.DR.DATA; end Conversion_Value; --------------------------- -- Data_Register_Address -- --------------------------- function Data_Register_Address (This : Analog_To_Digital_Converter) return System.Address is (This.DR'Address); ------------------------------- -- Injected_Conversion_Value -- ------------------------------- function Injected_Conversion_Value (This : Analog_To_Digital_Converter; Rank : Injected_Channel_Rank) return UInt16 is begin case Rank is when 1 => return This.JDR1.JDATA; when 2 => return This.JDR2.JDATA; when 3 => return This.JDR3.JDATA; when 4 => return This.JDR4.JDATA; end case; end Injected_Conversion_Value; -------------------------------- -- Multimode_Conversion_Value -- -------------------------------- function Multimode_Conversion_Value return UInt32 is (C_ADC_Periph.CDR.Val); -------------------- -- Configure_Unit -- -------------------- procedure Configure_Unit (This : in out Analog_To_Digital_Converter; Resolution : ADC_Resolution; Alignment : Data_Alignment) is begin This.CR1.RES := ADC_Resolution'Enum_Rep (Resolution); This.CR2.ALIGN := Alignment = Left_Aligned; end Configure_Unit; ------------------------ -- Current_Resolution -- ------------------------ function Current_Resolution (This : Analog_To_Digital_Converter) return ADC_Resolution is (ADC_Resolution'Val (This.CR1.RES)); ----------------------- -- Current_Alignment -- ----------------------- function Current_Alignment (This : Analog_To_Digital_Converter) return Data_Alignment is ((if This.CR2.ALIGN then Left_Aligned else Right_Aligned)); --------------------------------- -- Configure_Common_Properties -- --------------------------------- procedure Configure_Common_Properties (Mode : Multi_ADC_Mode_Selections; Prescalar : ADC_Prescalars; DMA_Mode : Multi_ADC_DMA_Modes; Sampling_Delay : Sampling_Delay_Selections) is begin C_ADC_Periph.CCR.MULT := Multi_ADC_Mode_Selections'Enum_Rep (Mode); C_ADC_Periph.CCR.DELAY_k := Sampling_Delay_Selections'Enum_Rep (Sampling_Delay); C_ADC_Periph.CCR.DMA := Multi_ADC_DMA_Modes'Enum_Rep (DMA_Mode); C_ADC_Periph.CCR.ADCPRE := ADC_Prescalars'Enum_Rep (Prescalar); end Configure_Common_Properties; ----------------------------------- -- Configure_Regular_Conversions -- ----------------------------------- procedure Configure_Regular_Conversions (This : in out Analog_To_Digital_Converter; Continuous : Boolean; Trigger : Regular_Channel_Conversion_Trigger; Enable_EOC : Boolean; Conversions : Regular_Channel_Conversions) is begin This.CR2.EOCS := Enable_EOC; This.CR2.CONT := Continuous; This.CR1.SCAN := Conversions'Length > 1; if Trigger.Enabler /= Trigger_Disabled then This.CR2.EXTSEL := External_Events_Regular_Group'Enum_Rep (Trigger.Event); This.CR2.EXTEN := External_Trigger'Enum_Rep (Trigger.Enabler); else This.CR2.EXTSEL := 0; This.CR2.EXTEN := 0; end if; for Rank in Conversions'Range loop declare Conversion : Regular_Channel_Conversion renames Conversions (Rank); begin Configure_Regular_Channel (This, Conversion.Channel, Rank, Conversion.Sample_Time); -- We check the VBat first because that channel is also used for -- the temperature sensor channel on some MCUs, in which case the -- VBat conversion is the only one done. This order reflects that -- hardware behavior. if VBat_Conversion (This, Conversion.Channel) then Enable_VBat_Connection; elsif VRef_TemperatureSensor_Conversion (This, Conversion.Channel) then Enable_VRef_TemperatureSensor_Connection; end if; end; end loop; This.SQR1.L := UInt4 (Conversions'Length - 1); -- biased rep end Configure_Regular_Conversions; ------------------------------------ -- Configure_Injected_Conversions -- ------------------------------------ procedure Configure_Injected_Conversions (This : in out Analog_To_Digital_Converter; AutoInjection : Boolean; Trigger : Injected_Channel_Conversion_Trigger; Enable_EOC : Boolean; Conversions : Injected_Channel_Conversions) is begin This.CR2.EOCS := Enable_EOC; -- Injected channels cannot be converted continuously. The only -- exception is when an injected channel is configured to be converted -- automatically after regular channels in continuous mode. See note in -- RM 13.3.5, pg 390, and "Auto-injection" section on pg 392. This.CR1.JAUTO := AutoInjection; if Trigger.Enabler /= Trigger_Disabled then This.CR2.JEXTEN := External_Trigger'Enum_Rep (Trigger.Enabler); This.CR2.JEXTSEL := External_Events_Injected_Group'Enum_Rep (Trigger.Event); else This.CR2.JEXTEN := 0; This.CR2.JEXTSEL := 0; end if; for Rank in Conversions'Range loop declare Conversion : Injected_Channel_Conversion renames Conversions (Rank); begin Configure_Injected_Channel (This, Conversion.Channel, Rank, Conversion.Sample_Time, Conversion.Offset); -- We check the VBat first because that channel is also used for -- the temperature sensor channel on some MCUs, in which case the -- VBat conversion is the only one done. This order reflects that -- hardware behavior. if VBat_Conversion (This, Conversion.Channel) then Enable_VBat_Connection; elsif VRef_TemperatureSensor_Conversion (This, Conversion.Channel) then Enable_VRef_TemperatureSensor_Connection; end if; end; end loop; This.JSQR.JL := UInt2 (Conversions'Length - 1); -- biased rep end Configure_Injected_Conversions; ---------------------------- -- Enable_VBat_Connection -- ---------------------------- procedure Enable_VBat_Connection is begin C_ADC_Periph.CCR.VBATE := True; end Enable_VBat_Connection; ------------------ -- VBat_Enabled -- ------------------ function VBat_Enabled return Boolean is (C_ADC_Periph.CCR.VBATE); ---------------------------------------------- -- Enable_VRef_TemperatureSensor_Connection -- ---------------------------------------------- procedure Enable_VRef_TemperatureSensor_Connection is begin C_ADC_Periph.CCR.TSVREFE := True; delay until Clock + Temperature_Sensor_Stabilization; end Enable_VRef_TemperatureSensor_Connection; -------------------------------------- -- VRef_TemperatureSensor_Connected -- -------------------------------------- function VRef_TemperatureSensor_Enabled return Boolean is (C_ADC_Periph.CCR.TSVREFE); ---------------------------------- -- Regular_Conversions_Expected -- ---------------------------------- function Regular_Conversions_Expected (This : Analog_To_Digital_Converter) return Natural is (Natural (This.SQR1.L) + 1); ----------------------------------- -- Injected_Conversions_Expected -- ----------------------------------- function Injected_Conversions_Expected (This : Analog_To_Digital_Converter) return Natural is (Natural (This.JSQR.JL) + 1); ----------------------- -- Scan_Mode_Enabled -- ----------------------- function Scan_Mode_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR1.SCAN); --------------------------- -- EOC_Selection_Enabled -- --------------------------- function EOC_Selection_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR2.EOCS); ------------------------------- -- Configure_Regular_Channel -- ------------------------------- procedure Configure_Regular_Channel (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Rank : Regular_Channel_Rank; Sample_Time : Channel_Sampling_Times) is begin Set_Sampling_Time (This, Channel, Sample_Time); Set_Sequence_Position (This, Channel, Rank); end Configure_Regular_Channel; -------------------------------- -- Configure_Injected_Channel -- -------------------------------- procedure Configure_Injected_Channel (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Rank : Injected_Channel_Rank; Sample_Time : Channel_Sampling_Times; Offset : Injected_Data_Offset) is begin Set_Sampling_Time (This, Channel, Sample_Time); Set_Injected_Channel_Sequence_Position (This, Channel, Rank); Set_Injected_Channel_Offset (This, Rank, Offset); end Configure_Injected_Channel; ---------------------- -- Start_Conversion -- ---------------------- procedure Start_Conversion (This : in out Analog_To_Digital_Converter) is begin if External_Trigger'Val (This.CR2.EXTEN) /= Trigger_Disabled then return; end if; if Multi_ADC_Mode_Selections'Val (C_ADC_Periph.CCR.MULT) = Independent or else This'Address = STM32_SVD.ADC1_Base then This.CR2.SWSTART := True; end if; end Start_Conversion; ------------------------ -- Conversion_Started -- ------------------------ function Conversion_Started (This : Analog_To_Digital_Converter) return Boolean is (This.CR2.SWSTART); ------------------------------- -- Start_Injected_Conversion -- ------------------------------- procedure Start_Injected_Conversion (This : in out Analog_To_Digital_Converter) is begin This.CR2.JSWSTART := True; end Start_Injected_Conversion; --------------------------------- -- Injected_Conversion_Started -- --------------------------------- function Injected_Conversion_Started (This : Analog_To_Digital_Converter) return Boolean is (This.CR2.JSWSTART); ------------------------------ -- Watchdog_Enable_Channels -- ------------------------------ procedure Watchdog_Enable_Channels (This : in out Analog_To_Digital_Converter; Mode : Multiple_Channels_Watchdog; Low : Watchdog_Threshold; High : Watchdog_Threshold) is begin This.HTR.HT := High; This.LTR.LT := Low; -- see RM 13.3.7, pg 391, table 66 case Mode is when Watchdog_All_Regular_Channels => This.CR1.AWDEN := True; when Watchdog_All_Injected_Channels => This.CR1.JAWDEN := True; when Watchdog_All_Both_Kinds => This.CR1.AWDEN := True; This.CR1.JAWDEN := True; end case; end Watchdog_Enable_Channels; ----------------------------- -- Watchdog_Enable_Channel -- ----------------------------- procedure Watchdog_Enable_Channel (This : in out Analog_To_Digital_Converter; Mode : Single_Channel_Watchdog; Channel : Analog_Input_Channel; Low : Watchdog_Threshold; High : Watchdog_Threshold) is begin This.HTR.HT := High; This.LTR.LT := Low; -- Set then channel This.CR1.AWDCH := Channel; -- Enable single channel mode This.CR1.AWDSGL := True; case Mode is when Watchdog_Single_Regular_Channel => This.CR1.AWDEN := True; when Watchdog_Single_Injected_Channel => This.CR1.JAWDEN := True; when Watchdog_Single_Both_Kinds => This.CR1.AWDEN := True; This.CR1.JAWDEN := True; end case; end Watchdog_Enable_Channel; ---------------------- -- Watchdog_Disable -- ---------------------- procedure Watchdog_Disable (This : in out Analog_To_Digital_Converter) is begin This.CR1.AWDEN := False; This.CR1.JAWDEN := False; -- clearing the single-channel bit (AWGSDL) is not required to disable, -- per the RM table 66, section 13.3.7, pg 391, but seems cleanest This.CR1.AWDSGL := False; end Watchdog_Disable; ---------------------- -- Watchdog_Enabled -- ---------------------- function Watchdog_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR1.AWDEN or This.CR1.JAWDEN); -- per the RM table 66, section 13.3.7, pg 391 ------------------------------- -- Enable_Discontinuous_Mode -- ------------------------------- procedure Enable_Discontinuous_Mode (This : in out Analog_To_Digital_Converter; Regular : Boolean; -- if False, enabling for Injected channels Count : Discontinuous_Mode_Channel_Count) is begin if Regular then This.CR1.JDISCEN := False; This.CR1.DISCEN := True; else -- Injected This.CR1.DISCEN := False; This.CR1.JDISCEN := True; end if; This.CR1.DISCNUM := UInt3 (Count - 1); -- biased end Enable_Discontinuous_Mode; ---------------------------------------- -- Disable_Discontinuous_Mode_Regular -- --------------------------------------- procedure Disable_Discontinuous_Mode_Regular (This : in out Analog_To_Digital_Converter) is begin This.CR1.DISCEN := False; end Disable_Discontinuous_Mode_Regular; ----------------------------------------- -- Disable_Discontinuous_Mode_Injected -- ----------------------------------------- procedure Disable_Discontinuous_Mode_Injected (This : in out Analog_To_Digital_Converter) is begin This.CR1.JDISCEN := False; end Disable_Discontinuous_Mode_Injected; ---------------------------------------- -- Discontinuous_Mode_Regular_Enabled -- ---------------------------------------- function Discontinuous_Mode_Regular_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR1.DISCEN); ----------------------------------------- -- Discontinuous_Mode_Injected_Enabled -- ----------------------------------------- function Discontinuous_Mode_Injected_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR1.JDISCEN); --------------------------- -- AutoInjection_Enabled -- --------------------------- function AutoInjection_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR1.JAUTO); ---------------- -- Enable_DMA -- ---------------- procedure Enable_DMA (This : in out Analog_To_Digital_Converter) is begin This.CR2.DMA := True; end Enable_DMA; ----------------- -- Disable_DMA -- ----------------- procedure Disable_DMA (This : in out Analog_To_Digital_Converter) is begin This.CR2.DMA := False; end Disable_DMA; ----------------- -- DMA_Enabled -- ----------------- function DMA_Enabled (This : Analog_To_Digital_Converter) return Boolean is (This.CR2.DMA); ------------------------------------ -- Enable_DMA_After_Last_Transfer -- ------------------------------------ procedure Enable_DMA_After_Last_Transfer (This : in out Analog_To_Digital_Converter) is begin This.CR2.DDS := True; end Enable_DMA_After_Last_Transfer; ------------------------------------- -- Disable_DMA_After_Last_Transfer -- ------------------------------------- procedure Disable_DMA_After_Last_Transfer (This : in out Analog_To_Digital_Converter) is begin This.CR2.DDS := False; end Disable_DMA_After_Last_Transfer; ------------------------------------- -- DMA_Enabled_After_Last_Transfer -- ------------------------------------- function DMA_Enabled_After_Last_Transfer (This : Analog_To_Digital_Converter) return Boolean is (This.CR2.DDS); ------------------------------------------ -- Multi_Enable_DMA_After_Last_Transfer -- ------------------------------------------ procedure Multi_Enable_DMA_After_Last_Transfer is begin C_ADC_Periph.CCR.DMA := 1; end Multi_Enable_DMA_After_Last_Transfer; ------------------------------------------- -- Multi_Disable_DMA_After_Last_Transfer -- ------------------------------------------- procedure Multi_Disable_DMA_After_Last_Transfer is begin C_ADC_Periph.CCR.DMA := 0; end Multi_Disable_DMA_After_Last_Transfer; ------------------------------------------- -- Multi_DMA_Enabled_After_Last_Transfer -- ------------------------------------------- function Multi_DMA_Enabled_After_Last_Transfer return Boolean is (C_ADC_Periph.CCR.DMA = 1); --------------------- -- Poll_For_Status -- --------------------- procedure Poll_For_Status (This : in out Analog_To_Digital_Converter; Flag : ADC_Status_Flag; Success : out Boolean; Timeout : Time_Span := Time_Span_Last) is Deadline : constant Time := Clock + Timeout; begin Success := False; while Clock < Deadline loop if Status (This, Flag) then Success := True; exit; end if; end loop; end Poll_For_Status; ------------ -- Status -- ------------ function Status (This : Analog_To_Digital_Converter; Flag : ADC_Status_Flag) return Boolean is begin case Flag is when Overrun => return This.SR.OVR; when Regular_Channel_Conversion_Started => return This.SR.STRT; when Injected_Channel_Conversion_Started => return This.SR.JSTRT; when Injected_Channel_Conversion_Complete => return This.SR.JEOC; when Regular_Channel_Conversion_Complete => return This.SR.EOC; when Analog_Watchdog_Event_Occurred => return This.SR.AWD; end case; end Status; ------------------ -- Clear_Status -- ------------------ procedure Clear_Status (This : in out Analog_To_Digital_Converter; Flag : ADC_Status_Flag) is begin case Flag is when Overrun => This.SR.OVR := False; when Regular_Channel_Conversion_Started => This.SR.STRT := False; when Injected_Channel_Conversion_Started => This.SR.JSTRT := False; when Injected_Channel_Conversion_Complete => This.SR.JEOC := False; when Regular_Channel_Conversion_Complete => This.SR.EOC := False; when Analog_Watchdog_Event_Occurred => This.SR.AWD := False; end case; end Clear_Status; ----------------------- -- Enable_Interrupts -- ----------------------- procedure Enable_Interrupts (This : in out Analog_To_Digital_Converter; Source : ADC_Interrupts) is begin case Source is when Overrun => This.CR1.OVRIE := True; when Injected_Channel_Conversion_Complete => This.CR1.JEOCIE := True; when Regular_Channel_Conversion_Complete => This.CR1.EOCIE := True; when Analog_Watchdog_Event => This.CR1.AWDIE := True; end case; end Enable_Interrupts; ----------------------- -- Interrupt_Enabled -- ----------------------- function Interrupt_Enabled (This : Analog_To_Digital_Converter; Source : ADC_Interrupts) return Boolean is begin case Source is when Overrun => return This.CR1.OVRIE; when Injected_Channel_Conversion_Complete => return This.CR1.JEOCIE; when Regular_Channel_Conversion_Complete => return This.CR1.EOCIE; when Analog_Watchdog_Event => return This.CR1.AWDIE; end case; end Interrupt_Enabled; ------------------------ -- Disable_Interrupts -- ------------------------ procedure Disable_Interrupts (This : in out Analog_To_Digital_Converter; Source : ADC_Interrupts) is begin case Source is when Overrun => This.CR1.OVRIE := False; when Injected_Channel_Conversion_Complete => This.CR1.JEOCIE := False; when Regular_Channel_Conversion_Complete => This.CR1.EOCIE := False; when Analog_Watchdog_Event => This.CR1.AWDIE := False; end case; end Disable_Interrupts; ----------------------------- -- Clear_Interrupt_Pending -- ----------------------------- procedure Clear_Interrupt_Pending (This : in out Analog_To_Digital_Converter; Source : ADC_Interrupts) is begin case Source is when Overrun => This.SR.OVR := False; when Injected_Channel_Conversion_Complete => This.SR.JEOC := False; when Regular_Channel_Conversion_Complete => This.SR.EOC := False; when Analog_Watchdog_Event => This.SR.AWD := False; end case; end Clear_Interrupt_Pending; --------------------------- -- Set_Sequence_Position -- --------------------------- procedure Set_Sequence_Position (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Rank : Regular_Channel_Rank) is begin case Rank is when 1 .. 6 => This.SQR3.SQ.Arr (Integer (Rank)) := Channel; when 7 .. 12 => This.SQR2.SQ.Arr (Integer (Rank)) := Channel; when 13 .. 16 => This.SQR1.SQ.Arr (Integer (Rank)) := Channel; end case; end Set_Sequence_Position; -------------------------------------------- -- Set_Injected_Channel_Sequence_Position -- -------------------------------------------- procedure Set_Injected_Channel_Sequence_Position (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Rank : Injected_Channel_Rank) is begin This.JSQR.JSQ.Arr (Integer (Rank)) := Channel; end Set_Injected_Channel_Sequence_Position; ----------------------- -- Set_Sampling_Time -- ----------------------- procedure Set_Sampling_Time (This : in out Analog_To_Digital_Converter; Channel : Analog_Input_Channel; Sample_Time : Channel_Sampling_Times) is begin if Channel > 9 then This.SMPR1.SMP.Arr (Natural (Channel)) := Channel_Sampling_Times'Enum_Rep (Sample_Time); else This.SMPR2.SMP.Arr (Natural (Channel)) := Channel_Sampling_Times'Enum_Rep (Sample_Time); end if; end Set_Sampling_Time; --------------------------------- -- Set_Injected_Channel_Offset -- --------------------------------- procedure Set_Injected_Channel_Offset (This : in out Analog_To_Digital_Converter; Rank : Injected_Channel_Rank; Offset : Injected_Data_Offset) is begin case Rank is when 1 => This.JOFR1.JOFFSET1 := Offset; when 2 => This.JOFR2.JOFFSET2 := Offset; when 3 => This.JOFR3.JOFFSET3 := Offset; when 4 => This.JOFR4.JOFFSET4 := Offset; end case; end Set_Injected_Channel_Offset; end STM32.ADC;
package body impact.d2.Shape is function getKind (Self : in b2Shape'Class) return shape.Kind is begin return self.m_Kind; end getKind; end impact.d2.Shape;
-- Copyright 2017-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 DOM.Core; use DOM.Core; -- ****h* Bases/BSaveLoad -- FUNCTION -- Provide code to save and load sky bases data from file -- SOURCE package Bases.SaveLoad is -- **** -- ****f* BSaveLoad/BSaveLoad.SaveBases -- FUNCTION -- Save bases from current game in file -- PARAMETERS -- SaveData - XML structure to which sky bases data will be saved -- MainNode - XML main node to which sky bases data will be saved -- SOURCE procedure SaveBases (SaveData: not null Document; MainNode: not null DOM.Core.Element); -- **** -- ****f* BSaveLoad/BSaveLoad.LoadBases -- FUNCTION -- Load bases from file -- PARAMETERS -- SaveData - XML structure from which sky bases data will be loaded -- SOURCE procedure LoadBases(SaveData: not null Document) with Post => (for all I in Sky_Bases'Range => Sky_Bases(I).Name /= Null_Unbounded_String); -- **** end Bases.SaveLoad;
----------------------------------------------------------------------- -- applications.views -- Ada Web Application -- Copyright (C) 2009, 2010, 2011, 2012, 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 Util.Locales; with ASF.Components.Root; with ASF.Contexts.Faces; with ASF.Views.Facelets; with ASF.Factory; with Ada.Strings.Unbounded; package ASF.Applications.Views is No_View : exception; type Local_Array_Access is access Util.Locales.Locale_Array; -- ------------------------------ -- View Handler -- ------------------------------ -- The view handler manages the component tree, the request processing -- life cycle and rendering the result view. type View_Handler is tagged limited private; type View_Handler_Access is access all View_Handler'Class; -- Initialize the view handler. procedure Initialize (Handler : out View_Handler; Components : access ASF.Factory.Component_Factory; Conf : in Config); -- Restore the view identified by the given name in the faces context -- and create the component tree representing that view. procedure Restore_View (Handler : in out View_Handler; Name : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class; View : out ASF.Components.Root.UIViewRoot; Ignore : in Boolean := False); -- Create a new UIViewRoot instance initialized from the context and with -- the view identifier. If the view is a valid view, create the component tree -- representing that view. procedure Create_View (Handler : in out View_Handler; Name : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class; View : out ASF.Components.Root.UIViewRoot; Ignore : in Boolean := False); -- Render the view represented by the component tree. The view is -- rendered using the context. procedure Render_View (Handler : in out View_Handler; Context : in out ASF.Contexts.Faces.Faces_Context'Class; View : in ASF.Components.Root.UIViewRoot); -- Compute the locale that must be used according to the <b>Accept-Language</b> request -- header and the application supported locales. function Calculate_Locale (Handler : in View_Handler; Context : in ASF.Contexts.Faces.Faces_Context'Class) return Util.Locales.Locale; -- Get the URL suitable for encoding and rendering the view specified by the <b>View</b> -- identifier. function Get_Action_URL (Handler : in View_Handler; Context : in ASF.Contexts.Faces.Faces_Context'Class; View : in String) return String; -- Get the URL for redirecting the user to the specified view. function Get_Redirect_URL (Handler : in View_Handler; Context : in ASF.Contexts.Faces.Faces_Context'Class; View : in String) return String; -- Closes the view handler procedure Close (Handler : in out View_Handler); -- Set the extension mapping rule to find the facelet file from -- the name. procedure Set_Extension_Mapping (Handler : in out View_Handler; From : in String; Into : in String); -- Get the facelet name from the view name. function Get_Facelet_Name (Handler : in View_Handler; Name : in String) return String; -- Register a module -- procedure Register_Module (Handler : in out View_Handler; -- Module : in ASF.Modules.Module_Access); private type View_Handler is tagged limited record Facelets : aliased ASF.Views.Facelets.Facelet_Factory; Paths : Ada.Strings.Unbounded.Unbounded_String; View_Ext : Ada.Strings.Unbounded.Unbounded_String; File_Ext : Ada.Strings.Unbounded.Unbounded_String; Locales : Local_Array_Access := null; end record; end ASF.Applications.Views;
with Tkmrpc.Types; package Tkmrpc.Contexts.esa is type esa_State_Type is (clean, -- Initial clean state. invalid, -- Error state. stale, -- ESA context is stale. selected, -- ESA is selected. active -- ESP SA is active. ); function Get_State (Id : Types.esa_id_type) return esa_State_Type with Pre => Is_Valid (Id); function Is_Valid (Id : Types.esa_id_type) return Boolean; -- Returns True if the given id has a valid value. function Has_ae_id (Id : Types.esa_id_type; ae_id : Types.ae_id_type) return Boolean with Pre => Is_Valid (Id); -- Returns True if the context specified by id has the given -- ae_id value. function Has_ea_id (Id : Types.esa_id_type; ea_id : Types.ea_id_type) return Boolean with Pre => Is_Valid (Id); -- Returns True if the context specified by id has the given -- ea_id value. function Has_sp_id (Id : Types.esa_id_type; sp_id : Types.sp_id_type) return Boolean with Pre => Is_Valid (Id); -- Returns True if the context specified by id has the given -- sp_id value. function Has_State (Id : Types.esa_id_type; State : esa_State_Type) return Boolean with Pre => Is_Valid (Id); -- Returns True if the context specified by id has the given -- State value. procedure create (Id : Types.esa_id_type; ae_id : Types.ae_id_type; ea_id : Types.ea_id_type; sp_id : Types.sp_id_type) with Pre => Is_Valid (Id) and then (Has_State (Id, clean)), Post => Has_State (Id, active) and Has_ae_id (Id, ae_id) and Has_ea_id (Id, ea_id) and Has_sp_id (Id, sp_id); procedure invalidate (Id : Types.esa_id_type) with Pre => Is_Valid (Id), Post => Has_State (Id, invalid); procedure reset (Id : Types.esa_id_type) with Pre => Is_Valid (Id), Post => Has_State (Id, clean); procedure select_sa (Id : Types.esa_id_type) with Pre => Is_Valid (Id) and then (Has_State (Id, active)), Post => Has_State (Id, selected); procedure unselect_sa (Id : Types.esa_id_type) with Pre => Is_Valid (Id) and then (Has_State (Id, selected)), Post => Has_State (Id, active); end Tkmrpc.Contexts.esa;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.exported.interrupts; use ewok.exported.interrupts; with ewok.devices_shared; use ewok.devices_shared; with ewok.interrupts; with ewok.devices; package body ewok.posthook with spark_mode => off is function read_register (addr : system_address) return unsigned_32 is reg : unsigned_32 with import, volatile_full_access, address => to_address (addr); begin return reg; end read_register; pragma inline (read_register); procedure set_bits_in_register (addr : in system_address; bits : in unsigned_32; val : in unsigned_32) is reg : unsigned_32 with import, volatile_full_access, address => to_address (addr); begin if bits = 16#FFFF_FFFF# then reg := val; else reg := (reg and (not bits)) or (val and bits); end if; end set_bits_in_register; procedure exec (intr : in soc.interrupts.t_interrupt; status : out unsigned_32; data : out unsigned_32) is dev_id : ewok.devices_shared.t_device_id; dev_addr : system_address; config : ewok.exported.interrupts.t_interrupt_config_access; found : boolean; val : unsigned_32; mask : unsigned_32; begin config := ewok.devices.get_interrupt_config_from_interrupt (intr); if config = NULL then status := 0; data := 0; return; end if; dev_id := ewok.interrupts.get_device_from_interrupt (intr); if dev_id = ID_DEV_UNUSED then status := 0; data := 0; return; end if; dev_addr := ewok.devices.get_device_addr (dev_id); #if CONFIG_KERNEL_EXP_REENTRANCY -- posthooks are, by now, executed with ISR disabled, to avoid temporal holes -- when reading/writing data in device's registers and generating potential -- ToCToU m4.cpu.disable_irq; #end if; for i in config.all.posthook.action'range loop case config.all.posthook.action(i).instr is when POSTHOOK_NIL => #if CONFIG_KERNEL_EXP_REENTRANCY -- No subsequent action. Returning. m4.cpu.enable_irq; #end if; return; when POSTHOOK_READ => val := read_register (dev_addr + system_address (config.all.posthook.action(i).read.offset)); config.all.posthook.action(i).read.value := val; -- This value need to be saved ? if config.all.posthook.status = config.all.posthook.action(i).read.offset then status := val; end if; -- This value need to be saved ? if config.all.posthook.data = config.all.posthook.action(i).read.offset then data := val; end if; when POSTHOOK_WRITE => set_bits_in_register (dev_addr + system_address (config.all.posthook.action(i).write.offset), config.all.posthook.action(i).write.mask, config.all.posthook.action(i).write.value); when POSTHOOK_WRITE_REG => -- Retrieving the already read register value found := false; for j in config.all.posthook.action'first .. i loop if config.all.posthook.action(j).instr = POSTHOOK_READ and then config.all.posthook.action(j).read.offset = config.all.posthook.action(i).write_reg.offset_src then val := config.all.posthook.action(j).read.value; found := true; exit; end if; end loop; if not found then val := read_register (dev_addr + system_address (config.all.posthook.action(i).write_reg.offset_src)); end if; -- Calculating the mask to apply in order to write only active -- bits mask := config.all.posthook.action(i).write_reg.mask and val; -- Inverted write might be needed if config.all.posthook.action(i).write_reg.mode = MODE_NOT then val := not val; end if; -- Writing into the destination register set_bits_in_register (dev_addr + system_address (config.all.posthook.action(i).write_reg.offset_dest), mask, val); when POSTHOOK_WRITE_MASK => -- Retrieving the value found := false; for j in config.all.posthook.action'first .. i loop if config.all.posthook.action(j).instr = POSTHOOK_READ and then config.all.posthook.action(j).read.offset = config.all.posthook.action(i).write_mask.offset_src then val := config.all.posthook.action(j).read.value; found := true; exit; end if; end loop; if not found then val := read_register (dev_addr + system_address (config.all.posthook.action(i).write_mask.offset_src)); end if; -- Retrieving the mask found := false; for j in config.all.posthook.action'first .. i loop if config.all.posthook.action(j).instr = POSTHOOK_READ and then config.all.posthook.action(j).read.offset = config.all.posthook.action(i).write_mask.offset_mask then mask := config.all.posthook.action(j).read.value; found := true; exit; end if; end loop; if not found then mask := read_register (dev_addr + system_address (config.all.posthook.action(i).write_mask.offset_mask)); end if; -- Calculating the mask mask := mask and val; -- Inverted write might be needed if config.all.posthook.action(i).write_mask.mode = MODE_NOT then val := not val; end if; -- Writing into the destination register set_bits_in_register (dev_addr + system_address (config.all.posthook.action(i).write_mask.offset_dest), mask, val); end case; end loop; #if CONFIG_KERNEL_EXP_REENTRANCY -- Let's enable again IRQs m4.cpu.enable_irq; #end if; end exec; end ewok.posthook;
with STM32.Device; package body STM32.CORDIC.Interrupts is ------------------------------- -- Calculate_CORDIC_Function -- ------------------------------- procedure Calculate_CORDIC_Function (This : in out CORDIC_Coprocessor; Argument : UInt32_Array; Result : out UInt32_Array) is -- Test if data width is 32 bit pragma Assert (This.CSR.ARGSIZE = True, "Invalid data size"); Operation : constant CORDIC_Function := CORDIC_Function'Val (This.CSR.FUNC); begin case Operation is when Cosine | Sine | Phase | Modulus => -- Two 32 bit arguments This.WDATA := Argument (1); This.WDATA := Argument (2); when Hyperbolic_Cosine | Hyperbolic_Sine | Arctangent | Hyperbolic_Arctangent | Natural_Logarithm | Square_Root => -- One 32 bit argument This.WDATA := Argument (1); end case; -- Get the results from the Ring Buffer case Operation is when Cosine | Sine | Phase | Modulus | Hyperbolic_Cosine | Hyperbolic_Sine => -- Two 32 bit results Receiver.Get_Result (Result (1)); Receiver.Get_Result (Result (2)); when Arctangent | Hyperbolic_Arctangent | Natural_Logarithm | Square_Root => -- One 32 bit result Receiver.Get_Result (Result (1)); end case; end Calculate_CORDIC_Function; ------------------------------- -- Calculate_CORDIC_Function -- ------------------------------- procedure Calculate_CORDIC_Function (This : in out CORDIC_Coprocessor; Argument : UInt16_Array; Result : out UInt16_Array) is -- Test if data width is 16 bit pragma Assert (This.CSR.ARGSIZE = False, "Invalid data size"); Operation : constant CORDIC_Function := CORDIC_Function'Val (This.CSR.FUNC); Data : UInt32; begin case Operation is when Cosine | Sine | Phase | Modulus => -- Two 16 bit argument Data := UInt32 (Argument (2)); Data := Shift_Left (Data, 16) or UInt32 (Argument (1)); This.WDATA := Data; when Hyperbolic_Cosine | Hyperbolic_Sine | Arctangent | Hyperbolic_Arctangent | Natural_Logarithm | Square_Root => -- One 16 bit argument This.WDATA := UInt32 (Argument (1)); end case; -- Get the results from the Ring Buffer Receiver.Get_Result (Data); case Operation is when Cosine | Sine | Phase | Modulus | Hyperbolic_Cosine | Hyperbolic_Sine => -- Two 16 bit results Result (1) := UInt16 (Data); Result (2) := UInt16 (Shift_Right (Data, 16)); when Arctangent | Hyperbolic_Arctangent | Natural_Logarithm | Square_Root => -- One 32 bit result Result (1) := UInt16 (Data); end case; end Calculate_CORDIC_Function; -------------- -- Receiver -- -------------- protected body Receiver is ---------------- -- Get_Result -- ---------------- entry Get_Result (Value : out UInt32) when Data_Available is Next : constant Integer := (Buffer.Tail + 1) mod Buffer.Content'Length; begin -- Remove an item from our ring buffer. Value := Buffer.Content (Next); Buffer.Tail := Next; -- If the buffer is empty, make sure we block subsequent callers -- until the buffer has something in it. if Buffer.Tail = Buffer.Head then Data_Available := False; end if; end Get_Result; ----------------------- -- Interrupt_Handler -- ----------------------- procedure Interrupt_Handler is use STM32.Device; begin if Interrupt_Enabled (CORDIC_Unit) then if Status (CORDIC_Unit, Flag => Result_Ready) then if (Buffer.Head + 1) mod Buffer.Content'Length = Buffer.Tail then -- But our buffer is full. raise Ring_Buffer_Full; else -- Add this first 32 bit data to our buffer. Buffer.Head := (Buffer.Head + 1) mod Buffer.Content'Length; Buffer.Content (Buffer.Head) := Get_CORDIC_Data (CORDIC_Unit); -- Test if the function has two 32 bits results if Get_CORDIC_Results_Number (CORDIC_Unit) = Two_32_Bit then if (Buffer.Head + 1) mod Buffer.Content'Length = Buffer.Tail then -- But our buffer is full. raise Ring_Buffer_Full; else -- Add this second 32 bit data to our buffer. Buffer.Head := (Buffer.Head + 1) mod Buffer.Content'Length; Buffer.Content (Buffer.Head) := Get_CORDIC_Data (CORDIC_Unit); end if; end if; Data_Available := True; end if; end if; end if; end Interrupt_Handler; end Receiver; end STM32.CORDIC.Interrupts;
with Lv.Style; with Lv.Objx.Cont; package Lv.Objx.Btn is subtype Instance is Obj_T; type State_T is (State_Rel, State_Pr, State_Tgl_Rel, State_Tgl_Pr, State_Ina, State_Num); type Action_T is (Action_Click, Action_Pr, Action_Long_Pr, Action_Long_Pr_Repeat, Action_Num); type Style_T is (Style_Rel, Style_Pr, Style_Tgl_Rel, Style_Tgl_Pr, Style_Ina); -- Create a button objects -- @param par pointer to an object, it will be the parent of the new button -- @param copy pointer to a button object, if not NULL then the new object will be copied from it -- @return pointer to the created button function Create (Parent : Obj_T; Copy : Instance) return Instance; ---------------------- -- Setter functions -- ---------------------- -- Enable the toggled states. On release the button will change from/to toggled state. -- @param self pointer to a button object -- @param tgl true: enable toggled states, false: disable procedure Set_Toggle (Self : Instance; Tgl : U_Bool); -- Set the state of the button -- @param self pointer to a button object -- @param state the new state of the button (from lv_btn_state_t enum) procedure Set_State (Self : Instance; State : State_T); -- Toggle the state of the button (ON->OFF, OFF->ON) -- @param self pointer to a button object procedure Toggle (Self : Instance); -- Set a function to call when a button event happens -- @param self pointer to a button object -- @param action type of event form 'lv_action_t' (press, release, long press, long press repeat) procedure Set_Action (Self : Instance; Type_P : Action_T; Action : Action_Func_T); -- Set the layout on a button -- @param self pointer to a button object -- @param layout a layout from 'lv_cont_layout_t' procedure Set_Layout (Self : Instance; Layout : Lv.Objx.Cont.Layout_T); -- Enable the horizontal or vertical fit. -- The button size will be set to involve the children horizontally or vertically. -- @param self pointer to a button object -- @param hor_en true: enable the horizontal fit -- @param ver_en true: enable the vertical fit procedure Set_Fit (Self : Instance; Hor_En : U_Bool; Ver_En : U_Bool); -- Set time of the ink effect (draw a circle on click to animate in the new state) -- @param self pointer to a button object -- @param time the time of the ink animation procedure Set_Ink_In_Time (Self : Instance; Time : Uint16_T); -- Set the wait time before the ink disappears -- @param self pointer to a button object -- @param time the time of the ink animation procedure Set_Ink_Wait_Time (Self : Instance; Time : Uint16_T); -- Set time of the ink out effect (animate to the released state) -- @param self pointer to a button object -- @param time the time of the ink animation procedure Set_Ink_Out_Time (Self : Instance; Time : Uint16_T); -- Set a style of a button. -- @param self pointer to button object -- @param type which style should be set -- @param style pointer to a style procedure Set_Style (Self : Instance; Type_P : Style_T; Style : access Lv.Style.Style); ---------------------- -- Getter functions -- ---------------------- -- Get the current state of the button -- @param self pointer to a button object -- @return the state of the button (from lv_btn_state_t enum) function State (Self : Instance) return State_T; -- Get the toggle enable attribute of the button -- @param self pointer to a button object -- @return ture: toggle enabled, false: disabled function Toggle_En (Self : Instance) return U_Bool; -- Get the release action of a button -- @param self pointer to a button object -- @return pointer to the release action function function Action (Self : Instance; Action : Action_T) return Action_Func_T; -- Get the layout of a button -- @param self pointer to button object -- @return the layout from 'lv_cont_layout_t' function Layout (Self : Instance) return Lv.Objx.Cont.Layout_T; -- Get horizontal fit enable attribute of a button -- @param self pointer to a button object -- @return true: horizontal fit is enabled; false: disabled function Hor_Fit (Self : Instance) return U_Bool; -- Get vertical fit enable attribute of a container -- @param self pointer to a button object -- @return true: vertical fit is enabled; false: disabled function Ver_Fit (Self : Instance) return U_Bool; -- Get time of the ink in effect (draw a circle on click to animate in the new state) -- @param self pointer to a button object -- @return the time of the ink animation function Ink_In_Time (Self : Instance) return Uint16_T; -- Get the wait time before the ink disappears -- @param self pointer to a button object -- @return the time of the ink animation function Ink_Wait_Time (Self : Instance) return Uint16_T; -- Get time of the ink out effect (animate to the releases state) -- @param self pointer to a button object -- @return the time of the ink animation function Ink_Out_Time (Self : Instance) return Uint16_T; -- Get style of a button. -- @param self pointer to button object -- @param type which style should be get -- @return style pointer to the style function Style (Self : Instance; Type_P : Style_T) return access Lv.Style.Style; ------------- -- Imports -- ------------- pragma Import (C, Create, "lv_btn_create"); pragma Import (C, Set_Toggle, "lv_btn_set_toggle"); pragma Import (C, Set_State, "lv_btn_set_state"); pragma Import (C, Toggle, "lv_btn_toggle"); pragma Import (C, Set_Action, "lv_btn_set_action"); pragma Import (C, Set_Layout, "lv_btn_set_layout_inline"); pragma Import (C, Set_Fit, "lv_btn_set_fit_inline"); pragma Import (C, Set_Ink_In_Time, "lv_btn_set_ink_in_time"); pragma Import (C, Set_Ink_Wait_Time, "lv_btn_set_ink_wait_time"); pragma Import (C, Set_Ink_Out_Time, "lv_btn_set_ink_out_time"); pragma Import (C, Set_Style, "lv_btn_set_style"); pragma Import (C, State, "lv_btn_get_state"); pragma Import (C, Toggle_En, "lv_btn_get_toggle"); pragma Import (C, Action, "lv_btn_get_action"); pragma Import (C, Layout, "lv_btn_get_layout_inline"); pragma Import (C, Hor_Fit, "lv_btn_get_hor_fit_inline"); pragma Import (C, Ver_Fit, "lv_btn_get_ver_fit_inline"); pragma Import (C, Ink_In_Time, "lv_btn_get_ink_in_time"); pragma Import (C, Ink_Wait_Time, "lv_btn_get_ink_wait_time"); pragma Import (C, Ink_Out_Time, "lv_btn_get_ink_out_time"); pragma Import (C, Style, "lv_btn_get_style"); for State_T'Size use 8; for State_T use (State_Rel => 0, State_Pr => 1, State_Tgl_Rel => 2, State_Tgl_Pr => 3, State_Ina => 4, State_Num => 5); for Action_T'Size use 8; for Action_T use (Action_Click => 0, Action_Pr => 1, Action_Long_Pr => 2, Action_Long_Pr_Repeat => 3, Action_Num => 4); for Style_T'Size use 8; for Style_T use (Style_Rel => 0, Style_Pr => 1, Style_Tgl_Rel => 2, Style_Tgl_Pr => 3, Style_Ina => 4); end Lv.Objx.Btn;
-- -- Minimal steganography tool. -- -- This demo is derived from mini.adb. -- -- To do: -- - encryption with GID; with Ada.Calendar; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Command_Line; use Ada.Command_Line; with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Text_IO; use Ada.Text_IO; with Ada.Unchecked_Deallocation; with Interfaces; procedure Steg is procedure Blurb is begin Put_Line(Standard_Error, "Steg * Minimal steganography tool"); New_Line(Standard_Error); Put_Line(Standard_Error, " Encoding: converts any image file to a PPM image file, with"); Put_Line(Standard_Error, " inclusion of a hidden data file. The PPM image can then"); Put_Line(Standard_Error, " be converted to a lossless-compressed format like PNG."); New_Line(Standard_Error); Put_Line(Standard_Error, " Decoding: extracts a hidden file from an image."); New_Line(Standard_Error); Put_Line(Standard_Error, "GID version " & GID.version & " dated " & GID.reference); Put_Line(Standard_Error, "URL: " & GID.web); New_Line(Standard_Error); Put_Line(Standard_Error, "Syntax:"); Put_Line(Standard_Error, " steg [e|d] <image> <file>"); New_Line(Standard_Error); end Blurb; use Interfaces; type Byte_Array is array(Integer range <>) of Unsigned_8; type p_Byte_Array is access Byte_Array; procedure Dispose is new Ada.Unchecked_Deallocation(Byte_Array, p_Byte_Array); img_buf: p_Byte_Array:= null; -- Load image into a 24-bit truecolor RGB raw bitmap (for a PPM output) procedure Load_raw_image( image : in out GID.Image_descriptor; buffer: in out p_Byte_Array; next_frame: out Ada.Calendar.Day_Duration ) is subtype Primary_color_range is Unsigned_8; image_width : constant Positive:= GID.Pixel_width(image); image_height: constant Positive:= GID.Pixel_height(image); idx: Natural; -- procedure Set_X_Y (x, y: Natural) is begin idx:= 3 * (x + image_width * (image_height - 1 - y)); end Set_X_Y; -- procedure Put_Pixel ( red, green, blue : Primary_color_range; alpha : Primary_color_range ) is pragma Warnings(off, alpha); -- alpha is just ignored begin buffer(idx..idx+2):= (red, green, blue); idx:= idx + 3; -- ^ GID requires us to look to next pixel on the right for next time. end Put_Pixel; stars: Natural:= 0; procedure Feedback(percents: Natural) is so_far: constant Natural:= percents / 5; begin for i in stars+1..so_far loop Put( Standard_Error, '*'); end loop; stars:= so_far; end Feedback; procedure Load_image is new GID.Load_image_contents( Primary_color_range, Set_X_Y, Put_Pixel, Feedback, GID.fast ); begin Dispose(buffer); buffer:= new Byte_Array(0..3 * image_width * image_height - 1); Load_image(image, next_frame); end Load_raw_image; procedure Dump_PPM(name: String; i: GID.Image_descriptor) is f: Ada.Streams.Stream_IO.File_Type; ppm_name: constant String:= name & ".ppm"; begin Create(f, Out_File, ppm_name); Put_Line(Standard_Error, "Creating PPM image, name = " & ppm_name & " ..."); -- PPM Header: String'Write( Stream(f), "P6 " & Integer'Image(GID.Pixel_width(i)) & Integer'Image(GID.Pixel_height(i)) & " 255" & ASCII.LF ); -- PPM raw BGR image: Byte_Array'Write(Stream(f), img_buf.all); -- ^ slow on some Ada systems, see to_bmp to have a faster version Close(f); end Dump_PPM; type Operation is (encoding, decoding); Data_too_large: exception; procedure Process(image_name, data_name: String; op: Operation) is f_im, f_dt: Ada.Streams.Stream_IO.File_Type; -- procedure Encode is idx: Natural:= img_buf'Last; -- Start with buffer's end (image's bottom), with the hope it is "noisier": -- often there is a blue sky or something like that on the top... procedure Encode_byte(b: Unsigned_8) is begin img_buf(idx):= (img_buf(idx) and 2#1111_1100#) or (b and 2#0000_0011#); -- B idx:= idx - 1; img_buf(idx):= (img_buf(idx) and 2#1111_1000#) or Shift_Right(b and 2#0001_1100#, 2); -- G idx:= idx - 1; img_buf(idx):= (img_buf(idx) and 2#1111_1000#) or Shift_Right(b, 5); -- R idx:= idx - 1; end Encode_byte; b: Unsigned_8; data_size: Unsigned_64; needed_size: Unsigned_64; available_size: constant Unsigned_64:= img_buf'Length / 3; -- 1 byte per pixel; factor: Float; begin Open(f_dt, In_File, data_name); data_size:= Unsigned_64(Size(f_dt)); needed_size:= data_size + 8; factor:= Float(needed_size) / Float(available_size); if needed_size > available_size then raise Data_too_large with "Needs a" & Integer'Image(1 + Integer(100.0 * factor)) & "% raw size scaling, i.e. a" & Integer'Image(1 + Integer(100.0 * Sqrt(factor))) & "% image scaling in both dimensions"; end if; Put_Line(Standard_Error, "Data size:" & Unsigned_64'Image(data_size) & ", using" & Integer'Image(Integer(100.0 * factor)) & "% of image data" ); for i in 1..8 loop Encode_byte(Unsigned_8(data_size and 16#FF#)); data_size:= Shift_Right(data_size, 8); end loop; while not End_Of_File(f_dt) loop Unsigned_8'Read(Stream(f_dt), b); Encode_byte(b); end loop; Close(f_dt); end Encode; -- procedure Decode is idx: Natural:= img_buf'Last; procedure Decode_byte(b: out Unsigned_8) is begin b:= img_buf(idx) and 2#0000_0011#; -- B idx:= idx - 1; b:= b + Shift_Left(img_buf(idx) and 2#0000_0111#, 2); -- G idx:= idx - 1; b:= b + Shift_Left(img_buf(idx) and 2#0000_0111#, 5); -- R idx:= idx - 1; end Decode_byte; b: Unsigned_8; data_size: Unsigned_64:= 0; begin for i in 0..7 loop Decode_byte(b); data_size:= data_size + Shift_Left(Unsigned_64(b), i * 8); end loop; Create(f_dt, Out_File, data_name); for i in 1..data_size loop Decode_byte(b); Unsigned_8'Write(Stream(f_dt), b); end loop; Close(f_dt); end Decode; -- i: GID.Image_descriptor; up_name: constant String:= To_Upper(image_name); -- next_frame: Ada.Calendar.Day_Duration; begin -- -- Load the image in its original format -- Open(f_im, In_File, image_name); Put_Line(Standard_Error, "Processing " & image_name & "..."); -- GID.Load_image_header( i, Stream(f_im).all, try_tga => image_name'Length >= 4 and then up_name(up_name'Last-3..up_name'Last) = ".TGA" ); Put_Line(Standard_Error, ".........v.........v"); -- Load_raw_image(i, img_buf, next_frame); New_Line(Standard_Error); Close(f_im); case op is when encoding => Encode; Dump_PPM(image_name, i); -- Output encoded image when decoding => Decode; end case; end Process; op: Operation; begin if Argument_Count /= 3 then Blurb; return; end if; if To_Lower(Argument(1))="e" then op:= encoding; elsif To_Lower(Argument(1))="d" then op:= decoding; else Blurb; return; end if; Process(Argument(2), Argument(3), op); end Steg;
-- 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 Ada.Text_IO; with Debug_Logs; use Debug_Logs; package body Memory is protected body RAM is procedure Init (Debug_Logging : in Boolean) is begin Logging := Debug_Logging; -- always need to map user page 0 Map_Page (Ring_7_Page_0, false); First_Shared_Page := (2 ** 31) - 1; Num_Shared_Pages := 0; Num_Unshared_Pages := 0; end Init; procedure Map_Page (Page : in Natural; Is_Shared : in Boolean) is New_Page : Page_T := (others => 0); begin if Page_Mapped(Page) then raise Page_Already_Mapped with Page'Image; else VRAM.Include(Page, New_Page); if Is_Shared then Num_Shared_Pages := Num_Shared_Pages + 1; if Page < First_Shared_Page then First_Shared_Page := Page; end if; else Num_Unshared_Pages := Num_Unshared_Pages + 1; Last_Unshared_Page := Page; end if; end if; Ada.Text_IO.Put_Line ("Memory: Mapped " & (if Is_Shared then "Shared" else "Unshared") & " page " & Int_To_String(Page, Hex, 8)); end Map_Page; function Page_Mapped (Page : in Natural) return Boolean is (VRAM.Contains(Page)); function Address_Mapped (Addr : in Phys_Addr_T) return Boolean is (VRAM.Contains(Natural(Shift_Right(Addr, 10)))); procedure Map_Range (Start_Addr : in Phys_Addr_T; Region : in Memory_Region; Is_Shared : in Boolean) is Loc : Phys_Addr_T; begin for Offset in Region'Range loop Loc := Start_Addr + Phys_Addr_T(Offset - Region'First); -- if we have hit a page boundary then check it's mapped if (Loc and 16#03ff#) = 0 then if not Address_Mapped(Loc) then Map_Page(Natural(Shift_Right(Loc, 10)), Is_Shared); Ada.Text_IO.Put_Line ("Memory: Mapped " & (if Is_Shared then "Shared" else "Unshared") & " page " & Int_To_String(Natural(Shift_Right(Loc, 10)), Hex, 8) & " for " & Dword_To_String(Dword_T(Loc), Hex, 8)); end if; end if; Write_Word(Loc, Region(Offset)); end loop; end Map_Range; procedure Map_Shared_Pages (Start_Addr : in Phys_Addr_T; Pages : in Page_Arr_T) is Page_Start : Phys_Addr_T; begin for P in Pages'Range loop Page_Start := Start_Addr + Phys_Addr_T(P * Words_Per_Page); if not Address_Mapped (Page_Start) then Map_Page(Natural(Shift_Right(Page_Start,10)), true); end if; for W in 0 .. Words_Per_Page - 1 loop Write_Word(Page_Start + Phys_Addr_T(W), Pages(P)(W)); end loop; end loop; end Map_Shared_Pages; function Get_Last_Unshared_Page return Dword_T is (Dword_T(Last_Unshared_Page)); function Get_First_Shared_Page return Dword_T is (Dword_T(First_Shared_Page)); function Get_Num_Shared_Pages return Dword_T is (Dword_T(Num_Shared_Pages)); function Get_Num_Unshared_Pages return Dword_T is (Dword_T(Num_Unshared_Pages)); function Read_Word (Word_Addr : in Phys_Addr_T) return Word_T is pragma Suppress (Index_Check); Page : Natural := Natural(Shift_Right(Word_Addr, 10)); begin if not Page_Mapped(Page) then raise Read_From_Unmapped_Page with Int_To_String(Page, Hex, 8) & " Unmapped Read for address: " & Dword_To_String(Dword_T(Word_Addr), Octal, 11); end if; return VRAM(Page)(Integer(Word_Addr and 16#03ff#)); end Read_Word; function Read_Dword (Word_Addr : in Phys_Addr_T) return Dword_T is Page : Natural := Natural(Shift_Right(Word_Addr, 10)); Hi_WD : Word_T := Read_Word(Word_Addr); Lo_WD : Word_T := Read_Word(Word_Addr + 1); begin return Dword_From_Two_Words(Hi_WD, Lo_WD); end Read_Dword; function Read_Qword (Word_Addr : in Phys_Addr_T) return Qword_T is DW_L, DW_R : Dword_T; begin DW_L := Read_Dword (Word_Addr); DW_R := Read_Dword (Word_Addr + 2); return Shift_Left(Qword_T(DW_L), 32) or Qword_T(DW_R); end Read_Qword; procedure Write_Word (Word_Addr : in Phys_Addr_T; Datum : Word_T) is Page : Natural := Natural(Shift_Right(Word_Addr, 10)); begin if not Page_Mapped(Page) then raise Write_To_Unmapped_Page with Page'Image; end if; VRAM(Page)(Integer(Word_Addr and 16#03ff#)) := Datum; end Write_Word; procedure Write_Dword (Word_Addr : in Phys_Addr_T; Datum : Dword_T) is begin Write_Word(Word_Addr, Upper_Word(Datum)); Write_Word(Word_Addr + 1, Lower_Word(Datum)); end Write_Dword; procedure Write_Qword (Word_Addr : in Phys_Addr_T; Datum : Qword_T) is begin Write_Dword(Word_Addr, Dword_T(Shift_Right(Datum, 32))); Write_Dword(Word_Addr + 2, Dword_T(Datum and 16#0000_ffff#)); end Write_Qword; function Read_Byte (Word_Addr : in Phys_Addr_T; Low_Byte : in Boolean) return Byte_T is W : Word_T; begin W := Read_Word (Word_Addr); if not Low_Byte then W := Shift_Right (W, 8); end if; return Byte_T (W and 16#00ff#); end Read_Byte; function Read_Byte_BA (BA : in Dword_T) return Byte_T is LB : Boolean := Test_DW_Bit (BA, 31); begin return Read_Byte (Phys_Addr_T(Shift_Right(BA, 1)), LB); end Read_Byte_BA; function Read_Bytes_BA (BA : in Dword_T; Num : in Natural) return Byte_Arr_T is Bytes : Byte_Arr_T (0 .. Num-1); begin for B in Bytes'Range loop Bytes(B) := Read_Byte_BA (BA + Dword_T(B)); end loop; return Bytes; end Read_Bytes_BA; function Read_String_BA (BA : in Dword_T; Keep_NUL : in Boolean) return String is Is_Low_Byte : Boolean := Test_DW_Bit (BA, 31); Byte, Low_Byte : Byte_T; Offset : Dword_T := 0; U_Str : Unbounded_String; begin loop Byte := Read_Byte_BA (BA + Offset); exit when Byte = 0; U_Str := U_Str & Byte_To_Char(Byte); Offset := Offset + 1; end loop; if Keep_NUL then return To_String(U_Str) & ASCII.NUL; else return To_String(U_Str); end if; end Read_String_BA; procedure Write_String_BA (BA : in Dword_T; Str : in String) is -- Write an AOS/VS "String" into memory, appending a NUL character Offset : Dword_T := 0; begin for C in Str'Range loop Write_Byte_BA (BA + Offset, Byte_T(Character'Pos(Str(C)))); Offset := Offset + 1; end loop; Write_Byte_BA (BA + Offset, 0); end Write_String_BA; function Read_Byte_Eclipse_BA (Segment : in Phys_Addr_T; BA_16 : in Word_T) return Byte_T is Low_Byte : Boolean := Test_W_Bit(BA_16, 15); Addr : Phys_Addr_T; begin Addr := Shift_Right(Phys_Addr_T(BA_16), 1) or Segment; return Read_Byte(Addr, Low_Byte); end Read_Byte_Eclipse_BA; procedure Write_Byte_Eclipse_BA (Segment : in Phys_Addr_T; BA_16 : in Word_T; Datum : in Byte_T) is Low_Byte : Boolean := Test_W_Bit(BA_16, 15); Addr : Phys_Addr_T; begin Addr := Shift_Right(Phys_Addr_T(BA_16), 1) or Segment; Write_Byte (Addr, Low_Byte, Datum); end Write_Byte_Eclipse_BA; procedure Write_Byte (Word_Addr : in Phys_Addr_T; Low_Byte : in Boolean; Byt : in Byte_T) is Wd : Word_T := Read_Word(Word_Addr); begin if Low_Byte then Wd := (Wd and 16#ff00#) or Word_T(Byt); else Wd := Shift_Left(Word_T(Byt), 8) or (Wd and 16#00ff#); end if; Write_Word(Word_Addr, Wd); end Write_Byte; procedure Write_Byte_BA (BA : in Dword_T; Datum : in Byte_T) is LB : Boolean := Test_DW_Bit (BA, 31); begin Write_Byte (Phys_Addr_T(Shift_Right(BA, 1)), LB, Datum); end Write_Byte_BA; procedure Copy_Byte_BA (Src, Dest : in Dword_T) is Src_LB : Boolean := Test_DW_Bit (Src, 31); Dest_LB : Boolean := Test_DW_Bit (Dest, 31); Byt : Byte_T; begin Byt := Read_Byte (Phys_Addr_T(Shift_Right(Src, 1)), Src_LB); Write_Byte (Phys_Addr_T(Shift_Right(Dest, 1)), Dest_LB, Byt); end Copy_Byte_BA; end RAM; protected body Narrow_Stack is procedure Push (Segment : in Phys_Addr_T; Datum : in Word_T) is New_NSP : Word_T := RAM.Read_Word (NSP_Loc or Segment) + 1; begin RAM.Write_Word (NSP_Loc or Segment, New_NSP); RAM.Write_Word (Phys_Addr_T (New_NSP) or Segment, Datum); end Push; function Pop (Segment : in Phys_Addr_T) return Word_T is Old_NSP : Word_T := RAM.Read_Word (NSP_Loc or Segment); Datum : Word_T := RAM.Read_Word (Phys_Addr_T (Old_NSP) or Segment); begin RAM.Write_Word (NSP_Loc or Segment, Old_NSP - 1); return Datum; end Pop; end Narrow_Stack; end Memory;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Element_Vectors; with Program.Elements.Associations; with Program.Lexical_Elements; with Program.Elements.Expressions; package Program.Elements.Record_Component_Associations is pragma Pure (Program.Elements.Record_Component_Associations); type Record_Component_Association is limited interface and Program.Elements.Associations.Association; type Record_Component_Association_Access is access all Record_Component_Association'Class with Storage_Size => 0; not overriding function Choices (Self : Record_Component_Association) return Program.Element_Vectors.Element_Vector_Access is abstract; not overriding function Component_Value (Self : Record_Component_Association) return Program.Elements.Expressions.Expression_Access is abstract; type Record_Component_Association_Text is limited interface; type Record_Component_Association_Text_Access is access all Record_Component_Association_Text'Class with Storage_Size => 0; not overriding function To_Record_Component_Association_Text (Self : in out Record_Component_Association) return Record_Component_Association_Text_Access is abstract; not overriding function Arrow_Token (Self : Record_Component_Association_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Box_Token (Self : Record_Component_Association_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; type Record_Component_Association_Vector is limited interface and Program.Element_Vectors.Element_Vector; type Record_Component_Association_Vector_Access is access all Record_Component_Association_Vector'Class with Storage_Size => 0; overriding function Element (Self : Record_Component_Association_Vector; Index : Positive) return not null Program.Elements.Element_Access is abstract with Post'Class => Element'Result.Is_Record_Component_Association; function To_Record_Component_Association (Self : Record_Component_Association_Vector'Class; Index : Positive) return not null Record_Component_Association_Access is (Self.Element (Index).To_Record_Component_Association); end Program.Elements.Record_Component_Associations;
pragma Style_Checks (Off); with x86_64_linux_gnu_bits_types_h; package x86_64_linux_gnu_bits_stdint_intn_h is -- Define intN_t types. -- Copyright (C) 2017-2018 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- 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/>. subtype int8_t is x86_64_linux_gnu_bits_types_h .uu_int8_t; -- /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:24 subtype int16_t is x86_64_linux_gnu_bits_types_h .uu_int16_t; -- /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:25 subtype int32_t is x86_64_linux_gnu_bits_types_h .uu_int32_t; -- /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26 subtype int64_t is x86_64_linux_gnu_bits_types_h .uu_int64_t; -- /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27 end x86_64_linux_gnu_bits_stdint_intn_h;
----------------------------------------------------------------------- -- awa-mail-clients-aws_smtp -- Mail client implementation on top of AWS SMTP client -- Copyright (C) 2012, 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Finalization; with Util.Properties; with AWS.SMTP; with AWS.SMTP.Authentication.Plain; -- The <b>AWA.Mail.Clients.AWS_SMTP</b> package provides an implementation of the -- mail client interfaces on top of AWS SMTP client API. package AWA.Mail.Clients.AWS_SMTP is NAME : constant String := "smtp"; -- ------------------------------ -- Mail Message -- ------------------------------ -- The <b>Mail_Message</b> represents an abstract mail message that can be initialized -- before being sent. type AWS_Mail_Message is new Ada.Finalization.Limited_Controlled and Mail_Message with private; type AWS_Mail_Message_Access is access all AWS_Mail_Message'Class; -- Set the <tt>From</tt> part of the message. overriding procedure Set_From (Message : in out AWS_Mail_Message; Name : in String; Address : in String); -- Add a recipient for the message. overriding procedure Add_Recipient (Message : in out AWS_Mail_Message; Kind : in Recipient_Type; Name : in String; Address : in String); -- Set the subject of the message. overriding procedure Set_Subject (Message : in out AWS_Mail_Message; Subject : in String); -- Set the body of the message. overriding procedure Set_Body (Message : in out AWS_Mail_Message; Content : in String); -- Send the email message. overriding procedure Send (Message : in out AWS_Mail_Message); -- Deletes the mail message. overriding procedure Finalize (Message : in out AWS_Mail_Message); -- ------------------------------ -- Mail Manager -- ------------------------------ -- The <b>Mail_Manager</b> is the entry point to create a new mail message -- and be able to send it. type AWS_Mail_Manager is new Mail_Manager with private; type AWS_Mail_Manager_Access is access all AWS_Mail_Manager'Class; -- Create a SMTP based mail manager and configure it according to the properties. function Create_Manager (Props : in Util.Properties.Manager'Class) return Mail_Manager_Access; -- Create a new mail message. overriding function Create_Message (Manager : in AWS_Mail_Manager) return Mail_Message_Access; private type Recipients_Access is access all AWS.SMTP.Recipients; type AWS_Mail_Message is new Ada.Finalization.Limited_Controlled and Mail_Message with record Manager : AWS_Mail_Manager_Access; From : AWS.SMTP.E_Mail_Data; Subject : Ada.Strings.Unbounded.Unbounded_String; Content : Ada.Strings.Unbounded.Unbounded_String; To : Recipients_Access := null; end record; type AWS_Mail_Manager is new Mail_Manager with record Self : AWS_Mail_Manager_Access; Server : AWS.SMTP.Receiver; Creds : aliased AWS.SMTP.Authentication.Plain.Credential; Port : Positive := 25; Enable : Boolean := True; Secure : Boolean := False; Auth : Boolean := False; end record; procedure Initialize (Client : in out AWS_Mail_Manager'Class; Props : in Util.Properties.Manager'Class); end AWA.Mail.Clients.AWS_SMTP;
with neural.Set; package Neural.Forge -- -- Declares a factory for creation/destruction of core types. -- is -- Pattern -- function Creation (From : in Pattern) return Pattern; procedure Destroy (Self : in out Pattern); -- Patterns -- function Creation (From_File_Named : in String) return neural.Set.Patterns_view; procedure Destroy (Self : in out Patterns); procedure Destroy (Self : in out neural.Set.Patterns_view); procedure Store (Self : in Patterns; In_File_Named : in String); end Neural.Forge;
with AdaM.Entity, AdaM.Block, gtk.Widget; private with aIDE.Editor.of_exception_Handler, gtk.Text_View, gtk.Box, gtk.Label, gtk.Frame, gtk.Expander; package aIDE.Editor.of_block is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function to_block_Editor (the_Block : in AdaM.Block.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; procedure Target_is (Self : in out Item; Now : in AdaM.Block.view); function Target (Self : in Item) return AdaM.Block.view; private use gtk.Text_View, gtk.Expander, gtk.Box, gtk.Label, gtk.Frame; type my_Expander_Record is new Gtk_Expander_Record with record -- Target : AdaM.Source.Entities_View; Target : AdaM.Entity.Entities_View; Editor : aIDE.Editor.of_block.view; end record; type my_Expander is access all my_Expander_Record'Class; type Item is new Editor.item with record Block : AdaM.Block.view; block_editor_Frame : Gtk_Frame; top_Box : gtk_Box; declare_Label : Gtk_Label; declare_Expander : my_Expander; declare_Box : gtk_Box; begin_Label : Gtk_Label; begin_Expander : my_Expander; begin_Box : gtk_Box; exception_Label : Gtk_Label; exception_Expander : my_Expander; exception_Box : gtk_Box; begin_Text, exception_Text : Gtk_Text_View; exception_Handler : aIDE.Editor.of_exception_Handler.view; end record; overriding procedure freshen (Self : in out Item); end aIDE.Editor.of_block;
with GDNative.Thin; package GDNative.Context is procedure GDNative_Initialize (p_options : access Thin.godot_gdnative_init_options); procedure GDNative_Finalize (p_options : access Thin.godot_gdnative_terminate_options); procedure Nativescript_Initialize (p_handle : in Thin.Nativescript_Handle); -- Use for function returns for void Nil_Godot_Variant : aliased Thin.godot_variant; -- Set during GDNative_Initialize Core_Initialized : Boolean := False; Nativescript_Initialized : Boolean := False; Core_Api : Thin.godot_gdnative_core_api_struct_ptr := null; Nativescript_Api : Thin.godot_gdnative_ext_nativescript_api_struct_ptr := null; Nativescript_Ptr : Thin.Nativescript_Handle := Thin.Null_Handle; Pluginscript_Api : Thin.godot_gdnative_ext_pluginscript_api_struct_ptr := null; Android_Api : Thin.godot_gdnative_ext_android_api_struct_ptr := null; Arvr_Api : Thin.godot_gdnative_ext_arvr_api_struct_ptr := null; Videodecoder_Api : Thin.godot_gdnative_ext_videodecoder_api_struct_ptr := null; Net_Api : Thin.godot_gdnative_ext_net_api_struct_ptr := null; end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . C O M M A N D _ L I N E -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, 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 is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- High level package for command line parsing -- This package provides an interface to Ada.Command_Line, to do the -- parsing of command line arguments. Here is a small usage example: -- -- begin -- loop -- case Getopt ("a b: ad") is -- Accepts '-a', '-ad', or '-b argument' -- when ASCII.NUL => exit; -- -- when 'a' => -- if Full_Switch = "a" then -- Put_Line ("Got a"); -- else -- Put_Line ("Got ad"); -- end if; -- -- when 'b' => -- Put_Line ("Got b + " & Parameter); -- -- when others => -- raise Program_Error; -- cannot occur! -- end case; -- end loop; -- -- loop -- declare -- S : constant String := Get_Argument (Do_Expansion => True); -- begin -- exit when S'Length = 0; -- Put_Line ("Got " & S); -- end; -- end loop; -- -- exception -- when Invalid_Switch => Put_Line ("Invalid Switch " & Full_Switch); -- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); -- end; -- -- A more complicated example would involve the use of sections for the -- switches, as for instance in gnatmake. These sections are separated by -- special switches, chosen by the programer. Each section act as a -- command line of its own. -- -- begin -- Initialize_Option_Scan ('-', False, "largs bargs cargs"); -- loop -- -- same loop as above to get switches and arguments -- end loop; -- -- Goto_Section ("bargs"); -- loop -- -- same loop as above to get switches and arguments -- -- The supports switches in Get_Opt might be different -- end loop; -- -- Goto_Section ("cargs"); -- loop -- -- same loop as above to get switches and arguments -- -- The supports switches in Get_Opt might be different -- end loop; -- end; with GNAT.Directory_Operations; with GNAT.Regexp; package GNAT.Command_Line is procedure Initialize_Option_Scan (Switch_Char : Character := '-'; Stop_At_First_Non_Switch : Boolean := False; Section_Delimiters : String := ""); -- This procedure resets the internal state of the package to prepare -- to rescan the parameters. It need not (but may be) called before the -- first use of Getopt, but it must be called if you want to start -- rescanning the command line parameters from the start. The optional -- parameter Switch_Char can be used to reset the switch character, -- e.g. to '/' for use in DOS-like systems. The optional parameter -- Stop_At_First_Non_Switch indicates if Getopt is to look for switches -- on the whole command line, or if it has to stop as soon as a -- non-switch argument is found. -- -- Example: -- -- Arguments: my_application file1 -c -- -- if Stop_At_First_Non_Switch is False, then -c will be considered -- as a switch (returned by getopt), otherwise it will be considered -- as a normal argument (returned by Get_Argument). -- -- if SECTION_DELIMITERS is set, then every following subprogram -- (Getopt and Get_Argument) will only operate within a section, which -- is delimited by any of these delimiters or the end of the command line. -- -- Example: -- Initialize_Option_Scan ("largs bargs cargs"); -- -- Arguments on command line : my_application -c -bargs -d -e -largs -f -- This line is made of three section, the first one is the default one -- and includes only the '-c' switch, the second one is between -bargs -- and -largs and includes '-d -e' and the last one includes '-f' procedure Goto_Section (Name : String := ""); -- Change the current section. The next Getopt of Get_Argument will -- start looking at the beginning of the section. An empty name ("") -- refers to the first section between the program name and the first -- section delimiter. -- If the section does not exist, then Invalid_Section is raised. function Full_Switch return String; -- Returns the full name of the last switch found (Getopt only returns -- the first character) function Getopt (Switches : String) return Character; -- This function moves to the next switch on the command line (defined -- as a switch character followed by a character within Switches, -- casing being significant). The result returned is the first -- character of the particular switch located. If there are no more -- switches in the current section, returns ASCII.NUL. The switches -- need not be separated by spaces (they can be concatenated if they do -- not require an argument, e.g. -ab is the same as two separate -- arguments -a -b). -- -- Switches is a string of all the possible switches, separated by a -- space. A switch can be followed by one of the following characters : -- -- ':' The switch requires a parameter. There can optionally be a space -- on the command line between the switch and its parameter -- '!' The switch requires a parameter, but there can be no space on the -- command line between the switch and its parameter -- '?' The switch may have an optional parameter. There can no space -- between the switch and its argument -- ex/ if Switches has the following value : "a? b" -- The command line can be : -- -afoo : -a switch with 'foo' parameter -- -a foo : -a switch and another element on the -- command line 'foo', returned by Get_Argument -- -- Example: if Switches is "-a: -aO:", you can have the following -- command lines : -- -aarg : 'a' switch with 'arg' parameter -- -a arg : 'a' switch with 'arg' parameter -- -aOarg : 'aO' switch with 'arg' parameter -- -aO arg : 'aO' switch with 'arg' parameter -- -- Example: -- -- Getopt ("a b: ac ad?") -- -- accept either 'a' or 'ac' with no argument, -- accept 'b' with a required argument -- accept 'ad' with an optional argument -- -- If the first item in switches is '*', then Getopt will catch -- every element on the command line that was not caught by any other -- switch. The character returned by GetOpt is '*' -- -- Example -- Getopt ("* a b") -- If the command line is '-a -c toto.o -b', GetOpt will return -- successively 'a', '*', '*' and 'b'. When '*' is returnd, -- Full_Switch returns the corresponding item on the command line. -- -- -- When Getopt encounters an invalid switch, it raises the exception -- Invalid_Switch and sets Full_Switch to return the invalid switch. -- When Getopt can not find the parameter associated with a switch, it -- raises Invalid_Parameter, and sets Full_Switch to return the invalid -- switch character. -- -- Note: in case of ambiguity, e.g. switches a ab abc, then the longest -- matching switch is returned. -- -- Arbitrary characters are allowed for switches, although it is -- strongly recommanded to use only letters and digits for portability -- reasons. function Get_Argument (Do_Expansion : Boolean := False) return String; -- Returns the next element in the command line which is not a switch. -- This function should not be called before Getopt has returned -- ASCII.NUL. -- -- If Expansion is True, then the parameter on the command -- line will considered as filename with wild cards, and will be -- expanded. The matching file names will be returned one at a time. -- When there are no more arguments on the command line, this function -- returns an empty string. This is useful in non-Unix systems for -- obtaining normal expansion of wild card references. function Parameter return String; -- Returns parameter associated with the last switch returned by Getopt. -- If no parameter was associated with the last switch, or no previous -- call has been made to Get_Argument, raises Invalid_Parameter. -- If the last switch was associated with an optional argument and this -- argument was not found on the command line, Parameter returns an empty -- string type Expansion_Iterator is limited private; -- Type used during expansion of file names procedure Start_Expansion (Iterator : out Expansion_Iterator; Pattern : String; Directory : String := ""; Basic_Regexp : Boolean := True); -- Initialize an wild card expansion. The next calls to Expansion will -- return the next file name in Directory which match Pattern (Pattern -- is a regular expression, using only the Unix shell and DOS syntax if -- Basic_Regexp is True. When Directory is an empty string, the current -- directory is searched. function Expansion (Iterator : Expansion_Iterator) return String; -- Return the next file in the directory matching the parameters given -- to Start_Expansion and updates Iterator to point to the next entry. -- Returns an empty string when there are no more files in the directory. -- If Expansion is called again after an empty string has been returned, -- then the exception GNAT.Directory_Operations.Directory_Error is raised. Invalid_Section : exception; -- Raised when an invalid section is selected by Goto_Section Invalid_Switch : exception; -- Raised when an invalid switch is detected in the command line Invalid_Parameter : exception; -- Raised when a parameter is missing, or an attempt is made to obtain -- a parameter for a switch that does not allow a parameter private type Expansion_Iterator is limited record Dir : GNAT.Directory_Operations.Dir_Type; Regexp : GNAT.Regexp.Regexp; end record; end GNAT.Command_Line;
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with STM32.Board; use STM32.Board; -- with STM32.DMA2D; use STM32.DMA2D; with STM32.DMA2D_Bitmap; use STM32.DMA2D_Bitmap; with HAL; use HAL; with HAL.Bitmap; use HAL.Bitmap; -- We import the gameboy with gameboy_hpp; with Interfaces.C; use Interfaces.C; procedure Main is GB : aliased gameboy_hpp.Class_Gameboy.Gameboy := gameboy_hpp.Class_Gameboy.New_Gameboy; type uchar_array is array (size_t range <>) of aliased unsigned_char; pixels_array : uchar_array (0 .. 23039); ptr : constant access unsigned_char := pixels_array (pixels_array'First)'Access; function Bitmap_Buffer return not null Any_Bitmap_Buffer; function Bitmap_Buffer return not null Any_Bitmap_Buffer is begin if Display.Hidden_Buffer (1).all not in DMA2D_Bitmap_Buffer then raise Program_Error with "We expect a DMA2D buffer here"; end if; return Display.Hidden_Buffer (1); end Bitmap_Buffer; X : Natural; Y : Natural; pix : unsigned_char := 0; pixx : size_t := 0; pixy : size_t := 0; Width : Natural; Height : Natural; begin Display.Initialize; Display.Initialize_Layer (1, HAL.Bitmap.ARGB_8888); Width := Display.Hidden_Buffer (1).Width; Height := Display.Hidden_Buffer (1).Height; loop Bitmap_Buffer.Set_Source (HAL.Bitmap.Dark_Green); Bitmap_Buffer.Fill; X := 0; Y := 0; pixx := 0; pixy := 0; Bitmap_Buffer.Set_Pixel ((Width / 2, Height / 2), HAL.Bitmap.Red); while X < 160 loop while Y < 144 loop pix := pixels_array (pixy * 144 + pixx); if pix = 0 then Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.White); elsif pix = 1 then Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.Light_Grey); elsif pix = 2 then Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.Dark_Grey); else Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.Black); end if; Y := Y + 1; pixy := pixy + 1; end loop; Y := 0; X := X + 1; pixy := 0; pixx := pixx + 1; end loop; Display.Update_Layers; gameboy_hpp.Class_Gameboy.step (GB'Access, ptr); end loop; end Main;
-- Author: A. Ireland -- -- Address: School Mathematical & Computer Sciences -- Heriot-Watt University -- Edinburgh, EH14 4AS -- -- E-mail: a.ireland@hw.ac.uk -- -- Last modified: 13.9.2019 -- -- Filename: alarm.ads -- -- Description: Models the alarm device associated with -- the WTP controller and the alarm count. pragma SPARK_Mode (On); package Alarm with Abstract_State => State is procedure Enable with Global => (In_Out => State), Depends => (State => State); procedure Disable with Global => (In_Out => State), Depends => (State => State); function Enabled return Boolean with Global => (Input => State), Depends => (Enabled'Result => State); function Alarm_Cnt_Value return Integer with Global => (Input => State), Depends => (Alarm_Cnt_Value'Result => State); end Alarm;
-- The MIT License (MIT) -- -- Copyright (c) 2016 artium@nihamkin.com -- -- 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 Linux_Joystick; with Text_IO; with Ada.Characters.Latin_1; procedure Main is type Common_Axis_Type is range 0..20; type Common_Button_Type is range 0..20; package LJS is new Linux_Joystick(Button_Type => Common_Button_Type, Axis_Type => Common_Axis_Type); generic with package JSP is new Linux_Joystick (<>); procedure Put(Js_Event : in JSP.Js_Event_Type); procedure Put(Js_Event : in JSP.Js_Event_Type) is package Millisecinds_IO is new Text_IO.Integer_IO(JSP.Milliseconds_Type); package Value_IO is new Text_IO.Integer_IO(JSP.Value_Type); begin Text_IO.Put(if Js_Event.Is_Init_Event then "I" else " "); Text_IO.Put(Ada.Characters.Latin_1.HT); Millisecinds_IO.Put(Js_Event.Time); Text_IO.Put(Ada.Characters.Latin_1.HT); Text_IO.Put(JSP.Event_Type_Type'Image(Js_Event.Event_Type)); Text_IO.Put(Ada.Characters.Latin_1.HT); case Js_Event.Event_Type is when JSP.JS_EVENT_BUTTON => Text_IO.Put(JSP.Button_Type'Image(Js_Event.Button)); Text_IO.Put(Ada.Characters.Latin_1.HT); Text_IO.Put(JSP.Button_Action_Type'Image(Js_Event.Button_Action)); when JSP.JS_EVENT_AXIS => Text_IO.Put(JSP.Axis_Type'Image(Js_Event.Axis)); Text_IO.Put(Ada.Characters.Latin_1.HT); Value_IO.Put(Js_Event.Value); end case; Text_IO.New_Line; end; procedure Put_LJS is new Put(LJS); begin declare -- It is also possible to use Open without parameters, it will automatically locate -- an available "js*" file. -- Opended_Device_Path : String := "/dev/input/js1"; begin LJS.Open(Opended_Device_Path); Text_IO.Put_Line("Opended device at: " & Opended_Device_Path); loop declare Js_Event : LJS.Js_Event_Type := LJS.Read; begin Put_LJS(Js_Event); end; end loop; exception -- It is advisable to handle the exceptions here: -- ADA.IO_EXCEPTION.DEVICE_ERROR, LJS.No_Joystick_Device_Found etc. -- when others => LJS.Close; raise; end; end Main;
with Tkmrpc.Servers.Ike; with Tkmrpc.Results; with Tkmrpc.Request.Ike.Esa_Create.Convert; with Tkmrpc.Response.Ike.Esa_Create.Convert; package body Tkmrpc.Operation_Handlers.Ike.Esa_Create is ------------------------------------------------------------------------- procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is Specific_Req : Request.Ike.Esa_Create.Request_Type; Specific_Res : Response.Ike.Esa_Create.Response_Type; begin Specific_Res := Response.Ike.Esa_Create.Null_Response; Specific_Req := Request.Ike.Esa_Create.Convert.From_Request (S => Req); if Specific_Req.Data.Esa_Id'Valid and Specific_Req.Data.Isa_Id'Valid and Specific_Req.Data.Sp_Id'Valid and Specific_Req.Data.Ea_Id'Valid and Specific_Req.Data.Dh_Id'Valid and Specific_Req.Data.Nc_Loc_Id'Valid and Specific_Req.Data.Nonce_Rem.Size'Valid and Specific_Req.Data.Initiator'Valid and Specific_Req.Data.Esp_Spi_Loc'Valid and Specific_Req.Data.Esp_Spi_Rem'Valid then Servers.Ike.Esa_Create (Result => Specific_Res.Header.Result, Esa_Id => Specific_Req.Data.Esa_Id, Isa_Id => Specific_Req.Data.Isa_Id, Sp_Id => Specific_Req.Data.Sp_Id, Ea_Id => Specific_Req.Data.Ea_Id, Dh_Id => Specific_Req.Data.Dh_Id, Nc_Loc_Id => Specific_Req.Data.Nc_Loc_Id, Nonce_Rem => Specific_Req.Data.Nonce_Rem, Initiator => Specific_Req.Data.Initiator, Esp_Spi_Loc => Specific_Req.Data.Esp_Spi_Loc, Esp_Spi_Rem => Specific_Req.Data.Esp_Spi_Rem); Res := Response.Ike.Esa_Create.Convert.To_Response (S => Specific_Res); else Res.Header.Result := Results.Invalid_Parameter; end if; end Handle; end Tkmrpc.Operation_Handlers.Ike.Esa_Create;
-- This package has been generated automatically by GNATtest. -- Do not edit any part of it, see GNATtest documentation for more details. -- begin read only with Gnattest_Generated; package Tk.Button.Test_Data.Tests is type Test is new GNATtest_Generated.GNATtest_Standard.Tk.Button.Test_Data .Test with null record; procedure Test_Flash_21d4a1_fe4617(Gnattest_T: in out Test); -- tk-button.ads:251:4:Flash:Test_Flash_Button procedure Test_Invoke_05a9d3_ac3b13(Gnattest_T: in out Test); -- tk-button.ads:273:4:Invoke:Test_Invoke_Button1 procedure Test_Invoke_89eee4_562019(Gnattest_T: in out Test); -- tk-button.ads:297:4:Invoke:Test_Invoke_Button2 end Tk.Button.Test_Data.Tests; -- end read only
with Ada.Numerics.Elementary_Functions; with Ada.Numerics.Generic_Real_Arrays; with SDL.Video.Windows.Makers; with SDL.Video.Renderers.Makers; with SDL.Video.Palettes; with SDL.Events.Events; procedure Death_Star is Width : constant := 400; Height : constant := 400; package Float_Arrays is new Ada.Numerics.Generic_Real_Arrays (Float); use Ada.Numerics.Elementary_Functions; use Float_Arrays; Window : SDL.Video.Windows.Window; Renderer : SDL.Video.Renderers.Renderer; subtype Vector_3 is Real_Vector (1 .. 3); type Sphere_Type is record Cx, Cy, Cz : Integer; R : Integer; end record; function Normalize (V : Vector_3) return Vector_3 is (V / Sqrt (V * V)); procedure Hit (S : Sphere_Type; X, Y : Integer; Z1, Z2 : out Float; Is_Hit : out Boolean) is NX : constant Integer := X - S.Cx; NY : constant Integer := Y - S.Cy; Zsq : constant Integer := S.R * S.R - (NX * NX + NY * NY); Zsqrt : Float; begin if Zsq >= 0 then Zsqrt := Sqrt (Float (Zsq)); Z1 := Float (S.Cz) - Zsqrt; Z2 := Float (S.Cz) + Zsqrt; Is_Hit := True; return; end if; Z1 := 0.0; Z2 := 0.0; Is_Hit := False; end Hit; procedure Draw_Death_Star (Pos, Neg : Sphere_Type; K, Amb : Float; Dir : Vector_3) is Vec : Vector_3; ZB1, ZB2 : Float; ZS1, ZS2 : Float; Is_Hit : Boolean; S : Float; Lum : Integer; begin for Y in Pos.Cy - Pos.R .. Pos.Cy + Pos.R loop for X in Pos.Cx - Pos.R .. Pos.Cx + Pos.R loop Hit (Pos, X, Y, ZB1, ZB2, Is_Hit); if not Is_Hit then goto Continue; end if; Hit (Neg, X, Y, ZS1, ZS2, Is_Hit); if Is_Hit then if ZS1 > ZB1 then Is_Hit := False; elsif ZS2 > ZB2 then goto Continue; end if; end if; if Is_Hit then Vec := (Float (Neg.Cx - X), Float (Neg.Cy - Y), Float (Neg.Cz) - ZS2); else Vec := (Float (X - Pos.Cx), Float (Y - Pos.Cy), ZB1 - Float (Pos.Cz)); end if; S := Float'Max (0.0, Dir * Normalize (Vec)); Lum := Integer (255.0 * (S ** K + Amb) / (1.0 + Amb)); Lum := Integer'Max (0, Lum); Lum := Integer'Min (Lum, 255); Renderer.Set_Draw_Colour ((SDL.Video.Palettes.Colour_Component (Lum), SDL.Video.Palettes.Colour_Component (Lum), SDL.Video.Palettes.Colour_Component (Lum), 255)); Renderer.Draw (Point => (SDL.C.int (X + Width / 2), SDL.C.int (Y + Height / 2))); <<Continue>> end loop; end loop; end Draw_Death_Star; procedure Wait is use type SDL.Events.Event_Types; Event : SDL.Events.Events.Events; begin loop while SDL.Events.Events.Poll (Event) loop if Event.Common.Event_Type = SDL.Events.Quit then return; end if; end loop; delay 0.100; end loop; end Wait; Direction : constant Vector_3 := Normalize ((20.0, -40.0, -10.0)); Positive : constant Sphere_Type := (0, 0, 0, 120); Negative : constant Sphere_Type := (-90, -90, -30, 100); begin if not SDL.Initialise (Flags => SDL.Enable_Screen) then return; end if; SDL.Video.Windows.Makers.Create (Win => Window, Title => "Death star", Position => SDL.Natural_Coordinates'(X => 10, Y => 10), Size => SDL.Positive_Sizes'(Width, Height), Flags => 0); SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface); Renderer.Set_Draw_Colour ((0, 0, 0, 255)); Renderer.Fill (Rectangle => (0, 0, Width, Height)); Draw_Death_Star (Positive, Negative, 1.5, 0.2, Direction); Window.Update_Surface; Wait; Window.Finalize; SDL.Finalise; end Death_Star;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Unchecked_Deallocation; package body Yaml.Stacks is procedure Adjust (Object : in out Stack) is begin if Object.Data /= null then Object.Data.Refcount := Object.Data.Refcount + 1; end if; end Adjust; procedure Free_Element_Array is new Ada.Unchecked_Deallocation (Element_Array, Element_Array_Access); procedure Finalize (Object : in out Stack) is procedure Free_Holder is new Ada.Unchecked_Deallocation (Holder, Holder_Access); Reference : Holder_Access := Object.Data; begin Object.Data := null; if Reference /= null then Reference.Refcount := Reference.Refcount - 1; if Reference.Refcount = 0 then Free_Element_Array (Reference.Elements); Free_Holder (Reference); end if; end if; end Finalize; function New_Stack (Initial_Capacity : Positive) return Stack is begin return Ret : constant Stack := (Ada.Finalization.Controlled with Data => new Holder) do Ret.Data.Elements := new Element_Array (1 .. Initial_Capacity); Ret.Data.Length := 0; end return; end New_Stack; function Top (Object : in out Stack) return access Element_Type is (Object.Data.Elements (Object.Data.Length)'Access); function Length (Object : Stack) return Natural is (if Object.Data = null then 0 else Object.Data.Length); function Element (Object : Stack; Index : Positive) return access Element_Type is (Object.Data.Elements (Index)'Access); procedure Pop (Object : in out Stack) is begin Object.Data.Length := Object.Data.Length - 1; end Pop; procedure Push (Object : in out Stack; Value : Element_Type) is begin if Object.Data = null then Object := New_Stack (32); end if; if Object.Data.Length = Object.Data.Elements.all'Last then declare New_Array : constant Element_Array_Access := new Element_Array (1 .. Object.Data.Length * 2); begin New_Array (1 .. Object.Data.Length) := Object.Data.Elements.all; Free_Element_Array (Object.Data.Elements); Object.Data.Elements := New_Array; end; end if; Object.Data.Length := Object.Data.Length + 1; Object.Data.Elements (Object.Data.Length) := Value; end Push; function Initialized (Object : Stack) return Boolean is (Object.Data /= null); end Yaml.Stacks;
with Startup; with Bootloader; procedure Main is begin Bootloader.Start; end Main;
with System; procedure Thread_Func (Arg : System.Address); pragma Convention (C, Thread_Func);
with OpenAL.Thin; package body OpenAL.Listener is -- -- Get_* -- procedure Get_Gain (Gain : out Types.Float_t) is Value : aliased Types.Float_t; begin Thin.Get_Listenerf (Parameter => Thin.AL_GAIN, Value => Value'Address); Gain := Value; end Get_Gain; procedure Get_Orientation_Discrete (Forward : out Types.Vector_3i_t; Up : out Types.Vector_3i_t) is type Orient_Vectors_t is new Types.Vector_i_t (1 .. 6); Vectors : Orient_Vectors_t; begin Thin.Get_Listeneriv (Parameter => Thin.AL_ORIENTATION, Values => Vectors (Vectors'First)'Address); Forward := Types.Vector_3i_t' (1 => Vectors (1), 2 => Vectors (2), 3 => Vectors (3)); Up := Types.Vector_3i_t' (1 => Vectors (4), 2 => Vectors (5), 3 => Vectors (6)); end Get_Orientation_Discrete; procedure Get_Orientation_Float (Forward : out Types.Vector_3f_t; Up : out Types.Vector_3f_t) is type Orient_Vectors_t is new Types.Vector_f_t (1 .. 6); Vectors : Orient_Vectors_t; begin Thin.Get_Listenerfv (Parameter => Thin.AL_ORIENTATION, Values => Vectors (Vectors'First)'Address); Forward := Types.Vector_3f_t' (1 => Vectors (1), 2 => Vectors (2), 3 => Vectors (3)); Up := Types.Vector_3f_t' (1 => Vectors (4), 2 => Vectors (5), 3 => Vectors (6)); end Get_Orientation_Float; procedure Get_Position_Discrete (X : out Types.Integer_t; Y : out Types.Integer_t; Z : out Types.Integer_t) is V : aliased Types.Vector_3i_t; begin Get_Position_Discrete_List (V); X := V (1); Y := V (2); Z := V (3); end Get_Position_Discrete; procedure Get_Position_Discrete_List (Position : out Types.Vector_3i_t) is begin Thin.Get_Listeneriv (Parameter => Thin.AL_POSITION, Values => Position (Position'First)'Address); end Get_Position_Discrete_List; procedure Get_Position_Float (X : out Types.Float_t; Y : out Types.Float_t; Z : out Types.Float_t) is V : aliased Types.Vector_3f_t; begin Get_Position_Float_List (V); X := V (1); Y := V (2); Z := V (3); end Get_Position_Float; procedure Get_Position_Float_List (Position : out Types.Vector_3f_t) is begin Thin.Get_Listenerfv (Parameter => Thin.AL_POSITION, Values => Position (Position'First)'Address); end Get_Position_Float_List; procedure Get_Velocity_Discrete (X : out Types.Integer_t; Y : out Types.Integer_t; Z : out Types.Integer_t) is V : aliased Types.Vector_3i_t; begin Get_Velocity_Discrete_List (V); X := V (1); Y := V (2); Z := V (3); end Get_Velocity_Discrete; procedure Get_Velocity_Discrete_List (Velocity : out Types.Vector_3i_t) is begin Thin.Get_Listeneriv (Parameter => Thin.AL_POSITION, Values => Velocity (Velocity'First)'Address); end Get_Velocity_Discrete_List; procedure Get_Velocity_Float (X : out Types.Float_t; Y : out Types.Float_t; Z : out Types.Float_t) is V : aliased Types.Vector_3f_t; begin Get_Velocity_Float_List (V); X := V (1); Y := V (2); Z := V (3); end Get_Velocity_Float; procedure Get_Velocity_Float_List (Velocity : out Types.Vector_3f_t) is begin Thin.Get_Listenerfv (Parameter => Thin.AL_POSITION, Values => Velocity (Velocity'First)'Address); end Get_Velocity_Float_List; -- -- Set_* -- procedure Set_Gain (Gain : in Types.Float_t) is begin Thin.Listenerf (Parameter => Thin.AL_GAIN, Value => Gain); end Set_Gain; procedure Set_Orientation_Discrete (Forward : in Types.Vector_3i_t; Up : in Types.Vector_3i_t) is type Orient_Vectors_t is new Types.Vector_i_t (1 .. 6); Vectors : constant Orient_Vectors_t := (1 => Forward (1), 2 => Forward (2), 3 => Forward (3), 4 => Up (1), 5 => Up (2), 6 => Up (3)); begin Thin.Listeneriv (Parameter => Thin.AL_ORIENTATION, Values => Vectors (Vectors'First)'Address); end Set_Orientation_Discrete; procedure Set_Orientation_Float (Forward : in Types.Vector_3f_t; Up : in Types.Vector_3f_t) is type Orient_Vectors_t is new Types.Vector_f_t (1 .. 6); Vectors : constant Orient_Vectors_t := (1 => Forward (1), 2 => Forward (2), 3 => Forward (3), 4 => Up (1), 5 => Up (2), 6 => Up (3)); begin Thin.Listenerfv (Parameter => Thin.AL_ORIENTATION, Values => Vectors (Vectors'First)'Address); end Set_Orientation_Float; procedure Set_Position_Discrete (X : in Types.Integer_t; Y : in Types.Integer_t; Z : in Types.Integer_t) is begin Set_Position_Discrete_List ((X, Y, Z)); end Set_Position_Discrete; procedure Set_Position_Discrete_List (Position : in Types.Vector_3i_t) is begin Thin.Listeneriv (Parameter => Thin.AL_POSITION, Values => Position (Position'First)'Address); end Set_Position_Discrete_List; procedure Set_Position_Float (X : in Types.Float_t; Y : in Types.Float_t; Z : in Types.Float_t) is begin Set_Position_Float_List ((X, Y, Z)); end Set_Position_Float; procedure Set_Position_Float_List (Position : in Types.Vector_3f_t) is begin Thin.Listenerfv (Parameter => Thin.AL_POSITION, Values => Position (Position'First)'Address); end Set_Position_Float_List; procedure Set_Velocity_Discrete (X : in Types.Integer_t; Y : in Types.Integer_t; Z : in Types.Integer_t) is begin Set_Velocity_Discrete_List ((X, Y, Z)); end Set_Velocity_Discrete; procedure Set_Velocity_Discrete_List (Velocity : in Types.Vector_3i_t) is begin Thin.Listeneriv (Parameter => Thin.AL_POSITION, Values => Velocity (Velocity'First)'Address); end Set_Velocity_Discrete_List; procedure Set_Velocity_Float (X : in Types.Float_t; Y : in Types.Float_t; Z : in Types.Float_t) is begin Set_Velocity_Float_List ((X, Y, Z)); end Set_Velocity_Float; procedure Set_Velocity_Float_List (Velocity : in Types.Vector_3f_t) is begin Thin.Listenerfv (Parameter => Thin.AL_POSITION, Values => Velocity (Velocity'First)'Address); end Set_Velocity_Float_List; end OpenAL.Listener;
with Ada.Text_IO; with Ada.Text_IO.Complex_IO; with Ada.Numerics.Generic_Real_Arrays; with Ada.Numerics.Generic_Complex_Types; with Ada.Numerics.Generic_Complex_Arrays; with Ada.Numerics.Generic_Elementary_Functions; with Ada.Numerics.Generic_Complex_Elementary_Functions; with Ada_Lapack; use Ada.Text_IO; procedure tdgetri is type Real is digits 18; package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real); package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Real); package Complex_Arrays is new Ada.Numerics.Generic_Complex_Arrays (Real_Arrays, Complex_Types); package Real_Maths is new Ada.Numerics.Generic_Elementary_Functions (Real); package Complex_Maths is new Ada.Numerics.Generic_Complex_Elementary_Functions (Complex_Types); package Real_IO is new Ada.Text_IO.Float_IO (Real); package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); package Complex_IO is new Ada.Text_IO.Complex_IO (Complex_Types); package Lapack is new Ada_Lapack(Real, Complex_Types, Real_Arrays, Complex_Arrays); use Lapack; use Real_Arrays; use Complex_Types; use Complex_Arrays; use Real_IO; use Integer_IO; use Complex_IO; use Real_Maths; use Complex_Maths; matrix : Real_Matrix (1..5,1..5); matrix_copy : Real_Matrix (1..5,1..5); matrix_rows : Integer := Matrix'Length (1); matrix_cols : Integer := Matrix'Length (2); pivots : Integer_Vector (1..matrix_rows); short_vector : Real_Vector (1..1); return_code : Integer; begin matrix :=( ( 6.80,-6.05,-0.45, 8.32,-9.67), (-2.11,-3.30, 2.58, 2.71,-5.14), ( 5.66, 5.36,-2.70, 4.35,-7.26), ( 5.97,-4.44, 0.27,-7.17, 6.08), ( 8.23, 1.08, 9.04, 2.14,-6.87) ); matrix_copy := matrix; GETRF ( A => matrix, M => matrix_rows, N => matrix_rows, LDA => matrix_rows, IPIV => pivots, INFO => return_code ); GETRI ( A => matrix, N => matrix_rows, LDA => matrix_rows, IPIV => pivots, WORK => short_vector, LWORK => -1, INFO => return_code); declare work_vector_rows : Integer := Integer( short_vector(1) ); work_vector : Real_Vector (1 .. work_vector_rows); begin GETRI ( A => matrix, N => matrix_rows, LDA => matrix_rows, IPIV => pivots, WORK => work_vector, LWORK => work_vector_rows, INFO => return_code); end; if (return_code /= 0) then Put_line ("The matrix is probably singular."); else Put_line ("Matrix"); for i in matrix_copy'range(1) loop for j in matrix_copy'range(2) loop put(matrix_copy(i,j),3,3,0); put(" "); end loop; new_line; end loop; new_line; Put_line ("Inverse"); for i in matrix'range(1) loop for j in matrix'range(2) loop put(matrix(i,j),3,3,0); put(" "); end loop; new_line; end loop; end if; end tdgetri;
package body Generic_Sliding_Statistics is Buffer : array (1 .. Buffer_Size) of Element; Buffer_Ix : Positive range Buffer'Range := Buffer'First; Fill_Level : Natural range 0 .. Buffer'Last := 0; package body Averages is function Average (New_Reading : Element) return Element is begin Add_Reading (New_Reading); return Average; end Average; -- function Average return Element is begin if Fill_Level > 0 then declare Buffer_Sum : Element := Buffer (Buffer'First); begin for i in Buffer'First + 1 .. Fill_Level loop Buffer_Sum := Buffer_Sum + Buffer (i); end loop; return Buffer_Sum / Real (Fill_Level); end; else raise No_Elements_in_Stats_Buffer; end if; end Average; end Averages; -- package body MinMax is function Min (New_Reading : Element) return Element is begin Add_Reading (New_Reading); return Min; end Min; -- function Max (New_Reading : Element) return Element is begin Add_Reading (New_Reading); return Max; end Max; -- function Min return Element is begin if Fill_Level > 0 then declare Min_Element : Element := Buffer (Buffer'First); begin for i in Buffer'First + 1 .. Fill_Level loop if Buffer (i) < Min_Element then Min_Element := Buffer (i); end if; end loop; return Min_Element; end; else raise No_Elements_in_Stats_Buffer; end if; end Min; -- function Max return Element is begin if Fill_Level > 0 then declare Max_Element : Element := Buffer (Buffer'First); begin for i in Buffer'First + 1 .. Fill_Level loop if Max_Element < Buffer (i) then Max_Element := Buffer (i); end if; end loop; return Max_Element; end; else raise No_Elements_in_Stats_Buffer; end if; end Max; end MinMax; ----------------- -- Add_Reading -- ----------------- procedure Add_Reading (New_Reading : Element) is begin Buffer (Buffer_Ix) := New_Reading; if Buffer_Ix = Buffer'Last then Buffer_Ix := Buffer'First; else Buffer_Ix := Buffer_Ix + 1; end if; Fill_Level := Natural'Min (Fill_Level + 1, Buffer'Last); end Add_Reading; end Generic_Sliding_Statistics;
-- { dg-do compile } -- { dg-options "-O2 -fdump-tree-optimized" } pragma Suppress (Overflow_Check); function Opt40 (X : Integer; Y : Integer) return Positive is Z : Integer; begin if X >= Y then return 1; end if; Z := Y - X; return Z; end; -- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } }
-- { dg-do compile } package body Addr8 is procedure Proc (B: Bytes) is O: Integer; for O'Address use B'Address; begin null; end; end Addr8;
with Ada.Containers.Array_Sorting; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System.Address_To_Named_Access_Conversions; with System.Growth; with System.Long_Long_Integer_Types; package body Ada.Containers.Vectors is pragma Check_Policy (Validate => Ignore); use type Copy_On_Write.Data_Access; use type System.Address; use type System.Long_Long_Integer_Types.Word_Integer; subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer; package DA_Conv is new System.Address_To_Named_Access_Conversions (Data, Data_Access); function Upcast is new Unchecked_Conversion (Data_Access, Copy_On_Write.Data_Access); function Downcast is new Unchecked_Conversion (Copy_On_Write.Data_Access, Data_Access); -- diff (Free) procedure Free is new Unchecked_Deallocation (Data, Data_Access); procedure Assign_Element ( Target : out Element_Type; Source : Element_Type); procedure Assign_Element ( Target : out Element_Type; Source : Element_Type) is begin Target := Source; end Assign_Element; procedure Swap_Element (I, J : Word_Integer; Params : System.Address); procedure Swap_Element (I, J : Word_Integer; Params : System.Address) is Data : constant Data_Access := DA_Conv.To_Pointer (Params); Temp : constant Element_Type := Data.Items (Index_Type'Val (I)); begin Assign_Element ( Data.Items (Index_Type'Val (I)), Data.Items (Index_Type'Val (J))); Assign_Element (Data.Items (Index_Type'Val (J)), Temp); end Swap_Element; -- diff (Equivalent_Element) -- -- -- -- -- -- -- diff (Allocate_Element) -- -- -- -- -- -- -- -- procedure Free_Data (Data : in out Copy_On_Write.Data_Access); procedure Free_Data (Data : in out Copy_On_Write.Data_Access) is X : Data_Access := Downcast (Data); begin -- diff -- diff -- diff Free (X); Data := null; end Free_Data; procedure Allocate_Data ( Target : out not null Copy_On_Write.Data_Access; New_Length : Count_Type; Capacity : Count_Type); procedure Allocate_Data ( Target : out not null Copy_On_Write.Data_Access; New_Length : Count_Type; Capacity : Count_Type) is New_Data : constant Data_Access := new Data'( Capacity_Last => Index_Type'First - 1 + Index_Type'Base (Capacity), Super => <>, Max_Length => New_Length, Items => <>); begin Target := Upcast (New_Data); end Allocate_Data; -- diff (Move_Data) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- procedure Copy_Data ( Target : out not null Copy_On_Write.Data_Access; Source : not null Copy_On_Write.Data_Access; Length : Count_Type; New_Length : Count_Type; Capacity : Count_Type); procedure Copy_Data ( Target : out not null Copy_On_Write.Data_Access; Source : not null Copy_On_Write.Data_Access; Length : Count_Type; New_Length : Count_Type; Capacity : Count_Type) is begin Allocate_Data (Target, New_Length, Capacity); declare subtype R is Extended_Index range Index_Type'First .. Index_Type'First - 1 + Index_Type'Base (Length); begin Downcast (Target).Items (R) := Downcast (Source).Items (R); -- diff -- diff -- diff -- diff -- diff -- diff end; end Copy_Data; function Max_Length (Data : not null Copy_On_Write.Data_Access) return not null access Count_Type; function Max_Length (Data : not null Copy_On_Write.Data_Access) return not null access Count_Type is begin return Downcast (Data).Max_Length'Access; end Max_Length; procedure Reallocate ( Container : in out Vector; Length : Count_Type; Capacity : Count_Type; To_Update : Boolean); procedure Reallocate ( Container : in out Vector; Length : Count_Type; Capacity : Count_Type; To_Update : Boolean) is begin Copy_On_Write.Unique ( Target => Container.Super'Access, Target_Length => Container.Length, Target_Capacity => Vectors.Capacity (Container), New_Length => Length, New_Capacity => Capacity, To_Update => To_Update, Allocate => Allocate_Data'Access, Move => Copy_Data'Access, Copy => Copy_Data'Access, Free => Free_Data'Access, Max_Length => Max_Length'Access); end Reallocate; procedure Unique (Container : in out Vector; To_Update : Boolean); procedure Unique (Container : in out Vector; To_Update : Boolean) is begin if Copy_On_Write.Shared (Container.Super.Data) then Reallocate ( Container, Container.Length, Capacity (Container), -- not shrinking To_Update); end if; end Unique; -- implementation function Empty_Vector return Vector is begin return (Finalization.Controlled with Super => <>, Length => 0); end Empty_Vector; function Has_Element (Position : Cursor) return Boolean is begin return Position /= No_Element; end Has_Element; overriding function "=" (Left, Right : Vector) return Boolean is begin if Left.Length /= Right.Length then return False; elsif Left.Length = 0 or else Left.Super.Data = Right.Super.Data then return True; else Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private for I in Index_Type'First .. Last (Left) loop if Downcast (Left.Super.Data).Items (I) /= Downcast (Right.Super.Data).Items (I) then return False; end if; -- diff -- diff -- diff -- diff -- diff end loop; return True; end if; end "="; function To_Vector (Length : Count_Type) return Vector is begin return Result : Vector do Insert_Space (Result, Index_Type'First, Length); end return; end To_Vector; function To_Vector (New_Item : Element_Type; Length : Count_Type) return Vector is begin return Result : Vector do Append (Result, New_Item, Length); end return; end To_Vector; function Generic_Array_To_Vector (S : Element_Array) return Vector is begin return Result : Vector do declare Length : constant Count_Type := S'Length; subtype R1 is Extended_Index range Index_Type'First .. Index_Type'First - 1 + Index_Type'Base (Length); begin Set_Length (Result, Length); Downcast (Result.Super.Data).Items (R1) := Vectors.Element_Array (S); end; end return; end Generic_Array_To_Vector; function "&" (Left, Right : Vector) return Vector is begin return Result : Vector := Left do Append (Result, Right); end return; end "&"; function "&" (Left : Vector; Right : Element_Type) return Vector is begin return Result : Vector := Left do Append (Result, Right); end return; end "&"; function "&" (Left : Element_Type; Right : Vector) return Vector is begin return Result : Vector do Reallocate (Result, 0, 1 + Right.Length, True); Append (Result, Left); Append (Result, Right); end return; end "&"; function "&" (Left, Right : Element_Type) return Vector is begin return Result : Vector do Reallocate (Result, 0, 2, True); Append (Result, Left); Append (Result, Right); end return; end "&"; function Capacity (Container : Vector) return Count_Type is Data : constant Data_Access := Downcast (Container.Super.Data); begin if Data = null then return 0; else return Count_Type'Base (Data.Capacity_Last - Index_Type'First + 1); end if; end Capacity; procedure Reserve_Capacity ( Container : in out Vector; Capacity : Count_Type) is New_Capacity : constant Count_Type := Count_Type'Max (Capacity, Container.Length); begin Reallocate (Container, Container.Length, New_Capacity, True); end Reserve_Capacity; function Length (Container : Vector) return Count_Type is begin return Container.Length; end Length; procedure Set_Length (Container : in out Vector; Length : Count_Type) is Old_Capacity : constant Count_Type := Capacity (Container); Failure : Boolean; begin Copy_On_Write.In_Place_Set_Length ( Target => Container.Super'Access, Target_Length => Container.Length, Target_Capacity => Old_Capacity, New_Length => Length, Failure => Failure, Max_Length => Max_Length'Access); if Failure then declare function Grow is new System.Growth.Good_Grow ( Count_Type, Component_Size => Element_Array'Component_Size); New_Capacity : Count_Type; begin if Old_Capacity >= Length then New_Capacity := Old_Capacity; -- not shrinking else New_Capacity := Count_Type'Max (Grow (Old_Capacity), Length); end if; Reallocate (Container, Length, New_Capacity, False); end; end if; Container.Length := Length; end Set_Length; function Is_Empty (Container : Vector) return Boolean is begin return Container.Length = 0; end Is_Empty; procedure Clear (Container : in out Vector) is begin Copy_On_Write.Clear (Container.Super'Access, Free => Free_Data'Access); Container.Length := 0; end Clear; function To_Cursor ( Container : Vector'Class; Index : Extended_Index) return Cursor is pragma Check (Pre, Check => Index <= Last_Index (Container) + 1 or else raise Constraint_Error); begin if Index = Index_Type'First + Index_Type'Base (Container.Length) then return No_Element; -- Last_Index (Container) + 1 else return Index; end if; end To_Cursor; function Element ( Container : Vector'Class; Index : Index_Type) return Element_Type is begin return Constant_Reference ( Vector (Container), Index) -- checking Constraint_Error .Element.all; end Element; procedure Replace_Element ( Container : in out Vector; Position : Cursor; New_Item : Element_Type) is pragma Check (Pre, Check => Position in Index_Type'First .. Last (Container) or else raise Constraint_Error); begin Unique (Container, True); declare E : Element_Type renames Downcast (Container.Super.Data).Items (Position); begin -- diff Assign_Element (E, New_Item); end; end Replace_Element; procedure Query_Element ( Container : Vector'Class; Index : Index_Type; Process : not null access procedure (Element : Element_Type)) is begin Process ( Constant_Reference ( Vector (Container), Index) -- checking Constraint_Error .Element.all); end Query_Element; procedure Update_Element ( Container : in out Vector'Class; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)) is begin Process ( Reference (Vector (Container), Position) -- checking Constraint_Error .Element.all); end Update_Element; function Constant_Reference (Container : aliased Vector; Position : Cursor) return Constant_Reference_Type is pragma Check (Pre, Check => Position in Index_Type'First .. Last (Container) or else raise Constraint_Error); begin Unique (Container'Unrestricted_Access.all, False); declare Data : constant Data_Access := Downcast (Container.Super.Data); begin return (Element => Data.all.Items (Position)'Access); -- [gcc-6] .all end; end Constant_Reference; function Reference (Container : aliased in out Vector; Position : Cursor) return Reference_Type is pragma Check (Pre, Check => Position in Index_Type'First .. Last (Container) or else raise Constraint_Error); begin Unique (Container, True); declare Data : constant Data_Access := Downcast (Container.Super.Data); begin return (Element => Data.all.Items (Position)'Access); -- [gcc-6] .all end; end Reference; procedure Assign (Target : in out Vector; Source : Vector) is begin Copy_On_Write.Assign ( Target.Super'Access, Source.Super'Access, Free => Free_Data'Access); Target.Length := Source.Length; end Assign; function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector is begin return Result : Vector := Source do Reserve_Capacity (Result, Capacity); end return; end Copy; procedure Move (Target : in out Vector; Source : in out Vector) is begin Copy_On_Write.Move ( Target.Super'Access, Source.Super'Access, Free => Free_Data'Access); Target.Length := Source.Length; Source.Length := 0; end Move; procedure Insert ( Container : in out Vector; Before : Cursor; New_Item : Vector) is Position : Cursor; begin Insert ( Container, Before, -- checking Constraint_Error New_Item, -- checking Program_Error if same nonempty container Position); end Insert; procedure Insert ( Container : in out Vector; Before : Cursor; New_Item : Vector; Position : out Cursor) is pragma Check (Pre, Check => Before <= Last (Container) + 1 or else raise Constraint_Error); pragma Check (Pre, Check => Container'Address /= New_Item'Address or else Is_Empty (Container) or else raise Program_Error); -- same nonempty container (should this case be supported?) New_Item_Length : constant Count_Type := New_Item.Length; begin if Container.Length = 0 and then Capacity (Container) < New_Item_Length -- New_Item_Length > 0 then Position := Index_Type'First; Assign (Container, New_Item); else Insert_Space (Container, Before, Position, New_Item_Length); if New_Item_Length > 0 then Unique (New_Item'Unrestricted_Access.all, False); -- private declare subtype R1 is Extended_Index range Position .. Position + Index_Type'Base (New_Item_Length) - 1; subtype R2 is Extended_Index range Index_Type'First .. Index_Type'First - 1 + Index_Type'Base (New_Item_Length); begin Downcast (Container.Super.Data).Items (R1) := Downcast (New_Item.Super.Data).Items (R2); end; -- diff -- diff -- diff -- diff end if; end if; end Insert; procedure Insert ( Container : in out Vector; Before : Cursor; New_Item : Element_Type; Count : Count_Type := 1) is Position : Cursor; begin Insert ( Container, Before, -- checking Constraint_Error New_Item, Position, Count); end Insert; procedure Insert ( Container : in out Vector; Before : Cursor; New_Item : Element_Type; Position : out Cursor; Count : Count_Type := 1) is begin Insert_Space ( Container, Before, -- checking Constraint_Error Position, Count); for I in Position .. Position + Index_Type'Base (Count) - 1 loop declare E : Element_Type renames Downcast (Container.Super.Data).Items (I); begin -- diff Assign_Element (E, New_Item); end; end loop; end Insert; procedure Prepend (Container : in out Vector; New_Item : Vector) is begin Insert ( Container, Index_Type'First, New_Item); -- checking Program_Error if same nonempty container end Prepend; procedure Prepend ( Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1) is begin Insert (Container, Index_Type'First, New_Item, Count); end Prepend; procedure Append (Container : in out Vector; New_Item : Vector) is New_Item_Length : constant Count_Type := New_Item.Length; Old_Length : constant Count_Type := Container.Length; begin if Old_Length = 0 and then Capacity (Container) < New_Item_Length then Assign (Container, New_Item); elsif New_Item_Length > 0 then Set_Length (Container, Old_Length + New_Item_Length); Unique (New_Item'Unrestricted_Access.all, False); -- private declare subtype R1 is Extended_Index range Index_Type'First + Index_Type'Base (Old_Length) .. Last (Container); subtype R2 is Extended_Index range Index_Type'First .. Index_Type'First - 1 + Index_Type'Base (New_Item_Length); -- Do not use New_Item.Length or Last (New_Item) in here -- for Append (X, X). begin Downcast (Container.Super.Data).Items (R1) := Downcast (New_Item.Super.Data).Items (R2); end; -- diff -- diff end if; end Append; procedure Append ( Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1) is Old_Length : constant Count_Type := Container.Length; begin Set_Length (Container, Old_Length + Count); for I in Index_Type'First + Index_Type'Base (Old_Length) .. Last (Container) loop declare E : Element_Type renames Downcast (Container.Super.Data).Items (I); begin -- diff Assign_Element (E, New_Item); end; end loop; end Append; procedure Insert_Space ( Container : in out Vector'Class; Before : Extended_Index; Count : Count_Type := 1) is Position : Cursor; begin Insert_Space ( Vector (Container), Before, -- checking Constraint_Error Position, Count); end Insert_Space; procedure Insert_Space ( Container : in out Vector; Before : Cursor; Position : out Cursor; Count : Count_Type := 1) is pragma Check (Pre, Check => Before <= Last (Container) + 1 or else raise Constraint_Error); Old_Length : constant Count_Type := Container.Length; After_Last : constant Index_Type'Base := Index_Type'First + Index_Type'Base (Old_Length); begin Position := Before; if Position = No_Element then Position := After_Last; end if; if Count > 0 then Set_Length (Container, Old_Length + Count); if Position < After_Last then -- Last_Index (Container) + 1 Unique (Container, True); declare Data : constant Data_Access := Downcast (Container.Super.Data); subtype R1 is Extended_Index range Position + Index_Type'Base (Count) .. After_Last - 1 + Index_Type'Base (Count); subtype R2 is Extended_Index range Position .. After_Last - 1; begin -- diff -- diff -- diff Data.Items (R1) := Data.Items (R2); -- diff -- diff -- diff end; end if; end if; end Insert_Space; procedure Delete ( Container : in out Vector; Position : in out Cursor; Count : Count_Type := 1) is pragma Check (Pre, Check => Position in Index_Type'First .. Last (Container) - Index_Type'Base (Count) + 1 or else raise Constraint_Error); begin if Count > 0 then declare Old_Length : constant Count_Type := Container.Length; After_Last : constant Index_Type'Base := Index_Type'First + Index_Type'Base (Old_Length); begin if Position + Index_Type'Base (Count) < After_Last then Unique (Container, True); declare Data : constant Data_Access := Downcast (Container.Super.Data); subtype R1 is Extended_Index range Position .. After_Last - 1 - Index_Type'Base (Count); subtype R2 is Extended_Index range Position + Index_Type'Base (Count) .. After_Last - 1; begin -- diff -- diff -- diff Data.Items (R1) := Data.Items (R2); -- diff -- diff -- diff end; end if; Set_Length (Container, Old_Length - Count); Position := No_Element; end; end if; end Delete; procedure Delete_First ( Container : in out Vector'Class; Count : Count_Type := 1) is Position : Cursor := Index_Type'First; begin Delete (Vector (Container), Position, Count => Count); end Delete_First; procedure Delete_Last ( Container : in out Vector'Class; Count : Count_Type := 1) is begin Set_Length (Vector (Container), Container.Length - Count); end Delete_Last; procedure Reverse_Elements (Container : in out Vector) is begin if Container.Length > 1 then Unique (Container, True); Array_Sorting.In_Place_Reverse ( Index_Type'Pos (Index_Type'First), Index_Type'Pos (Last (Container)), DA_Conv.To_Address (Downcast (Container.Super.Data)), Swap => Swap_Element'Access); end if; end Reverse_Elements; procedure Swap (Container : in out Vector; I, J : Cursor) is pragma Check (Pre, Check => (I in Index_Type'First .. Last (Container) and then J in Index_Type'First .. Last (Container)) or else raise Constraint_Error); begin Unique (Container, True); Swap_Element ( Index_Type'Pos (I), Index_Type'Pos (J), DA_Conv.To_Address (Downcast (Container.Super.Data))); end Swap; function First_Index (Container : Vector'Class) return Index_Type is pragma Unreferenced (Container); begin return Index_Type'First; end First_Index; function First (Container : Vector) return Cursor is begin if Container.Length = 0 then return No_Element; else return Index_Type'First; end if; end First; function First_Element (Container : Vector'Class) return Element_Type is begin return Element (Container, Index_Type'First); end First_Element; function Last_Index (Container : Vector'Class) return Extended_Index is begin return Last (Vector (Container)); end Last_Index; function Last (Container : Vector) return Cursor is begin return Index_Type'First - 1 + Index_Type'Base (Container.Length); end Last; function Last_Element (Container : Vector'Class) return Element_Type is begin return Element (Container, Last_Index (Container)); end Last_Element; function Find_Index ( Container : Vector'Class; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index is begin if Index = Index_Type'First and then Container.Length = 0 then return No_Index; else return Find ( Vector (Container), Item, Index); -- checking Constraint_Error end if; end Find_Index; function Find ( Container : Vector; Item : Element_Type) return Cursor is begin return Find (Container, Item, First (Container)); end Find; function Find ( Container : Vector; Item : Element_Type; Position : Cursor) return Cursor is pragma Check (Pre, Check => Position in Index_Type'First .. Last (Container) or else (Is_Empty (Container) and then Position = No_Element) or else raise Constraint_Error); Last : constant Cursor := Vectors.Last (Container); begin if Position in Index_Type'First .. Last then Unique (Container'Unrestricted_Access.all, False); -- private for I in Position .. Last loop if Downcast (Container.Super.Data).Items (I) = Item then -- diff -- diff -- diff return I; end if; end loop; end if; return No_Element; end Find; function Reverse_Find_Index ( Container : Vector'Class; Item : Element_Type; Index : Index_Type := Index_Type'Last) return Extended_Index is Start : constant Extended_Index := Extended_Index'Min (Index, Last_Index (Container)); begin return Reverse_Find ( Vector (Container), Item, Start); -- checking Constraint_Error end Reverse_Find_Index; function Reverse_Find ( Container : Vector; Item : Element_Type) return Cursor is begin return Reverse_Find (Container, Item, Last (Container)); end Reverse_Find; function Reverse_Find ( Container : Vector; Item : Element_Type; Position : Cursor) return Cursor is pragma Check (Pre, Check => (Position in Index_Type'First .. Last (Container)) or else (Is_Empty (Container) and then Position = No_Element) or else raise Constraint_Error); begin if Position >= Index_Type'First then Unique (Container'Unrestricted_Access.all, False); -- private for I in reverse Index_Type'First .. Position loop if Downcast (Container.Super.Data).Items (I) = Item then -- diff -- diff -- diff return I; end if; end loop; end if; return No_Element; end Reverse_Find; function Contains (Container : Vector; Item : Element_Type) return Boolean is begin return Find (Container, Item) /= No_Element; end Contains; procedure Iterate ( Container : Vector'Class; Process : not null access procedure (Position : Cursor)) is begin for I in Index_Type'First .. Last (Vector (Container)) loop Process (I); end loop; end Iterate; procedure Reverse_Iterate ( Container : Vector'Class; Process : not null access procedure (Position : Cursor)) is begin for I in reverse Index_Type'First .. Last (Vector (Container)) loop Process (I); end loop; end Reverse_Iterate; function Iterate (Container : Vector'Class) return Vector_Iterator_Interfaces.Reversible_Iterator'Class is begin return Vector_Iterator'( First => First (Vector (Container)), Last => Last (Vector (Container))); end Iterate; function Iterate (Container : Vector'Class; First, Last : Cursor) return Vector_Iterator_Interfaces.Reversible_Iterator'Class is pragma Check (Pre, Check => (First <= Vectors.Last (Vector (Container)) + 1 and then Last <= Vectors.Last (Vector (Container))) or else raise Constraint_Error); Actual_First : Cursor := First; Actual_Last : Cursor := Last; begin if Actual_First = No_Element or else Actual_Last < Actual_First -- implies Last = No_Element then Actual_First := No_Element; Actual_Last := No_Element; end if; return Vector_Iterator'(First => Actual_First, Last => Actual_Last); end Iterate; function Constant_Reference (Container : aliased Vector) return Slicing.Constant_Reference_Type is begin Unique (Container'Unrestricted_Access.all, False); declare type Element_Array_Access is access constant Element_Array; for Element_Array_Access'Storage_Size use 0; Data : constant Data_Access := Downcast (Container.Super.Data); begin return Slicing.Constant_Slice ( Element_Array_Access'(Data.Items'Unrestricted_Access).all, Index_Type'First, Last (Container)); end; end Constant_Reference; function Reference (Container : aliased in out Vector) return Slicing.Reference_Type is begin Unique (Container, True); declare type Element_Array_Access is access all Element_Array; for Element_Array_Access'Storage_Size use 0; Data : constant Data_Access := Downcast (Container.Super.Data); begin return Slicing.Slice ( Element_Array_Access'(Data.Items'Unrestricted_Access).all, Index_Type'First, Last (Container)); end; end Reference; overriding procedure Adjust (Object : in out Vector) is begin Copy_On_Write.Adjust (Object.Super'Access); end Adjust; overriding function First (Object : Vector_Iterator) return Cursor is begin return Object.First; end First; overriding function Next (Object : Vector_Iterator; Position : Cursor) return Cursor is begin if Position >= Object.Last then return No_Element; else return Position + 1; end if; end Next; overriding function Last (Object : Vector_Iterator) return Cursor is begin return Object.Last; end Last; overriding function Previous (Object : Vector_Iterator; Position : Cursor) return Cursor is begin if Position <= Object.First then return No_Element; else return Position - 1; end if; end Previous; function Constant_Indexing ( Container : aliased Vector'Class; Index : Index_Type) return Constant_Reference_Type is begin return Constant_Reference (Vector (Container), Index); end Constant_Indexing; function Indexing ( Container : aliased in out Vector'Class; Index : Index_Type) return Reference_Type is begin return Reference (Vector (Container), Index); end Indexing; package body Generic_Sorting is function LT (Left, Right : Word_Integer; Params : System.Address) return Boolean; function LT (Left, Right : Word_Integer; Params : System.Address) return Boolean is Data : constant Data_Access := DA_Conv.To_Pointer (Params); begin return Data.Items (Index_Type'Val (Left)) < Data.Items (Index_Type'Val (Right)); end LT; function Is_Sorted (Container : Vector) return Boolean is begin if Container.Length <= 1 then return True; else Unique (Container'Unrestricted_Access.all, False); -- private return Array_Sorting.Is_Sorted ( Index_Type'Pos (Index_Type'First), Index_Type'Pos (Last (Container)), DA_Conv.To_Address (Downcast (Container.Super.Data)), LT => LT'Access); end if; end Is_Sorted; procedure Sort (Container : in out Vector) is begin if Container.Length > 1 then Unique (Container, True); Array_Sorting.In_Place_Merge_Sort ( Index_Type'Pos (Index_Type'First), Index_Type'Pos (Last (Container)), DA_Conv.To_Address (Downcast (Container.Super.Data)), LT => LT'Access, Swap => Swap_Element'Access); end if; end Sort; procedure Merge (Target : in out Vector; Source : in out Vector) is pragma Check (Pre, Check => Target'Address /= Source'Address or else Is_Empty (Target) or else raise Program_Error); -- RM A.18.2(237/3), same nonempty container begin if Source.Length > 0 then declare Old_Length : constant Count_Type := Target.Length; begin if Old_Length = 0 then Move (Target, Source); else Append (Target, Source); Unique (Target, True); -- diff -- diff -- diff -- diff -- diff -- diff -- diff Set_Length (Source, 0); Array_Sorting.In_Place_Merge ( Index_Type'Pos (Index_Type'First), Word_Integer (Index_Type'First) + Word_Integer (Old_Length), Index_Type'Pos (Last (Target)), DA_Conv.To_Address (Downcast (Target.Super.Data)), LT => LT'Access, Swap => Swap_Element'Access); end if; end; end if; end Merge; end Generic_Sorting; package body Streaming is procedure Read ( Stream : not null access Streams.Root_Stream_Type'Class; Item : out Vector) is Length : Count_Type'Base; begin Count_Type'Base'Read (Stream, Length); Clear (Item); if Length > 0 then Set_Length (Item, Length); Element_Array'Read ( Stream, Downcast (Item.Super.Data).Items ( Index_Type'First .. Last (Item))); -- diff -- diff -- diff -- diff -- diff end if; end Read; procedure Write ( Stream : not null access Streams.Root_Stream_Type'Class; Item : Vector) is Length : constant Count_Type := Vectors.Length (Item); begin Count_Type'Write (Stream, Length); if Length > 0 then Unique (Item'Unrestricted_Access.all, False); -- private Element_Array'Write ( Stream, Downcast (Item.Super.Data).Items ( Index_Type'First .. Last (Item))); -- diff end if; end Write; end Streaming; end Ada.Containers.Vectors;
package Taft_Type1_Pkg1 is procedure Check; private type TAMT1; type TAMT1_Access is access TAMT1; type TAMT2; type TAMT2_Access is access TAMT2; end Taft_Type1_Pkg1;
package body Incomplete5_Pkg is function Get_Handle (Object: Base_Object) return Access_Type is begin return Object.Handle; end; function From_Handle (Handle: Access_Type) return Base_Object is begin return (Handle=>Handle); end; end Incomplete5_Pkg;
procedure Character_Type is type char is new Character; begin null; end Character_Type;
-- { dg-do compile } -- { dg-options "-gnatc" } package Sync_Iface_Test is type Iface is limited interface; procedure Do_Test (Container : in out Iface; Process : access procedure (E : Natural)) is abstract; protected type Buffer is new Iface with overriding procedure Do_Test (Process : access procedure (E : Natural)); end; end;
-- { dg-do compile } procedure Slice9 is function Ident (I : Integer) return Integer is begin return I; end; subtype S is String (Ident(5)..Ident(9)); Dest : S; Src : String (Ident(1)..Ident(5)) := "ABCDE"; begin Dest (Ident(5)..Ident(7)) := Src (Ident(1)..Ident(3)); end;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 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 AUnit.Assertions; with AUnit.Test_Caller; with Orka.SIMD.SSE.Singles; with Orka.SIMD.FMA.Singles.Arithmetic; package body Test_SIMD_FMA_Singles_Arithmetic is use Orka; use Orka.SIMD.SSE.Singles; use Orka.SIMD.FMA.Singles.Arithmetic; use AUnit.Assertions; package Caller is new AUnit.Test_Caller (Test); Test_Suite : aliased AUnit.Test_Suites.Test_Suite; function Suite return AUnit.Test_Suites.Access_Test_Suite is Name : constant String := "(SIMD - FMA - Singles - Arithmetic) "; begin Test_Suite.Add_Test (Caller.Create (Name & "Test '*' operator on matrix and vector", Test_Multiply_Vector'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test '*' operator on matrices", Test_Multiply_Matrices'Access)); return Test_Suite'Access; end Suite; procedure Test_Multiply_Vector (Object : in out Test) is -- Matrix is an array of columns Left : constant m128_Array := ((1.0, 5.0, 9.0, 13.0), (2.0, 6.0, 10.0, 14.0), (3.0, 7.0, 11.0, 15.0), (4.0, 8.0, 12.0, 16.0)); Right : constant m128 := (2.0, 1.0, 1.0, 1.0); Expected : constant m128 := (11.0, 31.0, 51.0, 71.0); Result : constant m128 := Left * Right; begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Multiply_Vector; procedure Test_Multiply_Matrices (Object : in out Test) is -- Each matrix is an array of columns Left : constant m128_Array := ((1.0, 5.0, 9.0, 13.0), (2.0, 6.0, 10.0, 14.0), (3.0, 7.0, 11.0, 15.0), (4.0, 8.0, 12.0, 16.0)); Right : constant m128_Array := ((2.0, 1.0, 1.0, 1.0), (1.0, 2.0, 1.0, 1.0), (1.0, 1.0, 2.0, 1.0), (1.0, 1.0, 1.0, 2.0)); Expected : constant m128_Array := ((11.0, 31.0, 51.0, 71.0), (12.0, 32.0, 52.0, 72.0), (13.0, 33.0, 53.0, 73.0), (14.0, 34.0, 54.0, 74.0)); Result : constant m128_Array := Left * Right; begin for I in Index_Homogeneous loop for J in Index_Homogeneous loop Assert (Expected (I) (J) = Result (I) (J), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end loop; end Test_Multiply_Matrices; end Test_SIMD_FMA_Singles_Arithmetic;
----------------------------------------------------------------------- -- awa-commands-stop -- Command to stop the web server -- Copyright (C) 2020, 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 GNAT.Sockets; with Util.Streams.Sockets; with Util.Streams.Texts; package body AWA.Commands.Stop is -- ------------------------------ -- Setup the command before parsing the arguments and executing it. -- ------------------------------ overriding procedure Setup (Command : in out Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Context_Type) is begin GC.Set_Usage (Config => Config, Usage => Command.Get_Name & " [arguments]", Help => Command.Get_Description); GC.Define_Switch (Config => Config, Output => Command.Management_Port'Access, Switch => "-m:", Long_Switch => "--management-port=", Initial => Command.Management_Port, Argument => "NUMBER", Help => -("The server listening management port on localhost")); AWA.Commands.Setup_Command (Config, Context); end Setup; -- ------------------------------ -- Stop the server by sending a 'stop' command on the management socket. -- ------------------------------ overriding procedure Execute (Command : in out Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Context_Type) is pragma Unreferenced (Name, Args, Context); Address : GNAT.Sockets.Sock_Addr_Type; Stream : aliased Util.Streams.Sockets.Socket_Stream; Writer : Util.Streams.Texts.Print_Stream; begin Address.Addr := GNAT.Sockets.Loopback_Inet_Addr; Address.Port := GNAT.Sockets.Port_Type (Command.Management_Port); Stream.Connect (Address); Writer.Initialize (Stream'Unchecked_Access, 1024); Writer.Write ("stop" & ASCII.CR & ASCII.LF); Writer.Flush; Writer.Close; end Execute; begin Command_Drivers.Driver.Add_Command ("stop", -("stop the web server"), Command'Access); end AWA.Commands.Stop;
----------------------------------------------------------------------- -- awa-commands -- AWA commands for server or admin tool -- Copyright (C) 2019, 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.IO_Exceptions; with Ada.Command_Line; with Ada.Unchecked_Deallocation; with Ada.Strings.Unbounded; with Util.Log.Loggers; with Util.Properties; with Util.Strings.Tokenizers; with Util.Strings.Vectors; with AWA.Applications.Configs; with Keystore.Passwords.Input; with Keystore.Passwords.Files; with Keystore.Passwords.Unsafe; with Keystore.Passwords.Cmds; package body AWA.Commands is use Ada.Strings.Unbounded; use type Keystore.Passwords.Provider_Access; use type Keystore.Header_Slot_Count_Type; use type Keystore.Passwords.Keys.Key_Provider_Access; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Commands"); procedure Load_Configuration (Context : in out Context_Type; Path : in String) is begin Log.Info ("Loading server configuration {0}", Path); begin Context.Global_Config.Load_Properties (Path); Util.Log.Loggers.Initialize (Util.Properties.Manager (Context.Global_Config)); exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Cannot read server configuration file '{0}'", Path); end; if Context.Exists (GPG_CRYPT_CONFIG) then Context.GPG.Set_Encrypt_Command (Context.Get_Config (GPG_CRYPT_CONFIG)); end if; if Context.Exists (GPG_DECRYPT_CONFIG) then Context.GPG.Set_Decrypt_Command (Context.Get_Config (GPG_DECRYPT_CONFIG)); end if; if Context.Exists (GPG_LIST_CONFIG) then Context.GPG.Set_List_Key_Command (Context.Get_Config (GPG_LIST_CONFIG)); end if; Context.Config.Randomize := not Context.Zero; end Load_Configuration; -- ------------------------------ -- Returns True if a keystore is used by the configuration and must be unlocked. -- ------------------------------ function Use_Keystore (Context : in Context_Type) return Boolean is begin if Context.Wallet_File'Length > 0 then return True; else return Context.Exists (KEYSTORE_PATH); end if; end Use_Keystore; -- ------------------------------ -- Open the keystore file using the password password. -- ------------------------------ procedure Open_Keystore (Context : in out Context_Type) is begin Setup_Password_Provider (Context); Setup_Key_Provider (Context); Context.Wallet.Open (Path => Context.Get_Keystore_Path, Data_Path => "", Config => Context.Config, Info => Context.Info); if not Context.No_Password_Opt or else Context.Info.Header_Count = 0 then if Context.Key_Provider /= null then Context.Wallet.Set_Master_Key (Context.Key_Provider.all); end if; if Context.Provider = null then Context.Provider := Keystore.Passwords.Input.Create (-("Enter password: "), False); end if; Context.Wallet.Unlock (Context.Provider.all, Context.Slot); else Context.GPG.Load_Secrets (Context.Wallet); Context.Wallet.Set_Master_Key (Context.GPG); Context.Wallet.Unlock (Context.GPG, Context.Slot); end if; Context.Keystore_Opened := True; Keystore.Properties.Initialize (Context.Secure_Config, Context.Wallet'Unchecked_Access); end Open_Keystore; function Get_Application_Config (Context : in Context_Type; Name : in String) return String is begin if Context.Exists (Name & ".config") then return Context.Get_Config (Name & ".config"); else return AWA.Applications.Configs.Get_Config_Path (Name); end if; end Get_Application_Config; -- ------------------------------ -- Configure the application by loading its configuration file and merging it with -- the keystore file if there is one. -- ------------------------------ procedure Configure (Application : in out ASF.Applications.Main.Application'Class; Name : in String; Context : in out Context_Type) is Path : constant String := Context.Get_Application_Config (Name); File_Config : ASF.Applications.Config; begin Log.Info ("Configuring {0} with {1}", Name, Path); begin File_Config.Load_Properties (Path); exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Configuration file {0} not found", Path); end; if Context.Use_Keystore then if not Context.Keystore_Opened then Open_Keystore (Context); end if; AWA.Applications.Configs.Merge (Context.App_Config, File_Config, Context.Secure_Config, Name & "."); else Context.App_Config := File_Config; end if; Application.Initialize (Context.App_Config, Context.Factory); end Configure; -- ------------------------------ -- Initialize the commands. -- ------------------------------ overriding procedure Initialize (Context : in out Context_Type) is begin GC.Set_Usage (Config => Context.Command_Config, Usage => "[switchs] command [arguments]", Help => -("akt - tool to store and protect your sensitive data")); GC.Define_Switch (Config => Context.Command_Config, Output => Context.Version'Access, Switch => "-V", Long_Switch => "--version", Help => -("Print the version")); GC.Define_Switch (Config => Context.Command_Config, Output => Context.Verbose'Access, Switch => "-v", Long_Switch => "--verbose", Help => -("Verbose execution mode")); GC.Define_Switch (Config => Context.Command_Config, Output => Context.Debug'Access, Switch => "-vv", Long_Switch => "--debug", Help => -("Enable debug execution")); GC.Define_Switch (Config => Context.Command_Config, Output => Context.Dump'Access, Switch => "-vvv", Long_Switch => "--debug-dump", Help => -("Enable debug dump execution")); GC.Define_Switch (Config => Context.Command_Config, Output => Context.Zero'Access, Switch => "-z", Long_Switch => "--zero", Help => -("Erase and fill with zeros instead of random values")); GC.Define_Switch (Config => Context.Command_Config, Output => Context.Config_File'Access, Switch => "-c:", Long_Switch => "--config=", Argument => "PATH", Help => -("Defines the path for configuration file")); GC.Initialize_Option_Scan (Stop_At_First_Non_Switch => True); -- Driver.Set_Description (-("akt - tool to store and protect your sensitive data")); -- Driver.Set_Usage (-("[-V] [-v] [-vv] [-vvv] [-c path] [-t count] [-z] " & -- "<command> [<args>]" & ASCII.LF & -- "where:" & ASCII.LF & -- " -V Print the tool version" & ASCII.LF & -- " -v Verbose execution mode" & ASCII.LF & -- " -vv Debug execution mode" & ASCII.LF & -- " -vvv Dump execution mode" & ASCII.LF & -- " -c path Defines the path for akt " & -- "global configuration" & ASCII.LF & -- " -t count Number of threads for the " & -- "encryption/decryption process" & ASCII.LF & -- " -z Erase and fill with zeros instead of random values")); -- Driver.Add_Command ("help", -- -("print some help"), -- Help_Command'Access); end Initialize; -- ------------------------------ -- Setup the command before parsing the arguments and executing it. -- ------------------------------ procedure Setup_Command (Config : in out GC.Command_Line_Configuration; Context : in out Context_Type) is begin GC.Define_Switch (Config => Config, Output => Context.Wallet_File'Access, Switch => "-k:", Long_Switch => "--keystore=", Argument => "PATH", Help => -("Defines the path for the keystore file")); GC.Define_Switch (Config => Config, Output => Context.Password_File'Access, Long_Switch => "--passfile=", Argument => "PATH", Help => -("Read the file that contains the password")); GC.Define_Switch (Config => Config, Output => Context.Unsafe_Password'Access, Long_Switch => "--passfd=", Argument => "NUM", Help => -("Read the password from the pipe with" & " the given file descriptor")); GC.Define_Switch (Config => Config, Output => Context.Unsafe_Password'Access, Long_Switch => "--passsocket=", Help => -("The password is passed within the socket connection")); GC.Define_Switch (Config => Config, Output => Context.Password_Env'Access, Long_Switch => "--passenv=", Argument => "NAME", Help => -("Read the environment variable that contains" & " the password (not safe)")); GC.Define_Switch (Config => Config, Output => Context.Unsafe_Password'Access, Switch => "-p:", Long_Switch => "--password=", Help => -("The password is passed within the command line (not safe)")); GC.Define_Switch (Config => Config, Output => Context.Password_Askpass'Access, Long_Switch => "--passask", Help => -("Run the ssh-askpass command to get the password")); GC.Define_Switch (Config => Config, Output => Context.Password_Command'Access, Long_Switch => "--passcmd=", Argument => "COMMAND", Help => -("Run the command to get the password")); GC.Define_Switch (Config => Config, Output => Context.Wallet_Key_File'Access, Long_Switch => "--wallet-key-file=", Argument => "PATH", Help => -("Read the file that contains the wallet keys")); end Setup_Command; procedure Setup_Password_Provider (Context : in out Context_Type) is begin if Context.Password_Askpass then Context.Provider := Keystore.Passwords.Cmds.Create ("ssh-askpass"); elsif Context.Password_Command'Length > 0 then Context.Provider := Keystore.Passwords.Cmds.Create (Context.Password_Command.all); elsif Context.Password_File'Length > 0 then Context.Provider := Keystore.Passwords.Files.Create (Context.Password_File.all); elsif Context.Password_Command'Length > 0 then Context.Provider := Keystore.Passwords.Cmds.Create (Context.Password_Command.all); elsif Context.Unsafe_Password'Length > 0 then Context.Provider := Keystore.Passwords.Unsafe.Create (Context.Unsafe_Password.all); elsif Context.Exists (PASSWORD_FILE_PATH) then Context.Provider := Keystore.Passwords.Files.Create (Context.Get_Config (PASSWORD_FILE_PATH)); else Context.No_Password_Opt := True; end if; end Setup_Password_Provider; procedure Setup_Key_Provider (Context : in out Context_Type) is begin if Context.Wallet_Key_File'Length > 0 then Context.Key_Provider := Keystore.Passwords.Files.Create (Context.Wallet_Key_File.all); elsif Context.Exists (WALLET_KEY_PATH) then Context.Key_Provider := Keystore.Passwords.Files.Create (Context.Get_Config (WALLET_KEY_PATH)); else Context.Key_Provider := Keystore.Passwords.Keys.Create (Keystore.DEFAULT_WALLET_KEY); end if; end Setup_Key_Provider; -- ------------------------------ -- Get the keystore file path. -- ------------------------------ function Get_Keystore_Path (Context : in out Context_Type) return String is begin if Context.Wallet_File'Length > 0 then Context.First_Arg := 1; return Context.Wallet_File.all; elsif Context.Exists (KEYSTORE_PATH) then return Context.Get_Config (KEYSTORE_PATH); else raise Error with "No keystore path"; end if; end Get_Keystore_Path; procedure Print (Context : in out Context_Type; Ex : in Ada.Exceptions.Exception_Occurrence) is pragma Unreferenced (Context); begin Ada.Exceptions.Reraise_Occurrence (Ex); exception when GNAT.Command_Line.Exit_From_Command_Line | GNAT.Command_Line.Invalid_Switch => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.Bad_Password => Log.Error (-("Invalid password to unlock the keystore file")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.No_Key_Slot => Log.Error (-("There is no available key slot to add the password")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.No_Content => Log.Error (-("No content for an item of type wallet")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.Corrupted => Log.Error (-("The keystore file is corrupted: invalid meta data content")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.Invalid_Block => Log.Error (-("The keystore file is corrupted: invalid data block headers or signature")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.Invalid_Signature => Log.Error (-("The keystore file is corrupted: invalid signature")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.Invalid_Storage => Log.Error (-("The keystore file is corrupted: invalid or missing storage file")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Keystore.Invalid_Keystore => Log.Error (-("The file is not a keystore")); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when AWA.Commands.Error | Util.Commands.Not_Found => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : Ada.IO_Exceptions.Name_Error => Log.Error (-("Cannot access file: {0}"), Ada.Exceptions.Exception_Message (E)); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : others => Log.Error (-("Some internal error occurred"), E); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); end Print; -- ------------------------------ -- Configure the logs. -- ------------------------------ procedure Configure_Logs (Root : in String; Debug : in Boolean; Dump : in Boolean; Verbose : in Boolean) is procedure Split (Item : in String; Done : out Boolean); function Make_Root (Level : in String; Appender1 : in String; Appender2 : in String) return String; Start : constant Natural := Util.Strings.Index (Root, ','); List : Util.Strings.Vectors.Vector; procedure Split (Item : in String; Done : out Boolean) is begin Done := False; List.Append (Item); end Split; function Make_Root (Level : in String; Appender1 : in String; Appender2 : in String) return String is Result : Unbounded_String; begin Append (Result, Level); Append (Result, ","); if not List.Contains (Appender1) then Append (Result, Appender1); end if; if Appender2'Length > 0 and then not List.Contains (Appender2) then Append (Result, ","); Append (Result, Appender2); end if; for Item of List loop Append (Result, ","); Append (Result, Item); end loop; return To_String (Result); end Make_Root; Log_Config : Util.Properties.Manager; begin if Start > 0 then Util.Strings.Tokenizers.Iterate_Tokens (Root (Start + 1 .. Root'Last), ",", Split'Access); end if; Log_Config.Set ("log4j.rootCategory", Make_Root ("DEBUG", "console", "")); Log_Config.Set ("log4j.appender.console", "Console"); Log_Config.Set ("log4j.appender.console.level", "ERROR"); Log_Config.Set ("log4j.appender.console.layout", "message"); Log_Config.Set ("log4j.appender.console.stderr", "true"); Log_Config.Set ("log4j.logger.Util", "FATAL"); Log_Config.Set ("log4j.logger.log", "ERROR"); if Verbose or Debug or Dump then Log_Config.Set ("log4j.logger.log", "INFO"); Log_Config.Set ("log4j.logger.Util", "WARN"); Log_Config.Set ("log4j.logger.Keystore.IO", "WARN"); Log_Config.Set ("log4j.logger.ADO.Sessions", "WARN"); Log_Config.Set ("log4j.rootCategory", Make_Root ("DEBUG", "console", "verbose")); Log_Config.Set ("log4j.appender.verbose", "Console"); Log_Config.Set ("log4j.appender.verbose.level", "INFO"); Log_Config.Set ("log4j.appender.verbose.layout", "level-message"); end if; if Debug or Dump then Log_Config.Set ("log4j.logger.log", "INFO"); Log_Config.Set ("log4j.logger.Util.Processes", "INFO"); Log_Config.Set ("log4j.logger.Keystore.IO", "INFO"); Log_Config.Set ("log4j.logger.ADO", "INFO"); Log_Config.Set ("log4j.rootCategory", Make_Root ("DEBUG", "console", "debug")); Log_Config.Set ("log4j.appender.debug", "Console"); Log_Config.Set ("log4j.appender.debug.level", "DEBUG"); Log_Config.Set ("log4j.appender.debug.layout", "full"); end if; if Dump then Log_Config.Set ("log4j.logger.Keystore.IO", "DEBUG"); Log_Config.Set ("log4j.logger.AWA", "DEBUG"); Log_Config.Set ("log4j.logger.ADO", "DEBUG"); Log_Config.Set ("log4j.logger.ADO.Sessions", "WARN"); end if; Util.Log.Loggers.Initialize (Log_Config); end Configure_Logs; overriding procedure Finalize (Context : in out Context_Type) is procedure Free is new Ada.Unchecked_Deallocation (Object => Keystore.Passwords.Provider'Class, Name => Keystore.Passwords.Provider_Access); begin GC.Free (Context.Command_Config); Free (Context.Provider); end Finalize; end AWA.Commands;
-- Auteurs : HATHOUTE Hamza, GUEMIL Walid -- Equipe : -- Mini-projet 1 : Le jeu du devin with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; -- TODO: à compléter... procedure Jeu_Devin is Min : constant Integer := 1; Max : constant Integer := 999; -- les nombres à trouver sont entre Min et Max -- TODO: Mettre le bon commentaire ! procedure Faire_deviner_un_nombre is -- TODO: Donner un nom significatif ! -- TODO: Déclarer ici les variables nécessaires pour cet exercice a: Integer; x: Integer; compteur: Integer; begin Put ("J'ai choisi "); Get (a); compteur := 0; loop Put ("Proposez un nombre : "); Get (x); if x>a then Put_Line ("Le nombre proposé est trop grand."); elsif x<a then Put_Line("Le nombre proposé est trop petit."); else Put_Line ("Trouvé !"); end if; compteur := compteur + 1; exit when x=a; end loop; Put ("Bravo ! Vous avez trouvé en "); Put (Compteur,1); Put_Line (" essai(s)."); end Faire_deviner_un_nombre; -- TODO: à changer -- TODO: Mettre le bon commentaire ! procedure Deviner_un_nombre is -- TODO: Donner un nom significatif ! -- TODO: Déclarer ici les variables nécessaires pour cet exercice BorneMin: Integer; -- la borne minimale. BorneMax: Integer; -- la borne maximale. Nombre: Integer; -- le nombre que l'ordinateur devine Essaies: Integer; -- le nombre d'essaies Choix: Character; -- le choix de l'utilisateur begin loop Put("Avez-vous choisi un nombre compris entre 1 et 999 (o/n) ? "); Get(Choix); exit when Choix = 'o'; Put_Line("J'attends..."); end loop; -- Initialiser les variables BorneMin := Min; BorneMax := Max; Nombre := 500; Essaies := 0; -- Chercher le nombre deviné loop -- Mettre à jour les variables if Choix = 'g' then BorneMax := Nombre - 1; elsif Choix = 'p' then BorneMin := Nombre + 1; end if; -- Verifier si l'utilisateur ne triche pas if BorneMax < BorneMin then Put_Line("Vous trichez. J'arrête cette partie."); return; end if; -- Calculer le nombre Nombre := (BorneMin + BorneMax)/2; -- Valeur médiane -- Incrementer les essaies Essaies := Essaies + 1; -- Afficher la proposition Put ("Je propose "); Put (Item => Nombre, Width => 1); Put_Line(""); -- Saisir l'indice loop Put("Votre indice (t/p/g) ? "); Get(Choix); exit when Choix = 't' or Choix = 'p' or Choix = 'g'; end loop; exit when Choix = 't'; end loop; -- Afficher le nombre trouvé Put ("J'ai trouvé "); Put (Item => Nombre, Width => 1); Put(" en "); Put (Item => Essaies, Width => 1); Put(" essai(s)."); end Deviner_un_nombre; choix: Integer; -- TODO: Déclarer ici les variables pour le programme principal begin loop New_Line; Put_Line ("1- L'ordinateur choisit un nombre et vous le devinez"); Put_Line ("2- Vous choisissez un nombre et l'ordinateur le devine"); Put_Line ("0- Quitter"); Put("Votre choix :"); Get (choix); New_Line; case choix is when 1 => Faire_deviner_un_nombre; when 2 => Deviner_un_nombre; when others => null; end case; exit when choix = 0; end loop; end Jeu_Devin;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; with Ada.Float_Text_Io; use Ada.Float_Text_Io; with Ada.Text_IO; use Ada.Text_IO; procedure Trig is Degrees_Cycle : constant Float := 360.0; Radians_Cycle : constant Float := 2.0 * Ada.Numerics.Pi; Angle_Degrees : constant Float := 45.0; Angle_Radians : constant Float := Ada.Numerics.Pi / 4.0; procedure Put (V1, V2 : Float) is begin Put (V1, Aft => 5, Exp => 0); Put (" "); Put (V2, Aft => 5, Exp => 0); New_Line; end Put; begin Put (Sin (Angle_Degrees, Degrees_Cycle), Sin (Angle_Radians, Radians_Cycle)); Put (Cos (Angle_Degrees, Degrees_Cycle), Cos (Angle_Radians, Radians_Cycle)); Put (Tan (Angle_Degrees, Degrees_Cycle), Tan (Angle_Radians, Radians_Cycle)); Put (Cot (Angle_Degrees, Degrees_Cycle), Cot (Angle_Radians, Radians_Cycle)); Put (ArcSin (Sin (Angle_Degrees, Degrees_Cycle), Degrees_Cycle), ArcSin (Sin (Angle_Radians, Radians_Cycle), Radians_Cycle)); Put (Arccos (Cos (Angle_Degrees, Degrees_Cycle), Degrees_Cycle), Arccos (Cos (Angle_Radians, Radians_Cycle), Radians_Cycle)); Put (Arctan (Y => Tan (Angle_Degrees, Degrees_Cycle)), Arctan (Y => Tan (Angle_Radians, Radians_Cycle))); Put (Arccot (X => Cot (Angle_Degrees, Degrees_Cycle)), Arccot (X => Cot (Angle_Degrees, Degrees_Cycle))); end Trig;
with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put_Line ("Hello there, general World!"); end Hello;
with Ada.Exception_Identification.From_Here; with System.Native_Calendar; package body Ada.Calendar.Time_Zones is use Exception_Identification.From_Here; function UTC_Time_Offset (Date : Time := Clock) return Time_Offset is Result : Time_Offset; Error : Boolean; begin System.Native_Calendar.UTC_Time_Offset ( Duration (Date), Time_Zone => System.Native_Calendar.Time_Offset (Result), Error => Error); if Error then Raise_Exception (Time_Error'Identity); end if; return Result; end UTC_Time_Offset; begin System.Native_Calendar.Initialize_Time_Zones; end Ada.Calendar.Time_Zones;
with Ada.Text_IO, Ada.Command_Line, Ada.Numerics.Float_Random, Ada.Numerics.Generic_Elementary_Functions; procedure Long_Basic_Stat is package FRG renames Ada.Numerics.Float_Random; package TIO renames Ada.Text_IO; type Counter is range 0 .. 2**63-1; type Result_Array is array(Natural range <>) of Counter; type High_Precision is digits 15; package FIO is new TIO.Float_IO(Float); procedure Put_Histogram(R: Result_Array; Scale, Full: Counter) is begin for I in R'Range loop FIO.Put(Float'Max(0.0, Float(I)/10.0 - 0.05), Fore => 1, Aft => 2, Exp => 0); TIO.Put(".."); FIO.Put(Float'Min(1.0, Float(I)/10.0 + 0.05), Fore => 1, Aft => 2, Exp => 0); TIO.Put(": "); for J in 1 .. (R(I)* Scale)/Full loop Ada.Text_IO.Put("X"); end loop; Ada.Text_IO.New_Line; end loop; end Put_Histogram; procedure Put_Mean_Et_Al(Sample_Size: Counter; Val_Sum, Square_Sum: Float) is Mean: constant Float := Val_Sum / Float(Sample_Size); package Math is new Ada.Numerics.Generic_Elementary_Functions(Float); begin TIO.Put("Mean: "); FIO.Put(Mean, Fore => 1, Aft => 5, Exp => 0); TIO.Put(", Standard Deviation: "); FIO.Put(Math.Sqrt(abs(Square_Sum / Float(Sample_Size) - (Mean * Mean))), Fore => 1, Aft => 5, Exp => 0); TIO.New_Line; end Put_Mean_Et_Al; N: Counter := Counter'Value(Ada.Command_Line.Argument(1)); Gen: FRG.Generator; Results: Result_Array(0 .. 10) := (others => 0); X: Float; Val_Sum, Squ_Sum: High_Precision := 0.0; begin FRG.Reset(Gen); for Outer in 1 .. 1000 loop for I in 1 .. N/1000 loop X := FRG.Random(Gen); Val_Sum := Val_Sum + High_Precision(X); Squ_Sum := Squ_Sum + High_Precision(X)*High_Precision(X); declare Index: Integer := Integer(X*10.0); begin Results(Index) := Results(Index) + 1; end; end loop; if Outer mod 50 = 0 then TIO.New_Line(1); TIO.Put_Line(Integer'Image(Outer/10) &"% done; current results:"); Put_Mean_Et_Al(Sample_Size => (Counter(Outer)*N)/1000, Val_Sum => Float(Val_Sum), Square_Sum => Float(Squ_Sum)); else Ada.Text_IO.Put("."); end if; end loop; TIO.New_Line(4); TIO.Put_Line("After sampling" & Counter'Image(N) & " random numnbers: "); Put_Histogram(Results, Scale => 600, Full => N); TIO.New_Line; Put_Mean_Et_Al(Sample_Size => N, Val_Sum => Float(Val_Sum), Square_Sum => Float(Squ_Sum)); end Long_Basic_Stat;
with Ada.Calendar; with Ada.Text_IO; use Ada.Calendar; package body Timer is function start return T is result: T; begin result.clock := Ada.Calendar.Clock; return result; end start; procedure reset(tm: in out T) is begin tm.clock := Ada.Calendar.Clock; end reset; function reset(tm: in out T) return Float is oldTime: Ada.Calendar.Time; begin oldTime := tm.clock; tm.clock := Ada.Calendar.Clock; return Float(tm.clock - oldTime); end reset; procedure report(tm: in out T) is dur: Float; begin dur := tm.reset; Ada.Text_IO.Put_Line("Elapsed: " & dur'Image); end report; procedure report(tm: in out T; message: in String) is dur: Float; begin dur := tm.reset; Ada.Text_IO.Put_Line(message & ", elapsed: " & dur'Image); end report; end Timer;
pragma License (Unrestricted); -- implementation unit required by compiler with Ada.Exceptions; with System.Tasking.Protected_Objects.Entries; package System.Tasking.Rendezvous is -- required for accept statement by compiler (s-tasren.ads) procedure Accept_Call ( E : Task_Entry_Index; Uninterpreted_Data : out Address); -- optionally required for accept statement by compiler (s-tasren.ads) procedure Complete_Rendezvous; -- required for accept statement by compiler (s-tasren.ads) procedure Exceptional_Complete_Rendezvous ( Ex : Ada.Exceptions.Exception_Id); -- required for simple accept statement by compiler (s-tasren.ads) procedure Accept_Trivial (E : Task_Entry_Index); -- by -fdump-tree-all, accept statement expanded below: -- -- A19b = system.tasking.rendezvous.accept_call (1); -- const arg2_t arg2 = *((struct xTK__P3b *) A19b)->arg2; -- const arg1_t arg1 = *((struct xTK__P3b *) A19b)->arg1; -- try -- { -- ... user code ... -- system.tasking.rendezvous.complete_rendezvous (); -- } -- catch -- { -- catch (&ALL_OTHERS) -- { -- void * EXPTR = .builtin_eh_pointer (0); -- try -- { -- void * EXPTR = .builtin_eh_pointer (0); -- .gnat_begin_handler (EXPTR); -- system.tasking.rendezvous.exceptional_complete_rendezvous ( -- (struct system__standard_library__exception_data * const) -- system.soft_links.get_gnat_exception ()); -- } -- finally -- { -- .gnat_end_handler (EXPTR); -- } -- } -- } -- required for selective wait by compiler (s-tasren.ads) procedure Selective_Wait ( Open_Accepts : not null access Accept_List; Select_Mode : Select_Modes; Uninterpreted_Data : out Address; Index : out Select_Index); -- required for timed selective wait by compiler (s-tasren.ads) procedure Timed_Selective_Wait ( Open_Accepts : not null access Accept_List; Select_Mode : Select_Modes; Uninterpreted_Data : out Address; Timeout : Duration; Mode : Integer; -- Delay_Modes Index : out Select_Index); -- required for synchronized interface by compiler (s-tasren.ads) procedure Task_Entry_Call ( Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : Address; Mode : Call_Modes; Rendezvous_Successful : out Boolean); -- required for synchronized interface by compiler (s-tasren.ads) procedure Timed_Task_Entry_Call ( Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : Address; Timeout : Duration; Mode : Integer; -- Tasking.Delay_Modes; Rendezvous_Successful : out Boolean); -- required for calling entry of task by compiler (s-tasren.ads) procedure Call_Simple ( Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : Address); -- by -fdump-tree-all, calling entry of task expanded below: -- -- struct xTK__P3b P = {.arg1=&arg1, .arg2=&arg2}; -- system.tasking.rendezvous.call_simple ( -- (struct system__tasking__ada_task_control_block * const {ref-all}) -- _init._task_id, -- entry_index, -- (const system__address) &P); -- required for select then abort by compiler (s-tasren.ads) procedure Cancel_Task_Entry_Call (Cancelled : out Boolean); -- required for synchronized interface by compiler (s-tasren.ads) procedure Requeue_Task_Entry ( Acceptor : Task_Id; E : Task_Entry_Index; With_Abort : Boolean); -- required for synchronized interface by compiler (s-tasren.ads) procedure Requeue_Protected_To_Task_Entry ( Object : not null access Protected_Objects.Entries.Protection_Entries'Class; Acceptor : Task_Id; E : Task_Entry_Index; With_Abort : Boolean); -- required for 'Callable by compiler (s-tasren.ads) function Callable (T : Task_Id) return Boolean; -- required for 'Caller by compiler (s-tasren.ads) type Task_Entry_Nesting_Depth is range 0 .. Integer'Last; function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_Id; -- required for 'Count by compiler (s-tasren.ads) function Task_Count (E : Task_Entry_Index) return Natural; end System.Tasking.Rendezvous;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C O M M A N D _ L I N E -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 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. -- -- -- ------------------------------------------------------------------------------ package Ada.Command_Line is pragma Preelaborate (Command_Line); function Argument_Count return Natural; -- If the external execution environment supports passing arguments to a -- program, then Argument_Count returns the number of arguments passed to -- the program invoking the function. Otherwise it return 0. -- -- In GNAT: Corresponds to (argc - 1) in C. function Argument (Number : Positive) return String; -- If the external execution environment supports passing arguments to -- a program, then Argument returns an implementation-defined value -- corresponding to the argument at relative position Number. If Number -- is outside the range 1 .. Argument_Count, then Constraint_Error is -- propagated. -- -- in GNAT: Corresponds to argv [n] (for n > 0) in C. function Command_Name return String; -- If the external execution environment supports passing arguments to -- a program, then Command_Name returns an implementation-defined value -- corresponding to the name of the command invoking the program. -- Otherwise Command_Name returns the null string. -- -- in GNAT: Corresponds to argv [0] in C. type Exit_Status is new Integer; Success : constant Exit_Status; Failure : constant Exit_Status; procedure Set_Exit_Status (Code : Exit_Status); private Success : constant Exit_Status := 0; Failure : constant Exit_Status := 1; -- The following locations support the operation of the package -- Ada.Command_Line_Remove, whih provides facilities for logically -- removing arguments from the command line. If one of the remove -- procedures is called in this unit, then Remove_Args/Remove_Count -- are set to indicate which arguments are removed. If no such calls -- have been made, then Remove_Args is null. Remove_Count : Natural; -- Number of arguments reflecting removals. Not defined unless -- Remove_Args is non-null. type Arg_Nums is array (Positive range <>) of Positive; type Arg_Nums_Ptr is access Arg_Nums; -- An array that maps logical argument numbers (reflecting removal) -- to physical argument numbers (e.g. if the first argument has been -- removed, but not the second, then Arg_Nums (1) will be set to 2. Remove_Args : Arg_Nums_Ptr := null; -- Left set to null if no remove calls have been made, otherwise set -- to point to an appropriate mapping array. Only the first Remove_Count -- elements are relevant. pragma Import (C, Set_Exit_Status, "__gnat_set_exit_status"); end Ada.Command_Line;
-- This spec has been automatically generated from STM32L4x3.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.CRC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype IDR_IDR_Field is HAL.UInt8; -- Independent data register type IDR_Register is record -- General-purpose 8-bit data register bits IDR : IDR_IDR_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 IDR_Register use record IDR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype CR_POLYSIZE_Field is HAL.UInt2; subtype CR_REV_IN_Field is HAL.UInt2; -- Control register type CR_Register is record -- Write-only. RESET bit RESET : Boolean := False; -- unspecified Reserved_1_2 : HAL.UInt2 := 16#0#; -- Polynomial size POLYSIZE : CR_POLYSIZE_Field := 16#0#; -- Reverse input data REV_IN : CR_REV_IN_Field := 16#0#; -- Reverse output data REV_OUT : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record RESET at 0 range 0 .. 0; Reserved_1_2 at 0 range 1 .. 2; POLYSIZE at 0 range 3 .. 4; REV_IN at 0 range 5 .. 6; REV_OUT at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Cyclic redundancy check calculation unit type CRC_Peripheral is record -- Data register DR : aliased HAL.UInt32; -- Independent data register IDR : aliased IDR_Register; -- Control register CR : aliased CR_Register; -- Initial CRC value INIT : aliased HAL.UInt32; -- polynomial POL : aliased HAL.UInt32; end record with Volatile; for CRC_Peripheral use record DR at 16#0# range 0 .. 31; IDR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; INIT at 16#10# range 0 .. 31; POL at 16#14# range 0 .. 31; end record; -- Cyclic redundancy check calculation unit CRC_Periph : aliased CRC_Peripheral with Import, Address => CRC_Base; end STM32_SVD.CRC;
pragma License (Unrestricted); with Ada.Containers; with Ada.Strings.Hash; function Ada.Strings.Fixed.Hash (Key : String) return Containers.Hash_Type renames Strings.Hash; pragma Pure (Ada.Strings.Fixed.Hash);
package HAL.UART is type UART_Status is (Ok, Err_Error, Err_Timeout, Busy); type UART_Data_Size is (Data_Size_8b, Data_Size_9b); type UART_Data_8b is array (Natural range <>) of Byte; type UART_Data_9b is array (Natural range <>) of UInt9; type UART_Port is limited interface; type UART_Port_Ref is not null access all UART_Port'Class; function Data_Size (Port : UART_Port) return UART_Data_Size is abstract; procedure Transmit (Port : in out UART_Port; Data : UART_Data_8b; Status : out UART_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_8b; procedure Transmit (Port : in out UART_Port; Data : UART_Data_9b; Status : out UART_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_9b; procedure Receive (Port : in out UART_Port; Data : out UART_Data_8b; Status : out UART_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_8b; procedure Receive (Port : in out UART_Port; Data : out UART_Data_9b; Status : out UART_Status; Timeout : Natural := 1000) is abstract with Pre'Class => Data_Size (Port) = Data_Size_9b; end HAL.UART;
with Project_Processor.Parsers.Abstract_Parsers; with Plugins.Tables; package Project_Processor.Parsers.Parser_Tables is new Plugins.Tables (Root_Plugin_Type => Abstract_Parsers.Abstract_Parser, Plugin_Parameters => Plugins.Parameter_Maps.Map, Plugin_ID => Parser_ID, Constructor => Abstract_Parsers.Create);
-- Mojang API -- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) -- -- OpenAPI spec version: 2020_06_05 -- -- -- NOTE: This package is auto generated by the swagger code generator 3.3.4. -- https://openapi-generator.tech -- Do not edit the class manually. with Swagger.Streams; with Ada.Containers.Vectors; package com.github.asyncmc.mojang.api.ada.server.model.Models is type SecurityQuestion_Type is record Id : Integer; Question : Swagger.UString; end record; package SecurityQuestion_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => SecurityQuestion_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityQuestion_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityQuestion_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityQuestion_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityQuestion_Type_Vectors.Vector); type SecurityAnswerId_Type is record Id : Integer; end record; package SecurityAnswerId_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => SecurityAnswerId_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityAnswerId_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityAnswerId_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityAnswerId_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityAnswerId_Type_Vectors.Vector); type SecurityChallenge_Type is record Question : com.github.asyncmc.mojang.api.ada.server.model.Models.SecurityQuestion_Type; Answer : com.github.asyncmc.mojang.api.ada.server.model.Models.SecurityAnswerId_Type; end record; package SecurityChallenge_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => SecurityChallenge_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityChallenge_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityChallenge_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityChallenge_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityChallenge_Type_Vectors.Vector); type Error_Type is record Error : Swagger.Nullable_UString; Error_Message : Swagger.Nullable_UString; end record; package Error_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Error_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Error_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Error_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Error_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Error_Type_Vectors.Vector); type CurrentPlayerIDs_Type is record Id : Swagger.UString; Name : Swagger.UString; Legacy : Swagger.Nullable_Boolean; Demo : Swagger.Nullable_Boolean; end record; package CurrentPlayerIDs_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => CurrentPlayerIDs_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in CurrentPlayerIDs_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in CurrentPlayerIDs_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out CurrentPlayerIDs_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out CurrentPlayerIDs_Type_Vectors.Vector); type NameChange_Type is record Name : Swagger.UString; Changed_To_At : Swagger.Nullable_Long; end record; package NameChange_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => NameChange_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in NameChange_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in NameChange_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out NameChange_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out NameChange_Type_Vectors.Vector); type SkinModel_Type is record end record; package SkinModel_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => SkinModel_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SkinModel_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SkinModel_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SkinModel_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SkinModel_Type_Vectors.Vector); type ChangeSkinRequest_Type is record Model : com.github.asyncmc.mojang.api.ada.server.model.Models.SkinModel_Type; Url : Swagger.UString; end record; package ChangeSkinRequest_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ChangeSkinRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ChangeSkinRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ChangeSkinRequest_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ChangeSkinRequest_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ChangeSkinRequest_Type_Vectors.Vector); type SecurityAnswer_Type is record Id : Integer; end record; package SecurityAnswer_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => SecurityAnswer_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityAnswer_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in SecurityAnswer_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityAnswer_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out SecurityAnswer_Type_Vectors.Vector); type OrderStatisticsResponse_Type is record Total : Swagger.Long; Last24h : Swagger.Long; Sale_Velocity_Per_Seconds : double; end record; package OrderStatisticsResponse_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => OrderStatisticsResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderStatisticsResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderStatisticsResponse_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderStatisticsResponse_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderStatisticsResponse_Type_Vectors.Vector); type OrderStatistic_Type is record end record; package OrderStatistic_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => OrderStatistic_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderStatistic_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderStatistic_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderStatistic_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderStatistic_Type_Vectors.Vector); type OrderStatisticsRequest_Type is record Metric_Keys : com.github.asyncmc.mojang.api.ada.server.model.Models.OrderStatistic_Type_Vectors.Vector; end record; package OrderStatisticsRequest_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => OrderStatisticsRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderStatisticsRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderStatisticsRequest_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderStatisticsRequest_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderStatisticsRequest_Type_Vectors.Vector); type UploadSkinRequest_Type is record Model : com.github.asyncmc.mojang.api.ada.server.model.Models.SkinModel_Type; File : Swagger.Http_Content_Type; end record; package UploadSkinRequest_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => UploadSkinRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in UploadSkinRequest_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in UploadSkinRequest_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out UploadSkinRequest_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out UploadSkinRequest_Type_Vectors.Vector); end com.github.asyncmc.mojang.api.ada.server.model.Models;
--=========================================================================== -- -- This package represents the definitions for -- all ports -- all standard definitions -- for the Tiny RP2040 board -- --=========================================================================== -- -- Copyright 2022 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with RP.GPIO; with RP.I2C_Master; with RP.Device; with RP.Clock; with RP.UART; with RP.SPI; package Tiny is -------------------------------------------------------------------------- -- Just the list of all GPIO pins for the RP2040 chip -- The commented lines do not have a board connection -------------------------------------------------------------------------- GP0 : aliased RP.GPIO.GPIO_Point := (Pin => 0); GP1 : aliased RP.GPIO.GPIO_Point := (Pin => 1); GP2 : aliased RP.GPIO.GPIO_Point := (Pin => 2); GP3 : aliased RP.GPIO.GPIO_Point := (Pin => 3); GP4 : aliased RP.GPIO.GPIO_Point := (Pin => 4); GP5 : aliased RP.GPIO.GPIO_Point := (Pin => 5); GP6 : aliased RP.GPIO.GPIO_Point := (Pin => 6); GP7 : aliased RP.GPIO.GPIO_Point := (Pin => 7); -- GP8 : aliased RP.GPIO.GPIO_Point := (Pin => 8); -- GP9 : aliased RP.GPIO.GPIO_Point := (Pin => 9); -- GP10 : aliased RP.GPIO.GPIO_Point := (Pin => 10); -- GP11 : aliased RP.GPIO.GPIO_Point := (Pin => 11); -- GP12 : aliased RP.GPIO.GPIO_Point := (Pin => 12); -- GP13 : aliased RP.GPIO.GPIO_Point := (Pin => 13); -- GP14 : aliased RP.GPIO.GPIO_Point := (Pin => 14); -- GP15 : aliased RP.GPIO.GPIO_Point := (Pin => 15); -- GP16 : aliased RP.GPIO.GPIO_Point := (Pin => 16); -- GP17 : aliased RP.GPIO.GPIO_Point := (Pin => 17); GP18 : aliased RP.GPIO.GPIO_Point := (Pin => 18); GP19 : aliased RP.GPIO.GPIO_Point := (Pin => 19); GP20 : aliased RP.GPIO.GPIO_Point := (Pin => 20); -- GP21 : aliased RP.GPIO.GPIO_Point := (Pin => 21); -- GP22 : aliased RP.GPIO.GPIO_Point := (Pin => 22); GP23 : aliased RP.GPIO.GPIO_Point := (Pin => 23); -- GP24 : aliased RP.GPIO.GPIO_Point := (Pin => 24); -- GP25 : aliased RP.GPIO.GPIO_Point := (Pin => 25); GP26 : aliased RP.GPIO.GPIO_Point := (Pin => 26); GP27 : aliased RP.GPIO.GPIO_Point := (Pin => 27); GP28 : aliased RP.GPIO.GPIO_Point := (Pin => 28); GP29 : aliased RP.GPIO.GPIO_Point := (Pin => 29); -------------------------------------------------------------------------- -- Order is counter clockwise around the chip, -- if you look at it holding the USB port top -- the identifiers are the ones on the board -------------------------------------------------------------------------- -------------------------------------------------------------------------- -- Left row of pins -------------------------------------------------------------------------- ADC3 : aliased RP.GPIO.GPIO_Point := GP29; ADC2 : aliased RP.GPIO.GPIO_Point := GP28; ADC1 : aliased RP.GPIO.GPIO_Point := GP27; ADC0 : aliased RP.GPIO.GPIO_Point := GP26; -- I2C block, device 1 SCL_1_27 : aliased RP.GPIO.GPIO_Point := GP27; SDA_1_26 : aliased RP.GPIO.GPIO_Point := GP26; -------------------------------------------------------------------------- -- Right row of pins -------------------------------------------------------------------------- -- UART block, device 1 RX_1 : aliased RP.GPIO.GPIO_Point := GP5; TX_1 : aliased RP.GPIO.GPIO_Point := GP4; -- UART block, device 0 RX_0 : aliased RP.GPIO.GPIO_Point := GP1; TX_0 : aliased RP.GPIO.GPIO_Point := GP0; -------------------------------------------------------------------------- -- I2C block, device 1 SCL_1_7 : aliased RP.GPIO.GPIO_Point := GP7; SDA_1_6 : aliased RP.GPIO.GPIO_Point := GP6; -- I2C block, device 0 SCL_0_5 : aliased RP.GPIO.GPIO_Point := GP5; SDA_0_4 : aliased RP.GPIO.GPIO_Point := GP4; -- I2C block, device 1 SCL_1_3 : aliased RP.GPIO.GPIO_Point := GP3; SDA_1_2 : aliased RP.GPIO.GPIO_Point := GP2; -- I2C block, device 0 SCL_0_1 : aliased RP.GPIO.GPIO_Point := GP1; SDA_0_0 : aliased RP.GPIO.GPIO_Point := GP0; -------------------------------------------------------------------------- -- SPI block: there is only one SPI port available -- this can be mapped to -- either GP7 - GP4 MOSI_0_7 : RP.GPIO.GPIO_Point renames Tiny.GP7; SCK_0_6 : RP.GPIO.GPIO_Point renames Tiny.GP6; NSS_0_5 : RP.GPIO.GPIO_Point renames Tiny.GP5; MISO_0_4 : RP.GPIO.GPIO_Point renames Tiny.GP4; -- or GP3 - GP0 MOSI_0_3 : RP.GPIO.GPIO_Point renames Tiny.GP3; SCK_0_2 : RP.GPIO.GPIO_Point renames Tiny.GP2; NSS_0_1 : RP.GPIO.GPIO_Point renames Tiny.GP1; MISO_0_0 : RP.GPIO.GPIO_Point renames Tiny.GP0; -------------------------------------------------------------------------- -- LEDs RGB -- IMPORTANT: those LEDs are active *LOW* -- => .Clear will switch the LED *ON* -------------------------------------------------------------------------- LED_Red : aliased RP.GPIO.GPIO_Point := GP18; LED_Green : aliased RP.GPIO.GPIO_Point := GP19; LED_Blue : aliased RP.GPIO.GPIO_Point := GP20; -------------------------------------------------------------------------- -- System frequency XOSC_Frequency : RP.Clock.XOSC_Hertz := 12_000_000; -------------------------------------------------------------------------- -- just convenient definitions for the ports SPI : RP.SPI.SPI_Port renames RP.Device.SPI_0; I2C_0 : RP.I2C_Master.I2C_Master_Port renames RP.Device.I2C_0; I2C_1 : RP.I2C_Master.I2C_Master_Port renames RP.Device.I2C_1; UART_0 : RP.UART.UART_Port renames RP.Device.UART_0; UART_1 : RP.UART.UART_Port renames RP.Device.UART_1; ------------------------------------------------------ -- Do the basic initialization procedure Initialize; ------------------------------------------------------ -- Switch on This LED procedure Switch_On (This : in out RP.GPIO.GPIO_Point); ------------------------------------------------------ -- Switch off This LED procedure Switch_Off (This : in out RP.GPIO.GPIO_Point); ------------------------------------------------------ -- Toggle This LED procedure Toggle (This : in out RP.GPIO.GPIO_Point); end Tiny;
with Ada.Command_Line; use Ada.Command_Line; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Text_IO; use Text_IO; procedure Circle is size : Integer; procedure SetSize is last : Integer; begin Get(Argument(1),size,last); end SetSize; function ShouldPaint(i,jj : Integer) return Boolean; function CircleLine(i : Integer) return String is result : String(1..(2*size)); begin for jj in 1..(2*size) loop if ShouldPaint(i,jj) then result(jj) := '*'; else result(jj) := ' '; end if; end loop; return result; end CircleLine; function ShouldPaintS(s,i,jj : Integer) return Boolean; function ShouldPaint(i,jj : Integer) return Boolean is begin return ShouldPaintS(size,i,jj); end ShouldPaint; function ShouldPaintS(s,i,jj : Integer) return Boolean is j : Integer := jj/2; begin return abs (i**2 + j**2 - s**2) <= s+1; end ShouldPaintS; begin SetSize; for i in 1..size loop Put_Line(CircleLine(i)); end loop; end Circle;
-- CC3106B.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT THE FORMAL PARAMETER DENOTES THE ACTUAL -- IN AN INSTANTIATION. -- HISTORY: -- LDC 06/20/88 CREATED ORIGINAL TEST -- EDWARD V. BERARD, 10 AUGUST 1990 ADDED CHECKS FOR MULTI- -- DIMENSIONAL ARRAYS WITH REPORT ; PROCEDURE CC3106B IS BEGIN -- CC3106B REPORT.TEST("CC3106B","CHECK THAT THE FORMAL PARAMETER DENOTES " & "THE ACTUAL IN AN INSTANTIATION"); LOCAL_BLOCK: DECLARE SUBTYPE SM_INT IS INTEGER RANGE 0..15 ; TYPE PCK_BOL IS ARRAY (5..18) OF BOOLEAN ; PRAGMA PACK(PCK_BOL) ; SHORT_START : CONSTANT := -100 ; SHORT_END : CONSTANT := 100 ; TYPE SHORT_RANGE IS RANGE SHORT_START .. SHORT_END ; SUBTYPE REALLY_SHORT IS SHORT_RANGE RANGE -9 .. 0 ; TYPE MONTH_TYPE IS (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC) ; SUBTYPE FIRST_HALF IS MONTH_TYPE RANGE JAN .. JUN ; TYPE DAY_TYPE IS RANGE 1 .. 31 ; TYPE YEAR_TYPE IS RANGE 1904 .. 2050 ; TYPE DATE IS RECORD MONTH : MONTH_TYPE ; DAY : DAY_TYPE ; YEAR : YEAR_TYPE ; END RECORD ; TODAY : DATE := (MONTH => AUG, DAY => 8, YEAR => 1990) ; FIRST_DATE : DATE := (DAY => 6, MONTH => JUN, YEAR => 1967) ; WALL_DATE : DATE := (MONTH => NOV, DAY => 9, YEAR => 1989) ; SUBTYPE FIRST_FIVE IS CHARACTER RANGE 'A' .. 'E' ; TYPE THREE_DIMENSIONAL IS ARRAY (REALLY_SHORT, FIRST_HALF, FIRST_FIVE) OF DATE ; TD_ARRAY : THREE_DIMENSIONAL := (THREE_DIMENSIONAL'RANGE => (THREE_DIMENSIONAL'RANGE (2) => (THREE_DIMENSIONAL'RANGE (3) => TODAY))) ; TASK TYPE TSK IS ENTRY ENT_1; ENTRY ENT_2; ENTRY ENT_3; END TSK; GENERIC TYPE GEN_TYPE IS (<>); GEN_BOLARR : IN OUT PCK_BOL; GEN_TYP : IN OUT GEN_TYPE; GEN_TSK : IN OUT TSK; TEST_VALUE : IN DATE ; TEST_CUBE : IN OUT THREE_DIMENSIONAL ; PACKAGE P IS PROCEDURE GEN_PROC1 ; PROCEDURE GEN_PROC2 ; PROCEDURE GEN_PROC3 ; PROCEDURE ARRAY_TEST ; END P; ACT_BOLARR : PCK_BOL := (OTHERS => FALSE); SI : SM_INT := 0 ; T : TSK; PACKAGE BODY P IS PROCEDURE GEN_PROC1 IS BEGIN -- GEN_PROC1 GEN_BOLARR(14) := REPORT.IDENT_BOOL(TRUE); GEN_TYP := GEN_TYPE'VAL(4); IF ACT_BOLARR(14) /= TRUE OR SI /= REPORT.IDENT_INT(4) THEN REPORT.FAILED("VALUES ARE DIFFERENT THAN " & "INSTANTIATED VALUES"); END IF; END GEN_PROC1; PROCEDURE GEN_PROC2 IS BEGIN -- GEN_PROC2 IF GEN_BOLARR(9) /= REPORT.IDENT_BOOL(TRUE) OR GEN_TYPE'POS(GEN_TYP) /= REPORT.IDENT_INT(2) THEN REPORT.FAILED("VALUES ARE DIFFERENT THAN " & "VALUES ASSIGNED IN THE MAIN " & "PROCEDURE"); END IF; GEN_BOLARR(18) := TRUE; GEN_TYP := GEN_TYPE'VAL(9); END GEN_PROC2; PROCEDURE GEN_PROC3 IS BEGIN -- GEN_PROC3 GEN_TSK.ENT_2; END GEN_PROC3 ; PROCEDURE ARRAY_TEST IS BEGIN -- ARRAY_TEST TEST_CUBE (0, JUN, 'C') := TEST_VALUE ; IF (TD_ARRAY (0, JUN, 'C') /= TEST_VALUE) OR (TEST_CUBE (-5, MAR, 'A') /= WALL_DATE) THEN REPORT.FAILED ("MULTI-DIMENSIONAL ARRAY VALUES ARE " & "DIFFERENT THAN THE VALUES ASSIGNED " & "IN THE MAIN AND ARRAY_TEST PROCEDURES.") ; END IF ; END ARRAY_TEST ; END P ; TASK BODY TSK IS BEGIN -- TSK ACCEPT ENT_1 DO REPORT.COMMENT("TASK ENTRY 1 WAS CALLED"); END; ACCEPT ENT_2 DO REPORT.COMMENT("TASK ENTRY 2 WAS CALLED"); END; ACCEPT ENT_3 DO REPORT.COMMENT("TASK ENTRY 3 WAS CALLED"); END; END TSK; PACKAGE INSTA1 IS NEW P (GEN_TYPE => SM_INT, GEN_BOLARR => ACT_BOLARR, GEN_TYP => SI, GEN_TSK => T, TEST_VALUE => FIRST_DATE, TEST_CUBE => TD_ARRAY) ; BEGIN -- LOCAL_BLOCK INSTA1.GEN_PROC1; ACT_BOLARR(9) := TRUE; SI := 2; INSTA1.GEN_PROC2; IF ACT_BOLARR(18) /= REPORT.IDENT_BOOL(TRUE) OR SI /= REPORT.IDENT_INT(9) THEN REPORT.FAILED("VALUES ARE DIFFERENT THAN VALUES " & "ASSIGNED IN THE GENERIC PROCEDURE"); END IF; T.ENT_1; INSTA1.GEN_PROC3; T.ENT_3; TD_ARRAY (-5, MAR, 'A') := WALL_DATE ; INSTA1.ARRAY_TEST ; END LOCAL_BLOCK; REPORT.RESULT; END CC3106B ;
----------------------------------------------------------------------- -- css-core-properties -- Core CSS API definition -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; package body CSS.Core.Properties is procedure Free is new Ada.Unchecked_Deallocation (CSSInternal_Property_Array, CSSInternal_Property_Array_Access); -- ------------------------------ -- Get the property with the given name from the list. -- If the property is defined several times, the last value -- that was inserted is returned. -- Raises the <tt>NO_PROPERTY</tt> exception if the property was not found. -- ------------------------------ function Get_Property (List : in CSSProperty_List; Name : in String) return CSSProperty is begin if List.Properties /= null then for P of List.Properties.all loop if P.Name.all = Name then return Result : CSSProperty do Result.Name := P.Name; Result.Value := P.Value; Result.Rule := List.Parent; Result.Location := Util.Log.Locations.Create_Line_Info (List.File, P.Line, P.Column); end return; end if; end loop; end if; raise NO_PROPERTY with "CSS property '" & Name & "' not found"; end Get_Property; -- ------------------------------ -- Get the number of properties in the list. -- ------------------------------ function Get_Length (List : in CSSProperty_List) return Natural is begin if List.Properties = null then return 0; else return List.Properties'Length; end if; end Get_Length; -- ------------------------------ -- Returns true if the two property list are identical. They contain -- the same properties in the same order. -- ------------------------------ function "=" (Left, Right : in CSSProperty_List) return Boolean is begin if Left.Properties = Right.Properties then return True; elsif Left.Properties = null or else Right.Properties = null then return False; elsif Left.Properties'Length /= Right.Properties'Length then return False; else for I in Left.Properties'Range loop -- Compare only the property name and property value. -- (we don't care about the line and column). if Left.Properties (I).Name /= Right.Properties (I).Name then return False; end if; if Left.Properties (I).Value /= Right.Properties (I).Value then return False; end if; end loop; return True; end if; end "="; -- ------------------------------ -- Set the file information associated with the property list. -- ------------------------------ procedure Set_File_Info (Into : in out CSSProperty_List; File : in Util.Log.Locations.File_Info_Access) is begin Into.File := File; end Set_File_Info; -- ------------------------------ -- Append the CSS property with the value to the list. -- ------------------------------ procedure Append (List : in out CSSProperty_List; Name : in CSSProperty_Name; Value : in Value_List; Line : in Natural := 0; Column : in Natural := 0) is New_List : CSSInternal_Property_Array_Access; begin if List.Properties = null then New_List := new CSSInternal_Property_Array (1 .. 1); else New_List := new CSSInternal_Property_Array (1 .. List.Properties'Length + 1); New_List (List.Properties'Range) := List.Properties.all; end if; New_List (New_List'Last).Name := Name; New_List (New_List'Last).Value := Value; New_List (New_List'Last).Line := Line; New_List (New_List'Last).Column := Column; Free (List.Properties); List.Properties := New_List; end Append; -- ------------------------------ -- Append the CSS property with the value to the list. -- ------------------------------ procedure Append (List : in out CSSProperty_List; Name : in CSSProperty_Name; Value : in Value_Type; Line : in Natural := 0; Column : in Natural := 0) is New_List : CSSInternal_Property_Array_Access; begin if List.Properties = null then New_List := new CSSInternal_Property_Array (1 .. 1); else New_List := new CSSInternal_Property_Array (1 .. List.Properties'Length + 1); New_List (List.Properties'Range) := List.Properties.all; end if; New_List (New_List'Last).Value.Append (Value); New_List (New_List'Last).Name := Name; New_List (New_List'Last).Line := Line; New_List (New_List'Last).Column := Column; Free (List.Properties); List.Properties := New_List; end Append; -- ------------------------------ -- Iterate over the list of properties and call the <tt>Process</tt> procedure. -- ------------------------------ procedure Iterate (List : in CSSProperty_List; Process : not null access procedure (Prop : in CSSProperty)) is Prop : CSSProperty; begin if List.Properties /= null then Prop.Rule := List.Parent; for P of List.Properties.all loop Prop.Name := P.Name; Prop.Value := P.Value; Prop.Location := Util.Log.Locations.Create_Line_Info (List.File, P.Line, P.Column); Process (Prop); end loop; end if; end Iterate; -- ------------------------------ -- Release the memory used by the property list. -- ------------------------------ overriding procedure Finalize (List : in out CSSProperty_List) is begin Free (List.Properties); end Finalize; end CSS.Core.Properties;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with GBA.Refs; with GBA.BIOS; with GBA.BIOS.Arm; with GBA.BIOS.Memset; with GBA.Display; with GBA.Display.Tiles; with GBA.Display.Backgrounds; with GBA.Display.Backgrounds.Refs; with GBA.Display.Objects; with GBA.Display.Palettes; with GBA.Display.Windows; with GBA.Allocation; use GBA.Allocation; with GBA.Memory; with GBA.Memory.Default_Heaps; with GBA.Numerics; with GBA.Numerics.Vectors; with GBA.Numerics.Matrices; with GBA.Interrupts; with GBA.Input; with GBA.Input.Buffered; with Interfaces; use Interfaces; with System.Machine_Code; use System.Machine_Code; procedure Hello is use GBA.BIOS; use GBA.BIOS.Arm; use GBA.Display; use GBA.Display.Palettes; use GBA.Display.Backgrounds; use GBA.Numerics; use GBA.Input; use GBA.Input.Buffered; use all type GBA.Refs.BG_Ref; VRAM : array (1 .. 160, 1 .. 240) of Color with Import, Volatile, Address => 16#6000000#; Color_Palette : Palette_16_Ptr := BG_Palette_16x16 (0)'Access; Color_BG : aliased Color with Volatile; procedure Adjust_Color (Y : Positive) is Index : Color_Index_16 := Color_Index_16 ((Y - 1) mod 160 / 32); begin Color_BG := Color_Palette (Index + 1); end; Y_Offset : Natural := 0; Origin : BG_Reference_Point := (X => 0.0, Y => 0.0); Theta : Radians_16 := 0.0; Delta_X, Delta_Y : Fixed_Snorm_16; begin Color_Palette (0 .. 5) := ( ( 0, 0, 0) , (19, 26, 21) , (31, 25, 21) , (31, 16, 15) , (29, 9, 11) , (00, 26, 26) ); -- GBA.Interrupts.Enable_Receiving_Interrupts; GBA.Interrupts.Enable_Interrupt (GBA.Interrupts.VBlank); Request_VBlank_Interrupt; Wait_For_VBlank; Set_Display_Mode (Mode_3); Enable_Display_Element (Background_2); loop Update_Key_State; for Y in VRAM'Range (1) loop for X in 1 .. 4 loop Adjust_Color (Y + Y_Offset * X); -- VRAM (Y, 1 + (X - 1) * 60 .. 1 + X * 60) := (others => Color_BG); Cpu_Set ( Source => Color_BG'Address , Dest => VRAM (Y, 1 + (X-1) * 60)'Address , Unit_Count => 60 , Unit_Size => Half_Word , Mode => Fill); end loop; end loop; if Are_Any_Down (A_Button or B_Button) then Y_Offset := @ + 5; else Y_Offset := @ + 1; end if; Sin_Cos_LUT (Theta, Delta_X, Delta_Y); Origin.X := 32.0 * Fixed_20_8 (Delta_X); Origin.Y := 32.0 * Fixed_20_8 (Delta_Y); Theta := @ + (1.0 / 128.0); Wait_For_VBlank; Set_Reference_Point (BG_2, Origin); end loop; end;
with PositionPackage, PathPackage, Ada.Text_IO, Ada.Assertions; use PositionPackage, PathPackage, Ada.Text_IO, Ada.Assertions; package TestPosition is procedure run_test; end TestPosition;
-- -- Copyright (C) 2012 Reto Buerki -- Copyright (C) 2012 Adrian-Ken Rueegsegger -- Hochschule fuer Technik Rapperswil -- -- This program is free software; you can redistribute it and/or modify it -- under the terms of the GNU General Public License as published by the -- Free Software Foundation; either version 2 of the License, or (at your -- option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. -- -- This program is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- for more details. -- package Exception_Handler is procedure Init; pragma Export (C, Init, "ehandler_init"); -- Register last-chance exception handler. end Exception_Handler;
------------------------------------------------------------------------------ -- 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. -- ------------------------------------------------------------------------------ package body Natools.S_Expressions.Special_Descriptors is overriding function Current_Event (Object : in Constant_Descriptor) return Events.Event is begin return Object.Event; end Current_Event; overriding function Current_Atom (Object : in Constant_Descriptor) return Atom is pragma Unreferenced (Object); begin raise Program_Error with "Current_Atom called on a special descriptor"; return Null_Atom; end Current_Atom; overriding function Current_Level (Object : in Constant_Descriptor) return Natural is pragma Unreferenced (Object); begin raise Program_Error with "Current_Level called on a special descriptor"; return 0; end Current_Level; overriding procedure Query_Atom (Object : in Constant_Descriptor; Process : not null access procedure (Data : in Atom)) is pragma Unreferenced (Object, Process); begin raise Program_Error with "Query_Atom called on a special descriptor"; end Query_Atom; overriding procedure Read_Atom (Object : in Constant_Descriptor; Data : out Atom; Length : out Count) is pragma Unreferenced (Object, Data, Length); begin raise Program_Error with "Read_Atom called on a special descriptor"; end Read_Atom; overriding procedure Next (Object : in out Constant_Descriptor; Event : out Events.Event) is pragma Unmodified (Object); begin Event := Object.Event; end Next; overriding procedure Lock (Object : in out Constant_Descriptor; State : out Lockable.Lock_State) is pragma Unreferenced (Object, State); begin raise Program_Error with "Lock called on a special descriptor"; end Lock; overriding procedure Unlock (Object : in out Constant_Descriptor; State : in out Lockable.Lock_State; Finish : in Boolean := True) is pragma Unreferenced (Object, State, Finish); begin raise Program_Error with "Unlock called on a special descriptor"; end Unlock; end Natools.S_Expressions.Special_Descriptors;
-------------------------------------------------------------------------- -- Arbitrary Precision Math Library -- Joe Wingbermuehle 20020320 <> 20020327 -------------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Unchecked_Deallocation; package body Arbitrary is procedure Delete is new Ada.Unchecked_Deallocation(Mantissa_Type, Mantissa_Pointer); ----------------------------------------------------------------------- -- Initialize an Arbitrary_Type ----------------------------------------------------------------------- procedure Initialize(object : in out Arbitrary_Type) is begin object.mantissa := new Mantissa_Type(1..object.precision); object.exponent := 0; object.sign := 1; for x in object.mantissa'range loop object.mantissa(x) := 0; end loop; end Initialize; ----------------------------------------------------------------------- -- Fix an Arbitrary_Type after being assigned a value ----------------------------------------------------------------------- procedure Adjust(object : in out Arbitrary_Type) is temp : Mantissa_Pointer; begin temp := new Mantissa_Type(1..object.precision); for x in object.mantissa'range loop temp(x) := object.mantissa(x); end loop; object.mantissa := temp; end Adjust; ----------------------------------------------------------------------- -- Release an Arbitrary_Type; ----------------------------------------------------------------------- procedure Finalize(object : in out Arbitrary_Type) is begin if object.mantissa /= null then Delete(object.mantissa); end if; object.mantissa := null; end Finalize; ----------------------------------------------------------------------- -- Shift mantissa left one digit and preserve the value ----------------------------------------------------------------------- procedure Shift_Left(a : in out Arbitrary_Type) is begin for x in a.mantissa'first + 1..a.mantissa'last loop a.mantissa(x - 1) := a.mantissa(x); end loop; a.mantissa(a.mantissa'last) := 0; a.exponent := a.exponent - 1; end Shift_Left; ----------------------------------------------------------------------- -- Shift the mantissa right one digit and preserve the value ----------------------------------------------------------------------- procedure Shift_Right(a : in out Arbitrary_Type) is begin for x in reverse a.mantissa'first..a.mantissa'last - 1 loop a.mantissa(x + 1) := a.mantissa(x); end loop; a.mantissa(a.mantissa'first) := 0; a.exponent := a.exponent + 1; end Shift_Right; ----------------------------------------------------------------------- -- Fix overflows, underflows, and sign changes ----------------------------------------------------------------------- procedure Normalize(a : in out Arbitrary_Type) is changed : boolean := true; temp : integer; carry : integer; begin -- Zero is a special case temp := a.mantissa'first; while temp <= a.mantissa'last loop exit when a.mantissa(temp) /= 0; temp := temp + 1; end loop; if temp > a.mantissa'last then a.sign := 1; a.exponent := 0; return; end if; while changed loop changed := false; for x in a.mantissa'first + 1 .. a.mantissa'last loop if a.mantissa(x) >= base then temp := a.mantissa(x); a.mantissa(x) := temp mod base; a.mantissa(x - 1) := a.mantissa(x - 1) + temp / base; changed := true; end if; while a.mantissa(x) < 0 loop a.mantissa(x) := a.mantissa(x) + base; a.mantissa(x - 1) := a.mantissa(x - 1) - 1; changed := true; end loop; end loop; if a.mantissa(a.mantissa'first) >= base then carry := a.mantissa(a.mantissa'first) / base; temp := a.mantissa(a.mantissa'first) mod base; a.mantissa(a.mantissa'first) := temp; Shift_Right(a); a.mantissa(a.mantissa'first) := carry; changed := true; end if; if a.mantissa(a.mantissa'first) < 0 then for x in a.mantissa'range loop a.mantissa(x) := -a.mantissa(x); end loop; a.sign := -a.sign; changed := true; end if; while a.mantissa(a.mantissa'first) = 0 loop Shift_Left(a); changed := true; end loop; end loop; end Normalize; ----------------------------------------------------------------------- -- Display an Arbitrary_Type ----------------------------------------------------------------------- procedure Display(a : Arbitrary_Type) is begin if a.sign < 0 then Put("-"); end if; Put(character'val(a.mantissa(a.mantissa'first) + character'pos('0'))); Put("."); for x in a.mantissa'first + 1 .. a.mantissa'last loop Put(character'val(a.mantissa(x) + character'pos('0'))); end loop; if a.exponent /= 0 then Put(" E" & a.exponent'img); end if; end Display; ----------------------------------------------------------------------- -- Set an Arbitrary_Type to zero -- (This is done in the Initializer) ----------------------------------------------------------------------- procedure Clear(a : out Arbitrary_Type) is begin for x in a.mantissa'range loop a.mantissa(x) := 0; end loop; a.exponent := 0; a.sign := 1; end Clear; ----------------------------------------------------------------------- -- Convert an integer type to an Arbitrary_Type ----------------------------------------------------------------------- function To_Arbitrary(value : integer; precision : integer) return Arbitrary_Type is result : Arbitrary_Type(precision); begin result.mantissa(result.exponent + 1) := value; Normalize(result); return result; end To_Arbitrary; ----------------------------------------------------------------------- -- Test for equality ----------------------------------------------------------------------- function "="(a, b : Arbitrary_Type) return boolean is begin if a.precision = b.precision and a.exponent = b.exponent and a.sign = b.sign then for x in a.mantissa'first..a.mantissa'last loop if a.mantissa(x) /= b.mantissa(x) then return false; end if; end loop; return true; else return false; end if; end "="; ----------------------------------------------------------------------- -- Test greater than ----------------------------------------------------------------------- function ">"(a, b : Arbitrary_Type) return boolean is begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; if a.sign < 0 and b.sign > 0 then return false; elsif a.sign > 0 and b.sign < 0 then return true; elsif a.exponent > b.exponent then if a.sign < 0 then return false; else return true; end if; elsif a.exponent < b.exponent then if a.sign < 0 then return true; else return false; end if; else if a.sign < 0 then for x in a.mantissa'range loop if a.mantissa(x) < b.mantissa(x) then return true; elsif a.mantissa(x) > b.mantissa(x) then return false; end if; end loop; else for x in a.mantissa'range loop if a.mantissa(x) > b.mantissa(x) then return true; elsif a.mantissa(x) < b.mantissa(x) then return false; end if; end loop; end if; return false; end if; end ">"; ----------------------------------------------------------------------- -- Test greater or equal ----------------------------------------------------------------------- function ">="(a, b : Arbitrary_Type) return boolean is begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; if a.sign < 0 and b.sign > 0 then return false; elsif a.sign > 0 and b.sign < 0 then return true; elsif a.exponent > b.exponent then if a.sign < 0 then return false; else return true; end if; elsif a.exponent < b.exponent then if a.sign < 0 then return true; else return false; end if; else if a.sign < 0 then for x in a.mantissa'range loop if a.mantissa(x) < b.mantissa(x) then return true; elsif a.mantissa(x) > b.mantissa(x) then return false; end if; end loop; else for x in a.mantissa'range loop if a.mantissa(x) > b.mantissa(x) then return true; elsif a.mantissa(x) < b.mantissa(x) then return false; end if; end loop; end if; return true; end if; end ">="; ----------------------------------------------------------------------- -- Test if less than ----------------------------------------------------------------------- function "<"(a, b : Arbitrary_Type) return boolean is begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; if a.sign < 0 and b.sign > 0 then return true; elsif a.sign > 0 and b.sign < 0 then return false; elsif a.exponent < b.exponent then if a.sign < 0 then return false; else return true; end if; elsif a.exponent > b.exponent then if a.sign < 0 then return true; else return false; end if; else if a.sign < 0 then for x in a.mantissa'range loop if a.mantissa(x) > b.mantissa(x) then return true; elsif a.mantissa(x) < b.mantissa(x) then return false; end if; end loop; else for x in a.mantissa'range loop if a.mantissa(x) < b.mantissa(x) then return true; elsif a.mantissa(x) > b.mantissa(x) then return false; end if; end loop; end if; return false; end if; end "<"; ----------------------------------------------------------------------- -- Test if less than or equal to ----------------------------------------------------------------------- function "<="(a, b : Arbitrary_Type) return boolean is begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; if a.sign < 0 and b.sign > 0 then return true; elsif a.sign > 0 and b.sign < 0 then return false; elsif a.exponent < b.exponent then if a.sign < 0 then return false; else return true; end if; elsif a.exponent > b.exponent then if a.sign < 0 then return true; else return false; end if; else if a.sign < 0 then for x in a.mantissa'range loop if a.mantissa(x) > b.mantissa(x) then return true; elsif a.mantissa(x) < b.mantissa(x) then return false; end if; end loop; else for x in a.mantissa'range loop if a.mantissa(x) < b.mantissa(x) then return true; elsif a.mantissa(x) > b.mantissa(x) then return false; end if; end loop; end if; return true; end if; end "<="; ----------------------------------------------------------------------- -- Compute n! to precision digits ----------------------------------------------------------------------- function Factorial(n : integer; precision : integer) return Arbitrary_Type is result : Arbitrary_Type(precision); begin if n < 0 then raise Constraint_Error; end if; result := To_Arbitrary(1, precision); for x in 2 .. n loop result := result * To_Arbitrary(x, precision); end loop; return result; end Factorial; ----------------------------------------------------------------------- -- Compute 1/n! ----------------------------------------------------------------------- function One_Over_Factorial(n : integer; precision : integer) return Arbitrary_Type is result : Arbitrary_Type(precision); begin if n < 0 then raise Constraint_Error; end if; result := To_Arbitrary(1, precision); for x in 2 .. n loop result := result / To_Arbitrary(x, precision); end loop; return result; end One_Over_Factorial; ----------------------------------------------------------------------- -- Compute the square root of n to precision digits ----------------------------------------------------------------------- function Square_Root(a : Arbitrary_Type) return Arbitrary_Type is result : Arbitrary_Type(a.precision); last : Arbitrary_Type(a.precision); two : constant Arbitrary_Type(a.precision) := To_Arbitrary(2, a.precision); begin -- x(i) = (x(i-1) + n / x(i-1)) / 2 result := To_Arbitrary(1, a.precision); loop last := result; result := result + a / result; result := result / two; exit when last = result; end loop; return result; end Square_Root; ----------------------------------------------------------------------- -- Unary + operator -- do nothing ----------------------------------------------------------------------- function "+"(a : Arbitrary_Type) return Arbitrary_Type is begin return a; end "+"; ----------------------------------------------------------------------- -- Negate a ----------------------------------------------------------------------- function "-"(a : Arbitrary_Type) return Arbitrary_Type is result : Arbitrary_Type(a.precision); begin result := a; result.sign := -result.sign; return result; end "-"; ----------------------------------------------------------------------- -- Compute a + b ----------------------------------------------------------------------- function "+"(a, b : Arbitrary_Type) return Arbitrary_Type is result : Arbitrary_Type(a.precision); begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; -- If the signs are different, addition becomes subtraction if a.sign /= b.sign then if b.sign < 0 then result := b; result.sign := -result.sign; result := a - result; return result; else result := a; result.sign := -result.sign; result := b - result; return result; end if; end if; -- Set result to the additive with the least exponent and shift if a.exponent > b.exponent then result := b; for x in b.exponent .. a.exponent - 1 loop Shift_Right(result); end loop; for x in result.mantissa'range loop result.mantissa(x) := result.mantissa(x) + a.mantissa(x); end loop; else result := a; for x in a.exponent .. b.exponent - 1 loop Shift_Right(result); end loop; for x in result.mantissa'range loop result.mantissa(x) := result.mantissa(x) + b.mantissa(x); end loop; end if; Normalize(result); return result; end "+"; ----------------------------------------------------------------------- -- Compute a - b ----------------------------------------------------------------------- function "-"(a, b : Arbitrary_Type) return Arbitrary_Type is result : Arbitrary_Type(a.precision); begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; -- Use addition if the signs differ if a.sign /= b.sign then if a.sign < 0 then result := b; result.sign := -1; return a + result; else result := b; result.sign := 1; return a + result; end if; end if; if a.exponent > b.exponent then result := b; for x in b.exponent .. a.exponent - 1 loop Shift_Right(result); end loop; for x in result.mantissa'range loop result.mantissa(x) := a.mantissa(x) - result.mantissa(x); end loop; else result := a; for x in a.exponent .. b.exponent - 1 loop Shift_Right(result); end loop; for x in result.mantissa'range loop result.mantissa(x) := result.mantissa(x) - b.mantissa(x); end loop; end if; Normalize(result); return result; end "-"; ----------------------------------------------------------------------- -- Compute a * b ----------------------------------------------------------------------- function "*"(a, b : Arbitrary_Type) return Arbitrary_Type is result : Arbitrary_Type( integer'max(a.precision, b.precision)); offset : integer; -- offset in result; begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; end if; offset := 0; for x in b.mantissa'range loop for y in a.mantissa'first .. a.mantissa'last - offset loop result.mantissa(offset + y) := result.mantissa(offset + y) + a.mantissa(y) * b.mantissa(x); end loop; offset := offset + 1; end loop; result.sign := a.sign * b.sign; result.exponent := a.exponent + b.exponent; Normalize(result); return result; end "*"; ----------------------------------------------------------------------- -- Compute a / b ----------------------------------------------------------------------- function "/"(a, b : Arbitrary_Type) return Arbitrary_Type is result : Arbitrary_Type(a.precision); denominator : Arbitrary_Type(a.precision); numerator : Arbitrary_Type(a.precision); temp : integer; begin if DEBUG_CHECKS then if a.precision /= b.precision then raise Constraint_Error; end if; if b = To_Arbitrary(0, b.precision) then raise Constraint_Error; end if; end if; if a = To_Arbitrary(0, a.precision) then return To_Arbitrary(0, a.precision); end if; numerator := a; numerator.sign := 1; denominator := b; denominator.sign := 1; -- The result's exponent will be the numerator's exponent -- minus the denominators exponent temp := numerator.exponent - denominator.exponent; result.exponent := temp; -- Now adjust the denominator's exponent such that we start getting -- digits for the result immediately -- The first digits will arise when the numerator and denominator -- have the same exponent. Since the result's exponent has already -- been calcuated, we simply adjust the denominator denominator.exponent := numerator.exponent; Magnitude: for x in result.mantissa'range loop Digit_Count: while numerator >= denominator loop -- Note that numerator must always be normalized exit Magnitude when numerator.mantissa(numerator.mantissa'first) = 0; result.mantissa(x) := result.mantissa(x) + 1; numerator := numerator - denominator; end loop Digit_Count; denominator.exponent := denominator.exponent - 1; end loop Magnitude; result.sign := a.sign * b.sign; Normalize(result); return result; end "/"; end Arbitrary;
with Generic_Unit; package Mission with SPARK_Mode is package New_Unit is new Generic_Unit(Index_Type => Integer, Element_Type => Float); use New_Unit; -- the mission can only go forward type Mission_State_Type is ( UNKNOWN, INITIALIZING, SELF_TESTING, ASCENDING); procedure run_Mission; end Mission;
-- Abstract: -- -- See spec -- -- Copyright (C) 2009, 2014-2015, 2017 - 2019 Free Software Foundation, Inc. -- -- This file is part of the WisiToken package. -- -- The WisiToken package is free software; you can redistribute it -- and/or modify it under the terms of the GNU General Public License -- as published by the Free Software Foundation; either version 3, or -- (at your option) any later version. The WisiToken package is -- distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. You should have received a copy of the -- GNU General Public License distributed with the WisiToken package; -- see file GPL.txt. 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. ------------------------------------------------------------------------------- with Ada.Strings.Fixed; package body WisiToken is function Padded_Image (Item : in Token_ID; Desc : in Descriptor) return String is begin return Ada.Strings.Fixed.Head (Desc.Image (Item).all, (if Item in Desc.First_Terminal .. Desc.Last_Terminal then Desc.Terminal_Image_Width else Desc.Image_Width)); end Padded_Image; function Image (Item : in Token_ID; Desc : in Descriptor) return String is begin return (if Item = Invalid_Token_ID then "-" else Desc.Image (Item).all); end Image; procedure Put_Tokens (Descriptor : in WisiToken.Descriptor) is use Ada.Text_IO; begin for I in Token_ID'First .. Descriptor.Last_Nonterminal loop Put_Line (Token_ID'Image (I) & " => " & Descriptor.Image (I).all); end loop; end Put_Tokens; function Find_ID (Descriptor : in WisiToken.Descriptor; Name : in String) return Token_ID is begin for I in Descriptor.Image'Range loop if Descriptor.Image (I).all = Name then return I; end if; end loop; raise SAL.Programmer_Error with "token name '" & Name & "' not found in descriptor.image"; end Find_ID; procedure To_Vector (Item : in Token_ID_Array; Vector : in out Token_ID_Arrays.Vector) is J : Integer := Vector.First_Index; begin for ID of Item loop Vector.Replace_Element (J, ID); J := J + 1; end loop; end To_Vector; function To_Vector (Item : in Token_ID_Array) return Token_ID_Arrays.Vector is begin return Result : Token_ID_Arrays.Vector do Result.Set_First_Last (Item'First, Item'Last); for I in Item'Range loop Result (I) := Item (I); end loop; end return; end To_Vector; function Shared_Prefix (A, B : in Token_ID_Arrays.Vector) return Natural is use all type Ada.Containers.Count_Type; I : Natural := A.First_Index; J : Natural := B.First_Index; begin if A.Length = 0 or B.Length = 0 then return 0; end if; loop exit when A (I) /= B (I) or I = A.Last_Index or J = B.Last_Index; I := I + 1; J := J + 1; end loop; return I - 1; end Shared_Prefix; function "&" (Left : in Token_ID_Set; Right : in Token_ID) return Token_ID_Set is begin return Result : Token_ID_Set := Left do Result (Right) := True; end return; end "&"; function To_Token_ID_Set (First, Last : in Token_ID; Item : in Token_ID_Array) return Token_ID_Set is begin return Result : Token_ID_Set := (First .. Last => False) do for ID of Item loop Result (ID) := True; end loop; end return; end To_Token_ID_Set; procedure To_Set (Item : in Token_ID_Arrays.Vector; Set : out Token_ID_Set) is begin for ID of Item loop Set (ID) := True; end loop; end To_Set; function To_Array (Item : in Token_ID_Set) return Token_ID_Arrays.Vector is begin return Result : Token_ID_Arrays.Vector do for ID in Item'Range loop if Item (ID) then Result.Append (ID); end if; end loop; end return; end To_Array; function Any (Item : in Token_ID_Set) return Boolean is begin for I in Item'Range loop if Item (I) then return True; end if; end loop; return False; end Any; function Count (Item : in Token_ID_Set) return Integer is Result : Integer := 0; begin for I in Item'Range loop if Item (I) then Result := Result + 1; end if; end loop; return Result; end Count; function Image (Item : in Token_ID_Set; Desc : in Descriptor; Max_Count : in Integer := Integer'Last; Inverted : in Boolean := False) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; Need_Comma : Boolean := False; Count : Integer := 0; function Include (Item : in Boolean) return Boolean is begin if not Inverted then return Item; else return not Item; end if; end Include; begin for I in Item'Range loop if Include (Item (I)) then if Need_Comma then Result := Result & ", "; end if; Result := Result & Image (I, Desc); Need_Comma := True; Count := Count + 1; if Count = Max_Count then return To_String (Result); end if; end if; end loop; return To_String (Result); end Image; function Image (Item : in Production_ID) return String is begin return '(' & Trimmed_Image (Item.LHS) & ',' & Natural'Image (Item.RHS) & ')'; end Image; function Trimmed_Image (Item : in Production_ID) return String is begin return Trimmed_Image (Item.LHS) & '.' & Trimmed_Image (Item.RHS); end Trimmed_Image; function Padded_Image (Item : in Production_ID; Width : in Integer) return String is use Ada.Strings.Fixed; begin return Result : String (1 .. Width) do Move (Trimmed_Image (Item), Result, Justify => Ada.Strings.Right); end return; end Padded_Image; function To_Vector (Item : in Production_ID_Array) return Production_ID_Arrays.Vector is begin return Result : Production_ID_Arrays.Vector do for I of Item loop Result.Append (I); end loop; end return; end To_Vector; function Net_Recursion (A, B : in Recursion) return Recursion is begin return (case A is when None => B, when Single => (case B is when None => Single, when others => B), when Right => (case B is when None | Single => Right, when others => B), when Left => (case B is when None | Single | Left => Left, when others => B), when Middle => Middle); end Net_Recursion; function Slice (Item : in Token_Array_Token_Set; I : in Token_ID) return Token_ID_Set is Result : Token_ID_Set := (Item'First (2) .. Item'Last (2) => False); begin for J in Result'Range loop Result (J) := Item (I, J); end loop; return Result; end Slice; function Any (Item : in Token_Array_Token_Set; I : in Token_ID) return Boolean is begin for J in Item'Range (2) loop if Item (I, J) then return True; end if; end loop; return False; end Any; function Any (Item : in Token_Array_Token_Set) return Boolean is begin for I in Item'Range (1) loop for J in Item'Range (2) loop if Item (I, J) then return True; end if; end loop; end loop; return False; end Any; procedure Or_Slice (Item : in out Token_Array_Token_Set; I : in Token_ID; Value : in Token_ID_Set) is begin for J in Item'Range (2) loop Item (I, J) := Item (I, J) or Value (J); end loop; end Or_Slice; procedure Put (Descriptor : in WisiToken.Descriptor; Item : in Token_Array_Token_Set) is use Ada.Text_IO; Paren_Done : Boolean := False; begin if not Any (Item) then Put_Line ("(others => (others => False))"); else Put ("("); for I in Item'Range (1) loop if Any (Item, I) then Put_Line (" " & Image (I, Descriptor) & " =>"); Put (" ("); Paren_Done := False; for J in Item'Range (2) loop if Item (I, J) then if Paren_Done then Put_Line (" |"); Put (" " & Image (J, Descriptor)); else Paren_Done := True; Put (Image (J, Descriptor)); end if; end if; end loop; if Paren_Done then Put_Line (" => True,"); Put_Line (" others => False)"); else Put_Line (" others => False),"); end if; end if; end loop; Put_Line ((if Paren_Done then " " else "") & "others => (others => False))"); end if; end Put; function Error_Message (File_Name : in String; Line : in Line_Number_Type; Column : in Ada.Text_IO.Count; Message : in String) return String is begin return File_Name & ":" & Trimmed_Image (if Line = Invalid_Line_Number then Integer'(0) else Integer (Line)) & ":" & Trimmed_Image (Integer (Column)) & ": " & Message; end Error_Message; function Image (Item : in Buffer_Region) return String is begin return "(" & Trimmed_Image (Integer (Item.First)) & " ." & Buffer_Pos'Image (Item.Last) & ")"; end Image; function "and" (Left, Right : in Buffer_Region) return Buffer_Region is begin return (Buffer_Pos'Min (Left.First, Right.First), Buffer_Pos'Max (Left.Last, Right.Last)); end "and"; function Image (Item : in Base_Token; Descriptor : in WisiToken.Descriptor) return String is ID_Image : constant String := WisiToken.Image (Item.ID, Descriptor); begin if Item.Char_Region = Null_Buffer_Region then return "(" & ID_Image & ")"; else return "(" & ID_Image & ", " & Image (Item.Char_Region) & ")"; end if; end Image; function Image (Token : in Base_Token_Index; Terminals : in Base_Token_Arrays.Vector; Descriptor : in WisiToken.Descriptor) return String is begin if Token = Invalid_Token_Index then return "<invalid_token_index>"; else return Token_Index'Image (Token) & ":" & Image (Terminals (Token), Descriptor); end if; end Image; function Image (Item : in Recover_Token; Descriptor : in WisiToken.Descriptor) return String is begin return "(" & Image (Item.ID, Descriptor) & (if Item.Byte_Region = Null_Buffer_Region then "" else ", " & Image (Item.Byte_Region)) & ")"; end Image; end WisiToken;