content
stringlengths
23
1.05M
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Iterator_Interfaces; limited with Regions.Entities; limited with Regions.Symbols; package Regions is pragma Pure; type Region is limited interface; type Entity_Cursor is abstract tagged record Entity : access Entities.Entity'Class; Left : Natural; -- How many entities left to iterate end record; subtype Entity_Cursor_Class is Entity_Cursor'Class; function Has_Element (Self : Entity_Cursor_Class) return Boolean is (Self.Entity /= null); package Entity_Iterator_Interfaces is new Ada.Iterator_Interfaces (Entity_Cursor_Class, Has_Element); -- type Entity_Iterator is limited interface and -- Entity_Iterator_Interfaces.Forward_Iterator; not overriding function Immediate_Visible_Backward (Self : Region; Symbol : Symbols.Symbol) return Entity_Iterator_Interfaces.Forward_Iterator'Class is abstract; not overriding function Immediate_Visible (Self : Region; Symbol : Symbols.Symbol) return Entity_Iterator_Interfaces.Forward_Iterator'Class is abstract; end Regions;
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------------ -- -- SPARK Proof Analysis Tool -- -- S.P.A.T. - Root package -- ------------------------------------------------------------------------------ limited with Ada.Containers; limited with Ada.Strings.Unbounded.Hash; with GNATCOLL.JSON; package SPAT is subtype JSON_Data is Ada.Strings.Unbounded.Unbounded_String; subtype Subject_Name is Ada.Strings.Unbounded.Unbounded_String; -- Type denoting some kind of name (i.e. file name, entity name, rule name -- etc. pp.) Null_Name : Subject_Name renames Ada.Strings.Unbounded.Null_Unbounded_String; -- Provide a renaming for the null string. --------------------------------------------------------------------------- -- To_String --------------------------------------------------------------------------- function To_String (Source : in Subject_Name) return String renames Ada.Strings.Unbounded.To_String; --------------------------------------------------------------------------- -- To_Name --------------------------------------------------------------------------- function To_Name (Source : in String) return Subject_Name renames Ada.Strings.Unbounded.To_Unbounded_String; --------------------------------------------------------------------------- -- "=" --------------------------------------------------------------------------- function "=" (Left : in Ada.Strings.Unbounded.Unbounded_String; Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean renames Ada.Strings.Unbounded."="; --------------------------------------------------------------------------- -- "<" --------------------------------------------------------------------------- function "<" (Left : in Ada.Strings.Unbounded.Unbounded_String; Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean renames Ada.Strings.Unbounded."<"; --------------------------------------------------------------------------- -- Hash --------------------------------------------------------------------------- function Hash (Key : Ada.Strings.Unbounded.Unbounded_String) return Ada.Containers.Hash_Type renames Ada.Strings.Unbounded.Hash; --------------------------------------------------------------------------- -- Length --------------------------------------------------------------------------- function Length (Source : in Ada.Strings.Unbounded.Unbounded_String) return Natural renames Ada.Strings.Unbounded.Length; -- Derived types for all kind of "names". type File_Name is new Subject_Name; -- A file on disk. type Entity_Name is new Subject_Name; -- An Ada language entity. -- Type renames for commonly used JSON types from GNATCOLL.JSON subtype JSON_Array is GNATCOLL.JSON.JSON_Array; subtype JSON_Value is GNATCOLL.JSON.JSON_Value; subtype JSON_Value_Type is GNATCOLL.JSON.JSON_Value_Type; subtype UTF8_String is GNATCOLL.JSON.UTF8_String; type File_Version is (GNAT_CE_2019, GNAT_CE_2020); -- Version information. Right now I only have access to the community -- releases of SPARK, so these are the only ones fully supported. end SPAT;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $: with Ada.Characters.Handling; with Asis.Clauses; with Asis.Elements; with Asis.Declarations; with Asis.Compilation_Units; with Asis.Gela.Utils; with Asis.Gela.Errors; with Asis.Gela.Elements; with Asis.Gela.Element_Utils; with XASIS.Utils; package body Asis.Gela.Visibility.Utils is function Find_Body_Stub (Body_Decl : Asis.Declaration; Subunit : Asis.Declaration) return Asis.Declaration; function Find_Corresponding_Declaration (Completion : Asis.Defining_Name; Point : Visibility.Point) return Asis.Defining_Name; function Find_In_With_Or_Parent (Unit : Asis.Compilation_Unit; Name : Wide_String) return Boolean; function Find_Name_Internal (Name : Asis.Program_Text; Until_Item : Region_Item_Access; No_Parent_Region : Boolean := False) return Region_Item_Access; procedure Unhide_Region_Item (Defining_Name : in Asis.Defining_Name; Point : in Visibility.Point); procedure Is_Char_Literal (Name : in Asis.Program_Text; Is_Wide_Wide : out Boolean; Is_Wide_Char : out Boolean; Is_Char : out Boolean); ---------------------- -- Check_Completion -- ---------------------- procedure Check_Completion (Declaration : Asis.Declaration; Point : Visibility.Point) is Completion_For : Asis.Defining_Name; begin declare List : constant Asis.Defining_Name_List := Asis.Declarations.Names (Declaration); begin for I in List'Range loop Completion_For := Find_Corresponding_Declaration (List (I), Point); Element_Utils.Set_Completion (Completion_For, Declaration); end loop; end; end Check_Completion; -------------- -- Find_All -- -------------- procedure Find_All (Item : in Region_Item_Access; Index : in out ASIS_Natural; Result : in out Asis.Defining_Name_List; Unit : in Asis.Compilation_Unit; Point : in Visibility.Point; No_Parent_Region : in Boolean := False) is use type Asis.List_Index; function Completion_Not_Exists return Boolean; function Unit_Withed (Item : Region_Item_Access; Unit : Asis.Compilation_Unit) return Boolean; function Completion_Not_Exists return Boolean is use XASIS.Utils; use Asis.Elements; Comp : Asis.Declaration := Completion_For_Name (Item.Defining_Name); Decl : Asis.Declaration; Found : Boolean := False; begin if not Assigned (Comp) then return True; end if; for I in 1 .. Index loop Decl := Enclosing_Element (Result (I)); if Is_Equal (Comp, Decl) then Found := True; exit; end if; end loop; return not Found; end Completion_Not_Exists; function Unit_Withed (Item : Region_Item_Access; Unit : Asis.Compilation_Unit) return Boolean is use Asis.Elements; use Asis.Compilation_Units; Decl_Unit : Asis.Compilation_Unit := Enclosing_Compilation_Unit (Item.Defining_Name); Unit_Name : Wide_String := Unit_Full_Name (Decl_Unit); begin return Find_In_With_Or_Parent (Unit, Unit_Name); end Unit_Withed; function Not_Overridden return Boolean is begin for I in 1 .. Index loop if Is_Equal (Item.Defining_Name, Element_Utils.Override (Result (I))) then return False; end if; end loop; return True; end Not_Overridden; function Is_Hidden (First : Asis.Defining_Name; Second : Asis.Defining_Name) return Boolean is use Asis.Elements; Decl_1 : Asis.Declaration := Enclosing_Element (First); Decl_2 : Asis.Declaration := Enclosing_Element (Second); Parent_1 : Asis.Declaration; Parent_2 : Asis.Declaration; Comp : Asis.Declaration; Kind : Asis.Declaration_Kinds := Declaration_Kind (Decl_1); begin if Declaration_Kind (Decl_2) /= Kind then return False; end if; if Kind = A_Parameter_Specification then Parent_1 := Enclosing_Element (Decl_1); Parent_2 := Enclosing_Element (Decl_2); elsif Kind = A_Discriminant_Specification then Parent_1 := Enclosing_Element (Enclosing_Element (Decl_1)); Parent_2 := Enclosing_Element (Enclosing_Element (Decl_2)); else return False; end if; -- How about Accert statement ??? if Declaration_Kind (Parent_1) in A_Body_Stub then Comp := Asis.Declarations.Corresponding_Subunit (Parent_1); if Is_Equal (Comp, Parent_2) then return True; end if; end if; Comp := XASIS.Utils.Completion_For_Declaration (Parent_1); return Is_Equal (Comp, Parent_2); end Is_Hidden; function Not_Hidden return Boolean is begin for I in 1 .. Index loop if Is_Hidden (Item.Defining_Name, Result (I)) then return False; end if; end loop; return True; end Not_Hidden; begin if (Item.Kind /= Definition or else not Item.Still_Hidden) and then Completion_Not_Exists and then Not_Overridden and then Not_Hidden and then Visible_From (Item, Point.Item) and then (Item.Kind /= Definition or else not Item.Library_Unit or else Unit_Withed (Item, Unit)) then Index := Index + 1; Result (Index) := Item.Defining_Name; end if; if No_Parent_Region and then Item.Prev = null then return; end if; if Item.Prev /= null then Find_All (Item.Prev, Index, Result, Unit, Point, No_Parent_Region); elsif Item.Up /= null then Find_All (Item.Up, Index, Result, Unit, Point, No_Parent_Region); end if; end Find_All; -------------------- -- Find_Body_Stub -- -------------------- function Find_Body_Stub (Body_Decl : Asis.Declaration; Subunit : Asis.Declaration) return Asis.Declaration is use Asis.Elements; use Asis.Gela.Errors; use Asis.Declarations; List : Asis.Element_List := Body_Declarative_Items (Body_Decl); Name : constant Asis.Program_Text := XASIS.Utils.Declaration_Direct_Name (Subunit); begin for I in List'Range loop if Declaration_Kind (List (I)) in A_Body_Stub and then XASIS.Utils.Has_Defining_Name (List (I), Name) then return List (I); end if; end loop; Report (Subunit, Error_No_Such_Stub); return Asis.Nil_Element; end Find_Body_Stub; ------------------------------------ -- Find_Corresponding_Declaration -- ------------------------------------ function Find_Corresponding_Declaration (Completion : Asis.Defining_Name; Point : Visibility.Point) return Asis.Defining_Name is use XASIS.Utils; use Asis.Elements; use Asis.Gela.Utils; Possible : Asis.Defining_Name_List := Visibility.Lookup_In_Region (Completion, Point, Point); Index : ASIS_Natural := 0; Decl : Asis.Declaration; begin for I in Possible'Range loop Decl := Enclosing_Element (Possible (I)); if not Overloadable (Possible (I)) or else (not Asis.Elements.Is_Part_Of_Implicit (Possible (I)) and then Are_Type_Conformant (Possible (I), Completion, Completion)) then Index := I; exit; end if; end loop; if Index = 0 then return Nil_Element; end if; return Possible (Index); end Find_Corresponding_Declaration; ---------------------------- -- Find_In_With_Or_Parent -- ---------------------------- function Find_In_With_Or_Parent (Unit : Asis.Compilation_Unit; Name : Wide_String) return Boolean is use Asis.Clauses; use Asis.Elements; use XASIS.Utils; use Asis.Compilation_Units; function With_Has_Name (Element : Asis.Element; Name : Program_Text) return Boolean is Item : Asis.Element := Element; begin loop if Are_Equal_Identifiers (Name_Image (Item), Name) then return True; end if; if Expression_Kind (Item.all) = A_Selected_Component then Item := Prefix (Item.all); else return False; end if; end loop; end With_Has_Name; Next : Asis.Compilation_Unit; Clauses : constant Context_Clause_List := Context_Clause_Elements (Unit); Unit_Name : Wide_String := Compilation_Units.Unit_Full_Name (Unit); begin if Are_Equal_Identifiers (Unit_Name, Name) then return True; end if; for I in Clauses'Range loop if Clause_Kind (Clauses (I)) = A_With_Clause then declare Names : constant Name_List := Clause_Names (Clauses (I)); begin for J in Names'Range loop if With_Has_Name (Names (J), Name) then return True; end if; end loop; end; end if; end loop; case Unit_Class (Unit) is when A_Separate_Body => Next := Corresponding_Subunit_Parent_Body (Unit); when A_Private_Body | A_Public_Body => Next := Corresponding_Declaration (Unit); when others => Next := Corresponding_Parent_Declaration (Unit); end case; if Is_Nil (Next) then return False; else return Find_In_With_Or_Parent (Next, Name); end if; end Find_In_With_Or_Parent; --------------- -- Find_Name -- --------------- function Find_Name (Name : Asis.Program_Text; Point : Visibility.Point; No_Parent_Region : Boolean := False) return Region_Item_Access is begin if Point.Item = null then return null; end if; return Find_Name_Internal (Name, Point.Item, No_Parent_Region); end Find_Name; ------------------------ -- Find_Name_Internal -- ------------------------ function Find_Name_Internal (Name : Asis.Program_Text; Until_Item : Region_Item_Access; No_Parent_Region : Boolean := False) return Region_Item_Access is Item : Region_Item_Access := Until_Item; Part : Part_Access := Item.Part; Region : Region_Access := Part.Region; Stored_Item : Region_Item_Access; Is_Wide_Wide : Boolean; Is_Wide_Char : Boolean; Is_Char : Boolean; procedure Fix_Item_Prev is begin -- Find the same name in the same region Item.Prev := Find_Name_Internal (Name => Name, Until_Item => Item.Next, No_Parent_Region => True); -- Find the same name in upper regions if Stored_Item.Part.Parent_Item /= null then Item.Up := Find_Name_Internal (Name => Name, Until_Item => Stored_Item.Part.Parent_Item); end if; -- Count names in the same region if Item.Prev = null then Item.Count := 0; else Item.Count := Item.Prev.Count; if Item.Prev.Up /= null then Item.Count := Item.Count - Item.Prev.Up.Count; end if; end if; -- Increment count by names in upper regions if Item.Up /= null then Item.Count := Item.Count + Item.Up.Count; end if; -- Count this name too Item.Count := Item.Count + 1; end Fix_Item_Prev; begin Is_Char_Literal (Name, Is_Wide_Wide, Is_Wide_Char, Is_Char); -- loop over regions (Region) while Region /= null loop Stored_Item := Item; -- loop over region items (Item) while Item /= null loop case Item.Kind is when Definition => if XASIS.Utils.Has_Name (Item.Defining_Name, Name) then if Item.Count = 0 then Fix_Item_Prev; end if; return Item; end if; when Char | Wide_Char | Wide_Wide_Char => if Is_Wide_Wide or (Is_Wide_Char and Item.Kind in Char .. Wide_Char) or (Is_Char and Item.Kind = Char) then Fix_Item_Prev; return Item; end if; when others => null; end case; Item := Item.Next; if Item = null then Part := Part.Next; if Part /= null then Item := Part.Last_Item; end if; end if; end loop; if No_Parent_Region then return null; end if; Item := Stored_Item.Part.Parent_Item; if Item /= null then Part := Item.Part; if Region.Library_Unit and Part.Kind in A_Children_Part then Item := Part.Last_Item; end if; Region := Part.Region; else Part := null; Region := null; end if; end loop; return null; end Find_Name_Internal; ------------------------ -- Find_Parent_Region -- ------------------------ procedure Find_Parent_Region (Unit : in Asis.Compilation_Unit; Point : out Visibility.Point) is use Asis.Elements; use Asis.Compilation_Units; Parent : Asis.Compilation_Unit; Decl : Asis.Declaration; Item : Region_Item_Access; begin if Unit_Kind (Unit) in Asis.A_Subunit then Parent := Corresponding_Subunit_Parent_Body (Unit); Decl := Unit_Declaration (Parent); Decl := Find_Body_Stub (Decl, Unit_Declaration (Unit)); Item := Get_Place (Decl); Point := (Item => Item.Part.Parent_Item); else Parent := Corresponding_Parent_Declaration (Unit); if Is_Nil (Parent) then Point := (Item => Top_Region.First_Part.Last_Item); else Decl := Unit_Declaration (Parent); Point := Find_Region (Decl); end if; end if; end Find_Parent_Region; ----------------- -- Find_Region -- ----------------- function Find_Region (Element : Asis.Element) return Visibility.Point is Item : Region_Item_Access := Get_Place (Element); begin return (Item => Item.Part.Region.Last_Part.Last_Item); end Find_Region; --------------- -- Get_Place -- --------------- function Get_Place (Point : in Asis.Element) return Region_Item_Access is use Asis.Gela.Elements; Element : Asis.Element := Point; Item : Region_Item_Access; begin while Item = null loop case Element_Kind (Element.all) is when Asis.A_Declaration => Item := Place (Declaration_Node (Element.all)); when Asis.An_Exception_Handler => Item := Place (Exception_Handler_Node (Element.all)); when Asis.A_Statement => Item := Place (Statement_Node (Element.all)); when Asis.A_Defining_Name => Item := Place (Defining_Name_Node (Element.all)); when Asis.A_Clause => Item := Place (Clause_Node (Element.all)); when others => null; end case; if Item = null then Element := Enclosing_Element (Element.all); end if; end loop; return Item; end Get_Place; --------------------------- -- Goto_Enclosing_Region -- --------------------------- function Goto_Enclosing_Region (Stmt : in Asis.Statement) return Visibility.Point renames Find_Region; --------------------- -- Is_Char_Literal -- --------------------- procedure Is_Char_Literal (Name : in Asis.Program_Text; Is_Wide_Wide : out Boolean; Is_Wide_Char : out Boolean; Is_Char : out Boolean) is use Ada.Characters.Handling; begin if Name (Name'First) = ''' then Is_Wide_Wide := True; Is_Wide_Char := Wide_Character'Pos (Name (Name'First + 1)) not in 16#D800# .. 16#DFFF#; Is_Char := Is_Character (Name (Name'First + 1)); else Is_Wide_Wide := False; Is_Wide_Char := False; Is_Char := False; end if; end Is_Char_Literal; ----------------- -- Is_Declared -- ----------------- function Is_Declared (Name : in Asis.Defining_Name) return Boolean is use Asis.Gela.Elements; Name_Node : Defining_Name_Ptr := Defining_Name_Ptr (Name); Name_Place : Region_Item_Access := Place (Name_Node.all); begin return Name_Place /= null; end Is_Declared; ----------------- -- Is_Template -- ----------------- function Is_Template (Decl : Asis.Declaration) return Boolean is use Asis.Elements; use Asis.Declarations; Template : Asis.Declaration; begin if Is_Part_Of_Instance (Decl) then Template := Enclosing_Element (Decl); case Declaration_Kind (Template) is when A_Generic_Instantiation | A_Formal_Package_Declaration | A_Formal_Package_Declaration_With_Box => return True; when others => null; end case; end if; return False; end Is_Template; ------------------------ -- Is_Top_Declaration -- ------------------------ function Is_Top_Declaration (Element : Asis.Element) return Boolean is use Asis.Elements; use Asis.Compilation_Units; Enclosing_Unit : constant Compilation_Unit := Enclosing_Compilation_Unit (Element); begin return Is_Identical (Element, Unit_Declaration (Enclosing_Unit)); end Is_Top_Declaration; --------------------- -- Is_Visible_Decl -- --------------------- function Is_Visible_Decl (Tipe : in Asis.Declaration) return Boolean is Item : Region_Item_Access; List : Asis.Defining_Name_List := Asis.Declarations.Names (Tipe); begin if List'Length = 0 then return True; else Item := Get_Place (List (1)); return Is_Visible (Item.Part.Kind); end if; end Is_Visible_Decl; --------------------- -- Need_New_Region -- --------------------- function Need_New_Region (Element : Asis.Element) return Boolean is use type Asis.Type_Kinds; use type Asis.Element_Kinds; use type Asis.Statement_Kinds; use type Asis.Definition_Kinds; use type Asis.Declaration_Kinds; Kind : Asis.Element_Kinds := Asis.Elements.Element_Kind (Element); Tipe : Asis.Definition; Enum : Asis.Type_Kinds; Stmt : Asis.Statement_Kinds; Def : Asis.Definition_Kinds; Decl : Asis.Declaration_Kinds; begin if Kind = Asis.An_Exception_Handler then return True; elsif Kind = Asis.A_Declaration then -- if XASIS.Utils.Is_Completion (Element) then -- return False; -- end if; Decl := Asis.Elements.Declaration_Kind (Element); if Decl = Asis.An_Ordinary_Type_Declaration then Tipe := Asis.Declarations.Type_Declaration_View (Element); Def := Asis.Elements.Definition_Kind (Tipe); if Def = Asis.A_Type_Definition then Enum := Asis.Elements.Type_Kind (Tipe); if Enum = Asis.An_Enumeration_Type_Definition then return False; end if; end if; elsif Decl = Asis.A_Return_Object_Specification then return False; end if; return True; elsif Kind /= Asis.A_Statement then return False; end if; Stmt := Asis.Elements.Statement_Kind (Element); if Stmt in Asis.A_Loop_Statement .. Asis.A_Block_Statement or Stmt = Asis.An_Accept_Statement or Stmt = Asis.An_Extended_Return_Statement then return True; end if; return False; end Need_New_Region; -------------------- -- Set_Name_Place -- -------------------- procedure Set_Name_Place (Element : in Asis.Defining_Name; Point : in Visibility.Point) is use Asis.Gela.Elements; Place : Region_Item_Access := Point.Item; begin Set_Place (Defining_Name_Node (Element.all), Place); end Set_Name_Place; --------------- -- Set_Place -- --------------- procedure Set_Place (Element : in Asis.Element; Point : in Visibility.Point) is use Asis.Gela.Elements; Place : Region_Item_Access := Point.Item; begin case Element_Kind (Element.all) is when Asis.A_Declaration => Set_Place (Declaration_Node (Element.all), Place); when Asis.An_Exception_Handler => Set_Place (Exception_Handler_Node (Element.all), Place); when Asis.A_Statement => Set_Place (Statement_Node (Element.all), Place); when Asis.A_Clause => Set_Place (Clause_Node (Element.all), Place); when others => null; end case; end Set_Place; --------------------- -- Strip_Homograph -- --------------------- procedure Strip_Homograph (Index : in out Asis.List_Index; Result : in out Asis.Defining_Name_List; Place : in Asis.Element) is use Asis.Gela.Utils; Passed : Asis.List_Index := 1; Failed : Boolean; begin for I in 2 .. Index loop Failed := False; for J in 1 .. Passed loop if Are_Homographs (Result (J), Result (I), Place) then Failed := True; exit; end if; end loop; if not Failed then Passed := Passed + 1; Result (Passed) := Result (I); end if; end loop; Index := Passed; end Strip_Homograph; ------------------------ -- Unhide_Declaration -- ------------------------ procedure Unhide_Declaration (Element : in Asis.Element; Point : in Visibility.Point) is Kind : Asis.Element_Kinds := Asis.Elements.Element_Kind (Element); begin pragma Assert (Kind = Asis.A_Declaration, "Wrong construct in Unhide_Declaration"); declare Names : Asis.Defining_Name_List := Asis.Declarations.Names (Element); begin for I in Names'Range loop Unhide_Region_Item (Names (I), Point); end loop; end; end Unhide_Declaration; ------------------------ -- Unhide_Region_Item -- ------------------------ procedure Unhide_Region_Item (Defining_Name : in Asis.Defining_Name; Point : in Visibility.Point) is Item : Region_Item_Access := Get_Place (Defining_Name); begin if Item.Kind = Definition and then Is_Equal (Item.Defining_Name, Defining_Name) then Item.Still_Hidden := False; end if; end Unhide_Region_Item; ------------------ -- Visible_From -- ------------------ function Visible_From (Name : in Region_Item_Access; Place : in Region_Item_Access) return Boolean is function Find_In_Region (Name : in Region_Item_Access; Place : in Region_Item_Access; With_Private : in Boolean) return Boolean is Place_Item : Region_Item_Access := Place; Part : Part_Access := Place_Item.Part; begin while Place_Item /= null loop if Place_Item = Name then if With_Private or Is_Visible (Name.Part.Kind) then return True; else return False; end if; end if; Place_Item := Place_Item.Next; if Place_Item = null then Part := Part.Next; if Part /= null then Place_Item := Part.Last_Item; end if; end if; end loop; return False; end Find_In_Region; Name_Item : Region_Item_Access := Name; Place_Item : Region_Item_Access := Place; With_Private : Boolean := True; From_Visible : Boolean := Is_Visible (Place.Part.Kind); Pl_Reg : Region_Access := Place_Item.Part.Region; begin while Pl_Reg.Depth < Name_Item.Part.Region.Depth loop if not Is_Visible (Name_Item.Part.Kind) then return False; end if; Name_Item := Name_Item.Part.Parent_Item; end loop; while Pl_Reg.Depth > Name_Item.Part.Region.Depth loop if Pl_Reg.Library_Unit and Pl_Reg.Public_Child and From_Visible then With_Private := False; else With_Private := True; end if; Place_Item := Place_Item.Part.Parent_Item; if Pl_Reg.Library_Unit and Place_Item.Part.Kind in A_Children_Part then Place_Item := Place_Item.Part.Last_Item; end if; From_Visible := Is_Visible (Place_Item.Part.Kind); Pl_Reg := Place_Item.Part.Region; end loop; loop if Pl_Reg = Name_Item.Part.Region then return Find_In_Region (Name_Item, Place_Item, With_Private); end if; if not Is_Visible (Name_Item.Part.Kind) then return False; end if; if Pl_Reg.Library_Unit and Pl_Reg.Public_Child and From_Visible then With_Private := False; else With_Private := True; end if; if Pl_Reg.Library_Unit then Pl_Reg := Place_Item.Part.Parent_Item.Part.Region; Place_Item := Pl_Reg.Last_Part.Last_Item; else Place_Item := Place_Item.Part.Parent_Item; Pl_Reg := Place_Item.Part.Region; end if; From_Visible := Is_Visible (Place_Item.Part.Kind); Name_Item := Name_Item.Part.Parent_Item; end loop; end Visible_From; ------------------ -- Visible_From -- ------------------ function Visible_From (Name : in Asis.Defining_Name; Point : in Asis.Element) return Boolean is use Asis.Elements; use Asis.Gela.Elements; function Child_Declaration_Part (Point : Region_Item_Access; Element : Asis.Element; Kind : Part_Kinds) return Part_Access; -- Find child region marked by Element abd return -- Visible specification part. ---------------------------- -- Child_Declaration_Part -- ---------------------------- function Child_Declaration_Part (Point : Region_Item_Access; Element : Asis.Element; Kind : Part_Kinds) return Part_Access is Result : Region_Access := Point.Part.Region.First_Child; Part : Part_Access; begin Search_Child_Region: while Result /= null loop Part := Result.Last_Part; while Part /= null loop if Is_Equal (Part.Element, Element) then exit Search_Child_Region; end if; Part := Part.Next; end loop; Result := Result.Next; end loop Search_Child_Region; if Result = null then return null; end if; Part := Result.Last_Part; while Part /= null loop if Part.Kind = Kind then return Part; end if; Part := Part.Next; end loop; return null; end Child_Declaration_Part; Name_Node : Defining_Name_Ptr := Defining_Name_Ptr (Name); Name_Place : Region_Item_Access := Place (Name_Node.all); Item : Region_Item_Access := Get_Place (Point); Part : Part_Access; Decl_Kind : constant Asis.Declaration_Kinds := Declaration_Kind (Enclosing_Element (Point)); begin if Element_Kind (Point) = A_Defining_Name then if Decl_Kind = A_Package_Declaration then -- This is a special element to point to end of package Part := Child_Declaration_Part (Point => Item, Element => Enclosing_Element (Point), Kind => A_Private_Part); Item := Part.Last_Item; elsif Decl_Kind = A_Package_Body_Declaration then Part := Child_Declaration_Part (Point => Item, Element => Enclosing_Element (Point), Kind => A_Body_Part); Item := Part.Last_Item; end if; end if; if Name_Place = null then -- Name have not been processed yet return False; else return Visible_From (Name_Place, Item); end if; end Visible_From; begin Top_Region.Last_Part := Top_Region.First_Part'Access; Top_Region.First_Part.Region := Top_Region'Access; Top_Region.First_Part.Kind := A_Public_Children_Part; Top_Region.First_Part.Last_Item := Top_Region.First_Part.Dummy_Item'Access; Top_Region.First_Part.Dummy_Item.Part := Top_Region.First_Part'Access; end Asis.Gela.Visibility.Utils; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
package body Swap_Generics is procedure Swap_Generic (Value_1 : in out Data_Type; Value_2 : in out Data_Type) is Tmp : Data_Type; begin Tmp := Value_1; Value_1 := Value_2; Value_2 := Tmp; end Swap_Generic; end Swap_Generics;
-- Abstract: -- -- WisiToken wrapper around the re2c lexer -- -- References: -- -- [1] http://re2c.org/ -- -- Copyright (C) 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. pragma License (GPL); -- GNATCOLL.Mmap pragma Warnings (Off, "license of withed unit ""GNATCOLL.Mmap"" may be inconsistent"); pragma Warnings (On); with Interfaces.C; with System; generic -- These subprograms are provided by generated source code. with function New_Lexer (Buffer : in System.Address; Length : in Interfaces.C.size_t; Verbosity : in Interfaces.C.int) return System.Address; -- Create the re2c lexer object, passing it the full text to process. -- Length is buffer length in 8 bit bytes. -- -- The C lexer does not know about Buffer_Nominal_First, -- Line_Nominal_First; its buffer positions and lines start at 1. with procedure Free_Lexer (Lexer : in out System.Address); -- Destruct the re2c lexer object with procedure Reset_Lexer (Lexer : in System.Address); -- Restart lexing, with previous input buffer. with function Next_Token (Lexer : in System.Address; ID : out Token_ID; Byte_Position : out Interfaces.C.size_t; Byte_Length : out Interfaces.C.size_t; Char_Position : out Interfaces.C.size_t; Char_Length : out Interfaces.C.size_t; Line_Start : out Interfaces.C.int) return Interfaces.C.int; -- *_Position and *_Length give the position and length in bytes and -- characters of the token from the start of the buffer, 0 indexed. -- -- Line_Start gives the line number in the source file that the first -- character of the token is in, 1 indexed. -- -- Result values: -- -- 0 - no error -- 1 - there is an unrecognized character at Position. package WisiToken.Lexer.re2c is Invalid_Input : exception; type Instance is new WisiToken.Lexer.Instance with private; overriding procedure Finalize (Object : in out Instance); function New_Lexer (Descriptor : not null access constant WisiToken.Descriptor) return WisiToken.Lexer.Handle; -- If the tokens do not include a reporting New_Line token, set -- New_Line_ID to Invalid_Token_ID. overriding procedure Reset_With_String (Lexer : in out Instance; Input : in String; Begin_Char : in Buffer_Pos := Buffer_Pos'First; Begin_Line : in Line_Number_Type := Line_Number_Type'First); -- Copies Input to internal buffer. overriding procedure Reset_With_String_Access (Lexer : in out Instance; Input : in Ada.Strings.Unbounded.String_Access; File_Name : in Ada.Strings.Unbounded.Unbounded_String; Begin_Char : in Buffer_Pos := Buffer_Pos'First; Begin_Line : in Line_Number_Type := Line_Number_Type'First); overriding procedure Reset_With_File (Lexer : in out Instance; File_Name : in String; Begin_Byte_Pos : in Buffer_Pos := Invalid_Buffer_Pos; End_Byte_Pos : in Buffer_Pos := Invalid_Buffer_Pos; Begin_Char : in Buffer_Pos := Buffer_Pos'First; Begin_Line : in Line_Number_Type := Line_Number_Type'First); -- Uses memory mapped file; no copies. overriding procedure Discard_Rest_Of_Input (Lexer : in out Instance) is null; overriding procedure Reset (Lexer : in out Instance); overriding function Buffer_Text (Lexer : in Instance; Byte_Bounds : in Buffer_Region) return String; overriding function First (Lexer : in Instance) return Boolean; overriding function Find_Next (Lexer : in out Instance; Token : out Base_Token) return Boolean; overriding function File_Name (Lexer : in Instance) return String; private type Instance is new WisiToken.Lexer.Instance with record Lexer : System.Address := System.Null_Address; Source : WisiToken.Lexer.Source; ID : Token_ID; -- Last token read by find_next Byte_Position : Natural; -- We don't use Buffer_Pos here, because Source.Buffer is indexed by Integer Byte_Length : Natural; Char_Position : Natural; Char_Length : Natural; -- Position and length in bytes and characters of last token from -- start of Managed.Buffer, 1 indexed. Line : Line_Number_Type; -- after last (or current) New_Line token Char_Line_Start : Natural; -- Character position after last New_Line token, lexer origin. Prev_ID : Token_ID; -- previous token_id end record; end WisiToken.Lexer.re2c;
with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Text_Io; use Ada.Text_Io; procedure Upper_Case_String is S : String := "alphaBETA"; begin Put_Line(To_Upper(S)); Put_Line(To_Lower(S)); end Upper_Case_String;
-- Standard Ada library specification -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- package Ada.Wide_Characters.Handling is pragma Pure(Handling); function Character_Set_Version return String; function Is_Control (Item : Wide_Character) return Boolean; function Is_Letter (Item : Wide_Character) return Boolean; function Is_Lower (Item : Wide_Character) return Boolean; function Is_Upper (Item : Wide_Character) return Boolean; function Is_Digit (Item : Wide_Character) return Boolean; function Is_Decimal_Digit (Item : Wide_Character) return Boolean renames Is_Digit; function Is_Hexadecimal_Digit (Item : Wide_Character) return Boolean; function Is_Alphanumeric (Item : Wide_Character) return Boolean; function Is_Special (Item : Wide_Character) return Boolean; function Is_Line_Terminator (Item : Wide_Character) return Boolean; function Is_Mark (Item : Wide_Character) return Boolean; function Is_Other_Format (Item : Wide_Character) return Boolean; function Is_Punctuation_Connector (Item : Wide_Character) return Boolean; function Is_Space (Item : Wide_Character) return Boolean; function Is_Graphic (Item : Wide_Character) return Boolean; function To_Lower (Item : Wide_Character) return Wide_Character; function To_Upper (Item : Wide_Character) return Wide_Character; function To_Lower (Item : Wide_String) return Wide_String; function To_Upper (Item : Wide_String) return Wide_String; end Ada.Wide_Characters.Handling;
with NRF52_DK.IOs; use NRF52_DK.IOs; with SteeringControl; use SteeringControl; with NRF52_DK.Buttons; use NRF52_DK.Buttons; with NRF52_DK.Time; with car_priorities; procedure Main is begin loop null; end loop; end Main;
----------------------------------------------------------------------- -- Servlets Tests - Unit tests for Servlet.Core -- Copyright (C) 2010, 2011, 2012, 2013, 2015, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Tests; with Util.Beans.Basic; with Util.Beans.Objects; package Servlet.Core.Tests is use Ada.Strings.Unbounded; procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test_Servlet1 is new Servlet with record Add_Resource : Boolean := False; end record; procedure Do_Get (Server : in Test_Servlet1; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class); type Test_Servlet2 is new Test_Servlet1 with null record; procedure Do_Post (Server : in Test_Servlet2; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class); type Test_Servlet3 is new Servlet with record Raise_Exception : Boolean := False; end record; procedure Do_Get (Server : in Test_Servlet3; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class); type Test is new Util.Tests.Test with record Writer : Integer; end record; -- Test creation of session procedure Test_Create_Servlet (T : in out Test); -- Test add servlet procedure Test_Add_Servlet (T : in out Test); -- Test getting a resource path procedure Test_Get_Resource (T : in out Test); procedure Test_Request_Dispatcher (T : in out Test); -- Test mapping and servlet path on a request. procedure Test_Servlet_Path (T : in out Test); -- Test mapping and servlet path on a request. procedure Test_Filter_Mapping (T : in out Test); -- Test execution of filters procedure Test_Filter_Execution (T : in out Test); -- Test execution of filters on complex mapping. procedure Test_Complex_Filter_Execution (T : in out Test); -- Test execution of the cache control filter. procedure Test_Cache_Control_Filter (T : in out Test); -- Test reading XML configuration file. procedure Test_Read_Configuration (T : in out Test); -- Test the Get_Name_Dispatcher. procedure Test_Name_Dispatcher (T : in out Test); -- Check that the mapping for the given URI matches the server. procedure Check_Mapping (T : in out Test; Ctx : in Servlet_Registry; URI : in String; Server : in Servlet_Access; Filter : in Natural := 0); -- Check that the request is done on the good servlet and with the correct servlet path -- and path info. procedure Check_Request (T : in out Test; Ctx : in Servlet_Registry; URI : in String; Servlet_Path : in String; Path_Info : in String); type Form_Bean is new Util.Beans.Basic.Bean with record Name : Unbounded_String; Password : Unbounded_String; Email : Unbounded_String; Called : Natural := 0; Gender : Unbounded_String; Use_Flash : Boolean := False; Def_Nav : Boolean := False; Perm_Error : Boolean := False; end record; type Form_Bean_Access is access all Form_Bean'Class; -- Get the value identified by the name. overriding function Get_Value (From : in Form_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. overriding procedure Set_Value (From : in out Form_Bean; Name : in String; Value : in Util.Beans.Objects.Object); end Servlet.Core.Tests;
-- AoC 2020, Day 23 with Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Fixed; use Ada.Strings.Fixed; package body Day is package TIO renames Ada.Text_IO; function to_cup_number(n : in Cup_Number_Mod) return Cup_Number is v : Natural := Natural(n+1); begin if v < Natural(Cup_Number'First) then v := Natural(Cup_Number'First); end if; return Cup_Number(v); end to_cup_number; function to_cup_number_mod(n : in Cup_Number) return Cup_Number_Mod is v : Natural := Natural(n) - 1; begin if v = 0 then v := Natural(Cup_Number_Mod'Last); end if; return Cup_Number_Mod(v); end to_cup_number_mod; function index_of(value : in Cup_Number; cups : in Cup_Array) return Cup_Index is begin for i in cups'Range loop if cups(i) = value then return i; end if; end loop; return cups'first; end index_of; function play(c : in Cup_Array; steps : in Natural) return String is cups : Cup_Array := c; next_cups : Cup_Array; current_idx : Cup_Index_Mod := Cup_Index_Mod(cups'first); dest : Cup_Number_Mod; dest_idx : Cup_Index; begin for s in 1..steps loop -- TIO.put_line("Step" & s'IMAGE); -- for c of cups loop -- TIO.put(c'IMAGE & " "); -- end loop; -- TIO.new_line; dest := to_cup_number_mod(cups(Cup_Index(current_idx))) - 1; loop dest_idx := index_of(to_cup_number(dest), cups); declare dest_idx_mod : constant Cup_Index_Mod := Cup_Index_Mod(dest_idx); begin if dest_idx_mod /= current_idx+1 and dest_idx_mod /= current_idx+2 and dest_idx_mod /= current_idx+3 then exit; end if; dest := dest-1; end; end loop; declare idx : Cup_Index_Mod := current_idx + 1; begin next_cups := cups; -- shift by three until we hit dest loop next_cups(Cup_Index(idx)) := cups(Cup_Index(idx+3)); if next_cups(Cup_Index(idx)) = to_cup_number(dest) then exit; end if; idx := idx + 1; end loop; -- add in the three removed items next_cups(Cup_Index(idx+1)) := cups(Cup_Index(current_idx+1)); next_cups(Cup_Index(idx+2)) := cups(Cup_Index(current_idx+2)); next_cups(Cup_Index(idx+3)) := cups(Cup_Index(current_idx+3)); end; current_idx := current_idx + 1; cups := next_cups; end loop; declare s : Unbounded_String := Null_Unbounded_String; one_idx : constant Cup_Index := index_of(1, cups); idx : Cup_Index_Mod := Cup_Index_Mod(one_idx) + 1; begin loop if Cup_Index(idx) = one_idx then TIO.put_line(to_string(s)); return to_string(s); end if; s := s & trim(cups(Cup_Index(idx))'IMAGE, Ada.Strings.Left); idx := idx + 1; end loop; end; end play; function play2(c : in Cup_Array; total_cups : in Natural; steps : in Natural) return Long_Integer is type Cup; type Cup_Access is access Cup; type Cup is record Value : Natural; Next : Cup_Access; end record; type Cup_Lookup_Array is array(1..total_cups) of Cup_Access; lookup : Cup_Lookup_Array; curr_cup : Cup_Access := null; begin declare new_cup : Cup_Access; last : Cup_Access := null; cnt : Natural := 1; begin for v of c loop new_cup := new Cup'(Value=>Natural(v), Next=>null); if curr_cup = null then curr_cup := new_cup; end if; lookup(new_cup.Value) := new_cup; if last /= null then last.Next := new_cup; end if; last := new_cup; cnt := cnt + 1; end loop; for v in cnt..total_cups loop new_cup := new Cup'(Value=>Natural(v), Next=>null); lookup(new_cup.Value) := new_cup; last.Next := new_cup; last := new_cup; end loop; last.next := curr_cup; end; -- declare -- tmp_cup : Cup_Access := curr_cup; -- cnt : Natural := 0; -- begin -- TIO.put_line("cups:"); -- loop -- TIO.put(tmp_cup.value'IMAGE & ", "); -- tmp_cup := tmp_cup.next; -- if cnt >= 20 then -- exit; -- end if; -- cnt := cnt + 1; -- end loop; -- end; for s in 1..steps loop declare type Move_Array is array(1..3) of Natural; target : Natural := curr_cup.value; target_ptr : Cup_Access := null; move_ptr : Cup_Access := null; move_vals : Move_Array; begin move_ptr := curr_cup.next; move_vals(1) := curr_cup.next.value; move_vals(2) := curr_cup.next.next.value; move_vals(3) := curr_cup.next.next.next.value; curr_cup.next := curr_cup.next.next.next.next; loop if target = 1 then target := total_cups; else target := target - 1; end if; if target /= move_vals(1) and target /= move_vals(2) and target /= move_vals(3) then exit; end if; end loop; target_ptr := lookup(target); move_ptr.next.next.next := target_ptr.next; target_ptr.next := move_ptr; curr_cup := curr_cup.next; end; end loop; declare i : constant Cup_Access := lookup(1); n1 : constant Long_Integer := Long_Integer(i.next.value); n2 : constant Long_Integer := Long_Integer(i.next.next.value); begin return n1 * n2; end; end play2; end Day;
package PP_LF_Rounded is -- Operations whose semantics is the same as the corresponding -- operations on type Long_Float. These operations can appear both in -- Ada expressions and in SPARK assertions. -- -- The intention is that programmers do not enter these operations -- directly into the Ada code. Instead the provided pre-processor -- replaces each ordinary operator or call of an Long_Elementary_Functions -- function with a corresponding function from this package. -- -- The Prec parameter is used only by PolyPaver to work -- out the rounding precision. The value for Prec is supplied -- by the pre-processor. function Plus (Prec : Integer; X,Y : Long_Float) return Long_Float; --# pre Plus(Prec,X,Y) in Long_Float; function Minus (Prec : Integer; X,Y : Long_Float) return Long_Float; --# pre Minus(Prec,X,Y) in Long_Float; function Multiply (Prec : Integer; X,Y : Long_Float) return Long_Float; --# pre Multiply(Prec,X,Y) in Long_Float; function Divide (Prec : Integer; X,Y : Long_Float) return Long_Float; --# pre Y /= 0.0 and --# Divide(Prec,X,Y) in Long_Float; function Pi(Prec : Integer) return Long_Float; function Exp (Prec : Integer; X : Long_Float) return Long_Float; --# pre Exp(Prec,X) in Long_Float; function Sqrt (Prec : Integer; X : Long_Float) return Long_Float; --# pre X >= 0.0 and --# Sqrt(Prec,X) in Long_Float; end PP_LF_Rounded;
separate(Practica2) function Es_primo(N:in natural) return Boolean is begin if n=0 then return true; else if n=1 then return true;-- ya sabemos que el uno es primo asi que yo miro los que son distintos de 1 en siguiente bucle else for i in 2..n loop if (n mod i)=0 and I=N then -- aqui explico si el resto de la divicion de N/I es igual a cero y I es igual a N return true; --devolvera verdadero else if (n mod i)=0 and i/=n then return false; end if; end if; end loop; return false; end if; end if; end;
With Ada.Strings.Fixed; Package Body Risi_Script.Types.Identifier.Scope is Function Image( Input : Scope ) return String is Function Img( Input : in out Scope ) return String is begin case Input.Length is when 0 => return ""; when 1 => return Input.First_Element; When others => declare Result : constant String:= '.' & Input.Last_Element; begin Input.Delete_Last; return Img(Input) & Result; end; end case; end Img; Working : Scope:= Input; begin Return Img(Working); end Image; Function Value( Input : String ) return Scope is Use Ada.Strings.Fixed, Ada.Strings; Start, Stop : Natural:= 0; begin Return Result : Scope := Global do Start:= Input'First; loop Stop:= Index(Source => Input, Pattern => ".", From => Start ); Stop := (if Stop not in Positive then Input'Last else Positive'Pred(Stop)); Result.Append( Input(Start..Stop) ); Start:= Positive'Succ( Positive'Succ( Stop ) ); Exit when Start not in Input'Range; end loop; end return; end Value; End Risi_Script.Types.Identifier.Scope;
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <denkpadje@gmail.com> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.SIMD.SSE.Singles; package Orka.SIMD.SSE4_1.Singles.Swizzle is pragma Pure; use Orka.SIMD.SSE.Singles; function Blend (Left, Right : m128; Mask : Unsigned_32) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendps"; -- Select elements from two sources (Left and Right) using a constant mask function Blend (Left, Right, Mask : m128) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendvps"; -- Select elements from two sources (Left and Right) using a variable mask function Extract (Elements : m128; Mask : Unsigned_32) return Float_32 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vec_ext_v4sf"; function Insert (Left, Right : m128; Mask : Unsigned_32) return m128 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_insertps128"; -- Insert an element from Right into Left. Bits 6-7 of Mask -- define the index of the source (Right), bits 4-5 define -- the index of the destination (Left). Bits 0-3 define the -- zero mask. end Orka.SIMD.SSE4_1.Singles.Swizzle;
----------------------------------------------------------------------- -- wiki-plugins-conditions -- Condition Plugin -- Copyright (C) 2016, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Wiki.Plugins.Conditions is -- ------------------------------ -- Append the attribute name/value to the condition plugin parameter list. -- ------------------------------ procedure Append (Plugin : in out Condition_Plugin; Name : in Wiki.Strings.WString; Value : in Wiki.Strings.WString) is begin Attributes.Append (Plugin.Params, Name, Value); end Append; -- ------------------------------ -- Evaluate the condition and return it as a boolean status. -- ------------------------------ function Evaluate (Plugin : in Condition_Plugin; Params : in Wiki.Attributes.Attribute_List) return Boolean is procedure Check (Name : in String; Value : in Wiki.Strings.WString); Result : Boolean := False; Index : Natural := 0; procedure Check (Name : in String; Value : in Wiki.Strings.WString) is pragma Unreferenced (Name); Pos : Wiki.Attributes.Cursor; begin Index := Index + 1; if Index > 1 and not Result then Pos := Attributes.Find (Plugin.Params, Wiki.Strings.To_String (Value)); Result := Attributes.Has_Element (Pos); end if; end Check; begin Attributes.Iterate (Params, Check'Access); return Result; end Evaluate; -- ------------------------------ -- Get the type of condition (IF, ELSE, ELSIF, END) represented by the plugin. -- ------------------------------ function Get_Condition_Kind (Plugin : in Condition_Plugin; Params : in Wiki.Attributes.Attribute_List) return Condition_Type is pragma Unreferenced (Plugin); Name : constant Strings.WString := Attributes.Get_Attribute (Params, "name"); begin if Name = "if" then return CONDITION_IF; elsif Name = "else" then return CONDITION_ELSE; elsif Name = "elsif" then return CONDITION_ELSIF; elsif Name = "end" then return CONDITION_END; else return CONDITION_IF; end if; end Get_Condition_Kind; -- ------------------------------ -- Evaluate the condition described by the parameters and hide or show the wiki -- content. -- ------------------------------ overriding procedure Expand (Plugin : in out Condition_Plugin; Document : in out Wiki.Documents.Document; Params : in out Wiki.Attributes.Attribute_List; Context : in out Plugin_Context) is pragma Unreferenced (Document); Kind : constant Condition_Type := Condition_Plugin'Class (Plugin).Get_Condition_Kind (Params); begin case Kind is when CONDITION_IF => Plugin.Depth := Plugin.Depth + 1; Plugin.Values (Plugin.Depth) := not Condition_Plugin'Class (Plugin).Evaluate (Params); when CONDITION_ELSIF => Plugin.Values (Plugin.Depth) := not Condition_Plugin'Class (Plugin).Evaluate (Params); when CONDITION_ELSE => Plugin.Values (Plugin.Depth) := not Plugin.Values (Plugin.Depth); when CONDITION_END => Plugin.Depth := Plugin.Depth - 1; end case; Context.Previous.Is_Hidden := Plugin.Values (Plugin.Depth); end Expand; end Wiki.Plugins.Conditions;
package Array_Pointer_Type is type A; type PA is access A; type A is array(1..2) of Boolean; end Array_Pointer_Type;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Utp; with Matreshka.Internals.Strings; package AMF.Internals.Tables.UTP_Attributes is function Internal_Get_Base_Accept_Event_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Accept_Event_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- TimeOutAction => TimeOutAction::base_AcceptEventAction function Internal_Get_Base_Behavior (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Behavior (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- Default => Default::base_Behavior -- TestCase => TestCase::base_Behavior -- TestLog => TestLog::base_Behavior -- TestSuite => TestSuite::base_Behavior function Internal_Get_Base_Behaviored_Classifier (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Behaviored_Classifier (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- TestContext => TestContext::base_BehavioredClassifier function Internal_Get_Base_Call_Operation_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Call_Operation_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- ReadTimerAction => ReadTimerAction::base_CallOperationAction -- StartTimerAction => StartTimerAction::base_CallOperationAction -- StopTimerAction => StopTimerAction::base_CallOperationAction -- ValidationAction => ValidationAction::base_CallOperationAction function Internal_Get_Base_Classifier (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Classifier (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- DataPartition => DataPartition::base_Classifier -- DataPool => DataPool::base_Classifier function Internal_Get_Base_Combined_Fragment (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Combined_Fragment (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- DetermAlt => DetermAlt::base_CombinedFragment function Internal_Get_Base_Dependency (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Dependency (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- DefaultApplication => DefaultApplication::base_Dependency -- TestLogApplication => TestLogApplication::base_Dependency -- TestObjective => TestObjective::base_Dependency function Internal_Get_Base_Element (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Element (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- ManagedElement => ManagedElement::base_Element function Internal_Get_Base_Invocation_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Invocation_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- FinishAction => FinishAction::base_InvocationAction function Internal_Get_Base_Literal_Specification (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Literal_Specification (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- LiteralAny => LiteralAny::base_LiteralSpecification -- LiteralAnyOrNull => LiteralAnyOrNull::base_LiteralSpecification function Internal_Get_Base_Message (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Message (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- TimeOutMessage => TimeOutMessage::base_Message function Internal_Get_Base_Namespace (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Namespace (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- CodingRule => CodingRule::base_Namespace function Internal_Get_Base_Opaque_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Opaque_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- FinishAction => FinishAction::base_OpaqueAction function Internal_Get_Base_Operation (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Operation (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- DataSelector => DataSelector::base_Operation -- TestCase => TestCase::base_Operation function Internal_Get_Base_Property (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Property (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- CodingRule => CodingRule::base_Property -- DataPool => DataPool::base_Property -- SUT => SUT::base_Property function Internal_Get_Base_Read_Structural_Feature_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Read_Structural_Feature_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- GetTimezoneAction => GetTimezoneAction::base_ReadStructuralFeatureAction -- TimerRunningAction => TimerRunningAction::base_ReadStructuralFeatureAction function Internal_Get_Base_Send_Object_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Send_Object_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- LogAction => LogAction::base_SendObjectAction function Internal_Get_Base_Structured_Classifier (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Structured_Classifier (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- TestComponent => TestComponent::base_StructuredClassifier -- TestContext => TestContext::base_StructuredClassifier function Internal_Get_Base_Time_Event (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Time_Event (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- TimeOut => TimeOut::base_TimeEvent function Internal_Get_Base_Value_Specification (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Value_Specification (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- CodingRule => CodingRule::base_ValueSpecification function Internal_Get_Base_Write_Structural_Feature_Action (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Element; procedure Internal_Set_Base_Write_Structural_Feature_Action (Self : AMF.Internals.AMF_Element; To : AMF.Internals.AMF_Element); -- SetTimezoneAction => SetTimezoneAction::base_WriteStructuralFeatureAction function Internal_Get_Coding (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Coding (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- CodingRule => CodingRule::coding function Internal_Get_Compatible_SUT_Variant (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Collection_Of_String; -- TestCase => TestCase::compatibleSUTVariant -- TestComponent => TestComponent::compatibleSUTVariant -- TestContext => TestContext::compatibleSUTVariant function Internal_Get_Compatible_SUT_Version (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Collection_Of_String; -- TestCase => TestCase::compatibleSUTVersion -- TestComponent => TestComponent::compatibleSUTVersion -- TestContext => TestContext::compatibleSUTVersion function Internal_Get_Criticality (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Criticality (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- ManagedElement => ManagedElement::criticality function Internal_Get_Description (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Description (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- ManagedElement => ManagedElement::description function Internal_Get_Duration (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Duration (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- TestLog => TestLog::duration function Internal_Get_Executed_At (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Executed_At (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- TestLog => TestLog::executedAt function Internal_Get_Owner (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Owner (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- ManagedElement => ManagedElement::owner function Internal_Get_Priority (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Priority (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- TestCase => TestCase::priority -- TestObjective => TestObjective::priority -- TestSuite => TestSuite::priority function Internal_Get_Repetition (Self : AMF.Internals.AMF_Element) return AMF.Unlimited_Natural; procedure Internal_Set_Repetition (Self : AMF.Internals.AMF_Element; To : AMF.Unlimited_Natural); -- DefaultApplication => DefaultApplication::repetition function Internal_Get_Sut_Version (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Sut_Version (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- TestLog => TestLog::sutVersion function Internal_Get_Test_Case (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Collection_Of_Element; -- TestSuite => TestSuite::testCase function Internal_Get_Test_Level (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Test_Level (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- TestContext => TestContext::testLevel function Internal_Get_Tester (Self : AMF.Internals.AMF_Element) return AMF.Internals.AMF_Collection_Of_String; -- TestLog => TestLog::tester function Internal_Get_Verdict (Self : AMF.Internals.AMF_Element) return AMF.Utp.Utp_Verdict; procedure Internal_Set_Verdict (Self : AMF.Internals.AMF_Element; To : AMF.Utp.Utp_Verdict); -- TestLog => TestLog::verdict function Internal_Get_Verdict_Reason (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Verdict_Reason (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- TestLog => TestLog::verdictReason function Internal_Get_Version (Self : AMF.Internals.AMF_Element) return Matreshka.Internals.Strings.Shared_String_Access; procedure Internal_Set_Version (Self : AMF.Internals.AMF_Element; To : Matreshka.Internals.Strings.Shared_String_Access); -- ManagedElement => ManagedElement::version end AMF.Internals.Tables.UTP_Attributes;
with Ada.Text_IO; with TOML; procedure Main is procedure Assert (Predicate : Boolean; Message : String); -- If Predicate is false, emit the given error Message procedure Assert_Eq (Left, Right : TOML.TOML_Value; Message : String); -- Shortcut for Assert (TOML.Equals (Left, Right), Message) procedure Assert_Ne (Left, Right : TOML.TOML_Value; Message : String); -- Shortcut for Assert (not TOML.Equals (Left, Right), Message) ------------ -- Assert -- ------------ procedure Assert (Predicate : Boolean; Message : String) is begin if not Predicate then Ada.Text_IO.Put_Line ("Test failed: " & Message); end if; end Assert; --------------- -- Assert_Eq -- --------------- procedure Assert_Eq (Left, Right : TOML.TOML_Value; Message : String) is begin Assert (TOML.Equals (Left, Right), Message); end Assert_Eq; --------------- -- Assert_Ne -- --------------- procedure Assert_Ne (Left, Right : TOML.TOML_Value; Message : String) is begin Assert (not TOML.Equals (Left, Right), Message); end Assert_Ne; use TOML; begin Assert_Ne (Create_String ("ABCD"), Create_Integer (0), "different kinds"); Assert_Eq (Create_Boolean (True), Create_Boolean (True), "same boolean"); Assert_Ne (Create_Boolean (True), Create_Boolean (False), "different boolean"); Assert_Eq (Create_Integer (0), Create_Integer (0), "same integer"); Assert_Ne (Create_Integer (0), Create_Integer (1), "different integer"); Assert_Eq (Create_String ("ABCD"), Create_String ("ABCD"), "same string"); Assert_Ne (Create_String ("ABCD"), Create_String ("ABCDE"), "different string"); declare Empty_1 : constant TOML_Value := Create_Array; Empty_2 : constant TOML_Value := Create_Array; One_Int_1 : constant TOML_Value := Create_Array; One_Int_2 : constant TOML_Value := Create_Array; Two_Ints : constant TOML_Value := Create_Array; One_String : constant TOML_Value := Create_Array; begin One_Int_1.Append (Create_Integer (0)); One_Int_2.Append (Create_Integer (0)); Two_Ints.Append (Create_Integer (0)); Two_Ints.Append (Create_Integer (1)); One_String.Append (Create_String ("ABCD")); Assert_Eq (Empty_1, Empty_2, "empty arrays"); Assert_Ne (Empty_1, One_Int_1, "different array length"); Assert_Eq (One_Int_1, One_Int_2, "same int array"); Assert_Ne (One_Int_1, Two_Ints, "different int array"); Assert_Ne (One_Int_1, One_String, "different array item kind"); end; declare Empty_1 : constant TOML_Value := Create_Table; Empty_2 : constant TOML_Value := Create_Table; Same_Key_1 : constant TOML_Value := Create_Table; Same_Key_2 : constant TOML_Value := Create_Table; Same_Key_3 : constant TOML_Value := Create_Table; Different_Key : constant TOML_Value := Create_Table; begin Same_Key_1.Set ("key", Create_Boolean (True)); Same_Key_2.Set ("key", Create_Boolean (True)); Same_Key_3.Set ("key", Create_Boolean (False)); Different_Key.Set ("KEY", Create_Boolean (True)); Assert_Eq (Empty_1, Empty_2, "empty tables"); Assert_Ne (Empty_1, Same_Key_1, "different table size"); Assert_Eq (Same_Key_1, Same_Key_2, "same table content"); Assert_Ne (Same_Key_1, Same_Key_3, "different member value"); Assert_Ne (Same_Key_1, Different_Key, "different key"); end; Ada.Text_IO.Put_Line ("Done"); end Main;
-- Automatically generated, do not edit. package OpenAL.Extension.Float32_Thin is -- Constants AL_FORMAT_MONO_FLOAT32 : constant := 16#10010#; AL_FORMAT_STEREO_FLOAT32 : constant := 16#10011#; end OpenAL.Extension.Float32_Thin;
package DDS.Request_Reply.Replieruntypedimpl is pragma Elaborate_Body; -- function RTI_Connext_ReplierUntypedImpl_Send_Sample -- (Self : not null access RTI_Connext_ReplierUntypedImpl; -- Data : System.Address; -- Related_Request_Info : DDS.SampleIdentity_T; -- WriteParams : in out DDS.WriteParams_T) return DDS.ReturnCode_T; -- Retcode : DDS.ReturnCode_T; -- -- function RTI_Connext_ReplierUntypedImpl_Configure_Params_For_Reply -- (Self : not null access RTI_Connext_ReplierUntypedImpl; -- Params : in out WriteParams_T; -- Related_Request_Info : DDS.SampleIdentity_T) return DDS.ReturnCode_T; -- -- function RTI_Connext_ReplierUntypedImpl_Create_Reader_Topic -- (Self : not null access RTI_Connext_EntityUntypedImpl; -- Params : RTI_Connext_EntityParams; -- Request_Type_Name : DDS.String) return DDS.Topic.Ref_Access; -- -- function RTI_Connext_ReplierUntypedImpl_Create_Writer_Topic -- (Self : not null access RTI_Connext_EntityUntypedImpl; -- Params : RTI_Connext_EntityParams; -- Reply_Type_Name : DDS.String) return DDS.Topic.Ref_Access; end DDS.Request_Reply.Replieruntypedimpl;
package body My_Class is procedure Primitive(Self: Object) is begin Put_Line("Hello World!"); end Primitive; procedure Dynamic(Self: Object'Class) is begin Put("Hi there! ... "); Self.Primitive; -- dispatching call: calls different subprograms, -- depending on the type of Self end Dynamic; procedure Static is begin Put_Line("Greetings"); end Static; end My_Class;
with openGL.Texture, openGL.GlyphImpl.Texture, freetype_c.FT_GlyphSlot; package openGL.Glyph.texture -- -- A specialisation of Glyph for creating texture glyphs. -- is type Item is new Glyph.item with private; ----------- -- Forge -- function to_Glyph (glyth_Slot : in freetype_c.FT_GlyphSlot.item; texture_Id : in openGL.Texture.texture_Name; xOffset, yOffset : in Integer; Width, Height : in Integer) return Glyph.texture.item; -- -- glyth_Slot: The Freetype glyph to be processed. -- texture_id: The id of the texture that this glyph will be drawn in. -- xOffset, yOffset: The x and y offset into the parent texture to draw this glyph. -- Width, Height: The width and height (number of rows) of the parent texture. function new_Glyph (glyth_Slot : in freetype_c.FT_GlyphSlot.item; texture_Id : in openGL.Texture.texture_Name; xOffset, yOffset : in Integer; Width, Height : in Integer) return access Glyph.texture.item'Class; -- -- glyth_Slot: The Freetype glyph to be processed. -- texture_Id: The id of the texture that this glyph will be drawn in. -- xOffset, yOffset: The x,y offset into the parent texture to draw this glyph. -- Width, Height: The width and height (number of rows) of the parent texture. -------------- -- Attributes -- function Quad (Self : in Item; Pen : in Vector_3) return GlyphImpl.texture.Quad_t; --------------- -- Operations -- overriding function render (Self : in Item; Pen : in Vector_3; renderMode : in Integer) return Vector_3; -- -- Render this glyph at the current pen position. -- -- Pen: The current pen position. -- renderMode: Render mode to display. -- -- Returns the advance distance for this glyph. private type Item is new Glyph.item with null record; end openGL.Glyph.texture;
with Ada.Containers; with Ada.Strings.Equal_Case_Insensitive; with Ada.Strings.Less_Case_Insensitive; with Ada.Strings.Hash_Case_Insensitive; with Ada.Strings.Wide_Hash_Case_Insensitive; with Ada.Strings.Wide_Wide_Hash_Case_Insensitive; procedure casing is use type Ada.Containers.Hash_Type; package AS renames Ada.Strings; subtype C is Character; Full_Width_Upper_A : constant String := ( C'Val (16#ef#), C'Val (16#bc#), C'Val (16#a1#)); Full_Width_Lower_A : constant String := ( C'Val (16#ef#), C'Val (16#bd#), C'Val (16#81#)); begin pragma Assert (AS.Equal_Case_Insensitive ("a", "a")); pragma Assert (not AS.Equal_Case_Insensitive ("a", "b")); pragma Assert (not AS.Equal_Case_Insensitive ("a", "aa")); pragma Assert (not AS.Equal_Case_Insensitive ("aa", "a")); pragma Assert (AS.Equal_Case_Insensitive ("a", "A")); pragma Assert (AS.Equal_Case_Insensitive ("aA", "Aa")); pragma Assert (AS.Equal_Case_Insensitive (Full_Width_Lower_A, Full_Width_Upper_A)); pragma Assert (AS.Less_Case_Insensitive ("a", "B")); pragma Assert (not AS.Less_Case_Insensitive ("b", "A")); pragma Assert (AS.Less_Case_Insensitive ("a", "AA")); pragma Assert (not AS.Less_Case_Insensitive ("aa", "A")); pragma Assert (not AS.Less_Case_Insensitive (Full_Width_Lower_A, Full_Width_Upper_A)); pragma Assert (AS.Hash_Case_Insensitive ("aAa") = AS.Hash_Case_Insensitive ("AaA")); -- Hash = Wide_Hash = Wide_Wide_Hash pragma Assert (AS.Hash_Case_Insensitive ("Hash") = AS.Wide_Hash_Case_Insensitive ("hASH")); pragma Assert (AS.Hash_Case_Insensitive ("HasH") = AS.Wide_Wide_Hash_Case_Insensitive ("hASh")); -- illegal sequence pragma Assert (AS.Less_Case_Insensitive ("", (1 => C'Val (16#80#)))); pragma Assert (AS.Less_Case_Insensitive (Full_Width_Upper_A, (1 => C'Val (16#80#)))); pragma Assert (AS.Less_Case_Insensitive (Full_Width_Upper_A, (C'Val (16#ef#), C'Val (16#bd#)))); pragma Assert (AS.Equal_Case_Insensitive (C'Val (16#80#) & Full_Width_Lower_A, C'Val (16#80#) & Full_Width_Upper_A)); pragma Debug (Ada.Debug.Put ("OK")); null; end casing;
with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Finalization; with Ada.Text_IO; use Ada.Text_IO; procedure Heronian is package Int_IO is new Ada.Text_IO.Integer_IO(Integer); use Int_IO; -- ----- Some math... function GCD (A, B : in Natural) return Natural is (if B = 0 then A else GCD (B, A mod B)); function Int_Sqrt (N : in Natural) return Natural is R1 : Natural := N; R2 : Natural; begin if N <= 1 then return N; end if; loop R2 := (R1+N/R1)/2; if R2 >= R1 then return R1; end if; R1 := R2; end loop; end Int_Sqrt; -- ----- Defines the triangle with sides as discriminants and a constructor which will -- compute its other characteristics type t_Triangle (A, B, C : Positive) is new Ada.Finalization.Controlled with record Is_Heronian : Boolean; Perimeter : Positive; Area : Natural; end record; overriding procedure Initialize (Self : in out t_Triangle) is -- Let's stick to integer computations, therefore a modified hero's formula -- will be used : S*(S-a)*(S-b)*(S-c) = (a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c)/16 -- This will require long integers because at max side size, the product -- before /16 excesses 2^31 Long_Product : Long_Long_Integer; Short_Product : Natural; begin Self.Perimeter := Self.A + Self.B + Self.C; Long_Product := Long_Long_Integer(Self.Perimeter) * Long_Long_Integer(- Self.A + Self.B + Self.C) * Long_Long_Integer( Self.A - Self.B + Self.C) * Long_Long_Integer( Self.A + Self.B - Self.C); Short_Product := Natural(Long_Product / 16); Self.Area := Int_Sqrt (Short_Product); Self.Is_Heronian := (Long_Product mod 16 = 0) and (Self.Area * Self.Area = Short_Product); end Initialize; -- ----- Ordering triangles with criteria (Area,Perimeter,A,B,C) function "<" (Left, Right : in t_Triangle) return Boolean is (Left.Area < Right.Area or else (Left.Area = Right.Area and then (Left.Perimeter < Right.Perimeter or else (Left.Perimeter = Right.Perimeter and then (Left.A < Right.A or else (Left.A = Right.A and then (Left.B < Right.B or else (Left.B = Right.B and then Left.C < Right.C)))))))); package Triangle_Lists is new Ada.Containers.Indefinite_Ordered_Sets (t_Triangle); use Triangle_Lists; -- ----- Displaying triangle characteristics Header : constant String := " A B C Per Area" & ASCII.LF & "---+---+---+---+-----"; procedure Put_Triangle (Position : Cursor) is Triangle : constant t_Triangle := Element(Position); begin Put(Triangle.A, 3); Put(Triangle.B, 4); Put(Triangle.C, 4); Put(Triangle.Perimeter, 4); Put(Triangle.Area, 6); New_Line; end Put_Triangle; -- ----- Global variables Triangles : Set := Empty_Set; -- Instead of constructing two sets, or browsing all the beginning of the set during -- the second output, start/end cursors will be updated during the insertions. First_201 : Cursor := No_Element; Last_201 : Cursor := No_Element; procedure Memorize_Triangle (A, B, C : in Positive) is Candidate : t_Triangle(A, B, C); Position : Cursor; Dummy : Boolean; begin if Candidate.Is_Heronian then Triangles.Insert (Candidate, Position, Dummy); if Candidate.Area = 210 then First_201 := (if First_201 = No_Element then Position elsif Position < First_201 then Position else First_201); Last_201 := (if Last_201 = No_Element then Position elsif Last_201 < Position then Position else Last_201); end if; end if; end Memorize_Triangle; begin -- Loops restrict to unique A,B,C (ensured by A <= B <= C) with sides < 200 and for -- which a triangle is constructible : C is not greater than B+A (flat triangle) for A in 1..200 loop for B in A..200 loop for C in B..Integer'Min(A+B-1,200) loop -- Filter non-primitive triangles if GCD(GCD(A,B),C) = 1 then Memorize_Triangle (A, B, C); end if; end loop; end loop; end loop; Put_Line (Triangles.Length'Img & " heronian triangles found :"); Put_Line (Header); Triangles.Iterate (Process => Put_Triangle'Access); New_Line; Put_Line ("Heronian triangles with area = 201"); Put_Line (Header); declare Position : Cursor := First_201; begin loop Put_Triangle (Position); exit when Position = Last_201; Position := Next(Position); end loop; end; end Heronian;
package Memory.Container is type Container_Type is abstract new Memory_Type with private; type Container_Pointer is access all Container_Type'Class; function Get_Memory(mem : Container_Type'Class) return Memory_Pointer; procedure Set_Memory(mem : in out Container_Type'Class; other : access Memory_Type'Class); overriding function Done(mem : Container_Type) return Boolean; overriding procedure Reset(mem : in out Container_Type; context : in Natural); overriding procedure Set_Port(mem : in out Container_Type; port : in Natural; ready : out Boolean); overriding procedure Read(mem : in out Container_Type; address : in Address_Type; size : in Positive); overriding procedure Write(mem : in out Container_Type; address : in Address_Type; size : in Positive); overriding procedure Idle(mem : in out Container_Type; cycles : in Time_Type); procedure Start(mem : in out Container_Type'Class); procedure Commit(mem : in out Container_Type'Class; cycles : out Time_Type); procedure Do_Read(mem : in out Container_Type'Class; address : in Address_Type; size : in Positive); procedure Do_Write(mem : in out Container_Type'Class; address : in Address_Type; size : in Positive); procedure Do_Idle(mem : in out Container_Type'Class; cycles : in Time_Type); overriding function Get_Path_Length(mem : Container_Type) return Natural; overriding procedure Show_Access_Stats(mem : in out Container_Type); overriding function To_String(mem : Container_Type) return Unbounded_String; overriding function Get_Cost(mem : Container_Type) return Cost_Type; overriding function Get_Writes(mem : Container_Type) return Long_Integer; overriding function Get_Word_Size(mem : Container_Type) return Positive; overriding function Get_Ports(mem : Container_Type) return Port_Vector_Type; overriding procedure Adjust(mem : in out Container_Type); overriding procedure Finalize(mem : in out Container_Type); private type Container_Type is abstract new Memory_Type with record mem : access Memory_Type'Class := null; start_time : Time_Type := 0; end record; end Memory.Container;
with Tipos_Tarea, Ada.Text_IO; use Tipos_Tarea, Ada.Text_IO; procedure Tarea_Dina_Declare is T1 : Tarea_Repetitiva(1); T_Dinamica : Tarea_Ptr; Td : Tarea_Ptr; begin Put_Line("Tarea Principal"); T_Dinamica := new Tarea_Repetitiva(4); declare task type T; type A is access T; P : A; Q : A; task body T is -- tarea dinamica en el declare begin for I in 1..3 loop Put_Line(" Tarea dinamica del declare"); delay 1.0; end loop; end T; begin Put_Line("Acccion previa a tarea dinmica"); P := new T; Q := new T; Put_Line("Accion tras tarea dinamica"); end; Td := new Tarea_Repetitiva(5); end Tarea_Dina_Declare;
package Vect2_Pkg is function K return Positive; function N return Positive; end Vect2_Pkg;
pragma License (Unrestricted); -- implementation unit package System.Exponentiations is pragma Pure; generic type Integer_Type is range <>; function Generic_Exp_Integer (Left : Integer_Type; Right : Natural) return Integer_Type; generic type Integer_Type is range <>; function Generic_Exp_Integer_No_Check (Left : Integer_Type; Right : Natural) return Integer_Type; -- Modulus = 2 ** N generic type Unsigned_Type is mod <>; with function Shift_Left (Value : Unsigned_Type; Amount : Natural) return Unsigned_Type is <>; function Generic_Exp_Unsigned (Left : Unsigned_Type; Right : Natural) return Unsigned_Type; -- Modulus /= 2 ** N generic type Unsigned_Type is mod <>; with function Shift_Left (Value : Unsigned_Type; Amount : Natural) return Unsigned_Type is <>; function Generic_Exp_Modular ( Left : Unsigned_Type; Modulus : Unsigned_Type; Right : Natural) return Unsigned_Type; end System.Exponentiations;
-- ----------------------------------------------------------------------------- -- smk, the smart make -- © 2018 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. -- ----------------------------------------------------------------------------- -- ----------------------------------------------------------------------------- -- Package: Smk.Makefiles body -- -- Implementation Notes: -- -- Portability Issues: -- -- Anticipated Changes: -- ----------------------------------------------------------------------------- with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; with Ada.Text_IO; use Ada.Text_IO; with Smk.IO; package body Smk.Makefiles is Debug : constant Boolean := False; Prefix : constant String := " smk-makefile.adb "; use Ada.Strings; use Ada.Strings.Fixed; Current_Section : Run_Files.Section_Names := Run_Files.Default_Section; use Ada.Strings.Maps; use Ada.Strings.Maps.Constants; Whitespace_Set : constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set (Ada.Characters.Latin_1.HT & Ada.Characters.Latin_1.Space & "@"); Identifier_Set : constant Ada.Strings.Maps.Character_Set := Alphanumeric_Set or To_Set (".-_"); -- -------------------------------------------------------------------------- function Is_Empty (Line : in String) return Boolean is (Index_Non_Blank (Line) = 0); -- -------------------------------------------------------------------------- function Is_A_Comment (Line : in String) return Boolean is begin return Head (Line, Count => 1) = "#" or else -- Shell style comment Head (Line, Count => 2) = "--" or else -- Ada style comment Head (Line, Count => 2) = "//"; -- Java style comment end Is_A_Comment; -- -------------------------------------------------------------------------- function Is_A_Section (Line : in String) return Boolean is -- A section line is an identifier followed by a semicolon. -- NB: this function updates the global Current_Section variable First : Positive; Last : Natural; begin Find_Token (Source => Line, Set => Identifier_Set, Test => Inside, First => First, Last => Last); if Last = 0 then return False; -- The line don't start with an identifier, can't be a section else IO.Put_Debug_Line (Line (First .. Last) & "<", Debug, Prefix); if Index (Source => Line, Pattern => ":", From => Last + 1, Going => Forward) /= 0 then Current_Section := +(Line (First .. Last)); return True; else return False; end if; end if; end Is_A_Section; -- -------------------------------------------------------------------------- procedure Analyze (Makefile_Name : in String; Line_List : out Makefile) is Make_Fl : Ada.Text_IO.File_Type; Entry_List : Makefile_Entry_Lists.List; begin Open (Make_Fl, Mode => In_File, Name => Makefile_Name); Analysis : while not End_Of_File (Make_Fl) loop declare --Line : constant String := Trim (Get_Line (Make_Fl), Side => Both); Raw_Line : constant String := Get_Line (Make_Fl); First_Non_Blank : constant Natural := Index (Source => Raw_Line, Set => Whitespace_Set, Test => Outside); Line : constant String := Raw_Line (Natural'Max (1, First_Non_Blank) .. Raw_Line'Last); -- Line = Get_Line, but heading blanks or tabs character are removed -- If there is not heading blank, First_Non_Blank will be null, -- and Line will start at 1. Line_Nb : constant Integer := Integer (Ada.Text_IO.Line (Make_Fl)); begin if Is_A_Comment (Line) then IO.Put_Debug_Line (Line & "<", Debug => Debug, Prefix => Prefix & "Comment >", File => Makefile_Name, Line => Line_Nb); elsif Is_Empty (Line) then IO.Put_Debug_Line (Line & "<", Debug => Debug, Prefix => Prefix & "Empty line >", File => Makefile_Name, Line => Line_Nb); elsif Is_A_Section (Line) then IO.Put_Debug_Line (+Current_Section & "<", Debug => Debug, Prefix => Prefix & "Section >", File => Makefile_Name, Line => Line_Nb); else -- Last but not least, it's a command line. declare -- First : Positive; -- Last : Natural; begin -- -- Let's go to the first Identifier -- Find_Token (Source => Line, -- Set => Whitespace_Set, -- Test => Outside, -- First => First, -- Last => Last); IO.Put_Debug_Line (Line -- (First .. Line'Last) & "<", Debug => Debug, Prefix => Prefix & "Command >", File => Makefile_Name, Line => Line_Nb); Entry_List.Append ((Line => Line_Nb - 1, -- why -1 ??? Section => Current_Section, Command => +(Line), -- (First .. Line'Last)), Already_Run => False)); end; end if; end; end loop Analysis; Close (Make_Fl); declare use Ada.Directories; begin Line_List := (Name => +Makefile_Name, Time_Tag => Modification_Time (Makefile_Name), Entries => Entry_List); end; end Analyze; -- -------------------------------------------------------------------------- procedure Dump (The_Make_File : in Makefile) is Time_Tag : constant String := IO.Image (The_Make_File.Time_Tag); begin IO.Put_Line (+The_Make_File.Name & " (" & Time_Tag & ") :"); for E of The_Make_File.Entries loop IO.Put_Line (Trim (Positive'Image (E.Line), Left) & ": [" & (+E.Section) & "] " & (+E.Command)); end loop; end Dump; end Smk.Makefiles;
package Math_Pkg is procedure Is_Prime(To_Check : in Integer; Prime : out Boolean); end Math_PKg;
-- Institution: Technische Universität München -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: Emanuel Regnath (emanuel.regnath@tum.de) -- -- Description: register definitions for the HMC5883L package HMC5883L.Register with SPARK_Mode is HMC5883L_ADDRESS : constant := 16#3C# ;-- this device only has one address HMC5883L_DEFAULT_ADDRESS : constant := 16#1E#; -- 2#0011_110X HMC5883L_RA_CONFIG_A : constant := 16#00#; HMC5883L_RA_CONFIG_B : constant := 16#01#; HMC5883L_RA_MODE : constant := 16#02#; HMC5883L_RA_DATAX_H : constant := 16#03#; HMC5883L_RA_DATAX_L : constant := 16#04#; HMC5883L_RA_DATAZ_H : constant := 16#05#; HMC5883L_RA_DATAZ_L : constant := 16#06#; HMC5883L_RA_DATAY_H : constant := 16#07#; HMC5883L_RA_DATAY_L : constant := 16#08#; HMC5883L_RA_STATUS : constant := 16#09#; HMC5883L_RA_IDA : constant := 16#0A#; HMC5883L_RA_IDB : constant := 16#0B#; HMC5883L_RA_IDC : constant := 16#0C#; HMC5883L_CRA_AVERAGE_BIT : constant := 6; HMC5883L_CRA_AVERAGE_LENGTH : constant := 2; HMC5883L_CRA_RATE_BIT : constant := 4; HMC5883L_CRA_RATE_LENGTH : constant := 3; HMC5883L_CRA_BIAS_BIT : constant := 1; HMC5883L_CRA_BIAS_LENGTH : constant := 2; HMC5883L_AVERAGING_1 : constant := 16#00#; HMC5883L_AVERAGING_2 : constant := 16#01#; HMC5883L_AVERAGING_4 : constant := 16#02#; HMC5883L_AVERAGING_8 : constant := 16#03#; HMC5883L_RATE_0P75 : constant := 16#00#; HMC5883L_RATE_1P5 : constant := 16#01#; HMC5883L_RATE_3 : constant := 16#02#; HMC5883L_RATE_7P5 : constant := 16#03#; HMC5883L_RATE_15 : constant := 16#04#; HMC5883L_RATE_30 : constant := 16#05#; HMC5883L_RATE_75 : constant := 16#06#; HMC5883L_BIAS_NORMAL : constant := 16#00#; HMC5883L_BIAS_POSITIVE : constant := 16#01#; HMC5883L_BIAS_NEGATIVE : constant := 16#02#; HMC5883L_CRB_GAIN_BIT : constant := 7; HMC5883L_CRB_GAIN_LENGTH : constant := 3; HMC5883L_GAIN_1370 : constant := 16#00#; HMC5883L_GAIN_1090 : constant := 16#01#; HMC5883L_GAIN_820 : constant := 16#02#; HMC5883L_GAIN_660 : constant := 16#03#; HMC5883L_GAIN_440 : constant := 16#04#; HMC5883L_GAIN_390 : constant := 16#05#; HMC5883L_GAIN_330 : constant := 16#06#; HMC5883L_GAIN_220 : constant := 16#07#; HMC5883L_MODEREG_BIT : constant := 1; HMC5883L_MODEREG_LENGTH : constant := 2; HMC5883L_MODE_CONTINUOUS : constant := 16#00#; HMC5883L_MODE_SINGLE : constant := 16#01#; HMC5883L_MODE_IDLE : constant := 16#02#; HMC5883L_STATUS_LOCK_BIT : constant := 1; HMC5883L_STATUS_READY_BIT : constant := 0; end HMC5883L.Register;
with System.Address_To_Access_Conversions; with Interfaces.C.Strings; with Ada.Tags; with Ada.Exceptions; with GDNative.Thin; with GDNative.Context; with GDNative.Console; with GDNative.Exceptions; package body GDNative.Objects is package S renames System; package IC renames Interfaces.C; package ICS renames Interfaces.C.Strings; package AE renames Ada.Exceptions; ------------------------- -- Object Registration -- ------------------------- package body Object_Registration is package Cast is new System.Address_To_Access_Conversions (New_Object); package Wrappers is function Create ( p_instance : System.Address; p_method_data : System.Address) return System.Address with Convention => C; procedure Destroy ( p_instance : System.Address; p_method_data : System.Address; p_user_data : System.Address) with Convention => C; end; package body Wrappers is function Create ( p_instance : S.Address; p_method_data : S.Address) return S.Address is Addr : S.Address := Context.Core_Api.godot_alloc (IC.int (New_Object'size)); Access_Instance : Cast.Object_Pointer := Cast.To_Pointer (Addr); begin Access_Instance.all := Initialize; return Addr; exception when Occurrence : others => Exceptions.Put_Error (Occurrence); return S.Null_Address; end; procedure Destroy ( p_instance : S.Address; p_method_data : S.Address; p_user_data : S.Address) is begin Context.Core_Api.godot_free (p_user_data); exception when Occurrence : others => Exceptions.Put_Error (Occurrence); end; end; -------------------- -- Register_Class -- -------------------- procedure Register_Class is Create_Func : Thin.godot_instance_create_func := (Wrappers.Create'access, S.Null_Address, null); Destroy_Func : Thin.godot_instance_destroy_func := (Wrappers.Destroy'access, S.Null_Address, null); Name_Ptr : ICS.chars_ptr := ICS.New_String (Ada.Tags.External_Tag (New_Object'Tag)); Reference_Ptr : ICS.chars_ptr := ICS.New_String ("Reference"); begin pragma Assert (Context.Core_Initialized, "Please run Context.GDNative_Initialize"); pragma Assert (Context.Nativescript_Initialized, "Please run Context.Nativescript_Initialize"); Console.Put ("Registering Class: " & To_Wide (Ada.Tags.External_Tag (New_Object'Tag))); Context.Nativescript_Api.godot_nativescript_register_class ( Context.Nativescript_Ptr, Name_Ptr, Reference_Ptr, Create_Func, Destroy_Func); ICS.Free (Name_Ptr); ICS.Free (Reference_Ptr); exception when Occurrence : others => Exceptions.Put_Error (Occurrence); end; end; ----------------------- -- Node Registration -- ----------------------- package body Node_Registration is package Cast is new System.Address_To_Access_Conversions (New_Node); package Wrappers is function Process ( p_instance : System.Address; p_method_data : System.Address; p_user_data : System.Address; p_num_args : Interfaces.C.int; p_args : Thin.Godot_Instance_Method_Args_Ptrs.Pointer) -- godot_variant ** return Thin.godot_variant with Convention => C; end; package body Wrappers is function Process ( p_instance : S.Address; p_method_data : S.Address; p_user_data : S.Address; p_num_args : IC.int; p_args : Thin.Godot_Instance_Method_Args_Ptrs.Pointer) -- godot_variant ** return Thin.godot_variant is Access_Instance : Cast.Object_Pointer := Cast.To_Pointer (p_user_data); Time_Elapsed : IC.double := Context.Core_Api.godot_variant_as_real (p_args.all); begin Process (Access_Instance.all, Long_Float (Time_Elapsed)); return Context.Nil_Godot_Variant; exception when Occurrence : others => Exceptions.Put_Error (Occurrence); return Context.Nil_Godot_Variant; end; end; package Obj_Reg is new Object_Registration (New_Node); procedure Register_Class renames Obj_Reg.Register_Class; ---------------------- -- Register Process -- ---------------------- procedure Register_Process is Process_Func : Thin.godot_instance_method := (Wrappers.Process'access, S.Null_Address, null); Process_Attr : Thin.godot_method_attributes := (rpc_type => Thin.GODOT_METHOD_RPC_MODE_DISABLED); Name_Ptr : ICS.chars_ptr := ICS.New_String (Ada.Tags.External_Tag (New_Node'tag)); Process_Ptr : ICS.chars_ptr := ICS.New_String ("_process"); begin pragma Assert (Context.Core_Initialized, "Please run Context.GDNative_Initialize"); pragma Assert (Context.Nativescript_Initialized, "Please run Context.Nativescript_Initialize"); Console.Put ("Registering Method: " & To_Wide (Ada.Tags.External_Tag (New_Node'Tag)) & "._process"); Context.Nativescript_Api.godot_nativescript_register_method ( Context.Nativescript_Ptr, Name_Ptr, Process_Ptr, Process_Attr, Process_Func); ICS.Free (Name_Ptr); ICS.Free (Process_Ptr); exception when Occurrence : others => Exceptions.Put_Error (Occurrence); end; end; end;
---------------------------------------------------------------------------- -- -- Ada client for BaseX -- ---------------------------------------------------------------------------- with Ada.Strings; with Ada.Strings.Fixed; with Ada.Strings.Maps; with Ada.Exceptions; with Ada.Streams; with GNAT.MD5; package body AdaBaseXClient is use Ada.Strings.Unbounded; use Ada.Exceptions; use GNAT.Sockets; -- -- Inserts a document in the database at the specified path -- function Add (Path : String; Input : String) return String is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin SendCmd (9, Path, Input); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with To_String (Response); end if; return To_String (Response); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Add; -- -- Authenticate for this session -- function Authenticate (Username : String; Password : String) return Boolean is Nonce : Ada.Strings.Unbounded.Unbounded_String; Realm : Ada.Strings.Unbounded.Unbounded_String; Output : Ada.Strings.Unbounded.Unbounded_String; Ret : Ada.Strings.Unbounded.Unbounded_String; begin Ret := To_Unbounded_String (ReadString); declare Input : constant String := To_String (Ret); Start : Positive := Input'First; Finish : Natural := 0; begin Ret := To_Unbounded_String (Username); Send (To_String (Ret)); Ada.Strings.Fixed.Find_Token (Input, Ada.Strings.Maps.To_Set (':'), Start, Ada.Strings.Outside, Start, Finish); if Finish = Input'Last then Nonce := To_Unbounded_String (Input (Start .. Input'Last - 1)); Output := To_Unbounded_String (Password); Ret := To_Unbounded_String (GNAT.MD5.Digest (GNAT.MD5.Digest (To_String (Output)) & To_String (Nonce))); else Realm := To_Unbounded_String (Input (Start .. Finish)); Nonce := To_Unbounded_String (Input (Finish + 2 .. Input'Last - 1)); Output := To_Unbounded_String (Username & ":" & To_String (Realm) & ":" & Password); Ret := To_Unbounded_String (GNAT.MD5.Digest (GNAT.MD5.Digest (To_String (Output)) & To_String (Nonce))); end if; end; Send (To_String (Ret)); if Status then return True; end if; return False; exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Authenticate; -- -- Bind procedure for Query class -- procedure Bind (Self : Query; Name : String; Value : String; Stype : String) is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin Send (Character'Val (3) & To_String (Self.Id) & Character'Val (0) & Name & Character'Val (0) & Value & Character'Val (0) & Stype); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with "Bind query failed"; end if; exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Bind; -- -- Close a connection to the host -- procedure Close is begin Send ("exit"); Free (Channel); Close_Socket (Socket); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Close; -- -- Close procedure for Query class -- procedure Close (Self : out Query) is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin Send (Character'Val (2) & To_String (Self.Id)); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with "Close query failed"; end if; -- Delete Query Id Delete (Self.Id, 1, Length (Self.Id)); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Close; -- -- Open a connection to the host -- function Connect (Server : String; Port : Natural) return Boolean is Address : GNAT.Sockets.Sock_Addr_Type; begin Address.Addr := GNAT.Sockets.Addresses (GNAT.Sockets.Get_Host_By_Name (Server), 1); Address.Port := Port_Type (Port); GNAT.Sockets.Create_Socket (AdaBaseXClient.Socket); GNAT.Sockets.Connect_Socket (AdaBaseXClient.Socket, Address); AdaBaseXClient.Channel := Stream (AdaBaseXClient.Socket); return True; exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Connect; -- -- Create a new database, inserts initial content -- function Create (Name : String; Input : String) return String is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin SendCmd (8, Name, Input); Response := To_Unbounded_String (ReadString); result_status := Status; if result_status = False then raise BaseXException with To_String (Response); end if; return To_String (Response); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Create; -- -- Create a new Query instance -- function CreateQuery (Qstring : String) return Query is MyQuery : Query; Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin Send (Character'Val (0) & Qstring); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with "Create Query failed"; end if; -- Assign Id to Query class MyQuery.Initialize (To_String (Response)); return MyQuery; exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end CreateQuery; -- -- Execute BaseX command -- function Execute (command : String) return String is Response : Ada.Strings.Unbounded.Unbounded_String; Info : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin Send (command); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); Info := To_Unbounded_String (ReadString); Info := To_Unbounded_String (Slice (Info, 1, Length (Info) - 1)); result_status := Status; if result_status = False then raise BaseXException with To_String (Info); end if; return To_String (Response); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Execute; -- -- Execute function for Query class -- function Execute (Self : Query) return String is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin Send (Character'Val (5) & To_String (Self.Id)); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with "Execute query failed"; end if; return (To_String (Response)); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Execute; -- -- Return process information -- function Info return String is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin Send ("INFO"); Response := To_Unbounded_String (ReadString); result_status := Status; if result_status = False then raise BaseXException with "Return process information failed"; end if; return To_String (Response); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Info; -- -- Initialize procedure for Query class -- procedure Initialize (Self : out Query; MyId : String) is begin Self.Id := To_Unbounded_String (MyId); end Initialize; -- -- Read data from server -- function Read return String is Data : Ada.Streams.Stream_Element_Array (1 .. 1_024); Size : Ada.Streams.Stream_Element_Offset; Res : Ada.Strings.Unbounded.Unbounded_String; begin GNAT.Sockets.Receive_Socket (Socket, Data, Size); for i in 1 .. Size loop Res := Res & Character'Val (Data (i)); end loop; return To_String (Res); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); end Read; -- -- Read string from server -- function ReadString return String is Data : Ada.Streams.Stream_Element_Array (1 .. 1); Size : Ada.Streams.Stream_Element_Offset; Res : Ada.Strings.Unbounded.Unbounded_String; Chr : Character; begin loop GNAT.Sockets.Receive_Socket (Socket, Data, Size); Res := Res & Character'Val (Data (1)); Chr := Character'Val (Data (1)); if Chr = Character'Val (0) then exit; end if; end loop; return To_String (Res); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); end ReadString; -- -- Replaces content at the specified path by the given document -- function Replace (Path : String; Input : String) return String is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin SendCmd (12, Path, Input); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with To_String (Response); end if; return To_String (Response); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Replace; -- -- Results function for Query class -- Returns all resulting items as strings -- function Results (Self : Query) return String_Vectors.Vector is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; VString : String_Vectors.Vector; begin Send (Character'Val (4) & To_String (Self.Id)); while Status = False loop Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); VString.Append (To_String (Response)); end loop; result_status := Status; if result_status = False then Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); raise BaseXException with To_String (Response); end if; return VString; exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Results; -- -- Send data to server -- procedure Send (Command : String) is begin String'Write (AdaBaseXClient.Channel, Command & Character'Val (0)); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); end Send; -- -- Send Command to server -- procedure SendCmd (Code : Natural; Arg : String; Input : String) is begin String'Write (AdaBaseXClient.Channel, Character'Val (Code) & Arg & Character'Val (0) & Input & Character'Val (0)); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); end SendCmd; -- -- Read status single byte from socket. -- Server replies with \00 (success) or \01 (error). -- function Status return Boolean is Data : Ada.Streams.Stream_Element_Array (1 .. 1); Size : Ada.Streams.Stream_Element_Offset; Res : Ada.Strings.Unbounded.Unbounded_String; begin GNAT.Sockets.Receive_Socket (Socket, Data, Size); Res := Res & Character'Val (Data (1)); if Element (Res, 1) = Character'Val (0) then return True; end if; return False; exception when E : Socket_Error => raise BaseXException with Exception_Message (E); end Status; -- -- Stores a binary resource in the opened database -- function Store (Path : String; Input : String) return String is Response : Ada.Strings.Unbounded.Unbounded_String; result_status : Boolean := True; begin SendCmd (13, Path, Input); Response := To_Unbounded_String (ReadString); Response := To_Unbounded_String (Slice (Response, 1, Length (Response) - 1)); result_status := Status; if result_status = False then raise BaseXException with To_String (Response); end if; return To_String (Response); exception when E : Socket_Error => raise BaseXException with Exception_Message (E); when E : BaseXException => raise BaseXException with Exception_Message (E); when others => raise BaseXException with "Unexpected exception"; end Store; begin null; end AdaBaseXClient;
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- S Y S T E M . V E R S I O N _ C O N T R O L -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994,1995 NYU, All Rights Reserved -- -- -- -- The GNAT library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU Library General Public License as published by -- -- the Free Software Foundation; either version 2, or (at your option) any -- -- later version. The GNAT library is distributed in the hope that it will -- -- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty -- -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Library General Public License for more details. You should have -- -- received a copy of the GNU Library General Public License along with -- -- the GNAT library; see the file COPYING.LIB. If not, write to the Free -- -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This module contains the runtime routine for implementation of the -- Version and Body_Version attributes, as well as the string type that -- is returned as a result of using these attributes. with System.Unsigned_Types; package System.Version_Control is subtype Version_String is String (1 .. 8); -- Eight character string returned by Get_version_String; function Get_Version_String (V : System.Unsigned_Types.Unsigned) return Version_String; -- The version information in the executable file is stored as unsigned -- integers. This routine converts the unsigned integer into an eight -- character string containing its hexadecimal digits (with lower case -- letters). end System.Version_Control;
-- { dg-do compile } with Ada.Strings.Bounded; package Pack11 is package My_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length (4); subtype My_Bounded_String is My_Strings.Bounded_String; type Rec1 is tagged null record; type Rec2 is record S : My_Bounded_String; end record; pragma Pack (Rec2); type Rec3 is new Rec1 with record R : Rec2; end record; end Pack11;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of 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_tim.c -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief timers HAL module driver. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ with STM32.Device; package body STM32.Timers is --------------- -- Configure -- --------------- procedure Configure (This : in out Timer; Prescaler : UInt16; Period : UInt32) is begin This.ARR := Period; This.Prescaler := Prescaler; end Configure; --------------- -- Configure -- --------------- procedure Configure (This : in out Timer; Prescaler : UInt16; Period : UInt32; Clock_Divisor : Timer_Clock_Divisor; Counter_Mode : Timer_Counter_Alignment_Mode) is begin This.ARR := Period; This.Prescaler := Prescaler; This.CR1.Clock_Division := Clock_Divisor; This.CR1.Mode_And_Dir := Counter_Mode; end Configure; ---------------------- -- Set_Counter_Mode -- ---------------------- procedure Set_Counter_Mode (This : in out Timer; Value : Timer_Counter_Alignment_Mode) is begin This.CR1.Mode_And_Dir := Value; end Set_Counter_Mode; ------------------------ -- Set_Clock_Division -- ------------------------ procedure Set_Clock_Division (This : in out Timer; Value : Timer_Clock_Divisor) is begin This.CR1.Clock_Division := Value; end Set_Clock_Division; ---------------------------- -- Current_Clock_Division -- ---------------------------- function Current_Clock_Division (This : Timer) return Timer_Clock_Divisor is begin return This.CR1.Clock_Division; end Current_Clock_Division; --------------- -- Configure -- --------------- procedure Configure (This : in out Timer; Prescaler : UInt16; Period : UInt32; Clock_Divisor : Timer_Clock_Divisor; Counter_Mode : Timer_Counter_Alignment_Mode; Repetitions : UInt8) is begin This.ARR := Period; This.Prescaler := Prescaler; This.CR1.Clock_Division := Clock_Divisor; This.CR1.Mode_And_Dir := Counter_Mode; This.RCR := UInt32 (Repetitions); This.EGR := Immediate'Enum_Rep; end Configure; ------------ -- Enable -- ------------ procedure Enable (This : in out Timer) is begin This.CR1.Timer_Enabled := True; end Enable; ------------- -- Enabled -- ------------- function Enabled (This : Timer) return Boolean is begin return This.CR1.Timer_Enabled; end Enabled; ------------------------ -- No_Outputs_Enabled -- ------------------------ function No_Outputs_Enabled (This : Timer) return Boolean is begin for C in Channel_1 .. Channel_3 loop if This.CCER (C).CCxE = Enable or This.CCER (C).CCxNE = Enable then return False; end if; end loop; -- Channel_4 doesn't have the complementary enabler and polarity bits. -- If it did they would be in the reserved area, which is zero, so we -- could be tricky and pretend that they exist for this function but -- doing that would be unnecessarily subtle. The money is on clarity. if This.CCER (Channel_4).CCxE = Enable then return False; end if; return True; end No_Outputs_Enabled; ------------- -- Disable -- ------------- procedure Disable (This : in out Timer) is begin if No_Outputs_Enabled (This) then This.CR1.Timer_Enabled := False; end if; end Disable; ------------------------ -- Enable_Main_Output -- ------------------------ procedure Enable_Main_Output (This : in out Timer) is begin This.BDTR.Main_Output_Enabled := True; end Enable_Main_Output; ------------------------- -- Disable_Main_Output -- ------------------------- procedure Disable_Main_Output (This : in out Timer) is begin if No_Outputs_Enabled (This) then This.BDTR.Main_Output_Enabled := False; end if; end Disable_Main_Output; ------------------------- -- Main_Output_Enabled -- ------------------------- function Main_Output_Enabled (This : Timer) return Boolean is begin return This.BDTR.Main_Output_Enabled; end Main_Output_Enabled; ----------------- -- Set_Counter -- ----------------- procedure Set_Counter (This : in out Timer; Value : UInt16) is begin This.Counter := UInt32 (Value); end Set_Counter; ----------------- -- Set_Counter -- ----------------- procedure Set_Counter (This : in out Timer; Value : UInt32) is begin This.Counter := Value; end Set_Counter; --------------------- -- Current_Counter -- --------------------- function Current_Counter (This : Timer) return UInt32 is begin return This.Counter; end Current_Counter; ---------------------------- -- Set_Repetition_Counter -- ---------------------------- procedure Set_Repetition_Counter (This : in out Timer; Value : UInt32) is begin This.RCR := Value; end Set_Repetition_Counter; -------------------------------- -- Current_Repetition_Counter -- -------------------------------- function Current_Repetition_Counter (This : Timer) return UInt32 is begin return This.RCR; end Current_Repetition_Counter; -------------------- -- Set_Autoreload -- -------------------- procedure Set_Autoreload (This : in out Timer; Value : UInt32) is begin This.ARR := Value; end Set_Autoreload; ------------------------ -- Current_Autoreload -- ------------------------ function Current_Autoreload (This : Timer) return UInt32 is begin return This.ARR; end Current_Autoreload; ---------------------- -- Enable_Interrupt -- ---------------------- procedure Enable_Interrupt (This : in out Timer; Source : Timer_Interrupt) is begin This.DIER := This.DIER or Source'Enum_Rep; end Enable_Interrupt; ---------------------- -- Enable_Interrupt -- ---------------------- procedure Enable_Interrupt (This : in out Timer; Sources : Timer_Interrupt_List) is begin for Source of Sources loop This.DIER := This.DIER or Source'Enum_Rep; end loop; end Enable_Interrupt; ----------------------- -- Disable_Interrupt -- ----------------------- procedure Disable_Interrupt (This : in out Timer; Source : Timer_Interrupt) is begin This.DIER := This.DIER and not Source'Enum_Rep; end Disable_Interrupt; ----------------------------- -- Clear_Pending_Interrupt -- ----------------------------- procedure Clear_Pending_Interrupt (This : in out Timer; Source : Timer_Interrupt) is begin This.SR := not Source'Enum_Rep; -- We do not, and must not, use the read-modify-write pattern because -- it leaves a window of vulnerability open to changes to the state -- after the read but before the write. The hardware for this register -- is designed so that writing other bits will not change them. This is -- indicated by the "rc_w0" notation in the status register definition. -- See the RM, page 57 for that notation explanation. end Clear_Pending_Interrupt; ----------------------- -- Interrupt_Enabled -- ----------------------- function Interrupt_Enabled (This : Timer; Source : Timer_Interrupt) return Boolean is begin return (This.DIER and Source'Enum_Rep) = Source'Enum_Rep; end Interrupt_Enabled; ------------ -- Status -- ------------ function Status (This : Timer; Flag : Timer_Status_Flag) return Boolean is begin return (This.SR and Flag'Enum_Rep) = Flag'Enum_Rep; end Status; ------------------ -- Clear_Status -- ------------------ procedure Clear_Status (This : in out Timer; Flag : Timer_Status_Flag) is begin This.SR := not Flag'Enum_Rep; -- We do not, and must not, use the read-modify-write pattern because -- it leaves a window of vulnerability open to changes to the state -- after the read but before the write. The hardware for this register -- is designed so that writing other bits will not change them. This is -- indicated by the "rc_w0" notation in the status register definition. -- See the RM, page 57 for that notation explanation. end Clear_Status; ----------------------- -- Enable_DMA_Source -- ----------------------- procedure Enable_DMA_Source (This : in out Timer; Source : Timer_DMA_Source) is begin This.DIER := This.DIER or Source'Enum_Rep; end Enable_DMA_Source; ------------------------ -- Disable_DMA_Source -- ------------------------ procedure Disable_DMA_Source (This : in out Timer; Source : Timer_DMA_Source) is begin This.DIER := This.DIER and not Source'Enum_Rep; end Disable_DMA_Source; ------------------------ -- DMA_Source_Enabled -- ------------------------ function DMA_Source_Enabled (This : Timer; Source : Timer_DMA_Source) return Boolean is begin return (This.DIER and Source'Enum_Rep) = Source'Enum_Rep; end DMA_Source_Enabled; ------------------------- -- Configure_Prescaler -- ------------------------- procedure Configure_Prescaler (This : in out Timer; Prescaler : UInt16; Reload_Mode : Timer_Prescaler_Reload_Mode) is begin This.Prescaler := Prescaler; This.EGR := Reload_Mode'Enum_Rep; end Configure_Prescaler; ------------------- -- Configure_DMA -- ------------------- procedure Configure_DMA (This : in out Timer; Base_Address : Timer_DMA_Base_Address; Burst_Length : Timer_DMA_Burst_Length) is begin This.DCR.Base_Address := Base_Address; This.DCR.Burst_Length := Burst_Length; end Configure_DMA; -------------------------------- -- Enable_Capture_Compare_DMA -- -------------------------------- procedure Enable_Capture_Compare_DMA (This : in out Timer) -- TODO: note that the CCDS field description in the RM, page 550, seems -- to indicate other than simply enabled/disabled is begin This.CR2.Capture_Compare_DMA_Selection := True; end Enable_Capture_Compare_DMA; --------------------------------- -- Disable_Capture_Compare_DMA -- --------------------------------- procedure Disable_Capture_Compare_DMA (This : in out Timer) -- TODO: note that the CCDS field description in the RM, page 550, seems -- to indicate other than simply enabled/disabled is begin This.CR2.Capture_Compare_DMA_Selection := False; end Disable_Capture_Compare_DMA; ----------------------- -- Current_Prescaler -- ----------------------- function Current_Prescaler (This : Timer) return UInt16 is begin return This.Prescaler; end Current_Prescaler; ----------------------- -- Set_UpdateDisable -- ----------------------- procedure Set_UpdateDisable (This : in out Timer; To : Boolean) is begin This.CR1.Update_Disable := To; end Set_UpdateDisable; ----------------------- -- Set_UpdateRequest -- ----------------------- procedure Set_UpdateRequest (This : in out Timer; Source : Timer_Update_Source) is begin This.CR1.Update_Request_Source := Source /= Global; end Set_UpdateRequest; ---------------------------- -- Set_Autoreload_Preload -- ---------------------------- procedure Set_Autoreload_Preload (This : in out Timer; To : Boolean) is begin This.CR1.ARPE := To; end Set_Autoreload_Preload; --------------------------- -- Select_One_Pulse_Mode -- --------------------------- procedure Select_One_Pulse_Mode (This : in out Timer; Mode : Timer_One_Pulse_Mode) is begin This.CR1.One_Pulse_Mode := Mode; end Select_One_Pulse_Mode; ---------------------------------- -- Compute_Prescaler_and_Period -- ---------------------------------- procedure Compute_Prescaler_And_Period (This : access Timer; Requested_Frequency : UInt32; Prescaler : out UInt32; Period : out UInt32) is Max_Prescaler : constant := 16#FFFF#; Max_Period : UInt32; Hardware_Frequency : UInt32; CK_CNT : UInt32; begin Hardware_Frequency := STM32.Device.Get_Clock_Frequency (This.all); if Has_32bit_Counter (This.all) then Max_Period := 16#FFFF_FFFF#; else Max_Period := 16#FFFF#; end if; if Requested_Frequency > Hardware_Frequency then raise Invalid_Request with "Frequency too high"; end if; Prescaler := 0; -- Corresponds to value 1 loop -- Compute the Counter's clock CK_CNT := Hardware_Frequency / (Prescaler + 1); -- Determine the CK_CNT periods to achieve the requested frequency Period := CK_CNT / Requested_Frequency; exit when ((Period <= Max_Period) or (Prescaler > Max_Prescaler)); Prescaler := Prescaler + 1; end loop; if Prescaler > Max_Prescaler then raise Invalid_Request with "Frequency too low"; end if; end Compute_Prescaler_And_Period; ----------------------- -- Counter_Direction -- ----------------------- function Current_Counter_Mode (This : Timer) return Timer_Counter_Alignment_Mode is begin if Basic_Timer (This) then return Up; else return This.CR1.Mode_And_Dir; end if; end Current_Counter_Mode; -------------------- -- Generate_Event -- -------------------- procedure Generate_Event (This : in out Timer; Source : Timer_Event_Source) is Temp_EGR : UInt32 := This.EGR; begin Temp_EGR := Temp_EGR or Source'Enum_Rep; This.EGR := Temp_EGR; end Generate_Event; --------------------------- -- Select_Output_Trigger -- --------------------------- procedure Select_Output_Trigger (This : in out Timer; Source : Timer_Trigger_Output_Source) is begin This.CR2.Master_Mode_Selection := Source; end Select_Output_Trigger; ----------------------- -- Select_Slave_Mode -- ----------------------- procedure Select_Slave_Mode (This : in out Timer; Mode : Timer_Slave_Mode) is begin case Mode is when Disabled .. External_1 => This.SMCR.Slave_Mode_Selection_2 := False; This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep); when Combined_Reset_Trigger .. Quadrature_Encoder_Mode_5 => This.SMCR.Slave_Mode_Selection_2 := True; This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep); end case; end Select_Slave_Mode; ------------------------------ -- Enable_Master_Slave_Mode -- ------------------------------ procedure Enable_Master_Slave_Mode (This : in out Timer) is begin This.SMCR.Master_Slave_Mode := True; end Enable_Master_Slave_Mode; ------------------------------- -- Disable_Master_Slave_Mode -- ------------------------------- procedure Disable_Master_Slave_Mode (This : in out Timer) is begin This.SMCR.Master_Slave_Mode := False; end Disable_Master_Slave_Mode; -------------------------------- -- Configure_External_Trigger -- -------------------------------- procedure Configure_External_Trigger (This : in out Timer; Polarity : Timer_External_Trigger_Polarity; Prescaler : Timer_External_Trigger_Prescaler; Filter : Timer_External_Trigger_Filter) is begin This.SMCR.External_Trigger_Polarity := Polarity; This.SMCR.External_Trigger_Prescaler := Prescaler; This.SMCR.External_Trigger_Filter := Filter; end Configure_External_Trigger; --------------------------------- -- Configure_As_External_Clock -- --------------------------------- procedure Configure_As_External_Clock (This : in out Timer; Source : Timer_Internal_Trigger_Source) is begin Select_Input_Trigger (This, Source); Select_Slave_Mode (This, External_1); end Configure_As_External_Clock; --------------------------------- -- Configure_As_External_Clock -- --------------------------------- procedure Configure_As_External_Clock (This : in out Timer; Source : Timer_External_Clock_Source; Polarity : Timer_Input_Capture_Polarity; Filter : Timer_Input_Capture_Filter) is begin if Source = Filtered_Timer_Input_2 then Configure_Channel_Input (This, Channel_2, Polarity, Direct_TI, Div1, -- default prescalar zero value Filter); else Configure_Channel_Input (This, Channel_1, Polarity, Direct_TI, Div1, -- default prescalar zero value Filter); end if; Select_Input_Trigger (This, Source); Select_Slave_Mode (This, External_1); end Configure_As_External_Clock; ------------------------------------ -- Configure_External_Clock_Mode1 -- ------------------------------------ procedure Configure_External_Clock_Mode1 (This : in out Timer; Polarity : Timer_External_Trigger_Polarity; Prescaler : Timer_External_Trigger_Prescaler; Filter : Timer_External_Trigger_Filter) is begin Configure_External_Trigger (This, Polarity, Prescaler, Filter); Select_Slave_Mode (This, External_1); Select_Input_Trigger (This, External_Trigger_Input); end Configure_External_Clock_Mode1; ------------------------------------ -- Configure_External_Clock_Mode2 -- ------------------------------------ procedure Configure_External_Clock_Mode2 (This : in out Timer; Polarity : Timer_External_Trigger_Polarity; Prescaler : Timer_External_Trigger_Prescaler; Filter : Timer_External_Trigger_Filter) is begin Configure_External_Trigger (This, Polarity, Prescaler, Filter); This.SMCR.External_Clock_Enable := True; end Configure_External_Clock_Mode2; -------------------------- -- Select_Input_Trigger -- -------------------------- procedure Select_Input_Trigger (This : in out Timer; Source : Timer_Trigger_Input_Source) is begin This.SMCR.Trigger_Selection := UInt3 (Source'Enum_Rep); This.SMCR.Trigger_Selection_1 := UInt2 (Shift_Right (UInt8 (Source'Enum_Rep), 3)); end Select_Input_Trigger; ------------------------------ -- Configure_Channel_Output -- ------------------------------ procedure Configure_Channel_Output (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode; State : Timer_Capture_Compare_State; Pulse : UInt32; Polarity : Timer_Output_Compare_Polarity) is begin -- first disable the channel CC output This.CCER (Channel).CCxE := Disable; Set_Output_Compare_Mode (This, Channel, Mode); This.CCER (Channel).CCxE := State; This.CCER (Channel).CCxP := Polarity'Enum_Rep; case Channel is when Channel_1 .. Channel_4 => This.CCR1_4 (Channel) := Pulse; when Channel_5 => This.CCR5 := Pulse; when Channel_6 => This.CCR6 := Pulse; end case; -- Only timers 2 and 5 have 32-bit CCR registers. The others must -- maintain the upper half at zero. We use a precondition to ensure -- values greater than a half-word are only specified for the proper -- timers. end Configure_Channel_Output; ------------------------------ -- Configure_Channel_Output -- ------------------------------ procedure Configure_Channel_Output (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode; State : Timer_Capture_Compare_State; Pulse : UInt32; Polarity : Timer_Output_Compare_Polarity; Idle_State : Timer_Capture_Compare_State; Complementary_Polarity : Timer_Output_Compare_Polarity; Complementary_Idle_State : Timer_Capture_Compare_State) is begin -- first disable the channel CC output This.CCER (Channel).CCxE := Disable; Set_Output_Compare_Mode (This, Channel, Mode); This.CCER (Channel).CCxE := State; This.CCER (Channel).CCxNP := Complementary_Polarity'Enum_Rep; This.CCER (Channel).CCxP := Polarity'Enum_Rep; case Channel is when Channel_1 => This.CR2.Channel_1_Output_Idle_State := Idle_State; This.CR2.Channel_1_Complementary_Output_Idle_State := Complementary_Idle_State; when Channel_2 => This.CR2.Channel_2_Output_Idle_State := Idle_State; This.CR2.Channel_2_Complementary_Output_Idle_State := Complementary_Idle_State; when Channel_3 => This.CR2.Channel_3_Output_Idle_State := Idle_State; This.CR2.Channel_3_Complementary_Output_Idle_State := Complementary_Idle_State; when Channel_4 => This.CR2.Channel_4_Output_Idle_State := Idle_State; when Channel_5 => This.CR2.Channel_5_Output_Idle_State := Idle_State; when Channel_6 => This.CR2.Channel_6_Output_Idle_State := Idle_State; end case; case Channel is when Channel_1 .. Channel_4 => This.CCR1_4 (Channel) := Pulse; when Channel_5 => This.CCR5 := Pulse; when Channel_6 => This.CCR6 := Pulse; end case; -- Only timers 2 and 5 have 32-bit CCR registers. The others must -- maintain the upper half at zero. We use a precondition to ensure -- values greater than a half-word are only specified for the proper -- timers. end Configure_Channel_Output; ----------------------- -- Set_Single_Output -- ----------------------- procedure Set_Single_Output (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode; OC_Clear_Enabled : Boolean; Preload_Enabled : Boolean; Fast_Enabled : Boolean) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; Mode0_2 : UInt3; Mode_3 : Boolean; Description_1 : Lower_Channel_Output_Descriptor; Description_2 : Higher_Channel_Output_Descriptor; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => Temp := This.CCMR3; end case; Mode0_2 := UInt3 (Mode'Enum_Rep); Mode_3 := Mode'Enum_Rep > 7; Description_1 := (OCxMode => Mode0_2, OCxFast_Enable => Fast_Enabled, OCxPreload_Enable => Preload_Enabled, OCxClear_Enable => OC_Clear_Enabled); Description_2 := (OCxMode_3 => Mode_3); Temp.Low_Descriptors (Descriptor_Index) := (Output, Description_1); Temp.High_Descriptors (Descriptor_Index) := (Output, Description_2); case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => This.CCMR3 := Temp; end case; end Set_Single_Output; ----------------------------- -- Set_Output_Compare_Mode -- ----------------------------- procedure Set_Output_Compare_Mode (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; Mode0_2 : UInt3; Mode_3 : Boolean; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => Temp := This.CCMR3; end case; if Temp.Low_Descriptors (Descriptor_Index).CCxSelection /= Output then raise Timer_Channel_Access_Error; end if; Mode0_2 := UInt3 (Mode'Enum_Rep); Mode_3 := Mode'Enum_Rep > 7; Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxMode := Mode0_2; Temp.High_Descriptors (Descriptor_Index).Compare_2.OCxMode_3 := Mode_3; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => This.CCMR3 := Temp; end case; end Set_Output_Compare_Mode; ---------------------------------- -- Current_Capture_Compare_Mode -- ---------------------------------- function Current_Capture_Compare_Mode (This : Timer; Channel : Timer_Channel) return Timer_Capture_Compare_Modes is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; return Temp.Low_Descriptors (Descriptor_Index).CCxSelection; when 2 => Temp := This.CCMR2; return Temp.Low_Descriptors (Descriptor_Index).CCxSelection; when 3 => Temp := This.CCMR3; return Temp.Low_Descriptors (Descriptor_Index).CCxSelection; end case; end Current_Capture_Compare_Mode; ------------------------------ -- Set_Output_Forced_Action -- ------------------------------ procedure Set_Output_Forced_Action (This : in out Timer; Channel : Timer_Channel; Active : Boolean) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; Mode0_2 : UInt3; Mode_3 : Boolean; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => Temp := This.CCMR3; end case; if Temp.Low_Descriptors (Descriptor_Index).CCxSelection /= Output then raise Timer_Channel_Access_Error; end if; if Active then Mode0_2 := UInt3 (Force_Active'Enum_Rep); Mode_3 := Force_Active'Enum_Rep > 7; Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxMode := Mode0_2; Temp.High_Descriptors (Descriptor_Index).Compare_2.OCxMode_3 := Mode_3; else Mode0_2 := UInt3 (Force_Inactive'Enum_Rep); Mode_3 := Force_Inactive'Enum_Rep > 7; Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxMode := Mode0_2; Temp.High_Descriptors (Descriptor_Index).Compare_2.OCxMode_3 := Mode_3; end if; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => This.CCMR3 := Temp; end case; end Set_Output_Forced_Action; ------------------------------- -- Set_Output_Preload_Enable -- ------------------------------- procedure Set_Output_Preload_Enable (This : in out Timer; Channel : Timer_Channel; Enabled : Boolean) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => Temp := This.CCMR3; end case; Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxPreload_Enable := Enabled; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => This.CCMR3 := Temp; end case; end Set_Output_Preload_Enable; ---------------------------- -- Set_Output_Fast_Enable -- ---------------------------- procedure Set_Output_Fast_Enable (This : in out Timer; Channel : Timer_Channel; Enabled : Boolean) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => Temp := This.CCMR3; end case; Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxFast_Enable := Enabled; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => This.CCMR3 := Temp; end case; end Set_Output_Fast_Enable; ----------------------- -- Set_Clear_Control -- ----------------------- procedure Set_Clear_Control (This : in out Timer; Channel : Timer_Channel; Enabled : Boolean) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when Channel_5 => CCMR_Index := 3; Descriptor_Index := 1; when Channel_6 => CCMR_Index := 3; Descriptor_Index := 2; end case; case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => Temp := This.CCMR3; end case; Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxClear_Enable := Enabled; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => This.CCMR3 := Temp; end case; end Set_Clear_Control; -------------------- -- Enable_Channel -- -------------------- procedure Enable_Channel (This : in out Timer; Channel : Timer_Channel) is Temp_EGR : UInt32 := This.EGR; begin This.CCER (Channel).CCxE := Enable; -- Trigger an event to initialize preload register Temp_EGR := Temp_EGR or (2 ** (Timer_Channel'Pos (Channel) + 1)); This.EGR := Temp_EGR; end Enable_Channel; ------------------------- -- Set_Output_Polarity -- ------------------------- procedure Set_Output_Polarity (This : in out Timer; Channel : Timer_Channel; Polarity : Timer_Output_Compare_Polarity) is begin This.CCER (Channel).CCxP := Polarity'Enum_Rep; end Set_Output_Polarity; --------------------------------------- -- Set_Output_Complementary_Polarity -- --------------------------------------- procedure Set_Output_Complementary_Polarity (This : in out Timer; Channel : Timer_Channel; Polarity : Timer_Output_Compare_Polarity) is begin This.CCER (Channel).CCxNP := Polarity'Enum_Rep; end Set_Output_Complementary_Polarity; --------------------- -- Disable_Channel -- --------------------- procedure Disable_Channel (This : in out Timer; Channel : Timer_Channel) is begin This.CCER (Channel).CCxE := Disable; end Disable_Channel; --------------------- -- Channel_Enabled -- --------------------- function Channel_Enabled (This : Timer; Channel : Timer_Channel) return Boolean is begin return This.CCER (Channel).CCxE = Enable; end Channel_Enabled; ---------------------------------- -- Enable_Complementary_Channel -- ---------------------------------- procedure Enable_Complementary_Channel (This : in out Timer; Channel : Timer_Channel) is begin This.CCER (Channel).CCxNE := Enable; end Enable_Complementary_Channel; ----------------------------------- -- Disable_Complementary_Channel -- ----------------------------------- procedure Disable_Complementary_Channel (This : in out Timer; Channel : Timer_Channel) is begin This.CCER (Channel).CCxNE := Disable; end Disable_Complementary_Channel; ----------------------------------- -- Complementary_Channel_Enabled -- ----------------------------------- function Complementary_Channel_Enabled (This : Timer; Channel : Timer_Channel) return Boolean is begin return This.CCER (Channel).CCxNE = Enable; end Complementary_Channel_Enabled; ----------------------- -- Set_Compare_Value -- ----------------------- procedure Set_Compare_Value (This : in out Timer; Channel : Timer_Channel; Word_Value : UInt32) is begin This.CCR1_4 (Channel) := Word_Value; -- Timers 2 and 5 really do have 32-bit capture/compare registers so we -- don't need to require half-words as inputs. end Set_Compare_Value; ----------------------- -- Set_Compare_Value -- ----------------------- procedure Set_Compare_Value (This : in out Timer; Channel : Timer_Channel; Value : UInt16) is begin This.CCR1_4 (Channel) := UInt32 (Value); -- These capture/compare registers are really only 15-bits wide, except -- for those of timers 2 and 5. For the sake of simplicity we represent -- all of them with full words, but only write word values when -- appropriate. The caller has to treat them as half-word values, since -- that's the type for the formal parameter, therefore our casting up to -- a word value will retain the reserved upper half-word value of zero. end Set_Compare_Value; --------------------------- -- Current_Capture_Value -- --------------------------- function Current_Capture_Value (This : Timer; Channel : Timer_Channel) return UInt32 is begin return This.CCR1_4 (Channel); end Current_Capture_Value; --------------------------- -- Current_Capture_Value -- --------------------------- function Current_Capture_Value (This : Timer; Channel : Timer_Channel) return UInt16 is begin return UInt16 (This.CCR1_4 (Channel)); end Current_Capture_Value; ------------------------------------- -- Write_Channel_Input_Description -- ------------------------------------- procedure Write_Channel_Input_Description (This : in out Timer; Channel : Timer_Channel; Kind : Timer_Input_Capture_Selection; Description : Lower_Channel_Input_Descriptor) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; New_Value : Lower_IO_Descriptor; begin case Kind is when Direct_TI => New_Value := (CCxSelection => Direct_TI, Capture => Description); when Indirect_TI => New_Value := (CCxSelection => Indirect_TI, Capture => Description); when TRC => New_Value := (CCxSelection => TRC, Capture => Description); end case; case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when others => null; end case; case CCMR_Index is -- effectively get CCMR1 or CCMR2 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => null; end case; Temp.Low_Descriptors (Descriptor_Index) := New_Value; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => null; end case; end Write_Channel_Input_Description; ------------------------- -- Set_Input_Prescaler -- ------------------------- procedure Set_Input_Prescaler (This : in out Timer; Channel : Timer_Channel; Value : Timer_Input_Capture_Prescaler) is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when others => null; end case; case CCMR_Index is -- effectively get CCMR1 or CCMR2 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => null; end case; Temp.Low_Descriptors (Descriptor_Index).Capture.ICxPrescaler := Value; case CCMR_Index is when 1 => This.CCMR1 := Temp; when 2 => This.CCMR2 := Temp; when 3 => null; end case; end Set_Input_Prescaler; ----------------------------- -- Current_Input_Prescaler -- ----------------------------- function Current_Input_Prescaler (This : Timer; Channel : Timer_Channel) return Timer_Input_Capture_Prescaler is CCMR_Index : CCMRx_Index; Descriptor_Index : Half_Index; Temp : TIMx_CCMRx; begin case Channel is when Channel_1 => CCMR_Index := 1; Descriptor_Index := 1; when Channel_2 => CCMR_Index := 1; Descriptor_Index := 2; when Channel_3 => CCMR_Index := 2; Descriptor_Index := 1; when Channel_4 => CCMR_Index := 2; Descriptor_Index := 2; when others => null; end case; case CCMR_Index is -- effectively get CCMR1 or CCMR2 when 1 => Temp := This.CCMR1; when 2 => Temp := This.CCMR2; when 3 => null; end case; return Temp.Low_Descriptors (Descriptor_Index).Capture.ICxPrescaler; end Current_Input_Prescaler; ----------------------------- -- Configure_Channel_Input -- ----------------------------- procedure Configure_Channel_Input (This : in out Timer; Channel : Timer_Channel; Polarity : Timer_Input_Capture_Polarity; Selection : Timer_Input_Capture_Selection; Prescaler : Timer_Input_Capture_Prescaler; Filter : Timer_Input_Capture_Filter) is Input : Lower_Channel_Input_Descriptor; begin -- first disable the channel This.CCER (Channel).CCxE := Disable; Input := (ICxFilter => Filter, ICxPrescaler => Prescaler); Write_Channel_Input_Description (This => This, Channel => Channel, Kind => Selection, Description => Input); case Polarity is when Rising => This.CCER (Channel).CCxNP := 0; This.CCER (Channel).CCxP := 0; when Falling => This.CCER (Channel).CCxNP := 0; This.CCER (Channel).CCxP := 1; when Both_Edges => This.CCER (Channel).CCxNP := 1; This.CCER (Channel).CCxP := 1; end case; This.CCER (Channel).CCxE := Enable; end Configure_Channel_Input; --------------------------------- -- Configure_Channel_Input_PWM -- --------------------------------- procedure Configure_Channel_Input_PWM (This : in out Timer; Channel : Timer_Channel; Selection : Timer_Input_Capture_Selection; Polarity : Timer_Input_Capture_Polarity; Prescaler : Timer_Input_Capture_Prescaler; Filter : Timer_Input_Capture_Filter) is Opposite_Polarity : Timer_Input_Capture_Polarity; Opposite_Selection : Timer_Input_Capture_Selection; begin Disable_Channel (This, Channel); if Polarity = Rising then Opposite_Polarity := Falling; else Opposite_Polarity := Rising; end if; if Selection = Indirect_TI then Opposite_Selection := Direct_TI; else Opposite_Selection := Indirect_TI; end if; if Channel = Channel_1 then Configure_Channel_Input (This, Channel_1, Polarity, Selection, Prescaler, Filter); Configure_Channel_Input (This, Channel_2, Opposite_Polarity, Opposite_Selection, Prescaler, Filter); else Configure_Channel_Input (This, Channel_2, Polarity, Selection, Prescaler, Filter); Configure_Channel_Input (This, Channel_1, Opposite_Polarity, Opposite_Selection, Prescaler, Filter); end if; Enable_Channel (This, Channel); end Configure_Channel_Input_PWM; ------------------------------- -- Enable_CC_Preload_Control -- ------------------------------- procedure Enable_CC_Preload_Control (This : in out Timer) is begin This.CR2.Capture_Compare_Preloaded_Control := True; end Enable_CC_Preload_Control; -------------------------------- -- Disable_CC_Preload_Control -- -------------------------------- procedure Disable_CC_Preload_Control (This : in out Timer) is begin This.CR2.Capture_Compare_Preloaded_Control := False; end Disable_CC_Preload_Control; ------------------------ -- Select_Commutation -- ------------------------ procedure Select_Commutation (This : in out Timer) is begin This.CR2.Capture_Compare_Control_Update_Selection := True; end Select_Commutation; -------------------------- -- Deselect_Commutation -- -------------------------- procedure Deselect_Commutation (This : in out Timer) is begin This.CR2.Capture_Compare_Control_Update_Selection := False; end Deselect_Commutation; --------------------- -- Configure_Break -- --------------------- procedure Configure_Break (This : in out Timer; Automatic_Output_Enabled : Boolean; Break_Polarity : Timer_Break_Polarity; Break_Enabled : Boolean; Break_Filter : Timer_Break_Filter; Off_State_Selection_Run_Mode : Bit; Off_State_Selection_Idle_Mode : Bit) is begin This.BDTR.Automatic_Output_Enabled := Automatic_Output_Enabled; This.BDTR.Break_Polarity := Break_Polarity; This.BDTR.Break_Enable := Break_Enabled; This.BDTR.Break_Filter := Break_Filter; This.BDTR.Off_State_Selection_Run_Mode := Off_State_Selection_Run_Mode; This.BDTR.Off_State_Selection_Idle_Mode := Off_State_Selection_Idle_Mode; end Configure_Break; --------------------- -- Configure_Break -- --------------------- procedure Configure_Break (This : in out Timer; Automatic_Output_Enabled : Boolean; Break_Polarity : Timer_Break_Polarity; Break_Enabled : Boolean; Break_Filter : Timer_Break_Filter; Break_2_Polarity : Timer_Break_Polarity; Break_2_Enabled : Boolean; Break_2_Filter : Timer_Break_Filter; Off_State_Selection_Run_Mode : Bit; Off_State_Selection_Idle_Mode : Bit) is begin This.BDTR.Automatic_Output_Enabled := Automatic_Output_Enabled; This.BDTR.Break_Polarity := Break_Polarity; This.BDTR.Break_Enable := Break_Enabled; This.BDTR.Break_2_Filter := Break_2_Filter; This.BDTR.Break_2_Polarity := Break_2_Polarity; This.BDTR.Break_2_Enable := Break_2_Enabled; This.BDTR.Break_Filter := Break_Filter; This.BDTR.Off_State_Selection_Run_Mode := Off_State_Selection_Run_Mode; This.BDTR.Off_State_Selection_Idle_Mode := Off_State_Selection_Idle_Mode; end Configure_Break; ------------------------ -- Configure_Deadtime -- ------------------------ procedure Configure_Deadtime (This : in out Timer; Time : Float) is Timer_Frequency : constant UInt32 := STM32.Device.Get_Clock_Frequency (This); -- The clock frequency of this timer. Clock_Divisor : constant Float := (case Current_Clock_Division (This) is when Div1 => 1.0, when Div2 => 2.0, when Div4 => 4.0); -- The division factor for dead-time of this timer. T_DTS : constant Float := Clock_Divisor / Float (Timer_Frequency); -- Time period for one cycle of the input timer frequency. Deadtime : UInt8 := 0; begin declare Tick_Time : Float; -- Time for one tick of the timer. DT_Max_Factor : constant array (0 .. 3) of Float := (2.0**7 - 1.0, (64.0 + 2.0**6 - 1.0) * 2.0, (32.0 + 2.0**5 - 1.0) * 8.0, (32.0 + 2.0**5 - 1.0) * 16.0); begin for I in DT_Max_Factor'Range loop if Time <= DT_Max_Factor (I) * T_DTS then case I is when 0 => Tick_Time := Time / T_DTS; Deadtime := UInt8 (UInt7 (Tick_Time)); exit; when 1 => Tick_Time := Time / T_DTS / 2.0 - 64.0; Deadtime := 16#80# + UInt8 (UInt6 (Tick_Time)); exit; when 2 => Tick_Time := Time / T_DTS / 8.0 - 32.0; Deadtime := 16#C0# + UInt8 (UInt5 (Tick_Time)); exit; when 3 => Tick_Time := Time / T_DTS / 16.0 - 32.0; Deadtime := 16#E0# + UInt8 (UInt5 (Tick_Time)); exit; end case; end if; end loop; end; This.BDTR.Deadtime_Generator := Deadtime; end Configure_Deadtime; ------------------- -- Set_BDTR_Lock -- ------------------- procedure Set_BDTR_Lock (This : in out Timer; Lock : Timer_Lock_Level) is begin This.BDTR.Lock := Lock; end Set_BDTR_Lock; --------------------------------- -- Configure_Encoder_Interface -- --------------------------------- procedure Configure_Encoder_Interface (This : in out Timer; Mode : Timer_Encoder_Mode; IC1_Polarity : Timer_Input_Capture_Polarity; IC2_Polarity : Timer_Input_Capture_Polarity) is begin case Mode is when Quadrature_Encoder_Mode_1 .. Quadrature_Encoder_Mode_3 => This.SMCR.Slave_Mode_Selection_2 := False; This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep); when Encoder_Mode_1 .. Quadrature_Encoder_Mode_5 => This.SMCR.Slave_Mode_Selection_2 := True; This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep); end case; Write_Channel_Input_Description (This, Channel => Channel_1, Kind => Direct_TI, Description => Lower_Channel_Input_Descriptor'(ICxFilter => No_Filter, ICxPrescaler => Div1)); Write_Channel_Input_Description (This, Channel => Channel_2, Kind => Direct_TI, Description => Lower_Channel_Input_Descriptor'(ICxFilter => No_Filter, ICxPrescaler => Div1)); case IC1_Polarity is when Rising => This.CCER (Channel_1).CCxNP := 0; This.CCER (Channel_1).CCxP := 0; when Falling => This.CCER (Channel_1).CCxNP := 0; This.CCER (Channel_1).CCxP := 1; when Both_Edges => This.CCER (Channel_1).CCxNP := 1; This.CCER (Channel_1).CCxP := 1; end case; case IC2_Polarity is when Rising => This.CCER (Channel_2).CCxNP := 0; This.CCER (Channel_2).CCxP := 0; when Falling => This.CCER (Channel_2).CCxNP := 0; This.CCER (Channel_2).CCxP := 1; when Both_Edges => This.CCER (Channel_2).CCxNP := 1; This.CCER (Channel_2).CCxP := 1; end case; end Configure_Encoder_Interface; ------------------------ -- Enable_Hall_Sensor -- ------------------------ procedure Enable_Hall_Sensor (This : in out Timer) is begin This.CR2.TI1_Selection := True; end Enable_Hall_Sensor; ------------------------- -- Disable_Hall_Sensor -- ------------------------- procedure Disable_Hall_Sensor (This : in out Timer) is begin This.CR2.TI1_Selection := False; end Disable_Hall_Sensor; end STM32.Timers;
-- { dg-do compile } -- { dg-options "-gnata -O2 -fno-inline" } with Ada.Unchecked_Conversion; package body Loop_Optimization2 is function To_Addr_Ptr is new Ada.Unchecked_Conversion (System.Address, Addr_Ptr); function To_Address is new Ada.Unchecked_Conversion (Tag, System.Address); function To_Type_Specific_Data_Ptr is new Ada.Unchecked_Conversion (System.Address, Type_Specific_Data_Ptr); function Interface_Ancestor_Tags (T : Tag) return Tag_Array is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T)); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); Iface_Table : constant Interface_Data_Ptr := TSD.Interfaces_Table; begin if Iface_Table = null then declare Table : Tag_Array (1 .. 0); begin return Table; end; else declare Table : Tag_Array (1 .. Iface_Table.Nb_Ifaces); begin for J in 1 .. Iface_Table.Nb_Ifaces loop Table (J) := Iface_Table.Ifaces_Table (J).Iface_Tag; end loop; return Table; end; end if; end Interface_Ancestor_Tags; end Loop_Optimization2;
------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This file provides definitions for the GPIO ports on the STM32F4 (ARM -- Cortex M4F) microcontrollers from ST Microelectronics. pragma Restrictions (No_Elaboration_Code); package STM32F4.GPIO is type GPIO_Port is limited private; function Current_Input (Port : GPIO_Port) return Half_Word with Inline; -- Returns the value of the Port's input data register function Current_Output (Port : GPIO_Port) return Half_Word with Inline; -- Returns the value of the Port's output data register procedure Write_Output (Port : in out GPIO_Port; Data : Half_Word) with Inline; -- Sets the value of the Port's output data register to Data. All bits -- in the register are affected. type GPIO_Pin is (Pin_0, Pin_1, Pin_2, Pin_3, Pin_4, Pin_5, Pin_6, Pin_7, Pin_8, Pin_9, Pin_10, Pin_11, Pin_12, Pin_13, Pin_14, Pin_15); for GPIO_Pin use (Pin_0 => 16#0001#, Pin_1 => 16#0002#, Pin_2 => 16#0004#, Pin_3 => 16#0008#, Pin_4 => 16#0010#, Pin_5 => 16#0020#, Pin_6 => 16#0040#, Pin_7 => 16#0080#, Pin_8 => 16#0100#, Pin_9 => 16#0200#, Pin_10 => 16#0400#, Pin_11 => 16#0800#, Pin_12 => 16#1000#, Pin_13 => 16#2000#, Pin_14 => 16#4000#, Pin_15 => 16#8000#); for GPIO_Pin'Size use 16; -- for compatibility with hardware registers pragma Compile_Time_Error (not (GPIO_Pin'First = Pin_0 and GPIO_Pin'Last = Pin_15 and Pin_0'Enum_Rep = 2 ** 0 and Pin_1'Enum_Rep = 2 ** 1 and Pin_2'Enum_Rep = 2 ** 2 and Pin_3'Enum_Rep = 2 ** 3 and Pin_4'Enum_Rep = 2 ** 4 and Pin_5'Enum_Rep = 2 ** 5 and Pin_6'Enum_Rep = 2 ** 6 and Pin_7'Enum_Rep = 2 ** 7 and Pin_8'Enum_Rep = 2 ** 8 and Pin_9'Enum_Rep = 2 ** 9 and Pin_10'Enum_Rep = 2 ** 10 and Pin_11'Enum_Rep = 2 ** 11 and Pin_12'Enum_Rep = 2 ** 12 and Pin_13'Enum_Rep = 2 ** 13 and Pin_14'Enum_Rep = 2 ** 14 and Pin_15'Enum_Rep = 2 ** 15), "Invalid representation for type GPIO_Pin"); type GPIO_Pins is array (Positive range <>) of GPIO_Pin; -- Note that, in addition to aggregates, the language-defined catenation -- operator "&" is available for types GPIO_Pin and GPIO_Pins, allowing one -- to construct GPIO_Pins values conveniently All_Pins : constant GPIO_Pins := (Pin_0, Pin_1, Pin_2, Pin_3, Pin_4, Pin_5, Pin_6, Pin_7, Pin_8, Pin_9, Pin_10, Pin_11, Pin_12, Pin_13, Pin_14, Pin_15); function Is_Any_Set (Port : GPIO_Port; Pins : GPIO_Pins) return Boolean with Inline; -- Returns True if any one of the bits specified by Pins is set (not zero) -- in the Port input data register; returns False otherwise. function Is_Set (Port : GPIO_Port; Pins : GPIO_Pins) return Boolean renames Is_Any_Set; -- for the sake of readability when only one pin is specified in GPIO_Pins function Is_Set (Port : GPIO_Port; Pin : GPIO_Pin) return Boolean with Inline; function All_Set (Port : GPIO_Port; Pins : GPIO_Pins) return Boolean with Inline; -- Returns True iff all of the bits specified by Pins are set (not zero) in -- the Port input data register; returns False otherwise. procedure Set (Port : in out GPIO_Port; Pin : GPIO_Pin) with Inline, Post => Is_Set (Port, Pin); -- For the given GPIO port, sets the pins specified by Pin to -- one. Other pins are unaffected. procedure Set (Port : in out GPIO_Port; Pins : GPIO_Pins) with Inline, Post => All_Set (Port, Pins); -- For the given GPIO port, sets of all of the pins specified by Pins to -- one. Other pins are unaffected. procedure Clear (Port : in out GPIO_Port; Pin : GPIO_Pin) with Inline, Post => not Is_Set (Port, Pin); -- For the given GPIO port, sets the pin specified by Pin to -- zero. Other pins are unaffected. procedure Clear (Port : in out GPIO_Port; Pins : GPIO_Pins) with Inline, Post => not All_Set (Port, Pins); -- For the given GPIO port, sets of all of the pins specified by Pins to -- zero. Other pins are unaffected. procedure Toggle (Port : in out GPIO_Port; Pin : GPIO_Pin) with Inline, Post => (if Is_Set (Port, Pin)'Old then not Is_Set (Port, Pin) else Is_Set (Port, Pin)); -- For the given GPIO port, negates the pin specified by Pin (ones -- become zeros and vice versa). Other pins are unaffected. procedure Toggle (Port : in out GPIO_Port; Pins : GPIO_Pins) with Inline; -- For the given GPIO port, negates all of the pins specified by Pins (ones -- become zeros and vice versa). Other pins are unaffected. procedure Lock (Port : in out GPIO_Port; Pin : GPIO_Pin) with Pre => not Locked (Port, Pin), Post => Locked (Port, Pin); -- Lock configuration of the given port until the MCU is reset function Locked (Port : GPIO_Port; Pin : GPIO_Pin) return Boolean with Inline; procedure Lock (Port : in out GPIO_Port; Pins : GPIO_Pins) with Pre => (for all Pin of Pins => (not Locked (Port, Pin))), Post => (for all Pin of Pins => (Locked (Port, Pin))); -- Lock configuration of the specified pins on the given port until the MCU -- is reset type Pin_IO_Modes is (Mode_In, Mode_Out, Mode_AF, Mode_Analog); for Pin_IO_Modes use (Mode_In => 0, Mode_Out => 1, Mode_AF => 2, Mode_Analog => 3); for Pin_IO_Modes'Size use 2; type Pin_Output_Types is (Push_Pull, Open_Drain); for Pin_Output_Types use (Push_Pull => 0, Open_Drain => 1); for Pin_Output_Types'Size use 1; type Pin_Output_Speeds is (Speed_2MHz, Speed_25MHz, Speed_50MHz, Speed_100MHz); for Pin_Output_Speeds use (Speed_2MHz => 0, Speed_25MHz => 1, Speed_50MHz => 2, Speed_100MHz => 3); for Pin_Output_Speeds'Size use 2; type Internal_Pin_Resistors is (Floating, Pull_Up, Pull_Down); for Internal_Pin_Resistors use (Floating => 0, Pull_Up => 1, Pull_Down => 2); for Internal_Pin_Resistors'Size use 2; type GPIO_Port_Configuration is record Mode : Pin_IO_Modes; Output_Type : Pin_Output_Types; Speed : Pin_Output_Speeds; Resistors : Internal_Pin_Resistors; Locked : Boolean := False; end record; procedure Configure_IO (Port : in out GPIO_Port; Pin : GPIO_Pin; Config : GPIO_Port_Configuration); -- For Pin on the specified Port, configures the -- characteristics specified by Config procedure Configure_IO (Port : in out GPIO_Port; Pins : GPIO_Pins; Config : GPIO_Port_Configuration); -- For each pin of Pins on the specified Port, configures the -- characteristics specified by Config type External_Triggers is (Interrupt_Rising_Edge, Interrupt_Falling_Edge, Interrupt_Rising_Falling_Edge, Event_Rising_Edge, Event_Falling_Edge, Event_Rising_Falling_Edge); subtype Interrupt_Triggers is External_Triggers range Interrupt_Rising_Edge .. Interrupt_Rising_Falling_Edge; subtype Event_Triggers is External_Triggers range Event_Rising_Edge .. Event_Rising_Falling_Edge; procedure Configure_Trigger (Port : in out GPIO_Port; Pin : GPIO_Pin; Trigger : External_Triggers); -- For Pin on the specified Port, configures the -- characteristics specified by Trigger procedure Configure_Trigger (Port : in out GPIO_Port; Pins : GPIO_Pins; Trigger : External_Triggers); -- For each pin of Pins on the specified Port, configures the -- characteristics specified by Trigger type GPIO_Alternate_Function is private; procedure Configure_Alternate_Function (Port : in out GPIO_Port; Pin : GPIO_Pin; AF : GPIO_Alternate_Function); -- For Pin on the specified Port, sets the alternate function -- specified by AF procedure Configure_Alternate_Function (Port : in out GPIO_Port; Pins : GPIO_Pins; AF : GPIO_Alternate_Function); -- For each pin of Pins on the specified Port, sets the alternate function -- specified by AF GPIO_AF_RTC_50Hz : constant GPIO_Alternate_Function; GPIO_AF_MCO : constant GPIO_Alternate_Function; GPIO_AF_TAMPER : constant GPIO_Alternate_Function; GPIO_AF_SWJ : constant GPIO_Alternate_Function; GPIO_AF_TRACE : constant GPIO_Alternate_Function; GPIO_AF_TIM1 : constant GPIO_Alternate_Function; GPIO_AF_TIM2 : constant GPIO_Alternate_Function; GPIO_AF_TIM3 : constant GPIO_Alternate_Function; GPIO_AF_TIM4 : constant GPIO_Alternate_Function; GPIO_AF_TIM5 : constant GPIO_Alternate_Function; GPIO_AF_TIM8 : constant GPIO_Alternate_Function; GPIO_AF_TIM9 : constant GPIO_Alternate_Function; GPIO_AF_TIM10 : constant GPIO_Alternate_Function; GPIO_AF_TIM11 : constant GPIO_Alternate_Function; GPIO_AF_I2C1 : constant GPIO_Alternate_Function; GPIO_AF_I2C2 : constant GPIO_Alternate_Function; GPIO_AF_I2C3 : constant GPIO_Alternate_Function; GPIO_AF_SPI1 : constant GPIO_Alternate_Function; GPIO_AF_SPI2 : constant GPIO_Alternate_Function; GPIO_AF5_I2S3ext : constant GPIO_Alternate_Function; GPIO_AF_SPI5 : constant GPIO_Alternate_Function; GPIO_AF_SPI3 : constant GPIO_Alternate_Function; GPIO_AF_I2S2ext : constant GPIO_Alternate_Function; GPIO_AF_USART1 : constant GPIO_Alternate_Function; GPIO_AF_USART2 : constant GPIO_Alternate_Function; GPIO_AF_USART3 : constant GPIO_Alternate_Function; GPIO_AF7_I2S3ext : constant GPIO_Alternate_Function; GPIO_AF_USART4 : constant GPIO_Alternate_Function; GPIO_AF_USART5 : constant GPIO_Alternate_Function; GPIO_AF_USART6 : constant GPIO_Alternate_Function; GPIO_AF_CAN1 : constant GPIO_Alternate_Function; GPIO_AF_CAN2 : constant GPIO_Alternate_Function; GPIO_AF_TIM12 : constant GPIO_Alternate_Function; GPIO_AF_TIM13 : constant GPIO_Alternate_Function; GPIO_AF_TIM14 : constant GPIO_Alternate_Function; GPIO_AF_LTDC_2 : constant GPIO_Alternate_Function; GPIO_AF_OTG_FS : constant GPIO_Alternate_Function; GPIO_AF_OTG_HS : constant GPIO_Alternate_Function; GPIO_AF_ETH : constant GPIO_Alternate_Function; GPIO_AF_FSMC : constant GPIO_Alternate_Function; GPIO_AF_OTG_HS_FS : constant GPIO_Alternate_Function; GPIO_AF_SDIO : constant GPIO_Alternate_Function; GPIO_AF_FMC : constant GPIO_Alternate_Function; GPIO_AF_DCMI : constant GPIO_Alternate_Function; GPIO_AF_LTDC : constant GPIO_Alternate_Function; GPIO_AF_EVENTOUT : constant GPIO_Alternate_Function; private type Reserved_246X32 is array (1 .. 246) of Word with Component_Size => 32, Size => 246*32; type Bits_16x4 is array (0 .. 15) of Bits_4 with Component_Size => 4, Size => 64; type Pin_Modes_Register is array (0 .. 15) of Pin_IO_Modes; for Pin_Modes_Register'Component_Size use Pin_IO_Modes'Size; type Output_Types_Register is array (0 .. 31) of Pin_Output_Types; for Output_Types_Register'Component_Size use Pin_Output_Types'Size; type Output_Speeds_Register is array (0 .. 15) of Pin_Output_Speeds; for Output_Speeds_Register'Component_Size use Pin_Output_Speeds'Size; type Resistors_Register is array (0 .. 15) of Internal_Pin_Resistors; for Resistors_Register'Component_Size use Internal_Pin_Resistors'Size; type GPIO_Port is limited record MODER : Pin_Modes_Register; OTYPER : Output_Types_Register; OSPEEDR : Output_Speeds_Register; PUPDR : Resistors_Register; IDR : Half_Word; -- input data register Reserved_1 : Half_Word; ODR : Half_Word; -- output data register Reserved_2 : Half_Word; BSRR_Set : Half_Word; -- bit set register BSRR_Reset : Half_Word; -- bit reset register LCKR : Word; pragma Atomic (LCKR); -- configuration lock register AFR : Bits_16x4; -- alternate function registers Reserved_4 : Reserved_246x32; end record with Volatile, Size => 16#400# * 8; for GPIO_Port use record MODER at 0 range 0 .. 31; OTYPER at 4 range 0 .. 31; OSPEEDR at 8 range 0 .. 31; PUPDR at 12 range 0 .. 31; IDR at 16 range 0 .. 15; Reserved_1 at 18 range 0 .. 15; ODR at 20 range 0 .. 15; Reserved_2 at 22 range 0 .. 15; BSRR_Set at 24 range 0 .. 15; BSRR_Reset at 26 range 0 .. 15; LCKR at 28 range 0 .. 31; AFR at 32 range 0 .. 63; Reserved_4 at 40 range 0 .. 7871; end record; LCCK : constant Word := 16#0001_0000#; -- As per the Reference Manual (RM0090; Doc ID 018909 Rev 6) pg 282, -- this is the "Lock Key" used to control the locking of port/pin -- configurations. It is bit 16 in the lock register (LCKR) of any -- given port, thus the first bit of the upper 16 bits of the word. type GPIO_Alternate_Function is new Bits_4; -- We cannot use an enumeration type because there are duplicate binary -- values GPIO_AF_RTC_50Hz : constant GPIO_Alternate_Function := 0; GPIO_AF_MCO : constant GPIO_Alternate_Function := 0; GPIO_AF_TAMPER : constant GPIO_Alternate_Function := 0; GPIO_AF_SWJ : constant GPIO_Alternate_Function := 0; GPIO_AF_TRACE : constant GPIO_Alternate_Function := 0; GPIO_AF_TIM1 : constant GPIO_Alternate_Function := 1; GPIO_AF_TIM2 : constant GPIO_Alternate_Function := 1; GPIO_AF_TIM3 : constant GPIO_Alternate_Function := 2; GPIO_AF_TIM4 : constant GPIO_Alternate_Function := 2; GPIO_AF_TIM5 : constant GPIO_Alternate_Function := 2; GPIO_AF_TIM8 : constant GPIO_Alternate_Function := 3; GPIO_AF_TIM9 : constant GPIO_Alternate_Function := 3; GPIO_AF_TIM10 : constant GPIO_Alternate_Function := 3; GPIO_AF_TIM11 : constant GPIO_Alternate_Function := 3; GPIO_AF_I2C1 : constant GPIO_Alternate_Function := 4; GPIO_AF_I2C2 : constant GPIO_Alternate_Function := 4; GPIO_AF_I2C3 : constant GPIO_Alternate_Function := 4; GPIO_AF_SPI1 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI2 : constant GPIO_Alternate_Function := 5; GPIO_AF5_I2S3ext : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI5 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI3 : constant GPIO_Alternate_Function := 6; GPIO_AF_I2S2ext : constant GPIO_Alternate_Function := 6; GPIO_AF_USART1 : constant GPIO_Alternate_Function := 7; GPIO_AF_USART2 : constant GPIO_Alternate_Function := 7; GPIO_AF_USART3 : constant GPIO_Alternate_Function := 7; GPIO_AF7_I2S3ext : constant GPIO_Alternate_Function := 7; GPIO_AF_USART4 : constant GPIO_Alternate_Function := 8; GPIO_AF_USART5 : constant GPIO_Alternate_Function := 8; GPIO_AF_USART6 : constant GPIO_Alternate_Function := 8; GPIO_AF_CAN1 : constant GPIO_Alternate_Function := 9; GPIO_AF_CAN2 : constant GPIO_Alternate_Function := 9; GPIO_AF_TIM12 : constant GPIO_Alternate_Function := 9; GPIO_AF_TIM13 : constant GPIO_Alternate_Function := 9; GPIO_AF_TIM14 : constant GPIO_Alternate_Function := 9; GPIO_AF_LTDC_2 : constant GPIO_Alternate_Function := 9; GPIO_AF_OTG_FS : constant GPIO_Alternate_Function := 10; GPIO_AF_OTG_HS : constant GPIO_Alternate_Function := 10; GPIO_AF_ETH : constant GPIO_Alternate_Function := 11; GPIO_AF_FSMC : constant GPIO_Alternate_Function := 12; GPIO_AF_OTG_HS_FS : constant GPIO_Alternate_Function := 12; GPIO_AF_SDIO : constant GPIO_Alternate_Function := 12; GPIO_AF_FMC : constant GPIO_Alternate_Function := 12; GPIO_AF_DCMI : constant GPIO_Alternate_Function := 13; GPIO_AF_LTDC : constant GPIO_Alternate_Function := 14; GPIO_AF_EVENTOUT : constant GPIO_Alternate_Function := 15; end STM32F4.GPIO;
-- AOC 2020, Day 6 package Day is function anyone_sum(filename : in String) return Natural; function everyone_sum(filename : in String) return Natural; end Day;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with GBA.Input; use GBA.Input; package GBA.Input.Buffered is procedure Update_Key_State; function Is_Key_Down (K : Key) return Boolean with Inline_Always; function Are_Any_Down (F : Key_Flags) return Boolean with Inline_Always; function Are_All_Down (F : Key_Flags) return Boolean with Inline_Always; function Was_Key_Pressed (K : Key) return Boolean with Inline_Always; function Were_Any_Pressed (F : Key_Flags) return Boolean with Inline_Always; function Were_All_Pressed (F : Key_Flags) return Boolean with Inline_Always; function Was_Key_Released (K : Key) return Boolean with Inline_Always; function Were_Any_Released (F : Key_Flags) return Boolean with Inline_Always; function Were_All_Released (F : Key_Flags) return Boolean with Inline_Always; function Was_Key_Held (K : Key) return Boolean with Inline_Always; function Were_Any_Held (F : Key_Flags) return Boolean with Inline_Always; function Were_All_Held (F : Key_Flags) return Boolean with Inline_Always; function Was_Key_Untouched (K : Key) return Boolean with Inline_Always; function Were_Any_Untouched (F : Key_Flags) return Boolean with Inline_Always; function Were_All_Untouched (F : Key_Flags) return Boolean with Inline_Always; private Last_Key_State : Key_Flags := 0; Current_Key_State : Key_Flags := 0; end GBA.Input.Buffered;
with AdaCar.Parametros; use AdaCar.Parametros; with AdaCar.Entrada_Salida; with AdaCar.Alarmas; package body AdaCar.Motores is type Canal_Encendido is mod 4; -- 0 => Canal_A -- 1 => Canal_B -- 2 => Canal_C -- 3 => Canal_D ---------------- -- Motores_PO -- ---------------- protected Motores_PO with Priority => Parametros.Techo_Motores_PO is procedure Actua_Direccion (Motor : Tipo_Motor; Valor : Tipo_Direccion); procedure Actua_Step (Motor : Tipo_Motor; Valor: Tipo_Step); private Direccion_Motor_Derecha: Tipo_Direccion; Direccion_Motor_Izquierda: Tipo_Direccion; Ultimo_Canal_Encendido_Derecha: Canal_Encendido; Ultimo_Canal_Encendido_Izquierda: Canal_Encendido; end Motores_PO; ---------------- -- Actua_Step -- ---------------- procedure Actua_Step (Motor : Tipo_Motor; Valor: Tipo_Step) is begin Motores_PO.Actua_Step(Motor,Valor); end Actua_Step; --------------------- -- Actua_Direccion -- --------------------- procedure Actua_Direccion (Motor : Tipo_Motor; Valor : Tipo_Direccion) is begin Motores_PO.Actua_Direccion(Motor,Valor); end Actua_Direccion; ---------------- -- Motores_PO -- ---------------- protected body Motores_PO is procedure Actua_Direccion (Motor : Tipo_Motor; Valor : Tipo_Direccion) is begin case Motor is when Motor_Derecho => Direccion_Motor_Derecha:= Valor; when Motor_Izquierdo => Direccion_Motor_Izquierda:= Valor; when Ambos_Motores => Direccion_Motor_Izquierda:= Valor; Direccion_Motor_Derecha:= Valor; end case; end Actua_Direccion; procedure Actua_Step (Motor : Tipo_Motor; Valor: Tipo_Step) is begin case Motor is when Motor_Derecho => case Direccion_Motor_Derecha is when Hacia_Delante => case Ultimo_Canal_Encendido_Derecha is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Derecha:= Ultimo_Canal_Encendido_Derecha+1; when Hacia_Detras => case Ultimo_Canal_Encendido_Derecha is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Derecha:= Ultimo_Canal_Encendido_Derecha-1; end case; when Motor_Izquierdo => case Direccion_Motor_Izquierda is when Hacia_Delante => case Ultimo_Canal_Encendido_Izquierda is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Izquierda:= Ultimo_Canal_Encendido_Izquierda+1; when Hacia_Detras => case Ultimo_Canal_Encendido_Izquierda is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Izquierda:= Ultimo_Canal_Encendido_Izquierda-1; end case; when Ambos_Motores => if Direccion_Motor_Derecha /= Direccion_Motor_Izquierda then Direccion_Motor_Derecha:= Direccion_Motor_Izquierda; Alarmas.Notificar_Alarma(Uso_Ambos_Motores); end if; declare Direccion_Ambos_Motores: Tipo_Direccion:= Direccion_Motor_Derecha; begin case Direccion_Ambos_Motores is when Hacia_Delante => case Ultimo_Canal_Encendido_Izquierda is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Izquierda:= Ultimo_Canal_Encendido_Izquierda+1; case Ultimo_Canal_Encendido_Derecha is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Derecha:= Ultimo_Canal_Encendido_Derecha+1; when Hacia_Detras => case Ultimo_Canal_Encendido_Derecha is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Derecho_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Derecha:= Ultimo_Canal_Encendido_Derecha-1; case Ultimo_Canal_Encendido_Izquierda is when 0 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(0)); when 1 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_A,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(0)); when 2 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_B,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(0)); when 3 => Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_C,Estado_Digital'(1)); Entrada_Salida.Salida_Digital(Canal_DO_Motor_Izquierdo_D,Estado_Digital'(0)); end case; Ultimo_Canal_Encendido_Izquierda:= Ultimo_Canal_Encendido_Izquierda-1; end case; end; end case; end Actua_Step; end Motores_PO; end AdaCar.Motores;
package body Bonacci is function Generate(Start: Sequence; Length: Positive := 10) return Sequence is begin if Length <= Start'Length then return Start(Start'First .. Start'First+Length-1); else declare Sum: Natural := 0; begin for I in Start'Range loop Sum := Sum + Start(I); end loop; return Start(Start'First) & Generate(Start(Start'First+1 .. Start'Last) & Sum, Length-1); end; end if; end Generate; end Bonacci;
package body History_Variables is -- set and get procedure Set(V: in out Variable; Item: Item_Type) is begin V.History.Prepend(Item); end Set; function Get(V: Variable) return Item_Type is begin return V.History.First_Element; end Get; -- number of items in history (including the current one) function Defined(V: Variable) return Natural is begin return (1 + V.History.Last_Index) - V.History.First_Index; end Defined; -- non-destructively search function Peek(V: Variable; Generation: Natural := 1) return Item_Type is Index: Positive := V.History.First_Index + Generation; begin if Index > V.History.Last_Index then raise Constraint_Error; end if; return V.History.Element(Index); end Peek; procedure Undo(V: in out Variable) is begin V.History.Delete_First; end Undo; end History_Variables;
-- The MIT License (MIT) -- -- Copyright (c) 2016-2017 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 Ada.Numerics.Generic_Elementary_Functions; generic type Base_Real_Type is digits <>; -- Floating point only (can be manually changed to fixed point) Dimension : Positive; package Curve is package Base_Type_Math is new Ada.Numerics.Generic_Elementary_Functions(Base_Real_Type); -- Type Definitions ------------------- type Dimension_Type is new Positive range 1 .. Dimension; type Point_Type is array( Dimension_Type ) of Base_Real_Type; subtype Parametrization_Type is Base_Real_Type range 0.0 .. 1.0; type Control_Points_Array is array(Positive range <>) of Point_Type; type Interpolation_Nodes_Array is array(Positive range <>) of Parametrization_Type; type Knot_Values_Array is array(Positive range <>) of Parametrization_Type; -- Constants ------------ ORIGIN_POINT : constant Point_Type := (others => Base_Real_Type(0.0)); X : constant := 1; Y : constant := 2; Z : constant := 3; W : constant := 4; -- Operator definitions ----------------------- function "+" (Left, Right : Point_Type) return Point_Type; function "-" (Left, Right : Point_Type) return Point_Type; function "-" (Right : Point_Type) return Point_Type; function "*" (Left : Point_Type; Right : Base_Real_Type ) return Point_Type; function "*" (Left : Base_Real_Type; Right : Point_Type ) return Point_Type; -- Curve functions and procedures --------------------------------- function Eval_De_Castelijau( Control_Points : in Control_Points_Array; T : in Parametrization_Type) return Point_Type; function Eval_De_Boor ( Control_Points : in Control_Points_Array; Knot_Values : in Knot_Values_Array; T : in Parametrization_Type; Is_Outside_The_Domain : out Boolean) return Point_Type with Pre => Control_Points'First = Knot_Values'First and then -- Implementation depends on this Knot_Values'Length - Control_Points'Length - 1 > 0; -- At least 0 degree function Eval_Catmull_Rom ( Control_Points : in Control_Points_Array; Segment : in Positive; T : in Parametrization_Type) return Point_Type; -- Evaluate f(t) of a function interpolating {t,f(t)}, where t vlaues are the interpolation nodes. -- and f(t) values are control points. The interpolation is done with Lagrange method. function Eval_Lagrange( Control_Points : in Control_Points_Array; Interpolation_Nodes : in Interpolation_Nodes_Array; T : in Parametrization_Type) return Point_Type with Pre => Control_Points'Length = Interpolation_Nodes'Length; function Make_Equidistant_Nodes( N : Positive ) return Interpolation_Nodes_Array; function Make_Chebyshev_Nodes( N : Positive ) return Interpolation_Nodes_Array; end Curve;
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Element_Vectors; with Program.Elements.Select_Paths; with Program.Element_Visitors; package Program.Nodes.Select_Paths is pragma Preelaborate; type Select_Path is new Program.Nodes.Node and Program.Elements.Select_Paths.Select_Path and Program.Elements.Select_Paths.Select_Path_Text with private; function Create (When_Token : Program.Lexical_Elements.Lexical_Element_Access; Guard : Program.Elements.Expressions.Expression_Access; Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access; Statements : not null Program.Element_Vectors.Element_Vector_Access) return Select_Path; type Implicit_Select_Path is new Program.Nodes.Node and Program.Elements.Select_Paths.Select_Path with private; function Create (Guard : Program.Elements.Expressions.Expression_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Select_Path with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Select_Path is abstract new Program.Nodes.Node and Program.Elements.Select_Paths.Select_Path with record Guard : Program.Elements.Expressions.Expression_Access; Statements : not null Program.Element_Vectors.Element_Vector_Access; end record; procedure Initialize (Self : in out Base_Select_Path'Class); overriding procedure Visit (Self : not null access Base_Select_Path; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Guard (Self : Base_Select_Path) return Program.Elements.Expressions.Expression_Access; overriding function Statements (Self : Base_Select_Path) return not null Program.Element_Vectors.Element_Vector_Access; overriding function Is_Select_Path (Self : Base_Select_Path) return Boolean; overriding function Is_Path (Self : Base_Select_Path) return Boolean; type Select_Path is new Base_Select_Path and Program.Elements.Select_Paths.Select_Path_Text with record When_Token : Program.Lexical_Elements.Lexical_Element_Access; Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Select_Path_Text (Self : in out Select_Path) return Program.Elements.Select_Paths.Select_Path_Text_Access; overriding function When_Token (Self : Select_Path) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Arrow_Token (Self : Select_Path) return Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Select_Path is new Base_Select_Path with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Select_Path_Text (Self : in out Implicit_Select_Path) return Program.Elements.Select_Paths.Select_Path_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Select_Path) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Select_Path) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Select_Path) return Boolean; end Program.Nodes.Select_Paths;
-- -- 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. -- -- package body soc.dma.interfaces with spark_mode => off is type t_dma_periph_access is access all t_dma_periph; procedure enable_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index) is begin case dma_id is when ID_DMA1 => soc.dma.enable (soc.dma.DMA1, stream); when ID_DMA2 => soc.dma.enable (soc.dma.DMA2, stream); end case; end enable_stream; procedure disable_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index) is begin case dma_id is when ID_DMA1 => soc.dma.disable (soc.dma.DMA1, stream); when ID_DMA2 => soc.dma.disable (soc.dma.DMA2, stream); end case; end disable_stream; procedure clear_interrupt (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index; interrupt : in t_dma_interrupts) is reg : t_dma_stream_clear_interrupts := (others => false); begin case interrupt is when FIFO_ERROR => reg.CLEAR_FIFO_ERROR := true; when DIRECT_MODE_ERROR => reg.CLEAR_DIRECT_MODE_ERROR := true; when TRANSFER_ERROR => reg.CLEAR_TRANSFER_ERROR := true; when HALF_COMPLETE => reg.CLEAR_HALF_TRANSFER := true; when TRANSFER_COMPLETE => reg.CLEAR_TRANSFER_COMPLETE := true; end case; case dma_id is when ID_DMA1 => set_IFCR (soc.dma.DMA1, stream, reg); when ID_DMA2 => set_IFCR (soc.dma.DMA2, stream, reg); end case; end clear_interrupt; procedure clear_all_interrupts (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index) is begin case dma_id is when ID_DMA1 => soc.dma.clear_all_interrupts (soc.dma.DMA1, stream); when ID_DMA2 => soc.dma.clear_all_interrupts (soc.dma.DMA2, stream); end case; end clear_all_interrupts; function get_interrupt_status (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index) return t_dma_stream_int_status is begin case dma_id is when ID_DMA1 => return soc.dma.get_interrupt_status (soc.dma.DMA1, stream); when ID_DMA2 => return soc.dma.get_interrupt_status (soc.dma.DMA2, stream); end case; end get_interrupt_status; procedure configure_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index; user_config : in t_dma_config) is controller : t_dma_periph_access; size : unsigned_16; -- Number of data items to transfer begin case dma_id is when ID_DMA1 => controller := soc.dma.DMA1'access; when ID_DMA2 => controller := soc.dma.DMA2'access; end case; controller.streams(stream).CR.EN := false; -- Direction -- The conversion below is due to the difference of representation -- between the field in the CR register and the more abstract -- type manipulated by the soc.dma.interfaces sub-package. controller.streams(stream).CR.DIR := soc.dma.t_transfer_dir'val (t_transfer_dir'pos (user_config.transfer_dir)); -- Input and output addresses case user_config.transfer_dir is when PERIPHERAL_TO_MEMORY => controller.streams(stream).PAR := user_config.in_addr; controller.streams(stream).M0AR := user_config.out_addr; when MEMORY_TO_PERIPHERAL => controller.streams(stream).M0AR := user_config.in_addr; controller.streams(stream).PAR := user_config.out_addr; when MEMORY_TO_MEMORY => controller.streams(stream).PAR := user_config.in_addr; controller.streams(stream).M0AR := user_config.out_addr; end case; -- Channel selection controller.streams(stream).CR.CHSEL := user_config.channel; -- Burst size (single, 4 beats, 8 beats or 16 beats) controller.streams(stream).CR.MBURST := soc.dma.t_burst_size'val (t_burst_size'pos (user_config.mem_burst_size)); controller.streams(stream).CR.PBURST := soc.dma.t_burst_size'val (t_burst_size'pos (user_config.periph_burst_size)); -- Current target controller.streams(stream).CR.CT := MEMORY_0; -- Double buffer mode controller.streams(stream).CR.DBM := false; -- Peripheral incr. size (PSIZE or WORD) controller.streams(stream).CR.PINCOS := INCREMENT_PSIZE; -- Memory and peripheral data size (byte, half word or word) controller.streams(stream).CR.MSIZE := soc.dma.t_data_size'val (t_data_size'pos (user_config.data_size)); controller.streams(stream).CR.PSIZE := soc.dma.t_data_size'val (t_data_size'pos (user_config.data_size)); -- Set if address pointer is incremented after each data transfer controller.streams(stream).CR.MINC := user_config.memory_inc; controller.streams(stream).CR.PINC := user_config.periph_inc; -- Circular mode is disabled controller.streams(stream).CR.CIRC := false; -- DMA or peripheral flow controller controller.streams(stream).CR.PFCTRL := soc.dma.t_flow_controller'val (t_flow_controller'pos (user_config.flow_controller)); -- Number of data items to transfer if user_config.flow_controller = DMA_FLOW_CONTROLLER then -- In direct mode, item size in the DMA bufsize register is -- calculated using the data_size unit. In FIFO/circular mode, -- the increment is always in bytes. if user_config.mode = DIRECT_MODE then case user_config.data_size is when TRANSFER_BYTE => size := user_config.bytes; when TRANSFER_HALF_WORD => size := user_config.bytes / 2; when TRANSFER_WORD => size := user_config.bytes / 4; end case; else size := user_config.bytes; end if; controller.streams(stream).NDTR.NDT := size; end if; -- Priority if user_config.transfer_dir = PERIPHERAL_TO_MEMORY then -- Memory is the destination controller.streams(stream).CR.PL := soc.dma.t_priority_level'val (t_priority_level'pos (user_config.out_priority)); else -- Memory is the source controller.streams(stream).CR.PL := soc.dma.t_priority_level'val (t_priority_level'pos (user_config.in_priority)); end if; -- Enable interrupts case user_config.mode is when DIRECT_MODE => controller.streams(stream).FCR.FIFO_ERROR := false; controller.streams(stream).CR.DIRECT_MODE_ERROR := true; controller.streams(stream).CR.TRANSFER_ERROR := true; controller.streams(stream).CR.TRANSFER_COMPLETE := true; when FIFO_MODE => controller.streams(stream).FCR.DMDIS := true; -- Disable direct mode controller.streams(stream).FCR.FIFO_ERROR := true; controller.streams(stream).FCR.FTH := FIFO_FULL; controller.streams(stream).CR.TRANSFER_ERROR := true; controller.streams(stream).CR.TRANSFER_COMPLETE := true; when CIRCULAR_MODE => if user_config.transfer_dir = MEMORY_TO_MEMORY then raise program_error; -- Not implemented end if; controller.streams(stream).FCR.DMDIS := true; -- Disable direct mode controller.streams(stream).FCR.FIFO_ERROR := false; controller.streams(stream).CR.CIRC := true; -- Enable circular mode controller.streams(stream).CR.TRANSFER_ERROR := true; controller.streams(stream).CR.TRANSFER_COMPLETE := true; end case; end configure_stream; procedure reconfigure_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index; user_config : in t_dma_config; to_configure: in t_config_mask) is controller : t_dma_periph_access; size : unsigned_16; -- Number of data items to transfer begin case dma_id is when ID_DMA1 => controller := soc.dma.DMA1'access; when ID_DMA2 => controller := soc.dma.DMA2'access; end case; controller.streams(stream).CR.EN := false; -- Direction if to_configure.direction then controller.streams(stream).CR.DIR := soc.dma.t_transfer_dir'val (t_transfer_dir'pos (user_config.transfer_dir)); end if; -- Input and output addresses if to_configure.buffer_in or to_configure.buffer_out then case user_config.transfer_dir is when PERIPHERAL_TO_MEMORY => controller.streams(stream).PAR := user_config.in_addr; controller.streams(stream).M0AR := user_config.out_addr; when MEMORY_TO_PERIPHERAL => controller.streams(stream).M0AR := user_config.in_addr; controller.streams(stream).PAR := user_config.out_addr; when MEMORY_TO_MEMORY => controller.streams(stream).PAR := user_config.in_addr; controller.streams(stream).M0AR := user_config.out_addr; end case; end if; -- Number of data items to transfer if user_config.flow_controller = DMA_FLOW_CONTROLLER then -- In direct mode, item size in the DMA bufsize register is -- calculated using the data_size unit. In FIFO/circular mode, -- the increment is always in bytes. if user_config.mode = DIRECT_MODE then case user_config.data_size is when TRANSFER_BYTE => size := user_config.bytes; when TRANSFER_HALF_WORD => size := user_config.bytes / 2; when TRANSFER_WORD => size := user_config.bytes / 4; end case; else size := user_config.bytes; end if; controller.streams(stream).NDTR.NDT := size; end if; -- Priority if to_configure.priority then if user_config.transfer_dir = PERIPHERAL_TO_MEMORY then -- Memory is the destination controller.streams(stream).CR.PL := soc.dma.t_priority_level'val (t_priority_level'pos (user_config.out_priority)); else -- Memory is the source controller.streams(stream).CR.PL := soc.dma.t_priority_level'val (t_priority_level'pos (user_config.in_priority)); end if; end if; -- Enable interrupts if to_configure.mode then case user_config.mode is when DIRECT_MODE => controller.streams(stream).FCR.FIFO_ERROR := false; controller.streams(stream).CR.DIRECT_MODE_ERROR := true; controller.streams(stream).CR.TRANSFER_ERROR := true; controller.streams(stream).CR.TRANSFER_COMPLETE := true; when FIFO_MODE => controller.streams(stream).FCR.DMDIS := true; -- Disable direct mode controller.streams(stream).FCR.FIFO_ERROR := true; controller.streams(stream).FCR.FTH := FIFO_FULL; controller.streams(stream).CR.TRANSFER_ERROR := true; controller.streams(stream).CR.TRANSFER_COMPLETE := true; when CIRCULAR_MODE => if user_config.transfer_dir = MEMORY_TO_MEMORY then raise program_error; -- Not implemented end if; controller.streams(stream).FCR.DMDIS := true; -- Disable direct mode controller.streams(stream).FCR.FIFO_ERROR := false; controller.streams(stream).CR.CIRC := true; -- Enable circular mode controller.streams(stream).CR.TRANSFER_ERROR := true; controller.streams(stream).CR.TRANSFER_COMPLETE := true; end case; end if; end reconfigure_stream; procedure reset_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index) is begin case dma_id is when ID_DMA1 => soc.dma.reset_stream (soc.dma.DMA1, stream); when ID_DMA2 => soc.dma.reset_stream (soc.dma.DMA2, stream); end case; end reset_stream; end soc.dma.interfaces;
-- Copyright (c) 2021 Bartek thindil Jasicki <thindil@laeran.pl> -- -- 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 Tcl.Strings; use Tcl.Strings; with Tk.Widget; use Tk.Widget; with Tk.TtkWidget; use Tk.TtkWidget; -- ****h* Tk/TtkLabel -- FUNCTION -- Provides code for manipulate Tk widget ttk::label -- SOURCE package Tk.TtkLabel is -- **** --## rule off REDUCEABLE_SCOPE -- ****t* TtkLabel/TtkLabel.Ttk_Label -- FUNCTION -- The Tk identifier of the ttk::label -- HISTORY -- 8.6.0 - Added -- SOURCE subtype Ttk_Label is Ttk_Widget; -- **** -- ****s* TtkLabel/TtkLabel.Ttk_Label_Options -- FUNCTION -- Data structure for all available options for the Tk ttk::label -- OPTIONS -- Anchor - Specifies how the text in the label is positioned relative -- to the inner margins -- Background - The background color of the label -- Compound - Specifies if the label should display image and text in -- the same time. If yes (other value than NONE or EMPTY), -- then mean position of image related to the text -- Font - The Tk font which will be used to draw text on the label -- Foreground - The foreground color of the label -- Image - Tk image used to display on the label. Default option -- mean image used when other state's images are not -- specified -- Justify - If there are multiple lines of text, specify how the lines -- are laid out relative to one another. -- Padding - Amount of extra space to allocate for the label. If some -- elemets are empty then, bottom defaults to top, right defaults -- to left, and top defaults to left. Order of the elements: -- left, top, right, bottom -- Relief - 3-D effect desired for the label -- State - The current state of the label -- Text - The text displayed on the label -- Text_Variable - The Tcl variable which value will be used for the text -- on the label -- Underline - The index of the character in the label text which will be -- underlined. The index starts from 0 -- Width - Width of the label. If greater than 0, allocate that -- much space for the label, if less than zero, it is -- minimum width, if zero, use natural width -- Wrap_Length - Maximum line lenght in pixels. If equal to zero, then automatic -- wrapping is not performed, otherwise the text is split into -- lines such that no line is longer than the specified value. -- HISTORY -- 8.6.0 - Added -- SOURCE type Ttk_Label_Options is new Ttk_Widget_Options with record Anchor: Directions_Type := NONE; Background: Tcl_String := Null_Tcl_String; Compound: Compound_Type := EMPTY; Font: Tcl_String := Null_Tcl_String; Foreground: Tcl_String := Null_Tcl_String; Image: Ttk_Image_Option := Default_Ttk_Image_Option; Justify: Justify_Type := NONE; Padding: Padding_Data := Empty_Padding_Data; Relief: Relief_Type := NONE; State: Disabled_State_Type := NORMAL; Text: Tcl_String := Null_Tcl_String; Text_Variable: Tcl_String := Null_Tcl_String; Underline: Extended_Natural := -1; Width: Integer := 0; Wrap_Length: Extended_Natural := -1; end record; -- **** -- ****f* TtkLabel/TtkLabel.Create_(function) -- FUNCTION -- Create a new Tk label widget with the selected pathname and options -- PARAMETERS -- Path_Name - Tk pathname for the newly created label -- Options - Options for the newly created label -- Interpreter - Tcl interpreter on which the label will be created. Can -- be empty. Default value is the default Tcl interpreter -- RESULT -- The Tk identifier of the newly created label widget -- HISTORY -- 8.6.0 - Added -- EXAMPLE -- -- Create the label with pathname .mylabel, text Quit and quitting from -- -- the program on activate -- My_Label: constant Ttk_Label := Create(".mylabel", (Text => To_Tcl_String("Quit"), -- Command => To_Tcl_String("exit"), others => <>)); -- SEE ALSO -- TtkLabel.Create_(procedure) -- COMMANDS -- ttk::label Path_Name Options -- SOURCE function Create (Path_Name: Tk_Path_String; Options: Ttk_Label_Options; Interpreter: Tcl_Interpreter := Get_Interpreter) return Ttk_Label with Pre'Class => Path_Name'Length > 0 and Interpreter /= Null_Interpreter, Test_Case => (Name => "Test_Create_TtkLabel1", Mode => Nominal); -- **** -- ****f* TtkLabel/TtkLabel.Create_(procedure) -- FUNCTION -- Create a new Tk label widget with the selected pathname and options -- PARAMETERS -- Widget - Ttk_Label identifier which will be returned -- Path_Name - Tk pathname for the newly created label -- Options - Options for the newly created label -- Interpreter - Tcl interpreter on which the label will be created. Can -- be empty. Default value is the default Tcl interpreter -- OUTPUT -- The Widget parameter as Tk identifier of the newly created label widget -- HISTORY -- 8.6.0 - Added -- EXAMPLE -- -- Create the label with pathname .mylabel, text Quit and quitting from -- -- the program on activate -- declare -- My_Label: Ttk_Label; -- begin -- Create(My_Label, ".mylabel", (Text => To_Tcl_String("Quit"), -- Command => To_Tcl_String("exit"), others => <>)); -- end; -- SEE ALSO -- TtkLabel.Create_(function) -- COMMANDS -- ttk::label Path_Name Options -- SOURCE procedure Create (Label: out Ttk_Label; Path_Name: Tk_Path_String; Options: Ttk_Label_Options; Interpreter: Tcl_Interpreter := Get_Interpreter) with Pre'Class => Path_Name'Length > 0 and Interpreter /= Null_Interpreter, Test_Case => (Name => "Test_Create_TtkLabel2", Mode => Nominal); -- **** -- ****f* TtkLabel/TtkLabel.Get_Options -- FUNCTION -- Get all values of Tk options of the selected label -- PARAMETERS -- Widget - Ttk_Label which options' values will be taken -- RESULT -- Ttk_Label_Options record with values of the selected label options -- HISTORY -- 8.6.0 - Added -- EXAMPLE -- -- Get all values of option of label with pathname .mylabel -- My_Label_Options: constant Ttk_Label_Options := Get_Options(Get_Widget(".mylabel")); -- SEE ALSO -- TtkLabel.Configure -- COMMANDS -- Label configure -- SOURCE function Get_Options(Label: Ttk_Label) return Ttk_Label_Options with Pre'Class => Label /= Null_Widget, Test_Case => (Name => "Test_Get_Options_TtkLabel", Mode => Nominal); -- **** -- ****f* TtkLabel/TtkLabel.Configure -- FUNCTION -- Set the selected options for the selected label -- PARAMETERS -- Widget - Ttk_Label which options will be set -- Options - The record with new values for the label options -- HISTORY -- 8.6.0 - Added -- EXAMPLE -- -- Disable label with pathname .mylabel -- Configure(Get_Widget(".mylabel"), (State => DISABLED, others => <>)); -- SEE ALSO -- TtkLabel.Get_Options -- COMMANDS -- Label configure Options -- SOURCE procedure Configure(Label: Ttk_Label; Options: Ttk_Label_Options) with Pre'Class => Label /= Null_Widget, Test_Case => (Name => "Test_Configure_TtkLabel", Mode => Nominal); -- **** -- ****d* TtkLabel/TtkLabel.Default_Ttk_Label_Options -- FUNCTION -- The default options for the Ttk_Label -- HISTORY -- 8.6.0 - Added -- SOURCE Default_Ttk_Label_Options: constant Ttk_Label_Options := Ttk_Label_Options'(others => <>); -- **** --## rule on REDUCEABLE_SCOPE end Tk.TtkLabel;
------------------------------------------------------------------------------ -- -- -- Generic HEX String Handling Package -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2018-2019, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai, Ensi Martini, Aninda Poddar, Noshen Atashe -- -- (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package Hex with SPARK_Mode => On is pragma Preelaborate (Hex); pragma Assertion_Policy (Ignore); -- This package is validated type Set_Case is (Lower_Case, Upper_Case); subtype Hex_Character is Character with Static_Predicate => Hex_Character in '0' .. '9' | 'A' .. 'F' | 'a' .. 'f'; function Valid_Hex_String (Candidate: String) return Boolean is (Candidate'Length >= 1 and then (for all Char of Candidate => Char in Hex_Character)) with Inline => True, Global => null; -- Returns True if and only if Candidate represents a valid hexadecimal -- string. -- ------------------ -- Identify_Hex -- ------------------ subtype Valid_Exterior is Character with Static_Predicate => Valid_Exterior in Character'Val (9) .. Character'Val (13) | -- HT,LF,VT,FF,CR Character'Val (32) .. Character'Val (47) | -- Punctuation Character'Val (58) .. Character'Val (64) | -- Punctuation Character'Val (123) .. Character'Val (126); -- More punctuation -- Characters that are valid immediately before and after a valid -- hexadecimal string during identification of that string function Demarcation_Precedent_Check (Source: String; First: Positive) return Boolean is (First = Source'First or else (First > Source'First and then (Source(First - 1) in Valid_Exterior or else (Source(First - 1) in 'X' | 'x' and then (case Source(Source'First .. First)'Length is when 3 => Source (First - 2) = '0', when 4 .. Positive'Last => (Source (First - 2) = '0' and then Source (First - 3) in Valid_Exterior), when others => False))))) with Inline => True, Global => null, Pre => First in Source'Range and then Source(First) in Hex_Character; -- True for one of the four following conditions, provided -- Source(First) is a Hex_Character -- 1. First = Source'First -- 2. (First - 1 .. First) is a Valid_Exterior & Hex_Character -- 3. (First - 2 .. First) is ("0x" | "0X") or -- 4. (First - 3) is Valid_Exterior & Condition 3 function Demarcation_Subsequent_Check (Source: String; Last: Natural) return Boolean is (Source'Length in 0 .. 1 or else Last = Source'Last or else Source (Last + 1) in Valid_Exterior) with Inline => True, Global => null, Pre => Source'Length = 0 or else (Last in Source'Range and then Source(Last) in Hex_Character); -- True if and only if: -- Source(Last) is a Hex_Character, and then -- Last = Source'Last, or else -- Source(Last + 1) = Valid_Exterior ---------------------------------------------------------------------------- procedure Identify_Hex (Source: in String; First : out Positive; Last : out Natural) with Global => null, Depends => ((First, Last) => Source), Post => (if Last >= First then Valid_Hex_String (Source (First .. Last)) and then Demarcation_Precedent_Check (Source, First) and then Demarcation_Subsequent_Check (Source, Last) else (if Source'Length > 0 then First = Source'First and Last = First - 1 else First = 1 and Last = 0)); -- Identify_Hex is a verified helper function which identifies the first -- (if any) valid unbroken hexadecimal string in the Source string, which -- is demarcated by the range First .. Last of Source -- -- If a valid hexadecimal string cannot be identified within Source, -- First is set to Source'First, and Last is set to Source'First - 1 -- (a null range). -- -- This procedure attempts to avoid misidentification of arbitrary -- "hexadecimal digits" that would otherwise appear frequently in most -- alphanumeric text. This is done by only identifying string of hexadecimal -- digits that are surrounded by an explicitly defined set of -- "Valid_Exterior" characters, which include exclusively graphical -- characters with tabs, spaces, CR/LF/FF, and most basic punctuation -- -- This procedure also recognizes hexadecimal strings prepended with the -- common "0x" indicator. end Hex;
-- -- N-Body integrations demonstrate the need for high accuracy and -- reliable error estimates. -- -- N-Body equation: -- Acceleration(Body_j) -- = SumOver(Body_k) { Mass(Body_k) * G * DeltaR / NORM(DeltaR)**3 } -- -- where DeltaR = (X(Body_k) - X(Body_j)) is a vector, -- and where G is the gravitaional constant. -- -- Natural units: -- Unit of time is earth_orbital_period : t_0. -- Unit of distance is earth's orbital semi-major axis : a_0. -- Unit of mass is sum of Sun and Earth mass : m_0. -- These are related to each other by Kepler's law: -- -- t_0 = 2 * Pi * SQRT (a_0**3 / (G * m_0)) -- -- where G is the gravitaional constant. If you divide variable of -- time in the N_Body equation by t_0 to get natural units, the equation -- becomes: -- -- Acceleration(Body_j) = 2*2*Pi*Pi* -- SumOver(Body_k) { Mass(Body_k) * DeltaR / NORM(DeltaR)**3 } -- -- where DeltaR = (X(Body_k) - X(Body_j)). -- -- Mass, time, and distance are in the natural units given above - -- gets rid of the gravitational constant G. In the Equation -- as implemented below, the masses are multiplied by 2*2*pi*pi -- when they are defined in order to avoid an excessive number of -- multiplications during evaluation of F(t, Y). with Runge_8th; with Text_IO; use Text_IO; with Four_Body; procedure runge_8th_order_demo_4 is type Real is digits 15; package rio is new Float_IO(Real); use rio; package Bodies_4 is new Four_Body (Real); use Bodies_4; package N_Body_Solve is new Runge_8th (Real, State_Index, Dynamical_Variable, F, "*", "+", "-", Norm); use N_Body_Solve; Initial_State : Dynamical_Variable; Final_Y : Dynamical_Variable; Previous_Y : Dynamical_Variable; Final_t : Real; Previous_t : Real; ErrorTolerance : constant Real := 2.0E-12; -- 2nd body : a : constant Real := 21.71534093275925; Orbital_Period : constant Real := 80.0; Orbits_Per_int : constant Real := 10.0; No_Of_Steps_Per_int : constant step_integer := 120_000; Delta_t : constant Real := Orbital_Period * Orbits_Per_int; X2, X0, Z2, Z0 : Real; -- Choose initial conditions. -- Body1 is the larger, mass = 1.0 (sun mass). -- Body2 is the smaller, mass = 0.6 (sun mass). -- Assume the orbital period of the 2 stars is 80.0 years. -- Say the planet is body 3: one earth distance -- from the larger star with 1 earth mass. -- From these calculate the semimajor axis "a" in -- Kepler's law given above; then put the three bodies in -- near circular orbits and observe stability. -- Remember to use the reduced-mass formulas to get distance -- from center of mass: -- -- Body_1_Radius r1 = a*m2 / (m1+m2) -- Body_2_Radius r2 = a*m1 / (m1+m2) --Planet_Orbital_Radius : constant Real := 1.0;-- earth's orbital period --Planet_Period : constant Real := 1.0; --Planet_Orbital_Radius : constant Real := 2.0;-- Twice earth's orbit --Planet_Period : constant Real := 2.82842712474619; --Planet_Orbital_Radius : constant Real := 3.0;-- Thrice earth's orbit --Planet_Period : constant Real := 5.196152422706632; --Planet_Orbital_Radius2 : constant Real := 1.587401052; -- 1.59 earth's orbit --Planet_Period2 : constant Real := 2.0;-- 1.59**1.5 from Kepler's law Planet_Orbital_Radius1 : constant Real := 1.0;-- 1 times earth's orbit Planet_Period1 : constant Real := 1.0;-- 4**1.5 from Kepler's law Planet_Orbital_Radius2 : constant Real := 4.0; -- 1.59 earth's orbit Planet_Period2 : constant Real := 8.0;-- 4.0**1.5 from Kepler's law m1 : constant Real := Mass(0); m2 : constant Real := Mass(1); Body_1_Radius : constant Real := a * m2 / (m1+m2); Body_2_Radius : constant Real := a * m1 / (m1+m2); Body_3_Radius : constant Real := Planet_Orbital_Radius1 + Body_1_Radius; Body_4_Radius : constant Real := Planet_Orbital_Radius2 + Body_1_Radius; Body_1_Speed : constant Real := TwoPii*Body_1_Radius / Orbital_Period; Body_2_Speed : constant Real := TwoPii*Body_2_Radius / Orbital_Period; Ratio : Constant Real := Body_3_Radius / Body_1_Radius; Body_3_Speed : constant Real := (TwoPii * Planet_Orbital_Radius1 / Planet_Period1) + Body_1_Speed; Body_4_Speed : constant Real := (TwoPii * Planet_Orbital_Radius2 / Planet_Period2) + Body_1_Speed; d_X, d_Z : Real; Orbit : Real := 0.0; Radius2 : Real; Min : Real := 100000.0; Max : Real := 0.0; Min3, Min1 : Real := 100000.0; Max3, Max1 : Real := 0.0; begin Update_State (Initial_State, 0, 0.0, Body_1_Radius, Body_1_Speed, 0.0); Update_State (Initial_State, 1, 0.0, -Body_2_Radius, -Body_2_Speed, 0.0); Update_State (Initial_State, 2, 0.0, Body_3_Radius, Body_3_Speed, 0.0); Update_State (Initial_State, 3, 0.0, Body_4_Radius, Body_4_Speed, 0.0); --Initial_State(0) := (0.0, Body_1_Radius, -- 1st body XY position -- Body_1_Speed, 0.0);-- 1st body UW velocity --Initial_State(1) := (0.0, -Body_2_Radius, -- 2nd body XY position -- -Body_2_Speed, 0.0);-- 2nd body UW velocity --Initial_State(2) := (0.0, Body_3_Radius, -- 3rd body XY position -- Body_3_Speed, 0.0);-- 3rd body UW velocity --Initial_State(3) := (0.0, Body_4_Radius, -- 4rth body XY position -- Body_4_Speed, 0.0);-- 4rth body UW velocity -- Notice that they are all rotating clockwise -- looking down on the XZ plane. Previous_t := 0.0; Previous_Y := Initial_State; Final_t := Delta_t; new_line; loop Integrate (Final_State => Final_Y, -- output the result. Final_Time => Final_t, -- integrate out to here. Initial_State => Previous_Y, -- input an initial condition. Initial_Time => Previous_t, -- start integrating here. No_Of_Steps => No_Of_Steps_Per_int); Previous_t := Final_t; Previous_Y := Final_Y; Final_t := Previous_t + Delta_t; Orbit := Orbit + Orbits_Per_int; X2 := State_Val (Final_Y,2,0); X0 := State_Val (Final_Y,0,0); Z2 := State_Val (Final_Y,2,1); Z0 := State_Val (Final_Y,0,1); d_X := X2 - X0; d_Z := Z2 - Z0; Radius2 := d_X**2 + d_Z**2; if Radius2 > Max then Max := Radius2; end if; if Radius2 < Min then Min := Radius2; end if; put ("Year = "); put (Orbit * Orbital_Period); new_line; put (" Max = "); put (Max); put(" Min = "); put (Min); new_line; X2 := State_Val (Final_Y,3,0); X0 := State_Val (Final_Y,0,0); Z2 := State_Val (Final_Y,3,1); Z0 := State_Val (Final_Y,0,1); d_X := X2 - X0; d_Z := Z2 - Z0; Radius2 := d_X**2 + d_Z**2; if Radius2 > Max3 then Max3 := Radius2; end if; if Radius2 < Min3 then Min3 := Radius2; end if; put (" Max3 ="); put (Max3); put (" Min3 ="); put (Min3); new_line; X2 := State_Val (Final_Y,1,0); X0 := State_Val (Final_Y,0,0); Z2 := State_Val (Final_Y,1,1); Z0 := State_Val (Final_Y,0,1); d_X := X2 - X0; d_Z := Z2 - Z0; Radius2 := d_X**2 + d_Z**2; if Radius2 > Max1 then Max1 := Radius2; end if; if Radius2 < Min1 then Min1 := Radius2; end if; put (" Max1 ="); put (Max1); put (" Min1 ="); put (Min1); new_line; --exit when Count = 2; end loop; end;
procedure Interval_proc is procedure some_procedure is begin -- this cannot be empty end; Interval_Length : Time_Span := To_Time_Span(0.5); Next_Call_Time : Time; begin Next_Call_Time := Clock; loop some_procedure; Next_Call_Time := Next_Call_Time + Interval_Length; delay until Next_Call_Time; end loop; end Interval_proc;
-- { dg-do compile } */ -- { dg-options "-cargs -I -gnatws" } -- { dg-error "search directory missing" "" { target *-*-* } 0 }
with ACO.Generic_Entry_Types; with ACO.OD_Types.Entries; package ACO.OD.Example is -- Shall be generated based on an EDS file type Dictionary is new Object_Dictionary with private; use ACO.OD_Types.Entries; -- 0x1008 Manufacturer Device Name VAR Device_Name_Str : constant String := "A device name"; type Device_Name_String is new Visible_String (Device_Name_Str'Range) with Alignment => 1; package Device_Name_Pack is new ACO.Generic_Entry_Types (Device_Name_String); type Device_Name_Entry is new Device_Name_Pack.Entry_Type with null record; private use type ACO.OD_Types.Object_Subindex; -- 0x1000 Device Type VAR Device_Type_Var : aliased Entry_U32 := Create (RO, 16#00000000#); Device_Type_Data : aliased Entry_Array := (0 => Device_Type_Var'Access); Device_Type : aliased Object_Base (Device_Type_Data'Access); -- 0x1001 Error Register VAR Error_Register_Var : aliased Entry_U8 := Create (RO, 16#00#); Error_Register_Data : aliased Entry_Array := (0 => Error_Register_Var'Access); Error_Register : aliased Object_Base (Error_Register_Data'Access); -- 0x1003 Pre-defined Error Field ARRAY Predef_Err_Field_Nof : aliased Entry_U8 := Create (RW, 16#00#); Predef_Err_Field_1 : aliased Entry_U32 := Create (RO, 16#00000000#); Predef_Err_Field_Data : aliased Entry_Array := (0 => Predef_Err_Field_Nof'Access, 1 => Predef_Err_Field_1'Access); Predef_Err_Field : aliased Object_Base (Predef_Err_Field_Data'Access); -- 0x1005 Sync COB-ID VAR Sync_COB_ID_Var : aliased Entry_U32 := Create (RW, 16#00000080#); Sync_COB_ID_Data : aliased Entry_Array := (0 => Sync_COB_ID_Var'Access); Sync_COB_ID : aliased Object_Base (Sync_COB_ID_Data'Access); -- 0x1006 Communication Cycle Period VAR Comm_Cycle_Per_Var : aliased Entry_Dur := Create (RW, 0.0000001); Comm_Cycle_Per_Data : aliased Entry_Array := (0 => Comm_Cycle_Per_Var'Access); Comm_Cycle_Per : aliased Object_Base (Comm_Cycle_Per_Data'Access); -- 0x1007 Synchronous Window Length VAR Sync_Win_Length_Var : aliased Entry_U32 := Create (RW, 16#00000000#); Sync_Win_Length_Data : aliased Entry_Array := (0 => Sync_Win_Length_Var'Access); Sync_Win_Length : aliased Object_Base (Sync_Win_Length_Data'Access); -- 0x1008 Manufacturer Device Name VAR Device_Name_Var : aliased Device_Name_Entry := Create (RW, Device_Name_String (Device_Name_Str)); Device_Name_Data : aliased Entry_Array := (0 => Device_Name_Var'Access); Device_Name : aliased Object_Base (Device_Name_Data'Access); -- 0x1016 Consumer Heartbeat Time ARRAY Consumer_Hbt_Nof : aliased Entry_U8 := Create (RO, 16#01#); Consumer_Hbt_1 : aliased Entry_U32 := Create (RW, 16#00040010#); Consumer_Hbt_Data : aliased Entry_Array := (0 => Consumer_Hbt_Nof'Access, 1 => Consumer_Hbt_1'Access); Consumer_Hbt : aliased Object_Base (Consumer_Hbt_Data'Access); -- 0x1017 Producer Heartbeat Time Producer_Hbt_Var : aliased Entry_U16 := Create (RW, 10); Producer_Hbt_Data : aliased Entry_Array := (0 => Producer_Hbt_Var'Access); Producer_Hbt : aliased Object_Base (Producer_Hbt_Data'Access); -- 0x1019 Synchronous Counter Overflow Value VAR Sync_Counter_Overflow_Var : aliased Entry_U8 := Create (RW, 16); Sync_Counter_Overflow_Data : aliased Entry_Array := (0 => Sync_Counter_Overflow_Var'Access); Sync_Counter_Overflow : aliased Object_Base (Sync_Counter_Overflow_Data'Access); -- 0x1200-0x127F SDO Server Parameter SDO_Server_Field_Nof : aliased Entry_U8 := Create (RO, 16#03#); SDO_Server_COBID_C2S : aliased Entry_U32 := Create (RO, 16#00000600# + 1); SDO_Server_COBID_S2C : aliased Entry_U32 := Create (RO, 16#00000580# + 1); SDO_Server_Client_ID : aliased Entry_U8 := Create (RO, 16#01#); SDO_Server_Data : aliased Entry_Array := (0 => SDO_Server_Field_Nof'Access, 1 => SDO_Server_COBID_C2S'Access, 2 => SDO_Server_COBID_S2C'Access, 3 => SDO_Server_Client_ID'Access); SDO_Servers : aliased Object_Base (SDO_Server_Data'Access); -- 0x1280-0x12FF SDO Client Parameter SDO_Client_Field_Nof : aliased Entry_U8 := Create (RO, 16#03#); SDO_Client_COBID_C2S : aliased Entry_U32 := Create (RO, 16#00000600# + 1); SDO_Client_COBID_S2C : aliased Entry_U32 := Create (RO, 16#00000580# + 1); SDO_Client_Server_ID : aliased Entry_U8 := Create (RO, 16#01#); SDO_Client_Data : aliased Entry_Array := (0 => SDO_Client_Field_Nof'Access, 1 => SDO_Client_COBID_C2S'Access, 2 => SDO_Client_COBID_S2C'Access, 3 => SDO_Client_Server_ID'Access); SDO_Clients : aliased Object_Base (SDO_Client_Data'Access); -- Communication Profile Data Com_Profile : aliased Profile_Objects := (0 => Device_Type'Access, 1 => Error_Register'Access, 2 => Predef_Err_Field'Access, 3 => Sync_COB_ID'Access, 4 => Comm_Cycle_Per'Access, 5 => Sync_Win_Length'Access, 6 => Device_Name'Access, 7 => Consumer_Hbt'Access, 8 => Producer_Hbt'Access, 9 => Sync_Counter_Overflow'Access, 10 => SDO_Servers'Access, 11 => SDO_Clients'Access); overriding function Index_Map (This : Dictionary; Index : Object_Index) return Index_Type is (case Index is when 16#1000# => 0, when 16#1001# => 1, when 16#1003# => 2, when 16#1005# => 3, when 16#1006# => 4, when 16#1007# => 5, when 16#1008# => 6, when 16#1016# => 7, when 16#1017# => 8, when 16#1019# => 9, when 16#1200# => 10, when 16#1280# => 11, when others => No_Index); overriding function Objects (This : Dictionary) return Profile_Objects_Ref is (Com_Profile'Access); type Dictionary is new Object_Dictionary with null record; end ACO.OD.Example;
package Space_Image_Format is Width: constant := 25; Height: constant := 6; type Width_Range is range 1 .. Width; type Height_Range is range 1 .. Height; type Pixel is new Character range '0' .. '9'; type Layer is array (Width_Range, Height_Range) of Pixel; type Layer_Stack is array (Positive range <>) of Layer; type Color is (Black, White, Transparent); subtype Visible_Color is Color range Black .. White; type Image is array (Width_Range, Height_Range) of Visible_Color; procedure Get_Layer(L: out Layer); function To_Image(S: Layer_Stack) return Image; procedure Put_Image(I: in Image); end Space_Image_Format;
-- This spec has been automatically generated from STM32F427x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with System; with HAL; package STM32_SVD.CAN is pragma Preelaborate; --------------- -- Registers -- --------------- ------------------ -- MCR_Register -- ------------------ -- master control register type MCR_Register is record -- INRQ INRQ : Boolean := False; -- SLEEP SLEEP : Boolean := True; -- TXFP TXFP : Boolean := False; -- RFLM RFLM : Boolean := False; -- NART NART : Boolean := False; -- AWUM AWUM : Boolean := False; -- ABOM ABOM : Boolean := False; -- TTCM TTCM : Boolean := False; -- unspecified Reserved_8_14 : HAL.UInt7 := 16#0#; -- RESET RESET : Boolean := False; -- DBF DBF : Boolean := True; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MCR_Register use record INRQ at 0 range 0 .. 0; SLEEP at 0 range 1 .. 1; TXFP at 0 range 2 .. 2; RFLM at 0 range 3 .. 3; NART at 0 range 4 .. 4; AWUM at 0 range 5 .. 5; ABOM at 0 range 6 .. 6; TTCM at 0 range 7 .. 7; Reserved_8_14 at 0 range 8 .. 14; RESET at 0 range 15 .. 15; DBF at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; ------------------ -- MSR_Register -- ------------------ -- master status register type MSR_Register is record -- Read-only. INAK INAK : Boolean := False; -- Read-only. SLAK SLAK : Boolean := True; -- ERRI ERRI : Boolean := False; -- WKUI WKUI : Boolean := False; -- SLAKI SLAKI : Boolean := False; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- Read-only. TXM TXM : Boolean := False; -- Read-only. RXM RXM : Boolean := False; -- Read-only. SAMP SAMP : Boolean := True; -- Read-only. RX RX : Boolean := True; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MSR_Register use record INAK at 0 range 0 .. 0; SLAK at 0 range 1 .. 1; ERRI at 0 range 2 .. 2; WKUI at 0 range 3 .. 3; SLAKI at 0 range 4 .. 4; Reserved_5_7 at 0 range 5 .. 7; TXM at 0 range 8 .. 8; RXM at 0 range 9 .. 9; SAMP at 0 range 10 .. 10; RX at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- TSR_Register -- ------------------ subtype TSR_CODE_Field is HAL.UInt2; ------------- -- TSR.TME -- ------------- -- TSR_TME array type TSR_TME_Field_Array is array (0 .. 2) of Boolean with Component_Size => 1, Size => 3; -- Type definition for TSR_TME type TSR_TME_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TME as a value Val : HAL.UInt3; when True => -- TME as an array Arr : TSR_TME_Field_Array; end case; end record with Unchecked_Union, Size => 3; for TSR_TME_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; ------------- -- TSR.LOW -- ------------- -- TSR_LOW array type TSR_LOW_Field_Array is array (0 .. 2) of Boolean with Component_Size => 1, Size => 3; -- Type definition for TSR_LOW type TSR_LOW_Field (As_Array : Boolean := False) is record case As_Array is when False => -- LOW as a value Val : HAL.UInt3; when True => -- LOW as an array Arr : TSR_LOW_Field_Array; end case; end record with Unchecked_Union, Size => 3; for TSR_LOW_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- transmit status register type TSR_Register is record -- RQCP0 RQCP0 : Boolean := False; -- TXOK0 TXOK0 : Boolean := False; -- ALST0 ALST0 : Boolean := False; -- TERR0 TERR0 : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- ABRQ0 ABRQ0 : Boolean := False; -- RQCP1 RQCP1 : Boolean := False; -- TXOK1 TXOK1 : Boolean := False; -- ALST1 ALST1 : Boolean := False; -- TERR1 TERR1 : Boolean := False; -- unspecified Reserved_12_14 : HAL.UInt3 := 16#0#; -- ABRQ1 ABRQ1 : Boolean := False; -- RQCP2 RQCP2 : Boolean := False; -- TXOK2 TXOK2 : Boolean := False; -- ALST2 ALST2 : Boolean := False; -- TERR2 TERR2 : Boolean := False; -- unspecified Reserved_20_22 : HAL.UInt3 := 16#0#; -- ABRQ2 ABRQ2 : Boolean := False; -- Read-only. CODE CODE : TSR_CODE_Field := 16#0#; -- Read-only. Lowest priority flag for mailbox 0 TME : TSR_TME_Field := (As_Array => False, Val => 16#1#); -- Read-only. Lowest priority flag for mailbox 0 LOW : TSR_LOW_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSR_Register use record RQCP0 at 0 range 0 .. 0; TXOK0 at 0 range 1 .. 1; ALST0 at 0 range 2 .. 2; TERR0 at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ABRQ0 at 0 range 7 .. 7; RQCP1 at 0 range 8 .. 8; TXOK1 at 0 range 9 .. 9; ALST1 at 0 range 10 .. 10; TERR1 at 0 range 11 .. 11; Reserved_12_14 at 0 range 12 .. 14; ABRQ1 at 0 range 15 .. 15; RQCP2 at 0 range 16 .. 16; TXOK2 at 0 range 17 .. 17; ALST2 at 0 range 18 .. 18; TERR2 at 0 range 19 .. 19; Reserved_20_22 at 0 range 20 .. 22; ABRQ2 at 0 range 23 .. 23; CODE at 0 range 24 .. 25; TME at 0 range 26 .. 28; LOW at 0 range 29 .. 31; end record; ------------------- -- RF0R_Register -- ------------------- subtype RF0R_FMP0_Field is HAL.UInt2; -- receive FIFO 0 register type RF0R_Register is record -- Read-only. FMP0 FMP0 : RF0R_FMP0_Field := 16#0#; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- FULL0 FULL0 : Boolean := False; -- FOVR0 FOVR0 : Boolean := False; -- RFOM0 RFOM0 : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RF0R_Register use record FMP0 at 0 range 0 .. 1; Reserved_2_2 at 0 range 2 .. 2; FULL0 at 0 range 3 .. 3; FOVR0 at 0 range 4 .. 4; RFOM0 at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; ------------------- -- RF1R_Register -- ------------------- subtype RF1R_FMP1_Field is HAL.UInt2; -- receive FIFO 1 register type RF1R_Register is record -- Read-only. FMP1 FMP1 : RF1R_FMP1_Field := 16#0#; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- FULL1 FULL1 : Boolean := False; -- FOVR1 FOVR1 : Boolean := False; -- RFOM1 RFOM1 : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RF1R_Register use record FMP1 at 0 range 0 .. 1; Reserved_2_2 at 0 range 2 .. 2; FULL1 at 0 range 3 .. 3; FOVR1 at 0 range 4 .. 4; RFOM1 at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; ------------------ -- IER_Register -- ------------------ -- interrupt enable register type IER_Register is record -- TMEIE TMEIE : Boolean := False; -- FMPIE0 FMPIE0 : Boolean := False; -- FFIE0 FFIE0 : Boolean := False; -- FOVIE0 FOVIE0 : Boolean := False; -- FMPIE1 FMPIE1 : Boolean := False; -- FFIE1 FFIE1 : Boolean := False; -- FOVIE1 FOVIE1 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- EWGIE EWGIE : Boolean := False; -- EPVIE EPVIE : Boolean := False; -- BOFIE BOFIE : Boolean := False; -- LECIE LECIE : Boolean := False; -- unspecified Reserved_12_14 : HAL.UInt3 := 16#0#; -- ERRIE ERRIE : Boolean := False; -- WKUIE WKUIE : Boolean := False; -- SLKIE SLKIE : Boolean := False; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IER_Register use record TMEIE at 0 range 0 .. 0; FMPIE0 at 0 range 1 .. 1; FFIE0 at 0 range 2 .. 2; FOVIE0 at 0 range 3 .. 3; FMPIE1 at 0 range 4 .. 4; FFIE1 at 0 range 5 .. 5; FOVIE1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; EWGIE at 0 range 8 .. 8; EPVIE at 0 range 9 .. 9; BOFIE at 0 range 10 .. 10; LECIE at 0 range 11 .. 11; Reserved_12_14 at 0 range 12 .. 14; ERRIE at 0 range 15 .. 15; WKUIE at 0 range 16 .. 16; SLKIE at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; ------------------ -- ESR_Register -- ------------------ subtype ESR_LEC_Field is HAL.UInt3; subtype ESR_TEC_Field is HAL.Byte; subtype ESR_REC_Field is HAL.Byte; -- interrupt enable register type ESR_Register is record -- Read-only. EWGF EWGF : Boolean := False; -- Read-only. EPVF EPVF : Boolean := False; -- Read-only. BOFF BOFF : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- LEC LEC : ESR_LEC_Field := 16#0#; -- unspecified Reserved_7_15 : HAL.UInt9 := 16#0#; -- Read-only. TEC TEC : ESR_TEC_Field := 16#0#; -- Read-only. REC REC : ESR_REC_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ESR_Register use record EWGF at 0 range 0 .. 0; EPVF at 0 range 1 .. 1; BOFF at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; LEC at 0 range 4 .. 6; Reserved_7_15 at 0 range 7 .. 15; TEC at 0 range 16 .. 23; REC at 0 range 24 .. 31; end record; ------------------ -- BTR_Register -- ------------------ subtype BTR_BRP_Field is HAL.UInt10; subtype BTR_TS1_Field is HAL.UInt4; subtype BTR_TS2_Field is HAL.UInt3; subtype BTR_SJW_Field is HAL.UInt2; -- bit timing register type BTR_Register is record -- BRP BRP : BTR_BRP_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- TS1 TS1 : BTR_TS1_Field := 16#0#; -- TS2 TS2 : BTR_TS2_Field := 16#0#; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- SJW SJW : BTR_SJW_Field := 16#0#; -- unspecified Reserved_26_29 : HAL.UInt4 := 16#0#; -- LBKM LBKM : Boolean := False; -- SILM SILM : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BTR_Register use record BRP at 0 range 0 .. 9; Reserved_10_15 at 0 range 10 .. 15; TS1 at 0 range 16 .. 19; TS2 at 0 range 20 .. 22; Reserved_23_23 at 0 range 23 .. 23; SJW at 0 range 24 .. 25; Reserved_26_29 at 0 range 26 .. 29; LBKM at 0 range 30 .. 30; SILM at 0 range 31 .. 31; end record; ------------------- -- TI0R_Register -- ------------------- subtype TI0R_EXID_Field is HAL.UInt18; subtype TI0R_STID_Field is HAL.UInt11; -- TX mailbox identifier register type TI0R_Register is record -- TXRQ TXRQ : Boolean := False; -- RTR RTR : Boolean := False; -- IDE IDE : Boolean := False; -- EXID EXID : TI0R_EXID_Field := 16#0#; -- STID STID : TI0R_STID_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TI0R_Register use record TXRQ at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; -------------------- -- TDT0R_Register -- -------------------- subtype TDT0R_DLC_Field is HAL.UInt4; subtype TDT0R_TIME_Field is HAL.Short; -- mailbox data length control and time stamp register type TDT0R_Register is record -- DLC DLC : TDT0R_DLC_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- TGT TGT : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- TIME TIME : TDT0R_TIME_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TDT0R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; TGT at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; TIME at 0 range 16 .. 31; end record; -------------------- -- TDL0R_Register -- -------------------- -- TDL0R_DATA array element subtype TDL0R_DATA_Element is HAL.Byte; -- TDL0R_DATA array type TDL0R_DATA_Field_Array is array (0 .. 3) of TDL0R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data low register type TDL0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : TDL0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDL0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -------------------- -- TDH0R_Register -- -------------------- -- TDH0R_DATA array element subtype TDH0R_DATA_Element is HAL.Byte; -- TDH0R_DATA array type TDH0R_DATA_Field_Array is array (4 .. 7) of TDH0R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type TDH0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : TDH0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDH0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- TI1R_Register -- ------------------- subtype TI1R_EXID_Field is HAL.UInt18; subtype TI1R_STID_Field is HAL.UInt11; -- mailbox identifier register type TI1R_Register is record -- TXRQ TXRQ : Boolean := False; -- RTR RTR : Boolean := False; -- IDE IDE : Boolean := False; -- EXID EXID : TI1R_EXID_Field := 16#0#; -- STID STID : TI1R_STID_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TI1R_Register use record TXRQ at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; -------------------- -- TDT1R_Register -- -------------------- subtype TDT1R_DLC_Field is HAL.UInt4; subtype TDT1R_TIME_Field is HAL.Short; -- mailbox data length control and time stamp register type TDT1R_Register is record -- DLC DLC : TDT1R_DLC_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- TGT TGT : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- TIME TIME : TDT1R_TIME_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TDT1R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; TGT at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; TIME at 0 range 16 .. 31; end record; -------------------- -- TDL1R_Register -- -------------------- -- TDL1R_DATA array element subtype TDL1R_DATA_Element is HAL.Byte; -- TDL1R_DATA array type TDL1R_DATA_Field_Array is array (0 .. 3) of TDL1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data low register type TDL1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : TDL1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDL1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -------------------- -- TDH1R_Register -- -------------------- -- TDH1R_DATA array element subtype TDH1R_DATA_Element is HAL.Byte; -- TDH1R_DATA array type TDH1R_DATA_Field_Array is array (4 .. 7) of TDH1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type TDH1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : TDH1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDH1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- TI2R_Register -- ------------------- subtype TI2R_EXID_Field is HAL.UInt18; subtype TI2R_STID_Field is HAL.UInt11; -- mailbox identifier register type TI2R_Register is record -- TXRQ TXRQ : Boolean := False; -- RTR RTR : Boolean := False; -- IDE IDE : Boolean := False; -- EXID EXID : TI2R_EXID_Field := 16#0#; -- STID STID : TI2R_STID_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TI2R_Register use record TXRQ at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; -------------------- -- TDT2R_Register -- -------------------- subtype TDT2R_DLC_Field is HAL.UInt4; subtype TDT2R_TIME_Field is HAL.Short; -- mailbox data length control and time stamp register type TDT2R_Register is record -- DLC DLC : TDT2R_DLC_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- TGT TGT : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- TIME TIME : TDT2R_TIME_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TDT2R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; TGT at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; TIME at 0 range 16 .. 31; end record; -------------------- -- TDL2R_Register -- -------------------- -- TDL2R_DATA array element subtype TDL2R_DATA_Element is HAL.Byte; -- TDL2R_DATA array type TDL2R_DATA_Field_Array is array (0 .. 3) of TDL2R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data low register type TDL2R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : TDL2R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDL2R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -------------------- -- TDH2R_Register -- -------------------- -- TDH2R_DATA array element subtype TDH2R_DATA_Element is HAL.Byte; -- TDH2R_DATA array type TDH2R_DATA_Field_Array is array (4 .. 7) of TDH2R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type TDH2R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : TDH2R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDH2R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- RI0R_Register -- ------------------- subtype RI0R_EXID_Field is HAL.UInt18; subtype RI0R_STID_Field is HAL.UInt11; -- receive FIFO mailbox identifier register type RI0R_Register is record -- unspecified Reserved_0_0 : HAL.Bit; -- Read-only. RTR RTR : Boolean; -- Read-only. IDE IDE : Boolean; -- Read-only. EXID EXID : RI0R_EXID_Field; -- Read-only. STID STID : RI0R_STID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RI0R_Register use record Reserved_0_0 at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; -------------------- -- RDT0R_Register -- -------------------- subtype RDT0R_DLC_Field is HAL.UInt4; subtype RDT0R_FMI_Field is HAL.Byte; subtype RDT0R_TIME_Field is HAL.Short; -- mailbox data high register type RDT0R_Register is record -- Read-only. DLC DLC : RDT0R_DLC_Field; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. FMI FMI : RDT0R_FMI_Field; -- Read-only. TIME TIME : RDT0R_TIME_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RDT0R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; FMI at 0 range 8 .. 15; TIME at 0 range 16 .. 31; end record; -------------------- -- RDL0R_Register -- -------------------- -- RDL0R_DATA array element subtype RDL0R_DATA_Element is HAL.Byte; -- RDL0R_DATA array type RDL0R_DATA_Field_Array is array (0 .. 3) of RDL0R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type RDL0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : RDL0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDL0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -------------------- -- RDH0R_Register -- -------------------- -- RDH0R_DATA array element subtype RDH0R_DATA_Element is HAL.Byte; -- RDH0R_DATA array type RDH0R_DATA_Field_Array is array (4 .. 7) of RDH0R_DATA_Element with Component_Size => 8, Size => 32; -- receive FIFO mailbox data high register type RDH0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : RDH0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDH0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- RI1R_Register -- ------------------- subtype RI1R_EXID_Field is HAL.UInt18; subtype RI1R_STID_Field is HAL.UInt11; -- mailbox data high register type RI1R_Register is record -- unspecified Reserved_0_0 : HAL.Bit; -- Read-only. RTR RTR : Boolean; -- Read-only. IDE IDE : Boolean; -- Read-only. EXID EXID : RI1R_EXID_Field; -- Read-only. STID STID : RI1R_STID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RI1R_Register use record Reserved_0_0 at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; -------------------- -- RDT1R_Register -- -------------------- subtype RDT1R_DLC_Field is HAL.UInt4; subtype RDT1R_FMI_Field is HAL.Byte; subtype RDT1R_TIME_Field is HAL.Short; -- mailbox data high register type RDT1R_Register is record -- Read-only. DLC DLC : RDT1R_DLC_Field; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. FMI FMI : RDT1R_FMI_Field; -- Read-only. TIME TIME : RDT1R_TIME_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RDT1R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; FMI at 0 range 8 .. 15; TIME at 0 range 16 .. 31; end record; -------------------- -- RDL1R_Register -- -------------------- -- RDL1R_DATA array element subtype RDL1R_DATA_Element is HAL.Byte; -- RDL1R_DATA array type RDL1R_DATA_Field_Array is array (0 .. 3) of RDL1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type RDL1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : RDL1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDL1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -------------------- -- RDH1R_Register -- -------------------- -- RDH1R_DATA array element subtype RDH1R_DATA_Element is HAL.Byte; -- RDH1R_DATA array type RDH1R_DATA_Field_Array is array (4 .. 7) of RDH1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type RDH1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : RDH1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDH1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- FMR_Register -- ------------------ subtype FMR_CAN2SB_Field is HAL.UInt6; -- filter master register type FMR_Register is record -- FINIT FINIT : Boolean := True; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; -- CAN2SB CAN2SB : FMR_CAN2SB_Field := 16#E#; -- unspecified Reserved_14_31 : HAL.UInt18 := 16#A870#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FMR_Register use record FINIT at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; CAN2SB at 0 range 8 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; ------------------- -- FM1R_Register -- ------------------- -------------- -- FM1R.FBM -- -------------- -- FM1R_FBM array type FM1R_FBM_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FM1R_FBM type FM1R_FBM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FBM as a value Val : HAL.UInt28; when True => -- FBM as an array Arr : FM1R_FBM_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FM1R_FBM_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter mode register type FM1R_Register is record -- Filter mode FBM : FM1R_FBM_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FM1R_Register use record FBM at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ------------------- -- FS1R_Register -- ------------------- -------------- -- FS1R.FSC -- -------------- -- FS1R_FSC array type FS1R_FSC_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FS1R_FSC type FS1R_FSC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FSC as a value Val : HAL.UInt28; when True => -- FSC as an array Arr : FS1R_FSC_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FS1R_FSC_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter scale register type FS1R_Register is record -- Filter scale configuration FSC : FS1R_FSC_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS1R_Register use record FSC at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -------------------- -- FFA1R_Register -- -------------------- --------------- -- FFA1R.FFA -- --------------- -- FFA1R_FFA array type FFA1R_FFA_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FFA1R_FFA type FFA1R_FFA_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FFA as a value Val : HAL.UInt28; when True => -- FFA as an array Arr : FFA1R_FFA_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FFA1R_FFA_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter FIFO assignment register type FFA1R_Register is record -- Filter FIFO assignment for filter 0 FFA : FFA1R_FFA_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FFA1R_Register use record FFA at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ------------------- -- FA1R_Register -- ------------------- --------------- -- FA1R.FACT -- --------------- -- FA1R_FACT array type FA1R_FACT_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FA1R_FACT type FA1R_FACT_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FACT as a value Val : HAL.UInt28; when True => -- FACT as an array Arr : FA1R_FACT_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FA1R_FACT_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter activation register type FA1R_Register is record -- Filter active FACT : FA1R_FACT_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FA1R_Register use record FACT at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ------------------ -- F0R_Register -- ------------------ -- F0R1_FB array type F0R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 0 register 1 type F0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F0R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F1R_Register -- ------------------ -- F1R1_FB array type F1R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 1 register 1 type F1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F1R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F2R_Register -- ------------------ -- F2R1_FB array type F2R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 2 register 1 type F2R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F2R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F2R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F3R_Register -- ------------------ -- F3R1_FB array type F3R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 3 register 1 type F3R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F3R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F3R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F4R_Register -- ------------------ -- F4R1_FB array type F4R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 4 register 1 type F4R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F4R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F4R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F5R_Register -- ------------------ -- F5R1_FB array type F5R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 5 register 1 type F5R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F5R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F5R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F6R_Register -- ------------------ -- F6R1_FB array type F6R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 6 register 1 type F6R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F6R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F6R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F7R_Register -- ------------------ -- F7R1_FB array type F7R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 7 register 1 type F7R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F7R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F7R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F8R_Register -- ------------------ -- F8R1_FB array type F8R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 8 register 1 type F8R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F8R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F8R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------ -- F9R_Register -- ------------------ -- F9R1_FB array type F9R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 9 register 1 type F9R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F9R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F9R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F10R_Register -- ------------------- -- F10R1_FB array type F10R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 10 register 1 type F10R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F10R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F10R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F11R_Register -- ------------------- -- F11R1_FB array type F11R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 11 register 1 type F11R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F11R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F11R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F12R_Register -- ------------------- -- F12R1_FB array type F12R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 4 register 1 type F12R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F12R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F12R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F13R_Register -- ------------------- -- F13R1_FB array type F13R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 13 register 1 type F13R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F13R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F13R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F14R_Register -- ------------------- -- F14R1_FB array type F14R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 14 register 1 type F14R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F14R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F14R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F15R_Register -- ------------------- -- F15R1_FB array type F15R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 15 register 1 type F15R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F15R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F15R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F16R_Register -- ------------------- -- F16R1_FB array type F16R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 16 register 1 type F16R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F16R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F16R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F17R_Register -- ------------------- -- F17R1_FB array type F17R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 17 register 1 type F17R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F17R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F17R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F18R_Register -- ------------------- -- F18R1_FB array type F18R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 18 register 1 type F18R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F18R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F18R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F19R_Register -- ------------------- -- F19R1_FB array type F19R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 19 register 1 type F19R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F19R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F19R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F20R_Register -- ------------------- -- F20R1_FB array type F20R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 20 register 1 type F20R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F20R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F20R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F21R_Register -- ------------------- -- F21R1_FB array type F21R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 21 register 1 type F21R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F21R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F21R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F22R_Register -- ------------------- -- F22R1_FB array type F22R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 22 register 1 type F22R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F22R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F22R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F23R_Register -- ------------------- -- F23R1_FB array type F23R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 23 register 1 type F23R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F23R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F23R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F24R_Register -- ------------------- -- F24R1_FB array type F24R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 24 register 1 type F24R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F24R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F24R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F25R_Register -- ------------------- -- F25R1_FB array type F25R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 25 register 1 type F25R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F25R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F25R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F26R_Register -- ------------------- -- F26R1_FB array type F26R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 26 register 1 type F26R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F26R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F26R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ------------------- -- F27R_Register -- ------------------- -- F27R1_FB array type F27R1_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 27 register 1 type F27R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.Word; when True => -- FB as an array Arr : F27R1_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F27R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Controller area network type CAN_Peripheral is record -- master control register MCR : MCR_Register; -- master status register MSR : MSR_Register; -- transmit status register TSR : TSR_Register; -- receive FIFO 0 register RF0R : RF0R_Register; -- receive FIFO 1 register RF1R : RF1R_Register; -- interrupt enable register IER : IER_Register; -- interrupt enable register ESR : ESR_Register; -- bit timing register BTR : BTR_Register; -- TX mailbox identifier register TI0R : TI0R_Register; -- mailbox data length control and time stamp register TDT0R : TDT0R_Register; -- mailbox data low register TDL0R : TDL0R_Register; -- mailbox data high register TDH0R : TDH0R_Register; -- mailbox identifier register TI1R : TI1R_Register; -- mailbox data length control and time stamp register TDT1R : TDT1R_Register; -- mailbox data low register TDL1R : TDL1R_Register; -- mailbox data high register TDH1R : TDH1R_Register; -- mailbox identifier register TI2R : TI2R_Register; -- mailbox data length control and time stamp register TDT2R : TDT2R_Register; -- mailbox data low register TDL2R : TDL2R_Register; -- mailbox data high register TDH2R : TDH2R_Register; -- receive FIFO mailbox identifier register RI0R : RI0R_Register; -- mailbox data high register RDT0R : RDT0R_Register; -- mailbox data high register RDL0R : RDL0R_Register; -- receive FIFO mailbox data high register RDH0R : RDH0R_Register; -- mailbox data high register RI1R : RI1R_Register; -- mailbox data high register RDT1R : RDT1R_Register; -- mailbox data high register RDL1R : RDL1R_Register; -- mailbox data high register RDH1R : RDH1R_Register; -- filter master register FMR : FMR_Register; -- filter mode register FM1R : FM1R_Register; -- filter scale register FS1R : FS1R_Register; -- filter FIFO assignment register FFA1R : FFA1R_Register; -- filter activation register FA1R : FA1R_Register; -- Filter bank 0 register 1 F0R1 : F0R_Register; -- Filter bank 0 register 2 F0R2 : F0R_Register; -- Filter bank 1 register 1 F1R1 : F1R_Register; -- Filter bank 1 register 2 F1R2 : F1R_Register; -- Filter bank 2 register 1 F2R1 : F2R_Register; -- Filter bank 2 register 2 F2R2 : F2R_Register; -- Filter bank 3 register 1 F3R1 : F3R_Register; -- Filter bank 3 register 2 F3R2 : F3R_Register; -- Filter bank 4 register 1 F4R1 : F4R_Register; -- Filter bank 4 register 2 F4R2 : F4R_Register; -- Filter bank 5 register 1 F5R1 : F5R_Register; -- Filter bank 5 register 2 F5R2 : F5R_Register; -- Filter bank 6 register 1 F6R1 : F6R_Register; -- Filter bank 6 register 2 F6R2 : F6R_Register; -- Filter bank 7 register 1 F7R1 : F7R_Register; -- Filter bank 7 register 2 F7R2 : F7R_Register; -- Filter bank 8 register 1 F8R1 : F8R_Register; -- Filter bank 8 register 2 F8R2 : F8R_Register; -- Filter bank 9 register 1 F9R1 : F9R_Register; -- Filter bank 9 register 2 F9R2 : F9R_Register; -- Filter bank 10 register 1 F10R1 : F10R_Register; -- Filter bank 10 register 2 F10R2 : F10R_Register; -- Filter bank 11 register 1 F11R1 : F11R_Register; -- Filter bank 11 register 2 F11R2 : F11R_Register; -- Filter bank 4 register 1 F12R1 : F12R_Register; -- Filter bank 12 register 2 F12R2 : F12R_Register; -- Filter bank 13 register 1 F13R1 : F13R_Register; -- Filter bank 13 register 2 F13R2 : F13R_Register; -- Filter bank 14 register 1 F14R1 : F14R_Register; -- Filter bank 14 register 2 F14R2 : F14R_Register; -- Filter bank 15 register 1 F15R1 : F15R_Register; -- Filter bank 15 register 2 F15R2 : F15R_Register; -- Filter bank 16 register 1 F16R1 : F16R_Register; -- Filter bank 16 register 2 F16R2 : F16R_Register; -- Filter bank 17 register 1 F17R1 : F17R_Register; -- Filter bank 17 register 2 F17R2 : F17R_Register; -- Filter bank 18 register 1 F18R1 : F18R_Register; -- Filter bank 18 register 2 F18R2 : F18R_Register; -- Filter bank 19 register 1 F19R1 : F19R_Register; -- Filter bank 19 register 2 F19R2 : F19R_Register; -- Filter bank 20 register 1 F20R1 : F20R_Register; -- Filter bank 20 register 2 F20R2 : F20R_Register; -- Filter bank 21 register 1 F21R1 : F21R_Register; -- Filter bank 21 register 2 F21R2 : F21R_Register; -- Filter bank 22 register 1 F22R1 : F22R_Register; -- Filter bank 22 register 2 F22R2 : F22R_Register; -- Filter bank 23 register 1 F23R1 : F23R_Register; -- Filter bank 23 register 2 F23R2 : F23R_Register; -- Filter bank 24 register 1 F24R1 : F24R_Register; -- Filter bank 24 register 2 F24R2 : F24R_Register; -- Filter bank 25 register 1 F25R1 : F25R_Register; -- Filter bank 25 register 2 F25R2 : F25R_Register; -- Filter bank 26 register 1 F26R1 : F26R_Register; -- Filter bank 26 register 2 F26R2 : F26R_Register; -- Filter bank 27 register 1 F27R1 : F27R_Register; -- Filter bank 27 register 2 F27R2 : F27R_Register; end record with Volatile; for CAN_Peripheral use record MCR at 0 range 0 .. 31; MSR at 4 range 0 .. 31; TSR at 8 range 0 .. 31; RF0R at 12 range 0 .. 31; RF1R at 16 range 0 .. 31; IER at 20 range 0 .. 31; ESR at 24 range 0 .. 31; BTR at 28 range 0 .. 31; TI0R at 384 range 0 .. 31; TDT0R at 388 range 0 .. 31; TDL0R at 392 range 0 .. 31; TDH0R at 396 range 0 .. 31; TI1R at 400 range 0 .. 31; TDT1R at 404 range 0 .. 31; TDL1R at 408 range 0 .. 31; TDH1R at 412 range 0 .. 31; TI2R at 416 range 0 .. 31; TDT2R at 420 range 0 .. 31; TDL2R at 424 range 0 .. 31; TDH2R at 428 range 0 .. 31; RI0R at 432 range 0 .. 31; RDT0R at 436 range 0 .. 31; RDL0R at 440 range 0 .. 31; RDH0R at 444 range 0 .. 31; RI1R at 448 range 0 .. 31; RDT1R at 452 range 0 .. 31; RDL1R at 456 range 0 .. 31; RDH1R at 460 range 0 .. 31; FMR at 512 range 0 .. 31; FM1R at 516 range 0 .. 31; FS1R at 524 range 0 .. 31; FFA1R at 532 range 0 .. 31; FA1R at 540 range 0 .. 31; F0R1 at 576 range 0 .. 31; F0R2 at 580 range 0 .. 31; F1R1 at 584 range 0 .. 31; F1R2 at 588 range 0 .. 31; F2R1 at 592 range 0 .. 31; F2R2 at 596 range 0 .. 31; F3R1 at 600 range 0 .. 31; F3R2 at 604 range 0 .. 31; F4R1 at 608 range 0 .. 31; F4R2 at 612 range 0 .. 31; F5R1 at 616 range 0 .. 31; F5R2 at 620 range 0 .. 31; F6R1 at 624 range 0 .. 31; F6R2 at 628 range 0 .. 31; F7R1 at 632 range 0 .. 31; F7R2 at 636 range 0 .. 31; F8R1 at 640 range 0 .. 31; F8R2 at 644 range 0 .. 31; F9R1 at 648 range 0 .. 31; F9R2 at 652 range 0 .. 31; F10R1 at 656 range 0 .. 31; F10R2 at 660 range 0 .. 31; F11R1 at 664 range 0 .. 31; F11R2 at 668 range 0 .. 31; F12R1 at 672 range 0 .. 31; F12R2 at 676 range 0 .. 31; F13R1 at 680 range 0 .. 31; F13R2 at 684 range 0 .. 31; F14R1 at 688 range 0 .. 31; F14R2 at 692 range 0 .. 31; F15R1 at 696 range 0 .. 31; F15R2 at 700 range 0 .. 31; F16R1 at 704 range 0 .. 31; F16R2 at 708 range 0 .. 31; F17R1 at 712 range 0 .. 31; F17R2 at 716 range 0 .. 31; F18R1 at 720 range 0 .. 31; F18R2 at 724 range 0 .. 31; F19R1 at 728 range 0 .. 31; F19R2 at 732 range 0 .. 31; F20R1 at 736 range 0 .. 31; F20R2 at 740 range 0 .. 31; F21R1 at 744 range 0 .. 31; F21R2 at 748 range 0 .. 31; F22R1 at 752 range 0 .. 31; F22R2 at 756 range 0 .. 31; F23R1 at 760 range 0 .. 31; F23R2 at 764 range 0 .. 31; F24R1 at 768 range 0 .. 31; F24R2 at 772 range 0 .. 31; F25R1 at 776 range 0 .. 31; F25R2 at 780 range 0 .. 31; F26R1 at 784 range 0 .. 31; F26R2 at 788 range 0 .. 31; F27R1 at 792 range 0 .. 31; F27R2 at 796 range 0 .. 31; end record; -- Controller area network CAN1_Periph : aliased CAN_Peripheral with Import, Address => CAN1_Base; -- Controller area network CAN2_Periph : aliased CAN_Peripheral with Import, Address => CAN2_Base; end STM32_SVD.CAN;
-- This spec has been automatically generated from STM32F429x.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 -- Independent Data register IDR : IDR_IDR_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, 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; -- Control register type CR_Register is record -- Write-only. Control regidter CR : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record CR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Cyclic Redundancy Check (CRC) 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; 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; end record; -- Cyclic Redundancy Check (CRC) unit CRC_Periph : aliased CRC_Peripheral with Import, Address => System'To_Address (16#40023000#); end STM32_SVD.CRC;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body OTM8009A is ADDR_SHIFT_CMD : constant := 16#00#; ----------- -- Write -- ----------- procedure Write (This : in out OTM8009A_Device; Address : UInt16; Data : DSI_Data) is MSB, LSB : UInt8; begin MSB := UInt8 (Shift_Right (Address and 16#FF00#, 8)); LSB := UInt8 (Address and 16#FF#); if LSB /= This.Current_Shift then This.DSI_IO_WriteCmd ((ADDR_SHIFT_CMD, LSB)); This.Current_Shift := LSB; end if; This.DSI_IO_WriteCmd (MSB & Data); end Write; ----------- -- Write -- ----------- procedure Write (This : in out OTM8009A_Device; S_Addr : UInt8; Data : DSI_Data) is begin This.DSI_IO_WriteCmd (S_Addr & Data); end Write; ---------------- -- Initialize -- ---------------- procedure Initialize (This : in out OTM8009A_Device; Color_Mode : OTM8009A_Color_Mode; Orientation : LCD_Orientation) is begin -- Enable CMD2 to access vendor specific commands -- Enter in command 2 mode and set EXTC to enable address shift -- function (16#00#) This.Write (Address => 16#FF00#, Data => (16#80#, 16#09#, 16#01#)); -- Enter ORISE Command 2 This.Write (Address => 16#FF80#, Data => (16#80#, 16#09#)); ---------------------------------------------------------------------- -- SD_PCH_CTRL - 0xC480h - 129th parameter - Default 0x00 -- -- Set SD_PT -- -- -> Source output level during porch and non-display area to GND -- This.Write (Address => 16#C480#, Data => (1 => 16#30#)); This.Time.Delay_Milliseconds (10); -- Not documented... This.Write (Address => 16#C48A#, Data => (1 => 16#40#)); This.Time.Delay_Milliseconds (10); ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- PWR_CTRL4 - 0xC5B1h - 178th parameter - Default 0xA8 -- -- Set gvdd_en_test -- -- -> enable GVDD test mode This.Write (Address => 16#C5B1#, Data => (1 => 16#A9#)); ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- PWR_CTRL2 - 0xC590h - 146th parameter - Default 0x79 -- -- Set pump 4 vgh voltage -- -- -> from 15.0v down to 13.0v -- -- Set pump 5 vgh voltage -- -- -> from -12.0v downto -9.0v -- This.Write (Address => 16#C591#, Data => (1 => 16#34#)); ---------------------------------------------------------------------- -- P_DRV_M - 0xC0B4h - 181th parameter - Default 0x00 -- -> Column inversion This.Write (Address => 16#C0B4#, Data => (1 => 16#50#)); -- VCOMDC - 0xD900h - 1st parameter - Default 0x39h -- VCOM Voltage settings -- -> from - 1.0000v down to - 1.2625v This.Write (Address => 16#D900#, Data => (1 => 16#4E#)); -- Oscillator adjustment for Idle/Normal mode (LPDT only) set to 65Hz -- (default is 60Hz) This.Write (Address => 16#C181#, Data => (1 => 16#66#)); -- Video mode internal This.Write (Address => 16#C1A1#, Data => (1 => 16#08#)); -- PWR_CTRL2 - 0xC590h - 147h parameter - Default 0x00 -- Set pump 4&5 x6 -- -> ONLY VALID when PUMP4_EN_ASDM_HV = "0" This.Write (Address => 16#C592#, Data => (1 => 16#01#)); -- PWR_CTRL2 - 0xC590h - 150th parameter - Default 0x33h -- Change pump4 clock ratio -- -> from 1 line to 1/2 line This.Write (Address => 16#C595#, Data => (1 => 16#34#)); -- GVDD/NGVDD settings This.Write (Address => 16#D800#, Data => (16#79#, 16#79#)); -- PWR_CTRL2 - 0xC590h - 149th parameter - Default 0x33h -- Rewrite the default value ! This.Write (Address => 16#C594#, Data => (1 => 16#33#)); -- SD_CTRL = 0xC0A2h - 164th parameter - default 0x6h -- Panel display timing Setting 3 This.Write (Address => 16#C0A3#, Data => (1 => 16#1B#)); -- PWR_CTRL1 - 0xC580h - 131st parameter - Default 0x80h -- Power control 1 This.Write (Address => 16#C582#, Data => (1 => 16#83#)); -- SD_PCH_CTRL - 0xC480h - 130th parameter - default 84h -- Source driver precharge This.Write (Address => 16#C481#, Data => (1 => 16#83#)); -- RGB Video mode setting: This.Write (Address => 16#C1A1#, Data => (1 => 16#0E#)); -- Panel type setting: -- Normal panel: ZIGOPT=1, SIGSET=0 This.Write (Address => 16#B3A6#, Data => (16#00#, 16#01#)); -- GOAVST This.Write (Address => 16#CE80#, Data => (16#85#, 16#01#, 16#00#, 16#84#, 16#01#, 16#00#)); -- GOACLKA1 setting This.Write (Address => 16#CEA0#, Data => (16#18#, 16#04#, 16#03#, 16#39#, 16#00#, 16#00#, 16#00#)); -- GOACLKA2 setting This.Write (Address => 16#CEA7#, Data => (16#18#, 16#03#, 16#03#, 16#3A#, 16#00#, 16#00#, 16#00#)); -- GOACLKA3 setting This.Write (Address => 16#CEB0#, Data => (16#18#, 16#02#, 16#03#, 16#3B#, 16#00#, 16#00#, 16#00#)); -- GOACLKA4 setting This.Write (Address => 16#CEB7#, Data => (16#18#, 16#01#, 16#03#, 16#3C#, 16#00#, 16#00#, 16#00#)); -- GOA ECLK setting This.Write (Address => 16#CFC0#, Data => (16#01#, 16#01#, 16#20#, 16#20#, 16#00#, 16#00#)); -- GOA Other options This.Write (Address => 16#CFC6#, Data => (1 => 16#01#)); -- GOA Signal toggle setting This.Write (Address => 16#CFC7#, Data => (16#02#, 16#00#, 16#00#)); -- undocumented... This.Write (Address => 16#CFD0#, Data => (1 => 16#00#)); This.Write (Address => 16#CB80#, Data => (1 .. 10 => 16#00#)); This.Write (Address => 16#CB90#, Data => (1 .. 15 => 16#00#)); This.Write (Address => 16#CBA0#, Data => (1 .. 15 => 16#00#)); This.Write (Address => 16#CBB0#, Data => (1 .. 10 => 16#00#)); This.Write (Address => 16#CBC0#, Data => (16#00#, 16#04#, 16#04#, 16#04#, 16#04#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#)); This.Write (Address => 16#CBD0#, Data => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#04#, 16#04#, 16#04#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#)); This.Write (Address => 16#CBE0#, Data => (1 .. 10 => 16#00#)); This.Write (Address => 16#CBF0#, Data => (1 .. 10 => 16#FF#)); This.Write (Address => 16#CC80#, Data => (16#00#, 16#26#, 16#09#, 16#0B#, 16#01#, 16#25#, 16#00#, 16#00#, 16#00#, 16#00#)); This.Write (Address => 16#CC90#, Data => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#26#, 16#0A#, 16#0C#, 16#02#)); This.Write (Address => 16#CCA0#, Data => (16#25#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#)); This.Write (Address => 16#CCB0#, Data => (16#00#, 16#25#, 16#0C#, 16#0A#, 16#02#, 16#26#, 16#00#, 16#00#, 16#00#, 16#00#)); This.Write (Address => 16#CCC0#, Data => (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#25#, 16#0B#, 16#09#, 16#01#)); This.Write (Address => 16#CCD0#, Data => (16#26#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#)); ----------------------------------------------------------- -- PWR_CTRL1 - 0xc580h - 130th parameter - default 0x00 -- -- Pump 1 min and max DM -- This.Write (Address => 16#C581#, Data => (1 => 16#66#)); This.Write (Address => 16#F5B6#, Data => (1 => 16#06#)); ----------------------------------------------------------- -- Exit CMD2 mode This.Write (Address => 16#FF00#, Data => (16#FF#, 16#FF#, 16#FF#)); ---------------------------------- -- Standard DCS Initialization -- ---------------------------------- -- NOP - goes back to DCS std command ? This.Write (Address => CMD_NOP, Data => (1 .. 0 => <>)); -- Gamma correction 2.2+ table (HSDT possible) This.Write (Address => 16#E100#, Data => (16#00#, 16#09#, 16#0F#, 16#0E#, 16#07#, 16#10#, 16#0B#, 16#0A#, 16#04#, 16#07#, 16#0B#, 16#08#, 16#0F#, 16#10#, 16#0A#, 16#01#)); -- Gamma correction 2.2- table (HSDT possible) This.Write (Address => 16#E200#, Data => (16#00#, 16#09#, 16#0F#, 16#0E#, 16#07#, 16#10#, 16#0B#, 16#0A#, 16#04#, 16#07#, 16#0B#, 16#08#, 16#0F#, 16#10#, 16#0A#, 16#01#)); -- Send Sleep Out command to display : no parameter This.Write (S_Addr => CMD_SLPOUT, Data => (1 .. 0 => <>)); -- Wait for Sleep Out exit This.Time.Delay_Milliseconds (120); case Color_Mode is when RGB565 => This.Write (S_Addr => CMD_COLMOD, Data => (1 => COLMOD_RGB565)); when RGB888 => This.Write (S_Addr => CMD_COLMOD, Data => (1 => COLMOD_RGB888)); end case; if Orientation = Landscape then -- Send command to configure display in landscape orientation -- mode. By default the orientation mode is portrait This.Write (S_Addr => CMD_MADCTR, Data => (1 => MADCTR_MODE_LANDSCAPE)); -- CASET value (Column Address Set) : X direction LCD GRAM -- boundaries depending on LCD orientation mode and PASET value (Page -- Address Set) : Y direction LCD GRAM boundaries depending on LCD -- orientation mode -- XS[15:0] = 16#000 = 0, XE[15:0] = 16#31F = 799 for landscape mode -- apply to CASET -- YS[15:0] = 16#000 = 0, YE[15:0] = 16#1DF = 479 for landscape mode -- apply to PASET This.Write (S_Addr => CMD_CASET, Data => (16#00#, 16#00#, 16#03#, 16#1F#)); This.Write (S_Addr => CMD_PASET, Data => (16#00#, 16#00#, 16#01#, 16#DF#)); else This.Write (S_Addr => CMD_MADCTR, Data => (1 => MADCTR_MODE_PORTRAIT)); This.Write (S_Addr => CMD_CASET, Data => (16#00#, 16#00#, 16#01#, 16#DF#)); This.Write (S_Addr => CMD_PASET, Data => (16#00#, 16#00#, 16#03#, 16#1F#)); end if; -------------------------------------------------------------- -- CABC : Content Adaptive Backlight Control section start -- -------------------------------------------------------------- -- Note : -- defaut is 0 (lowest Brightness), -- 0xFF is highest Brightness, This.Write (S_Addr => CMD_WRDISBV, Data => (1 => 16#FF#)); -- defaut is 0, try 0x2C - Brightness Control Block, Display Dimming -- & BackLight on This.Write (S_Addr => CMD_WRCTRLD, Data => (1 => 16#2C#)); -- defaut is 0, try 0x02 - image Content based Adaptive Brightness -- [Still Picture] This.Write (S_Addr => CMD_WRCABC, Data => (1 => 16#02#)); -- defaut is 0 (lowest Brightness), 0xFF is highest Brightness This.Write (S_Addr => CMD_WRCABCMB, Data => (1 => 16#FF#)); ------------------------------------------------------------ -- CABC : Content Adaptive Backlight Control section end -- ------------------------------------------------------------ -- Send Command Display On This.Write (S_Addr => CMD_DISPON, Data => (1 => 16#00#)); -- NOP command This.Write (S_Addr => CMD_NOP, Data => (1 => 16#00#)); -- Send Command GRAM memory write (no parameters) : this initiates -- frame write via other DSI commands sent by DSI host from LTDC -- incoming pixels in video mode This.Write (S_Addr => CMD_RAMWR, Data => (1 => 16#00#)); end Initialize; --------------------- -- DSI_IO_WriteCmd -- --------------------- procedure DSI_IO_WriteCmd (This : in out OTM8009A_Device; Data : HAL.DSI.DSI_Data) is begin if Data'Length = 0 then return; elsif Data'Length = 1 then This.DSI_Host.DSI_Short_Write (This.Channel_ID, Mode => DCS_Short_Pkt_Write_P0, Param1 => Data (1), Param2 => 16#00#); elsif Data'Length = 2 then This.DSI_Host.DSI_Short_Write (This.Channel_ID, Mode => DCS_Short_Pkt_Write_P1, Param1 => Data (1), Param2 => Data (2)); else This.DSI_Host.DSI_Long_Write (This.Channel_ID, Mode => DCS_Long_Pkt_Write, Param1 => Data (Data'First), Parameters => Data (Data'First + 1 .. Data'Last)); end if; end DSI_IO_WriteCmd; end OTM8009A;
-- 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; use Ada.Text_IO; with CPU_Instructions; use CPU_Instructions; with Debug_Logs; use Debug_Logs; with DG_Types; use DG_Types; with Devices; with Devices.Bus; with Memory; use Memory; package body Decoder is -- Match_Instruction looks for a match for the opcode in the instruction set and returns -- the corresponding mnemonic. It is used only by the decoderGenAllPossOpcodes() below when -- the emulator is initialising. procedure Match_Instruction (Opcode : in Word_T; Mnem : out Instr_Mnemonic_T; Found : out Boolean) is Instr_Char : Instr_Char_Rec; Tail : Word_T; begin for I in Instr_Mnemonic_T range Instr_Mnemonic_T'Range loop Instr_Char := Instruction_Set (I); if (Opcode and Instr_Char.Mask) = Instr_Char.Bits then case I is when I_LEF => null; when I_ADC | I_ADD | I_AND | I_COM | I_INC | I_MOV | I_NEG | I_SUB => -- these instructions are not allowed to end in 1000(2) or 1001(2) -- as those patterns are used for Eagle instructions Tail := Opcode and 16#000f#; if Tail /= 16#0008# and Tail /= 16#0009# then Mnem := I; Found := True; return; end if; when others => Mnem := I; Found := True; return; end case; end if; end loop; Mnem := I_ZEX; Found := False; return; end Match_Instruction; -- procedure Generate_All_Possible_Opcodes is -- Mnem : Instr_Mnemonic_T; -- Found : Boolean; -- begin -- for N in Opcode_Lookup_T'Range loop -- Match_Instruction (Word_T (N), Mnem, Found); -- if Found then -- Opcode_Lookup_Arr (N).Exists := True; -- Opcode_Lookup_Arr (N).Mnem := Mnem; -- else -- Opcode_Lookup_Arr (N).Exists := False; -- end if; -- end loop; -- end Generate_All_Possible_Opcodes; function Generate_All_Possible_Opcodes return Opcode_Lookup_T is Lookup : Opcode_Lookup_T; Mnem : Instr_Mnemonic_T; Found : Boolean; begin for N in Opcode_Lookup_T'Range loop Match_Instruction (Word_T (N), Mnem, Found); if Found then Lookup(N).Exists := True; Lookup(N).Mnem := Mnem; else Lookup(N).Exists := False; end if; end loop; return Lookup; end Generate_All_Possible_Opcodes; -- Instruction_Lookup looks up an opcode in the opcode lookup table and returns -- the corresponding mnemonic. This needs to be as quick as possible function Instruction_Lookup (Opcode : in Word_T; LEF_Mode : in Boolean) return Instr_Mnemonic_T is Mnem : Instr_Mnemonic_T; begin -- special case, if LEF mode is enabled then ALL I/O instructions are interpreted as LEF if LEF_Mode then -- check for I/O instruction if (Opcode and 2#1110_0000_0000_0000#) = 2#0110_0000_0000_0000# then return I_LEF; end if; end if; Mnem := Opcode_Lookup_Arr (Integer (Opcode)).Mnem; -- catch unimplemented Eagle instructions... if Mnem = I_ADC and (((Opcode and 2#0000_0000_0000_1111#) = 2#0000_0000_0000_1001#) or ((Opcode and 2#0000_0000_0000_1111#) = 2#0000_0000_0000_1000#)) then raise Decode_Failed with "Unimplemented Eagle instruction: " & Word_To_String(Opcode, Binary, 16, true); end if; return Mnem; end Instruction_Lookup; procedure Init is begin Opcode_Lookup_Arr := Generate_All_Possible_Opcodes; end; function Char_Carry (Cr : Carry_T) return Character is begin case Cr is when None => return ' '; when Z => return 'Z'; when O => return 'O'; when C => return 'C'; end case; end Char_Carry; function Char_Indirect (I : Boolean) return Character is begin if I then return '@'; end if; return ' '; end Char_Indirect; function Char_IO_Flag (IO : IO_Flag_T) return Character is begin case IO is when None => return ' '; when S => return 'S'; when C => return 'C'; when P => return 'P'; end case; end Char_IO_Flag; function Char_No_Load (N : Boolean) return Character is begin if N then return '#'; end if; return ' '; end Char_No_Load; function Char_Shift (Sh : Shift_T) return Character is begin case Sh is when None => return ' '; when L => return 'L'; when R => return 'R'; when S => return 'S'; end case; end Char_Shift; function Decode_2bit_Imm (I2 : Word_T) return Unsigned_16 is begin -- to expand range (by 1!) 1 is subtracted from operand by the Assembler... return Word_To_Unsigned_16(I2)+ 1; end Decode_2bit_Imm; function Decode_8bit_Disp (D8 : Byte_T; Mode : Mode_T) return Integer_16 is begin if Mode = Absolute then return Integer_16(D8); else return Integer_16(Byte_To_Integer_8(D8)); end if; end Decode_8bit_Disp; function Decode_15bit_Disp (D15 : in Word_T; Mode : in Mode_T) return Integer_16 is begin if Mode = Absolute then return Integer_16 (D15 and 16#7fff#); -- zero extend end if; if Test_W_Bit (D15, 1) then return Word_To_Integer_16 (D15 or 2#1000_0000_0000_0000#); else return Integer_16 (D15 and 2#0011_1111_1111_1111#); end if; -- return Word_To_Integer_16(Shift_Left(D15, 1)) / 2; end Decode_15bit_Disp; -- TODO Test/verify this procedure Decode_16bit_Byte_Disp (D16 : in Word_T; Disp_16 : out Integer_16; Lo_Byte : out Boolean) is begin Lo_Byte := Test_W_Bit (D16, 15); Disp_16 := Word_To_Integer_16(D16) / 2; end Decode_16bit_Byte_Disp; function Decode_31bit_Disp (W_1, W_2 : in Word_T; Mode : in Mode_T) return Integer_32 is Dw_1, Dw_2 : Dword_T; Disp : Integer_32; begin Dw_1 := Shift_Left(Dword_T(W_1 and 16#7fff#), 16); Dw_2 := Dword_T(W_2); if Mode /= Absolute then if Test_W_Bit (W_1, 1) then Dw_1 := Dw_1 or 16#8000_0000#; end if; end if; Disp := Dword_To_Integer_32(Dw_1 or Dw_2); return Disp; end Decode_31bit_Disp; function Decode_Carry (Cr : Word_T) return Carry_T is begin case Cr is when 0 => return None; when 1 => return Z; when 2 => return O; when 3 => return C; when others => return None; -- TODO error handling end case; end Decode_Carry; function Decode_IO_Flag (W : Word_T) return IO_Flag_T is begin case W is when 0 => return None; when 1 => return S; -- Set when 2 => return C; -- Clear when 3 => return P; -- Pulse when others => return None; -- TODO error handling end case; end Decode_IO_Flag; function Decode_IO_Test (W : Word_T) return IO_Test_T is begin case W is when 0 => return BN; when 1 => return BZ; when 2 => return DN; when 3 => return DZ; when others => raise Decode_Failed with "Unknown I/O Test"; end case; end Decode_IO_Test; function Decode_Mode (W : Mode_Num_T) return Mode_T is begin case W is when 0 => return Absolute; when 1 => return PC; when 2 => return AC2; when 3 => return AC3; end case; end Decode_Mode; function Decode_Shift (Sh : Word_T) return Shift_T is begin case Sh is when 0 => return None; when 1 => return L; when 2 => return R; when 3 => return S; when others => return None; -- TODO error handling end case; end Decode_Shift; function Decode_Skip (Sk : Word_T) return Skip_T is begin case Sk is when 0 => return None; when 1 => return SKP; when 2 => return SZC; when 3 => return SNC; when 4 => return SZR; when 5 => return SNR; when 6 => return SEZ; when 7 => return SBN; when others => return None; -- TODO error handling end case; end Decode_Skip; function String_Mode (W : Mode_T) return String is begin case W is when Absolute => return ""; when PC => return ",PC"; when AC2 => return ",AC2"; when AC3 => return ",AC3"; end case; end String_Mode; function String_Skip (Sk : Skip_T) return String is begin if Sk = None then return ""; end if; return Sk'Image; end String_Skip; function Instruction_Decode (Opcode : in Word_T; PC : Phys_Addr_T; LEF_Mode : Boolean; IO_On : Boolean; ATU_On : Boolean; Disassemble : Boolean; Radix : Number_Base_T) return Decoded_Instr_T is Decoded : Decoded_Instr_T; Instr : Instr_Mnemonic_T; Tmp_8bit : Byte_T; begin Decoded.Disassembly := To_Unbounded_String ("; Unknown instruction"); Instr := Instruction_Lookup (Opcode, LEF_Mode); Decoded.Instruction := Instr; Decoded.Mnemonic := Instruction_Set (Instr).Mnemonic; Decoded.Disassembly := Instruction_Set (Instr).Mnemonic; Decoded.Format := Instruction_Set (Instr).Instr_Fmt; Decoded.Instr_Type := Instruction_Set (Instr).Instr_Class; Decoded.Instr_Len := Instruction_Set (Instr).Instr_Len; Decoded.Disp_Offset := Instruction_Set (Instr).Disp_Offset; case Decoded.Format is when IMM_MODE_2_WORD_FMT => -- eg. XNADI, XNSBI, XNSUB, XWADI, XWSBI Decoded.Imm_U16 := Decode_2bit_Imm (Get_W_Bits (Opcode, 1, 2)); Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Imm_U16), Radix, 8, false, true) & "," & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & " [2-Word Instruction]"; end if; when IMM_ONEACC_FMT => -- eg. ADI, HXL, NADI, SBI, WADI, WLSI, WSBI -- N.B. Immediate value is encoded by assembler to be one less than required -- This is handled by decode2bitImm Decoded.Imm_U16 := Decode_2bit_Imm (Get_W_Bits (Opcode, 1, 2)); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Imm_U16'Image & Decoded.Ac'Image; end if; when IO_FLAGS_DEV_FMT => -- eg. NIO Decoded.IO_Flag := Decode_IO_Flag (Get_W_Bits (Opcode, 8, 2)); Decoded.IO_Dev := Dev_Num_T(Get_W_Bits (Opcode, 10, 6)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & Decoded.IO_Flag'Image & " " & Devices.Bus.Actions.Get_Device_Name_Or_Number(Decoded.IO_Dev); end if; when IO_TEST_DEV_FMT => -- eg. SKPn Decoded.IO_Test := Decode_IO_Test (Get_W_Bits (Opcode, 8, 2)); Decoded.IO_Dev := Dev_Num_T(Get_W_Bits (Opcode, 10, 6)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & Decoded.IO_Test'Image & " " & Devices.Bus.Actions.Get_Device_Name_Or_Number(Decoded.IO_Dev); end if; when LNDO_4_WORD_FMT => -- also LWDO Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 1, 2)); Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_31 := Decode_31bit_Disp (Decoded.Word_2, Decoded.Word_3, Decoded.Mode); Decoded.Imm_U16 := Unsigned_16(Memory.RAM.Read_Word (PC + 3)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Int_To_String (Integer(Decoded.Imm_U16), Radix, 8, false, true) & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_31), Radix, 12, false, true) & String_Mode(Decoded.Mode) & " [4-Word Instruction]"; end if; when NOACC_MODE_2_WORD_FMT => -- eg. XPEFB Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decode_16bit_Byte_Disp (Decoded.Word_2, Decoded.Disp_15, Decoded.Low_Byte) ; if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & " " & Low_Byte_To_Char (Decoded.Low_Byte) &" [2-Word Instruction]"; end if; when NOACC_MODE_3_WORD_FMT => -- eg. LPEFB Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Disp_32 := Unsigned_32(Memory.RAM.Read_Dword (PC + 1)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Int_To_String (Unsigned_32_To_Integer(Decoded.Disp_32), Radix, 11, false, true) & "," & String_Mode(Decoded.Mode) & " [3-Word Instruction]"; end if; when NOACC_MODE_IMM_IND_3_WORD_FMT => -- eg. LNADI, LNSBI Decoded.Imm_U16 := Decode_2bit_Imm (Get_W_Bits (Opcode, 1, 2)); Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); Decoded.Disp_31 := Decode_31bit_Disp (Decoded.Word_2, Decoded.Word_3, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Int_To_String (Integer(Decoded.Imm_U16), Radix, 8, false, true) & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_31), Radix, 12, false, true) & String_Mode(Decoded.Mode) & " [3-Word Instruction]"; end if; when NOACC_MODE_IND_2_WORD_E_FMT => -- eg. EJSR, PSHJ Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 6, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & " [2-Word Instruction]"; end if; when NOACC_MODE_IND_2_WORD_X_FMT => -- eg. XJSR Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & " [2-Word Instruction]"; end if; when NOACC_MODE_IND_3_WORD_FMT => -- eg. LJMP/LJSR, LNISZ, LNDSZ, LWDS Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); Decoded.Disp_31 := Decode_31bit_Disp (Decoded.Word_2, Decoded.Word_3, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_31), Radix, 12, false, true) & String_Mode(Decoded.Mode); end if; when NOACC_MODE_IND_4_WORD_FMT => -- eg. LCALL Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_31 := Decode_31bit_Disp (Decoded.Word_2, Memory.RAM.Read_Word (PC + 2), Decoded.Mode); Decoded.Arg_Count := Integer(Word_To_Integer_16(Memory.RAM.Read_Word (PC + 3))); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_31), Radix, 12, false, true) & String_Mode(Decoded.Mode) & "," & Decoded.Arg_Count'Image & " [4-Word Instruction]"; end if; when NOACC_MODE_IND_3_WORD_XCALL_FMT => -- Unique to XCALL? Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); Decoded.Arg_Count := Integer(Decoded.Word_3); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & "," & Decoded.Arg_Count'Image & " [3-Word Instruction]"; end if; when NOVA_DATA_IO_FMT => -- eg. DOA/B/C, DIA/B/C Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); if Decoded.Instruction = I_DIA or Decoded.Instruction = I_DIB or Decoded.Instruction = I_DIC then Decoded.IO_Dir := Data_In; else Decoded.IO_Dir := Data_Out; end if; case Decoded.Instruction is when I_DIA | I_DOA => Decoded.IO_Reg := A; when I_DIB | I_DOB => Decoded.IO_Reg := B; when I_DIC | I_DOC => Decoded.IO_Reg := C; when others => null; end case; Decoded.IO_Flag := Decode_IO_Flag (Get_W_Bits (Opcode, 8, 2)); Decoded.IO_Dev := Dev_Num_T(Word_To_Unsigned_16(Get_W_Bits (Opcode, 10, 6))); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & Char_IO_Flag (Decoded.IO_Flag) & " " & Decoded.Ac'Image & "," & Devices.Bus.Actions.Get_Device_Name_Or_Number (Dev_Num_T(Decoded.IO_Dev)); end if; when NOVA_NOACC_EFF_ADDR_FMT => -- eg. DSZ, ISZ, JMP, JSR Decoded.Ind := Test_W_Bit(Opcode, 5); Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 6, 2))); Decoded.Disp_15 := Decode_8bit_Disp(Get_Lower_Byte(Opcode), Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode); end if; when NOVA_ONEACC_EFF_ADDR_FMT => -- eg. LDA, STA Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Ind := Test_W_Bit(Opcode, 5); Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 6, 2))); Decoded.Disp_15 := Decode_8bit_Disp(Get_Lower_Byte(Opcode), Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode); end if; when NOVA_TWOACC_MULT_OP_FMT => -- eg. ADC, ADD, AND, COM Decoded.Acs := AC_ID(Get_W_Bits (Opcode, 1, 2)); Decoded.Acd := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Sh := Decode_Shift (Get_W_Bits (Opcode, 8, 2)); Decoded.Carry := Decode_Carry (Get_W_Bits (Opcode, 10, 2)); Decoded.No_Load := Test_W_Bit (Opcode, 12); Decoded.Skip := Decode_Skip(Get_W_Bits(Opcode, 13, 3)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & Char_Carry(Decoded.Carry) & Char_Shift (Decoded.Sh) & Char_No_Load (Decoded.No_Load) & " " & Decoded.Acs'Image & "," & Decoded.Acd'Image & " " & String_Skip (Decoded.Skip); end if; when ONEACC_1_WORD_FMT => -- eg. CVWN, HLV, LDAFP Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image; end if; when ONEACC_IMM_2_WORD_FMT => -- eg. IORI Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Int_To_String (Integer(Decoded.Word_2), Radix, 8, false, true) & "," & Decoded.Ac'Image & " [2-Word Instruction]"; end if; when ONEACC_IMM_3_WORD_FMT => -- eg. WADDI, WUGTI, WXORI Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Imm_DW := RAM.Read_Dword (PC + 1); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Dword_To_String(Decoded.Imm_DW, Radix, 11, false ) & "," & Decoded.Ac'Image & " [3-Word Instruction]"; end if; when ONEACC_IMMDWD_3_WORD_FMT => -- eg. WANDI, WIORI, WLDAI Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Imm_DW := Memory.RAM.Read_Dword (PC + 1); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Dword_To_String(Decoded.Imm_DW, Radix, 11, false ) & "," & Decoded.Ac'Image & " [3-Word Instruction]"; end if; when ONEACC_IMMWD_2_WORD_FMT => -- eg. ADDI, NADDI, NLDAI, WASHI, WSEQI, WLSHI, WNADI Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Imm_S16 := Word_To_Integer_16(Decoded.Word_2); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Int_To_String (Integer(Decoded.Imm_S16), Radix, 8, false, true) & "," & Decoded.Ac'Image & " [2-Word Instruction]"; end if; when ONEACC_MODE_2_WORD_X_B_FMT => -- eg. XLDB, XLEFB, XSTB Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 1, 2))); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decode_16bit_Byte_Disp (D16 => Decoded.Word_2, Disp_16 => Decoded.Disp_15, Lo_Byte => Decoded.Low_Byte); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15 * 2), Radix, 8, false, true) & "+" & Low_Byte_To_Char (Decoded.Low_Byte) & String_Mode(Decoded.Mode) & " [2-Word Instruction]"; end if; when ONEACC_MODE_3_WORD_FMT => -- eg. LLDB, LLEFB Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 1, 2))); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); Decoded.Disp_32 := Unsigned_32(Dword_From_Two_Words(Decoded.Word_2,Decoded.Word_3)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Int_To_String (Unsigned_32_To_Integer(Decoded.Disp_32), Radix, 11, false, true) & String_Mode(Decoded.Mode) & " [3-Word Instruction]"; end if; when ONEACC_MODE_IND_2_WORD_E_FMT => -- eg. DSPA, ELDA, ELDB, ELEF, ESTA Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 6, 2))); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & " [2-Word Instruction]"; end if; when ONEACC_MODE_IND_2_WORD_X_FMT => -- eg. XNLDA, XWMUL & many others Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 1, 2))); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Char_Indirect(Decoded.Ind) & --Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & Decoded.Disp_15'Image & "." & String_Mode(Decoded.Mode) & " [2-Word Instruction]"; end if; when ONEACC_MODE_IND_3_WORD_FMT => -- eg. LLEF, LNADD/SUB LNDIV, LNLDA/STA, LNMUL, LWLDA/LWSTA, LNLDA Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 1, 2))); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); Decoded.Disp_31 := Decode_31bit_Disp (Decoded.Word_2, Decoded.Word_3, Decoded.Mode); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " &Decoded.Ac'Image & "," & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_31), Radix, 11, false, true) & String_Mode(Decoded.Mode) & " [3-Word Instruction]"; end if; when SPLIT_8BIT_DISP_FMT => -- eg. WBR, always a signed displacement Tmp_8bit := Byte_T(Get_W_Bits(Opcode, 1, 4)); Tmp_8bit := Shift_Left (Tmp_8bit, 4); Tmp_8bit := Tmp_8bit or Byte_T(Get_W_Bits(Opcode, 6, 4)); Decoded.Disp_8 := Integer_8(Decode_8bit_Disp(Tmp_8bit, Decoder.PC)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Disp_8'Image; end if; when THREE_WORD_DO_FMT => -- eg. XNDO Decoded.Mode := Decode_Mode(Mode_Num_T(Get_W_Bits(Opcode, 3, 2))); Decoded.Ac := AC_ID(Get_W_Bits (Opcode, 1, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Ind := Test_W_Bit(Decoded.Word_2, 0); Decoded.Disp_15 := Decode_15bit_Disp(Decoded.Word_2, Decoded.Mode); Decoded.Word_3 := Memory.RAM.Read_Word (PC + 2); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Ac'Image & "," & Int_To_String (Integer(Decoded.Word_3), Radix, 11, false, true) & " " & Char_Indirect(Decoded.Ind) & Int_To_String (Integer(Decoded.Disp_15), Radix, 8, false, true) & String_Mode(Decoded.Mode) & " [3-Word Instruction]"; end if; when TWOACC_1_WORD_FMT => -- eg. ANC, BTO, WSUB and MANY others Decoded.Acs := AC_ID(Get_W_Bits (Opcode, 1, 2)); Decoded.Acd := AC_ID(Get_W_Bits (Opcode, 3, 2)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Acs'Image & "," & Decoded.Acd'Image; end if; when TWOACC_IMM_2_WORD_FMT => -- eg. CIOI Decoded.Acs := AC_ID(Get_W_Bits (Opcode, 1, 2)); Decoded.Acd := AC_ID(Get_W_Bits (Opcode, 3, 2)); Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Dword_To_String (Dword_T(Decoded.Word_2), Radix, 11) & "," & Decoded.Acs'Image & "," & Decoded.Acd'Image; end if; when UNIQUE_1_WORD_FMT => -- nothing to do null; when UNIQUE_2_WORD_FMT => Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); Decoded.Imm_U16 := Unsigned_16(Decoded.Word_2); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Word_To_String(Decoded.Word_2, Octal, 7) & " [2-Word Instruction]"; end if; when WIDE_DEC_SPECIAL_FMT => -- Funky - following word defines OpCode... Decoded.Word_2 := Memory.RAM.Read_Word (PC + 1); if Disassemble then case Decoded.Word_2 is when 0 => Decoded.Disassembly := To_Unbounded_String ("WDMOV"); when 1 => Decoded.Disassembly := To_Unbounded_String ("WDCMP"); when 2 => Decoded.Disassembly := To_Unbounded_String ("WDINC"); when 3 => Decoded.Disassembly := To_Unbounded_String ("WDDEC"); when others => raise Decode_Failed with "Unknown WDxxx instruction"; end case; end if; when WSKB_FMT => -- eg. WSKBO/Z Tmp_8bit := Byte_T(Get_W_Bits(Opcode, 1, 3)); Tmp_8bit := Shift_Left (Tmp_8bit, 2); Tmp_8bit := Tmp_8bit or Byte_T(Get_W_Bits(Opcode, 10, 2)); Decoded.Bit_Number := Natural(Unsigned_8(Tmp_8bit)); if Disassemble then Decoded.Disassembly := Decoded.Disassembly & " " & Decoded.Bit_Number'Image; end if; when others => Loggers.Debug_Print (Debug_Log, "ERROR: Unhandled instruction format: " & Decoded.Format'Image & " for instruction: " & To_String (Decoded.Mnemonic)); raise Decode_Failed with "Unhandled instruction format: " & Decoded.Format'Image & " for: " & To_String(Decoded.Mnemonic); end case; return Decoded; end Instruction_Decode; end Decoder;
with launch_simple_chat_Client, launch_simple_chat_Registrar, launch_simple_instant_events_demo, launch_simple_deferred_events_demo, lace_demo_Events, lace_demo_Keyboard, lace.Observer.instant, lace.Subject .local, lace.Response, lace.Event.utility, launch_strings_Demo, launch_basic_math_Demo, launch_basic_geometry_Demo, launch_math_Testsuite, launch_Outline, launch_Tree, launch_Write, launch_parse_Box, launch_learn_Linear, launch_impact_hello_2d_Demo, launch_orbs_hello_Demo, launch_impact_hello_3d_Demo, launch_box_box_collision_Test, launch_rigid_body_spin_Test, launch_sphere_sphere_collision_Test, launch_camera_Demo, launch_core_Test, launch_large_terrain_Demo, launch_many_boxes_Demo, launch_render_Lighting, launch_Model_scaling, launch_render_Arrows, launch_render_billboards, launch_render_Boxes, launch_render_Capsules, launch_render_Models, launch_render_Screenshot, launch_render_Text, launch_two_cameras_Demo, -- launch_egl_linkage_Test, launch_freetype_linkage_Test, -- launch_gl_linkage_Test, launch_Test_2d, -- launch_hello_physics_interface_Demo, -- launch_test_Engine, launch_Client, launch_Server, launch_Pong, launch_Hello_mmi, -- launch_opengl_Model, launch_Mouse_motion, launch_Mouse_selection, launch_Rig_Demo, launch_Chains_2d, launch_drop_Ball_on_Box, -- launch_drop_Box_on_Box, -- launch_hinged_Box, -- launch_mixed_Joints, launch_mixed_Joints_2d, -- launch_mixed_Shapes, launch_text_Sprite_Demo, launch_add_rid_Sprite_Test, launch_pong_Tute, ada.Text_IO; procedure build_all_Lace -- -- Pulls in all applets and libraries for global checking, reference finding and refactoring. -- is begin launch_simple_chat_Client; launch_simple_chat_Registrar; launch_simple_deferred_events_Demo; launch_simple_instant_events_Demo; launch_strings_Demo; launch_basic_math_Demo; launch_basic_geometry_Demo; launch_math_Testsuite; launch_Outline; launch_Tree; launch_Write; launch_parse_Box; launch_learn_Linear; launch_impact_hello_2d_Demo; launch_orbs_hello_Demo; launch_impact_hello_3d_Demo; launch_box_box_collision_Test; launch_rigid_body_spin_Test; launch_sphere_sphere_collision_Test; launch_camera_Demo; launch_core_Test; launch_large_terrain_Demo; launch_many_boxes_Demo; launch_render_Lighting; launch_Model_scaling; launch_render_Arrows; launch_render_billboards; launch_render_Boxes; launch_render_Capsules; launch_render_Models; launch_render_Screenshot; launch_render_Text; launch_two_cameras_Demo; -- launch_egl_linkage_Test; launch_freetype_linkage_Test; -- launch_gl_linkage_Test; launch_Test_2d; -- launch_hello_physics_interface_Demo; -- launch_test_Engine; launch_Client; launch_Server; launch_Pong; launch_Hello_mmi; -- launch_opengl_Model; launch_Mouse_motion; launch_Mouse_selection; launch_Rig_Demo; launch_Chains_2d; launch_drop_Ball_on_Box; -- launch_drop_Box_on_Box; -- launch_hinged_Box; -- launch_mixed_Joints; launch_mixed_Joints_2d; -- launch_mixed_Shapes; launch_text_Sprite_Demo; launch_add_rid_Sprite_Test; launch_pong_Tute; end build_all_Lace;
with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A007 is use Ada.Integer_Text_IO; Nth : constant Integer := 10001; N : constant Integer := 1E+6; Primes_N : Integer := 0; I, J, Result : Integer; type Large_Array_Bool is array (Integer range 1 .. N + 1) of Boolean; Integers_List : Large_Array_Bool := (others => True); begin -- Using the algorithm of Sieve of Eratosthenes I := 2; while (I * I) <= N loop if Integers_List (I) then J := I * I; while J <= N loop Integers_List (J) := False; J := J + I; end loop; end if; I := I + 1; end loop; Loop_K : for K in 2 .. N loop if Integers_List (K) then Primes_N := Primes_N + 1; if Primes_N = Nth then Result := K; exit Loop_K; end if; end if; end loop Loop_K; Put (Result, Width => 0); end A007;
with AdaCar.Parametros; package AdaCar.Seguimiento_Sensor is task Seguimiento_Task with Priority => Parametros.Prioridad_Seguimiento_Task; end AdaCar.Seguimiento_Sensor;
with Interfaces; with Fmt.Generic_Mod_Int_Argument; package Fmt.Uint32_Argument is new Generic_Mod_Int_Argument(Interfaces.Unsigned_32);
----------------------------------------------------------------------- -- helios-monitor -- Helios monitor -- 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.Finalization; with Ada.Real_Time; with Util.Properties; with Util.Events.Timers; with Helios.Schemas; with Helios.Datas; package Helios.Monitor is type Agent_Type; type Agent_Type_Access is access all Agent_Type'Class; type Agent_Type is new Ada.Finalization.Limited_Controlled and Util.Events.Timers.Timer with record Next : Agent_Type_Access; Index : Helios.Schemas.Monitor_Index; Node : Schemas.Definition_Type_Access; Period : Ada.Real_Time.Time_Span; Data : Helios.Datas.Snapshot_Queue_Type; end record; -- The timer handler executed when the timer deadline has passed. overriding procedure Time_Handler (Agent : in out Agent_Type; Event : in out Util.Events.Timers.Timer_Ref'Class); -- Create a new definition with the given name. The filter parameter allows to control -- which definition values are really needed. The "*" indicates that all values are required. -- Otherwise, it is a comma separated list of strings. A null definition is returned if -- the filter does not contain the definition name. function Create_Definition (Agent : in Agent_Type; Name : in String; Filter : in String := "*") return Schemas.Definition_Type_Access; -- Add a definition to the agent. procedure Add_Definition (Agent : in out Agent_Type; Def : in Schemas.Definition_Type_Access); -- Find a child definition with the given name. -- Returns null if there is no such definition. function Find_Definition (Agent : in Agent_Type; Name : in String) return Schemas.Definition_Type_Access; -- Register the agent. procedure Register (Agent : in Agent_Type_Access; Name : in String; Config : in Util.Properties.Manager); -- Start the agent and build the definition tree. procedure Start (Agent : in out Agent_Type; Config : in Util.Properties.Manager) is null; -- Collect the values in the snapshot. procedure Collect (Agent : in out Agent_Type; Values : in out Datas.Snapshot_Type) is null; -- Get a period configuration parameter. function Get_Period (Config : in Util.Properties.Manager; Name : in String; Default : in Natural) return Ada.Real_Time.Time_Span; -- Get the current report and prepare the plugin agents for a new snapshot. function Get_Report return Helios.Datas.Report_Queue_Type; private -- Iterate over the plugin agents that are registered and execute -- the <tt>Process</tt> procedure. procedure Iterate (Process : not null access procedure (Agent : in out Agent_Type'Class)); end Helios.Monitor;
with eGL; package opengl.surface_Profile.privvy is function to_eGL (Self : in surface_Profile.Item'Class) return egl.EGLConfig; end opengl.surface_Profile.privvy;
package openGL.Impostor.simple -- -- Can impostor any 'visual'. -- is type Item is new Impostor.item with private; type View is access all Item'Class; overriding function current_Camera_look_at_Rotation (Self : in Item) return Matrix_3x3; overriding function update_Required (Self : access Item; the_Camera : access Camera.item'Class) return Boolean; overriding procedure pre_update (Self : in out Item; the_Camera : access Camera.item'Class); overriding procedure update (Self : in out Item; the_Camera : access Camera.item'Class; texture_Pool : in Texture.Pool_view); overriding procedure post_update (Self : in out Item; the_Camera : access Camera.item'Class); procedure free (Self : in out View); private type Item is new Impostor.item with record current_Camera_look_at_Rotation : Matrix_3x3; camera_world_Rotation_original : Matrix_3x3; end record; end openGL.Impostor.simple;
-- Copyright (c) 2013, Nordic Semiconductor ASA -- 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 Nordic Semiconductor ASA 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 spec has been automatically generated from nrf51.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF51_SVD.TWI is pragma Preelaborate; --------------- -- Registers -- --------------- -- Shortcut between BB event and the SUSPEND task. type SHORTS_BB_SUSPEND_Field is ( -- Shortcut disabled. Disabled, -- Shortcut enabled. Enabled) with Size => 1; for SHORTS_BB_SUSPEND_Field use (Disabled => 0, Enabled => 1); -- Shortcut between BB event and the STOP task. type SHORTS_BB_STOP_Field is ( -- Shortcut disabled. Disabled, -- Shortcut enabled. Enabled) with Size => 1; for SHORTS_BB_STOP_Field use (Disabled => 0, Enabled => 1); -- Shortcuts for TWI. type SHORTS_Register is record -- Shortcut between BB event and the SUSPEND task. BB_SUSPEND : SHORTS_BB_SUSPEND_Field := NRF51_SVD.TWI.Disabled; -- Shortcut between BB event and the STOP task. BB_STOP : SHORTS_BB_STOP_Field := NRF51_SVD.TWI.Disabled; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SHORTS_Register use record BB_SUSPEND at 0 range 0 .. 0; BB_STOP at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- Enable interrupt on STOPPED event. type INTENSET_STOPPED_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on STOPPED event. type INTENSET_STOPPED_Field_1 is ( -- Reset value for the field Intenset_Stopped_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_STOPPED_Field_1 use (Intenset_Stopped_Field_Reset => 0, Set => 1); -- Enable interrupt on READY event. type INTENSET_RXDREADY_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_RXDREADY_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on READY event. type INTENSET_RXDREADY_Field_1 is ( -- Reset value for the field Intenset_Rxdready_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_RXDREADY_Field_1 use (Intenset_Rxdready_Field_Reset => 0, Set => 1); -- Enable interrupt on TXDSENT event. type INTENSET_TXDSENT_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_TXDSENT_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on TXDSENT event. type INTENSET_TXDSENT_Field_1 is ( -- Reset value for the field Intenset_Txdsent_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_TXDSENT_Field_1 use (Intenset_Txdsent_Field_Reset => 0, Set => 1); -- Enable interrupt on ERROR event. type INTENSET_ERROR_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_ERROR_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on ERROR event. type INTENSET_ERROR_Field_1 is ( -- Reset value for the field Intenset_Error_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_ERROR_Field_1 use (Intenset_Error_Field_Reset => 0, Set => 1); -- Enable interrupt on BB event. type INTENSET_BB_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_BB_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on BB event. type INTENSET_BB_Field_1 is ( -- Reset value for the field Intenset_Bb_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_BB_Field_1 use (Intenset_Bb_Field_Reset => 0, Set => 1); -- Enable interrupt on SUSPENDED event. type INTENSET_SUSPENDED_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_SUSPENDED_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on SUSPENDED event. type INTENSET_SUSPENDED_Field_1 is ( -- Reset value for the field Intenset_Suspended_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_SUSPENDED_Field_1 use (Intenset_Suspended_Field_Reset => 0, Set => 1); -- Interrupt enable set register. type INTENSET_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Enable interrupt on STOPPED event. STOPPED : INTENSET_STOPPED_Field_1 := Intenset_Stopped_Field_Reset; -- Enable interrupt on READY event. RXDREADY : INTENSET_RXDREADY_Field_1 := Intenset_Rxdready_Field_Reset; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Enable interrupt on TXDSENT event. TXDSENT : INTENSET_TXDSENT_Field_1 := Intenset_Txdsent_Field_Reset; -- unspecified Reserved_8_8 : HAL.Bit := 16#0#; -- Enable interrupt on ERROR event. ERROR : INTENSET_ERROR_Field_1 := Intenset_Error_Field_Reset; -- unspecified Reserved_10_13 : HAL.UInt4 := 16#0#; -- Enable interrupt on BB event. BB : INTENSET_BB_Field_1 := Intenset_Bb_Field_Reset; -- unspecified Reserved_15_17 : HAL.UInt3 := 16#0#; -- Enable interrupt on SUSPENDED event. SUSPENDED : INTENSET_SUSPENDED_Field_1 := Intenset_Suspended_Field_Reset; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INTENSET_Register use record Reserved_0_0 at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; RXDREADY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; TXDSENT at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; ERROR at 0 range 9 .. 9; Reserved_10_13 at 0 range 10 .. 13; BB at 0 range 14 .. 14; Reserved_15_17 at 0 range 15 .. 17; SUSPENDED at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- Disable interrupt on STOPPED event. type INTENCLR_STOPPED_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on STOPPED event. type INTENCLR_STOPPED_Field_1 is ( -- Reset value for the field Intenclr_Stopped_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_STOPPED_Field_1 use (Intenclr_Stopped_Field_Reset => 0, Clear => 1); -- Disable interrupt on RXDREADY event. type INTENCLR_RXDREADY_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_RXDREADY_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on RXDREADY event. type INTENCLR_RXDREADY_Field_1 is ( -- Reset value for the field Intenclr_Rxdready_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_RXDREADY_Field_1 use (Intenclr_Rxdready_Field_Reset => 0, Clear => 1); -- Disable interrupt on TXDSENT event. type INTENCLR_TXDSENT_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_TXDSENT_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on TXDSENT event. type INTENCLR_TXDSENT_Field_1 is ( -- Reset value for the field Intenclr_Txdsent_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_TXDSENT_Field_1 use (Intenclr_Txdsent_Field_Reset => 0, Clear => 1); -- Disable interrupt on ERROR event. type INTENCLR_ERROR_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_ERROR_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on ERROR event. type INTENCLR_ERROR_Field_1 is ( -- Reset value for the field Intenclr_Error_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_ERROR_Field_1 use (Intenclr_Error_Field_Reset => 0, Clear => 1); -- Disable interrupt on BB event. type INTENCLR_BB_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_BB_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on BB event. type INTENCLR_BB_Field_1 is ( -- Reset value for the field Intenclr_Bb_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_BB_Field_1 use (Intenclr_Bb_Field_Reset => 0, Clear => 1); -- Disable interrupt on SUSPENDED event. type INTENCLR_SUSPENDED_Field is ( -- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_SUSPENDED_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on SUSPENDED event. type INTENCLR_SUSPENDED_Field_1 is ( -- Reset value for the field Intenclr_Suspended_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_SUSPENDED_Field_1 use (Intenclr_Suspended_Field_Reset => 0, Clear => 1); -- Interrupt enable clear register. type INTENCLR_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Disable interrupt on STOPPED event. STOPPED : INTENCLR_STOPPED_Field_1 := Intenclr_Stopped_Field_Reset; -- Disable interrupt on RXDREADY event. RXDREADY : INTENCLR_RXDREADY_Field_1 := Intenclr_Rxdready_Field_Reset; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Disable interrupt on TXDSENT event. TXDSENT : INTENCLR_TXDSENT_Field_1 := Intenclr_Txdsent_Field_Reset; -- unspecified Reserved_8_8 : HAL.Bit := 16#0#; -- Disable interrupt on ERROR event. ERROR : INTENCLR_ERROR_Field_1 := Intenclr_Error_Field_Reset; -- unspecified Reserved_10_13 : HAL.UInt4 := 16#0#; -- Disable interrupt on BB event. BB : INTENCLR_BB_Field_1 := Intenclr_Bb_Field_Reset; -- unspecified Reserved_15_17 : HAL.UInt3 := 16#0#; -- Disable interrupt on SUSPENDED event. SUSPENDED : INTENCLR_SUSPENDED_Field_1 := Intenclr_Suspended_Field_Reset; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for INTENCLR_Register use record Reserved_0_0 at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; RXDREADY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; TXDSENT at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; ERROR at 0 range 9 .. 9; Reserved_10_13 at 0 range 10 .. 13; BB at 0 range 14 .. 14; Reserved_15_17 at 0 range 15 .. 17; SUSPENDED at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- Byte received in RXD register before read of the last received byte -- (data loss). type ERRORSRC_OVERRUN_Field is ( -- Error not present. Notpresent, -- Error present. Present) with Size => 1; for ERRORSRC_OVERRUN_Field use (Notpresent => 0, Present => 1); -- Byte received in RXD register before read of the last received byte -- (data loss). type ERRORSRC_OVERRUN_Field_1 is ( -- Reset value for the field Errorsrc_Overrun_Field_Reset, -- Clear error on write. Clear) with Size => 1; for ERRORSRC_OVERRUN_Field_1 use (Errorsrc_Overrun_Field_Reset => 0, Clear => 1); -- NACK received after sending the address. type ERRORSRC_ANACK_Field is ( -- Error not present. Notpresent, -- Error present. Present) with Size => 1; for ERRORSRC_ANACK_Field use (Notpresent => 0, Present => 1); -- NACK received after sending the address. type ERRORSRC_ANACK_Field_1 is ( -- Reset value for the field Errorsrc_Anack_Field_Reset, -- Clear error on write. Clear) with Size => 1; for ERRORSRC_ANACK_Field_1 use (Errorsrc_Anack_Field_Reset => 0, Clear => 1); -- NACK received after sending a data byte. type ERRORSRC_DNACK_Field is ( -- Error not present. Notpresent, -- Error present. Present) with Size => 1; for ERRORSRC_DNACK_Field use (Notpresent => 0, Present => 1); -- NACK received after sending a data byte. type ERRORSRC_DNACK_Field_1 is ( -- Reset value for the field Errorsrc_Dnack_Field_Reset, -- Clear error on write. Clear) with Size => 1; for ERRORSRC_DNACK_Field_1 use (Errorsrc_Dnack_Field_Reset => 0, Clear => 1); -- Two-wire error source. Write error field to 1 to clear error. type ERRORSRC_Register is record -- Byte received in RXD register before read of the last received byte -- (data loss). OVERRUN : ERRORSRC_OVERRUN_Field_1 := Errorsrc_Overrun_Field_Reset; -- NACK received after sending the address. ANACK : ERRORSRC_ANACK_Field_1 := Errorsrc_Anack_Field_Reset; -- NACK received after sending a data byte. DNACK : ERRORSRC_DNACK_Field_1 := Errorsrc_Dnack_Field_Reset; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ERRORSRC_Register use record OVERRUN at 0 range 0 .. 0; ANACK at 0 range 1 .. 1; DNACK at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Enable or disable W2M type ENABLE_ENABLE_Field is ( -- Disabled. Disabled, -- Enabled. Enabled) with Size => 3; for ENABLE_ENABLE_Field use (Disabled => 0, Enabled => 5); -- Enable two-wire master. type ENABLE_Register is record -- Enable or disable W2M ENABLE : ENABLE_ENABLE_Field := NRF51_SVD.TWI.Disabled; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ENABLE_Register use record ENABLE at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype RXD_RXD_Field is HAL.UInt8; -- RX data register. type RXD_Register is record -- Read-only. *** Reading this field has side effects on other resources -- ***. RX data from last transfer. RXD : RXD_RXD_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RXD_Register use record RXD at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype TXD_TXD_Field is HAL.UInt8; -- TX data register. type TXD_Register is record -- TX data for next transfer. TXD : TXD_TXD_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TXD_Register use record TXD at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype ADDRESS_ADDRESS_Field is HAL.UInt7; -- Address used in the two-wire transfer. type ADDRESS_Register is record -- Two-wire address. ADDRESS : ADDRESS_ADDRESS_Field := 16#0#; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ADDRESS_Register use record ADDRESS at 0 range 0 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Peripheral power control. type POWER_POWER_Field is ( -- Module power disabled. Disabled, -- Module power enabled. Enabled) with Size => 1; for POWER_POWER_Field use (Disabled => 0, Enabled => 1); -- Peripheral power control. type POWER_Register is record -- Peripheral power control. POWER : POWER_POWER_Field := NRF51_SVD.TWI.Disabled; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for POWER_Register use record POWER at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Two-wire interface master 0. type TWI_Peripheral is record -- Start 2-Wire master receive sequence. TASKS_STARTRX : aliased HAL.UInt32; -- Start 2-Wire master transmit sequence. TASKS_STARTTX : aliased HAL.UInt32; -- Stop 2-Wire transaction. TASKS_STOP : aliased HAL.UInt32; -- Suspend 2-Wire transaction. TASKS_SUSPEND : aliased HAL.UInt32; -- Resume 2-Wire transaction. TASKS_RESUME : aliased HAL.UInt32; -- Two-wire stopped. EVENTS_STOPPED : aliased HAL.UInt32; -- Two-wire ready to deliver new RXD byte received. EVENTS_RXDREADY : aliased HAL.UInt32; -- Two-wire finished sending last TXD byte. EVENTS_TXDSENT : aliased HAL.UInt32; -- Two-wire error detected. EVENTS_ERROR : aliased HAL.UInt32; -- Two-wire byte boundary. EVENTS_BB : aliased HAL.UInt32; -- Two-wire suspended. EVENTS_SUSPENDED : aliased HAL.UInt32; -- Shortcuts for TWI. SHORTS : aliased SHORTS_Register; -- Interrupt enable set register. INTENSET : aliased INTENSET_Register; -- Interrupt enable clear register. INTENCLR : aliased INTENCLR_Register; -- Two-wire error source. Write error field to 1 to clear error. ERRORSRC : aliased ERRORSRC_Register; -- Enable two-wire master. ENABLE : aliased ENABLE_Register; -- Pin select for SCL. PSELSCL : aliased HAL.UInt32; -- Pin select for SDA. PSELSDA : aliased HAL.UInt32; -- RX data register. RXD : aliased RXD_Register; -- TX data register. TXD : aliased TXD_Register; -- Two-wire frequency. FREQUENCY : aliased HAL.UInt32; -- Address used in the two-wire transfer. ADDRESS : aliased ADDRESS_Register; -- Peripheral power control. POWER : aliased POWER_Register; end record with Volatile; for TWI_Peripheral use record TASKS_STARTRX at 16#0# range 0 .. 31; TASKS_STARTTX at 16#8# range 0 .. 31; TASKS_STOP at 16#14# range 0 .. 31; TASKS_SUSPEND at 16#1C# range 0 .. 31; TASKS_RESUME at 16#20# range 0 .. 31; EVENTS_STOPPED at 16#104# range 0 .. 31; EVENTS_RXDREADY at 16#108# range 0 .. 31; EVENTS_TXDSENT at 16#11C# range 0 .. 31; EVENTS_ERROR at 16#124# range 0 .. 31; EVENTS_BB at 16#138# range 0 .. 31; EVENTS_SUSPENDED at 16#148# range 0 .. 31; SHORTS at 16#200# range 0 .. 31; INTENSET at 16#304# range 0 .. 31; INTENCLR at 16#308# range 0 .. 31; ERRORSRC at 16#4C4# range 0 .. 31; ENABLE at 16#500# range 0 .. 31; PSELSCL at 16#508# range 0 .. 31; PSELSDA at 16#50C# range 0 .. 31; RXD at 16#518# range 0 .. 31; TXD at 16#51C# range 0 .. 31; FREQUENCY at 16#524# range 0 .. 31; ADDRESS at 16#588# range 0 .. 31; POWER at 16#FFC# range 0 .. 31; end record; -- Two-wire interface master 0. TWI0_Periph : aliased TWI_Peripheral with Import, Address => System'To_Address (16#40003000#); -- Two-wire interface master 1. TWI1_Periph : aliased TWI_Peripheral with Import, Address => System'To_Address (16#40004000#); end NRF51_SVD.TWI;
pragma License (Unrestricted); -- extended unit with Ada.Numerics; package Ada.Colors is -- Color spaces. pragma Pure; subtype Brightness is Float range 0.0 .. 1.0; subtype Hue is Float range 0.0 .. Float'Pred (2.0 * Numerics.Pi); type RGB is record Red : Brightness; Green : Brightness; Blue : Brightness; end record; type HSV is record Hue : Colors.Hue; Saturation : Brightness; Value : Brightness; end record; type HSL is record Hue : Colors.Hue; Saturation : Brightness; Lightness : Brightness; end record; function To_RGB (Color : HSV) return RGB; function To_RGB (Color : HSL) return RGB; function To_HSV (Color : RGB) return HSV; function To_HSV (Color : HSL) return HSV; function To_HSL (Color : RGB) return HSL; function To_HSL (Color : HSV) return HSL; -- NTSC luminance function Luminance (Color : RGB) return Brightness; function Luminance (Color : HSV) return Brightness; function Luminance (Color : HSL) return Brightness; -- distances in the color spaces function RGB_Distance (Left, Right : RGB) return Float; function HSV_Distance (Left, Right : HSV) return Float; function HSL_Distance (Left, Right : HSL) return Float; end Ada.Colors;
private with Unchecked_Conversion; with Interfaces; package Emulator_8080.Processor is subtype Register_Type is Emulator_8080.Byte_Type; type Address_Type is new Natural range 0 .. 16#FFFF#; subtype Rom_Address_Type is Address_Type range 0 .. 16#1FFF#; subtype Ram_Address_Type is Address_Type range 16#2000# .. 16#23FF#; subtype Vram_Address_Type is Address_Type range 16#2400# .. 16#3FFF#; type Flag_Type is (Not_Set, Set) with Size => 1; for Flag_Type use (Not_Set => 0, Set => 1); type Memory_Type is array (Address_Type) of Byte_Type; type Vram_Type is array (Vram_Address_Type) of Byte_Type; type Parity_Type is (Odd, Even) with Size => 1; for Parity_Type use (Odd => 0, Even => 1); --type Shift_Hardware_Type is limited record --end record; type Processor_Type is record A : Register_Type := 0; B : Register_Type := 0; C : Register_Type := 0; D : Register_Type := 0; E : Register_Type := 0; H : Register_Type := 0; L : Register_Type := 0; Sign_Flag : Flag_Type := Not_Set; Zero_Flag : Flag_Type := Not_Set; Carry_Flag : Flag_Type := Not_Set; Auxillary_Carry : Flag_Type := Not_Set; Parity : Parity_Type := Odd; Memory : Memory_Type := (others => 0); Program_Counter : Address_Type := 0; Stack_Pointer : Address_Type := Address_Type'Last; Set_Interrupt : Boolean := False; end record; function Initialize(Rom : in Byte_Array_Type) return Processor_Type; procedure NOP(Processor : in out Processor_Type); procedure LXI_BxD16(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure STAX_B(Processor : in out Processor_Type); procedure INX_B(Processor : in out Processor_Type); procedure INR_B(Processor : in out Processor_Type); procedure DCR_B(Processor : in out Processor_Type); procedure MVI_BxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RLC(Processor : in out Processor_Type); -- procedure DAD_B(Processor : in out Processor_Type); procedure LDAX_B(Processor : in out Processor_Type); procedure DCX_B(Processor : in out Processor_Type); procedure INR_C(Processor : in out Processor_Type); procedure DCR_C(Processor : in out Processor_Type); procedure MVI_CxD8(Byte_2 : in Byte_Type; Processor: in out Processor_Type); procedure RRC(Processor : in out Processor_Type); -- procedure LXI_DxD16(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure STAX_D(Processor : in out Processor_Type); procedure INX_D(Processor : in out Processor_Type); procedure INR_D(Processor : in out Processor_Type); procedure DCR_D(Processor : in out Processor_Type); procedure MVI_DxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RAL(Processor : in out Processor_Type); -- procedure DAD_D(Processor : in out Processor_Type); procedure LDAX_D(Processor : in out Processor_Type); procedure DCX_D(Processor : in out Processor_Type); procedure INR_E(Processor : in out Processor_Type); procedure DCR_E(Processor : in out Processor_Type); procedure MVI_ExD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RAR(Processor : in out Processor_Type); -- procedure LXI_HxD16(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure SHLD_Adr(Processor : in out Processor_Type); procedure INX_H(Processor : in out Processor_Type); procedure INR_H(Processor : in out Processor_Type); procedure DCR_H(Processor : in out Processor_Type); procedure MVI_HxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure DAA(Processor : in out Processor_Type); -- procedure DAD_H(Processor : in out Processor_Type); procedure LHLD(Byte_2, Byte_3 : in Byte_Type; Processor: in out Processor_Type); procedure DCX_H(Processor : in out Processor_Type); procedure INR_L(Processor : in out Processor_Type); procedure DCR_L(Processor : in out Processor_Type); procedure MVI_LxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure CMA(Processor : in out Processor_Type); -- procedure LXI_SPxD16(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure STA(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure INX_SP(Processor : in out Processor_Type); procedure INR_M(Processor : in out Processor_Type); procedure DCR_M(Processor : in out Processor_Type); procedure MVI_MxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure STC(Processor : in out Processor_Type); -- procedure DAD_SP(Processor : in out Processor_Type); procedure LDA(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure DCX_SP(Processor : in out Processor_Type); procedure INR_A(Processor : in out Processor_Type); procedure DCR_A(Processor : in out Processor_Type); procedure MVI_AxD8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure CMC(Processor : in out Processor_Type); -- procedure MOV_BxB(Processor : in out Processor_Type); procedure MOV_BxC(Processor : in out Processor_Type); procedure MOV_BxD(Processor : in out Processor_Type); procedure MOV_BxE(Processor : in out Processor_Type); procedure MOV_BxH(Processor : in out Processor_Type); procedure MOV_BxL(Processor : in out Processor_Type); procedure MOV_BxM(Processor : in out Processor_Type); procedure MOV_BxA(Processor : in out Processor_Type); -- procedure MOV_CxB(Processor : in out Processor_Type); procedure MOV_CxC(Processor : in out Processor_Type); procedure MOV_CxD(Processor : in out Processor_Type); procedure MOV_CxE(Processor : in out Processor_Type); procedure MOV_CxH(Processor : in out Processor_Type); procedure MOV_CxL(Processor : in out Processor_Type); procedure MOV_CxM(Processor : in out Processor_Type); procedure MOV_CxA(Processor : in out Processor_Type); -- procedure MOV_DxB(Processor : in out Processor_Type); procedure MOV_DxC(Processor : in out Processor_Type); procedure MOV_DxD(Processor : in out Processor_Type); procedure MOV_DxE(Processor : in out Processor_Type); procedure MOV_DxH(Processor : in out Processor_Type); procedure MOV_DxL(Processor : in out Processor_Type); procedure MOV_DxM(Processor : in out Processor_Type); procedure MOV_DxA(Processor : in out Processor_Type); -- procedure MOV_ExB(Processor : in out Processor_Type); procedure MOV_ExC(Processor : in out Processor_Type); procedure MOV_ExD(Processor : in out Processor_Type); procedure MOV_ExE(Processor : in out Processor_Type); procedure MOV_ExH(Processor : in out Processor_Type); procedure MOV_ExL(Processor : in out Processor_Type); procedure MOV_ExM(Processor : in out Processor_Type); procedure MOV_ExA(Processor : in out Processor_Type); -- procedure MOV_HxB(Processor : in out Processor_Type); procedure MOV_HxC(Processor : in out Processor_Type); procedure MOV_HxD(Processor : in out Processor_Type); procedure MOV_HxE(Processor : in out Processor_Type); procedure MOV_HxH(Processor : in out Processor_Type); procedure MOV_HxL(Processor : in out Processor_Type); procedure MOV_HxM(Processor : in out Processor_Type); procedure MOV_HxA(Processor : in out Processor_Type); -- procedure MOV_LxB(Processor : in out Processor_Type); procedure MOV_LxC(Processor : in out Processor_Type); procedure MOV_LxD(Processor : in out Processor_Type); procedure MOV_LxE(Processor : in out Processor_Type); procedure MOV_LxH(Processor : in out Processor_Type); procedure MOV_LxL(Processor : in out Processor_Type); procedure MOV_LxM(Processor : in out Processor_Type); procedure MOV_LxA(Processor : in out Processor_Type); -- procedure MOV_MxB(Processor : in out Processor_Type); procedure MOV_MxC(Processor : in out Processor_Type); procedure MOV_MxD(Processor : in out Processor_Type); procedure MOV_MxE(Processor : in out Processor_Type); procedure MOV_MxH(Processor : in out Processor_Type); procedure MOV_MxL(Processor : in out Processor_Type); procedure HLT(Processor : in out Processor_Type); -- procedure MOV_MxA(Processor : in out Processor_Type); procedure MOV_AxB(Processor : in out Processor_Type); procedure MOV_AxC(Processor : in out Processor_Type); procedure MOV_AxD(Processor : in out Processor_Type); procedure MOV_AxE(Processor : in out Processor_Type); procedure MOV_AxH(Processor : in out Processor_Type); procedure MOV_AxL(Processor : in out Processor_Type); procedure MOV_AxM(Processor : in out Processor_Type); procedure MOV_AxA(Processor : in out Processor_Type); -- procedure ADD_B(Processor : in out Processor_Type); procedure ADD_C(Processor : in out Processor_Type); procedure ADD_D(Processor : in out Processor_Type); procedure ADD_E(Processor : in out Processor_Type); procedure ADD_H(Processor : in out Processor_Type); procedure ADD_L(Processor : in out Processor_Type); procedure ADD_M(Processor : in out Processor_Type); procedure ADD_A(Processor : in out Processor_Type); -- procedure ADC_B(Processor : in out Processor_Type); procedure ADC_C(Processor : in out Processor_Type); procedure ADC_D(Processor : in out Processor_Type); procedure ADC_E(Processor : in out Processor_Type); procedure ADC_H(Processor : in out Processor_Type); procedure ADC_L(Processor : in out Processor_Type); procedure ADC_M(Processor : in out Processor_Type); procedure ADC_A(Processor : in out Processor_Type); -- procedure SUB_B(Processor : in out Processor_Type); procedure SUB_C(Processor : in out Processor_Type); procedure SUB_D(Processor : in out Processor_Type); procedure SUB_E(Processor : in out Processor_Type); procedure SUB_H(Processor : in out Processor_Type); procedure SUB_L(Processor : in out Processor_Type); procedure SUB_M(Processor : in out Processor_Type); procedure SUB_A(Processor : in out Processor_Type); -- procedure SBB_B(Processor : in out Processor_Type); procedure SBB_C(Processor : in out Processor_Type); procedure SBB_D(Processor : in out Processor_Type); procedure SBB_E(Processor : in out Processor_Type); procedure SBB_H(Processor : in out Processor_Type); procedure SBB_L(Processor : in out Processor_Type); procedure SBB_M(Processor : in out Processor_Type); procedure SBB_A(Processor : in out Processor_Type); -- procedure ANA_B(Processor : in out Processor_Type); procedure ANA_C(Processor : in out Processor_Type); procedure ANA_D(Processor : in out Processor_Type); procedure ANA_E(Processor : in out Processor_Type); procedure ANA_H(Processor : in out Processor_Type); procedure ANA_L(Processor : in out Processor_Type); procedure ANA_M(Processor : in out Processor_Type); procedure ANA_A(Processor : in out Processor_Type); -- procedure XRA_B(Processor : in out Processor_Type); procedure XRA_C(Processor : in out Processor_Type); procedure XRA_D(Processor : in out Processor_Type); procedure XRA_E(Processor : in out Processor_Type); procedure XRA_H(Processor : in out Processor_Type); procedure XRA_L(Processor : in out Processor_Type); procedure XRA_M(Processor : in out Processor_Type); procedure XRA_A(Processor : in out Processor_Type); -- procedure ORA_B(Processor : in out Processor_Type); procedure ORA_C(Processor : in out Processor_Type); procedure ORA_D(Processor : in out Processor_Type); procedure ORA_E(Processor : in out Processor_Type); procedure ORA_H(Processor : in out Processor_Type); procedure ORA_L(Processor : in out Processor_Type); procedure ORA_M(Processor : in out Processor_Type); procedure ORA_A(Processor : in out Processor_Type); -- procedure CMP_B(Processor : in out Processor_Type); procedure CMP_C(Processor : in out Processor_Type); procedure CMP_D(Processor : in out Processor_Type); procedure CMP_E(Processor : in out Processor_Type); procedure CMP_H(Processor : in out Processor_Type); procedure CMP_L(Processor : in out Processor_Type); procedure CMP_M(Processor : in out Processor_Type); procedure CMP_A(Processor : in out Processor_Type); -- procedure RNZ(Processor : in out Processor_Type); procedure POP_B(Processor : in out Processor_Type); procedure JNZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure JMP(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure RET(Processor : in out Processor_Type); procedure CNZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure PUSH_B(Processor : in out Processor_Type); procedure ADI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_0(Processor : in out Processor_Type); procedure RZ(Processor : in out Processor_Type); procedure JZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); -- procedure CZ(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure CALL(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure ACI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_1(Processor : in out Processor_Type); procedure RNC(Processor : in out Processor_Type); procedure POP_D(Processor : in out Processor_Type); procedure JNC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure OUT_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure CNC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure PUSH_D(Processor : in out Processor_Type); procedure SUI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_2(Processor : in out Processor_Type); procedure RC(Processor : in out Processor_Type); -- procedure JC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure IN_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure CC(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure SBI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_3(Processor : in out Processor_Type); procedure RPO(Processor : in out Processor_Type); procedure POP_H(Processor : in out Processor_Type); procedure JPO(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure XTHL(Processor : in out Processor_Type); procedure CPO(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure PUSH_H(Processor : in out Processor_Type); procedure ANI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_4(Processor : in out Processor_Type); procedure RPE(Processor : in out Processor_Type); procedure PCHL(Processor : in out Processor_Type); procedure JPE(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure XCHG(Processor : in out Processor_Type); procedure CPE(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); -- procedure XRI_D8(Byte_2 : in Byte_Type; Processor: in out Processor_Type); procedure RST_5(Processor : in out Processor_Type); procedure RP(Processor : in out Processor_Type); procedure POP_PSW(Processor : in out Processor_Type); procedure JP(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure DI(Processor : in out Processor_Type); procedure CP(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure PUSH_PSW(Processor : in out Processor_Type); procedure ORI_D8(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_6(Processor : in out Processor_Type); procedure RM(Processor: in out Processor_Type); procedure SPHL(Processor : in out Processor_Type); procedure JM(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure EI(Processor : in out Processor_Type); procedure CM(Byte_2, Byte_3 : in Byte_Type; Processor : in out Processor_Type); procedure CPI(Byte_2 : in Byte_Type; Processor : in out Processor_Type); procedure RST_7(Processor : in out Processor_Type); procedure Unimplemented_Instruction(Processor : in out Processor_Type); private subtype Concatenated_Register_Type is Interfaces.Unsigned_16; type Byte_Pair_Type is record Low_Order_Byte : Byte_Type := 0; High_Order_Byte : Byte_Type := 0; end record; for Byte_Pair_Type use record Low_Order_Byte at 0 range 0 .. 7; High_Order_Byte at 1 range 0 .. 7; end record; for Byte_Pair_Type'Size use 16; type Flag_Storage_Type is record Sign_Flag : Flag_Type := Not_Set; Zero_Flag : Flag_Type := Not_Set; Carry_Flag : Flag_Type := Not_Set; Auxillary_Carry : Flag_Type := Not_Set; Parity : Parity_Type := Odd; Spare : Interfaces.Unsigned_8 range 0 .. 3; end record; for Flag_Storage_Type use record Sign_Flag at 0 range 0 .. 0; Zero_Flag at 0 range 1 .. 1; Carry_Flag at 0 range 2 .. 2; Auxillary_Carry at 0 range 3 .. 3; Parity at 0 range 4 .. 4; Spare at 0 range 5 .. 7; end record; procedure Set_Zero_Flag_If_Applicable(Value : in Interfaces.Unsigned_16; Processor : in out Processor_Type); procedure Set_Sign_Flag_If_Applicable(Value : in Interfaces.Unsigned_16; Processor : in out Processor_Type); procedure Set_Carry_Flag_If_Applicable(Value : in Interfaces.Unsigned_16; Processor : in out Processor_Type); procedure Add(Summand : in Register_Type; Processor : in out Processor_Type); procedure Add_With_Carry(Summand : in Register_Type; Processor : in out Processor_Type); procedure Sub(Subtrahend : in Register_Type; Processor : in out Processor_Type); procedure Sub(Subtrahend : in Byte_Type; Register : in out Register_Type; Processor : in out Processor_Type); procedure Sub_With_Carry(Subtrahend : in Register_Type; Processor : in out Processor_Type); procedure And_A(Value : in Register_Type; Processor : in out Processor_Type); procedure Xor_A(Value : in Register_Type; Processor : in out Processor_Type); procedure Or_A(Value : in Register_Type; Processor : in out Processor_Type); procedure Compare_A(Value : in Register_Type; Processor : in out Processor_Type); procedure Inx(V1, V2 : in out Register_Type); function Convert_To_Address is new Unchecked_Conversion(Source => Byte_Pair_Type, Target => Address_Type); function Convert_To_Concatenated_Register is new Unchecked_Conversion(Source => Byte_Pair_Type, Target => Concatenated_Register_Type); function Convert_To_Byte_Pair is new Unchecked_Conversion(Source => Address_Type, Target => Byte_Pair_Type); function Convert_To_Byte_Pair is new Unchecked_Conversion(Source => Concatenated_Register_Type, Target => Byte_Pair_Type); function Convert_To_Byte is new Unchecked_Conversion(Source => Flag_Storage_Type, Target => Byte_Type); function Convert_To_Flag_Storage is new Unchecked_Conversion(Source => Byte_Type, Target => Flag_Storage_Type); end Emulator_8080.Processor;
with Ada.Text_IO; procedure Map is type First_Range is new Float range 0.0 .. 10.0; type Second_Range is new Float range -1.0 .. 0.0; function Translate (Value : First_Range) return Second_Range is B1 : Float := Float (Second_Range'First); B2 : Float := Float (Second_Range'Last); A1 : Float := Float (First_Range'First); A2 : Float := Float (First_Range'Last); Result : Float; begin Result := B1 + (Float (Value) - A1) * (B2 - B1) / (A2 - A1); return Second_Range (Result); end; function Translate (Value : Second_Range) return First_Range is B1 : Float := Float (First_Range'First); B2 : Float := Float (First_Range'Last); A1 : Float := Float (Second_Range'First); A2 : Float := Float (Second_Range'Last); Result : Float; begin Result := B1 + (Float (Value) - A1) * (B2 - B1) / (A2 - A1); return First_Range (Result); end; Test_Value : First_Range := First_Range'First; begin loop Ada.Text_IO.Put_Line (First_Range'Image (Test_Value) & " maps to: " & Second_Range'Image (Translate (Test_Value))); exit when Test_Value = First_Range'Last; Test_Value := Test_Value + 1.0; end loop; end Map;
separate (Numerics) function Max_Real_Array (Item : in Real_Vector) return Real is Result : Real := Item (Item'First); begin for N of Item loop Result := Real'Max (Result, N); end loop; return Result; end Max_Real_Array;
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ -- Purpose: -- Procedural wrapper over Object-Oriented ASIS implementation package body Asis.Statements is ------------------- -- Aborted_Tasks -- ------------------- function Aborted_Tasks (Statement : in Asis.Statement) return Asis.Expression_List is begin Check_Nil_Element (Statement, "Aborted_Tasks"); return Aborted_Tasks (Statement.all); end Aborted_Tasks; ------------------------------------ -- Accept_Body_Exception_Handlers -- ------------------------------------ function Accept_Body_Exception_Handlers (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Statement, "Accept_Body_Exception_Handlers"); return Accept_Body_Exception_Handlers (Statement.all, Include_Pragmas); end Accept_Body_Exception_Handlers; ---------------------------- -- Accept_Body_Statements -- ---------------------------- function Accept_Body_Statements (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Statement, "Accept_Body_Statements"); return Accept_Body_Statements (Statement.all, Include_Pragmas); end Accept_Body_Statements; ------------------------------ -- Accept_Entry_Direct_Name -- ------------------------------ function Accept_Entry_Direct_Name (Statement : in Asis.Statement) return Asis.Name is begin Check_Nil_Element (Statement, "Accept_Entry_Direct_Name"); return Accept_Entry_Direct_Name (Statement.all); end Accept_Entry_Direct_Name; ------------------------ -- Accept_Entry_Index -- ------------------------ function Accept_Entry_Index (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Accept_Entry_Index"); return Accept_Entry_Index (Statement.all); end Accept_Entry_Index; ----------------------- -- Accept_Parameters -- ----------------------- function Accept_Parameters (Statement : in Asis.Statement) return Asis.Parameter_Specification_List is begin Check_Nil_Element (Statement, "Accept_Parameters"); return Accept_Parameters (Statement.all); end Accept_Parameters; --------------------------- -- Assignment_Expression -- --------------------------- function Assignment_Expression (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Assignment_Expression"); return Assignment_Expression (Statement.all); end Assignment_Expression; ------------------------------ -- Assignment_Variable_Name -- ------------------------------ function Assignment_Variable_Name (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Assignment_Variable_Name"); return Assignment_Variable_Name (Statement.all); end Assignment_Variable_Name; ----------------------------- -- Block_Declarative_Items -- ----------------------------- function Block_Declarative_Items (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Declarative_Item_List is begin Check_Nil_Element (Statement, "Block_Declarative_Items"); return Block_Declarative_Items (Statement.all, Include_Pragmas); end Block_Declarative_Items; ------------------------------ -- Block_Exception_Handlers -- ------------------------------ function Block_Exception_Handlers (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Exception_Handler_List is begin Check_Nil_Element (Statement, "Block_Exception_Handlers"); return Block_Exception_Handlers (Statement.all, Include_Pragmas); end Block_Exception_Handlers; ---------------------- -- Block_Statements -- ---------------------- function Block_Statements (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Statement, "Block_Statements"); return Block_Statements (Statement.all, Include_Pragmas); end Block_Statements; ------------------------------- -- Call_Statement_Parameters -- ------------------------------- function Call_Statement_Parameters (Statement : in Asis.Statement; Normalized : in Boolean := False) return Asis.Association_List is begin Check_Nil_Element (Statement, "Call_Statement_Parameters"); if Normalized then return Normalized_Call_Statement_Parameters (Statement.all); else return Call_Statement_Parameters (Statement.all); end if; end Call_Statement_Parameters; ----------------- -- Called_Name -- ----------------- function Called_Name (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Called_Name"); return Called_Name (Statement.all); end Called_Name; --------------------- -- Case_Expression -- --------------------- function Case_Expression (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Case_Expression"); return Case_Expression (Statement.all); end Case_Expression; ---------------------------------------- -- Case_Statement_Alternative_Choices -- ---------------------------------------- function Case_Statement_Alternative_Choices (Path : in Asis.Path) return Asis.Element_List is begin Check_Nil_Element (Path, "Case_Statement_Alternative_Choices"); return Case_Statement_Alternative_Choices (Path.all); end Case_Statement_Alternative_Choices; ------------------------------------ -- Choice_Parameter_Specification -- ------------------------------------ function Choice_Parameter_Specification (Handler : in Asis.Exception_Handler) return Asis.Declaration is begin Check_Nil_Element (Handler, "Choice_Parameter_Specification"); return Choice_Parameter_Specification (Handler.all); end Choice_Parameter_Specification; -------------------------- -- Condition_Expression -- -------------------------- function Condition_Expression (Path : in Asis.Path) return Asis.Expression is begin Check_Nil_Element (Path, "Condition_Expression"); return Condition_Expression (Path.all); end Condition_Expression; --------------------------------- -- Corresponding_Called_Entity -- --------------------------------- function Corresponding_Called_Entity (Statement : in Asis.Statement) return Asis.Declaration is begin Check_Nil_Element (Statement, "Corresponding_Called_Entity"); return Corresponding_Called_Entity (Statement.all); end Corresponding_Called_Entity; ----------------------------------------- -- Corresponding_Destination_Statement -- ----------------------------------------- function Corresponding_Destination_Statement (Statement : in Asis.Statement) return Asis.Statement is begin Check_Nil_Element (Statement, "Corresponding_Destination_Statement"); return Corresponding_Destination_Statement (Statement.all); end Corresponding_Destination_Statement; ------------------------- -- Corresponding_Entry -- ------------------------- function Corresponding_Entry (Statement : in Asis.Statement) return Asis.Declaration is begin Check_Nil_Element (Statement, "Corresponding_Entry"); return Corresponding_Entry (Statement.all); end Corresponding_Entry; ------------------------------- -- Corresponding_Loop_Exited -- ------------------------------- function Corresponding_Loop_Exited (Statement : in Asis.Statement) return Asis.Statement is begin Check_Nil_Element (Statement, "Corresponding_Loop_Exited"); return Corresponding_Loop_Exited (Statement.all); end Corresponding_Loop_Exited; ---------------------- -- Delay_Expression -- ---------------------- function Delay_Expression (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Delay_Expression"); return Delay_Expression (Statement.all); end Delay_Expression; ----------------------- -- Exception_Choices -- ----------------------- function Exception_Choices (Handler : in Asis.Exception_Handler) return Asis.Element_List is begin Check_Nil_Element (Handler, "Exception_Choices"); return Exception_Choices (Handler.all); end Exception_Choices; -------------------- -- Exit_Condition -- -------------------- function Exit_Condition (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Exit_Condition"); return Exit_Condition (Statement.all); end Exit_Condition; -------------------- -- Exit_Loop_Name -- -------------------- function Exit_Loop_Name (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Exit_Loop_Name"); return Exit_Loop_Name (Statement.all); end Exit_Loop_Name; ---------------------------------------- -- Extended_Return_Exception_Handlers -- ---------------------------------------- function Extended_Return_Exception_Handlers (Statement : Asis.Statement; Include_Pragmas : Boolean := False) return Asis.Exception_Handler_List is begin Check_Nil_Element (Statement, "Extended_Return_Exception_Handlers"); return Extended_Return_Exception_Handlers (Statement.all, Include_Pragmas); end Extended_Return_Exception_Handlers; -------------------------------- -- Extended_Return_Statements -- -------------------------------- function Extended_Return_Statements (Statement : Asis.Statement; Include_Pragmas : Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Statement, "Extended_Return_Statements"); return Extended_Return_Statements (Statement.all, Include_Pragmas); end Extended_Return_Statements; -------------------------------------- -- For_Loop_Parameter_Specification -- -------------------------------------- function For_Loop_Parameter_Specification (Statement : in Asis.Statement) return Asis.Declaration is begin Check_Nil_Element (Statement, "For_Loop_Parameter_Specification"); return Loop_Parameter_Specification (Statement.all); end For_Loop_Parameter_Specification; ---------------- -- Goto_Label -- ---------------- function Goto_Label (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Goto_Label"); return Goto_Label (Statement.all); end Goto_Label; ----------- -- Guard -- ----------- function Guard (Path : in Asis.Path) return Asis.Expression is begin Check_Nil_Element (Path, "Guard"); return Guard (Path.all); end Guard; ------------------------ -- Handler_Statements -- ------------------------ function Handler_Statements (Handler : in Asis.Exception_Handler; Include_Pragmas : in Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Handler, "Handler_Statements"); return Handler_Statements (Handler.all, Include_Pragmas); end Handler_Statements; -------------------------------------- -- Is_Call_On_Dispatching_Operation -- -------------------------------------- function Is_Call_On_Dispatching_Operation (Call : in Asis.Element) return Boolean is begin Check_Nil_Element (Call, "Is_Call_On_Dispatching_Operation"); return Is_Call_On_Dispatching_Operation (Call.all); end Is_Call_On_Dispatching_Operation; ---------------------- -- Is_Declare_Block -- ---------------------- function Is_Declare_Block (Statement : in Asis.Statement) return Boolean is begin Check_Nil_Element (Statement, "Is_Declare_Block"); return Is_Declare_Block (Statement.all); end Is_Declare_Block; ------------------------- -- Is_Dispatching_Call -- ------------------------- function Is_Dispatching_Call (Call : in Asis.Element) return Boolean is begin Check_Nil_Element (Call, "Is_Dispatching_Call"); return Is_Dispatching_Call (Call.all); end Is_Dispatching_Call; ---------------------- -- Is_Name_Repeated -- ---------------------- function Is_Name_Repeated (Statement : in Asis.Statement) return Boolean is begin Check_Nil_Element (Statement, "Is_Name_Repeated"); return Is_Name_Repeated (Statement.all); end Is_Name_Repeated; ----------------- -- Label_Names -- ----------------- function Label_Names (Statement : in Asis.Statement) return Asis.Defining_Name_List is begin Check_Nil_Element (Statement, "Label_Names"); return Label_Names (Statement.all); end Label_Names; --------------------- -- Loop_Statements -- --------------------- function Loop_Statements (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Statement, "Loop_Statements"); return Loop_Statements (Statement.all, Include_Pragmas); end Loop_Statements; -------------------------- -- Qualified_Expression -- -------------------------- function Qualified_Expression (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Qualified_Expression"); return Qualified_Expression (Statement.all); end Qualified_Expression; ---------------------- -- Raised_Exception -- ---------------------- function Raised_Exception (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Raised_Exception"); return Raised_Exception (Statement.all); end Raised_Exception; ----------------------------- -- Raise_Statement_Message -- ----------------------------- function Raise_Statement_Message -- 13.3(2) (Statement : Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Raise_Statement_Message"); return Raise_Statement_Message (Statement.all); end Raise_Statement_Message; ------------------------ -- Requeue_Entry_Name -- ------------------------ function Requeue_Entry_Name (Statement : in Asis.Statement) return Asis.Name is begin Check_Nil_Element (Statement, "Requeue_Entry_Name"); return Requeue_Entry_Name (Statement.all); end Requeue_Entry_Name; ----------------------- -- Return_Expression -- ----------------------- function Return_Expression (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "Return_Expression"); return Return_Expression (Statement.all); end Return_Expression; --------------------------------- -- Return_Object_Specification -- --------------------------------- function Return_Object_Specification (Statement : Asis.Statement) return Asis.Declaration is begin Check_Nil_Element (Statement, "Return_Object_Specification"); return Return_Object_Specification (Statement.all); end Return_Object_Specification; ---------------------------- -- Sequence_Of_Statements -- ---------------------------- function Sequence_Of_Statements (Path : in Asis.Path; Include_Pragmas : in Boolean := False) return Asis.Statement_List is begin Check_Nil_Element (Path, "Sequence_Of_Statements"); return Sequence_Of_Statements (Path.all, Include_Pragmas); end Sequence_Of_Statements; -------------------------- -- Statement_Identifier -- -------------------------- function Statement_Identifier (Statement : in Asis.Statement) return Asis.Defining_Name is begin Check_Nil_Element (Statement, "Statement_Identifier"); return Statement_Identifier (Statement.all); end Statement_Identifier; --------------------- -- Statement_Paths -- --------------------- function Statement_Paths (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Path_List is begin Check_Nil_Element (Statement, "Statement_Paths"); return Statement_Paths (Statement.all, Include_Pragmas); end Statement_Paths; --------------------- -- While_Condition -- --------------------- function While_Condition (Statement : in Asis.Statement) return Asis.Expression is begin Check_Nil_Element (Statement, "While_Condition"); return While_Condition (Statement.all); end While_Condition; end Asis.Statements; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . L I B M _ S I N G L E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2014-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Ada Cert Math specific version of s-libsin.ads with System.Libm_Prefix; -- @llrset Libm -- LLR Libm -- ======== package System.Libm_Single is pragma Pure; package SLP renames System.Libm_Prefix; -- This package provides an implementation of the various C99 functions -- used in the Ada run time. It is intended to be used for targets that -- do not have a C math library, or where the C math library isn't of -- sufficient quality and accuracy to meet Ada requirements. -- In case of error conditions, NaNs or infinities are returned as -- recommended in clause F.9 of the C99 standard. When called from C code, -- the implementation behaves as if the FENV_ACCESS state is off, assuming -- default rounding behavior and exception behavior. -- The following C99 elementary functions are provided for single -- precision (with the "f" suffix): -- Acos, Acosh, Asin, Asinh, Atan, Atan2, Atanh, Cosh, Exp, Exp2, Log, -- Log1p, Log2, Pow, Sin, Sinh, Tan, Tanh -- All functions with a NaN argument return a NaN result, except where -- stated otherwise. Unless otherwise specified, where the symbol +- occurs -- in both an argument and the result, the result has the same sign as -- the argument. -- Each function lists C special values, Ada expected values as well as -- Ada accuracy requirements the function meets. For accuracy requirements -- the maximum relative error (abbreviated as MRE) is given, as well as -- the domain for which the accuracy is guaranteed, where applicable. -- The maximum relative error is expressed as multiple of Eps, -- where Eps is Float'Model_Epsilon. -- What about principal branch ??? ---------- -- Acos -- ---------- function Acos (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "acosf"; -- @llr acos (Float) Special Values -- The Acos function shall return the following special values: -- -- C99 special values: -- Acos (1) = +0 -- Acos (x) = NaN if abs (x) > 1 -- -- Ada expected values: -- Acos (0) = Pi/2.0 (tightly approximated) -- Acos (-1) = Pi (tightly approximated) -- Acos (x) return a result in [0, Pi] radians -- -- @llr acos (Float) Accuracy -- The Acos function shall return the inverse cosine of <X> with the -- following accuracy: -- -- Ada accuracy requirements: -- MRE <= 4.0 * Eps ----------- -- Acosh -- ----------- function Acosh (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "acoshf"; -- @llr acosh (Float) Special Values -- The Acosh function shall return the following special values: -- -- C99 special values: -- Acosh (1) = +0 -- Acosh (x) = NaN if abs X > 1 -- Acosh (+INF) = +INF -- -- @llr acosh (Float) Accuracy -- The Acosh function shall return the inverse hyperbolic tangent of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 8.0 * Eps ---------- -- Asin -- ---------- function Asin (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "asinf"; -- @llr asin (Float) Special Values -- The Asin function shall return the following special values: -- -- C99 special values: -- Asin (+-0) = +-0 -- Asin (x) = NaN if abs (x) > 1 -- -- Ada expected values: -- Asin (1) = Pi/2.0 (tightly approximated) -- Asin (-1) = -Pi/2 (tightly approximated) -- Asin (x) return a result in [-Pi/2, Pi/2] radians -- -- @llr asin (Float) Accuracy -- The Asin function shall return the inverse sine of <X> with the -- following accuracy: -- -- Ada accuracy requirements: -- MRE <= 4.0 * Eps ----------- -- Asinh -- ----------- function Asinh (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "asinhf"; -- @llr asinh (Float) Special Values -- The Asinh function shall return the following special values: -- -- C99 special values: -- Asinh (0) = 0 -- Asinh (+INF) = +INF -- -- @llr asinh (Float) Accuracy -- The Asinh function shall return the inverse hyperbolic sine of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 8.0 * Eps ---------- -- Atan -- ---------- function Atan (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "atanf"; -- @llr atan (Float) Special Values -- The Atan function shall return the following special values: -- -- C99 special values: -- Atan (+-0) = +-Pi -- Atan2 (+-INF) = +-0.5 * Pi -- -- C expected values: -- Atan (x) return a result in [-Pi/2, Pi/2] ----------- -- Atan2 -- ----------- function Atan2 (Y : Float; X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "atan2f"; -- @llr atan2 (Float; Float) Special Values -- The Atan2 function shall return the following special values: -- -- C99 special values: -- Atan2 (+-0, -0) = +-Pi -- Atan2 (+-0, +0) = +-0 -- Atan2 (+-0, x) = +-Pi, if x < 0 -- Atan2 (+-0, x) = +-0, if x > 0 -- Atan2 (y, +-0) = -0.5 * Pi, if y < 0 -- Atan2 (y, +-0) = 0.5 * Pi, if y > 0 -- Atan2 (+-y, -INF) = +-Pi, if y > 0 and y is finite -- (tightly approximated) -- Atan2 (+-y, -INF) = +-0, if y < 0 and y is finite -- Atan2 (+-INF, x) = +-0.5 * Pi, if x is finite -- (tightly approximated) -- Atan2 (+-INF, -INF) = +-0.75 * Pi (tightly approximated) -- Atan2 (+-INF, +INF) = +-0.25 * Pi (tightly approximated) -- -- Ada expected values: -- Atan2 (y, x) return a result in [-Pi, Pi] -- -- @llr atan2 (Float; Float) Accuracy -- The Atan2 function shall return the inverse tangent of <Y> / <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 4.0 * Eps ----------- -- Atanh -- ----------- function Atanh (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "atanhf"; -- @llr atanh (Float) Special Values -- The Atanh function shall return the following special values: -- -- C99 special values: -- Atanh (0) = 0 -- Atanh (+-1) = +- INF -- Atanh (X) = NaN for abs X > 1 -- -- @llr atanh (Float) Accuracy -- The Atanh function shall return the inverse hyperbolic tangent of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 8.0 * Eps --------- -- Cos -- --------- function Cos (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "cosf"; -- @llr cos (Float) Special Values -- The Cos function shall return the following special values: -- -- C99 special values: -- Cos (+-0) = 1 -- Cos (+-INF) = NaN -- -- Ada expected values: -- abs (Cos (x)) <= 1 -- -- @llr cos (Float) Accuracy -- The Cos function shall return the cosine of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 2.0 * Eps ---------- -- Cosh -- ---------- function Cosh (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "coshf"; -- @llr cosh (Float) Special Values -- The Cosh function shall return the following special values: -- -- C99 special values: -- Cosh (+-0) = 1 -- Cosh (+-INF) = +INF -- -- Ada expected values: -- abs (Cosh (x)) > 1 -- -- @llr cosh (Float) Accuracy -- The Cosh function shall return the inverse cosine of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 8.0 * Eps --------- -- Exp -- --------- function Exp (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "expf"; -- @llr exp (Float) Special Values -- The Exp function shall return the following special values: -- -- C99 special values: -- Exp (+-0) = 1 -- Exp (-INF) = +0 -- Exp (+INF) = +INF -- -- @llr exp (Float) Accuracy -- The Exp function shall return the exponential of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 4.0 * Eps ---------- -- Exp2 -- ---------- function Exp2 (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "exp2f"; -- @llr exp2 (Float) Special Values -- The Exp2 function shall return the following special values: -- -- C99 special values: -- Exp2 (+-0) = 1 -- Exp2 (-INF) = +0 -- Exp2 (+INF) = +INF -- -- @llr exp2 (Float) Accuracy -- The Exp2 function shall return the exponential of <X> in base 2 -- with the following accuracy: -- -- Accuracy requirements: -- MRE <= 4.0 * Eps --------- -- Log -- --------- function Log (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "logf"; -- @llr log (Float) Special Values -- The Log function shall return the following special values: -- -- C99 special values: -- Log (+-0) = -INF -- Log (1) = +0 -- Log (x) = NaN if x<0 -- Log (+INF) = +INF -- -- @llr log (Float) Accuracy -- The Log function shall return the logarithm of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 4.0 * Eps ----------- -- Log1p -- ----------- function Log1p (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "log1pf"; -- @llr log1p (Float) Special Values: -- The Log1p function shall return the following special values: -- -- C99 special values: -- Log1p (+-0) = -INF -- Log1p (1) = +0 -- Log1p (x) = NaN if x<0 -- Log1p (+INF) = +INF -- -- @llr log1p (Float) Accuracy -- The Log1p function shall return the logarithm of <X> + 1 -- with the following accuracy: -- -- Accuracy requirements: -- MRE <= 4.0 * Eps ---------- -- Log2 -- ---------- function Log2 (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "log2f"; -- @llr log2 (Float) Special Values -- The Log2 function shall return the following special values: -- -- C99 Special values: -- Log2 (+-0) = -INF -- Log2 (1) = +0 -- Log2 (x) = NaN if x<0 -- Log2 (+INF) = +INF -- -- @llr log2 (Float) Accuracy -- The Log function shall return the logarithm of <X> in base 2 -- with the following accuracy: -- -- Accuracy requirements: -- MRE <= 4.0 * Eps --------- -- Pow -- --------- function Pow (Left, Right : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "powf"; -- @llr pow (Float; Float) Special Values -- The Pow function shall return the following special values -- -- C99 Special values: -- Pow (+-0, y) = +-INF, if y < 0 and y an odd integer -- Pow (+-0, y) = +INF, if y < 0 and y not an odd integer -- Pow (+-0, y) = +-0 if y > 0 and y an odd integer -- Pow (+-0, y) = +0 if y > 0 and y not an odd integer -- Pow (-1, +-INF) = 1 -- Pow (1, y) = 1 for any y, even a NaN -- Pow (x, +-0) = 1 for any x, even a NaN -- Pow (x, y) = NaN, if x < 0 and both x and y finite and not integer -- Pow (x, -INF) = +INF if abs (x) < 1 -- Pow (x, -INF) = +0 if abs (x) > 1 -- Pow (x, +INF) = +0 if abs (x) < 1 -- Pow (x, +INF) = +INF if abs (x) > 1 -- Pow (-INF, y) = -0 if y < 0 and y an odd integer -- Pow (-INF, y) = +0 if y < 0 and y not an odd integer -- Pow (-INF, y) = -INF if y > 0 and y an odd integer -- Pow (-INF, y) = +INF if y > 0 and y not an odd integer -- Pow (+INF, y) = +0 if y < 0 -- Pow (+INF, y) = +INF if y > 0 -- -- @llr pow (Float; Float) Accuracy -- The Pow function shall return <Left> to the power of <Right> -- with the following accuracy: -- -- Ada Accuracy requirements: -- MRE <= (4.0 + abs (x * Log (y)) / 32) * Eps --------- -- Sin -- --------- function Sin (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "sinf"; -- @llr sin (Float) Special Values -- The Sin function shall return the following special values: -- -- C99 special values: -- Sin (+-0) = +-0 -- Sin (+-INF) = NaN -- -- @llr sin (Float) Accuracy -- The Sin function shall return the sine of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 2.0 * Eps ---------- -- Sinh -- ---------- function Sinh (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "sinhf"; -- @llr sinh (Float) Special Values -- The Sinh function shall return the following special values: -- -- C99 Special values: -- Sinh (+-0) = +-0 -- Sinh (+-INF) = +-INF -- -- @llr sinh (Float) Accuracy -- The Sinh function shall return the hyperbolic sine of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 8.0 * Eps ---------- -- Sqrt -- ---------- function Sqrt (X : Float) return Float with Convention => C; -- @ignore -- The Sqrt function shall return the following special values: -- -- C99 special values: -- Sqrt (+-0) = +-0 -- Sqrt (INF) = INF -- Sqrt (X) = NaN, for X < 0.0 --------- -- Tan -- --------- function Tan (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "tanf"; -- @llr tan (Float) Special Values -- The Tan function shall return the following special values: -- -- C99 special values: -- Tan (+-0) = +0 -- Tan (+-INF) = NaN -- -- @llr tan (Float) Accuracy -- The Tan function shall return the tangent of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 4.0 * Eps ---------- -- Tanh -- ---------- function Tanh (X : Float) return Float with Export, Convention => C, External_Name => SLP.Prefix & "tanhf"; -- @llr tanh (Float) Special Values -- The Tanh function shall return the following special values: -- -- C99 special values: -- Tanh (+-0) = +-0 -- Tanh (+-INF) = +-1 -- -- @llr tanh (Float) Accuracy -- The Tanh function shall return the hyperbolic tangent of <X> -- with the following accuracy: -- -- Ada accuracy requirements: -- MRE <= 8.0 * Eps private function Identity (X : Float) return Float is (X); function Infinity return Float with Import, Convention => Intrinsic, External_Name => "__builtin_inff"; function NaN return Float is (Infinity - Infinity); function Exact (X : Long_Long_Float) return Float is (Float (X)); function Epsilon return Float is (Float'Model_Epsilon); function Maximum_Relative_Error (X : Float) return Float is (0.0 * X); end System.Libm_Single;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Containers.Hashed_Maps; with League.Strings.Hash; package body AMF.Internals.Factories is package Universal_String_Factory_Maps is new Ada.Containers.Hashed_Maps (League.Strings.Universal_String, Factory_Constructor, League.Strings.Hash, League.Strings."="); URI_Registry : Universal_String_Factory_Maps.Map; Packages : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package; Module_Registry : array (AMF.Internals.AMF_Metamodel) of Module_Factory_Access; Last_Module : AMF_Metamodel := 0; -------------------- -- Create_Factory -- -------------------- function Create_Factory (URI : League.Strings.Universal_String; Extent : AMF_Extent) return AMF.Factories.Factory_Access is Position : constant Universal_String_Factory_Maps.Cursor := URI_Registry.Find (URI); begin if Universal_String_Factory_Maps.Has_Element (Position) then return Universal_String_Factory_Maps.Element (Position) (Extent); else return null; end if; end Create_Factory; ----------------- -- Get_Factory -- ----------------- function Get_Factory (Metamodel : AMF.Internals.AMF_Metamodel) return Module_Factory_Access is begin return Module_Registry (Metamodel); end Get_Factory; ------------------ -- Get_Packages -- ------------------ function Get_Packages return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package is begin return Packages; end Get_Packages; -------------- -- Register -- -------------- procedure Register (The_Package : not null AMF.CMOF.Packages.CMOF_Package_Access; Constructor : not null Factory_Constructor) is begin URI_Registry.Insert (The_Package.Get_URI.Value, Constructor); Packages.Add (The_Package); end Register; -------------- -- Register -- -------------- procedure Register (Factory : not null Module_Factory_Access; Module : out AMF_Metamodel) is begin Module := Last_Module; Last_Module := Last_Module + 1; Module_Registry (Module) := Factory; end Register; end AMF.Internals.Factories;
with Main; use Main; with Ada.Exceptions; with Reporter; with RASCAL.TaskManager; package body Controller_Internet is -- package TaskManager renames RASCAL.TaskManager; -- procedure Handle (The : in TEL_ViewHomePage_Type) is Child : Integer; begin Child := TaskManager.Start_Task ("URIdispatch http://www.arcsite.de/hp/bracke/"); exception when e: others => Report_Error("HOMEPAGE",Ada.Exceptions.Exception_Information (e)); end Handle; -- procedure Handle (The : in TEL_SendEmail_Type) is Child : Integer; begin Child := TaskManager.Start_Task ("URIdispatch mailto:bbracke@web.de"); exception when e: others => Report_Error("SENDEMAIL",Ada.Exceptions.Exception_Information (e)); end Handle; -- end Controller_Internet;
-- $Id: Errors.mi,v 1.5 1994/08/15 22:13:23 grosch rel $ -- $Log: Errors.mi,v $ -- Ich, Doktor Josef Grosch, Informatiker, Aug. 1994 with Strings, Idents, Sets, Position, Sort, Unchecked_Conversion; use Strings, Idents, Sets, Position; package body Errors is package Int_Io is new Integer_Io (Integer ); use Int_Io; package Real_Io is new Float_Io (Float ); use Real_Io; package Bool_Io is new Enumeration_Io (Boolean ); use Bool_Io; package Char_Io is new Enumeration_Io (Character ); use Char_Io; subtype Short is Integer range 0 .. 2 ** 16 - 1; subtype Long is Integer; type tpInteger is access Integer ; type tpShort is access Short ; type tpLong is access Integer ; type tpFloat is access Float ; type tpBoolean is access Boolean ; type tpCharacter is access Character ; type tptString is access tString ; type tpSet is access tSet ; type tpIdent is access tIdent ; type tpPosition is access tPosition ; function To_Integer is new Unchecked_Conversion (Address, tpInteger ); function To_Short is new Unchecked_Conversion (Address, tpShort ); function To_Long is new Unchecked_Conversion (Address, tpLong ); function To_Float is new Unchecked_Conversion (Address, tpFloat ); function To_Boolean is new Unchecked_Conversion (Address, tpBoolean ); function To_Character is new Unchecked_Conversion (Address, tpCharacter); function To_tString is new Unchecked_Conversion (Address, tptString ); function To_Set is new Unchecked_Conversion (Address, tpSet ); function To_Ident is new Unchecked_Conversion (Address, tpIdent ); function To_Position is new Unchecked_Conversion (Address, tpPosition); MaxError : constant Integer := 500; type tError is record Position : tPosition ; IsErrorCode : Boolean ; ErrorNumber : Short ; ErrorCode : Short ; ErrorClass : Short ; InfoClass : Short ; Info : Address ; end record; ErrorTable : array (0 .. MaxError) of tError; MessageCount : Integer := 0; IsStore : Boolean := False; PrevLine : Integer := 0; FoundString : tString; procedure WriteHead (File: File_Type; Position: tPosition; ErrorClass: Integer); procedure WriteCode (File: File_Type; ErrorCode: Integer); procedure WriteInfo (File: File_Type; InfoClass: Integer; Info: Address); procedure WriteT (File: File_Type; String: tString); procedure WriteMessage (File: File_Type; IsErrorCode: Boolean; ErrorCode, ErrorClass: Integer; Position: tPosition; InfoClass: Integer := cNone; Info: Address := IsStore'Address); procedure StoreMessage (pIsErrorCode: Boolean; pErrorCode, pErrorClass: Integer; pPosition: tPosition; pInfoClass: Integer := cNone; pInfo: Address := IsStore'Address); procedure Swap (i, j: Integer); function IsLess (i, j: Integer) return Boolean; package Error_Sort is new Sort (IsLess, Swap); procedure ErrorMessage (ErrorCode, ErrorClass: Integer; Position: tPosition) is begin if IsStore then StoreMessage (True, ErrorCode, ErrorClass, Position); else WriteMessage (Standard_Error, True, ErrorCode, ErrorClass, Position); end if; end ErrorMessage; procedure ErrorMessageI (ErrorCode, ErrorClass: Integer; Position: tPosition; InfoClass: Integer; Info: Address) is begin if IsStore then StoreMessage (True, ErrorCode, ErrorClass, Position, InfoClass, Info); else WriteMessage (Standard_Error, True, ErrorCode, ErrorClass, Position, InfoClass, Info); end if; end ErrorMessageI; procedure Message (ErrorText: String; ErrorClass: Integer; Position: tPosition) is s : tString; begin To_tString (ErrorText, s); if IsStore then StoreMessage (False, MakeIdent (s), ErrorClass, Position); else WriteMessage (Standard_Error, False, MakeIdent (s), ErrorClass, Position); end if; end Message; procedure MessageI (ErrorText: String; ErrorClass: Integer; Position: tPosition; InfoClass: Integer; Info: Address) is s : tString; begin To_tString (ErrorText, s); if IsStore then StoreMessage (False, MakeIdent (s), ErrorClass, Position, InfoClass, Info); else WriteMessage (Standard_Error, False, MakeIdent (s), ErrorClass, Position, InfoClass, Info); end if; end MessageI; procedure WriteHead (File: File_Type; Position: tPosition; ErrorClass: Integer) is begin if Compare (Position, NoPosition) = 0 then Set_Col (File, Col (File) + 10); else WritePosition (File, Position); Put (File, ": "); end if; case ErrorClass is when NoClass => Put (File, " "); when Fatal => Put (File, "Fatal "); when Restriction => Put (File, "Restriction "); when Error => Put (File, "Error "); when Warning => Put (File, "Warning "); when Repair => Put (File, "Repair "); when Note => Put (File, "Note "); when Information => Put (File, "Information "); when others => Put (File, "Error class: "); Put (File, ErrorClass, 0); end case; end WriteHead; procedure WriteCode (File: File_Type; ErrorCode: Integer) is begin case ErrorCode is when NoText => null; when SyntaxError => Put (File, "syntax error" ); when ExpectedTokens => Put (File, "expected tokens" ); when RestartPoint => Put (File, "restart point" ); when TokenInserted => Put (File, "token inserted " ); when WrongParseTable => Put (File, "parse table mismatch" ); when OpenParseTable => Put (File, "cannot open parse table" ); when ReadParseTable => Put (File, "cannot read parse table" ); when TooManyErrors => Put (File, "too many messages" ); when TokenFound => Put (File, "token found " ); when FoundExpected => Put (File, "found/expected " ); when others => Put (File, " error code: "); Put (File, ErrorCode, 0); end case; end WriteCode; procedure WriteInfo (File: File_Type; InfoClass: Integer; Info: Address) is begin if InfoClass = cNone then return; end if; Put (File, ": "); case InfoClass is when cInteger => Put (File, To_Integer (Info).all, 0); when cShort => Put (File, To_Short (Info).all, 0); when cLong => Put (File, To_Long (Info).all, 0); when cFloat => Put (File, To_Float (Info).all); when cBoolean => Put (File, To_Boolean (Info).all); when cCharacter => Char_Io.Put (File, To_Character (Info).all); when cString => WriteT (File, To_tString (Info).all); when cSet => WriteSet (File, To_Set (Info).all); when cIdent => WriteIdent (File, To_Ident (Info).all); when cPosition => WritePosition (File, To_Position (Info).all); when others => null; end case; end WriteInfo; procedure WriteT (File: File_Type; String: tString) is l, i : Integer; c : Character; begin if TRUNCATE then l := Length (String); if l <= 32 then WriteS (File, String); else Put (File, Slice (String, 1, 32)); i := 32; loop i := i + 1; if i > l then exit; end if; c := Element (String, i); if c = ' ' then exit; end if; Text_Io.Put (File, c); end loop; if i < l then Put (File, " ..."); end if; end if; else WriteS (File, String); end if; end WriteT; procedure WriteMessage (File: File_Type; IsErrorCode: Boolean; ErrorCode, ErrorClass: Integer; Position: tPosition; InfoClass: Integer := cNone; Info: Address := IsStore'Address) is begin if IsErrorCode then if BRIEF then case ErrorCode is when TokenFound => FoundString := To_tString (Info).all & "/"; return; when SyntaxError | RestartPoint | TokenInserted => return; when ExpectedTokens => FoundString := FoundString & To_tString (Info).all; WriteHead (File, Position, Error); WriteCode (File, FoundExpected); WriteInfo (File, InfoClass, FoundString'Address); New_Line (File); return; when others => null; end case; end if; if FIRST and then Position.Line /= 0 then if Position.Line = PrevLine then return; else PrevLine := Position.Line; end if; end if; end if; WriteHead (File, Position, ErrorClass); if IsErrorCode then WriteCode (File, ErrorCode); else WriteIdent (File, ErrorCode); end if; WriteInfo (File, InfoClass, Info); New_Line (File); if (ErrorClass = Fatal) and not IsStore then raise Program_Error; end if; end WriteMessage; procedure WriteMessages (File: File_Type) is begin Error_Sort.QuickSort (1, MessageCount); for i in 1 .. MessageCount loop WriteMessage (File, ErrorTable (i).IsErrorCode, ErrorTable (i).ErrorCode, ErrorTable (i).ErrorClass, ErrorTable (i).Position, ErrorTable (i).InfoClass, ErrorTable (i).Info); end loop; end WriteMessages; procedure StoreMessage (pIsErrorCode: Boolean; pErrorCode, pErrorClass: Integer; pPosition: tPosition; pInfoClass: Integer := cNone; pInfo: Address := IsStore'Address) is IntegerPtr : tpInteger ; ShortPtr : tpShort ; LongPtr : tpLong ; FloatPtr : tpFloat ; BooleanPtr : tpBoolean ; CharacterPtr : tpCharacter ; SetPtr : tpSet ; IdentPtr : tpIdent ; PositionPtr : tpPosition ; begin if MessageCount < MaxError then MessageCount := MessageCount + 1; ErrorTable (MessageCount) := ( Position => pPosition , IsErrorCode => pIsErrorCode , ErrorNumber => MessageCount , ErrorCode => pErrorCode , ErrorClass => pErrorClass , InfoClass => pInfoClass , Info => IsStore'Address ); case pInfoClass is when cInteger => IntegerPtr := new Integer ; IntegerPtr.all := To_Integer (pInfo).all; ErrorTable (MessageCount).Info := IntegerPtr .all'Address; when cShort => ShortPtr := new Short ; ShortPtr.all := To_Short (pInfo).all; ErrorTable (MessageCount).Info := ShortPtr .all'Address; when cLong => LongPtr := new Long ; LongPtr.all := To_Long (pInfo).all; ErrorTable (MessageCount).Info := LongPtr .all'Address; when cFloat => FloatPtr := new Float ; FloatPtr.all := To_Float (pInfo).all; ErrorTable (MessageCount).Info := FloatPtr .all'Address; when cBoolean => BooleanPtr := new Boolean ; BooleanPtr.all := To_Boolean (pInfo).all; ErrorTable (MessageCount).Info := BooleanPtr .all'Address; when cCharacter=> CharacterPtr := new Character; CharacterPtr.all := To_Character (pInfo).all; ErrorTable (MessageCount).Info := CharacterPtr.all'Address; when cString => ErrorTable (MessageCount).Info := pInfo; when cSet => SetPtr := new tSet ; MakeSet (SetPtr.all, Size (To_Set (pInfo).all)); Sets. Assign (SetPtr.all, To_Set (pInfo).all); ErrorTable (MessageCount).Info := SetPtr .all'Address; when cIdent => IdentPtr := new tIdent ; IdentPtr.all := To_Ident (pInfo).all; ErrorTable (MessageCount).Info := IdentPtr .all'Address; when cPosition => PositionPtr := new tPosition; PositionPtr.all := To_Position (pInfo).all; ErrorTable (MessageCount).Info := PositionPtr.all'Address; when others => null; end case; else ErrorTable (MessageCount) := ( Position => NoPosition , IsErrorCode => True , ErrorNumber => MessageCount , ErrorCode => TooManyErrors, ErrorClass => Restriction , InfoClass => cNone , Info => IsStore'Address ); end if; if pErrorClass = Fatal then WriteMessages (Standard_Error); raise Program_Error; end if; end StoreMessage; function IsLess (i, j: Integer) return Boolean is r : Integer := Compare (ErrorTable (i).Position, ErrorTable (j).Position); begin if r = -1 then return True ; end if; if r = +1 then return False; end if; return ErrorTable (i).ErrorNumber < ErrorTable (j).ErrorNumber; end IsLess; procedure Swap (i, j: Integer) is t : tError := ErrorTable (i); begin ErrorTable (i) := ErrorTable (j); ErrorTable (j) := t; end Swap; procedure StoreMessages (Store: Boolean) is begin if Store then MessageCount := 0; PrevLine := 0; end if; IsStore := Store; end StoreMessages; end Errors;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Hash; package Tokenization is type Tokenizer (<>) is limited private; type Symbol_Id is new Positive; type Token_Kind is (Identifier, Numeric_Literal, String_Literal, Delimiter, Comment, Stream_End); type Token (Length : Natural; Kind : Token_Kind) is limited record Content : String (1 .. Length); case Kind is when Identifier => Id : Symbol_Id; when others => null; end case; end record; Tokenization_Error : exception; function Tokenize (File_Path : String) return Tokenizer; function Next (Object : in out Tokenizer) return Token; function Paren_Depth (Object : Tokenizer) return Natural; function Line (Object : Tokenizer) return Positive; function Column (Object : Tokenizer) return Positive; function To_String (T : Token) return String; function Is_Keyword (Id : Symbol_Id) return Boolean; function Copy (T : Token) return Token; procedure Register_Symbol (Object : in out Tokenizer; Symbol : String; New_Id : out Symbol_Id); Keyword_Access : constant Symbol_Id := 1; Keyword_Constant : constant Symbol_Id := 2; Keyword_Dynamic : constant Symbol_Id := 3; Keyword_End : constant Symbol_Id := 4; Keyword_Function : constant Symbol_Id := 5; Keyword_In : constant Symbol_Id := 6; Keyword_Is : constant Symbol_Id := 7; Keyword_Out : constant Symbol_Id := 8; Keyword_Package : constant Symbol_Id := 9; Keyword_Pragma : constant Symbol_Id := 10; Keyword_Procedure : constant Symbol_Id := 11; Keyword_Return : constant Symbol_Id := 12; Keyword_Spec : constant Symbol_Id := 13; Keyword_Static : constant Symbol_Id := 14; Keyword_Subtype : constant Symbol_Id := 15; Keyword_Type : constant Symbol_Id := 16; Keyword_Use : constant Symbol_Id := 17; Keyword_With : constant Symbol_Id := 18; Keyword_Wrapper : constant Symbol_Id := 19; private function Case_Insensitive_Hash (S : String) return Ada.Containers.Hash_Type; function Case_Insensitive_Equals (Left, Right : String) return Boolean; package String_Indexer is new Ada.Containers.Indefinite_Hashed_Maps (String, Symbol_Id, Case_Insensitive_Hash, Case_Insensitive_Equals); type Tokenizer (Length : Positive) is record Input : String (1 .. Length); Pos : Positive; Symbol_Table : String_Indexer.Map; Depth : Natural; Cur_Line, Cur_Column, Prev_Line, Prev_Column : Positive; end record; end Tokenization;
pragma License (Unrestricted); -- extended unit package Ada.Streams.Block_Transmission.Strings is -- There are efficient streaming operations for String. pragma Pure; procedure Read is new Block_Transmission.Read (Positive, Character, String); procedure Write is new Block_Transmission.Write (Positive, Character, String); end Ada.Streams.Block_Transmission.Strings;
-- NORX3241 -- an Ada implementation of the NORX Authenticated Encryption Algorithm -- created by Jean-Philippe Aumasson, Philipp Jovanovic and Samuel Neves -- This instantiation words on 32-bit words, with 4 rounds and a parallelism -- degree of 1 -- Copyright (c) 2016, James Humphry - see LICENSE file for details pragma SPARK_Mode (On); with Interfaces; with NORX; with NORX_Load_Store; pragma Elaborate_All(NORX); use all type Interfaces.Unsigned_32; package NORX3241 is new NORX(w => 32, Word => Interfaces.Unsigned_32, Storage_Array_To_Word => NORX_Load_Store.Storage_Array_To_Unsigned_32, Word_To_Storage_Array => NORX_Load_Store.Unsigned_32_To_Storage_Array, l => 4, k => 128, Key_Position => 4, t => 128, n => 128, rot => (8, 11, 16, 31), r => 384, c => 128);
with C.signal; package body System.Native_Interrupts is use type C.signed_int; procedure Raise_Interrupt (Interrupt : Interrupt_Id) is begin if C.signal.C_raise (C.signed_int (Interrupt)) < 0 then raise Program_Error; end if; end Raise_Interrupt; end System.Native_Interrupts;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S I N P U T . D -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-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 child package contains the routines used to write debug source -- files. These routines are not in Sinput.L, because they are used only -- by the compiler, while Sinput.L is also used by gnatmake. package Sinput.D is ------------------------------------------------ -- Subprograms for Writing Debug Source Files -- ------------------------------------------------ procedure Create_Debug_Source (Source : Source_File_Index; Loc : out Source_Ptr); -- Given a source file, creates a new source file table entry to be used -- for the debug source file output (Debug_Generated_Code switch set). -- Loc is set to the initial Sloc value for the first line. This call -- also creates the debug source output file (using Create_Debug_File). procedure Write_Debug_Line (Str : String; Loc : in out Source_Ptr); -- This procedure is called to write a line to the debug source file -- previously created by Create_Debug_Source using Write_Debug_Info. -- Str is the source line to be written to the file (it does not include -- an end of line character). On entry Loc is the Sloc value previously -- returned by Create_Debug_Source or Write_Debug_Line, and on exit, -- Sloc is updated to point to the start of the next line to be written, -- taking into account the length of the terminator that was written by -- Write_Debug_Info. procedure Close_Debug_Source; -- This procedure completes the source table entry for the debug file -- previously created by Create_Debug_Source, and written using the -- Write_Debug_Line procedure. It then calls Close_Debug_File to -- complete the writing of the file itself. end Sinput.D;
pragma License (Unrestricted); -- implementation unit required by compiler package System.Img_Enum_New is pragma Pure; -- required for Enum'Image by compiler (s-imenne.ads) procedure Image_Enumeration_8 ( Pos : Natural; S : in out String; P : out Natural; Names : String; Indexes : Address); procedure Image_Enumeration_16 ( Pos : Natural; S : in out String; P : out Natural; Names : String; Indexes : Address); procedure Image_Enumeration_32 ( Pos : Natural; S : in out String; P : out Natural; Names : String; Indexes : Address); end System.Img_Enum_New;
package Ancestor_Type is type T is tagged private; package B is function make return T; end B; private type T is tagged record n: Natural; end record; end Ancestor_Type;
with Ada.Real_Time; use Ada.Real_Time; package Timeout is procedure Start (Timeout_Time : out Time ; Duration : Time_Span); function Timed_Out (Timeout_Time : Time) return Boolean; end Timeout;
with System.Address_To_Named_Access_Conversions; with System.Formatting.Address; with System.Long_Long_Integer_Types; with System.Termination; package body System.Unbounded_Stack_Allocators.Debug is pragma Suppress (All_Checks); use type Storage_Elements.Storage_Offset; subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; package BA_Conv is new Address_To_Named_Access_Conversions (Block, Block_Access); procedure Dump (Allocator : aliased in out Allocator_Type) is subtype Buffer_Type is String (1 .. 256); procedure Put ( Buffer : in out Buffer_Type; Last : in out Natural; S : String); procedure Put ( Buffer : in out Buffer_Type; Last : in out Natural; S : String) is First : constant Natural := Last + 1; begin Last := Last + S'Length; Buffer (First .. Last) := S; end Put; begin Termination.Error_Put_Line ("Secondary Stack:"); declare Buffer : Buffer_Type; Last : Natural; -- formatting Error : Boolean; -- index I : Address := Allocator; Block_Number : Natural := 0; begin while I /= Null_Address loop Last := 0; -- put block number Put (Buffer, Last, "#"); Formatting.Image ( Word_Unsigned (Block_Number), Buffer (Last + 1 .. Buffer'Last), Last, Width => 2, Error => Error); -- start Put (Buffer, Last, " 0x"); Formatting.Address.Image ( I, Buffer ( Last + 1 .. Last + Formatting.Address.Address_String'Length), Set => Formatting.Lower_Case); Last := Last + Formatting.Address.Address_String'Length; -- used Put (Buffer, Last, " 0x"); Formatting.Address.Image ( BA_Conv.To_Pointer (I).Used, Buffer ( Last + 1 .. Last + Formatting.Address.Address_String'Length), Set => Formatting.Lower_Case); Last := Last + Formatting.Address.Address_String'Length; -- limit Put (Buffer, Last, " 0x"); Formatting.Address.Image ( BA_Conv.To_Pointer (I).Limit, Buffer ( Last + 1 .. Last + Formatting.Address.Address_String'Length), Set => Formatting.Lower_Case); Last := Last + Formatting.Address.Address_String'Length; -- percentage Put (Buffer, Last, " ("); declare Space : constant Storage_Elements.Storage_Count := Size (I); Used : constant Storage_Elements.Storage_Count := Used_Size (I); Percentage : constant Storage_Elements.Storage_Count := (Used * 100 + Space - 1) / Space; begin Formatting.Image ( Word_Unsigned (Percentage), Buffer (Last + 1 .. Buffer'Last), Last, Width => 3, Fill => ' ', Error => Error); end; Put (Buffer, Last, "%)"); Termination.Error_Put_Line (Buffer (1 .. Last)); -- next I := BA_Conv.To_Pointer (I).Previous; Block_Number := Block_Number + 1; end loop; end; end Dump; end System.Unbounded_Stack_Allocators.Debug;
----------------------------------------------------------------------- -- asf-servlets-faces-mappers -- Read faces specific configuration files -- 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.Beans.Objects; with Util.Serialize.Mappers.Record_Mapper; with EL.Contexts; -- == Faces Pretty URLs == -- The faces servlet supports pretty URLs with a custom XML configuration. -- The `url-mapping` XML description allows to define a URL pattern that -- contains parameters that will be injected in some Ada bean and will be -- mapped to a specific faces XHTML view file. -- -- <url-mapping> -- <pattern>/wikis/#{wiki.wiki_space_id}/admin/#{wiki.page_id}/view.html</pattern> -- <view-id>/wikis/admin/view.html</view-id> -- </url-mapping> -- -- package ASF.Servlets.Faces.Mappers is type Servlet_Fields is (URL_MAPPING, URL_PATTERN, VIEW_ID); -- ------------------------------ -- Servlet Config Reader -- ------------------------------ -- When reading and parsing the servlet configuration file, the <b>Servlet_Config</b> object -- is populated by calls through the <b>Set_Member</b> procedure. The data is -- collected and when the end of an element (URL_MAPPING, URL_PATTERN, VIEW_ID) -- is reached, the definition is updated in the servlet registry. type Servlet_Config is limited record URL_Pattern : Util.Beans.Objects.Object; View_Id : Util.Beans.Objects.Object; Handler : Servlet_Registry_Access; Context : EL.Contexts.ELContext_Access; end record; type Servlet_Config_Access is access all Servlet_Config; -- Save in the servlet config object the value associated with the given field. -- When the URL_MAPPING, URL_PATTERN, VIEW_ID field -- is reached, insert the new configuration rule in the servlet registry. procedure Set_Member (N : in out Servlet_Config; Field : in Servlet_Fields; Value : in Util.Beans.Objects.Object); -- Setup the XML parser to read the servlet and mapping rules <b>url-mapping</b>. generic Mapper : in out Util.Serialize.Mappers.Processing; Handler : in Servlet_Registry_Access; Context : in EL.Contexts.ELContext_Access; package Reader_Config is Config : aliased Servlet_Config; end Reader_Config; private package Servlet_Mapper is new Util.Serialize.Mappers.Record_Mapper (Element_Type => Servlet_Config, Element_Type_Access => Servlet_Config_Access, Fields => Servlet_Fields, Set_Member => Set_Member); end ASF.Servlets.Faces.Mappers;
package Tkmrpc.Operations.Ike is Tkm_Version : constant Operations.Operation_Type := 16#0000#; Tkm_Limits : constant Operations.Operation_Type := 16#0001#; Tkm_Reset : constant Operations.Operation_Type := 16#0002#; Nc_Reset : constant Operations.Operation_Type := 16#0100#; Nc_Create : constant Operations.Operation_Type := 16#0101#; Dh_Reset : constant Operations.Operation_Type := 16#0200#; Dh_Create : constant Operations.Operation_Type := 16#0201#; Dh_Generate_Key : constant Operations.Operation_Type := 16#0202#; Cc_Reset : constant Operations.Operation_Type := 16#0300#; Cc_Set_User_Certificate : constant Operations.Operation_Type := 16#0301#; Cc_Add_Certificate : constant Operations.Operation_Type := 16#0302#; Cc_Check_Ca : constant Operations.Operation_Type := 16#0303#; Ae_Reset : constant Operations.Operation_Type := 16#0800#; Isa_Reset : constant Operations.Operation_Type := 16#0900#; Isa_Create : constant Operations.Operation_Type := 16#0901#; Isa_Sign : constant Operations.Operation_Type := 16#0902#; Isa_Auth : constant Operations.Operation_Type := 16#0903#; Isa_Create_Child : constant Operations.Operation_Type := 16#0904#; Isa_Skip_Create_First : constant Operations.Operation_Type := 16#0905#; Esa_Reset : constant Operations.Operation_Type := 16#0A00#; Esa_Create : constant Operations.Operation_Type := 16#0A01#; Esa_Create_No_Pfs : constant Operations.Operation_Type := 16#0A02#; Esa_Create_First : constant Operations.Operation_Type := 16#0A03#; Esa_Select : constant Operations.Operation_Type := 16#0A04#; end Tkmrpc.Operations.Ike;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Upg1 is procedure Print(A, B: in Integer) is Spaces: Integer; begin if A < B then Spaces := (B - A) * 4; for I in 1..Spaces loop Put(' '); end loop; end if; for X in 1..A loop Put(B,1); Put(' '); if A = X then Put("= "); Put(A * B, 1); else Put("+ "); end if; end loop; New_Line; end; A, B : Integer; begin Put("Mata in två positiva siffror: "); Get(A); Get(B); Skip_Line; New_Line; Print(A, B); Print(B, A); Put("Tryck ENTER för at fortsätta..."); Skip_Line; Put("Multiplikation är KUL!"); end;
-- A parallel single-source, all-destinations shortest-path finder. -- Each task is assigned a node, and tries to extend the path by -- cloning new tasks that explore all successors of that node. -- The graph is represented by adjacency lists. This representation -- is fixed, and global to all tasks. -- The minimum distances at each step of the computation are kept in -- arrays RESULT and COMING_FROM. These objects are monitored by an -- array of tasks, one for each node, to yield greater concurrency. with TEXT_IO; use TEXT_IO; procedure shortest_path is package i_io is new integer_io(integer); use i_io; n: integer := 4; -- cardinality of graph subtype graph_size is integer range 1..n; subtype graph_node is graph_size ; inf: integer := 9999; -- Infinite distance type config is array(graph_size) of integer; adjacency: array(graph_size) of config; -- To describe the graph result: config := (graph_size => inf); -- Shortest distances coming_from: config; -- To reconstruct paths begin declare task type monitor_node is entry init(node: graph_node) ; entry go_on(pred: graph_node; pathlength: integer; shorter: out boolean); end monitor_node; monitor: array(graph_size) of monitor_node ; task type path is entry init(node, pred: graph_node; pathlength, size: integer); end path; type path_name is access path; start: path_name; subtype s_path is path; task body monitor_node is here: graph_node ; -- node monitored by this task begin accept init(node: graph_node) do here := node ; end init ; loop select accept go_on(pred: graph_node; pathlength: integer; shorter: out boolean) do if pathlength < result(here) then -- new path is shorter than previous attempts. result(here) := pathlength; coming_from(here) := pred; shorter := true; else shorter := false; end if; end go_on; or terminate; end select; end loop; end monitor_node; task body path is source, from: graph_node; cost,edge: integer; options: config; x: path_name; response: boolean; begin accept init(node, pred: graph_node; pathlength,size: integer) do source := node; from := pred; cost := pathlength; edge := size; end init; cost:=cost+edge; monitor(source).go_on(from, cost, response); if response then -- found shorter path than previous attempts. -- Clone successors to explore edges out of this node. options := adjacency(source) ; for j in graph_size loop if options(j) /= inf then -- edge exists; x := new s_path ; -- new task for it x.init(j, source, cost, options(j)); end if; end loop; end if; end path; begin adjacency :=((inf, 9, 2, inf), (inf, 1, 1, 2), (inf, 2, inf, 5), (inf, 1, inf, 2) ); for j in graph_size loop -- Attach a monitor_node to each graph node. monitor(j).init(j) ; end loop ; start := new path; start.init(1, 1, 0, 0); -- start from node 1, distance 0. end; -- and wait for tasks to terminate. put_line("Final distances from source") ; new_line; for j in graph_size'succ(graph_size'first).. graph_size'last loop put(result(j)); put(" to ") ; put(j) ; put(" reached via ") ; put(coming_from(j)) ; new_line; end loop; end shortest_path;
with System; with Interfaces.C; with GDNative.Thin; use GDNative.Thin; package Simple is procedure godot_gdnative_init (p_options : access godot_gdnative_init_options) with Export => True, Convention => C, External_Name => "godot_gdnative_init"; procedure godot_gdnative_terminate (p_options : access godot_gdnative_terminate_options) with Export => True, Convention => C, External_Name => "godot_gdnative_terminate"; procedure godot_nativescript_init (p_handle : Nativescript_Handle) with Export => True, Convention => C, External_Name => "godot_nativescript_init"; ------- private ------- package Object is function simple_constructor ( p_instance : System.Address; p_method_data : System.Address) return System.Address; pragma Convention(C, simple_constructor); procedure simple_destructor ( p_instance : System.Address; p_method_data : System.Address; p_user_data : System.Address); pragma Convention(C, simple_destructor); function simple_get_data ( p_instance : System.Address; p_method_data : System.Address; p_user_data : System.Address; p_num_args : Interfaces.C.int; p_args : Godot_Instance_Method_Args_Ptrs.Pointer) -- godot_variant ** return godot_variant; pragma Convention(C, simple_get_data); end; end;
with System; package Lv.Mem is -- Allocate a memory dynamically -- @param size size of the memory to allocate in bytes -- @return pointer to the allocated memory function Alloc (Size : Uint32_T) return System.Address; -- Free an allocated data -- @param data pointer to an allocated memory procedure Free (Addr : System.Address); -- Reallocate a memory with a new size. The old content will be kept. -- @param data pointer to an allocated memory. -- Its content will be copied to the new memory block and freed -- @param new_size the desired new size in byte -- @return pointer to the new memory function Realloc (Addr : System.Address; New_Size : Uint32_T) return System.Address; -- Join the adjacent free memory blocks procedure Defrag; -- Give the size of an allocated memory -- @param data pointer to an allocated memory -- @return the size of data memory in bytes function Get_Size (Addr : System.Address) return Uint32_T; type Monitor_T is record Total_Size : Uint32_T; Free_Cnt : Uint32_T; Free_Size : Uint32_T; Free_Biggest_Size : Uint32_T; Used_Pct : Uint8_T; Frag_Pct : Uint8_T; end record; pragma Convention (C_Pass_By_Copy, Monitor_T); -- Give information about the work memory of dynamic allocation -- @param mon_p pointer to a dm_mon_p variable, -- the result of the analysis will be stored here procedure Monitor (Mon : not null access Monitor_T); ------------- -- Imports -- ------------- pragma Import (C, Alloc, "lv_mem_alloc"); pragma Import (C, Free, "lv_mem_free"); pragma Import (C, Realloc, "lv_mem_realloc"); pragma Import (C, Defrag, "lv_mem_defrag"); pragma Import (C, Get_Size, "lv_mem_get_size"); pragma Import (C, Monitor, "lv_mem_monitor"); end Lv.Mem;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . B O A R D _ S U P P O R T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2006 The European Space Agency -- -- Copyright (C) 2003-2021, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ -- This is the ARMv8-A + GICv2 version of this package with Ada.Unchecked_Conversion; with System.ARM_GIC; with System.BB.CPU_Primitives.Multiprocessors; with System.BB.Parameters; with System.Machine_Code; with Interfaces; use Interfaces; with Interfaces.AArch64; package body System.BB.Board_Support is use BB.Interrupts, AArch64, Parameters; use System.Machine_Code; use System.Multiprocessors; ----------- -- Timer -- ----------- Alarm_Interrupt_ID : constant BB.Interrupts.Interrupt_ID := 30; -- Phys. Non-secure timer -- System time stamp generator IOU_SCNTRS_Base_Address : constant := 16#FF26_0000#; SCNTRS_CTRL : Unsigned_32 with Volatile, Import, Address => IOU_SCNTRS_Base_Address; SCNTRS_FREQ : Unsigned_32 with Volatile, Import, Address => IOU_SCNTRS_Base_Address + 16#20#; ------------------ -- Set_CNTP_CTL -- ------------------ procedure Set_CNTP_CTL (Val : Unsigned_32) renames Set_CNTP_CTL_EL0; ------------------- -- Set_CNTP_CVAL -- ------------------- procedure Set_CNTP_CVAL (Val : Unsigned_64) renames Set_CNTP_CVAL_EL0; ----------- -- GICv2 -- ----------- package GIC renames System.ARM_GIC; --------- -- APU -- --------- package APU is type Power_Down_Array is array (CPU) of Boolean with Pack; type UInt12 is mod 2 ** 12 with Size => 12; type UInt14 is mod 2 ** 14 with Size => 14; type POWERCTL_Register is record CPUPWRDWNREQ : Power_Down_Array; Unused_4_15 : UInt12; L2FLUSH_REQ : Boolean; CLREXMONREQ : Boolean; Unused_18_31 : UInt14; end record with Volatile_Full_Access, Size => 32; for POWERCTL_Register use record CPUPWRDWNREQ at 0 range 0 .. 3; Unused_4_15 at 0 range 4 .. 15; L2FLUSH_REQ at 0 range 16 .. 16; CLREXMONREQ at 0 range 17 .. 17; Unused_18_31 at 0 range 18 .. 31; end record; type APU_Registers is record ERR_CTRL : Unsigned_32; ISR : Unsigned_32; IMR : Unsigned_32; IEN : Unsigned_32; IDS : Unsigned_32; CONFIG_0 : Unsigned_32; CONFIG_1 : Unsigned_32; RVBAR_ADDR0L : Unsigned_32; RVBAR_ADDR0H : Unsigned_32; RVBAR_ADDR1L : Unsigned_32; RVBAR_ADDR1H : Unsigned_32; RVBAR_ADDR2L : Unsigned_32; RVBAR_ADDR2H : Unsigned_32; RVBAR_ADDR3L : Unsigned_32; RVBAR_ADDR3H : Unsigned_32; ACE_CTRL : Unsigned_32; SNOOP_CTRL : Unsigned_32; PWRCTL : POWERCTL_Register; PWRSTAT : Unsigned_32; end record with Volatile; for APU_Registers use record ERR_CTRL at 16#00# range 0 .. 31; ISR at 16#10# range 0 .. 31; IMR at 16#14# range 0 .. 31; IEN at 16#18# range 0 .. 31; IDS at 16#1C# range 0 .. 31; CONFIG_0 at 16#20# range 0 .. 31; CONFIG_1 at 16#24# range 0 .. 31; RVBAR_ADDR0L at 16#40# range 0 .. 31; RVBAR_ADDR0H at 16#44# range 0 .. 31; RVBAR_ADDR1L at 16#48# range 0 .. 31; RVBAR_ADDR1H at 16#4C# range 0 .. 31; RVBAR_ADDR2L at 16#50# range 0 .. 31; RVBAR_ADDR2H at 16#54# range 0 .. 31; RVBAR_ADDR3L at 16#58# range 0 .. 31; RVBAR_ADDR3H at 16#5C# range 0 .. 31; ACE_CTRL at 16#60# range 0 .. 31; SNOOP_CTRL at 16#80# range 0 .. 31; PWRCTL at 16#90# range 0 .. 31; PWRSTAT at 16#94# range 0 .. 31; end record; Regs : APU_Registers with Import, Address => 16#FD5C_0000#; end APU; procedure Initialize_CPU_Devices; pragma Export (C, Initialize_CPU_Devices, "__gnat_initialize_cpu_devices"); -- Per CPU device initialization ---------------------------- -- Initialize_CPU_Devices -- ---------------------------- procedure Initialize_CPU_Devices is begin -- Timer: using the non-secure physical timer -- at init, we disable both the physical and the virtual timers -- the pysical timer is awaken when we need it. -- Disable CNTP signals and mask its IRQ. Set_CNTP_CTL (2#10#); -- Disable CNTV and mask. Set_CNTV_CTL_EL0 (2); -- Core-specific part of the GIC configuration: -- The GICC (CPU Interface) is banked for each CPU, so has to be -- configured each time. GIC.Initialize_GICC; end Initialize_CPU_Devices; ---------------------- -- Initialize_Board -- ---------------------- procedure Initialize_Board is begin GIC.Initialize_GICD; Initialize_CPU_Devices; end Initialize_Board; package body Time is --------------- -- Set_Alarm -- --------------- procedure Set_Alarm (Ticks : BB.Time.Time) is use type BB.Time.Time; begin if Ticks = BB.Time.Time'Last then Clear_Alarm_Interrupt; else -- Set Timer comparator value Set_CNTP_CVAL (Unsigned_64 (Ticks)); -- Set CNTP_CTL (enable and unmask) Set_CNTP_CTL (2#01#); end if; end Set_Alarm; ---------------- -- Read_Clock -- ---------------- function Read_Clock return BB.Time.Time is begin -- Read CNTPCT return BB.Time.Time (Get_CNTPCT_EL0); end Read_Clock; --------------------------- -- Install_Alarm_Handler -- --------------------------- procedure Install_Alarm_Handler (Handler : Interrupt_Handler) is begin -- Attach interrupt handler BB.Interrupts.Attach_Handler (Handler, Alarm_Interrupt_ID, Interrupt_Priority'Last); end Install_Alarm_Handler; --------------------------- -- Clear_Alarm_Interrupt -- --------------------------- procedure Clear_Alarm_Interrupt is begin -- mask the IRQ and disable signals Set_CNTP_CTL (2#10#); end Clear_Alarm_Interrupt; end Time; ----------------- -- IRQ_Handler -- ----------------- procedure IRQ_Handler is new GIC.IRQ_Handler (Interrupt_Wrapper => Interrupt_Wrapper); pragma Export (C, IRQ_Handler, "__gnat_irq_handler"); -- Low-level interrupt handler package body Interrupts is ------------------------------- -- Install_Interrupt_Handler -- ------------------------------- procedure Install_Interrupt_Handler (Interrupt : BB.Interrupts.Interrupt_ID; Prio : Interrupt_Priority) renames GIC.Install_Interrupt_Handler; --------------------------- -- Priority_Of_Interrupt -- --------------------------- function Priority_Of_Interrupt (Interrupt : System.BB.Interrupts.Interrupt_ID) return System.Any_Priority renames GIC.Priority_Of_Interrupt; -------------------------- -- Set_Current_Priority -- -------------------------- procedure Set_Current_Priority (Priority : Integer) renames GIC.Set_Current_Priority; ---------------- -- Power_Down -- ---------------- procedure Power_Down renames GIC.Power_Down; end Interrupts; package body Multiprocessors is Poke_Interrupt : constant Interrupt_ID := 0; -- Use SGI #0 procedure Poke_Handler (Interrupt : BB.Interrupts.Interrupt_ID); -- Handler for the Poke interrupt procedure Start with Import, External_Name => "__start"; -- Entry point (in crt0) for a slave cpu function MPIDR return Unsigned_32 with Inline_Always; -- Return current value of the MPIDR register procedure CPU_Wake_Up (CPU_Id : CPU; Start_Address : System.Address); -- Reset and wake_up the specified CPU Calculated_Number_Of_CPUs : Unsigned_32 := 0; -------------------- -- Number_Of_CPUs -- -------------------- function Number_Of_CPUs return CPU is R : Unsigned_32; begin if Calculated_Number_Of_CPUs = 0 then pragma Warnings (Off, "condition is always *"); if Parameters.Max_Number_Of_CPUs = 1 then Calculated_Number_Of_CPUs := 1; else Asm ("mrs %0, S3_1_c11_c0_2", Outputs => Unsigned_32'Asm_Output ("=r", R), Volatile => True); R := Shift_Right (R, 24) and 3; Calculated_Number_Of_CPUs := Unsigned_32'Min (R + 1, Parameters.Max_Number_Of_CPUs); end if; pragma Warnings (On, "condition is always *"); end if; return CPU (Calculated_Number_Of_CPUs); end Number_Of_CPUs; ----------- -- MPIDR -- ----------- function MPIDR return Unsigned_32 is R : Unsigned_32; begin Asm ("mrs %0, mpidr_el1", Outputs => Unsigned_32'Asm_Output ("=r", R), Volatile => True); return R and 3; end MPIDR; ----------------- -- Current_CPU -- ----------------- function Current_CPU return CPU is -- Get CPU Id from bits 1:0 from the MPIDR register (if CPU'Last = 1 then 1 else CPU ((MPIDR and 3) + 1)); -------------- -- Poke_CPU -- -------------- procedure Poke_CPU (CPU_Id : CPU) is begin GIC.Poke_CPU (CPU_Id, Poke_Interrupt); end Poke_CPU; ----------------- -- CPU_Wake_Up -- ----------------- procedure CPU_Wake_Up (CPU_Id : CPU; Start_Address : System.Address) is function To_U64 is new Ada.Unchecked_Conversion (System.Address, Unsigned_64); RST_FPD_APU : Unsigned_16 with Volatile, Import, Address => 16#FD1A0104#; Addr : constant Unsigned_64 := To_U64 (Start_Address); Addr_L : constant Unsigned_32 := Unsigned_32 (Addr and 16#FFFF_FFFF#); Addr_H : constant Unsigned_32 := Unsigned_32 (Shift_Right (Addr, 32)); Pwron_Rst_Mask : constant Unsigned_16 := Shift_Left (1, Natural (CPU_Id) + 9); Rst_Mask : constant Unsigned_16 := Shift_Left (1, Natural (CPU_Id) - 1); Rst_Value : Unsigned_16; begin -- Make sure the target CPU is powered APU.Regs.PWRCTL.CPUPWRDWNREQ (CPU_Id) := False; -- Assert the power-on-reset Rst_Value := RST_FPD_APU; if (Rst_Value and Pwron_Rst_Mask) = 0 then Rst_Value := Rst_Value or Pwron_Rst_Mask; RST_FPD_APU := Rst_Value; end if; -- Set the APU start address case Natural (CPU_Id) is when 1 => APU.Regs.RVBAR_ADDR0L := Addr_L; APU.Regs.RVBAR_ADDR0H := Addr_H; when 2 => APU.Regs.RVBAR_ADDR1L := Addr_L; APU.Regs.RVBAR_ADDR1H := Addr_H; when 3 => APU.Regs.RVBAR_ADDR2L := Addr_L; APU.Regs.RVBAR_ADDR2H := Addr_H; when 4 => APU.Regs.RVBAR_ADDR3L := Addr_L; APU.Regs.RVBAR_ADDR3H := Addr_H; when others => raise Program_Error; end case; -- Release the reset line if needed if (Rst_Value and Rst_Mask) = Rst_Mask then Rst_Value := Rst_Value and not Rst_Mask; RST_FPD_APU := Rst_Value; end if; -- Release the power-on-reset line RST_FPD_APU := Rst_Value and not Pwron_Rst_Mask; end CPU_Wake_Up; -------------------- -- Start_All_CPUs -- -------------------- procedure Start_All_CPUs is begin if not System.BB.Parameters.Multiprocessor or else Number_Of_CPUs = 1 then -- Nothing to do return; end if; -- Note: this gets never called in the Uniprocessor case. BB.Interrupts.Attach_Handler (Poke_Handler'Access, Poke_Interrupt, Interrupt_Priority'Last); -- Disable warnings for non-SMP case pragma Warnings (Off, "loop range is null*"); for CPU_Id in CPU'First + 1 .. Number_Of_CPUs loop CPU_Wake_Up (CPU_Id, Start'Address); end loop; pragma Warnings (On, "loop range is null*"); end Start_All_CPUs; ------------------ -- Poke_Handler -- ------------------ procedure Poke_Handler (Interrupt : BB.Interrupts.Interrupt_ID) is begin -- Make sure we are handling the right interrupt pragma Assert (Interrupt = Poke_Interrupt); System.BB.CPU_Primitives.Multiprocessors.Poke_Handler; end Poke_Handler; end Multiprocessors; end System.BB.Board_Support;
-- IntCode Interpreter with Ada.Containers; with Ada.Containers.Hashed_Maps; with Ada.Containers.Vectors; package IntCode is procedure load(s : String); procedure load_file(path : String); procedure eval; procedure append_input(val : Integer); function take_output return Integer; procedure poke(addr : Natural; value : Integer); function peek(addr : Natural) return Integer; function dump return String; private package Memory_Vector is new Ada.Containers.Vectors(Index_Type => Natural, Element_Type => Integer); memory : Memory_Vector.Vector := Memory_Vector.Empty_Vector; package IO_Vector is new Ada.Containers.Vectors(Index_Type => Natural, Element_Type => Integer); input_vector : IO_Vector.Vector := IO_Vector.Empty_Vector; output_vector : IO_Vector.Vector := IO_Vector.Empty_Vector; type OpCode is (Add, Mult, Input, Output, Halt); function integer_hash(i: Integer) return Ada.Containers.Hash_Type; package Int_to_OpCode_Map is new Ada.Containers.Hashed_Maps ( Key_Type => Integer, Element_Type => OpCode, Hash => integer_hash, Equivalent_Keys => "=" ); OpCode_Map : Int_to_OpCode_Map.Map; end IntCode;
-------------------------------------------------------------------------------- -- -- -- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU Lesser General Public -- -- License as published by the Free Software Foundation; either -- -- version 2.1 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Lesser General Public License for more details. -- -- -- -- You should have received a copy of the GNU Lesser General Public -- -- License along with this library; if not, write to the Free Software -- -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- -------------------------------------------------------------------------------- -- $Author$ -- $Date$ -- $Revision$ with RASCAL.Memory; use RASCAL.Memory; with RASCAL.OS; use RASCAL.OS; with RASCAL.Utility; use RASCAL.Utility; with Kernel; use Kernel; with Reporter; package body RASCAL.ToolboxQuit is Toolbox_ObjectMiscOp : constant Interfaces.C.unsigned := 16#44EC6#; -- function Get_Window_ID (Quit : in Object_ID; Flags: in System.Unsigned_Types.Unsigned := 0) return Object_ID is Register : aliased Kernel.swi_regs; Error : OSError_Access; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 0; Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Get_Window_ID: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); return -1; end if; return Object_ID(Register.R(0)); end Get_Window_ID; -- function Get_Message (Quit : in Object_ID; Flags: in System.Unsigned_Types.Unsigned := 0) return string is Register : aliased Kernel.swi_regs; Error : OSError_Access; Buffer_Size : integer; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 2; Register.R(3) := 0; Register.R(4) := 0; Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Get_Message: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); return ""; end if; Buffer_Size := Integer (Register.R(4)); declare Buffer : String (1..Buffer_Size); begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 2; Register.R(3) := Adr_To_Int(Buffer'Address); Register.R(4) := int(Buffer_Size); Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Get_Message: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); return ""; end if; return MemoryToString(Buffer'Address); end; end Get_Message; -- function Get_Title (Quit : in Object_ID; Flags: in System.Unsigned_Types.Unsigned := 0) return String is Register : aliased Kernel.swi_regs; Error : OSError_Access; Buffer_Size : Integer; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 3; Register.R(3) := 0; Register.R(4) := 0; Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Get_Title: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); return ""; end if; Buffer_Size := integer(Register.R(4)); declare Buffer : string(1..Buffer_Size); begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 3; Register.R(3) := Adr_To_Int(Buffer'Address); Register.R(4) := int(Buffer_Size); Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Get_Title: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); return ""; end if; return MemoryToString(Buffer'Address); end; end Get_Title; -- procedure Set_Message (Quit : in Object_ID; Message : in String; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : OSError_Access; Null_Message : String := Message & ASCII.NUL; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 1; Register.R(3) := Adr_To_Int(Null_Message'Address); Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Set_Message: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); null; end if; end Set_Message; -- procedure Set_Title (Quit : in Object_ID; Title : in string; Flags : in System.Unsigned_Types.Unsigned := 0) is Register : aliased Kernel.swi_regs; Error : OSError_Access; Null_Title : String := Title & ASCII.NUL; begin Register.R(0) := int(Unsigned_to_Int(Flags)); Register.R(1) := int(Quit); Register.R(2) := 3; Register.R(3) := Adr_To_Int(Null_Title'Address); Error := Kernel.SWI(Toolbox_ObjectMiscOp,Register'Access,Register'Access); if Error /= null then Pragma Debug(Reporter.Report("ToolboxQuit.Set_Title: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Set_Title; -- end RASCAL.ToolboxQuit;
package body Generic_Unit_Vectors with SPARK_Mode is function addition(Left, Right : Unit_Vector) return Unit_Vector is begin return (Left.x + Right.x, Left.y + Right.y, Left.z + Right.z); end addition; end Generic_Unit_Vectors;
with Text_IO; use Text_IO; with Tarmi; use Tarmi; with Tarmi.Environments; use Tarmi.Environments; with Tarmi.Evaluation; use Tarmi.Evaluation; with Tarmi.Symbols; use Tarmi.Symbols; with Tarmi.Combiners; use Tarmi.Combiners; use type Tarmi.Datum; procedure Test_Eval is Env : Environment := Make_Environment ((Datum(Interned("foo")), Nil)); A : Datum := Eval (Nil, Env); B : Datum := Eval (Datum(Interned("foo")), Env); Op1 : Operative := new Operative_R'(Param_Tree_Formals => Ignore , Dyn_Env_Formal => Ignore , Static_Env => Env , Body_Form => Datum (Interned("foo")) ) ; Expr1 : Pair := new Pair_R'(Datum (Op1), Nil) ; C : Datum := Eval (Datum (Expr1), Env); -- Op2 : Operative_R := (Param_Tree_Formals => Interned("foo") , -- Dyn_Env_Formal => Ignore , -- Static_Env => Env , -- Body_Form => ) ; begin Put_Line (Boolean'Image(A = Nil)); Put_Line (Boolean'Image(B = Nil)); Put_Line (Boolean'Image(C = Nil)); end Test_Eval;
----------------------------------------------------------------------- -- ado-sessions-entities -- Find entity types -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ADO.Schemas.Entities; package body ADO.Sessions.Entities is -- ------------------------------ -- Find the entity type object associated with the given database table. -- Raises the No_Entity_Type exception if no such mapping exist. -- ------------------------------ function Find_Entity_Type (Session : in ADO.Sessions.Session'Class; Object : in ADO.Objects.Object_Key) return ADO.Entity_Type is begin Check_Session (Session); return ADO.Schemas.Entities.Find_Entity_Type (Session.Impl.Entities.all, Object.Of_Class); end Find_Entity_Type; -- ------------------------------ -- Find the entity type index associated with the given database table. -- Raises the No_Entity_Type exception if no such mapping exist. -- ------------------------------ function Find_Entity_Type (Session : in ADO.Sessions.Session'Class; Table : in ADO.Schemas.Class_Mapping_Access) return ADO.Entity_Type is begin Check_Session (Session); return ADO.Schemas.Entities.Find_Entity_Type (Session.Impl.Entities.all, Table); end Find_Entity_Type; -- ------------------------------ -- Find the entity type index associated with the given database table. -- Raises the No_Entity_Type exception if no such mapping exist. -- ------------------------------ function Find_Entity_Type (Session : in ADO.Sessions.Session'Class; Name : in Util.Strings.Name_Access) return ADO.Entity_Type is begin Check_Session (Session); return ADO.Schemas.Entities.Find_Entity_Type (Session.Impl.Entities.all, Name); end Find_Entity_Type; -- ------------------------------ -- Find the entity type index associated with the given database table. -- Raises the No_Entity_Type exception if no such mapping exist. -- ------------------------------ function Find_Entity_Type (Session : in ADO.Sessions.Session'Class; Name : in String) return ADO.Entity_Type is begin return Find_Entity_Type (Session, Name'Unrestricted_Access); end Find_Entity_Type; -- ------------------------------ -- Resolve the entity type associated with the database table <b>Table</b> by using -- the <b<Session</b> connection object. Then, bind the parameter identified by -- <b>Name</b> in the parameter list. -- ------------------------------ procedure Bind_Param (Params : in out ADO.Parameters.Abstract_List'Class; Name : in String; Table : in ADO.Schemas.Class_Mapping_Access; Session : in ADO.Sessions.Session'Class) is Value : constant Entity_Type := Find_Entity_Type (Session, Table.Table.all); begin Params.Bind_Param (Name, Value); end Bind_Param; end ADO.Sessions.Entities;
package body Chi_Square is function Distance(Bins: Bins_Type) return Flt is Bad_Bins: Natural := 0; Sum: Natural := 0; Expected: Flt; Result: Flt; begin for I in Bins'Range loop if Bins(I) < 5 then Bad_Bins := Bad_Bins + 1; end if; Sum := Sum + Bins(I); end loop; if 5*Bad_Bins > Bins'Length then raise Program_Error with "too many (almost) empty bins"; end if; Expected := Flt(Sum) / Flt(Bins'Length); Result := 0.0; for I in Bins'Range loop Result := Result + ((Flt(Bins(I)) - Expected)**2) / Expected; end loop; return Result; end Distance; end Chi_Square;
with Ada.Text_IO; package body Simple_IO with SPARK_Mode => Off is procedure Put_Line (S : in String) is begin Ada.Text_IO.Put_Line (S); end Put_Line; procedure Put_Line (S : in Integer) is begin Ada.Text_IO.Put_Line (Integer'Image (S)); end Put_Line; end Simple_IO;
-- ----------------------------------------------------------------------------- -- Copyright (C) 2003-2019 Stichting Mapcode Foundation (http://www.mapcode.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.Characters.Handling; with Mapcode_Utils.Str_Tools, Mapcode_Utils.Bits; use Mapcode_Utils; with Mapcodes.Languages; with Ndata; package body Mapcodes is subtype Lint is Long_Long_Integer; -- All functions returning a Integer return a natural or Error Error : constant Integer := -1; -- All functions returning a string may return Undefined, on error Undefined : constant String := ""; subtype Country_Range is Positive range Countries.Territories_Def'Range; function Iso3166Alpha_Of (Index : Natural) return String is begin if Index + 1 <= Country_Range'Last then return Countries.Territories_Def(Index + 1).Code.Image; else return Undefined; end if; end Iso3166Alpha_Of; Aliases : constant String := "2UK=2UT,2CG=2CT,1GU=GUM,1UM=UMI,1VI=VIR,1AS=ASM,1MP=MNP,4CX=CXR,4CC=CCK," & "4NF=NFK,4HM=HMD,COL=5CL,5ME=5MX,MEX=5MX,5AG=AGU,5BC=BCN,5BS=BCS,5CM=CAM," & "5CS=CHP,5CH=CHH,5CO=COA,5DF=DIF,5DG=DUR,5GT=GUA,5GR=GRO,5HG=HID,5JA=JAL," & "5MI=MIC,5MO=MOR,5NA=NAY,5NL=NLE,5OA=OAX,5PB=PUE,5QE=QUE,5QR=ROO,5SL=SLP," & "5SI=SIN,5SO=SON,5TB=TAB,5TL=TLA,5VE=VER,5YU=YUC,5ZA=ZAC,811=8BJ,812=8TJ," & "813=8HE,814=8SX,815=8NM,821=8LN,822=8JL,823=8HL,831=8SH,832=8JS,833=8ZJ," & "834=8AH,835=8FJ,836=8JX,837=8SD,841=8HA,842=8HB,843=8HN,844=8GD,845=8GX," & "846=8HI,850=8CQ,851=8SC,852=8GZ,853=8YN,854=8XZ,861=8SN,862=8GS,863=8QH," & "864=8NX,865=8XJ,871=TWN,891=HKG,892=MAC,8TW=TWN,8HK=HKG,8MC=MAC,BEL=7BE," & "KIR=7KI,PRI=7PO,CHE=7CH,KHM=7KM,PER=7PM,TAM=7TT,0US=USA,0AU=AUS,0RU=RUS," & "0CN=CHN,TAA=SHN,ASC=SHN,DGA=IOT,WAK=MHL,JTN=UMI,MID=1HI,1PR=PRI,5TM=TAM," & "TAM=TAM,2OD=2OR,"; Usa_From : constant := 343; Usa_Upto : constant := 393; Ccode_Usa : constant := 410; Ind_From : constant := 271; Ind_Upto : constant := 306; Ccode_Ind : constant := 407; Can_From : constant := 394; Can_Upto : constant := 406; Ccode_Can : constant := 495; Aus_From : constant := 307; Aus_Upto : constant := 315; Ccode_Aus : constant := 408; Mex_From : constant := 233; Mex_Upto : constant := 264; Ccode_Mex : constant := 411; Bra_From : constant := 316; Bra_Upto : constant := 342; Ccode_Bra : constant := 409; Chn_From : constant := 497; Chn_Upto : constant := 527; Ccode_Chn : constant := 528; Rus_From : constant := 412; Rus_Upto : constant := 494; Ccode_Rus : constant := 496; Ccode_Earth : constant := 532; -- Parent territories Parent_Length : constant := 8; subtype String3 is String (1 .. 3); Parents3 : constant array (1 .. Parent_Length) of String3 := ("USA", "IND", "CAN", "AUS", "MEX", "BRA", "RUS", "CHN"); subtype String2 is String (1 .. 2); Parents2 : constant array (1 .. Parent_Length) of String2 := ("US", "IN", "CA", "AU", "MX", "BR", "RU", "CN"); -- Returns 2-letter parent country abbreviation (disam in range 1..8) function Parent_Name2 (Disam : Positive) return String is (Parents2 (Disam)); -- Given a parent country abbreviation, return disam (in range 1-8) or -- Error function Parent_Letter (Territory_Alpha_Code : String) return Integer is Srch : constant String := Str_Tools.Upper_Str (Territory_Alpha_Code); begin if Srch'Length = 2 then for I in Parents2'Range loop if Srch = Parents2(I) then return I; end if; end loop; elsif Srch'Length = 3 then for I in Parents3'Range loop if Srch = Parents3(I) then return I; end if; end loop; end if; return Error; end Parent_Letter; function Image (I : Integer) return String is Str : constant String := I'Img; begin return (if Str(Str'First) /= ' ' then Str else Str (Integer'Succ(Str'First) .. Str'Last)); end Image; -- Returns alias of ISO abbreviation (if any), or empty function Alias2Iso (Territory_Alpha_Code : String) return String is -- Look for "DigitCrit=" function Match (Crit, Within : String) return Natural is Occ : Positive := 1; I : Natural; begin loop I := Str_Tools.Locate (Within, Crit, Occurence => Occ); exit when I = 0; if I > 1 and then Within(I - 1) >= '0' and then Within(I - 1) <= '9' then return I - 1; end if; Occ := Occ + 1; end loop; return 0; end Match; Index : Natural; begin Index := (if Territory_Alpha_Code'Length = 2 then Match (Territory_Alpha_Code & "=", Aliases) else Str_Tools.Locate (Aliases, Territory_Alpha_Code & "=")); if Index /= 0 then return Aliases (Index + 4 .. Index + 6); else return Undefined; end if; end Alias2Iso; -- Given ISO code, return Territory_Number or Error function Find_Iso (Territory_Alpha_Code : String) return Integer is begin for I in Country_Range loop if Countries.Territories_Def(I).Code.Image = Territory_Alpha_Code then return I - 1; end if; end loop; return Error; end Find_Iso; -- Given ISO code, return territoryNumber or Error function Iso2Ccode (Alpha_Code : String; Context : in String) return Integer is function Is_Digit (Char : Character) return Boolean is (Char >= '0' and then Char <= '9'); function Is_Digits (Str : String) return Boolean is begin for I in Str'Range loop if not Is_Digit (Str(I)) then return False; end if; end loop; return Str /= ""; end Is_Digits; N, Sep : Natural; P, Tmpp : Integer; Result, Index : Integer; Isoa : As_U.Asu_Us; Code2Search, Context2Search : As_U.Asu_Us; Hyphenated : As_U.Asu_Us; use all type As_U.Asu_Us; begin if Alpha_Code = Undefined then return Error; end if; P := Parent_Letter (Context); if P = Error and then Context /= "" and then Context /= "AAA" then return Error; end if; Sep := Str_Tools.Locate (Alpha_Code, "-"); Code2Search := Tus (Str_Tools.Upper_Str (Alpha_Code)); if P /= Error and then Sep /= 0 then -- Cannot provide a context together with territory-subdivision return Error; end if; -- Optims: direct number or code if P = Error and then Sep = 0 then -- Direct territory number if Is_Digits (Code2Search.Image) then N := Natural'Value (Code2Search.Image); if N <= Ccode_Earth then return N; end if; end if; -- Check if a simple territory if Code2Search.Length = 3 then Index := Find_Iso (Code2Search.Image); if Index /= Error then return Index; end if; end if; -- Find unique occurence of subdivision in ANY context if Code2Search.Length >= 2 then Hyphenated := Tus ("-") & Code2Search; Result := Error; for I in Country_Range loop Index := Str_Tools.Locate (Countries.Territories_Def(I).Code.Image, Hyphenated.Image); if Index > 0 and then Index = Countries.Territories_Def(I).Code.Length - Hyphenated.Length + 1 then -- iso3166alpha ends by Hyphenated if Result /= Error then -- Not unique return Error; else Result := I - 1; end if; end if; end loop; if Result /= Error then return Result; end if; end if; end if; -- Set Context and Code for search if Context /= "" then -- Context provided Context2Search.Set (Context); elsif Sep /= 0 then -- Code contains a prefix Context2Search := Code2Search.Uslice (1, Sep - 1); Code2Search.Delete (1, Sep); P := Parent_Letter (Context2Search.Image); if P = Error and then Context2Search.Image /= "AAA" then return Error; end if; end if; -- Sanity check if Code2Search.Length /= 2 and then Code2Search.Length /= 3 then return Error; end if; -- Optim: search this prefix and code if P /= Error then Index := Find_Iso (Parent_Name2 (P) & "-" & Code2Search.Image); if Index /= Error then return Index; end if; end if; -- Resolve alias if P /= Error then -- Alias for a subdivision with context Isoa := Tus (Alias2Iso (Image (P) & Code2Search.Image)); end if; if Isoa.Is_Null and then Code2Search.Length = 3 then -- Alias for a territory or subdivision without context Isoa := Tus (Alias2Iso (Code2Search.Image)); end if; if Isoa.Is_Null then Index := Error; else if Is_Digit (Isoa.Element (1)) then -- Alias is a subdivision Code2Search := Isoa.Uslice (2, Isoa.Length); Tmpp := Integer'Value (Isoa.Slice (1, 1)); if P /= Error and then Tmpp /= P then -- Cannot change territory through aliasing return Error; end if; P := Tmpp; Index := Find_Iso (Parent_Name2 (P) & "-" & Code2Search.Image); else -- Alias is a subdivision or territory Code2Search := Isoa; -- Search for a territory Index := Find_Iso (Code2Search.Image); if Index = Error and then P /= Error then -- Search for a subdivision Index := Find_Iso (Parent_Name2 (P) & "-" & Code2Search.Image); end if; end if; end if; -- Return valid result if Index /= Error then return Index; end if; if P /= Error then -- With a context, the search shall have succeded return Error; end if; -- All else failed, try non-disambiguated alphacode Isoa := Tus (Alias2Iso (Code2Search.Image)); if not Isoa.Is_Null then if Is_Digit (Isoa.Element (1)) then -- Starts with digit Code2Search := Tus (Parent_Name2 (Natural'Value (Isoa.Slice (1, 1))) & "-" & Isoa.Slice (2, Isoa.Length)); else Code2Search := Isoa; end if; return Iso2Ccode (Code2Search.Image, Context); end if; return Error; end Iso2Ccode; -- Image of a territory (index starting at 0 for VAT) function Get_Territory_Number (Territory : Territories) return String is (Image (Integer (Territory))); -- Given an alphacode (such As_US-AL), returns the territory number -- or Error. -- A context_Territory number helps to interpret ambiguous (abbreviated) -- AlphaCodes, such as "AL" function Get_Territory (Territory_Code : String; Context : in String := "") return Territories is Num : Integer; begin Num := Iso2Ccode (Territory_Code, Context); if Num = Error then raise Unknown_Territory; end if; return Territories (Num); end Get_Territory; -- Return full name of territory function Get_Territory_Fullname (Territory: in Territories) return String is Name : As_U.Asu_Us; Index : Natural; begin Name := Countries.Territories_Def(Positive (Territory) + 1).Name; Index := Str_Tools.Locate (Name.Image, " ("); if Index > 0 then return Name.Slice (1, Index - 1); else return Name.Image; end if; end Get_Territory_Fullname; -- Return the AlphaCode (usually an ISO 3166 code) of a territory -- Format: Local (often ambiguous), International (full and unambiguous, -- DEFAULT), or Shortest function Get_Territory_Alpha_Code ( Territory : Territories; Format : Territory_Formats := International) return String is Full : constant String := Iso3166Alpha_Of (Natural (Territory)); Iso : As_U.Asu_Us; Hyphen, Index : Natural; Short : As_U.Asu_Us; Count : Natural; begin Hyphen := Str_Tools.Locate (Full, "-"); if Format = International or else Hyphen = 0 then -- Format full or no hyphen return Full; end if; Short := As_U.Tus (Full(Hyphen + 1 .. Full'Last)); if Format = Local then -- Format local return Short.Image; end if; -- Shortest possible -- Keep parent if it has aliases or if territory occurs multiple times Count := 0; if Str_Tools.Locate (Aliases, Short.Image & "=") > 0 then Count := 2; else for I in Country_Range loop Iso := As_U.Tus (Iso3166Alpha_Of (I)); Index := Str_Tools.Locate (Iso.Image, "-" & Short.Image); if Index > 0 and then Index + Short.Length = Iso.Length then Count := Count + 1; exit when Count = 2; end if; end loop; end if; return (if Count = 1 then Short.Image else Full); end Get_Territory_Alpha_Code; -- Return parent country of subdivision or error (if territory is not a -- subdivision) function Get_Parent (Territory : Territories) return Integer is begin return (case Territory is when Usa_From .. Usa_Upto => Ccode_Usa, when Ind_From .. Ind_Upto => Ccode_Ind, when Can_From .. Can_Upto => Ccode_Can, when Aus_From .. Aus_Upto => Ccode_Aus, when Mex_From .. Mex_Upto => Ccode_Mex, when Bra_From .. Bra_Upto => Ccode_Bra, when Rus_From .. Rus_Upto => Ccode_Rus, when Chn_From .. Chn_Upto => Ccode_Chn, when others => Error); end Get_Parent; function Get_Parent_Of (Territory : Territories) return Territories is Code : constant Integer := Get_Parent (Territory); begin if Code = Error then raise Not_A_Subdivision; else return Territories (Code); end if; end Get_Parent_Of; -- Return True if Territory is a state function Is_Subdivision (Territory : Territories) return Boolean is (Get_Parent (Territory) /= Error); -- Return True if Territory is a country that has states function Has_Subdivision (Territory : Territories) return Boolean is Code : constant String := Get_Territory_Alpha_Code (Territory); begin for Parent of Parents3 loop if Code = Parent then return True; end if; end loop; return False; end Has_Subdivision; -- Given a subdivision, return the array of subdivisions with same name -- with various parents function Get_Subdivisions_With (Subdivision : String) return Territories_Array is Upper_Subd : constant String := Str_Tools.Upper_Str (Subdivision); Ccodes : array (1 .. Parent_Length) of Integer; Nb_Ok : Natural := 0; begin -- Count and store valid combinations of a Parent and this subdivision for I in Parents2'Range loop Ccodes(I) := Iso2Ccode (Upper_Subd, Parents2(I)); if Ccodes(I) /= Error then Nb_Ok := Nb_Ok + 1; end if; end loop; -- Return array of valid combinations return Result : Territories_Array (1 .. Nb_Ok) do Nb_Ok := 0; for Ccode of Ccodes loop if Ccode /= Error then Nb_Ok := Nb_Ok + 1; Result(Nb_Ok) := Territories (Ccode); end if; end loop; end return; end Get_Subdivisions_With; -- Low-level routines for data access type Min_Max_Rec is record Minx, Miny, Maxx, Maxy : Lint; end record; function Data_First_Record (Territory_Number : Natural) return Integer is begin return Ndata.Data_Start(Territory_Number + 1); exception when others => return Error; end Data_First_Record; function Data_Last_Record (Territory_Number : Natural) return Integer is begin return Ndata.Data_Start(Territory_Number + 2) - 1; exception when others => return Error; end Data_Last_Record; function Min_Max_Setup (I : Natural) return Min_Max_Rec is Short_Maxy : constant array (Positive range <>) of Natural := (0, 122309, 27539, 27449, 149759, 2681190, 60119, 62099, 491040, 86489); D : Natural; begin D := Ndata.Data_Maxy(I + 1); if D < Short_Maxy'Last then D := Short_Maxy(D + 1); end if; return (Minx => Lint (Ndata.Data_Minx(I + 1)), Miny => Lint (Ndata.Data_Miny(I + 1)), Maxx => Lint (Ndata.Data_Minx(I + 1) + Ndata.Data_Maxx(I + 1)), Maxy => Lint (Ndata.Data_Miny(I + 1) + D)); end Min_Max_Setup; Xdivider19 : constant array (Positive range <>) of Natural := ( 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, -- 5.2429 degrees 362, 362, 362, 363, 363, 363, 364, 364, 365, 366, -- 10.4858 degrees 366, 367, 367, 368, 369, 370, 370, 371, 372, 373, -- 15.7286 degrees 374, 375, 376, 377, 378, 379, 380, 382, 383, 384, -- 20.9715 degrees 386, 387, 388, 390, 391, 393, 394, 396, 398, 399, -- 26.2144 degrees 401, 403, 405, 407, 409, 411, 413, 415, 417, 420, -- 31.4573 degrees 422, 424, 427, 429, 432, 435, 437, 440, 443, 446, -- 36.7002 degrees 449, 452, 455, 459, 462, 465, 469, 473, 476, 480, -- 41.9430 degrees 484, 488, 492, 496, 501, 505, 510, 515, 520, 525, -- 47.1859 degrees 530, 535, 540, 546, 552, 558, 564, 570, 577, 583, -- 52.4288 degrees 590, 598, 605, 612, 620, 628, 637, 645, 654, 664, -- 57.6717 degrees 673, 683, 693, 704, 715, 726, 738, 751, 763, 777, -- 62.9146 degrees 791, 805, 820, 836, 852, 869, 887, 906, 925, 946, -- 68.1574 degrees -- 73.4003 degrees 968, 990, 1014, 1039, 1066, 1094, 1123, 1154, 1187, 1223, -- 78.6432 degrees 1260, 1300, 1343, 1389, 1438, 1490, 1547, 1609, 1676, 1749, -- 83.8861 degrees 1828, 1916, 2012, 2118, 2237, 2370, 2521, 2691, 2887, 3114, -- 89.1290 degrees 3380, 3696, 4077, 4547, 5139, 5910, 6952, 8443, 10747, 14784, 23681, 59485); Nc : constant array (Positive range <>) of Natural := ( 1, 31, 961, 29791, 923521, 28629151, 887503681); X_Side : constant array (Positive range <>) of Natural := ( 0, 5, 31, 168, 961, 168 * 31, 29791, 165869, 923521, 5141947, 28629151); Y_Side : constant array (Positive range <>) of Natural := ( 0, 6, 31, 176, 961, 176 * 31, 29791, 165869, 923521, 5141947, 28629151); Decode_Char : constant array (Positive range <>) of Integer := ( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -2, 10, 11, 12, -3, 13, 14, 15, 1, 16, 17, 18, 19, 20, 0, 21, 22, 23, 24, 25, -4, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -2, 10, 11, 12, -3, 13, 14, 15, 1, 16, 17, 18, 19, 20, 0, 21, 22, 23, 24, 25, -4, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); Encode_Char : constant array (Positive range <>) of Character := ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'A', 'E', 'U'); function Decode_A_Char (C : Natural) return Integer is (Decode_Char(C + 1)); function Encode_A_Char (C : Natural) return Character is (Encode_Char(C + 1)); -- Given a minimum and maximum latitude, returns a relative stretch factor -- (in 360th) for the longitud function Xdivider4 (Miny, Maxy : Lint) return Natural is use Bits; begin if Miny >= 0 then return Xdivider19(Integer (Shr (Miny, 19)) + 1); end if; if Maxy >= 0 then return Xdivider19(1); end if; return Xdivider19(Integer (Shr (-Maxy, 19)) + 1); end Xdivider4; type Coord_Rec is record X, Y : Lint; end record; type Frac_Rec is record Fraclon, Fraclat : Integer; Coord32 : Coord_Rec; end record; -- Return True if x in range (all values in millionths) function Is_In_Range_X (X, Minx, Maxx : Lint) return Boolean is Lx : Lint; begin if Minx <= X and then X < Maxx then return True; end if; Lx := X; if Lx < Minx then Lx := Lx + 360000000; else Lx := Lx - 360000000; end if; return Minx <= Lx and then Lx < Maxx; end Is_In_Range_X; -- Return True if coordinate inside rectangle (all values in millionths) function Fits_Inside (Coord : Coord_Rec; Min_Max : Min_Max_Rec) return Boolean is (Min_Max.Miny <= Coord.Y and then Coord.Y < Min_Max.Maxy and then Is_In_Range_X (Coord.X, Min_Max.Minx, Min_Max.Maxx)); -- Mapcodezone type Mapcode_Zone_Rec is record Fminx, Fmaxx, Fminy, Fmaxy : Lint := 0; end record; -- Empty Mapcode_Zone Mz_Empty : constant Mapcode_Zone_Rec := (others => <>); function Mz_Is_Empty (Zone : Mapcode_Zone_Rec) return Boolean is (Zone.Fmaxx <= Zone.Fminx or else Zone.Fmaxy <= Zone.Fminy); -- Construct MapcodeZone based on coordinate and deltas (in Fractions) function Mz_Set_From_Fractions (Y, X, Ydelta, Xdelta : Lint) return Mapcode_Zone_Rec is (if Ydelta < 0 then (Fminx => X, Fmaxx => X + Xdelta, Fminy => Y + 1 + Ydelta, -- y+yDelta can NOT be represented Fmaxy => Y + 1) -- y CAN be represented else (Fminx => X, Fmaxx => X + Xdelta, Fminy => Y, Fmaxy => Y + Ydelta)); function Mz_Mid_Point_Fractions (Zone : Mapcode_Zone_Rec) return Coord_Rec is ( (Y => (Zone.Fminy + Zone.Fmaxy) / 2, X => (Zone.Fminx + Zone.Fmaxx) / 2)); function Convert_Fractions_To_Coord32 (P : Coord_Rec) return Coord_Rec is ( (Y => P.Y / 810000, X => P.X / 3240000) ); function Wrap (P : Coord_Rec) return Coord_Rec is Res : Coord_Rec := P; begin if Res.X >= 180 * 3240000 * 1000000 then Res.X := Res.X - 360 * 3240000 * 1000000; end if; if Res.X < -180 * 3240000 * 1000000 then Res.X := Res.X + 360 * 3240000 * 1000000; end if; return Res; end Wrap; function Round (Val, Max : Real) return Real is Epsilon : constant Real := 0.0000005; begin if Val < 0.0 then if Val < -Max and then Val >= -Max - Epsilon then return -Max; end if; else if Val > Max and then Val <= Max + Epsilon then return Max; end if; end if; return Val; end Round; function Convert_Fractions_To_Degrees (P : Coord_Rec) return Coordinate is begin return (Lat => Round (Real (P.Y) / 810000.0 / 1000000.0, 90.0), Lon => Round (Real (P.X) / 3240000.0 / 1000000.0, 180.0) ); end Convert_Fractions_To_Degrees; function Mz_Restrict_Zone_To (Zone : Mapcode_Zone_Rec; Mm : Min_Max_Rec) return Mapcode_Zone_Rec is Z : Mapcode_Zone_Rec := Zone; Miny : constant Lint := Mm.Miny * 810000; Maxy : constant Lint := Mm.Maxy * 810000; Minx : Lint; Maxx : Lint; begin if Z.Fminy < Miny then Z.Fminy := Miny; end if; if Z.Fmaxy > Maxy then Z.Fmaxy := Maxy; end if; if Z.Fminy < Z.Fmaxy then Minx := Mm.Minx * 3240000; Maxx := Mm.Maxx * 3240000; if Maxx < 0 and then Z.Fminx > 0 then Minx := Minx + 360000000 * 3240000; Maxx := Maxx + 360000000 * 3240000; elsif Minx > 1 and then Z.Fmaxx < 0 then Minx := Minx - 360000000 * 3240000; Maxx := Maxx - 360000000 * 3240000; end if; if Z.Fminx < Minx then Z.Fminx := Minx; end if; if Z.Fmaxx > Maxx then Z.Fmaxx := Maxx; end if; end if; return Z; end Mz_Restrict_Zone_To; -- High-precision extension routines function Max_Mapcode_Precision return Natural is (8); -- PRIVATE lowest-level data access function Header_Letter (I : Natural) return String is Flags : constant Integer := Ndata.Data_Flags(I + 1); use Bits; begin if (Shr (Flags, 7) and 3) = 1 then return Encode_Char((Shr (Flags, 11) and 31) + 1) & ""; end if; return ""; end Header_Letter; function Smart_Div (I : Natural) return Integer is (Ndata.Data_Special1(I + 1)); function Is_Restricted (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and 512) /= 0; end Is_Restricted; function Is_Nameless (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and 64) /= 0; end Is_Nameless; function Is_Auto_Header (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and Shl (8, 5)) /= 0; end Is_Auto_Header; function Codex_Len (I : Natural) return Integer is use Bits; Flags : constant Integer := Ndata.Data_Flags (I + 1) and 31; begin return Flags / 5 + Flags rem 5 + 1; end Codex_Len; function Co_Dex (I : Natural) return Integer is use Bits; Flags : constant Integer := Ndata.Data_Flags (I + 1) and 31; begin return 10 * (Flags / 5) + Flags rem 5 + 1; end Co_Dex; function Is_Special_Shape (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and 1024) /= 0; end Is_Special_Shape; -- 1=pipe 2=plus 3=star function Rec_Type (I : Natural) return Integer is use Bits; begin return Shr (Ndata.Data_Flags(I + 1), 7) and 3; end Rec_Type; function First_Nameless_Record (Index : Natural; First_Code : Natural) return Natural is I : Integer := Index; Codex : constant Natural := Co_Dex (I); begin while I >= First_Code and then Co_Dex (I) = Codex and then Is_Nameless (I) loop I := I - 1; end loop; return I + 1; end First_Nameless_Record; function Count_Nameless_Records (Index : Natural; First_Code : Natural) return Natural is I : constant Natural := First_Nameless_Record (Index, First_Code); E : Natural := Index; Codex : constant Natural := Co_Dex (I); begin while Co_Dex(E) = Codex loop E := E + 1; end loop; return E - I; end Count_Nameless_Records; -- Return Lint immediately smaller than Real function Floor (X : Real) return Lint is Int : Lint; begin Int := Lint(X); if Real(Int) > X then Int := Int - 1; end if; return Int; end Floor; function Get_Encode_Rec(Lat, Lon : in Real) return Frac_Rec is Ilat : Real := Lat; Ilon : Real := Lon; D : Real; Fraclat, Fraclon : Lint; Lat32, Lon32 : Lint; begin if Ilat < -90.0 then Ilat := -90.0; elsif Ilat > 90.0 then Ilat := 90.0; end if; Ilat := Ilat + 90.0; -- Ilat now [0..180] Ilat := Ilat * 810000000000.0; Fraclat := Floor (Ilat + 0.1); D := Real (Fraclat) / 810000.0; Lat32 := Floor (D); Fraclat := Fraclat - Lat32 * 810000; Lat32 := Lat32 - 90000000; Ilon := Ilon - 360.0 * Real (Floor (Ilon / 360.0)); -- Lon now in [0..360> Ilon := Ilon * 3240000000000.0; Fraclon := Floor (Ilon + 0.1); D := Real (Fraclon) / 3240000.0; Lon32 := Floor (D); Fraclon := Fraclon - Lon32 * 3240000; if Lon32 >= 180000000 then Lon32 := Lon32 - 360000000; end if; return (Coord32 => (Y => Lat32, X => Lon32), Fraclat => Integer (Fraclat), Fraclon => Integer (Fraclon) ); end Get_Encode_Rec; function Encode_Base31 (Value : Lint; Nrchars : Natural) return String is Result : As_U.Asu_Us; Lv : Lint := Value; Ln : Natural := Nrchars; use type As_U.Asu_Us; begin while Ln > 0 loop Ln := Ln - 1; Result := Encode_Char(Integer (Lv rem 31) + 1) & Result; Lv := Lv / 31; end loop; return Result.Image; end Encode_Base31; -- Lowest level encode/decode routines function Decode_Base31 (Str : String) return Integer is Value : Integer := 0; C : Natural; begin for I in Str'Range loop C := Character'Pos (Str(I)); if C = 46 then -- Dot! return Value; end if; if Decode_Char(C + 1) < 0 then return Error; end if; Value := Value * 31 + Decode_Char(C + 1); end loop; return Value; end Decode_Base31; function Encode_Triple (Difx, Dify : Lint) return String is Rx, Ry, Cx, Cy : Lint; begin if Dify < 4 * 34 then Rx := Difx / 28; Ry := Dify / 34; Cx := Difx rem 28; Cy := Dify rem 34; return Encode_Char(Integer (Rx + 6 * Ry + 1)) & Encode_Base31 (Cx * 34 + Cy, 2); else Rx := Difx / 24; Cx := Difx rem 24; return Encode_Char(Integer (Rx + 25)) & Encode_Base31 (Cx * 40 + (Dify - 136), 2); end if; end Encode_Triple; function Decode_Triple (Input : String) return Coord_Rec is Triplex, Tripley : Integer; C1 : constant Character := Input(Input'First); I1 : constant Integer := Decode_Char(Character'Pos(C1) + 1); X : constant Integer := Decode_Base31 (Input(Positive'Succ(Input'First) .. Input'Last)); begin if I1 < 24 then Triplex := (I1 rem 6) * 28 + X / 34; Tripley := (I1 / 6) * 34 + X rem 34; else Tripley := X rem 40 + 136; Triplex := X / 40 + 24 * (I1 - 24); end if; return (Y => Lint (Tripley), X => Lint (Triplex)); end Decode_Triple; function Encode_Six_Wide (X, Y, Width, Height : in Integer) return Integer is D : Integer := 6; Col : Integer := X / 6; Maxcol : constant Integer := (Width - 4) / 6; begin if Col >= Maxcol then Col := Maxcol; D := Width - Maxcol * 6; end if; return Height * 6 * Col + (Height - 1 - Y) * D + X - Col * 6; end Encode_Six_Wide; function Decode_Six_Wide (V, Width, Height : in Integer) return Coord_Rec is D : Integer := 6; Col : Integer := V / (Height * 6); Maxcol : constant Integer := (Width - 4) / 6; W, X6, Y6 : Integer; begin if Col >= Maxcol then Col := Maxcol; D := Width - Maxcol * 6; end if; W := V - Col * Height * 6; X6 := Col * 6 + W rem D; Y6 := Height - 1 - W / D; return (Y => Lint (Y6), X => Lint (X6)); end Decode_Six_Wide; function Encode_Extension ( Input : String; Enc : Frac_Rec; Extrax4, Extray, Dividerx4, Dividery : Lint; Extradigits, Ydirection : Integer) return String is Factorx, Factory, Valx, Valy : Lint; Gx, Gy, Column1, Column2, Row1, Row2 : Integer; Digit : Integer := Extradigits; Result : As_U.Asu_Us; begin if Extradigits = 0 then return Input; end if; if Digit > Max_Mapcode_Precision then Digit := Max_Mapcode_Precision; end if; Result := As_U.Tus (Input); -- The following are all perfect integers -- 810000 = 30^4 Factorx := 810000 * Dividerx4; Factory := 810000 * Dividery; Valx := 810000 * Extrax4 + Lint (Enc.Fraclon); Valy := 810000 * Extray + Lint (Enc.Fraclat) * Lint (Ydirection); -- Protect against floating point errors if Valx < 0 then Valx := 0; elsif Valx >= Factorx then Valx := Factorx - 1; end if; if Valy < 0 then Valy := 0; elsif Valy >= Factory then Valy := Factory - 1; end if; Result.Append ('-'); loop Factorx := Factorx / 30; Gx := Integer (Valx / Factorx); Factory := Factory / 30; Gy := Integer (Valy / Factory); Column1 := Gx / 6; Row1 := Gy / 5; Result.Append (Encode_Char(Row1 * 5 + Column1 + 1)); Digit := Digit - 1; exit when Digit = 0; Column2 := Gx rem 6; Row2 := Gy rem 5; Result.Append (Encode_Char(Row2 * 6 + Column2 + 1)); Digit := Digit - 1; exit when Digit = 0; Valx := Valx - Factorx * Lint (Gx); Valy := Valy - Factory * Lint (Gy); end loop; return Result.Image; end Encode_Extension; -- Returns (possibly empty) MapcodeZone function Decode_Extension ( Extension_Chars : String; Coord32 : Coord_Rec; Dividerx4, Dividery, Lon_Offset4, Extremelatmicrodeg, Maxlonmicrodeg : Lint) return Mapcode_Zone_Rec is Processor : Lint := 1; Lon32, Lat32 : Lint := 0; Odd : Boolean := False; Idx : Positive; Column1, Row1, Column2, Row2 : Lint; C1, C2 : Character; N1, N2 : Integer; Ldivx4, Ldivy : Lint; Lon4, Lat1: Lint; Mapcode_Zone : Mapcode_Zone_Rec; begin if Extension_Chars'Length > 8 then -- Too many digits return Mz_Empty; end if; Idx := Extension_Chars'First; while Idx <= Extension_Chars'Length loop C1 := Extension_Chars(Idx); N1 := Decode_Char(Character'Pos(C1) + 1); Idx := Idx + 1; if N1 < 0 or else N1 = 30 then return Mz_Empty; end if; Row1 := Lint (N1 / 5); Column1 := Lint (N1 rem 5); if Idx <= Extension_Chars'Length then C2 := Extension_Chars(Idx); N2 := Decode_Char(Character'Pos(C2) + 1); Idx := Idx + 1; if N2 < 0 or else N2 = 30 then return Mz_Empty; end if; Row2 := Lint (N2 / 6); Column2 := Lint (N2 rem 6); else Row2 := 0; Column2 := 0; Odd := True; end if; Processor := Processor * 30; Lon32 := Lon32 * 30 + Column1 * 6 + Column2; Lat32 := Lat32 * 30 + Row1 * 5 + Row2; end loop; Ldivx4 := Dividerx4; Ldivy := Dividery; while Processor < 810000 loop Ldivx4 := Ldivx4 * 30; Ldivy := Ldivy * 30; Processor := Processor * 30; end loop; Lon4 := Coord32.X * 3240000 + Lon32 * Ldivx4 + Lon_Offset4 * 810000; Lat1 := Coord32.Y * 810000 + Lat32 * Ldivy; if Odd then Mapcode_Zone := Mz_Set_From_Fractions (Lat1, Lon4, 5 * Ldivy, 6 * Ldivx4); else Mapcode_Zone := Mz_Set_From_Fractions (Lat1, Lon4, Ldivy, Ldivx4); end if; -- FORCE_RECODE: restrict the coordinate range to the extremes that were -- provided if Mapcode_Zone.Fmaxx > Maxlonmicrodeg * 3240000 then Mapcode_Zone.Fmaxx := Maxlonmicrodeg * 3240000; end if; if Ldivy >= 0 then if Mapcode_Zone.Fmaxy > Extremelatmicrodeg * 810000 then Mapcode_Zone.Fmaxy := Extremelatmicrodeg * 810000; end if; else if Mapcode_Zone.Fminy < Extremelatmicrodeg * 810000 then Mapcode_Zone.Fminy := Extremelatmicrodeg * 810000; end if; end if; return Mapcode_Zone; end Decode_Extension; -- Add vowels to prevent a mapcode r from being all-digit function Aeu_Pack (R : As_U.Asu_Us; Short : Boolean) return String is Dotpos : Natural := 0; Result : As_U.Asu_Us := R; Rlen : Natural := Result.Length; Rest : As_U.Asu_Us; V : Integer; use type As_U.Asu_Us; begin for D in 1 .. Rlen loop if Result.Element (D) < '0' or else Result.Element (D) > '9' then -- Not digit? if Result.Element (D) = '.' and then Dotpos = 0 then -- First dot? Dotpos := D; elsif R.Element (D) = '-' then Rest := Result.Uslice (D, Result.Length); Result := Result.Uslice (1, D - 1); Rlen := D - 1; exit; else return Result.Image; end if; end if; end loop; -- Does Result have a dot, AND at least 2 chars before and after the dot? if Dotpos >= 3 and then Rlen - 2 >= Dotpos then if Short then -- v1.50 new way: use only A V := (Character'Pos(Result.Element (1)) - 48) * 100 + (Character'Pos(Result.Element (Rlen - 1)) - 48) * 10 + Character'Pos(Result.Element (Rlen)) - 48; Result := 'A' & Result.Uslice (2, Rlen - 2) & Encode_Char(V / 32 + 1) & Encode_Char(V rem 32 + 1); else -- Old way: use A, E and U */ V := (Character'Pos(Result.Element(Rlen - 1)) - 48) * 10 + Character'Pos(Result.Element(Rlen)) - 48; Result := Result.Uslice(1, Rlen - 2) & Encode_Char(V / 34 + 32) & Encode_Char(V rem 34 + 1); end if; end if; Result.Append (Rest); return Result.Image; end Aeu_Pack; -- Remove vowels from mapcode str into an all-digit mapcode -- (Assumes str is already uppercase!) function Aeu_Unpack (Str : String) return String is Voweled, Has_Letters : Boolean := False; Lastpos : constant Natural := Str'Length; Result : As_U.Asu_Us := As_U.Tus (Str); Dotpos : Natural := Result.Locate ("."); V, V1, V2 : Integer; S : String (1 .. 4); C : Character; use type As_U.Asu_Us; begin if Dotpos < 3 or else Lastpos < Dotpos + 2 then -- No dot, or less than 2 letters before dot, or less than 2 letters -- after dot return Str; end if; if Result.Element(1) = 'A' then -- V1.50 V1 := Decode_Char(Character'Pos(Result.Element(Lastpos)) + 1); if V1 < 0 then V1 := 31; end if; V2 := Decode_Char(Character'Pos(Result.Element(Lastpos - 1)) + 1); if V2 < 0 then V2 := 31; end if; S := Image (1000 + V1 + 32 * V2); Result := S(2) & Result.Uslice(2, Lastpos - 2) & S(3 .. 4); Voweled := True; elsif Result.Element(1) = 'U' then Result.Delete (1, 1); Dotpos := Dotpos - 1; Voweled := True; else C := Result.Element(Lastpos - 1); V := Character'Pos(C); if C = 'A' then V := 0; elsif C = 'E'then V := 34; elsif C = 'U' then V := 68; else V := -1; end if; if V >= 0 then C := Result.Element (Lastpos); if C = 'A' then V := V + 31; elsif C = 'E' then V := V + 32; elsif C = 'U' then V := V + 33; else V1 := Decode_Char(Character'Pos(Result.Element(Lastpos)) + 1); if V1 < 0 then return Undefined; end if; V := V + V1; end if; if V >= 100 then return Undefined; end if; Voweled := True; Result := Result.Uslice (1, Lastpos - 2) & Encode_Char(V / 10 + 1) & Encode_Char(V rem 10 + 1); end if; end if; if Dotpos < 3 or else Dotpos > 6 then return Undefined; end if; for I in 1 .. Lastpos loop if I /= Dotpos then V := Decode_Char(Character'Pos(Result.Element(I)) + 1); if V < 0 then -- Bad char! return Undefined; elsif V > 9 then Has_Letters := True; end if; end if; end loop; if Voweled and then Has_Letters then return Undefined; end if; if not Voweled and then not Has_Letters then return Undefined; end if; return Result.Image; end Aeu_Unpack; -- Mid-level encode/decode function Encode_Nameless (Enc : Frac_Rec; M : Natural; First_Code : Natural; Extra_Digits : Integer) return String is A : constant Natural := Count_Nameless_Records (M, First_Code); P : constant Natural := 31 / A; R : constant Natural := 31 rem A; Codex : constant Natural := Co_Dex (M); Codexlen : constant Natural := Codex_Len(M); X : Integer; Storage_Offset, Base_Power, Base_Power_A : Lint; begin if A < 1 then return Undefined; end if; X := M - First_Nameless_Record (M, First_Code); if Codex /= 21 and then A <= 31 then Storage_Offset := Lint (X * P + (if X < R then X else R)) * 961 * 961; elsif Codex /= 21 and then A < 62 then if X < 62 - A then Storage_Offset := Lint (X) * (961 * 961); else Storage_Offset := Lint (62 - A + (X - 62 + A) / 2) * 961 * 961; if (X + A) rem 2 = 1 then Storage_Offset := Storage_Offset + 16 * 961 * 31; end if; end if; else Base_Power := (if Codex = 21 then 961 * 961 else 961 * 961 * 31); Base_Power_A := Base_Power / Lint (A); if A = 62 then Base_Power_A := Base_Power_A + 1; else Base_Power_A := 961 * (Base_Power_A / 961); end if; Storage_Offset := Lint (X) * Base_Power_A; end if; declare Mm : constant Min_Max_Rec := Min_Max_Setup (M); Side : Integer := Smart_Div (M); Org_Side : constant Integer := Side; X_Side : Integer := Side; -- Note that xDivider4 is 4 times too large Dividerx4 : constant Lint := Lint (Xdivider4 (Mm.Miny, Mm.Maxy)); Xfracture : constant Lint := Lint (Enc.Fraclon) / 810000; -- Dx is in millionths Dx : constant Lint := (4 * (Enc.Coord32.X - Mm.Minx) + Xfracture) / Dividerx4; -- Extrax4 is in quarter-millionths Extrax4 : constant Lint := (Enc.Coord32.X - Mm.Minx) * 4 - Dx * Dividerx4; Dividery : constant Lint := 90; Dy : Lint := (Mm.Maxy - Enc.Coord32.Y) / Dividery; Extray : Lint := (Mm.Maxy - Enc.Coord32.Y) rem Dividery; V : Lint; Result : As_U.Asu_Us; use type As_U.Asu_Us; begin if Extray = 0 and then Enc.Fraclat > 0 then Dy := Dy - 1; Extray := Extray + Dividery; end if; V := Storage_Offset; if Is_Special_Shape (M) then X_Side := X_Side * Side; Side := Integer (1 + (Mm.Maxy - Mm.Miny) / 90); X_Side := X_Side / Side; V := V + Lint (Encode_Six_Wide (Integer (Dx), Side - 1 - Integer(Dy), X_Side, Side)); else V := V + (Dx * Lint (Side) + Dy); end if; Result := As_U.Tus (Encode_Base31 (V, Codexlen + 1)); if Codexlen = 3 then Result := Result.Uslice (1, 2) & '.' & Result.Uslice (3, Result.Length); elsif Codexlen = 4 then if Codex = 22 and then Org_Side = 961 and then not Is_Special_Shape (M) then Result := As_U.Tus (Result.Element (1) & Result.Element (2) & Result.Element (4) & '.' & Result.Element (3) & Result.Element (5)); elsif Codex = 13 then Result := Result.Uslice (1, 2) & '.' & Result.Uslice (3, Result.Length); else Result := Result.Uslice (1, 3) & '.' & Result.Uslice (4, Result.Length); end if; end if; return Encode_Extension (Result.Image, Enc, Extrax4, Extray, Dividerx4, Dividery, Extra_Digits, -1); end; end Encode_Nameless; function Decode_Nameless (Input : String; Extension_Chars : String; M : Natural; First_Index : Natural) return Mapcode_Zone_Rec is Codex : constant Natural := Co_Dex (M); Result : As_U.Asu_Us; A : constant Natural := Count_Nameless_Records (M, First_Index); F : constant Natural := First_Nameless_Record (M, First_Index); P : constant Natural := 31 / A; R : constant Natural := 31 rem A; X, V, Offset : Integer; Swap_Letters : Boolean := False; Base_Power, Base_Power_A : Integer; use type As_U.Asu_Us; begin Result := As_U.Tus (Input); if Codex = 22 then Result := Result.Uslice (1, 3) & Result.Uslice (5, Result.Length); else Result := Result.Uslice (1, 2) & Result.Uslice (4, Result.Length); end if; if Codex /= 21 and then A <= 31 then Offset := Decode_Char(Character'Pos (Result.Element(1)) + 1); if Offset < R * (P + 1) then X := Offset / (P + 1); else Swap_Letters := P = 1 and then Codex = 22; X := R + (Offset - R * (P + 1)) / P; end if; elsif Codex /= 21 and then A < 62 then X := Decode_Char(Character'Pos (Result.Element(1)) + 1); if X < 62 - A then Swap_Letters := Codex = 22; else X := X + X - (62 - A); end if; else -- codex = 21 or else A >= 62 Base_Power := (if Codex = 21 then 961 * 961 else 961 * 961 * 31); Base_Power_A := Base_Power / A; if A = 62 then Base_Power_A := Base_Power_A + 1; else Base_Power_A := 961 * (Base_Power_A / 961); end if; -- Decode V := Decode_Base31 (Result.Image); X := V / Base_Power_A; V := V rem Base_Power_A; end if; if Swap_Letters then if not Is_Special_Shape (M + X) then Result := As_U.Tus (Result.Element (1) & Result.Element (2) & Result.Element (4) & Result.Element (3) & Result.Element (5)); end if; end if; if Codex /= 21 and then A <= 31 then V := Decode_Base31 (Result.Image); if X > 0 then V := V - (X * P + (if X < R then X else R)) * (961 * 961); end if; elsif Codex /= 21 and then A < 62 then V := Decode_Base31 (Result.Slice (2, Result.Length)); if X >= 62 - A then if V >= 16 * 961 * 31 then V := V - 16 * 961 * 31; X := X + 1; end if; end if; end if; if X > A then -- past end! return Mz_Empty; end if; declare Lm : constant Natural := F + X; Mm : constant Min_Max_Rec := Min_Max_Setup (Lm); Side : Integer := Smart_Div (Lm); X_Side : Integer := Side; D : Coord_Rec; Dividerx4 : constant Lint := Lint (Xdivider4 (Mm.Miny, Mm.Maxy)); Dividery : constant Lint := 90; Corner : Coord_Rec; begin X_Side := Side; if Is_Special_Shape(Lm) then X_Side := X_Side * Side; Side := Integer (1 + (Mm.Maxy - Mm.Miny) / 90); X_Side := X_Side / Side; D := Decode_Six_Wide(V, X_Side, Side); D.Y := Lint (Side) - 1 - D.Y; else D.X := Lint (V / Side); D.Y := Lint (V rem Side); end if; if D.X >= Lint (X_Side) then -- Out-of-range! return Mz_Empty; end if; Corner := ( Y => Mm.Maxy - D.Y * Dividery, X => Mm.Minx + (D.X * Dividerx4) / 4); return Decode_Extension(Extension_Chars, Corner, Dividerx4, -Dividery, (D.X * Dividerx4) rem 4, Mm.Miny, Mm.Maxx); end; end Decode_Nameless; function Encode_Auto_Header (Enc : Frac_Rec; M : Natural; Extradigits : in Natural) return String is Codex : constant Integer := Co_Dex(M); Codexlen : constant Integer := Codex_Len (M); First_Index : Integer := M; I : Integer; Mm : Min_Max_Rec; H : Lint; Xdiv : Natural; W : Lint; Product : Lint; Good_Rounder : Lint; Storage_Start : Lint := 0; Dividerx, Dividery, Vx, Vy, Extrax, Extray, Spx, Spy, Value : Lint; Mapc : As_U.Asu_Us; use Bits; begin while Is_Auto_Header (First_Index - 1) and then Co_Dex (First_Index - 1) = Codex loop First_Index := First_Index - 1; end loop; I := First_Index; while Co_Dex (I) = Codex loop Mm := Min_Max_Setup (I); H := (Mm.Maxy - Mm.Miny + 89) / 90; Xdiv := Xdivider4 (Mm.Miny, Mm.Maxy); W := ((Mm.Maxx - Mm.Minx) * 4 + Lint (Xdiv) - 1) / Lint (Xdiv); H := 176 * ((H + 176 - 1) / 176); W := 168 * ((W + 168 - 1) / 168); Product := (W / 168) * (H / 176) * 961 * 31; if Rec_Type (I) = 2 then -- *+ Good_Rounder := (if Codex >= 23 then 961 * 961 * 31 else 961 * 961); Product := (Storage_Start + Product + Good_Rounder - 1) / Good_Rounder * Good_Rounder - Storage_Start; end if; if I = M and then Fits_Inside (Enc.Coord32, Mm) then Dividerx := (Mm.Maxx - Mm.Minx + W - 1) / W; Vx := (Enc.Coord32.X - Mm.Minx) / Dividerx; Extrax := (Enc.Coord32.X - Mm.Minx) rem Dividerx; Dividery := (Mm.Maxy - Mm.Miny + H - 1) / H; Vy := (Mm.Maxy - Enc.Coord32.Y) / Dividery; Extray := (Mm.Maxy - Enc.Coord32.Y) rem Dividery; Spx := Vx rem 168; Vx := Vx / 168; Value := Vx * (H / 176); if Extray = 0 and then Enc.Fraclat > 0 then Vy := Vy - 1; Extray := Extray + Dividery; end if; Spy := Vy rem 176; Vy := Vy / 176; Value := Value + Vy; Mapc := As_U.Tus ( Encode_Base31 (Storage_Start / (961 * 31) + Value, Codexlen - 2) & "." & Encode_Triple (Spx, Spy)); return Encode_Extension (Mapc.Image, Enc, Shl (Extrax, 2), Extray, Shl( Dividerx, 2), Dividery, Extradigits, -1); end if; Storage_Start := Storage_Start + Product; I := I + 1; end loop; return Undefined; end Encode_Auto_Header; function Decode_Auto_Header (Input : String; Extension_Chars : String; M : Natural) return Mapcode_Zone_Rec is Storage_Start : Lint := 0; Codex : constant Integer := Co_Dex(M); -- Decode (before dot) Value : Lint := Lint (Decode_Base31 (Input)); Triple : Coord_Rec; Lm : Natural; Mm : Min_Max_Rec; H : Lint; Xdiv : Lint; W : Lint; Product : Lint; Good_Rounder : Lint; Dividerx, Dividery, Vx, Vy : Lint; Corner : Coord_Rec; use Bits; begin Value := Value * (961 * 31); -- Decode bottom Triple := Decode_Triple (Input (Input'Last - 2 .. Input'Last)); Lm := M; while Co_Dex (Lm) = Codex and then Rec_Type (Lm) > 1 loop Mm := Min_Max_Setup (Lm); H := (Mm.Maxy - Mm.Miny + 89) / 90; Xdiv := Lint (Xdivider4 (Mm.Miny, Mm.Maxy)); W := ((Mm.Maxx - Mm.Minx) * 4 + (Xdiv - 1)) / Xdiv; H := 176 * ((H + 176 - 1) / 176); W := 168 * ((W + 168 - 1) / 168); Product := (W / 168) * (H / 176) * 961 * 31; if Rec_Type (Lm) = 2 then Good_Rounder := (if Codex >= 23 then 961 * 961 * 31 else 961 * 961); Product := ((Storage_Start + Product + Good_Rounder - 1) / Good_Rounder) * Good_Rounder - Storage_Start; end if; if Value >= Storage_Start and then Value < Storage_Start + Product then -- Code belongs here? Dividerx := (Mm.Maxx - Mm.Minx + W - 1) / W; Dividery := (Mm.Maxy - Mm.Miny + H - 1) / H; Value := Value - Storage_Start; Value := Value / (961 * 31); Vx := Triple.X + 168 * (Value / (H / 176)); Vy := Triple.Y + 176 * (Value rem (H / 176)); Corner := ( -- In microdegrees Y => Mm.Maxy - Vy * Dividery, X => Mm.Minx + Vx * Dividerx); if Corner.Y /= Mm.Maxy and then not Fits_Inside (Corner, Mm) then return Mz_Empty; end if; return Decode_Extension (Extension_Chars, Corner, Shl (Dividerx, 2), -Dividery, 0, Mm.Miny, Mm.Maxx); -- autoheader end if; Storage_Start := Storage_Start + Product; Lm := Lm + 1; end loop; return Mz_Empty; end Decode_Auto_Header; function Encode_Grid (Enc : Frac_Rec; M : Natural; Mm : Min_Max_Rec; Headerletter : in String; Extradigits : in Natural) return String is Orgcodex : constant Integer := Co_Dex(M); Codex : Integer := Orgcodex; Prefixlength, Postfixlength : Integer; Divx, Divy : Integer; Xgridsize, Ygridsize, X, Relx, Rely : Lint; V : Integer; Result, Postfix : As_U.Asu_Us; Dividery, Dividerx : Lint; Difx, Dify, Extrax, Extray : Lint; use Bits; use type As_U.Asu_Us; begin if Codex = 21 then Codex := 22; end if; if Codex = 14 then Codex := 23; end if; Prefixlength := Codex / 10; Postfixlength := Codex rem 10; Divy := Smart_Div(M); if Divy = 1 then Divx := X_Side(Prefixlength + 1); Divy := Y_Side(Prefixlength + 1); else Divx := Nc(Prefixlength + 1) / Divy; end if; Ygridsize := (Mm.Maxy - Mm.Miny + Lint (Divy) - 1) / Lint (Divy); Rely := Enc.Coord32.Y - Mm.Miny; Rely := Rely / Ygridsize; Xgridsize := (Mm.Maxx - Mm.Minx + Lint (Divx) - 1) / Lint (Divx); X := Enc.Coord32.X; Relx := X - Mm.Minx; if Relx < 0 then X := X + 360000000; Relx := Relx + 360000000; elsif Relx >= 360000000 then X := X - 360000000; Relx := Relx - 360000000; end if; -- 1.32 fix FIJI edge case if Relx < 0 then return ""; end if; Relx := Relx / Xgridsize; if Relx >= Lint (Divx) then return ""; end if; if Divx /= Divy and then Prefixlength > 2 then -- D = 6 V := Encode_Six_Wide (Integer (Relx), Integer (Rely), Divx, Divy); else V := Integer (Relx) * Divy + (Divy - 1 - Integer (Rely)); end if; Result := As_U.Tus (Encode_Base31 (Lint (V), Prefixlength)); if Prefixlength = 4 and then Divx = 961 and then Divy = 961 then Result := As_U.Tus (Result.Element(1) & Result.Element(3) & Result.Element(2) & Result.Element(4)); end if; Rely := Mm.Miny + Rely * Ygridsize; Relx := Mm.Minx + Relx * Xgridsize; Dividery := (Ygridsize + Lint (Y_Side(Postfixlength + 1)) - 1) / Lint (Y_Side(Postfixlength + 1)); Dividerx := (Xgridsize + Lint (X_Side(Postfixlength + 1)) - 1) / Lint (X_Side(Postfixlength + 1)); Result.Append ("."); -- Encoderelative Difx := X - Relx; Dify := Enc.Coord32.Y - Rely; Extrax := Difx rem Dividerx; Extray := Dify rem Dividery; Difx := Difx / Dividerx; Dify := Dify / Dividery; Dify := Lint (Y_Side(Postfixlength + 1)) - 1 - Dify; if Postfixlength = 3 then Result.Append (Encode_Triple (Difx, Dify)); else Postfix := As_U.Tus (Encode_Base31 ( Difx * Lint (Y_Side(Postfixlength + 1)) + Dify, Postfixlength)); if Postfixlength = 4 then Postfix := As_U.Tus (Postfix.Element(1) & Postfix.Element(3) & Postfix.Element(2) & Postfix.Element(4)); end if; Result.Append (Postfix); end if; if Orgcodex = 14 then Result := Result.Element(1) & '.' & Result.Element(2) & Result.Uslice (4, Result.Length); end if; return Encode_Extension (Headerletter & Result.Image, Enc, Shl (Extrax, 2), Extray, Shl (Dividerx, 2), Dividery, Extradigits, 1); end Encode_Grid; function Decode_Grid (Input, Extension_Chars : String; M : Natural) return Mapcode_Zone_Rec is Linput : As_U.Asu_Us := As_U.Tus (Input); Prefixlength, Postfixlength : Natural; Divx, Divy : Integer; V : Integer; Rel : Coord_Rec; Mm : Min_Max_Rec; Xgridsize, Ygridsize : Lint; Xp, Yp, Dividerx, Dividery : Lint; Rest : As_U.Asu_Us; Dif : Coord_Rec; Corner : Coord_Rec; Decodemaxx, Decodemaxy : Lint; use Bits; use type As_U.Asu_Us; begin Prefixlength := Linput.Locate (".") - 1; Postfixlength := Linput.Length - 1 - Prefixlength; if Prefixlength = 1 and then Postfixlength = 4 then Prefixlength := Prefixlength + 1; Postfixlength:= Postfixlength - 1; Linput := Linput.Element(1) & Linput.Element(3) & '.' & Linput.Uslice (4, Linput.Length); end if; Divy := Smart_Div(M); if Divy = 1 then Divx := X_Side(Prefixlength + 1); Divy := Y_Side(Prefixlength + 1); else Divx := Nc(Prefixlength + 1) / Divy; end if; if Prefixlength = 4 and then Divx = 961 and then Divy = 961 then Linput := Linput.Element(1) & Linput.Element(3) & Linput.Element(2) & Linput.Uslice (4, Linput.Length); end if; V := Decode_Base31 (Linput.Image); if Divx /= Divy and then Prefixlength > 2 then -- D = 6 Rel := Decode_Six_Wide (V, Divx, Divy); else Rel.X := Lint (V / Divy); Rel.Y := Lint (Divy - 1 - V rem Divy); end if; Mm := Min_Max_Setup (M); Ygridsize := (Mm.Maxy - Mm.Miny + Lint (Divy) - 1) / Lint (Divy); Xgridsize := (Mm.Maxx - Mm.Minx + Lint (Divx) - 1) / Lint (Divx); Rel.Y := Mm.Miny + Rel.Y * Ygridsize; Rel.X := Mm.Minx + Rel.X * Xgridsize; Xp := Lint (X_Side(Postfixlength + 1)); Dividerx := (Xgridsize + Xp - 1) / Xp; Yp := Lint (Y_Side(Postfixlength + 1)); Dividery := (Ygridsize + Yp - 1) / Yp; Rest := Linput.Uslice(Prefixlength + 2, Linput.Length); if Postfixlength = 3 then Dif := Decode_Triple (Rest.Image); else if Postfixlength = 4 then Rest := As_U.Tus (Rest.Element (1) & Rest.Element(3) & Rest.Element(2) & Rest.Element(4)); end if; V := Decode_Base31 (Rest.Image); Dif.X := Lint (V) / Yp; Dif.Y := Lint (V) rem Yp; end if; Dif.Y := Yp - 1 - Dif.Y; Corner := (Y => Rel.Y + Dif.Y * Dividery, X => Rel.X + Dif.X * Dividerx); if not Fits_Inside (Corner, Mm) then return Mz_Empty; end if; Decodemaxx := (if Rel.X + Xgridsize < Mm.Maxx then Rel.X + Xgridsize else Mm.Maxx); Decodemaxy := (if Rel.Y + Ygridsize < Mm.Maxy then Rel.Y + Ygridsize else Mm.Maxy); return Decode_Extension (Extension_Chars, Corner, Shl (Dividerx, 2), Dividery, 0, Decodemaxy, Decodemaxx); end Decode_Grid; -- Mapcoder engine Max_Nr_Of_Mapcode_Results : constant := 22; function Mapcoder_Engine (Enc : Frac_Rec; Tn : in Integer; Get_Shortest : Boolean; State_Override : Integer; Extra_Digits : Integer) return Mapcode_Infos is Results : Mapcode_Infos (1 .. Max_Nr_Of_Mapcode_Results); Nb_Results : Natural := 0; From_Territory : Integer := 0; Upto_Territory : Integer := Ccode_Earth; Original_Length : Natural; From, Upto : Integer; Store_Code : Integer; Mc_Info : Mapcode_Info; Go_On : Boolean; -- Scan a range of territories procedure Scan (Territory_Number : Integer) is Mm : Min_Max_Rec; R : As_U.Asu_Us; use type As_U.Asu_Us; begin for I in From .. Upto loop -- Exlude 54 and 55 if Co_Dex(I) < 54 then Mm := Min_Max_Setup (I); if Fits_Inside (Enc.Coord32, Mm) then if Is_Nameless (I) then R := As_U.Tus (Encode_Nameless (Enc, I, From, Extra_Digits)); elsif Rec_Type(I) > 1 then R := As_U.Tus (Encode_Auto_Header (Enc, I, Extra_Digits)); elsif I = Upto and then Get_Parent (Territories (Territory_Number)) >= 0 then declare More_Results : constant Mapcode_Infos := Mapcoder_Engine (Enc, Get_Parent (Territories (Territory_Number)), Get_Shortest, Territory_Number, Extra_Digits); T : constant Natural := Nb_Results; N : constant Natural := More_Results'Length; begin if N > 0 then Nb_Results := Nb_Results + N; if Nb_Results > Max_Nr_Of_Mapcode_Results then Nb_Results := Max_Nr_Of_Mapcode_Results; end if; Results (T + 1 .. Nb_Results) := More_Results; end if; R.Set_Null; end; else if Is_Restricted (I) and then Nb_Results = Original_Length then -- Restricted, and no shorter mapcodes exist: -- do not generate mapcodes R.Set_Null; else R := As_U.Tus (Encode_Grid (Enc, I, Mm, Header_Letter(I), Extra_Digits)); end if; end if; if R.Length > 4 then R := As_U.Tus (Aeu_Pack (R, False)); Store_Code := Territory_Number; if State_Override >= 0 then Store_Code := State_Override; end if; Mc_Info.Mapcode := R; Mc_Info.Territory_Alpha_Code := As_U.Tus (Get_Territory_Alpha_Code (Territories (Store_Code))); Mc_Info.Full_Mapcode := (if Store_Code = Ccode_Earth then As_U.Asu_Null else Mc_Info.Territory_Alpha_Code & " ") & R; Mc_Info.Territory := Territories (Store_Code); Nb_Results := Nb_Results + 1; Results (Nb_Results) := Mc_Info; exit when Get_Shortest; end if; end if; end if; end loop; end Scan; begin if Tn in From_Territory .. Upto_Territory then From_Territory := Tn; Upto_Territory := Tn; end if; for Territory_Number in From_Territory .. Upto_Territory loop Go_On := True; Original_Length := Nb_Results; From := Data_First_Record (Territory_Number); if Ndata.Data_Flags(From + 1) = 0 then Go_On := False; end if; if Go_On then Upto := Data_Last_Record (Territory_Number); if Territory_Number /= Ccode_Earth and then not Fits_Inside (Enc.Coord32, Min_Max_Setup (Upto)) then Go_On := False; end if; end if; if Go_On then Scan (Territory_Number); end if; end loop; return Results (1 .. Nb_Results); end Mapcoder_Engine; function Master_Decode (Mapcode : String; Territory_Number : Natural) return Coordinate is Map_Code : As_U.Asu_Us := As_U.Tus (Mapcode); Extensionchars : As_U.Asu_Us; Minpos : constant Natural := Map_Code.Locate ("-"); Mclen : Positive; Number : Natural; Parent : Integer; From, Upto : Integer; Prefixlength, Postfixlength, Incodex : Integer; Zone : Mapcode_Zone_Rec; Codex : Integer; Nr_Zone_Overlaps : Natural; Coord32 : Coord_Rec; Zfound, Z : Mapcode_Zone_Rec; procedure Try_Smaller (M : in Integer) is begin for J in From .. M - 1 loop -- Try all smaller rectangles j if not Is_Restricted (J) then Z := Mz_Restrict_Zone_To (Zone, Min_Max_Setup (J)); if not Mz_Is_Empty (Z) then Nr_Zone_Overlaps := Nr_Zone_Overlaps + 1; if Nr_Zone_Overlaps = 1 then -- First fit! remember... Zfound := Z; else -- More than one hit, give up exit; end if; end if; end if; end loop; end Try_Smaller; begin if Minpos > 1 then Extensionchars := Map_Code.Uslice (Minpos + 1, Map_Code.Length); Map_Code := Map_Code.Uslice (1, Minpos - 1); end if; Map_Code := As_U.Tus (Aeu_Unpack (Map_Code.Image)); if Map_Code.Is_Null then -- Failed to decode! raise Decode_Error; end if; Mclen := Map_Code.Length; Number := Territory_Number; if Mclen >= 10 then Number := Ccode_Earth; end if; -- Long codes in states are handled by the country Parent := Get_Parent (Territories (Number)); if Parent >= 0 then if Mclen >= 9 or else (Mclen >= 8 and then (Parent = Ccode_Ind or else Parent = Ccode_Mex)) then Number := Parent; end if; end if; From := Data_First_Record (Number); if From < 0 or else Ndata.Data_Flags(From + 1) = 0 then raise Decode_Error; end if; Upto := Data_Last_Record (Number); Prefixlength := Map_Code.Locate (".") - 1; Postfixlength := Mclen - 1 - Prefixlength; Incodex := Prefixlength * 10 + Postfixlength; Zone := Mz_Empty; for M in From .. Upto loop Codex := Co_Dex (M); if Rec_Type (M) = 0 and then not Is_Nameless(M) and then (Incodex = Codex or else (Incodex = 22 and then Codex = 21)) then Zone := Decode_Grid (Map_Code.Image, Extensionchars.Image, M); -- First of all, make sure the zone fits the country Zone := Mz_Restrict_Zone_To (Zone, Min_Max_Setup (Upto)); if not Mz_Is_Empty (Zone) and then Is_Restricted (M) then Nr_Zone_Overlaps := 0; -- Get midpoint in microdegrees Coord32 := Convert_Fractions_To_Coord32 ( Mz_Mid_Point_Fractions (Zone)); for J in reverse M - 1 .. From loop -- Look in previous rects if not Is_Restricted (J) then if Fits_Inside (Coord32, Min_Max_Setup (J)) then Nr_Zone_Overlaps := Nr_Zone_Overlaps + 1; exit; end if; end if; end loop; if Nr_Zone_Overlaps = 0 then -- See if mapcode zone OVERLAPS any sub-area... Try_Smaller (M); if Nr_Zone_Overlaps = 1 then -- Intersected exactly ONE sub-area? -- Use the intersection found... Zone := Zfound; end if; end if; if Nr_Zone_Overlaps = 0 then Zone := Mz_Empty; end if; end if; exit; elsif Rec_Type(M) = 1 and then Codex + 10 = Incodex and then Header_Letter(M)'Length = 1 and then Header_Letter(M)(1) = Map_Code.Element (1) then Zone := Decode_Grid (Map_Code.Slice(2, Map_Code.Length), Extensionchars.Image, M); exit; elsif Is_Nameless (M) and then ((Codex = 21 and then Incodex = 22) or else (Codex = 22 and then Incodex = 32) or else (Codex = 13 and then Incodex = 23)) then Zone := Decode_Nameless (Map_Code.Image, Extensionchars.Image, M, From); exit; elsif Rec_Type(M) > 1 and then Postfixlength = 3 and then Codex_Len(M) = Prefixlength + 2 then Zone := Decode_Auto_Header (Map_Code.Image, Extensionchars.Image, M); exit; end if; end loop; Zone := Mz_Restrict_Zone_To (Zone, Min_Max_Setup (Upto)); if Mz_Is_Empty(Zone) then raise Decode_Error; end if; return Convert_Fractions_To_Degrees (Wrap (Mz_Mid_Point_Fractions (Zone))); end Master_Decode; -- Legacy interface function Encode (Coord : Coordinate; Territory_Code : String := ""; Shortest : Boolean := False; Precision : Precisions := 0; Sort : Boolean := False) return Mapcode_Infos is Result : Mapcode_Infos := Mapcoder_Engine ( Enc => Get_Encode_Rec (Coord.Lat, Coord.Lon), Tn => (if Territory_Code = "" then Error else Integer (Get_Territory (Territory_Code))), Get_Shortest => Shortest, State_Override => -1, Extra_Digits => Precision); -- First and last index of the mapcodes, of the same territory, -- producing the shortest mapcode First, Last : Natural := 0; Len : Positive := Positive'Last; use type As_U.Asu_Us; begin if not Sort then return Result; end if; -- Search shortest mapcode (First) and the last mapcode for the -- same territory as First for I in Result'Range loop if Result(I).Mapcode.Length < Len then First := I; Len := Result(I).Mapcode.Length; end if; if Result(I).Territory_Alpha_Code = Result(First).Territory_Alpha_Code then Last := I; end if; end loop; -- Move First .. Last at beginning of list if First /= Result'First then declare Slice : constant Mapcode_Infos := Result(First .. Last); begin Result(Last-First+2 .. Last) := Result(Result'First .. First-1); Result(Result'First .. Result'First+Last-First) := Slice; end; end if; return Result; end Encode; function Decode (Mapcode, Context : String) return Coordinate is Contextterritorynumber : Integer; begin -- Raise Decode error if Mapcode or Context is not in Roman declare Lm, Lc : Mapcodes.Languages.Language_List; use type Mapcodes.Languages.Language_List; begin Lm := Mapcodes.Languages.Get_Language ( Ada.Characters.Handling.To_Wide_String (Mapcode)); if Context /= "" then Lc := Mapcodes.Languages.Get_Language ( Ada.Characters.Handling.To_Wide_String (Context)); else Lc := Mapcodes.Languages.Default_Language; end if; if Lm /= Mapcodes.Languages.Default_Language or else Lc /= Mapcodes.Languages.Default_Language then raise Decode_Error; end if; exception when Mapcodes.Languages.Invalid_Text => raise Decode_Error; end; -- Set context number if Context = Undefined then Contextterritorynumber := Ccode_Earth; else Contextterritorynumber := Integer (Get_Territory (Context)); end if; -- Decode return Master_Decode (Mapcode, Contextterritorynumber); end Decode; end Mapcodes;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2015, 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$ ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); -- GNAT: enforce generation of preinitialized data section instead of -- generation of elaboration code. package Matreshka.Internals.Unicode.Ucd.Core_001E is pragma Preelaborate; Group_001E : aliased constant Core_Second_Stage := (16#00# => -- 1E00 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#02# => -- 1E02 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#04# => -- 1E04 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#06# => -- 1E06 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#08# => -- 1E08 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#0A# => -- 1E0A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#0C# => -- 1E0C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#0E# => -- 1E0E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#10# => -- 1E10 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#12# => -- 1E12 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#14# => -- 1E14 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#16# => -- 1E16 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#18# => -- 1E18 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#1A# => -- 1E1A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#1C# => -- 1E1C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#1E# => -- 1E1E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#20# => -- 1E20 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#22# => -- 1E22 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#24# => -- 1E24 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#26# => -- 1E26 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#28# => -- 1E28 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#2A# => -- 1E2A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#2C# => -- 1E2C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#2D# => -- 1E2D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Soft_Dotted | Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#2E# => -- 1E2E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#30# => -- 1E30 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#32# => -- 1E32 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#34# => -- 1E34 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#36# => -- 1E36 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#38# => -- 1E38 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#3A# => -- 1E3A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#3C# => -- 1E3C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#3E# => -- 1E3E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#40# => -- 1E40 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#42# => -- 1E42 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#44# => -- 1E44 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#46# => -- 1E46 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#48# => -- 1E48 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#4A# => -- 1E4A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#4C# => -- 1E4C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#4E# => -- 1E4E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#50# => -- 1E50 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#52# => -- 1E52 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#54# => -- 1E54 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#56# => -- 1E56 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#58# => -- 1E58 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#5A# => -- 1E5A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#5C# => -- 1E5C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#5E# => -- 1E5E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#60# => -- 1E60 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#62# => -- 1E62 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#64# => -- 1E64 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#66# => -- 1E66 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#68# => -- 1E68 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#6A# => -- 1E6A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#6C# => -- 1E6C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#6E# => -- 1E6E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#70# => -- 1E70 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#72# => -- 1E72 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#74# => -- 1E74 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#76# => -- 1E76 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#78# => -- 1E78 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#7A# => -- 1E7A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#7C# => -- 1E7C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#7E# => -- 1E7E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#80# => -- 1E80 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#82# => -- 1E82 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#84# => -- 1E84 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#86# => -- 1E86 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#88# => -- 1E88 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#8A# => -- 1E8A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#8C# => -- 1E8C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#8E# => -- 1E8E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#90# => -- 1E90 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#92# => -- 1E92 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#94# => -- 1E94 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9A# .. 16#9B# => -- 1E9A .. 1E9B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9C# .. 16#9D# => -- 1E9C .. 1E9D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#9E# => -- 1E9E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9F# => -- 1E9F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#A0# => -- 1EA0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A2# => -- 1EA2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A4# => -- 1EA4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A6# => -- 1EA6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A8# => -- 1EA8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#AA# => -- 1EAA (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#AC# => -- 1EAC (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#AE# => -- 1EAE (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#B0# => -- 1EB0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#B2# => -- 1EB2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#B4# => -- 1EB4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#B6# => -- 1EB6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#B8# => -- 1EB8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#BA# => -- 1EBA (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#BC# => -- 1EBC (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#BE# => -- 1EBE (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#C0# => -- 1EC0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#C2# => -- 1EC2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#C4# => -- 1EC4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#C6# => -- 1EC6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#C8# => -- 1EC8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#CA# => -- 1ECA (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#CB# => -- 1ECB (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Soft_Dotted | Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#CC# => -- 1ECC (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#CE# => -- 1ECE (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#D0# => -- 1ED0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#D2# => -- 1ED2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#D4# => -- 1ED4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#D6# => -- 1ED6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#D8# => -- 1ED8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#DA# => -- 1EDA (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#DC# => -- 1EDC (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#DE# => -- 1EDE (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#E0# => -- 1EE0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#E2# => -- 1EE2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#E4# => -- 1EE4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#E6# => -- 1EE6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#E8# => -- 1EE8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#EA# => -- 1EEA (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#EC# => -- 1EEC (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#EE# => -- 1EEE (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#F0# => -- 1EF0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#F2# => -- 1EF2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#F4# => -- 1EF4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#F6# => -- 1EF6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#F8# => -- 1EF8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#FA# => -- 1EFA (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#FC# => -- 1EFC (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#FE# => -- 1EFE (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), others => (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False))); end Matreshka.Internals.Unicode.Ucd.Core_001E;
----------------------------------------------------------------------- -- components-utils-files -- Include raw files in the output -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; with Ada.Streams.Stream_IO; with ASF.Requests; with ASF.Contexts.Writer; with Util.Beans.Objects; with Util.Streams.Files; with Util.Log.Loggers; package body ASF.Components.Utils.Files is use Util.Log; -- The logger Log : constant Loggers.Logger := Loggers.Create ("ASF.Components.Utils.Files"); -- ------------------------------ -- Get the resource path that must be included. -- The resource path is identified by the <b>src</b> attribute. -- ------------------------------ function Get_Resource (UI : in UIFile; Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is Req : constant ASF.Requests.Request_Access := Context.Get_Request; Src : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context => Context, Name => "src"); begin if Util.Beans.Objects.Is_Null (Src) then UI.Log_Error ("Missing 'src' parameter"); return ""; else return Req.Get_Resource (Util.Beans.Objects.To_String (Src)); end if; end Get_Resource; -- ------------------------------ -- Copy the stream represented by <b>From</b> in the output stream associated with -- the context <b>Context</b>. When <b>Escape</b> is True, escape any special character -- using HTML escape rules. -- ------------------------------ procedure Copy (UI : in UIFile; From : in out Util.Streams.Input_Stream'Class; Escape : in Boolean; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is pragma Unreferenced (UI); use Ada.Streams; Writer : constant ASF.Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer; Buffer : Stream_Element_Array (0 .. 4_096); Last : Stream_Element_Offset; begin Writer.Close_Current; loop From.Read (Buffer, Last); if Last > Buffer'First then if not Escape then Writer.Write (Buffer (Buffer'First .. Last)); else for I in Buffer'First .. Last loop Writer.Write_Char (Char => Character'Val (Buffer (I))); end loop; end if; end if; exit when Last < Buffer'Last; end loop; end Copy; -- ------------------------------ -- Include in the output stream the resource identified by the <b>Get_Resource</b> -- function. -- ------------------------------ overriding procedure Encode_Begin (UI : in UIFile; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare Path : constant String := UIFile'Class (UI).Get_Resource (Context); Escape : constant Boolean := UI.Get_Attribute ("escape", Context, True); From : Util.Streams.Files.File_Stream; begin if Path /= "" then Log.Info ("Including file {0} in view", Path); From.Open (Name => Path, Mode => Ada.Streams.Stream_IO.In_File); UIFile'Class (UI).Copy (From, Escape, Context); end if; end; end Encode_Begin; end ASF.Components.Utils.Files;