content stringlengths 23 1.05M |
|---|
generic
type Number is private;
Zero : Number;
One : Number;
Two : Number;
with function Image (X : Number) return String is <>;
with function "+" (X, Y : Number) return Number is <>;
with function "/" (X, Y : Number) return Number is <>;
with function "mod" (X, Y : Number) return Number is <>;
with function ">=" (X, Y : Number) return Boolean is <>;
package Prime_Numbers is
type Number_List is array (Positive range <>) of Number;
procedure Put (List : Number_List);
task type Calculate_Factors is
entry Start (The_Number : in Number);
entry Get_Size (Size : out Natural);
entry Get_Result (List : out Number_List);
end Calculate_Factors;
end Prime_Numbers;
|
with STM32GD.Board;
procedure Main is
I : Integer with volatile;
begin
STM32GD.Board.Init;
STM32GD.Board.LED.Set;
loop
I := 100000;
while I > 0 loop
I := I - 1;
end loop;
STM32GD.Board.LED.Toggle;
end loop;
end Main;
|
------------------------------------------------------------------------------
-- 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 Asis.Gela.Elements.Defs.Formal is
------------------------------
-- Formal_Private_Type_Node --
------------------------------
type Formal_Private_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Private_Type_Ptr is
access all Formal_Private_Type_Node;
for Formal_Private_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Private_Type_Node
(The_Context : ASIS.Context)
return Formal_Private_Type_Ptr;
function Trait_Kind
(Element : Formal_Private_Type_Node) return Asis.Trait_Kinds;
procedure Set_Trait_Kind
(Element : in out Formal_Private_Type_Node;
Value : in Asis.Trait_Kinds);
function Has_Limited
(Element : Formal_Private_Type_Node) return Boolean;
procedure Set_Has_Limited
(Element : in out Formal_Private_Type_Node;
Value : in Boolean);
function Has_Private
(Element : Formal_Private_Type_Node) return Boolean;
procedure Set_Has_Private
(Element : in out Formal_Private_Type_Node;
Value : in Boolean);
function Formal_Type_Definition_Kind (Element : Formal_Private_Type_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Private_Type_Node;
Parent : Asis.Element)
return Asis.Element;
-------------------------------------
-- Formal_Tagged_Private_Type_Node --
-------------------------------------
type Formal_Tagged_Private_Type_Node is
new Formal_Private_Type_Node with private;
type Formal_Tagged_Private_Type_Ptr is
access all Formal_Tagged_Private_Type_Node;
for Formal_Tagged_Private_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Tagged_Private_Type_Node
(The_Context : ASIS.Context)
return Formal_Tagged_Private_Type_Ptr;
function Has_Abstract
(Element : Formal_Tagged_Private_Type_Node) return Boolean;
procedure Set_Has_Abstract
(Element : in out Formal_Tagged_Private_Type_Node;
Value : in Boolean);
function Has_Tagged
(Element : Formal_Tagged_Private_Type_Node) return Boolean;
procedure Set_Has_Tagged
(Element : in out Formal_Tagged_Private_Type_Node;
Value : in Boolean);
function Formal_Type_Definition_Kind (Element : Formal_Tagged_Private_Type_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Tagged_Private_Type_Node;
Parent : Asis.Element)
return Asis.Element;
------------------------------
-- Formal_Derived_Type_Node --
------------------------------
type Formal_Derived_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Derived_Type_Ptr is
access all Formal_Derived_Type_Node;
for Formal_Derived_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Derived_Type_Node
(The_Context : ASIS.Context)
return Formal_Derived_Type_Ptr;
function Implicit_Inherited_Declarations
(Element : Formal_Derived_Type_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Add_To_Implicit_Inherited_Declarations
(Element : in out Formal_Derived_Type_Node;
Item : in Asis.Element);
function Implicit_Inherited_Subprograms
(Element : Formal_Derived_Type_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Add_To_Implicit_Inherited_Subprograms
(Element : in out Formal_Derived_Type_Node;
Item : in Asis.Element);
function Get_Subtype_Mark
(Element : Formal_Derived_Type_Node) return Asis.Expression;
procedure Set_Subtype_Mark
(Element : in out Formal_Derived_Type_Node;
Value : in Asis.Expression);
function Trait_Kind
(Element : Formal_Derived_Type_Node) return Asis.Trait_Kinds;
procedure Set_Trait_Kind
(Element : in out Formal_Derived_Type_Node;
Value : in Asis.Trait_Kinds);
function Progenitor_List
(Element : Formal_Derived_Type_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Progenitor_List
(Element : in out Formal_Derived_Type_Node;
Value : in Asis.Element);
function Progenitor_List_List
(Element : Formal_Derived_Type_Node) return Asis.Element;
function Has_Abstract
(Element : Formal_Derived_Type_Node) return Boolean;
procedure Set_Has_Abstract
(Element : in out Formal_Derived_Type_Node;
Value : in Boolean);
function Has_Private
(Element : Formal_Derived_Type_Node) return Boolean;
procedure Set_Has_Private
(Element : in out Formal_Derived_Type_Node;
Value : in Boolean);
function Has_Limited
(Element : Formal_Derived_Type_Node) return Boolean;
procedure Set_Has_Limited
(Element : in out Formal_Derived_Type_Node;
Value : in Boolean);
function Has_Synchronized
(Element : Formal_Derived_Type_Node) return Boolean;
procedure Set_Has_Synchronized
(Element : in out Formal_Derived_Type_Node;
Value : in Boolean);
function Formal_Type_Definition_Kind (Element : Formal_Derived_Type_Node)
return Asis.Formal_Type_Kinds;
function Children (Element : access Formal_Derived_Type_Node)
return Traverse_List;
function Clone
(Element : Formal_Derived_Type_Node;
Parent : Asis.Element)
return Asis.Element;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Derived_Type_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element);
-------------------------------
-- Formal_Discrete_Type_Node --
-------------------------------
type Formal_Discrete_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Discrete_Type_Ptr is
access all Formal_Discrete_Type_Node;
for Formal_Discrete_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Discrete_Type_Node
(The_Context : ASIS.Context)
return Formal_Discrete_Type_Ptr;
function Formal_Type_Definition_Kind (Element : Formal_Discrete_Type_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Discrete_Type_Node;
Parent : Asis.Element)
return Asis.Element;
-------------------------------------
-- Formal_Signed_Integer_Type_Node --
-------------------------------------
type Formal_Signed_Integer_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Signed_Integer_Type_Ptr is
access all Formal_Signed_Integer_Type_Node;
for Formal_Signed_Integer_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Signed_Integer_Type_Node
(The_Context : ASIS.Context)
return Formal_Signed_Integer_Type_Ptr;
function Formal_Type_Definition_Kind (Element : Formal_Signed_Integer_Type_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Signed_Integer_Type_Node;
Parent : Asis.Element)
return Asis.Element;
------------------------------
-- Formal_Modular_Type_Node --
------------------------------
type Formal_Modular_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Modular_Type_Ptr is
access all Formal_Modular_Type_Node;
for Formal_Modular_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Modular_Type_Node
(The_Context : ASIS.Context)
return Formal_Modular_Type_Ptr;
function Formal_Type_Definition_Kind (Element : Formal_Modular_Type_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Modular_Type_Node;
Parent : Asis.Element)
return Asis.Element;
--------------------------------
-- Formal_Floating_Point_Node --
--------------------------------
type Formal_Floating_Point_Node is
new Formal_Type_Definition_Node with private;
type Formal_Floating_Point_Ptr is
access all Formal_Floating_Point_Node;
for Formal_Floating_Point_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Floating_Point_Node
(The_Context : ASIS.Context)
return Formal_Floating_Point_Ptr;
function Formal_Type_Definition_Kind (Element : Formal_Floating_Point_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Floating_Point_Node;
Parent : Asis.Element)
return Asis.Element;
--------------------------------------
-- Formal_Ordinary_Fixed_Point_Node --
--------------------------------------
type Formal_Ordinary_Fixed_Point_Node is
new Formal_Type_Definition_Node with private;
type Formal_Ordinary_Fixed_Point_Ptr is
access all Formal_Ordinary_Fixed_Point_Node;
for Formal_Ordinary_Fixed_Point_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Ordinary_Fixed_Point_Node
(The_Context : ASIS.Context)
return Formal_Ordinary_Fixed_Point_Ptr;
function Formal_Type_Definition_Kind (Element : Formal_Ordinary_Fixed_Point_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Ordinary_Fixed_Point_Node;
Parent : Asis.Element)
return Asis.Element;
-------------------------------------
-- Formal_Decimal_Fixed_Point_Node --
-------------------------------------
type Formal_Decimal_Fixed_Point_Node is
new Formal_Type_Definition_Node with private;
type Formal_Decimal_Fixed_Point_Ptr is
access all Formal_Decimal_Fixed_Point_Node;
for Formal_Decimal_Fixed_Point_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Decimal_Fixed_Point_Node
(The_Context : ASIS.Context)
return Formal_Decimal_Fixed_Point_Ptr;
function Formal_Type_Definition_Kind (Element : Formal_Decimal_Fixed_Point_Node)
return Asis.Formal_Type_Kinds;
function Clone
(Element : Formal_Decimal_Fixed_Point_Node;
Parent : Asis.Element)
return Asis.Element;
-------------------------------------
-- Formal_Unconstrained_Array_Node --
-------------------------------------
type Formal_Unconstrained_Array_Node is
new Formal_Type_Definition_Node with private;
type Formal_Unconstrained_Array_Ptr is
access all Formal_Unconstrained_Array_Node;
for Formal_Unconstrained_Array_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Unconstrained_Array_Node
(The_Context : ASIS.Context)
return Formal_Unconstrained_Array_Ptr;
function Index_Subtype_Definitions
(Element : Formal_Unconstrained_Array_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Index_Subtype_Definitions
(Element : in out Formal_Unconstrained_Array_Node;
Value : in Asis.Element);
function Index_Subtype_Definitions_List
(Element : Formal_Unconstrained_Array_Node) return Asis.Element;
function Array_Component_Definition
(Element : Formal_Unconstrained_Array_Node) return Asis.Component_Definition;
procedure Set_Array_Component_Definition
(Element : in out Formal_Unconstrained_Array_Node;
Value : in Asis.Component_Definition);
function Array_Definition
(Element : Formal_Unconstrained_Array_Node) return Asis.Element;
procedure Set_Array_Definition
(Element : in out Formal_Unconstrained_Array_Node;
Value : in Asis.Element);
function Formal_Type_Definition_Kind (Element : Formal_Unconstrained_Array_Node)
return Asis.Formal_Type_Kinds;
function Children (Element : access Formal_Unconstrained_Array_Node)
return Traverse_List;
function Clone
(Element : Formal_Unconstrained_Array_Node;
Parent : Asis.Element)
return Asis.Element;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Unconstrained_Array_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element);
-----------------------------------
-- Formal_Constrained_Array_Node --
-----------------------------------
type Formal_Constrained_Array_Node is
new Formal_Type_Definition_Node with private;
type Formal_Constrained_Array_Ptr is
access all Formal_Constrained_Array_Node;
for Formal_Constrained_Array_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Constrained_Array_Node
(The_Context : ASIS.Context)
return Formal_Constrained_Array_Ptr;
function Discrete_Subtype_Definitions
(Element : Formal_Constrained_Array_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Discrete_Subtype_Definitions
(Element : in out Formal_Constrained_Array_Node;
Value : in Asis.Element);
function Discrete_Subtype_Definitions_List
(Element : Formal_Constrained_Array_Node) return Asis.Element;
function Array_Component_Definition
(Element : Formal_Constrained_Array_Node) return Asis.Component_Definition;
procedure Set_Array_Component_Definition
(Element : in out Formal_Constrained_Array_Node;
Value : in Asis.Component_Definition);
function Array_Definition
(Element : Formal_Constrained_Array_Node) return Asis.Element;
procedure Set_Array_Definition
(Element : in out Formal_Constrained_Array_Node;
Value : in Asis.Element);
function Formal_Type_Definition_Kind (Element : Formal_Constrained_Array_Node)
return Asis.Formal_Type_Kinds;
function Children (Element : access Formal_Constrained_Array_Node)
return Traverse_List;
function Clone
(Element : Formal_Constrained_Array_Node;
Parent : Asis.Element)
return Asis.Element;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Constrained_Array_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element);
-----------------------------
-- Formal_Access_Type_Node --
-----------------------------
type Formal_Access_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Access_Type_Ptr is
access all Formal_Access_Type_Node;
for Formal_Access_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Access_Type_Node
(The_Context : ASIS.Context)
return Formal_Access_Type_Ptr;
function Access_Type_Kind
(Element : Formal_Access_Type_Node) return Asis.Access_Type_Kinds;
procedure Set_Access_Type_Kind
(Element : in out Formal_Access_Type_Node;
Value : in Asis.Access_Type_Kinds);
function Get_Access_To_Object_Definition
(Element : Formal_Access_Type_Node) return Asis.Subtype_Indication;
procedure Set_Access_To_Object_Definition
(Element : in out Formal_Access_Type_Node;
Value : in Asis.Subtype_Indication);
function Access_To_Subprogram_Parameter_Profile
(Element : Formal_Access_Type_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Access_To_Subprogram_Parameter_Profile
(Element : in out Formal_Access_Type_Node;
Value : in Asis.Element);
function Access_To_Subprogram_Parameter_Profile_List
(Element : Formal_Access_Type_Node) return Asis.Element;
function Access_To_Function_Result_Subtype
(Element : Formal_Access_Type_Node) return Asis.Definition;
procedure Set_Access_To_Function_Result_Subtype
(Element : in out Formal_Access_Type_Node;
Value : in Asis.Definition);
function Access_Definition
(Element : Formal_Access_Type_Node) return Asis.Element;
procedure Set_Access_Definition
(Element : in out Formal_Access_Type_Node;
Value : in Asis.Element);
function Formal_Type_Definition_Kind (Element : Formal_Access_Type_Node)
return Asis.Formal_Type_Kinds;
function Children (Element : access Formal_Access_Type_Node)
return Traverse_List;
function Clone
(Element : Formal_Access_Type_Node;
Parent : Asis.Element)
return Asis.Element;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Access_Type_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element);
--------------------------------
-- Formal_Interface_Type_Node --
--------------------------------
type Formal_Interface_Type_Node is
new Formal_Type_Definition_Node with private;
type Formal_Interface_Type_Ptr is
access all Formal_Interface_Type_Node;
for Formal_Interface_Type_Ptr'Storage_Pool use Lists.Pool;
function New_Formal_Interface_Type_Node
(The_Context : ASIS.Context)
return Formal_Interface_Type_Ptr;
function Interface_Kind
(Element : Formal_Interface_Type_Node) return Asis.Interface_Kinds;
procedure Set_Interface_Kind
(Element : in out Formal_Interface_Type_Node;
Value : in Asis.Interface_Kinds);
function Progenitor_List
(Element : Formal_Interface_Type_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Set_Progenitor_List
(Element : in out Formal_Interface_Type_Node;
Value : in Asis.Element);
function Progenitor_List_List
(Element : Formal_Interface_Type_Node) return Asis.Element;
function Implicit_Inherited_Subprograms
(Element : Formal_Interface_Type_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List;
procedure Add_To_Implicit_Inherited_Subprograms
(Element : in out Formal_Interface_Type_Node;
Item : in Asis.Element);
function Formal_Type_Definition_Kind (Element : Formal_Interface_Type_Node)
return Asis.Formal_Type_Kinds;
function Children (Element : access Formal_Interface_Type_Node)
return Traverse_List;
function Clone
(Element : Formal_Interface_Type_Node;
Parent : Asis.Element)
return Asis.Element;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Interface_Type_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element);
private
type Formal_Private_Type_Node is
new Formal_Type_Definition_Node with
record
Trait_Kind : aliased Asis.Trait_Kinds := An_Ordinary_Trait;
Has_Limited : aliased Boolean := False;
Has_Private : aliased Boolean := False;
end record;
type Formal_Tagged_Private_Type_Node is
new Formal_Private_Type_Node with
record
Has_Abstract : aliased Boolean := False;
Has_Tagged : aliased Boolean := False;
end record;
type Formal_Derived_Type_Node is
new Formal_Type_Definition_Node with
record
Implicit_Inherited_Declarations : aliased Secondary_Declaration_Lists.List_Node;
Implicit_Inherited_Subprograms : aliased Secondary_Declaration_Lists.List_Node;
Subtype_Mark : aliased Asis.Expression;
Trait_Kind : aliased Asis.Trait_Kinds := An_Ordinary_Trait;
Progenitor_List : aliased Primary_Expression_Lists.List;
Has_Abstract : aliased Boolean := False;
Has_Private : aliased Boolean := False;
Has_Limited : aliased Boolean := False;
Has_Synchronized : aliased Boolean := False;
end record;
type Formal_Discrete_Type_Node is
new Formal_Type_Definition_Node with
record
null;
end record;
type Formal_Signed_Integer_Type_Node is
new Formal_Type_Definition_Node with
record
null;
end record;
type Formal_Modular_Type_Node is
new Formal_Type_Definition_Node with
record
null;
end record;
type Formal_Floating_Point_Node is
new Formal_Type_Definition_Node with
record
null;
end record;
type Formal_Ordinary_Fixed_Point_Node is
new Formal_Type_Definition_Node with
record
null;
end record;
type Formal_Decimal_Fixed_Point_Node is
new Formal_Type_Definition_Node with
record
null;
end record;
type Formal_Unconstrained_Array_Node is
new Formal_Type_Definition_Node with
record
Index_Subtype_Definitions : aliased Primary_Identifier_Lists.List;
Array_Component_Definition : aliased Asis.Component_Definition;
Array_Definition : aliased Asis.Element;
end record;
type Formal_Constrained_Array_Node is
new Formal_Type_Definition_Node with
record
Discrete_Subtype_Definitions : aliased Primary_Definition_Lists.List;
Array_Component_Definition : aliased Asis.Component_Definition;
Array_Definition : aliased Asis.Element;
end record;
type Formal_Access_Type_Node is
new Formal_Type_Definition_Node with
record
Access_Type_Kind : aliased Asis.Access_Type_Kinds := A_Pool_Specific_Access_To_Variable;
Access_To_Object_Definition : aliased Asis.Subtype_Indication;
Access_To_Subprogram_Parameter_Profile : aliased Primary_Parameter_Lists.List;
Access_To_Function_Result_Subtype : aliased Asis.Definition;
Access_Definition : aliased Asis.Element;
end record;
type Formal_Interface_Type_Node is
new Formal_Type_Definition_Node with
record
Interface_Kind : aliased Asis.Interface_Kinds := Not_An_Interface;
Progenitor_List : aliased Primary_Expression_Lists.List;
Implicit_Inherited_Subprograms : aliased Secondary_Declaration_Lists.List_Node;
end record;
end Asis.Gela.Elements.Defs.Formal;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-1994, Florida State University --
-- Copyright (C) 1995-2005, 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 2, 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a LynxOS version of this package, derived from s-taspri-posix.ads
pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during
-- tasking operations. It causes infinite loops and other problems.
with System.OS_Interface;
-- used for pthread_mutex_t
-- pthread_cond_t
-- pthread_t
package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
-- Should be used inside the runtime system. The difference between Lock
-- and the RTS_Lock is that the later one serves only as a semaphore so
-- that do not check for ceiling violations.
type Suspension_Object is limited private;
-- Should be used for the implementation of Ada.Synchronous_Task_Control
type Task_Body_Access is access procedure;
-- Pointer to the task body's entry point (or possibly a wrapper
-- declared local to the GNARL).
type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task basis.
-- A component of this type is guaranteed to be included in the
-- Ada_Task_Control_Block.
private
type Lock is record
Mutex : aliased System.OS_Interface.pthread_mutex_t;
Ceiling : System.Any_Priority;
Saved_Priority : System.Any_Priority;
end record;
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
State : Boolean;
pragma Atomic (State);
-- Boolean that indicates whether the object is open. This field is
-- marked Atomic to ensure that we can read its value without locking
-- the access to the Suspension_Object.
Waiting : Boolean;
-- Flag showing if there is a task already suspended on this object
L : aliased System.OS_Interface.pthread_mutex_t;
-- Protection for ensuring mutual exclusion on the Suspension_Object
CV : aliased System.OS_Interface.pthread_cond_t;
-- Condition variable used to queue threads until condition is signaled
end record;
type Private_Data is record
Thread : aliased System.OS_Interface.pthread_t;
pragma Atomic (Thread);
-- Thread field may be updated by two different threads of control.
-- (See, Enter_Task and Create_Task in s-taprop.adb). They put the
-- same value (thr_self value). We do not want to use lock on those
-- operations and the only thing we have to make sure is that they
-- are updated in atomic fashion.
LWP : aliased System.Address;
-- The purpose of this field is to provide a better tasking support on
-- gdb. The order of the two first fields (Thread and LWP) is important.
-- On targets where lwp is not relevant, this is equivalent to Thread.
CV : aliased System.OS_Interface.pthread_cond_t;
L : aliased RTS_Lock;
-- Protection for all components is lock L
end record;
end System.Task_Primitives;
|
--
-- Copyright (C) 2016, AdaCore
--
-- This spec has been automatically generated from STM32F429x.svd
pragma Ada_2012;
with Interfaces.Bit_Types;
with System;
package Interfaces.STM32.SYSCFG is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
--------------------
-- MEMRM_Register --
--------------------
subtype MEMRM_MEM_MODE_Field is Interfaces.Bit_Types.UInt3;
subtype MEMRM_FB_MODE_Field is Interfaces.Bit_Types.Bit;
subtype MEMRM_SWP_FMC_Field is Interfaces.Bit_Types.UInt2;
-- memory remap register
type MEMRM_Register is record
-- Memory mapping selection
MEM_MODE : MEMRM_MEM_MODE_Field := 16#0#;
-- unspecified
Reserved_3_7 : Interfaces.Bit_Types.UInt5 := 16#0#;
-- Flash bank mode selection
FB_MODE : MEMRM_FB_MODE_Field := 16#0#;
-- unspecified
Reserved_9_9 : Interfaces.Bit_Types.Bit := 16#0#;
-- FMC memory mapping swap
SWP_FMC : MEMRM_SWP_FMC_Field := 16#0#;
-- unspecified
Reserved_12_31 : Interfaces.Bit_Types.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MEMRM_Register use record
MEM_MODE at 0 range 0 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
FB_MODE at 0 range 8 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
SWP_FMC at 0 range 10 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
------------------
-- PMC_Register --
------------------
subtype PMC_ADC1DC2_Field is Interfaces.Bit_Types.Bit;
subtype PMC_ADC2DC2_Field is Interfaces.Bit_Types.Bit;
subtype PMC_ADC3DC2_Field is Interfaces.Bit_Types.Bit;
subtype PMC_MII_RMII_SEL_Field is Interfaces.Bit_Types.Bit;
-- peripheral mode configuration register
type PMC_Register is record
-- unspecified
Reserved_0_15 : Interfaces.Bit_Types.Short := 16#0#;
-- ADC1DC2
ADC1DC2 : PMC_ADC1DC2_Field := 16#0#;
-- ADC2DC2
ADC2DC2 : PMC_ADC2DC2_Field := 16#0#;
-- ADC3DC2
ADC3DC2 : PMC_ADC3DC2_Field := 16#0#;
-- unspecified
Reserved_19_22 : Interfaces.Bit_Types.UInt4 := 16#0#;
-- Ethernet PHY interface selection
MII_RMII_SEL : PMC_MII_RMII_SEL_Field := 16#0#;
-- unspecified
Reserved_24_31 : Interfaces.Bit_Types.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_Register use record
Reserved_0_15 at 0 range 0 .. 15;
ADC1DC2 at 0 range 16 .. 16;
ADC2DC2 at 0 range 17 .. 17;
ADC3DC2 at 0 range 18 .. 18;
Reserved_19_22 at 0 range 19 .. 22;
MII_RMII_SEL at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
---------------------
-- EXTICR_Register --
---------------------
------------------
-- EXTICR1.EXTI --
------------------
-- EXTICR1_EXTI array element
subtype EXTICR1_EXTI_Element is Interfaces.Bit_Types.UInt4;
-- EXTICR1_EXTI array
type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR1_EXTI
type EXTICR1_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : Interfaces.Bit_Types.Short;
when True =>
-- EXTI as an array
Arr : EXTICR1_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR1_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 1
type EXTICR_Register is record
-- EXTI x configuration (x = 0 to 3)
EXTI : EXTICR1_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : Interfaces.Bit_Types.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------
-- CMPCR_Register --
--------------------
subtype CMPCR_CMP_PD_Field is Interfaces.Bit_Types.Bit;
subtype CMPCR_READY_Field is Interfaces.Bit_Types.Bit;
-- Compensation cell control register
type CMPCR_Register is record
-- Read-only. Compensation cell power-down
CMP_PD : CMPCR_CMP_PD_Field := 16#0#;
-- unspecified
Reserved_1_7 : Interfaces.Bit_Types.UInt7;
-- Read-only. READY
READY : CMPCR_READY_Field := 16#0#;
-- unspecified
Reserved_9_31 : Interfaces.Bit_Types.UInt23;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMPCR_Register use record
CMP_PD at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
READY at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- System configuration controller
type SYSCFG_Peripheral is record
-- memory remap register
MEMRM : MEMRM_Register;
-- peripheral mode configuration register
PMC : PMC_Register;
-- external interrupt configuration register 1
EXTICR1 : EXTICR_Register;
-- external interrupt configuration register 2
EXTICR2 : EXTICR_Register;
-- external interrupt configuration register 3
EXTICR3 : EXTICR_Register;
-- external interrupt configuration register 4
EXTICR4 : EXTICR_Register;
-- Compensation cell control register
CMPCR : CMPCR_Register;
end record
with Volatile;
for SYSCFG_Peripheral use record
MEMRM at 0 range 0 .. 31;
PMC at 4 range 0 .. 31;
EXTICR1 at 8 range 0 .. 31;
EXTICR2 at 12 range 0 .. 31;
EXTICR3 at 16 range 0 .. 31;
EXTICR4 at 20 range 0 .. 31;
CMPCR at 32 range 0 .. 31;
end record;
-- System configuration controller
SYSCFG_Periph : aliased SYSCFG_Peripheral
with Import, Address => SYSCFG_Base;
end Interfaces.STM32.SYSCFG;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package avx512dqintrin_h is
-- Copyright (C) 2014-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC 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.
-- GCC 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.
-- 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/>.
-- skipped func _ktest_mask8_u8
-- skipped func _ktestz_mask8_u8
-- skipped func _ktestc_mask8_u8
-- skipped func _ktest_mask16_u8
-- skipped func _ktestz_mask16_u8
-- skipped func _ktestc_mask16_u8
-- skipped func _kortest_mask8_u8
-- skipped func _kortestz_mask8_u8
-- skipped func _kortestc_mask8_u8
-- skipped func _kadd_mask8
-- skipped func _kadd_mask16
-- skipped func _cvtmask8_u32
-- skipped func _cvtu32_mask8
-- skipped func _load_mask8
-- skipped func _store_mask8
-- skipped func _knot_mask8
-- skipped func _kor_mask8
-- skipped func _kxnor_mask8
-- skipped func _kxor_mask8
-- skipped func _kand_mask8
-- skipped func _kandn_mask8
-- skipped func _mm512_broadcast_f64x2
-- skipped func _mm512_mask_broadcast_f64x2
-- skipped func _mm512_maskz_broadcast_f64x2
-- skipped func _mm512_broadcast_i64x2
-- skipped func _mm512_mask_broadcast_i64x2
-- skipped func _mm512_maskz_broadcast_i64x2
-- skipped func _mm512_broadcast_f32x2
-- skipped func _mm512_mask_broadcast_f32x2
-- skipped func _mm512_maskz_broadcast_f32x2
-- skipped func _mm512_broadcast_i32x2
-- skipped func _mm512_mask_broadcast_i32x2
-- skipped func _mm512_maskz_broadcast_i32x2
-- skipped func _mm512_broadcast_f32x8
-- skipped func _mm512_mask_broadcast_f32x8
-- skipped func _mm512_maskz_broadcast_f32x8
-- skipped func _mm512_broadcast_i32x8
-- skipped func _mm512_mask_broadcast_i32x8
-- skipped func _mm512_maskz_broadcast_i32x8
-- skipped func _mm512_mullo_epi64
-- skipped func _mm512_mask_mullo_epi64
-- skipped func _mm512_maskz_mullo_epi64
-- skipped func _mm512_xor_pd
-- skipped func _mm512_mask_xor_pd
-- skipped func _mm512_maskz_xor_pd
-- skipped func _mm512_xor_ps
-- skipped func _mm512_mask_xor_ps
-- skipped func _mm512_maskz_xor_ps
-- skipped func _mm512_or_pd
-- skipped func _mm512_mask_or_pd
-- skipped func _mm512_maskz_or_pd
-- skipped func _mm512_or_ps
-- skipped func _mm512_mask_or_ps
-- skipped func _mm512_maskz_or_ps
-- skipped func _mm512_and_pd
-- skipped func _mm512_mask_and_pd
-- skipped func _mm512_maskz_and_pd
-- skipped func _mm512_and_ps
-- skipped func _mm512_mask_and_ps
-- skipped func _mm512_maskz_and_ps
-- skipped func _mm512_andnot_pd
-- skipped func _mm512_mask_andnot_pd
-- skipped func _mm512_maskz_andnot_pd
-- skipped func _mm512_andnot_ps
-- skipped func _mm512_mask_andnot_ps
-- skipped func _mm512_maskz_andnot_ps
-- skipped func _mm512_movepi32_mask
-- skipped func _mm512_movepi64_mask
-- skipped func _mm512_movm_epi32
-- skipped func _mm512_movm_epi64
-- skipped func _mm512_cvttpd_epi64
-- skipped func _mm512_mask_cvttpd_epi64
-- skipped func _mm512_maskz_cvttpd_epi64
-- skipped func _mm512_cvttpd_epu64
-- skipped func _mm512_mask_cvttpd_epu64
-- skipped func _mm512_maskz_cvttpd_epu64
-- skipped func _mm512_cvttps_epi64
-- skipped func _mm512_mask_cvttps_epi64
-- skipped func _mm512_maskz_cvttps_epi64
-- skipped func _mm512_cvttps_epu64
-- skipped func _mm512_mask_cvttps_epu64
-- skipped func _mm512_maskz_cvttps_epu64
-- skipped func _mm512_cvtpd_epi64
-- skipped func _mm512_mask_cvtpd_epi64
-- skipped func _mm512_maskz_cvtpd_epi64
-- skipped func _mm512_cvtpd_epu64
-- skipped func _mm512_mask_cvtpd_epu64
-- skipped func _mm512_maskz_cvtpd_epu64
-- skipped func _mm512_cvtps_epi64
-- skipped func _mm512_mask_cvtps_epi64
-- skipped func _mm512_maskz_cvtps_epi64
-- skipped func _mm512_cvtps_epu64
-- skipped func _mm512_mask_cvtps_epu64
-- skipped func _mm512_maskz_cvtps_epu64
-- skipped func _mm512_cvtepi64_ps
-- skipped func _mm512_mask_cvtepi64_ps
-- skipped func _mm512_maskz_cvtepi64_ps
-- skipped func _mm512_cvtepu64_ps
-- skipped func _mm512_mask_cvtepu64_ps
-- skipped func _mm512_maskz_cvtepu64_ps
-- skipped func _mm512_cvtepi64_pd
-- skipped func _mm512_mask_cvtepi64_pd
-- skipped func _mm512_maskz_cvtepi64_pd
-- skipped func _mm512_cvtepu64_pd
-- skipped func _mm512_mask_cvtepu64_pd
-- skipped func _mm512_maskz_cvtepu64_pd
end avx512dqintrin_h;
|
with Ada.Numerics.Real_Arrays;
with Ada.Text_IO;
with Decomposition;
procedure Decompose_Example is
package Real_Decomposition is new Decomposition
(Matrix => Ada.Numerics.Real_Arrays);
package Real_IO is new Ada.Text_IO.Float_IO (Float);
procedure Print (M : Ada.Numerics.Real_Arrays.Real_Matrix) is
begin
for Row in M'Range (1) loop
for Col in M'Range (2) loop
Real_IO.Put (M (Row, Col), 4, 3, 0);
end loop;
Ada.Text_IO.New_Line;
end loop;
end Print;
Example_1 : constant Ada.Numerics.Real_Arrays.Real_Matrix :=
((25.0, 15.0, -5.0),
(15.0, 18.0, 0.0),
(-5.0, 0.0, 11.0));
L_1 : Ada.Numerics.Real_Arrays.Real_Matrix (Example_1'Range (1),
Example_1'Range (2));
Example_2 : constant Ada.Numerics.Real_Arrays.Real_Matrix :=
((18.0, 22.0, 54.0, 42.0),
(22.0, 70.0, 86.0, 62.0),
(54.0, 86.0, 174.0, 134.0),
(42.0, 62.0, 134.0, 106.0));
L_2 : Ada.Numerics.Real_Arrays.Real_Matrix (Example_2'Range (1),
Example_2'Range (2));
begin
Real_Decomposition.Decompose (A => Example_1,
L => L_1);
Real_Decomposition.Decompose (A => Example_2,
L => L_2);
Ada.Text_IO.Put_Line ("Example 1:");
Ada.Text_IO.Put_Line ("A:"); Print (Example_1);
Ada.Text_IO.Put_Line ("L:"); Print (L_1);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Example 2:");
Ada.Text_IO.Put_Line ("A:"); Print (Example_2);
Ada.Text_IO.Put_Line ("L:"); Print (L_2);
end Decompose_Example;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with Interfaces.C.Strings;
with System;
procedure Load_Library
(Name : League.Strings.Universal_String;
Error : out League.Strings.Universal_String)
is
use type System.Address;
RTLD_NOW : constant Interfaces.C.int := 2;
function dlopen
(file : Interfaces.C.char_array;
mode : Interfaces.C.int) return System.Address
with Import, Convention => C, External_Name => "dlopen";
function dlerror return Interfaces.C.Strings.chars_ptr
with Import, Convention => C, External_name => "dlerror";
Raw_Name : constant Interfaces.C.char_array :=
Interfaces.C.To_C (Name.To_UTF_8_String);
Handler : constant System.Address := dlopen (Raw_Name, RTLD_NOW);
Message : constant Interfaces.C.Strings.chars_ptr := dlerror;
begin
if Handler = System.Null_Address then
Error := League.Strings.From_UTF_8_String
(Interfaces.C.Strings.Value (Message));
end if;
end Load_Library;
|
with System.Storage_Elements; use System.Storage_Elements;
with AUnit.Assertions; use AUnit.Assertions;
with HAL; use HAL;
with USB.Utils; use USB.Utils;
package body Tests.Utils is
---------------------
-- Basic_Mem_Alloc --
---------------------
procedure Basic_Mem_Alloc (Unused : in out Null_Fixture)
is
Alloc : USB.Utils.Basic_RAM_Allocator (256);
procedure Test (Alignment : UInt8;
Len : UInt11;
Expect_Fail : Boolean)
is
Addr : constant Integer_Address :=
To_Integer (Allocate (Alloc, Alignment, Len));
begin
Assert (Addr /= 0 or else Expect_Fail, "Allocation failed");
Assert ((Addr mod Integer_Address (Alignment)) = 0, "Bad alignment");
end Test;
begin
Test (1, 1, False);
Test (2, 1, False);
Test (4, 1, False);
Test (8, 1, False);
Test (16, 1, False);
Test (32, 1, False);
Test (4, 512, True);
end Basic_Mem_Alloc;
begin
Suite.Add_Test (Null_Caller.Create ("Basic Mem Alloc", Basic_Mem_Alloc'Access));
end Tests.Utils;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_18.Main is
begin
Put_Line ("Day-18");
end Adventofcode.Day_18.Main;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 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.
package body Orka.Inputs.Joysticks.Filtering is
function Low_Pass_Filter
(Current, Last : Axis_Position;
RC, DT : GL.Types.Single) return Axis_Position
is
A : constant Axis_Position := Axis_Position (DT / (RC + DT));
begin
return A * Current + (1.0 - A) * Last;
end Low_Pass_Filter;
function Dead_Zone (Value, Threshold : Axis_Position) return Axis_Position is
Result : Axis_Position;
Scale : constant Axis_Position'Base := 1.0 / (1.0 - Threshold);
begin
Result := (if abs Value <= Threshold then 0.0 else Value);
if Value >= 0.0 then
Result := Axis_Position'Max (Result - Threshold, 0.0);
Result := Axis_Position'Min (Result * Scale, 1.0);
else
Result := Axis_Position'Min (Result + Threshold, 0.0);
Result := Axis_Position'Max (Result * Scale, -1.0);
end if;
return Result;
end Dead_Zone;
function Invert (Value : Axis_Position; Enable : Boolean) return Axis_Position is
(if Enable then -1.0 * Value else Value);
end Orka.Inputs.Joysticks.Filtering;
|
-- -----------------------------------------------------------------------------
-- 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.IO body
--
-- Implementation Notes:
--
-- Portability Issues:
--
-- Anticipated Changes:
--
-- -----------------------------------------------------------------------------
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Text_IO;
package body Smk.IO is
Warnings : Natural := 0;
-- --------------------------------------------------------------------------
-- Function: GNU_Prefix
--
-- Purpose:
-- This function return a source/line/column prefix to messages compatible
-- whith GNU Standard
-- (refer to <https://www.gnu.org/prep/standards/html_node/Errors.html>),
-- That is :
-- > program:sourcefile:lineno: message
-- when there is an appropriate source file, or :
-- > program: message
-- otherwise.
--
-- --------------------------------------------------------------------------
function GNU_Prefix (File : in String;
Line : in Integer := 0) return String
is
use Ada.Strings;
use Ada.Strings.Fixed;
Trimed_File : constant String := Trim (File, Side => Both);
Trimed_Line : constant String := Trim (Positive'Image (Line),
Side => Both);
Common_Part : constant String := "smk:" & Trimed_File;
begin
if File = "" then
return "";
elsif Line = 0 then
return Common_Part & " ";
else
return Common_Part & ":" & Trimed_Line & ": ";
end if;
end GNU_Prefix;
-- --------------------------------------------------------------------------
procedure Put_Warning (Msg : in String;
File : in String := "";
Line : in Integer := 0) is
begin
Warnings := Warnings + 1;
Put_Line ("Warning : " & Msg, File, Line);
-- use the local version of Put_Line, and not the Ada.Text_IO one,
-- so that Warning messages are also ignored when --quiet.
end Put_Warning;
Errors : Natural := 0;
-- --------------------------------------------------------------------------
procedure Put_Error (Msg : in String;
File : in String := "";
Line : in Integer := 0) is
begin
Errors := Errors + 1;
Put_Line ("Error : " & Msg, File, Line, Level => Quiet);
-- Quiet because Error Msg should not be ignored
end Put_Error;
-- --------------------------------------------------------------------------
procedure Put_Exception (Msg : in String;
File : in String := "";
Line : in Integer := 0) is
begin
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
GNU_Prefix (File, Line) & "Exception : " & Msg);
end Put_Exception;
-- --------------------------------------------------------------------------
function Error_Count return Natural is (Errors);
function Warning_Count return Natural is (Warnings);
-- --------------------------------------------------------------------------
procedure Put_Debug_Line (Msg : in String;
Debug : in Boolean;
Prefix : in String;
File : in String := "";
Line : in Integer := 0) is
begin
if Debug then
Ada.Text_IO.Put_Line (GNU_Prefix (File, Line) & Prefix & Msg);
end if;
end Put_Debug_Line;
-- --------------------------------------------------------------------------
procedure Put_Line (Item : String;
File : in String := "";
Line : in Integer := 0;
Level : Print_Out_Level := Normal) is
begin
if Level >= Settings.Verbosity then
Ada.Text_IO.Put_Line (GNU_Prefix (File, Line) & Item);
end if;
end Put_Line;
-- --------------------------------------------------------------------------
function Image (Time : in Ada.Calendar.Time) return String is
begin
return Ada.Calendar.Formatting.Image
(Date => Time,
Include_Time_Fraction => True,
Time_Zone => Ada.Calendar.Time_Zones.UTC_Time_Offset);
end Image;
end Smk.IO;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure tp1 is
-- conversion en majuscule
function Maju (c : Character) return Character is
begin
if c in 'a'..'z' then -- si minuscule
return Character'Val(Character'Pos(c) - 32); -- on décale de 32
else
return c; -- on change rien
end if;
end Maju;
-- caractère actuel
ch : Character;
-- compteurs
nb_i, nb_le, nb_mots_4 : Integer := 0;
-- drapeau / indique si le dernier caractère était un L
dernier_est_l : Boolean := False;
-- drapeau / indique si le mot actuel contient au moins un I
mot_contient_i : Boolean := False;
-- longueur du mot en cours
longueur_act : Integer := 0;
begin
loop
-- lecture du caractère
Get(ch);
ch := Maju(ch);
-- fin de mot ou de phrase
if ch = ' ' or ch = '.' then
-- compteur de mots de 4 lettres
if longueur_act = 4 then
nb_mots_4 := nb_mots_4 + 1;
end if;
-- le mot est fini, on repasse la longueur à 0 et le drapeau à Faux
longueur_act := 0;
mot_contient_i := False;
else
-- le mot n'est pas fini, on incrémente la longueur
longueur_act := longueur_act + 1;
end if;
-- on sort de la boucle si on trouve un point car la phrase est finie
exit when ch = '.';
-- compteur de I
if ch = 'I' and not mot_contient_i then -- si c'est le premier I dans le mot actuel
nb_i := nb_i + 1;
mot_contient_i := True;
end if;
-- compteur de LE
if dernier_est_l and ch = 'E' then
nb_le := nb_le + 1;
end if;
-- on vérifie si c'est un L, pour pouvoir compter les LE
dernier_est_l := ch = 'L';
-- on affiche le caractère en majuscule
Put(Maju(ch));
end loop;
-- on ajoute une ligne à la fin de la phrase affichée
New_Line;
-- affichage des compteurs
Put_Line("Nombre de 'le' : " & Integer'Image(nb_le));
Put_Line("Nombre de mots contenant un i : " & Integer'Image(nb_i));
Put_Line("Nombre de mots de 4 lettres : " & Integer'Image(nb_mots_4));
end tp1;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2019, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with SAM_SVD.OSCCTRL; use SAM_SVD.OSCCTRL;
package body SAM.Oscillators_Controller is
--------------------
-- Configure_DFLL --
--------------------
procedure Configure_DFLL
(On_Demand_Control : Boolean;
Run_On_Standby : Boolean;
USB_Clock_Recovery : Boolean;
Wait_Lock : Boolean;
Bypass_Coarse_Lock : Boolean;
Quick_Lock_Disable : Boolean;
Chill_Cycle_Disable : Boolean;
Lose_Lock_After_Wake : Boolean;
Stable_DFLL_Frequency : Boolean;
Operating_Mode : DFLL_Operating_Mode;
Coarse_Maximum_Step : HAL.UInt6;
Fine_Maximum_Step : HAL.UInt8;
Multiply_Factor : HAL.UInt16)
is
Tmp : OSCCTRL_DFLLVAL_Register with Volatile;
begin
-- Disable DFLL
OSCCTRL_Periph.DFLLCTRLA := (ENABLE => False,
RUNSTDBY => False,
ONDEMAND => False,
others => <>);
-- Set MUL and wait sync
OSCCTRL_Periph.DFLLMUL := (MUL => Multiply_Factor,
FSTEP => Fine_Maximum_Step,
CSTEP => Coarse_Maximum_Step,
others => <>);
while OSCCTRL_Periph.DFLLSYNC.DFLLMUL loop
null;
end loop;
-- Reset CTRLB register and wait sync
OSCCTRL_Periph.DFLLCTRLB := (others => False);
while OSCCTRL_Periph.DFLLSYNC.DFLLCTRLB loop
null;
end loop;
-- Enable and wait sync
OSCCTRL_Periph.DFLLCTRLA := (ENABLE => True,
RUNSTDBY => Run_On_Standby,
ONDEMAND => False,
others => <>);
while OSCCTRL_Periph.DFLLSYNC.ENABLE loop
null;
end loop;
-- Use the calibration after reset values
Tmp := OSCCTRL_Periph.DFLLVAL;
OSCCTRL_Periph.DFLLVAL := Tmp;
-- Set CTRLB values and wait sync
OSCCTRL_Periph.DFLLCTRLB :=
(MODE => (case Operating_Mode is
when Open_Loop_Mode => False,
when Closed_Loop_Mode => True),
STABLE => Stable_DFLL_Frequency,
LLAW => Lose_Lock_After_Wake,
USBCRM => USB_Clock_Recovery,
CCDIS => Chill_Cycle_Disable,
QLDIS => Quick_Lock_Disable,
BPLCKC => Bypass_Coarse_Lock,
WAITLOCK => Wait_Lock);
while OSCCTRL_Periph.DFLLSYNC.DFLLCTRLB loop
null;
end loop;
-- Wait for DFLL ready signal
case Operating_Mode is
when Closed_Loop_Mode =>
while not OSCCTRL_Periph.STATUS.DFLLRDY
and then
not OSCCTRL_Periph.STATUS.DFLLLCKC
loop
null;
end loop;
when Open_Loop_Mode =>
while not OSCCTRL_Periph.STATUS.DFLLRDY loop
null;
end loop;
end case;
-- Set On demand config if necessary
if On_Demand_Control then
OSCCTRL_Periph.DFLLCTRLA.ONDEMAND := True;
end if;
end Configure_DFLL;
-------------------------
-- Configure_DPLL_GCLK --
-------------------------
procedure Configure_DPLL
(DPLL : HAL.Bit;
On_Demand_Control : Boolean;
Run_On_Standby : Boolean;
Loop_Divider_Fractional : HAL.UInt5;
Loop_Divider_Integer : HAL.UInt13;
Clock_Divider : HAL.UInt11;
DCO_Filter_Enable : Boolean;
Sigma_Delta_DCO_Filter : HAL.UInt3;
Lock_Bypass : Boolean;
Lock_Time : DPLL_Lock_Time;
Reference_Clock : DPLL_Reference_Clock;
Wakeup_Fast : Boolean;
Prop_Integral_Filter : HAL.UInt4)
is
RATIO : constant DPLLRATIO_Register :=
(LDR => Loop_Divider_Integer,
LDRFRAC => Loop_Divider_Fractional,
others => <>);
CTRLB : constant DPLLCTRLB_Register :=
(FILTER => Prop_Integral_Filter,
WUF => Wakeup_Fast,
REFCLK => (case Reference_Clock is
when GCLK_Ref => Gclk,
when XOSC32K_Ref => Xosc32,
when XOSC0_Ref => Xosc0,
when XOSC1_Ref => Xosc1),
LTIME => DPLLCTRLB0_LTIMESelect'Enum_Val (Lock_Time'Enum_Rep),
LBYPASS => Lock_Bypass,
DCOFILTER => Sigma_Delta_DCO_Filter,
DCOEN => DCO_Filter_Enable,
DIV => Clock_Divider,
others => <>);
CTRLA : constant DPLLCTRLA_Register :=
(ENABLE => True,
RUNSTDBY => Run_On_Standby,
ONDEMAND => False,
others => <>);
begin
case DPLL is
when 0 =>
OSCCTRL_Periph.DPLLRATIO0 := RATIO;
OSCCTRL_Periph.DPLLCTRLB0 := CTRLB;
OSCCTRL_Periph.DPLLCTRLA0 := CTRLA;
while not OSCCTRL_Periph.DPLLSTATUS0.LOCK
and then
not OSCCTRL_Periph.DPLLSTATUS0.CLKRDY
loop
null;
end loop;
if On_Demand_Control then
OSCCTRL_Periph.DPLLCTRLA0.ONDEMAND := True;
end if;
when 1 =>
OSCCTRL_Periph.DPLLRATIO1 := RATIO;
OSCCTRL_Periph.DPLLCTRLB1 := CTRLB;
OSCCTRL_Periph.DPLLCTRLA1 := CTRLA;
while not OSCCTRL_Periph.DPLLSTATUS1.LOCK
and then
not OSCCTRL_Periph.DPLLSTATUS1.CLKRDY
loop
null;
end loop;
if On_Demand_Control then
OSCCTRL_Periph.DPLLCTRLA1.ONDEMAND := True;
end if;
end case;
end Configure_DPLL;
end SAM.Oscillators_Controller;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with GBA.BIOS.Raw.Arm;
with GBA.BIOS.Extended_Interface;
package GBA.BIOS.Arm is
new GBA.BIOS.Extended_Interface (GBA.BIOS.Raw.Arm.Generic_Interface);
|
-- This spec has been automatically generated from STM32F427x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
with HAL;
package STM32_SVD.FSMC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-------------------
-- BCR1_Register --
-------------------
subtype BCR1_MTYP_Field is HAL.UInt2;
subtype BCR1_MWID_Field is HAL.UInt2;
-- SRAM/NOR-Flash chip-select control register 1
type BCR1_Register is record
-- MBKEN
MBKEN : Boolean := False;
-- MUXEN
MUXEN : Boolean := False;
-- MTYP
MTYP : BCR1_MTYP_Field := 16#0#;
-- MWID
MWID : BCR1_MWID_Field := 16#1#;
-- FACCEN
FACCEN : Boolean := True;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#1#;
-- BURSTEN
BURSTEN : Boolean := False;
-- WAITPOL
WAITPOL : Boolean := False;
-- unspecified
Reserved_10_10 : HAL.Bit := 16#0#;
-- WAITCFG
WAITCFG : Boolean := False;
-- WREN
WREN : Boolean := True;
-- WAITEN
WAITEN : Boolean := True;
-- EXTMOD
EXTMOD : Boolean := False;
-- ASYNCWAIT
ASYNCWAIT : Boolean := False;
-- unspecified
Reserved_16_18 : HAL.UInt3 := 16#0#;
-- CBURSTRW
CBURSTRW : Boolean := False;
-- CCLKEN
CCLKEN : Boolean := False;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BCR1_Register use record
MBKEN at 0 range 0 .. 0;
MUXEN at 0 range 1 .. 1;
MTYP at 0 range 2 .. 3;
MWID at 0 range 4 .. 5;
FACCEN at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
BURSTEN at 0 range 8 .. 8;
WAITPOL at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
WAITCFG at 0 range 11 .. 11;
WREN at 0 range 12 .. 12;
WAITEN at 0 range 13 .. 13;
EXTMOD at 0 range 14 .. 14;
ASYNCWAIT at 0 range 15 .. 15;
Reserved_16_18 at 0 range 16 .. 18;
CBURSTRW at 0 range 19 .. 19;
CCLKEN at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
------------------
-- BTR_Register --
------------------
subtype BTR1_ADDSET_Field is HAL.UInt4;
subtype BTR1_ADDHLD_Field is HAL.UInt4;
subtype BTR1_DATAST_Field is HAL.Byte;
subtype BTR1_BUSTURN_Field is HAL.UInt4;
subtype BTR1_CLKDIV_Field is HAL.UInt4;
subtype BTR1_DATLAT_Field is HAL.UInt4;
subtype BTR1_ACCMOD_Field is HAL.UInt2;
-- SRAM/NOR-Flash chip-select timing register 1
type BTR_Register is record
-- ADDSET
ADDSET : BTR1_ADDSET_Field := 16#F#;
-- ADDHLD
ADDHLD : BTR1_ADDHLD_Field := 16#F#;
-- DATAST
DATAST : BTR1_DATAST_Field := 16#FF#;
-- BUSTURN
BUSTURN : BTR1_BUSTURN_Field := 16#F#;
-- CLKDIV
CLKDIV : BTR1_CLKDIV_Field := 16#F#;
-- DATLAT
DATLAT : BTR1_DATLAT_Field := 16#F#;
-- ACCMOD
ACCMOD : BTR1_ACCMOD_Field := 16#3#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#3#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BTR_Register use record
ADDSET at 0 range 0 .. 3;
ADDHLD at 0 range 4 .. 7;
DATAST at 0 range 8 .. 15;
BUSTURN at 0 range 16 .. 19;
CLKDIV at 0 range 20 .. 23;
DATLAT at 0 range 24 .. 27;
ACCMOD at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
------------------
-- BCR_Register --
------------------
subtype BCR2_MTYP_Field is HAL.UInt2;
subtype BCR2_MWID_Field is HAL.UInt2;
-- SRAM/NOR-Flash chip-select control register 2
type BCR_Register is record
-- MBKEN
MBKEN : Boolean := False;
-- MUXEN
MUXEN : Boolean := False;
-- MTYP
MTYP : BCR2_MTYP_Field := 16#0#;
-- MWID
MWID : BCR2_MWID_Field := 16#1#;
-- FACCEN
FACCEN : Boolean := True;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#1#;
-- BURSTEN
BURSTEN : Boolean := False;
-- WAITPOL
WAITPOL : Boolean := False;
-- WRAPMOD
WRAPMOD : Boolean := False;
-- WAITCFG
WAITCFG : Boolean := False;
-- WREN
WREN : Boolean := True;
-- WAITEN
WAITEN : Boolean := True;
-- EXTMOD
EXTMOD : Boolean := False;
-- ASYNCWAIT
ASYNCWAIT : Boolean := False;
-- unspecified
Reserved_16_18 : HAL.UInt3 := 16#0#;
-- CBURSTRW
CBURSTRW : Boolean := False;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BCR_Register use record
MBKEN at 0 range 0 .. 0;
MUXEN at 0 range 1 .. 1;
MTYP at 0 range 2 .. 3;
MWID at 0 range 4 .. 5;
FACCEN at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
BURSTEN at 0 range 8 .. 8;
WAITPOL at 0 range 9 .. 9;
WRAPMOD at 0 range 10 .. 10;
WAITCFG at 0 range 11 .. 11;
WREN at 0 range 12 .. 12;
WAITEN at 0 range 13 .. 13;
EXTMOD at 0 range 14 .. 14;
ASYNCWAIT at 0 range 15 .. 15;
Reserved_16_18 at 0 range 16 .. 18;
CBURSTRW at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
------------------
-- PCR_Register --
------------------
subtype PCR2_PWID_Field is HAL.UInt2;
subtype PCR2_TCLR_Field is HAL.UInt4;
subtype PCR2_TAR_Field is HAL.UInt4;
subtype PCR2_ECCPS_Field is HAL.UInt3;
-- PC Card/NAND Flash control register 2
type PCR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- PWAITEN
PWAITEN : Boolean := False;
-- PBKEN
PBKEN : Boolean := False;
-- PTYP
PTYP : Boolean := True;
-- PWID
PWID : PCR2_PWID_Field := 16#1#;
-- ECCEN
ECCEN : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- TCLR
TCLR : PCR2_TCLR_Field := 16#0#;
-- TAR
TAR : PCR2_TAR_Field := 16#0#;
-- ECCPS
ECCPS : PCR2_ECCPS_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PCR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
PWAITEN at 0 range 1 .. 1;
PBKEN at 0 range 2 .. 2;
PTYP at 0 range 3 .. 3;
PWID at 0 range 4 .. 5;
ECCEN at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
TCLR at 0 range 9 .. 12;
TAR at 0 range 13 .. 16;
ECCPS at 0 range 17 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- FIFO status and interrupt register 2
type SR_Register is record
-- IRS
IRS : Boolean := False;
-- ILS
ILS : Boolean := False;
-- IFS
IFS : Boolean := False;
-- IREN
IREN : Boolean := False;
-- ILEN
ILEN : Boolean := False;
-- IFEN
IFEN : Boolean := False;
-- Read-only. FEMPT
FEMPT : Boolean := True;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
IRS at 0 range 0 .. 0;
ILS at 0 range 1 .. 1;
IFS at 0 range 2 .. 2;
IREN at 0 range 3 .. 3;
ILEN at 0 range 4 .. 4;
IFEN at 0 range 5 .. 5;
FEMPT at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
-------------------
-- PMEM_Register --
-------------------
subtype PMEM2_MEMSETx_Field is HAL.Byte;
subtype PMEM2_MEMWAITx_Field is HAL.Byte;
subtype PMEM2_MEMHOLDx_Field is HAL.Byte;
subtype PMEM2_MEMHIZx_Field is HAL.Byte;
-- Common memory space timing register 2
type PMEM_Register is record
-- MEMSETx
MEMSETx : PMEM2_MEMSETx_Field := 16#FC#;
-- MEMWAITx
MEMWAITx : PMEM2_MEMWAITx_Field := 16#FC#;
-- MEMHOLDx
MEMHOLDx : PMEM2_MEMHOLDx_Field := 16#FC#;
-- MEMHIZx
MEMHIZx : PMEM2_MEMHIZx_Field := 16#FC#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMEM_Register use record
MEMSETx at 0 range 0 .. 7;
MEMWAITx at 0 range 8 .. 15;
MEMHOLDx at 0 range 16 .. 23;
MEMHIZx at 0 range 24 .. 31;
end record;
-------------------
-- PATT_Register --
-------------------
subtype PATT2_ATTSETx_Field is HAL.Byte;
subtype PATT2_ATTWAITx_Field is HAL.Byte;
subtype PATT2_ATTHOLDx_Field is HAL.Byte;
subtype PATT2_ATTHIZx_Field is HAL.Byte;
-- Attribute memory space timing register 2
type PATT_Register is record
-- ATTSETx
ATTSETx : PATT2_ATTSETx_Field := 16#FC#;
-- ATTWAITx
ATTWAITx : PATT2_ATTWAITx_Field := 16#FC#;
-- ATTHOLDx
ATTHOLDx : PATT2_ATTHOLDx_Field := 16#FC#;
-- ATTHIZx
ATTHIZx : PATT2_ATTHIZx_Field := 16#FC#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PATT_Register use record
ATTSETx at 0 range 0 .. 7;
ATTWAITx at 0 range 8 .. 15;
ATTHOLDx at 0 range 16 .. 23;
ATTHIZx at 0 range 24 .. 31;
end record;
-------------------
-- PIO4_Register --
-------------------
subtype PIO4_IOSETx_Field is HAL.Byte;
subtype PIO4_IOWAITx_Field is HAL.Byte;
subtype PIO4_IOHOLDx_Field is HAL.Byte;
subtype PIO4_IOHIZx_Field is HAL.Byte;
-- I/O space timing register 4
type PIO4_Register is record
-- IOSETx
IOSETx : PIO4_IOSETx_Field := 16#FC#;
-- IOWAITx
IOWAITx : PIO4_IOWAITx_Field := 16#FC#;
-- IOHOLDx
IOHOLDx : PIO4_IOHOLDx_Field := 16#FC#;
-- IOHIZx
IOHIZx : PIO4_IOHIZx_Field := 16#FC#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PIO4_Register use record
IOSETx at 0 range 0 .. 7;
IOWAITx at 0 range 8 .. 15;
IOHOLDx at 0 range 16 .. 23;
IOHIZx at 0 range 24 .. 31;
end record;
-------------------
-- BWTR_Register --
-------------------
subtype BWTR1_ADDSET_Field is HAL.UInt4;
subtype BWTR1_ADDHLD_Field is HAL.UInt4;
subtype BWTR1_DATAST_Field is HAL.Byte;
subtype BWTR1_CLKDIV_Field is HAL.UInt4;
subtype BWTR1_DATLAT_Field is HAL.UInt4;
subtype BWTR1_ACCMOD_Field is HAL.UInt2;
-- SRAM/NOR-Flash write timing registers 1
type BWTR_Register is record
-- ADDSET
ADDSET : BWTR1_ADDSET_Field := 16#F#;
-- ADDHLD
ADDHLD : BWTR1_ADDHLD_Field := 16#F#;
-- DATAST
DATAST : BWTR1_DATAST_Field := 16#FF#;
-- unspecified
Reserved_16_19 : HAL.UInt4 := 16#F#;
-- CLKDIV
CLKDIV : BWTR1_CLKDIV_Field := 16#F#;
-- DATLAT
DATLAT : BWTR1_DATLAT_Field := 16#F#;
-- ACCMOD
ACCMOD : BWTR1_ACCMOD_Field := 16#0#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BWTR_Register use record
ADDSET at 0 range 0 .. 3;
ADDHLD at 0 range 4 .. 7;
DATAST at 0 range 8 .. 15;
Reserved_16_19 at 0 range 16 .. 19;
CLKDIV at 0 range 20 .. 23;
DATLAT at 0 range 24 .. 27;
ACCMOD at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-------------------
-- SDCR_Register --
-------------------
subtype SDCR1_NC_Field is HAL.UInt2;
subtype SDCR1_NR_Field is HAL.UInt2;
subtype SDCR1_MWID_Field is HAL.UInt2;
subtype SDCR1_CAS_Field is HAL.UInt2;
subtype SDCR1_SDCLK_Field is HAL.UInt2;
subtype SDCR1_RPIPE_Field is HAL.UInt2;
-- SDRAM Control Register 1
type SDCR_Register is record
-- Number of column address bits
NC : SDCR1_NC_Field := 16#0#;
-- Number of row address bits
NR : SDCR1_NR_Field := 16#0#;
-- Memory data bus width
MWID : SDCR1_MWID_Field := 16#1#;
-- Number of internal banks
NB : Boolean := True;
-- CAS latency
CAS : SDCR1_CAS_Field := 16#1#;
-- Write protection
WP : Boolean := True;
-- SDRAM clock configuration
SDCLK : SDCR1_SDCLK_Field := 16#0#;
-- Burst read
RBURST : Boolean := False;
-- Read pipe
RPIPE : SDCR1_RPIPE_Field := 16#0#;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SDCR_Register use record
NC at 0 range 0 .. 1;
NR at 0 range 2 .. 3;
MWID at 0 range 4 .. 5;
NB at 0 range 6 .. 6;
CAS at 0 range 7 .. 8;
WP at 0 range 9 .. 9;
SDCLK at 0 range 10 .. 11;
RBURST at 0 range 12 .. 12;
RPIPE at 0 range 13 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-------------------
-- SDTR_Register --
-------------------
subtype SDTR1_TMRD_Field is HAL.UInt4;
subtype SDTR1_TXSR_Field is HAL.UInt4;
subtype SDTR1_TRAS_Field is HAL.UInt4;
subtype SDTR1_TRC_Field is HAL.UInt4;
subtype SDTR1_TWR_Field is HAL.UInt4;
subtype SDTR1_TRP_Field is HAL.UInt4;
subtype SDTR1_TRCD_Field is HAL.UInt4;
-- SDRAM Timing register 1
type SDTR_Register is record
-- Load Mode Register to Active
TMRD : SDTR1_TMRD_Field := 16#F#;
-- Exit self-refresh delay
TXSR : SDTR1_TXSR_Field := 16#F#;
-- Self refresh time
TRAS : SDTR1_TRAS_Field := 16#F#;
-- Row cycle delay
TRC : SDTR1_TRC_Field := 16#F#;
-- Recovery delay
TWR : SDTR1_TWR_Field := 16#F#;
-- Row precharge delay
TRP : SDTR1_TRP_Field := 16#F#;
-- Row to column delay
TRCD : SDTR1_TRCD_Field := 16#F#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SDTR_Register use record
TMRD at 0 range 0 .. 3;
TXSR at 0 range 4 .. 7;
TRAS at 0 range 8 .. 11;
TRC at 0 range 12 .. 15;
TWR at 0 range 16 .. 19;
TRP at 0 range 20 .. 23;
TRCD at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
--------------------
-- SDCMR_Register --
--------------------
subtype SDCMR_MODE_Field is HAL.UInt3;
---------------
-- SDCMR.CTB --
---------------
-- SDCMR_CTB array
type SDCMR_CTB_Field_Array is array (1 .. 2) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for SDCMR_CTB
type SDCMR_CTB_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CTB as a value
Val : HAL.UInt2;
when True =>
-- CTB as an array
Arr : SDCMR_CTB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for SDCMR_CTB_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
subtype SDCMR_NRFS_Field is HAL.UInt4;
subtype SDCMR_MRD_Field is HAL.UInt13;
-- SDRAM Command Mode register
type SDCMR_Register is record
-- Write-only. Command mode
MODE : SDCMR_MODE_Field := 16#0#;
-- Write-only. Command target bank 2
CTB : SDCMR_CTB_Field := (As_Array => False, Val => 16#0#);
-- Number of Auto-refresh
NRFS : SDCMR_NRFS_Field := 16#0#;
-- Mode Register definition
MRD : SDCMR_MRD_Field := 16#0#;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SDCMR_Register use record
MODE at 0 range 0 .. 2;
CTB at 0 range 3 .. 4;
NRFS at 0 range 5 .. 8;
MRD at 0 range 9 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
--------------------
-- SDRTR_Register --
--------------------
subtype SDRTR_COUNT_Field is HAL.UInt13;
-- SDRAM Refresh Timer register
type SDRTR_Register is record
-- Write-only. Clear Refresh error flag
CRE : Boolean := False;
-- Refresh Timer Count
COUNT : SDRTR_COUNT_Field := 16#0#;
-- RES Interrupt Enable
REIE : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SDRTR_Register use record
CRE at 0 range 0 .. 0;
COUNT at 0 range 1 .. 13;
REIE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-------------------
-- SDSR_Register --
-------------------
----------------
-- SDSR.MODES --
----------------
-- SDSR_MODES array element
subtype SDSR_MODES_Element is HAL.UInt2;
-- SDSR_MODES array
type SDSR_MODES_Field_Array is array (1 .. 2) of SDSR_MODES_Element
with Component_Size => 2, Size => 4;
-- Type definition for SDSR_MODES
type SDSR_MODES_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MODES as a value
Val : HAL.UInt4;
when True =>
-- MODES as an array
Arr : SDSR_MODES_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for SDSR_MODES_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- SDRAM Status register
type SDSR_Register is record
-- Read-only. Refresh error flag
RE : Boolean;
-- Read-only. Status Mode for Bank 1
MODES : SDSR_MODES_Field;
-- Read-only. Busy status
BUSY : Boolean;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SDSR_Register use record
RE at 0 range 0 .. 0;
MODES at 0 range 1 .. 4;
BUSY at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Flexible memory controller
type FMC_Peripheral is record
-- SRAM/NOR-Flash chip-select control register 1
BCR1 : BCR1_Register;
-- SRAM/NOR-Flash chip-select timing register 1
BTR1 : BTR_Register;
-- SRAM/NOR-Flash chip-select control register 2
BCR2 : BCR_Register;
-- SRAM/NOR-Flash chip-select timing register 2
BTR2 : BTR_Register;
-- SRAM/NOR-Flash chip-select control register 3
BCR3 : BCR_Register;
-- SRAM/NOR-Flash chip-select timing register 3
BTR3 : BTR_Register;
-- SRAM/NOR-Flash chip-select control register 4
BCR4 : BCR_Register;
-- SRAM/NOR-Flash chip-select timing register 4
BTR4 : BTR_Register;
-- PC Card/NAND Flash control register 2
PCR2 : PCR_Register;
-- FIFO status and interrupt register 2
SR2 : SR_Register;
-- Common memory space timing register 2
PMEM2 : PMEM_Register;
-- Attribute memory space timing register 2
PATT2 : PATT_Register;
-- ECC result register 2
ECCR2 : HAL.Word;
-- PC Card/NAND Flash control register 3
PCR3 : PCR_Register;
-- FIFO status and interrupt register 3
SR3 : SR_Register;
-- Common memory space timing register 3
PMEM3 : PMEM_Register;
-- Attribute memory space timing register 3
PATT3 : PATT_Register;
-- ECC result register 3
ECCR3 : HAL.Word;
-- PC Card/NAND Flash control register 4
PCR4 : PCR_Register;
-- FIFO status and interrupt register 4
SR4 : SR_Register;
-- Common memory space timing register 4
PMEM4 : PMEM_Register;
-- Attribute memory space timing register 4
PATT4 : PATT_Register;
-- I/O space timing register 4
PIO4 : PIO4_Register;
-- SRAM/NOR-Flash write timing registers 1
BWTR1 : BWTR_Register;
-- SRAM/NOR-Flash write timing registers 2
BWTR2 : BWTR_Register;
-- SRAM/NOR-Flash write timing registers 3
BWTR3 : BWTR_Register;
-- SRAM/NOR-Flash write timing registers 4
BWTR4 : BWTR_Register;
-- SDRAM Control Register 1
SDCR1 : SDCR_Register;
-- SDRAM Control Register 2
SDCR2 : SDCR_Register;
-- SDRAM Timing register 1
SDTR1 : SDTR_Register;
-- SDRAM Timing register 2
SDTR2 : SDTR_Register;
-- SDRAM Command Mode register
SDCMR : SDCMR_Register;
-- SDRAM Refresh Timer register
SDRTR : SDRTR_Register;
-- SDRAM Status register
SDSR : SDSR_Register;
end record
with Volatile;
for FMC_Peripheral use record
BCR1 at 0 range 0 .. 31;
BTR1 at 4 range 0 .. 31;
BCR2 at 8 range 0 .. 31;
BTR2 at 12 range 0 .. 31;
BCR3 at 16 range 0 .. 31;
BTR3 at 20 range 0 .. 31;
BCR4 at 24 range 0 .. 31;
BTR4 at 28 range 0 .. 31;
PCR2 at 96 range 0 .. 31;
SR2 at 100 range 0 .. 31;
PMEM2 at 104 range 0 .. 31;
PATT2 at 108 range 0 .. 31;
ECCR2 at 116 range 0 .. 31;
PCR3 at 128 range 0 .. 31;
SR3 at 132 range 0 .. 31;
PMEM3 at 136 range 0 .. 31;
PATT3 at 140 range 0 .. 31;
ECCR3 at 148 range 0 .. 31;
PCR4 at 160 range 0 .. 31;
SR4 at 164 range 0 .. 31;
PMEM4 at 168 range 0 .. 31;
PATT4 at 172 range 0 .. 31;
PIO4 at 176 range 0 .. 31;
BWTR1 at 260 range 0 .. 31;
BWTR2 at 268 range 0 .. 31;
BWTR3 at 276 range 0 .. 31;
BWTR4 at 284 range 0 .. 31;
SDCR1 at 320 range 0 .. 31;
SDCR2 at 324 range 0 .. 31;
SDTR1 at 328 range 0 .. 31;
SDTR2 at 332 range 0 .. 31;
SDCMR at 336 range 0 .. 31;
SDRTR at 340 range 0 .. 31;
SDSR at 344 range 0 .. 31;
end record;
-- Flexible memory controller
FMC_Periph : aliased FMC_Peripheral
with Import, Address => FMC_Base;
end STM32_SVD.FSMC;
|
with Ada.Text_IO;
with Ada.Command_Line;
procedure SyntaxError is
package IO renames Ada.Text_IO;
begin
IO.Put_Line("Hello, world!")
end SyntaxErro;
|
with
FLTK.Devices.Graphics;
package FLTK.Devices.Surfaces is
type Surface_Device is new Device with private;
type Surface_Device_Reference (Data : not null access Surface_Device'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(Graphics : in out FLTK.Devices.Graphics.Graphics_Driver)
return Surface_Device;
end Forge;
function Get_Current
return access Surface_Device'Class;
procedure Set_Current
(This : in out Surface_Device);
private
type Surface_Device is new Device with null record;
overriding procedure Finalize
(This : in out Surface_Device);
Original_Surface : aliased Surface_Device;
Current_Ptr : access Surface_Device'Class := Original_Surface'Access;
pragma Inline (Get_Current);
pragma Inline (Set_Current);
end FLTK.Devices.Surfaces;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Exceptions;
with GNAT.Sockets;
with Interfaces.C;
with Network.Streams;
with Network.Managers.TCP_V4_Out;
package body Network.Managers.TCP_V4 is
type Out_Socket_Access is access all TCP_V4_Out.Out_Socket;
-----------------
-- Can_Connect --
-----------------
overriding function Can_Connect
(Self : Protocol;
Address : Network.Addresses.Address) return Boolean
is
pragma Unreferenced (Self);
List : constant League.String_Vectors.Universal_String_Vector :=
Network.Addresses.To_String (Address).Split ('/');
begin
return List.Length = 5 and then
List (1).Is_Empty and then
List (2).To_Wide_Wide_String = "ip4" and then
List (4).To_Wide_Wide_String = "tcp";
end Can_Connect;
----------------
-- Can_Listen --
----------------
overriding function Can_Listen
(Self : Protocol; Address : Network.Addresses.Address) return Boolean
renames Can_Connect;
-------------
-- Connect --
-------------
overriding procedure Connect
(Self : in out Protocol;
Address : Network.Addresses.Address;
Poll : in out Network.Polls.Poll;
Error : out League.Strings.Universal_String;
Promise : out Network.Connection_Promises.Promise;
Options : League.String_Vectors.Universal_String_Vector :=
League.String_Vectors.Empty_Universal_String_Vector)
is
pragma Unreferenced (Options, Self);
Req : GNAT.Sockets.Request_Type :=
(GNAT.Sockets.Non_Blocking_IO, Enabled => True);
List : constant League.String_Vectors.Universal_String_Vector :=
Network.Addresses.To_String (Address).Split ('/');
Internal : GNAT.Sockets.Socket_Type;
Addr : GNAT.Sockets.Sock_Addr_Type;
Socket : Out_Socket_Access;
begin
Addr.Addr := GNAT.Sockets.Inet_Addr (List (3).To_UTF_8_String);
Addr.Port := GNAT.Sockets.Port_Type'Wide_Wide_Value
(List (5).To_Wide_Wide_String);
GNAT.Sockets.Create_Socket (Internal);
GNAT.Sockets.Control_Socket (Internal, Req);
begin
GNAT.Sockets.Connect_Socket (Internal, Addr);
exception -- Ignore Operation_Now_In_Progress
when E : GNAT.Sockets.Socket_Error =>
declare
Kind : constant GNAT.Sockets.Error_Type :=
GNAT.Sockets.Resolve_Exception (E);
begin
if Kind not in GNAT.Sockets.Operation_Now_In_Progress then
Error := League.Strings.From_UTF_8_String
(Ada.Exceptions.Exception_Message (E));
return;
end if;
end;
end;
Socket := new TCP_V4_Out.Out_Socket (Poll'Unchecked_Access);
Socket.Internal := Internal;
Socket.Events := (Network.Polls.Output => True, others => False);
Poll.Watch
(Interfaces.C.int (GNAT.Sockets.To_C (Internal)),
Events => Socket.Events,
Listener => Socket.all'Access);
Promise := Socket.Promise.To_Promise;
exception
when E : GNAT.Sockets.Socket_Error =>
Error := League.Strings.From_UTF_8_String
(Ada.Exceptions.Exception_Message (E));
end Connect;
------------
-- Listen --
------------
overriding procedure Listen
(Self : in out Protocol;
List : Network.Addresses.Address_Array;
Listener : Connection_Listener_Access;
Poll : in out Network.Polls.Poll;
Error : out League.Strings.Universal_String;
Options : League.String_Vectors.Universal_String_Vector :=
League.String_Vectors.Empty_Universal_String_Vector)
is
pragma Unreferenced (List, Poll, Error, Options);
begin
raise Program_Error;
end Listen;
--------------
-- Register --
--------------
procedure Register (Manager : in out Network.Managers.Manager) is
begin
Manager.Register (new Protocol);
end Register;
end Network.Managers.TCP_V4;
|
------------------------------------------------------------------------------
-- --
-- Giza --
-- --
-- Copyright (C) 2016 Fabien Chouteau (chouteau@adacore.com) --
-- --
-- --
-- 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 Giza.Types is
subtype Dim is Integer;
type Point_T is record
X, Y : Dim;
end record;
function To_String (Pt : Point_T) return String is
("(X:" & Pt.X'Img & ", Y:" & Pt.Y'Img & ")");
function "+" (A, B : Point_T) return Point_T is (A.X + B.X, A.Y + B.Y);
function "-" (A, B : Point_T) return Point_T is (A.X - B.X, A.Y - B.Y);
type Size_T is record
W, H : Natural;
end record;
function To_String (Size : Size_T) return String is
("(W:" & Size.W'Img & ", H:" & Size.H'Img & ")");
function "+" (A, B : Size_T) return Size_T is (A.W + B.W, A.H + B.H);
function "-" (A, B : Size_T) return Size_T is (A.W - B.W, A.H - B.H);
function "*" (A : Size_T; B : Integer) return Size_T is (A.W * B, A.H * B);
function "/" (A : Size_T; B : Integer) return Size_T is (A.W / B, A.H / B);
type Rect_T is record
Org : Point_T;
Size : Size_T;
end record;
function "+" (A : Rect_T; B : Size_T) return Rect_T is
(A.Org, A.Size + B);
function "+" (B : Size_T; A : Rect_T) return Rect_T is
(A.Org, A.Size + B);
function "+" (A : Rect_T; B : Point_T) return Rect_T is
(A.Org + B, A.Size);
function "+" (B : Point_T; A : Rect_T) return Rect_T is
(A.Org + B, A.Size);
function "+" (A : Point_T; B : Size_T) return Point_T is
(A.X + B.W, A.Y + B.H);
function "+" (A : Size_T; B : Point_T) return Point_T is
(A.W + B.X, A.H + B.Y);
function To_String (Rect : Rect_T) return String is
("(Org:" & To_String (Rect.Org) &
", Size:" & To_String (Rect.Size) & ")");
function Center (R : Rect_T) return Point_T;
function Intersection (A, B : Rect_T) return Rect_T;
type HC_Matrix is record
V11, V12, V13 : Float := 0.0;
V21, V22, V23 : Float := 0.0;
V31, V32, V33 : Float := 0.0;
end record;
function "*" (A, B : HC_Matrix) return HC_Matrix;
function "*" (A : HC_Matrix; B : Point_T) return Point_T;
function Id return HC_Matrix;
function Rotation_Matrix (Rad : Float) return HC_Matrix;
function Translation_Matrix (Pt : Point_T) return HC_Matrix;
function Scale_Matrix (Scale : Float) return HC_Matrix;
function Scale_Matrix (X, Y : Float) return HC_Matrix;
end Giza.Types;
|
-- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)
-- Martin Becker (becker@rcs.ei.tum.de)
with Units; use Units;
with Units.Operations; use Units.Operations;
with MS5611.Register; use MS5611.Register;
with Ada.Real_Time; use Ada.Real_Time;
with HIL.SPI;
-- @summary Driver for the Barometer MS5611-01BA03
package body MS5611.Driver with SPARK_Mode,
Refined_State => (State => (G_Baro_State, temperature_raw, temperature, pressure_raw, pressure),
Coefficients => (G_sens_t1, G_off_t1, G_tcs, G_tco, G_t_ref, G_tempsens, dT, SENS, OFF, TEMP))
is
type Data_Array is array (Natural range <>) of HIL.Byte with
Component_Size => 8;
-- baro device states
type Baro_FSM_Type is
(NOT_INITIALIZED,
READY,
TEMPERATURE_CONVERSION,
PRESSURE_CONVERSION)
with Default_Value => NOT_INITIALIZED;
type Conversion_Info_Type is record
OSR : OSR_Type;
Start : Time_Type;
end record;
-- the current state of the sensor device
-- @field FSM_State what the device is currently doing
-- @field Conv_Info_Temp context for state TEMPERATURE_CONVERSION
-- @field Conv_Info_Pres context for state PRESSURE_CONVERSION
type Baro_State_Type is record
FSM_State : Baro_FSM_Type;
Conv_Info_Temp : Conversion_Info_Type;
Conv_Info_Pres : Conversion_Info_Type;
end record;
type Conversion_Time_LUT_Type is array (OSR_Type) of Time_Type;
type Coefficient_ID_Type is (COEFF_SENS_T1, COEFF_OFF_T1, COEFF_TCS, COEFF_TCO, COEFF_T_REF, COEFF_TEMPSENS);
type Coefficient_Data_Type is mod 2**16 with
Size => 16;
type Conversion_ID_Type is (D1, D2);
type Conversion_Data_Type is mod 2**24 with Size => 24;
subtype Sens_T1_Type is Float range 0.0 .. Float ((2**16 - 1) * 2**15);
subtype Off_T1_Type is Float range 0.0 .. Float ((2**16 - 1) * 2**16);
subtype TCS_Type is Float range 0.0 .. Float (2**16 - 1) / Float (2**8);
subtype TCO_Type is Float range 0.0 .. Float (2**16 - 1) / Float (2**7);
subtype T_Ref_Type is Float range 0.0 .. Float ((2**16 - 1) * 2**8);
subtype Tempsens_Type is Float range 0.0 .. Float (2**16 - 1) / Float (2**23);
subtype DT_Type is Float range -16776960.9 .. 16777216.9;
subtype Sense_Type is Float range -4294836225.9 .. 6442352640.9;
subtype OFF_Type is Float range -8589672450.9 .. 12884705280.9;
subtype TEMP_Type is Float range -4000.9 .. 8500.9;
-- a bunch of functions that allows to add/sub/cast types without range problems
function Sat_Cast_OffType is new Units.Saturated_Cast (OFF_Type);
function Sat_Cast_TEMPType is new Units.Saturated_Cast (TEMP_Type);
function Sat_Cast_SensType is new Units.Saturated_Cast (Sense_Type);
function Sat_Add_OffType is new Units.Saturated_Addition (OFF_Type);
function Sat_Add_SensType is new Units.Saturated_Addition (Sense_Type);
function Sat_Add_TempType is new Units.Saturated_Addition (TEMP_Type);
function Sat_Sub_TempType is new Units.Saturated_Subtraction (TEMP_Type);
function Sat_Sub_OffType is new Units.Saturated_Subtraction (OFF_Type);
function Sat_Sub_SensType is new Units.Saturated_Subtraction (Sense_Type);
----------------------
-- PROTOTYPES
----------------------
procedure start_conversion (ID : Conversion_ID_Type; OSR : OSR_Type);
function calculateTemperatureDifference
(Temp_Raw : Conversion_Data_Type;
T_Ref : Float) return DT_Type;
procedure compensateTemperature;
function conversion_Finished (state : Baro_State_Type;
conv_time : Conversion_Time_LUT_Type;
now : Time) return Boolean;
function convertToKelvin (thisTemp : in TEMP_Type) return Temperature_Type;
function calculatePressure
(arg_pressure_raw : Conversion_Data_Type;
arg_sense : Sense_Type;
arg_offset : OFF_Type) return Pressure_Type;
-- calculate physical pressure from raw measurements
-- @param arg_pressure_raw raw pressure data
-- @param arg_sense raw sense data
-- @param arg_offset calibration offset
-- @return barometric pressure
procedure writeToDevice (Device : Device_Type; data : in Data_Array);
procedure selectDevice (Device : Device_Type);
procedure deselectDevice (Device : Device_Type);
procedure transferWithDevice (Device : Device_Type;
data_tx : in Data_Array;
data_rx : out Data_Array);
procedure read_coefficient (Device : Device_Type;
coeff_id : Coefficient_ID_Type;
coeff_data : out Coefficient_Data_Type);
procedure read_adc (Device : Device_Type; adc_value : out Conversion_Data_Type);
-------------
-- LUTS
-------------
-- maximum conversion times (taken from the datasheet)
Conversion_Time_LUT : constant Conversion_Time_LUT_Type :=
(OSR_256 => Time_Type (0.60 / 1000.0),
OSR_512 => Time_Type (1.17 / 1000.0),
OSR_1024 => Time_Type (2.28 / 1000.0),
OSR_2048 => Time_Type (4.54 / 1000.0),
OSR_4096 => Time_Type (9.04 / 1000.0));
-- conversion variables
G_Baro_State : Baro_State_Type :=
(FSM_State => NOT_INITIALIZED,
Conv_Info_Temp => (OSR_256, Time_Type (0.0)),
Conv_Info_Pres => (OSR_256, Time_Type (0.0)));
-- calibration variables (read values)
G_sens_t1 : Sens_T1_Type := 0.0; -- Pressure sensitivity (54487)
G_off_t1 : Off_T1_Type := 0.0; -- Pressure offset (51552)
G_tcs : TCS_Type := 0.0; -- Temperature coefficient of pressure sensitivity (33258)
G_tco : TCO_Type := 0.0; -- Temperature coefficient of pressure offset (27255)
G_t_ref : T_Ref_Type := 0.0; -- barometer reference temperature (29426)
G_tempsens : Tempsens_Type := 0.0; -- Temperature coefficient of the temperature (27777)
-- ADC values
temperature_raw : Conversion_Data_Type := 0; -- raw temperture read from baro
pressure_raw : Conversion_Data_Type := 0; -- raw pressure read from baro
-- Compensation values
dT : DT_Type := 0.0; -- difference between actual and reference temperature
SENS : Sense_Type := 0.0; -- pressure sensitivity at the actual temperature
OFF : OFF_Type := 0.0; -- pressure offset at actual temperature
TEMP : TEMP_Type := 0.0;
-- final measurement values
pressure : Pressure_Type := 101300.0 * Units.Pascal; -- invalid initial value
temperature : Temperature_Type := 293.15 * Units.Kelvin;
G_CELSIUS_0 : constant := 273.15;
-- Glue Code
-- the following procedures access the Hardware Interface Layer (HIL)
----------------------
-- selectDevice
----------------------
procedure selectDevice (Device : Device_Type) is
begin
if Device = Baro then
HIL.SPI.select_Chip (HIL.SPI.Barometer);
end if;
end selectDevice;
----------------------
-- deselectDevice
----------------------
procedure deselectDevice (Device : Device_Type) is
begin
if Device = Baro then
HIL.SPI.deselect_Chip (HIL.SPI.Barometer);
end if;
end deselectDevice;
----------------------
-- writeToDevice
----------------------
procedure writeToDevice (Device : Device_Type; data : in Data_Array) is
begin
selectDevice (Device);
HIL.SPI.write (HIL.SPI.Barometer, HIL.SPI.Data_Type (data));
deselectDevice (Device);
end writeToDevice;
----------------------
-- transferWithDevice
----------------------
procedure transferWithDevice
(Device : Device_Type;
data_tx : in Data_Array;
data_rx : out Data_Array)
is
begin
selectDevice (Device);
HIL.SPI.transceive
(HIL.SPI.Barometer,
HIL.SPI.Data_Type (data_tx),
HIL.SPI.Data_Type (data_rx));
deselectDevice (Device);
end transferWithDevice;
----------------------
-- read_coefficient
----------------------
procedure read_coefficient
(Device : Device_Type;
coeff_id : Coefficient_ID_Type;
coeff_data : out Coefficient_Data_Type)
is
Data_TX : Data_Array (1 .. 3) := (others => 0);
Data_RX : Data_Array (1 .. 3);
begin
case coeff_id is
when COEFF_SENS_T1 =>
Data_TX (1) := HIL.Byte (CMD_READ_C1);
when COEFF_OFF_T1 =>
Data_TX (1) := HIL.Byte (CMD_READ_C2);
when COEFF_TCS =>
Data_TX (1) := HIL.Byte (CMD_READ_C3);
when COEFF_TCO =>
Data_TX (1) := HIL.Byte (CMD_READ_C4);
when COEFF_T_REF =>
Data_TX (1) := HIL.Byte (CMD_READ_C5);
when COEFF_TEMPSENS =>
Data_TX (1) := HIL.Byte (CMD_READ_C6);
end case;
transferWithDevice (Device, Data_TX, Data_RX);
coeff_data :=
Coefficient_Data_Type (Data_RX (3)) +
Coefficient_Data_Type (Data_RX (2)) * (2**8);
-- coeff_data := Convert( data(1 .. 2) );
end read_coefficient;
----------------------
-- read_adc
----------------------
-- reads the 24 bit ADC value from the barometer
procedure read_adc (Device : Device_Type; adc_value : out Conversion_Data_Type)
is
Data_TX : constant Data_Array (1 .. 4) :=
(1 => HIL.Byte (CMD_ADC_READ), others => 0);
Data_RX : Data_Array (1 .. 4);
begin
transferWithDevice (Device, Data_TX, Data_RX);
adc_value :=
Conversion_Data_Type (Data_RX (4)) +
Conversion_Data_Type (Data_RX (3)) * (2**8) +
Conversion_Data_Type (Data_RX (2)) * (2**16);
end read_adc;
----------------------
-- reset
----------------------
procedure Reset is
begin
writeToDevice (Baro, (1 => HIL.Byte (CMD_RESET)));
end Reset;
-------------
-- Init
-------------
-- This function sequentially initializes the barometer.
-- Therefore, the barometer is reset, the PROM-Coefficients are read and
-- the takeoff altitude (altitude_offset) is calculated.
procedure Init is
c1 : Coefficient_Data_Type;
c2 : Coefficient_Data_Type;
c3 : Coefficient_Data_Type;
c4 : Coefficient_Data_Type;
c5 : Coefficient_Data_Type;
c6 : Coefficient_Data_Type;
begin
read_coefficient (Baro, COEFF_SENS_T1, c1);
G_sens_t1 := Float (c1) * Float (2**15);
read_coefficient (Baro, COEFF_OFF_T1, c2);
G_off_t1 := Float (c2) * Float (2**16);
read_coefficient (Baro, COEFF_TCS, c3);
G_tcs := (Float (c3) / Float (2**8));
read_coefficient (Baro, COEFF_TCO, c4);
G_tco := (Float (c4) / Float (2**7));
read_coefficient (Baro, COEFF_T_REF, c5);
G_t_ref := (Float (c5) * Float (2**8));
read_coefficient (Baro, COEFF_TEMPSENS, c6);
G_tempsens := (Float (c6) / Float (2**23));
G_Baro_State.FSM_State := READY;
end Init;
----------------------
-- start_conversion
----------------------
procedure start_conversion (ID : Conversion_ID_Type; OSR : OSR_Type) is
data : Data_Array (1 .. 1) := (others => 0);
now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
case (ID) is
when D1 =>
case (OSR) is
when OSR_256 =>
data (1) := HIL.Byte (CMD_D1_CONV_256);
when OSR_512 =>
data (1) := HIL.Byte (CMD_D1_CONV_512);
when OSR_1024 =>
data (1) := HIL.Byte (CMD_D1_CONV_1024);
when OSR_2048 =>
data (1) := HIL.Byte (CMD_D1_CONV_2048);
when OSR_4096 =>
data (1) := HIL.Byte (CMD_D1_CONV_4096);
end case;
G_Baro_State.Conv_Info_Pres.OSR := OSR;
G_Baro_State.Conv_Info_Pres.Start := Units.To_Time (now);
when D2 =>
case (OSR) is
when OSR_256 =>
data (1) := HIL.Byte (CMD_D2_CONV_256);
when OSR_512 =>
data (1) := HIL.Byte (CMD_D2_CONV_512);
when OSR_1024 =>
data (1) := HIL.Byte (CMD_D2_CONV_1024);
when OSR_2048 =>
data (1) := HIL.Byte (CMD_D2_CONV_2048);
when OSR_4096 =>
data (1) := HIL.Byte (CMD_D2_CONV_4096);
end case;
G_Baro_State.Conv_Info_Temp.OSR := OSR;
G_Baro_State.Conv_Info_Temp.Start := Units.To_Time (now);
end case;
writeToDevice (Baro, data);
end start_conversion;
----------------------
-- self_check
----------------------
procedure Self_Check (Status : out Error_Type) is
later : Ada.Real_Time.Time := Ada.Real_Time.Clock;
have_update : Boolean;
begin
Wait_Value_Loop :
for k in 0 .. 4 loop
Update_Val (have_update);
exit Wait_Value_Loop when have_update;
later := later + Milliseconds (100); -- easily enough
delay until later;
end loop Wait_Value_Loop;
Status := (if have_update then SUCCESS else FAILURE);
end Self_Check;
----------------------
-- conversion_Finished
----------------------
function conversion_Finished (state : Baro_State_Type;
conv_time : Conversion_Time_LUT_Type;
now : Time) return Boolean
is
result : Boolean;
begin
case (state.FSM_State) is
when TEMPERATURE_CONVERSION =>
result := (Sum_Time (state.Conv_Info_Temp.Start,
conv_time (state.Conv_Info_Temp.OSR)) < Units.To_Time (now));
when PRESSURE_CONVERSION =>
result := (Sum_Time (state.Conv_Info_Pres.Start,
conv_time (state.Conv_Info_Pres.OSR)) < Units.To_Time (now));
when others =>
result := False;
end case;
return result;
end conversion_Finished;
------------------------------------
-- calculateTemperatureDifference
------------------------------------
function calculateTemperatureDifference
(Temp_Raw : Conversion_Data_Type;
T_Ref : Float) return DT_Type
is
begin
return DT_Type (Float (Temp_Raw) - T_Ref);
end calculateTemperatureDifference;
----------------------
-- convertToKelvin
----------------------
function convertToKelvin (thisTemp : in TEMP_Type) return Temperature_Type is
ret : Temperature_Type := Temperature_Type'First; -- init required, otherwise constraint error!
cand : constant Float := Float (G_CELSIUS_0) + Float (thisTemp) / 100.0;
-- function Sat_Cast_Temperature is new Units.Saturated_Cast (Temperature_Type);
-- cannot use Sat_Cast here, because that builds on units,
-- which requires default value of 0.0, which isn't in Temperature_Type'Range
begin
if cand > Float (Temperature_Type'Last) then
ret := Temperature_Type'Last;
elsif cand < Float (Temperature_Type'First) then
ret := Temperature_Type'First;
else
ret := Temperature_Type (cand);
end if;
return ret;
end convertToKelvin;
---------------------------
-- compensateTemperature
---------------------------
-- compensates values according to datasheet
procedure compensateTemperature is
T2 : TEMP_Type := 0.0;
OFF2 : OFF_Type := 0.0;
SENS2 : Sense_Type := 0.0;
begin
if TEMP < TEMP_Type (2000.0) then
T2 := Sat_Cast_TEMPType (dT**2 / Float (2**31));
OFF2 := Sat_Cast_OffType (5.0 * (TEMP - TEMP_Type (2000.0))**2 / 2.0);
SENS2 := Sense_Type (OFF2 / 2.0);
if TEMP < TEMP_Type (-1500.0) then
OFF2 := Sat_Add_OffType (OFF2, Sat_Cast_OffType (7.0 * (TEMP - TEMP_Type (1500.0))**2));
SENS2 := Sat_Add_SensType (SENS2, Sat_Cast_SensType (11.0 * (TEMP - TEMP_Type (1500.0))**2 / 2.0));
end if;
end if;
TEMP := Sat_Sub_TempType (TEMP, T2); -- this compensates the final temperature value
OFF := Sat_Sub_OffType (OFF, OFF2);
SENS := Sat_Sub_SensType (SENS, SENS2);
end compensateTemperature;
----------------------
-- calculatePressure
----------------------
function calculatePressure
(arg_pressure_raw : Conversion_Data_Type;
arg_sense : Sense_Type;
arg_offset : OFF_Type) return Pressure_Type
is
begin
return Pressure_Type
((Float (arg_pressure_raw) * arg_sense / Float (2**21) - arg_offset) /
Float (2**15));
end calculatePressure;
----------------------
-- get_temperature
----------------------
function Get_Temperature return Temperature_Type is
begin
return temperature;
end Get_Temperature;
----------------------
-- get_pressure
----------------------
function Get_Pressure return Pressure_Type is
begin
return pressure;
end Get_Pressure;
----------------------
-- update_val
----------------------
procedure Update_Val (have_update : out Boolean) is
begin
-- Barometer takes 10ms (8.2ms) for one conversion, barometer_update_val gets called every main_loop (5ms)
-- read conversion value every second to make sure barometer timing constraint is not violated
have_update := False;
case G_Baro_State.FSM_State is
when NOT_INITIALIZED =>
null;
when READY =>
start_conversion (D2, OSR_4096);
G_Baro_State.FSM_State := TEMPERATURE_CONVERSION;
when TEMPERATURE_CONVERSION =>
-- ToDo check time
declare
t_abs : constant Ada.Real_Time.Time := Clock; -- see SPARK RM 7.1.3-12
begin
if conversion_Finished (G_Baro_State, Conversion_Time_LUT, t_abs) then
read_adc (Baro, temperature_raw);
if temperature_raw /= 0 then
dT := calculateTemperatureDifference (temperature_raw, G_t_ref);
TEMP := Sat_Add_TempType (2000.0, Sat_Cast_TEMPType (dT * G_tempsens));
OFF := Sat_Add_OffType (G_off_t1, Sat_Cast_OffType (G_tco * dT));
SENS := Sat_Add_SensType (G_sens_t1, Sat_Cast_SensType (G_tcs * dT));
compensateTemperature;
temperature := convertToKelvin (TEMP);
start_conversion (D1, OSR_4096);
G_Baro_State.FSM_State := PRESSURE_CONVERSION;
else -- Read error, restart
start_conversion (D2, OSR_4096);
G_Baro_State.FSM_State := TEMPERATURE_CONVERSION;
end if;
end if;
end;
when PRESSURE_CONVERSION =>
declare
t_abs : constant Ada.Real_Time.Time := Clock; -- see SPARK RM 7.1.3-12
begin
if conversion_Finished (G_Baro_State, Conversion_Time_LUT, t_abs) then
read_adc (Baro, pressure_raw);
if pressure_raw /= 0 then
pressure := calculatePressure (pressure_raw, SENS, OFF);
have_update := True;
start_conversion (D2, OSR_4096);
G_Baro_State.FSM_State := TEMPERATURE_CONVERSION;
else
start_conversion (D1, OSR_4096);
G_Baro_State.FSM_State := PRESSURE_CONVERSION;
end if;
end if;
end;
end case;
end Update_Val;
end MS5611.Driver;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A S P E C T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2010-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package defines the aspects that are recognized by GNAT in aspect
-- specifications. It also contains the subprograms for storing/retrieving
-- aspect specifications from the tree. The semantic processing for aspect
-- specifications is found in Sem_Ch13.Analyze_Aspect_Specifications.
------------------------
-- Adding New Aspects --
------------------------
-- In general, each aspect should have a corresponding pragma, so that the
-- newly developed functionality is available for Ada versions < Ada 2012.
-- When both are defined, it is convenient to first transform the aspect into
-- an equivalent pragma in Sem_Ch13.Analyze_Aspect_Specifications, and then
-- analyze the pragma in Sem_Prag.Analyze_Pragma.
-- To add a new aspect, you need to do the following
-- 1. Create a name in snames.ads-tmpl
-- 2. Create a value in type Aspect_Id in this unit
-- 3. Add a value for the aspect in the global arrays defined in this unit
-- 4. Add code for the aspect in Sem_Ch13.Analyze_Aspect_Specifications.
-- This may involve adding some nodes to the tree to perform additional
-- treatments later.
-- 5. If the semantic analysis of expressions/names in the aspect should not
-- occur at the point the aspect is defined, add code in the adequate
-- semantic analysis procedure for the aspect. For example, this is the
-- case for aspects Pre and Post on subprograms, which are pre-analyzed
-- at the end of the declaration list to which the subprogram belongs,
-- and fully analyzed (possibly with expansion) during the semantic
-- analysis of subprogram bodies.
with Namet; use Namet;
with Snames; use Snames;
with Types; use Types;
package Aspects is
-- Type defining recognized aspects
type Aspect_Id is
(No_Aspect, -- Dummy entry for no aspect
Aspect_Abstract_State, -- GNAT
Aspect_Address,
Aspect_Alignment,
Aspect_Annotate, -- GNAT
Aspect_Attach_Handler,
Aspect_Bit_Order,
Aspect_Component_Size,
Aspect_Constant_Indexing,
Aspect_Contract_Cases, -- GNAT
Aspect_Convention,
Aspect_CPU,
Aspect_Default_Component_Value,
Aspect_Default_Initial_Condition, -- GNAT
Aspect_Default_Iterator,
Aspect_Default_Storage_Pool,
Aspect_Default_Value,
Aspect_Depends, -- GNAT
Aspect_Dimension, -- GNAT
Aspect_Dimension_System, -- GNAT
Aspect_Dispatching_Domain,
Aspect_Dynamic_Predicate,
Aspect_Extensions_Visible, -- GNAT
Aspect_External_Name,
Aspect_External_Tag,
Aspect_Ghost, -- GNAT
Aspect_Global, -- GNAT
Aspect_Implicit_Dereference,
Aspect_Initial_Condition, -- GNAT
Aspect_Initializes, -- GNAT
Aspect_Input,
Aspect_Interrupt_Priority,
Aspect_Invariant, -- GNAT
Aspect_Iterator_Element,
Aspect_Iterable, -- GNAT
Aspect_Link_Name,
Aspect_Linker_Section, -- GNAT
Aspect_Machine_Radix,
Aspect_Object_Size, -- GNAT
Aspect_Obsolescent, -- GNAT
Aspect_Output,
Aspect_Part_Of, -- GNAT
Aspect_Post,
Aspect_Postcondition,
Aspect_Pre,
Aspect_Precondition,
Aspect_Predicate, -- GNAT
Aspect_Priority,
Aspect_Read,
Aspect_Refined_Depends, -- GNAT
Aspect_Refined_Global, -- GNAT
Aspect_Refined_Post, -- GNAT
Aspect_Refined_State, -- GNAT
Aspect_Relative_Deadline,
Aspect_Scalar_Storage_Order, -- GNAT
Aspect_Simple_Storage_Pool, -- GNAT
Aspect_Size,
Aspect_Small,
Aspect_SPARK_Mode, -- GNAT
Aspect_Static_Predicate,
Aspect_Storage_Pool,
Aspect_Storage_Size,
Aspect_Stream_Size,
Aspect_Suppress,
Aspect_Synchronization,
Aspect_Test_Case, -- GNAT
Aspect_Type_Invariant,
Aspect_Unimplemented, -- GNAT
Aspect_Unsuppress,
Aspect_Value_Size, -- GNAT
Aspect_Variable_Indexing,
Aspect_Warnings, -- GNAT
Aspect_Write,
-- The following aspects correspond to library unit pragmas
Aspect_All_Calls_Remote,
Aspect_Elaborate_Body,
Aspect_No_Elaboration_Code_All, -- GNAT
Aspect_Preelaborate,
Aspect_Pure,
Aspect_Remote_Call_Interface,
Aspect_Remote_Types,
Aspect_Shared_Passive,
Aspect_Universal_Data, -- GNAT
-- Remaining aspects have a static boolean value that turns the aspect
-- on or off. They all correspond to pragmas, but are only converted to
-- the pragmas where the value is True. A value of False normally means
-- that the aspect is ignored, except in the case of derived types where
-- the aspect value is inherited from the parent, in which case, we do
-- not allow False if we inherit a True value from the parent.
Aspect_Async_Readers, -- GNAT
Aspect_Async_Writers, -- GNAT
Aspect_Asynchronous,
Aspect_Atomic,
Aspect_Atomic_Components,
Aspect_Discard_Names,
Aspect_Effective_Reads, -- GNAT
Aspect_Effective_Writes, -- GNAT
Aspect_Export,
Aspect_Favor_Top_Level, -- GNAT
Aspect_Independent,
Aspect_Independent_Components,
Aspect_Import,
Aspect_Inline,
Aspect_Inline_Always, -- GNAT
Aspect_Interrupt_Handler,
Aspect_Lock_Free, -- GNAT
Aspect_No_Return,
Aspect_No_Tagged_Streams, -- GNAT
Aspect_Pack,
Aspect_Persistent_BSS, -- GNAT
Aspect_Preelaborable_Initialization,
Aspect_Pure_Function, -- GNAT
Aspect_Remote_Access_Type, -- GNAT
Aspect_Shared, -- GNAT (equivalent to Atomic)
Aspect_Simple_Storage_Pool_Type, -- GNAT
Aspect_Suppress_Debug_Info, -- GNAT
Aspect_Suppress_Initialization, -- GNAT
Aspect_Thread_Local_Storage, -- GNAT
Aspect_Unchecked_Union,
Aspect_Universal_Aliasing, -- GNAT
Aspect_Unmodified, -- GNAT
Aspect_Unreferenced, -- GNAT
Aspect_Unreferenced_Objects, -- GNAT
Aspect_Volatile,
Aspect_Volatile_Components);
subtype Aspect_Id_Exclude_No_Aspect is
Aspect_Id range Aspect_Id'Succ (No_Aspect) .. Aspect_Id'Last;
-- Aspect_Id's excluding No_Aspect
-- The following array indicates aspects that accept 'Class
Class_Aspect_OK : constant array (Aspect_Id) of Boolean :=
(Aspect_Input => True,
Aspect_Invariant => True,
Aspect_Output => True,
Aspect_Pre => True,
Aspect_Predicate => True,
Aspect_Post => True,
Aspect_Read => True,
Aspect_Write => True,
Aspect_Type_Invariant => True,
others => False);
-- The following array identifies all implementation defined aspects
Implementation_Defined_Aspect : constant array (Aspect_Id) of Boolean :=
(Aspect_Abstract_State => True,
Aspect_Annotate => True,
Aspect_Async_Readers => True,
Aspect_Async_Writers => True,
Aspect_Contract_Cases => True,
Aspect_Depends => True,
Aspect_Dimension => True,
Aspect_Dimension_System => True,
Aspect_Effective_Reads => True,
Aspect_Effective_Writes => True,
Aspect_Extensions_Visible => True,
Aspect_Favor_Top_Level => True,
Aspect_Ghost => True,
Aspect_Global => True,
Aspect_Inline_Always => True,
Aspect_Invariant => True,
Aspect_Lock_Free => True,
Aspect_Object_Size => True,
Aspect_Persistent_BSS => True,
Aspect_Predicate => True,
Aspect_Pure_Function => True,
Aspect_Remote_Access_Type => True,
Aspect_Scalar_Storage_Order => True,
Aspect_Shared => True,
Aspect_Simple_Storage_Pool => True,
Aspect_Simple_Storage_Pool_Type => True,
Aspect_Suppress_Debug_Info => True,
Aspect_Suppress_Initialization => True,
Aspect_Thread_Local_Storage => True,
Aspect_Test_Case => True,
Aspect_Universal_Aliasing => True,
Aspect_Universal_Data => True,
Aspect_Unmodified => True,
Aspect_Unreferenced => True,
Aspect_Unreferenced_Objects => True,
Aspect_Value_Size => True,
Aspect_Warnings => True,
others => False);
-- The following array indicates aspects for which multiple occurrences of
-- the same aspect attached to the same declaration are allowed.
No_Duplicates_Allowed : constant array (Aspect_Id) of Boolean :=
(Aspect_Annotate => False,
Aspect_Test_Case => False,
others => True);
-- The following subtype defines aspects corresponding to library unit
-- pragmas, these can only validly appear as aspects for library units,
-- and result in a corresponding pragma being inserted immediately after
-- the occurrence of the aspect.
subtype Library_Unit_Aspects is
Aspect_Id range Aspect_All_Calls_Remote .. Aspect_Universal_Data;
-- The following subtype defines aspects accepting an optional static
-- boolean parameter indicating if the aspect should be active or
-- cancelling. If the parameter is missing the effective value is True,
-- enabling the aspect. If the parameter is present it must be a static
-- expression of type Standard.Boolean. If the value is True, then the
-- aspect is enabled. If it is False, the aspect is disabled.
subtype Boolean_Aspects is
Aspect_Id range Aspect_Async_Readers .. Aspect_Id'Last;
subtype Pre_Post_Aspects is
Aspect_Id range Aspect_Post .. Aspect_Precondition;
-- The following type is used for indicating allowed expression forms
type Aspect_Expression is
(Expression, -- Required expression
Name, -- Required name
Optional_Expression, -- Optional boolean expression
Optional_Name); -- Optional name
-- The following array indicates what argument type is required
Aspect_Argument : constant array (Aspect_Id) of Aspect_Expression :=
(No_Aspect => Optional_Expression,
Aspect_Abstract_State => Expression,
Aspect_Address => Expression,
Aspect_Alignment => Expression,
Aspect_Annotate => Expression,
Aspect_Attach_Handler => Expression,
Aspect_Bit_Order => Expression,
Aspect_Component_Size => Expression,
Aspect_Constant_Indexing => Name,
Aspect_Contract_Cases => Expression,
Aspect_Convention => Name,
Aspect_CPU => Expression,
Aspect_Default_Component_Value => Expression,
Aspect_Default_Initial_Condition => Optional_Expression,
Aspect_Default_Iterator => Name,
Aspect_Default_Storage_Pool => Expression,
Aspect_Default_Value => Expression,
Aspect_Depends => Expression,
Aspect_Dimension => Expression,
Aspect_Dimension_System => Expression,
Aspect_Dispatching_Domain => Expression,
Aspect_Dynamic_Predicate => Expression,
Aspect_Extensions_Visible => Optional_Expression,
Aspect_External_Name => Expression,
Aspect_External_Tag => Expression,
Aspect_Ghost => Optional_Expression,
Aspect_Global => Expression,
Aspect_Implicit_Dereference => Name,
Aspect_Initial_Condition => Expression,
Aspect_Initializes => Expression,
Aspect_Input => Name,
Aspect_Interrupt_Priority => Expression,
Aspect_Invariant => Expression,
Aspect_Iterable => Expression,
Aspect_Iterator_Element => Name,
Aspect_Link_Name => Expression,
Aspect_Linker_Section => Expression,
Aspect_Machine_Radix => Expression,
Aspect_Object_Size => Expression,
Aspect_Obsolescent => Optional_Expression,
Aspect_Output => Name,
Aspect_Part_Of => Expression,
Aspect_Post => Expression,
Aspect_Postcondition => Expression,
Aspect_Pre => Expression,
Aspect_Precondition => Expression,
Aspect_Predicate => Expression,
Aspect_Priority => Expression,
Aspect_Read => Name,
Aspect_Refined_Depends => Expression,
Aspect_Refined_Global => Expression,
Aspect_Refined_Post => Expression,
Aspect_Refined_State => Expression,
Aspect_Relative_Deadline => Expression,
Aspect_Scalar_Storage_Order => Expression,
Aspect_Simple_Storage_Pool => Name,
Aspect_Size => Expression,
Aspect_Small => Expression,
Aspect_SPARK_Mode => Optional_Name,
Aspect_Static_Predicate => Expression,
Aspect_Storage_Pool => Name,
Aspect_Storage_Size => Expression,
Aspect_Stream_Size => Expression,
Aspect_Suppress => Name,
Aspect_Synchronization => Name,
Aspect_Test_Case => Expression,
Aspect_Type_Invariant => Expression,
Aspect_Unimplemented => Optional_Expression,
Aspect_Unsuppress => Name,
Aspect_Value_Size => Expression,
Aspect_Variable_Indexing => Name,
Aspect_Warnings => Name,
Aspect_Write => Name,
Boolean_Aspects => Optional_Expression,
Library_Unit_Aspects => Optional_Expression);
-----------------------------------------
-- Table Linking Names and Aspect_Id's --
-----------------------------------------
-- Table linking aspect names and id's
Aspect_Names : constant array (Aspect_Id) of Name_Id :=
(No_Aspect => No_Name,
Aspect_Abstract_State => Name_Abstract_State,
Aspect_Address => Name_Address,
Aspect_Alignment => Name_Alignment,
Aspect_All_Calls_Remote => Name_All_Calls_Remote,
Aspect_Annotate => Name_Annotate,
Aspect_Async_Readers => Name_Async_Readers,
Aspect_Async_Writers => Name_Async_Writers,
Aspect_Asynchronous => Name_Asynchronous,
Aspect_Atomic => Name_Atomic,
Aspect_Atomic_Components => Name_Atomic_Components,
Aspect_Attach_Handler => Name_Attach_Handler,
Aspect_Bit_Order => Name_Bit_Order,
Aspect_Component_Size => Name_Component_Size,
Aspect_Constant_Indexing => Name_Constant_Indexing,
Aspect_Contract_Cases => Name_Contract_Cases,
Aspect_Convention => Name_Convention,
Aspect_CPU => Name_CPU,
Aspect_Default_Component_Value => Name_Default_Component_Value,
Aspect_Default_Initial_Condition => Name_Default_Initial_Condition,
Aspect_Default_Iterator => Name_Default_Iterator,
Aspect_Default_Storage_Pool => Name_Default_Storage_Pool,
Aspect_Default_Value => Name_Default_Value,
Aspect_Depends => Name_Depends,
Aspect_Dimension => Name_Dimension,
Aspect_Dimension_System => Name_Dimension_System,
Aspect_Discard_Names => Name_Discard_Names,
Aspect_Dispatching_Domain => Name_Dispatching_Domain,
Aspect_Dynamic_Predicate => Name_Dynamic_Predicate,
Aspect_Effective_Reads => Name_Effective_Reads,
Aspect_Effective_Writes => Name_Effective_Writes,
Aspect_Elaborate_Body => Name_Elaborate_Body,
Aspect_Export => Name_Export,
Aspect_Extensions_Visible => Name_Extensions_Visible,
Aspect_External_Name => Name_External_Name,
Aspect_External_Tag => Name_External_Tag,
Aspect_Favor_Top_Level => Name_Favor_Top_Level,
Aspect_Ghost => Name_Ghost,
Aspect_Global => Name_Global,
Aspect_Implicit_Dereference => Name_Implicit_Dereference,
Aspect_Import => Name_Import,
Aspect_Independent => Name_Independent,
Aspect_Independent_Components => Name_Independent_Components,
Aspect_Inline => Name_Inline,
Aspect_Inline_Always => Name_Inline_Always,
Aspect_Initial_Condition => Name_Initial_Condition,
Aspect_Initializes => Name_Initializes,
Aspect_Input => Name_Input,
Aspect_Interrupt_Handler => Name_Interrupt_Handler,
Aspect_Interrupt_Priority => Name_Interrupt_Priority,
Aspect_Invariant => Name_Invariant,
Aspect_Iterator_Element => Name_Iterator_Element,
Aspect_Iterable => Name_Iterable,
Aspect_Link_Name => Name_Link_Name,
Aspect_Linker_Section => Name_Linker_Section,
Aspect_Lock_Free => Name_Lock_Free,
Aspect_Machine_Radix => Name_Machine_Radix,
Aspect_No_Elaboration_Code_All => Name_No_Elaboration_Code_All,
Aspect_No_Return => Name_No_Return,
Aspect_No_Tagged_Streams => Name_No_Tagged_Streams,
Aspect_Object_Size => Name_Object_Size,
Aspect_Obsolescent => Name_Obsolescent,
Aspect_Output => Name_Output,
Aspect_Pack => Name_Pack,
Aspect_Part_Of => Name_Part_Of,
Aspect_Persistent_BSS => Name_Persistent_BSS,
Aspect_Post => Name_Post,
Aspect_Postcondition => Name_Postcondition,
Aspect_Pre => Name_Pre,
Aspect_Precondition => Name_Precondition,
Aspect_Predicate => Name_Predicate,
Aspect_Preelaborable_Initialization => Name_Preelaborable_Initialization,
Aspect_Preelaborate => Name_Preelaborate,
Aspect_Priority => Name_Priority,
Aspect_Pure => Name_Pure,
Aspect_Pure_Function => Name_Pure_Function,
Aspect_Read => Name_Read,
Aspect_Refined_Depends => Name_Refined_Depends,
Aspect_Refined_Global => Name_Refined_Global,
Aspect_Refined_Post => Name_Refined_Post,
Aspect_Refined_State => Name_Refined_State,
Aspect_Relative_Deadline => Name_Relative_Deadline,
Aspect_Remote_Access_Type => Name_Remote_Access_Type,
Aspect_Remote_Call_Interface => Name_Remote_Call_Interface,
Aspect_Remote_Types => Name_Remote_Types,
Aspect_Scalar_Storage_Order => Name_Scalar_Storage_Order,
Aspect_Shared => Name_Shared,
Aspect_Shared_Passive => Name_Shared_Passive,
Aspect_Simple_Storage_Pool => Name_Simple_Storage_Pool,
Aspect_Simple_Storage_Pool_Type => Name_Simple_Storage_Pool_Type,
Aspect_Size => Name_Size,
Aspect_Small => Name_Small,
Aspect_SPARK_Mode => Name_SPARK_Mode,
Aspect_Static_Predicate => Name_Static_Predicate,
Aspect_Storage_Pool => Name_Storage_Pool,
Aspect_Storage_Size => Name_Storage_Size,
Aspect_Stream_Size => Name_Stream_Size,
Aspect_Suppress => Name_Suppress,
Aspect_Suppress_Debug_Info => Name_Suppress_Debug_Info,
Aspect_Suppress_Initialization => Name_Suppress_Initialization,
Aspect_Thread_Local_Storage => Name_Thread_Local_Storage,
Aspect_Synchronization => Name_Synchronization,
Aspect_Test_Case => Name_Test_Case,
Aspect_Type_Invariant => Name_Type_Invariant,
Aspect_Unchecked_Union => Name_Unchecked_Union,
Aspect_Unimplemented => Name_Unimplemented,
Aspect_Universal_Aliasing => Name_Universal_Aliasing,
Aspect_Universal_Data => Name_Universal_Data,
Aspect_Unmodified => Name_Unmodified,
Aspect_Unreferenced => Name_Unreferenced,
Aspect_Unreferenced_Objects => Name_Unreferenced_Objects,
Aspect_Unsuppress => Name_Unsuppress,
Aspect_Value_Size => Name_Value_Size,
Aspect_Variable_Indexing => Name_Variable_Indexing,
Aspect_Volatile => Name_Volatile,
Aspect_Volatile_Components => Name_Volatile_Components,
Aspect_Warnings => Name_Warnings,
Aspect_Write => Name_Write);
function Get_Aspect_Id (Name : Name_Id) return Aspect_Id;
pragma Inline (Get_Aspect_Id);
-- Given a name Nam, returns the corresponding aspect id value. If the name
-- does not match any aspect, then No_Aspect is returned as the result.
function Get_Aspect_Id (Aspect : Node_Id) return Aspect_Id;
pragma Inline (Get_Aspect_Id);
-- Given an aspect specification, return the corresponding aspect_id value.
-- If the name does not match any aspect, return No_Aspect.
------------------------------------
-- Delaying Evaluation of Aspects --
------------------------------------
-- The RM requires that all language defined aspects taking an expression
-- delay evaluation of the expression till the freeze point of the entity
-- to which the aspect applies. This allows forward references, and is of
-- use for example in connection with preconditions and postconditions
-- where the requirement of making all references in contracts to local
-- functions be backwards references would be onerous.
-- For consistency, even attributes like Size are delayed, so we can do:
-- type A is range 1 .. 10
-- with Size => Not_Defined_Yet;
-- ..
-- Not_Defined_Yet : constant := 64;
-- Resulting in A having a size of 64, which gets set when A is frozen.
-- Furthermore, we can have a situation like
-- type A is range 1 .. 10
-- with Size => Not_Defined_Yet;
-- ..
-- type B is new A;
-- ..
-- Not_Defined_Yet : constant := 64;
-- where the Size of A is considered to have been previously specified at
-- the point of derivation, even though the actual value of the size is
-- not known yet, and in this example B inherits the size value of 64.
-- Our normal implementation model (prior to Ada 2012) was simply to copy
-- inheritable attributes at the point of derivation. Then any subsequent
-- representation items apply either to the parent type, not affecting the
-- derived type, or to the derived type, not affecting the parent type.
-- To deal with the delayed aspect case, we use two flags. The first is
-- set on the parent type if it has delayed representation aspects. This
-- flag Has_Delayed_Rep_Aspects indicates that if we derive from this type
-- we have to worry about making sure we inherit any delayed aspects. The
-- second flag is set on a derived type: May_Have_Inherited_Rep_Aspects
-- is set if the parent type has Has_Delayed_Rep_Aspects set.
-- When we freeze a derived type, if the May_Have_Inherited_Rep_Aspects
-- flag is set, then we call Freeze.Inherit_Delayed_Rep_Aspects when
-- the derived type is frozen, which deals with the necessary copying of
-- information from the parent type, which must be frozen at that point
-- (since freezing the derived type first freezes the parent type).
-- SPARK 2014 aspects do not follow the general delay mechanism as they
-- act as annotations and cannot modify the attributes of their related
-- constructs. To handle forward references in such aspects, the compiler
-- delays the analysis of their respective pragmas by collecting them in
-- N_Contract nodes. The pragmas are then analyzed at the end of the
-- declarative region which contains the related construct. For details,
-- see routines Analyze_xxx_In_Decl_Part.
-- The following shows which aspects are delayed. There are three cases:
type Delay_Type is
(Always_Delay,
-- This aspect is not a representation aspect that can be inherited and
-- is always delayed, as required by the language definition.
Never_Delay,
-- There are two cases. There are language defined aspects like
-- Convention where the "expression" is simply an uninterpreted
-- identifier, and there is no issue of evaluating it and thus no
-- issue of delaying the evaluation. The second case is implementation
-- defined aspects where we have decided that we don't want to allow
-- delays (and for our own aspects we can do what we like).
Rep_Aspect);
-- These are the cases of representation aspects that are in general
-- delayed, and where there is a potential issue of derived types that
-- inherit delayed representation values.
-- Note: even if this table indicates that an aspect is delayed, we never
-- delay Boolean aspects that have a missing expression (taken as True),
-- or expressions for delayed rep items that consist of an integer literal
-- (most cases of Size etc. in practice), since in these cases we know we
-- can get the value of the expression without delay. Note that we still
-- need to delay Boolean aspects that are specifically set to True:
-- type R is array (0 .. 31) of Boolean
-- with Pack => True;
-- True : constant Boolean := False;
-- This is nonsense, but we need to make it work and result in R not
-- being packed, and if we have something like:
-- type R is array (0 .. 31) of Boolean
-- with Pack => True;
-- RR : R;
-- True : constant Boolean := False;
-- This is illegal because the visibility of True changes after the freeze
-- point, which is not allowed, and we need the delay mechanism to properly
-- diagnose this error.
Aspect_Delay : constant array (Aspect_Id) of Delay_Type :=
(No_Aspect => Always_Delay,
Aspect_Address => Always_Delay,
Aspect_All_Calls_Remote => Always_Delay,
Aspect_Asynchronous => Always_Delay,
Aspect_Attach_Handler => Always_Delay,
Aspect_Constant_Indexing => Always_Delay,
Aspect_CPU => Always_Delay,
Aspect_Default_Iterator => Always_Delay,
Aspect_Default_Storage_Pool => Always_Delay,
Aspect_Default_Value => Always_Delay,
Aspect_Default_Component_Value => Always_Delay,
Aspect_Discard_Names => Always_Delay,
Aspect_Dispatching_Domain => Always_Delay,
Aspect_Dynamic_Predicate => Always_Delay,
Aspect_Elaborate_Body => Always_Delay,
Aspect_Export => Always_Delay,
Aspect_External_Name => Always_Delay,
Aspect_External_Tag => Always_Delay,
Aspect_Favor_Top_Level => Always_Delay,
Aspect_Implicit_Dereference => Always_Delay,
Aspect_Import => Always_Delay,
Aspect_Independent => Always_Delay,
Aspect_Independent_Components => Always_Delay,
Aspect_Inline => Always_Delay,
Aspect_Inline_Always => Always_Delay,
Aspect_Input => Always_Delay,
Aspect_Interrupt_Handler => Always_Delay,
Aspect_Interrupt_Priority => Always_Delay,
Aspect_Invariant => Always_Delay,
Aspect_Iterable => Always_Delay,
Aspect_Iterator_Element => Always_Delay,
Aspect_Link_Name => Always_Delay,
Aspect_Linker_Section => Always_Delay,
Aspect_Lock_Free => Always_Delay,
Aspect_No_Return => Always_Delay,
Aspect_Output => Always_Delay,
Aspect_Persistent_BSS => Always_Delay,
Aspect_Post => Always_Delay,
Aspect_Postcondition => Always_Delay,
Aspect_Pre => Always_Delay,
Aspect_Precondition => Always_Delay,
Aspect_Predicate => Always_Delay,
Aspect_Preelaborable_Initialization => Always_Delay,
Aspect_Preelaborate => Always_Delay,
Aspect_Priority => Always_Delay,
Aspect_Pure => Always_Delay,
Aspect_Pure_Function => Always_Delay,
Aspect_Read => Always_Delay,
Aspect_Relative_Deadline => Always_Delay,
Aspect_Remote_Access_Type => Always_Delay,
Aspect_Remote_Call_Interface => Always_Delay,
Aspect_Remote_Types => Always_Delay,
Aspect_Shared => Always_Delay,
Aspect_Shared_Passive => Always_Delay,
Aspect_Simple_Storage_Pool => Always_Delay,
Aspect_Simple_Storage_Pool_Type => Always_Delay,
Aspect_Static_Predicate => Always_Delay,
Aspect_Storage_Pool => Always_Delay,
Aspect_Stream_Size => Always_Delay,
Aspect_Suppress => Always_Delay,
Aspect_Suppress_Debug_Info => Always_Delay,
Aspect_Suppress_Initialization => Always_Delay,
Aspect_Thread_Local_Storage => Always_Delay,
Aspect_Type_Invariant => Always_Delay,
Aspect_Unchecked_Union => Always_Delay,
Aspect_Universal_Aliasing => Always_Delay,
Aspect_Universal_Data => Always_Delay,
Aspect_Unmodified => Always_Delay,
Aspect_Unreferenced => Always_Delay,
Aspect_Unreferenced_Objects => Always_Delay,
Aspect_Unsuppress => Always_Delay,
Aspect_Variable_Indexing => Always_Delay,
Aspect_Write => Always_Delay,
Aspect_Abstract_State => Never_Delay,
Aspect_Annotate => Never_Delay,
Aspect_Async_Readers => Never_Delay,
Aspect_Async_Writers => Never_Delay,
Aspect_Contract_Cases => Never_Delay,
Aspect_Convention => Never_Delay,
Aspect_Default_Initial_Condition => Never_Delay,
Aspect_Depends => Never_Delay,
Aspect_Dimension => Never_Delay,
Aspect_Dimension_System => Never_Delay,
Aspect_Effective_Reads => Never_Delay,
Aspect_Effective_Writes => Never_Delay,
Aspect_Extensions_Visible => Never_Delay,
Aspect_Ghost => Never_Delay,
Aspect_Global => Never_Delay,
Aspect_Initial_Condition => Never_Delay,
Aspect_Initializes => Never_Delay,
Aspect_No_Elaboration_Code_All => Never_Delay,
Aspect_No_Tagged_Streams => Never_Delay,
Aspect_Obsolescent => Never_Delay,
Aspect_Part_Of => Never_Delay,
Aspect_Refined_Depends => Never_Delay,
Aspect_Refined_Global => Never_Delay,
Aspect_Refined_Post => Never_Delay,
Aspect_Refined_State => Never_Delay,
Aspect_SPARK_Mode => Never_Delay,
Aspect_Synchronization => Never_Delay,
Aspect_Test_Case => Never_Delay,
Aspect_Unimplemented => Never_Delay,
Aspect_Warnings => Never_Delay,
Aspect_Alignment => Rep_Aspect,
Aspect_Atomic => Rep_Aspect,
Aspect_Atomic_Components => Rep_Aspect,
Aspect_Bit_Order => Rep_Aspect,
Aspect_Component_Size => Rep_Aspect,
Aspect_Machine_Radix => Rep_Aspect,
Aspect_Object_Size => Rep_Aspect,
Aspect_Pack => Rep_Aspect,
Aspect_Scalar_Storage_Order => Rep_Aspect,
Aspect_Size => Rep_Aspect,
Aspect_Small => Rep_Aspect,
Aspect_Storage_Size => Rep_Aspect,
Aspect_Value_Size => Rep_Aspect,
Aspect_Volatile => Rep_Aspect,
Aspect_Volatile_Components => Rep_Aspect);
------------------------------------------------
-- Handling of Aspect Specifications on Stubs --
------------------------------------------------
-- Aspects that appear on the following stub nodes
-- N_Package_Body_Stub
-- N_Protected_Body_Stub
-- N_Subprogram_Body_Stub
-- N_Task_Body_Stub
-- are treated as if they apply to the corresponding proper body. Their
-- analysis is postponed until the analysis of the proper body takes place
-- (see Analyze_Proper_Body). The delay is required because the analysis
-- may generate extra code which would be harder to relocate to the body.
-- If the proper body is present, the aspect specifications are relocated
-- to the corresponding body node:
-- N_Package_Body
-- N_Protected_Body
-- N_Subprogram_Body
-- N_Task_Body
-- The subsequent analysis takes care of the aspect-to-pragma conversions
-- and verification of pragma legality. In the case where the proper body
-- is not available, the aspect specifications are analyzed on the spot
-- (see Analyze_Proper_Body) to catch potential errors.
-- The following table lists all aspects that can apply to a subprogram
-- body [stub]. For instance, the following example is legal:
-- package P with SPARK_Mode ...;
-- package body P with SPARK_Mode is ...;
-- The table should be synchronized with Pragma_On_Body_Or_Stub_OK in unit
-- Sem_Prag if the aspects below are implemented by a pragma.
Aspect_On_Body_Or_Stub_OK : constant array (Aspect_Id) of Boolean :=
(Aspect_Refined_Depends => True,
Aspect_Refined_Global => True,
Aspect_Refined_Post => True,
Aspect_SPARK_Mode => True,
Aspect_Warnings => True,
others => False);
---------------------------------------------------
-- Handling of Aspect Specifications in the Tree --
---------------------------------------------------
-- Several kinds of declaration node permit aspect specifications in Ada
-- 2012 mode. If there was room in all the corresponding declaration nodes,
-- we could just have a field Aspect_Specifications pointing to a list of
-- nodes for the aspects (N_Aspect_Specification nodes). But there isn't
-- room, so we adopt a different approach.
-- The following subprograms provide access to a specialized interface
-- implemented internally with a hash table in the body, that provides
-- access to aspect specifications.
function Aspect_Specifications (N : Node_Id) return List_Id;
-- Given a node N, returns the list of N_Aspect_Specification nodes that
-- are attached to this declaration node. If the node is in the class of
-- declaration nodes that permit aspect specifications, as defined by the
-- predicate above, and if their Has_Aspects flag is set to True, then this
-- will always be a non-empty list. If this flag is set to False, then
-- No_List is returned. Normally, the only nodes that have Has_Aspects set
-- True are the nodes for which Permits_Aspect_Specifications would return
-- True (i.e. the declaration nodes defined in the RM as permitting the
-- presence of Aspect_Specifications). However, it is possible for the
-- flag Has_Aspects to be set on other nodes as a result of Rewrite and
-- Replace calls, and this function may be used to retrieve the aspect
-- specifications for the original rewritten node in such cases.
function Aspects_On_Body_Or_Stub_OK (N : Node_Id) return Boolean;
-- N denotes a body [stub] with aspects. Determine whether all aspects of N
-- are allowed to appear on a body [stub].
procedure Exchange_Aspects (N1 : Node_Id; N2 : Node_Id);
-- Exchange the aspect specifications of two nodes. If either node lacks an
-- aspect specification list, the routine has no effect. It is assumed that
-- both nodes can support aspects.
function Find_Aspect (Id : Entity_Id; A : Aspect_Id) return Node_Id;
-- Find the aspect specification of aspect A associated with entity I.
-- Return Empty if Id does not have the requested aspect.
function Find_Value_Of_Aspect
(Id : Entity_Id;
A : Aspect_Id) return Node_Id;
-- Find the value of aspect A associated with entity Id. Return Empty if
-- Id does not have the requested aspect.
function Has_Aspect (Id : Entity_Id; A : Aspect_Id) return Boolean;
-- Determine whether entity Id has aspect A
procedure Move_Aspects (From : Node_Id; To : Node_Id);
-- Relocate the aspect specifications of node From to node To. On entry it
-- is assumed that To does not have aspect specifications. If From has no
-- aspects, the routine has no effect.
procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id);
-- Relocate the aspect specifications of node From to node To. If To has
-- aspects, the aspects of From are added to the aspects of To. If From has
-- no aspects, the routine has no effect. When From denotes a subprogram
-- body stub that also acts as a spec, the only aspects relocated to node
-- To are those from table Aspect_On_Body_Or_Stub_OK and preconditions.
function Permits_Aspect_Specifications (N : Node_Id) return Boolean;
-- Returns True if the node N is a declaration node that permits aspect
-- specifications in the grammar. It is possible for other nodes to have
-- aspect specifications as a result of Rewrite or Replace calls.
procedure Remove_Aspects (N : Node_Id);
-- Delete the aspect specifications associated with node N. If the node has
-- no aspects, the routine has no effect.
function Same_Aspect (A1 : Aspect_Id; A2 : Aspect_Id) return Boolean;
-- Returns True if A1 and A2 are (essentially) the same aspect. This is not
-- a simple equality test because e.g. Post and Postcondition are the same.
-- This is used for detecting duplicate aspects.
procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id);
-- The node N must be in the class of declaration nodes that permit aspect
-- specifications and the Has_Aspects flag must be False on entry. L must
-- be a non-empty list of N_Aspect_Specification nodes. This procedure sets
-- the Has_Aspects flag to True, and makes an entry that can be retrieved
-- by a subsequent Aspect_Specifications call. It is an error to call this
-- procedure with a node that does not permit aspect specifications, or a
-- node that has its Has_Aspects flag set True on entry, or with L being an
-- empty list or No_List.
procedure Tree_Read;
-- Reads contents of Aspect_Specifications hash table from the tree file
procedure Tree_Write;
-- Writes contents of Aspect_Specifications hash table to the tree file
end Aspects;
|
-- MIT License
--
-- Copyright (c) 2021 Glen Cornell <glen.m.cornell@gmail.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 Interfaces.C;
with Sockets.Can_Frame;
package Sockets.Can_Bcm_Thin is
pragma Pure;
type Timeval is record
Tv_Sec : aliased Interfaces.C.Long;
Tv_Usec : aliased Interfaces.C.Long;
end record;
type Opcode_Type is
(TX_SETUP, -- create (cyclic) transmission task
TX_DELETE, -- remove (cyclic) transmission task
TX_READ, -- read properties of (cyclic) transmission task
TX_SEND, -- send one CAN frame
RX_SETUP, -- create RX content filter subscription
RX_DELETE, -- remove RX content filter subscription
RX_READ, -- read properties of RX content filter subscription
TX_STATUS, -- reply to TX_READ request
TX_EXPIRED, -- notification on performed transmissions (count=0)
RX_STATUS, -- reply to RX_READ request
RX_TIMEOUT, -- cyclic message is absent
RX_CHANGED); -- updated CAN frame (detected content change)
type Flag_Type is mod 2 ** 32;
for Flag_Type'Size use 32;
pragma Convention (C, Flag_Type);
-- Possible values (logically OR'ed):
SETTIMER : constant Flag_Type := 16#00000001#;
STARTTIMER : constant Flag_Type := 16#00000002#;
TX_COUNTEVT : constant Flag_Type := 16#00000004#;
TX_ANNOUNCE : constant Flag_Type := 16#00000008#;
TX_CP_CAN_ID : constant Flag_Type := 16#00000010#;
RX_FILTER_ID : constant Flag_Type := 16#00000020#;
RX_CHECK_DLC : constant Flag_Type := 16#00000040#;
RX_NO_AUTOTIMER : constant Flag_Type := 16#00000080#;
RX_ANNOUNCE_RESUME : constant Flag_Type := 16#00000100#;
TX_RESET_MULTI_IDX : constant Flag_Type := 16#00000200#;
RX_RTR_FRAME : constant Flag_Type := 16#00000400#;
CAN_FD_FRAME : constant Flag_Type := 16#00000800#;
type Frame_Count_Type is range 0..256;
for Frame_Count_Type'Size use 32;
pragma Convention (C, Frame_Count_Type);
-- msg_head - head of messages to/from the broadcast manager. Note
-- that this is not exactly the type as seen in linux/can/bcm.h.
-- You must append the message array (with nframes elements) to
-- this header before passing the structure to the kernel.
type Bcm_Msg_Head is record
Opcode : aliased Opcode_Type; -- Opcode
Flags : aliased Flag_Type; -- Special flags, see below.
Count : aliased Frame_Count_Type; -- number of frames to send before changing interval.
Ival1 : aliased Timeval; -- interval for the first "count" frames.
Ival2 : aliased Timeval; -- interval for the following frames.
Can_Id : aliased Sockets.Can_Frame.Can_Id_Type; -- CAN ID of frames to be sent or received.
Nframes : aliased Frame_Count_Type; -- Number of frames to be sent or received.
end record;
type Frame_Array_Type is array
(Frame_Count_Type range <>) of
aliased Sockets.Can_Frame.Can_Frame;
private
pragma Convention (C_Pass_By_Copy, Timeval);
pragma Convention (C, Opcode_Type);
pragma Convention (C, Frame_Array_Type);
pragma Convention (C_Pass_By_Copy, Bcm_Msg_Head);
for Opcode_Type use
(TX_SETUP => 1,
TX_DELETE => 2,
TX_READ => 3,
TX_SEND => 4,
RX_SETUP => 5,
RX_DELETE => 6,
RX_READ => 7,
TX_STATUS => 8,
TX_EXPIRED => 9,
RX_STATUS => 10,
RX_TIMEOUT => 11,
RX_CHANGED => 12);
end Sockets.Can_Bcm_Thin;
|
with Ada.Text_IO; use Ada.Text_IO;
with GL.Types;
-- with Utilities;
with C3GA;
with GA_Draw;
with GA_Maths;
-- with GA_Utilities;
with Plane;
package body C3GA_Draw is
use GA_Draw;
procedure Draw_C3GA (Render_Program : GL.Objects.Programs.Program;
Analyzed_MV : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet);
procedure Draw_Flat (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet);
procedure Draw_Free (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet);
procedure Draw_Round (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet);
-- -------------------------------------------------------------------------
procedure Draw (Render_Program : GL.Objects.Programs.Program;
MV : Multivectors.Multivector;
Palet_Type : Palet.Colour_Palet := Palet.Is_Null) is
-- Method : GA_Draw.Method_Type :=
-- GA_Draw.Draw_Method_Undefined) is
Analyzed_MV : Multivector_Analyze.MV_Analysis;
begin
Analyzed_MV := Multivector_Analyze.Analyze (MV, C3GA.no);
-- Multivector_Analyze.Print_Analysis_M_Vectors
-- ("C3GA_Draw.Draw, Analyzed_MV.M_Vectors", Analyzed_MV);
-- M_Vectors agrees with C++: -1.00E+00 * e1 -1.00E+00 * e2 1.00E+00 * e3
Draw_C3GA (Render_Program, Analyzed_MV, Palet_Type);
exception
when others =>
Put_Line ("An exception occurred in C3GA_Draw.Draw MV.");
raise;
end Draw;
-- -------------------------------------------------------------------------
-- procedure Draw (Render_Program : GL.Objects.Programs.Program;
-- Model_View_Matrix : GL.Types.Singles.Matrix4;
-- aVector : C3GA.Vector_E3; Colour : GL.Types.Colors.Color) is
-- use Multivectors;
-- Vec_3D : constant Vector := New_Vector (C3GA.Get_Coord_1 (aVector),
-- C3GA.Get_Coord_2 (aVector), 0.0);
-- Tail : constant Vector := New_Vector (0.0, 0.0, 0.0);
-- begin
-- GA_Draw.Draw_Vector (Render_Program, Model_View_Matrix,
-- Tail, Vec_3D, Colour);
--
-- exception
-- when others =>
-- Put_Line ("An exception occurred in C3GA_Draw.Draw vector.");
-- raise;
-- end Draw;
-- -------------------------------------------------------------------------
procedure Draw_C3GA (Render_Program : GL.Objects.Programs.Program;
Analyzed_MV : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet) is
use Multivector_Analyze;
begin
if Analyzed_MV.M_Type.Model_Kind = Conformal_Model then
case Analyzed_MV.M_Type.Blade_Class is
when Flat_Blade =>
Put_Line ("C3GA_Draw.Draw_C3GA Flat.");
-- Draw_Flat doesn't use method
Draw_Flat (Render_Program, Analyzed_MV, Palet_Type);
when Free_Blade =>
Put_Line ("C3GA_Draw.Draw_C3GA Free.");
Draw_Free (Render_Program, Analyzed_MV, Palet_Type);
when Round_Blade =>
Put_Line ("C3GA_Draw.Draw_C3GA Round.");
-- Draw_Round doesn't use method
Draw_Round (Render_Program, Analyzed_MV, Palet_Type);
when Tangent_Blade =>
Put_Line ("C3GA_Draw.Draw_C3GA Tangent.");
when others =>
Put_Line ("C3GA_Draw.Draw_C3GA Others.");
null;
end case;
else
Put_Line ("C3GA_Draw.Draw_C3GA only processes conformal models.");
end if;
exception
when others =>
Put_Line ("An exception occurred in C3GA_Draw.Draw_C3GA.");
raise;
end Draw_C3GA;
-- -------------------------------------------------------------------------
procedure Draw_Flat (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet) is
use Multivector_Analyze;
Point_Pos : constant C3GA.Vector_E3 :=
C3GA.To_VectorE3GA (Analysis.Points (1));
M_Vector_1 : constant C3GA.Vector_E3 :=
C3GA.To_VectorE3GA (Analysis.M_Vectors (1));
M_Vector_2 : constant C3GA.Vector_E3 :=
C3GA.To_VectorE3GA (Analysis.M_Vectors (2));
M_Vector_3 : constant C3GA.Vector_E3 :=
C3GA.To_VectorE3GA (Analysis.M_Vectors (3));
Scale : Float := Analysis.Weight;
begin
case Analysis.M_Type.Blade_Subclass is
when Line_Subclass =>
Put_Line ("C3GA_Draw.Draw_Flat Line.");
-- Draw_Line doesn't use method
GA_Draw.Draw_Line (Render_Program, M_Vector_1, Scale);
when Plane_Subclass =>
Put_Line ("C3GA_Draw.Draw_Flat Plane.");
-- Draw_Plane doesn't use method
Plane.Draw_Plane (Render_Program, Point_Pos, M_Vector_1, M_Vector_2,
M_Vector_3, Scale);
when Point_Subclass =>
Put_Line ("C3GA_Draw.Draw_Flat Point.");
Scale := 4.0 / 3.0 * GA_Maths.PI * Palet.Point_Size ** 3;
GA_Draw.Draw_Trivector (Render_Program, Point_Pos,
Scale, Palet_Type);
when others => null;
end case;
exception
when others =>
Put_Line ("An exception occurred in C3GA_Draw.Draw_Flat.");
raise;
end Draw_Flat;
-- -------------------------------------------------------------------------
procedure Draw_Free (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet) is
use GA_Maths.Float_Functions;
use Multivector_Analyze;
use C3GA;
Tail : constant Vector_E3 := (0.0, 0.0, 0.0);
BV_Scale : float := 1.0;
begin
case Analysis.M_Type.Blade_Subclass is
when Vector_Subclass =>
Put_Line ("C3GA_Draw.Draw_Free Vector.");
GA_Draw.Draw_Vector (Render_Program, Tail,
To_VectorE3GA (Analysis.M_Vectors (1)),
Analysis.Weight);
when Bivector_Subclass =>
Put_Line ("C3GA_Draw.Draw_Free Bivector.");
BV_Scale := Sqrt (Analysis.Weight / GA_Maths.Pi);
GA_Draw.Draw_Bivector (Render_Program => Render_Program,
Base => Tail,
Normal => To_VectorE3GA (Analysis.M_Vectors (3)),
Ortho_1 => To_VectorE3GA (Analysis.M_Vectors (1)),
Ortho_2 => To_VectorE3GA (Analysis.M_Vectors (2)),
Palet_Type => Palet_Type,
Scale => BV_Scale,
Method => GA_Draw.Draw_Bivector_Circle);
when Trivector_Subclass =>
Put_Line ("C3GA_Draw.Draw_Free Trivector.");
GA_Draw.Draw_Trivector (Render_Program => Render_Program,
Base => Tail,
Scale => Analysis.Weight,
V => Analysis.M_Vectors);
when others => null;
end case;
exception
when others =>
Put_Line ("An exception occurred in C3GA_Draw.Draw_Free.");
raise;
end Draw_Free;
-- -------------------------------------------------------------------------
-- Based on c3ga_draw.drawFlat A.bladeSubclass() == mvAnalysis::POINT
-- procedure Draw_Line (Render_Program : GL.Objects.Programs.Program;
-- Model_View_Matrix : GL.Types.Singles.Matrix4;
-- L : Multivectors.Vector;
-- Colour : GL.Types.Colors.Color) is
-- Scale : constant Float := 4.0 / 3.0 * GA_Maths.PI * Palet.Point_Size ** 3;
-- V : C3GA.Vector_E3;
-- begin
-- GA_Draw.Draw_Trivector (Render_Program, Model_View_Matrix,
-- C3GA.To_VectorE3GA (L), Scale, V, Colour);
--
-- exception
-- when others =>
-- Put_Line ("An exception occurred in C3GA_Draw.Draw_Line.");
-- raise;
-- end Draw_Line;
-- -------------------------------------------------------------------------
-- Based on c3ga_draw.drawFlat A.bladeSubclass() == mvAnalysis::POINT
procedure Draw_Point (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet := Palet.Is_Null) is
Scale : constant Float := 4.0 / 3.0 * GA_Maths.PI * Palet.Point_Size ** 3;
begin
GA_Draw.Draw_Trivector (Render_Program => Render_Program,
Base => Analysis.Points (1),
Scale => Scale,
Palet_Type => Palet_Type,
Method => GA_Draw.Draw_TV_Sphere);
exception
when others =>
Put_Line ("An exception occurred in C3GA_Draw.Draw_Point.");
raise;
end Draw_Point;
-- -------------------------------------------------------------------------
procedure Draw_Round (Render_Program : GL.Objects.Programs.Program;
Analysis : Multivector_Analyze.MV_Analysis;
Palet_Type : Palet.Colour_Palet) is
use GL.Types;
use GL.Types.Singles;
use Multivector_Analyze;
use C3GA;
Point_Pos : constant Vector_E3 := Analysis.Points (1);
Radius : constant Float := Analysis.Radius;
-- Weight : Float := Analysis.Scalars (2);
P_Scale : Float;
M_Vectors : constant E3_Vector_Array := Analysis.M_Vectors;
M_Vec1 : constant Vector_E3 := To_VectorE3GA (M_Vectors (1));
M_Vec2 : constant Vector_E3 := To_VectorE3GA (M_Vectors (2));
M_Vec3 : constant Vector_E3 := To_VectorE3GA (M_Vectors (3));
begin
case Analysis.M_Type.Blade_Subclass is
when Point_Pair_Subclass =>
Put_Line ("C3GA_Draw.Draw_Round Point Pair.");
Palet.Set_Draw_Mode_Off (Palet.OD_Orientation);
P_Scale := 4.0 / 3.0 * GA_Maths.PI * (Palet.Point_Size ** 3);
GA_Draw.Draw_Trivector (Render_Program, Point_Pos + Radius * M_Vec1,
P_Scale, Palet_Type,
GA_Draw.Draw_TV_Sphere);
GA_Draw.Draw_Trivector (Render_Program, Point_Pos - Radius * M_Vec1,
P_Scale, Palet_Type,
GA_Draw.Draw_TV_Sphere);
when Circle_Subclass =>
Put_Line ("C3GA_Draw.Draw_Round Circle.");
GA_Draw.Draw_Bivector (Render_Program => Render_Program,
Base => Point_Pos,
Normal => M_Vec3,
Ortho_1 => M_Vec1,
Ortho_2 => M_Vec2,
Palet_Type => Palet_Type,
Scale => Radius,
Method =>
GA_Draw.Draw_Bivector_Circle_Outline);
when Sphere_Subclass =>
Put_Line ("C3GA_Draw.Draw_Round Sphere.");
P_Scale := 4.0 / 3.0 * GA_Maths.PI * Radius ** 3;
GA_Draw.Draw_Trivector
(Render_Program, Point_Pos, P_Scale, Palet_Type,
GA_Draw.Draw_TV_Sphere);
when others =>
Put_Line
("C3GA_Draw.Draw_Round, unprocessed Blade_Subclass: " &
Blade_Subclass_Type'Image (Analysis.M_Type.Blade_Subclass) &
" " & Integer'Image
(Blade_Subclass_Type'Enum_Rep (Analysis.M_Type.Blade_Subclass)));
end case;
exception
when others =>
Put_Line ("An exception occurred in C3GA_Draw.Draw_Round.");
raise;
end Draw_Round;
-- -------------------------------------------------------------------------
end C3GA_Draw;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . U T I L I T I E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- 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. 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides RTS Internal Declarations.
-- These declarations are not part of the GNARLI
with Ada.Unchecked_Conversion;
with System.Task_Primitives;
package System.Tasking.Utilities is
function ATCB_To_Address is new
Ada.Unchecked_Conversion (Task_Id, System.Task_Primitives.Task_Address);
---------------------------------
-- Task_Stage Related routines --
---------------------------------
function Make_Independent return Boolean;
-- Move the current task to the outermost level (level 2) of the master
-- hierarchy of the environment task. That is one level further out
-- than normal tasks defined in library-level packages (level 3). The
-- environment task will wait for level 3 tasks to terminate normally,
-- then it will abort all the level 2 tasks. See Finalize_Global_Tasks
-- procedure for more information.
--
-- This is a dangerous operation, and should never be used on nested tasks
-- or tasks that depend on any objects that might be finalized earlier than
-- the termination of the environment task. It is for internal use by the
-- GNARL, to prevent such internal server tasks from preventing a partition
-- from terminating.
--
-- Also note that the run time assumes that the parent of an independent
-- task is the environment task. If this is not the case, Make_Independent
-- will change the task's parent. This assumption is particularly
-- important for master level completion and for the computation of
-- Independent_Task_Count.
--
-- NOTE WELL: Make_Independent should be called before the task reaches its
-- "begin", like this:
--
-- task body Some_Independent_Task is
-- ...
-- Ignore : constant Boolean := Make_Independent;
-- ...
-- begin
--
-- The return value is meaningless; the only reason this is a function is
-- to get around the Ada limitation that makes a procedure call
-- syntactically illegal before the "begin".
--
-- Calling it before "begin" ensures that the call completes before the
-- activating task can proceed. This is important for preventing race
-- conditions. For example, if the environment task reaches
-- Finalize_Global_Tasks before some task has finished Make_Independent,
-- the program can hang.
--
-- Note also that if a package declares independent tasks, it should not
-- initialize its package-body data after "begin" of the package, because
-- that's where the tasks are activated. Initializing such data before the
-- task activation helps prevent the tasks from accessing uninitialized
-- data.
Independent_Task_Count : Natural := 0;
-- Number of independent tasks. This counter is incremented each time
-- Make_Independent is called. Note that if a server task terminates,
-- this counter will not be decremented. Since Make_Independent locks
-- the environment task (because every independent task depends on it),
-- this counter is protected by the environment task's lock.
---------------------------------
-- Task Abort Related Routines --
---------------------------------
procedure Cancel_Queued_Entry_Calls (T : Task_Id);
-- Cancel any entry calls queued on target task.
-- Call this while holding T's lock (or RTS_Lock in Single_Lock mode).
procedure Exit_One_ATC_Level (Self_ID : Task_Id);
pragma Inline (Exit_One_ATC_Level);
-- Call only with abort deferred and holding lock of Self_ID.
-- This is a bit of common code for all entry calls.
-- The effect is to exit one level of ATC nesting.
procedure Abort_One_Task (Self_ID : Task_Id; T : Task_Id);
-- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but:
-- (1) caller should be holding no locks
-- (2) may be called for tasks that have not yet been activated
-- (3) always aborts whole task
procedure Abort_Tasks (Tasks : Task_List);
-- Abort_Tasks is called to initiate abort, however, the actual
-- aborting is done by aborted task by means of Abort_Handler
procedure Make_Passive (Self_ID : Task_Id; Task_Completed : Boolean);
-- Update counts to indicate current task is either terminated or
-- accepting on a terminate alternative. Call holding no locks except
-- Global_Task_Lock when calling from Terminate_Task, and RTS_Lock when
-- Single_Lock is True.
end System.Tasking.Utilities;
|
-----------------------------------------------------------------------
--
-- simple XML Parser using glib & utilities
--
-----------------------------------------------------------------------
with Glib.Xml_Int; use Glib.Xml_Int;
pragma Elaborate_All (Glib.Xml_Int);
package Gate3_Glib is
-- utility functions
function To_Ada (S : String; Separator : Character := '_') return String;
-- Convert S by adding a separator before each upper case character.
-- Also put in upper case each character following a separator.
function Find_Top_Object (N : Node_Ptr) return Node_Ptr;
-- Find a node in the ancestors of N that represents a root object.
end Gate3_Glib;
|
with Ada.Containers.Vectors;
with GNATCOLL.Projects;
package Rejuvenation.Factory is
-- This Factory is for backwards compatibility / advanced usage only
-- Please use Rejuvenation.Simple_Factory
-- Methods to create AST instances from fragments of Ada source code.
--
-- The return type of these methods is Analysis_Unit; the AST node can
-- be obtained using .Root .
--
-- The return type is Analysis_Unit, because AST nodes are only valid as
-- long as the corresponding Analysis_Unit is in scope.
-- Project methods --------
type Project_Context is private;
-- A Project_Context that can be used to open files within a GPR project.
function Create_Context return Project_Context;
-- Create an empty Project_Context, not associated with any GPR project file.
function Open_Project (Project_Path : String) return Project_Context;
-- Return a Project_Context for reference resolving within a GPR project.
-- Core methods --------
Parse_Exception : exception;
-- Exception that indicates that a string could not be parsed.
function Open_File
(Filename : String; Context : Project_Context := Create_Context)
return Analysis_Unit;
-- Return AST for the given Ada file.
-- Optionally a project-specific Analysis_Context can be specified.
package Analysis_Unit_Vectors is new Ada.Containers.Vectors
(Positive, Analysis_Unit);
-- Data type for list of analysis units.
function Open_Files_From_Project
(Context : Project_Context; Recursive : Boolean := True)
return Analysis_Unit_Vectors.Vector;
-- Return ASTs for all Ada files in a GPR project and
-- recursively include projects not built separately.
function Is_Ada_File_Built_By_Project
(Filename : String; Context : Project_Context;
Recursive : Boolean := True) return Boolean;
-- Check whether a file is an Ada file built by a project.
function Is_Project_Main_Program
(Node : Ada_Node'Class; Context : Project_Context) return Boolean;
-- Check whether a node is a main program of a project.
private
type Project_Context is record
Environment : GNATCOLL.Projects.Project_Environment_Access := null;
Project_Tree : GNATCOLL.Projects.Project_Tree_Access :=
new GNATCOLL.Projects.Project_Tree;
Provider : Unit_Provider_Reference := No_Unit_Provider_Reference;
Context : Analysis_Context := No_Analysis_Context;
end record;
end Rejuvenation.Factory;
|
-- Institution: Technische Universitaet Muenchen
-- Department: Real-Time Computer Systems (RCS)
-- Project: StratoX
-- Authors: Martin Becker (becker@rcs.ei.tum.de)
with Interfaces; use Interfaces;
with HIL.NVRAM; use HIL.NVRAM;
with HIL; use HIL;
with Buildinfo; use Buildinfo;
with Ada.Unchecked_Conversion;
with Fletcher16;
package body NVRAM with SPARK_Mode => On,
Refined_State => (Memory_State => null)
is
use type HIL.NVRAM.Address;
----------------------------------
-- instantiate generic Fletcher16
----------------------------------
function "+" (Left : HIL.Byte; Right : Character) return HIL.Byte;
-- provide add function for checksumming characters
function "+" (Left : HIL.Byte; Right : Character) return HIL.Byte is
val : constant Integer := Character'Pos (Right);
rbyte : constant HIL.Byte := HIL.Byte (val);
begin
return Left + rbyte;
end "+";
-- instantiation of checksum
package Fletcher16_String is new Fletcher16 (Index_Type => Positive,
Element_Type => Character,
Array_Type => String);
----------------------------------
-- Types
----------------------------------
-- the header in NVRAM is a checksum, which
-- depends on build date/time
type NVRAM_Header is
record
ck_a : HIL.Byte := 0;
ck_b : HIL.Byte := 0;
end record;
for NVRAM_Header use
record
ck_a at 0 range 0 .. 7;
ck_b at 1 range 0 .. 7;
end record;
-- GNATprove from SPARK 2016 GPL doesn't implement attribute Position, yet
HDR_OFF_CK_A : constant HIL.NVRAM.Address := 0;
HDR_OFF_CK_B : constant HIL.NVRAM.Address := 1;
for NVRAM_Header'Size use 16;
----------------------------------
-- body specs
----------------------------------
function Var_To_Address (var : in Variable_Name) return HIL.NVRAM.Address;
-- get address of variable in RAM
-- no need for postcondition.
function Hdr_To_Address return HIL.NVRAM.Address;
-- get address of header in RAM
-- no need for postcondition.
function Get_Default (var : in Variable_Name) return HIL.Byte;
-- read default value of variable
procedure Make_Header (newhdr : out NVRAM_Header);
-- generate a new header for this build
procedure Write_Header (hdr : in NVRAM_Header);
-- write a header to RAM
procedure Read_Header (framhdr : out NVRAM_Header);
-- read header from RAM.
procedure Clear_Contents;
-- set all variables in NVRAM to their default
procedure Validate_Contents;
-- check whether the entries in NVRAM are valid for the current
-- compilation version of this program. if not, set all of them
-- to their defaults (we cannot defer this, since the program could
-- reset at any point in time).
----------------------------------
-- Bodies
----------------------------------
function Hdr_To_Address return HIL.NVRAM.Address is (0);
-- header's address is fixed at beginning of NVRAM
-----------------
-- Make_Header
-----------------
procedure Make_Header (newhdr : out NVRAM_Header) is
build_date : constant String := Short_Datetime;
crc : constant Fletcher16_String.Checksum_Type :=
Fletcher16_String.Checksum (build_date);
begin
newhdr := (ck_a => crc.ck_a, ck_b => crc.ck_b);
end Make_Header;
------------------
-- Write_Header
------------------
procedure Write_Header (hdr : in NVRAM_Header) is
Unused_Header : NVRAM_Header;
-- GNATprove from SPARK 2017 onwards can do this:
-- HDR_OFF_CK_A : constant HIL.NVRAM.Address :=
-- Unused_Header.ck_a'Position;
-- HDR_OFF_CK_B : constant HIL.NVRAM.Address :=
-- Unused_Header.ck_b'Position;
begin
HIL.NVRAM.Write_Byte
(addr => Hdr_To_Address + HDR_OFF_CK_A, byte => hdr.ck_a);
HIL.NVRAM.Write_Byte
(addr => Hdr_To_Address + HDR_OFF_CK_B, byte => hdr.ck_b);
end Write_Header;
-----------------
-- Read_Header
-----------------
procedure Read_Header (framhdr : out NVRAM_Header) is
Unused_Header : NVRAM_Header;
-- GNATprove from SPARK 2017 onwards can do this:
-- HDR_OFF_CK_A : constant HIL.NVRAM.Address :=
-- Unused_Header.ck_a'Position;
-- HDR_OFF_CK_B : constant HIL.NVRAM.Address :=
-- Unused_Header.ck_b'Position;
begin
HIL.NVRAM.Read_Byte
(addr => Hdr_To_Address + HDR_OFF_CK_A, byte => framhdr.ck_a);
HIL.NVRAM.Read_Byte
(addr => Hdr_To_Address + HDR_OFF_CK_B, byte => framhdr.ck_b);
end Read_Header;
-----------------
-- Get_Default
-----------------
function Get_Default (var : in Variable_Name) return HIL.Byte
is (Variable_Defaults (var));
--------------------
-- Clear_Contents
--------------------
procedure Clear_Contents is
begin
for V in Variable_Name'Range loop
declare
defaultval : constant HIL.Byte := Get_Default (V);
begin
Store (variable => V, data => defaultval);
end;
end loop;
end Clear_Contents;
-----------------------
-- Validate_Contents
-----------------------
procedure Validate_Contents is
hdr_fram : NVRAM_Header;
hdr_this : NVRAM_Header;
same_header : Boolean;
begin
Read_Header (hdr_fram);
Make_Header (hdr_this);
same_header := hdr_fram = hdr_this;
if not same_header then
Clear_Contents;
Write_Header (hdr_this);
end if;
end Validate_Contents;
---------------------
-- Var_To_Address
---------------------
function Var_To_Address (var : in Variable_Name) return HIL.NVRAM.Address
is (HIL.NVRAM.Address ((NVRAM_Header'Size + 7) / 8) -- ceiling bit -> bytes
+ Variable_Name'Pos (var));
------------
-- Init
------------
procedure Init is
num_boots : HIL.Byte;
begin
HIL.NVRAM.Init;
Validate_Contents;
-- maintain boot counter: FIXME: for some unknown reason this
-- isn't reliable. Does the FRAM fail sometimes?
Load (VAR_BOOTCOUNTER, num_boots);
if num_boots < HIL.Byte'Last then
num_boots := num_boots + 1;
Store (VAR_BOOTCOUNTER, num_boots);
end if;
end Init;
----------------
-- Self_Check
----------------
procedure Self_Check (Status : out Boolean) is
begin
HIL.NVRAM.Self_Check (Status);
end Self_Check;
--------------
-- Load
--------------
procedure Load (variable : Variable_Name; data : out HIL.Byte) is
begin
HIL.NVRAM.Read_Byte (addr => Var_To_Address (variable), byte => data);
end Load;
procedure Load (variable : Variable_Name; data : out Integer_8) is
tmp : HIL.Byte;
function Byte_To_Int8 is new
Ada.Unchecked_Conversion (HIL.Byte, Integer_8);
begin
HIL.NVRAM.Read_Byte (addr => Var_To_Address (variable), byte => tmp);
data := Byte_To_Int8 (tmp);
end Load;
procedure Load (variable : in Variable_Name; data : out Float) is
bytes : Byte_Array_4 := (others => 0);
-- needs init, because SPARK cannot prove via call
begin
for index in Natural range 0 .. 3 loop
HIL.NVRAM.Read_Byte
(addr => Var_To_Address
(Variable_Name'Val (Variable_Name'Pos (variable) + index)),
byte => bytes (bytes'First + index));
end loop;
data := HIL.toFloat (bytes);
end Load;
procedure Load (variable : in Variable_Name; data : out Unsigned_32) is
bytes : Byte_Array_4 := (others => 0);
-- needs init, because SPARK cannot prove via call
begin
for index in Natural range 0 .. 3 loop
HIL.NVRAM.Read_Byte
(addr => Var_To_Address
(Variable_Name'Val (Variable_Name'Pos (variable) + index)),
byte => bytes (bytes'First + index));
end loop;
data := HIL.Bytes_To_Unsigned32 (bytes);
end Load;
------------
-- Store
------------
procedure Store (variable : Variable_Name; data : in HIL.Byte) is
begin
HIL.NVRAM.Write_Byte (addr => Var_To_Address (variable), byte => data);
end Store;
procedure Store (variable : in Variable_Name; data : in Integer_8) is
function Int8_To_Byte is new
Ada.Unchecked_Conversion (Integer_8, HIL.Byte);
begin
HIL.NVRAM.Write_Byte
(addr => Var_To_Address (variable), byte => Int8_To_Byte (data));
end Store;
procedure Store (variable : in Variable_Name; data : in Float) is
bytes : constant Byte_Array_4 := HIL.toBytes (data);
begin
for index in Natural range 0 .. 3 loop
HIL.NVRAM.Write_Byte
(addr => Var_To_Address
(Variable_Name'Val (Variable_Name'Pos (variable) + index)),
byte => bytes (bytes'First + index));
end loop;
end Store;
procedure Store (variable : in Variable_Name; data : in Unsigned_32) is
bytes : constant Byte_Array_4 := HIL.Unsigned32_To_Bytes (data);
begin
for index in Natural range 0 .. 3 loop
HIL.NVRAM.Write_Byte
(addr => Var_To_Address
(Variable_Name'Val (Variable_Name'Pos (variable) + index)),
byte => bytes (bytes'First + index));
end loop;
end Store;
------------
-- Reset
------------
procedure Reset is
hdr_this : NVRAM_Header;
begin
Make_Header (hdr_this);
Clear_Contents;
Write_Header (hdr_this);
end Reset;
end NVRAM;
|
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A009 is
use Ada.Integer_Text_IO;
B : Float;
A, C, Product : Integer;
begin
A := 1;
loop
B := (5.0E+5 - (1.0E+3 * Float (A))) / (1.0E+3 - Float (A));
if (B - Float (Integer (B))) = 0.0 and B > Float (A) then
C := Integer (1000.0 - Float (A) - B);
if B < Float (C) then
Product := Integer (Float (A) * B * Float (C));
exit;
end if;
end if;
A := A + 1;
if A = 1000 then
A := A + 1;
end if;
end loop;
Put (Product, Width => 0);
end A009;
|
-----------------------------------------------------------------------
-- hestia-display-scheduler -- Display scheduler
-- Copyright (C) 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 HAL.Bitmap;
with HAL.Touch_Panel;
with Ada.Real_Time;
with Net;
with UI.Displays;
with Hestia.Ports;
with Hestia.Scheduler;
package Hestia.Display.Scheduler is
type Display_Type is limited new UI.Displays.Display_Type with private;
-- Draw the layout presentation frame.
overriding
procedure On_Restore (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class);
-- Refresh the current display.
overriding
procedure On_Refresh (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Deadline : out Ada.Real_Time.Time);
-- Handle touch events on the display.
overriding
procedure On_Touch (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
States : in HAL.Touch_Panel.TP_State);
-- Set the zone for the schedule.
procedure Set_Zone (Display : in out Display_Type;
Port : in Ports.Zone_Type);
private
subtype Day_Time is Hestia.Scheduler.Day_Time;
type Display_Type is limited new UI.Displays.Display_Type with record
Back_Button : UI.Buttons.Button_Type;
Slide_Button : UI.Buttons.Button_Type;
Schedule_Area : UI.Buttons.Button_Type;
Deadline : Ada.Real_Time.Time;
Last_Touch : Ada.Real_Time.Time;
Touch_Disable : Boolean := True;
Last_State : Hestia.Scheduler.State_Type := Hestia.Scheduler.OFF;
Port : Ports.Zone_Type := 1;
Start_Time : Hestia.Scheduler.Day_Time;
End_Time : Hestia.Scheduler.Day_Time;
Delta_Time : Integer;
Width : Natural;
end record;
function Get_X (Display : in Display_Type;
Date : in Hestia.Scheduler.Day_Time) return Natural;
function Get_Time (Display : in Display_Type;
X : in Natural) return Day_Time;
end Hestia.Display.Scheduler;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
package snd4ada_hpp is
procedure termSnds; -- snd4ada.hpp:5
pragma Import (CPP, termSnds, "_Z8termSndsv");
function initLoop (pc : Interfaces.C.Strings.chars_ptr; vol : int) return int; -- snd4ada.hpp:7
pragma Import (CPP, initLoop, "_Z8initLoopPKci");
procedure initSnds; -- snd4ada.hpp:9
pragma Import (CPP, initSnds, "_Z8initSndsv");
function initSnd (pc : Interfaces.C.Strings.chars_ptr; vol : int) return int; -- snd4ada.hpp:11
pragma Import (CPP, initSnd, "_Z7initSndPKci");
procedure stopLoop (nbuf : int); -- snd4ada.hpp:13
pragma Import (CPP, stopLoop, "_Z8stopLoopi");
procedure stopLoops; -- snd4ada.hpp:15
pragma Import (CPP, stopLoops, "_Z9stopLoopsv");
procedure playLoop (nbuf : int); -- snd4ada.hpp:17
pragma Import (CPP, playLoop, "_Z8playLoopi");
procedure playSnd (nbuf : int); -- snd4ada.hpp:19
pragma Import (CPP, playSnd, "_Z7playSndi");
end snd4ada_hpp;
|
pragma Ada_2012;
with Protypo.Code_Trees.Interpreter;
with Protypo.Scanning;
with Protypo.Parsing;
with Ada.Directories;
pragma Warnings (Off, "no entities of ""Ada.Text_IO"" are referenced");
with Ada.Text_IO; use Ada.Text_IO;
with Protypo.Api.Consumers.File_Writer;
package body Protypo.API.Interpreters is
procedure Define (Interpreter : in out Interpreter_Type;
Name : ID;
Value : Engine_Values.Engine_Value)
is
begin
Interpreter.Symbol_Table.Create (Name => Name,
Initial_Value => Value);
end Define;
---------
-- Run --
---------
procedure Run (Interpreter : in out Interpreter_Type;
Program : Compiled_Code;
Consumer : Consumers.Consumer_Access)
is
begin
Code_Trees.Interpreter.Run (Program => Program.Code,
Symbol_Table => Interpreter.Symbol_Table,
Consumer => Consumer);
end Run;
---------
-- Run --
---------
procedure Run (Interpreter : in out Interpreter_Type;
Program : Template_Type;
Consumer : Consumers.Consumer_Access)
is
begin
Run (Program => Compile (Program),
Interpreter => Interpreter,
Consumer => Consumer);
end Run;
---------------------
-- Expand_Template --
---------------------
procedure Expand_Template (Interpreter : in out Interpreter_Type;
Input_Filename : String;
Target_Filenane : String)
is
use Consumers.File_Writer;
Cons : Consumers.Consumer_Access;
Template : constant Template_Type := Slurp (Input_Filename);
begin
Cons := Open (if Target_Filenane = "-"
then
Consumers.File_Writer.Standard_Output_Special_Name
else
Target_Filenane);
Run (Interpreter => Interpreter,
Program => Template,
Consumer => Cons);
end Expand_Template;
----------
-- Dump --
----------
procedure Dump (X : Compiled_Code)
is
begin
Code_Trees.Dump (X.Code);
end Dump;
---------
-- Bye --
---------
procedure Bye (X : in out Compiled_Code)
is
begin
Code_Trees.Delete (X.Code);
end Bye;
-------------
-- Compile --
-------------
function Compile (Program : Template_Type;
Base_Dir : String := "") return Compiled_Code is
Tokens : Scanning.Token_List :=
Scanning.Tokenize (Template => Program,
Base_Dir => (if Base_Dir /= "" then
Base_Dir
else
Ada.Directories.Current_Directory));
begin
return Compiled_Code'(Code => Parsing.Parse_Statement_Sequence (Tokens));
end Compile;
-------------
-- Compile --
-------------
procedure Compile (Target : out Compiled_Code;
Program : Template_Type;
Base_Dir : String := "")
is
Tokens : Scanning.Token_List :=
Scanning.Tokenize (Template => Program,
Base_Dir => (if Base_Dir /= "" then
Base_Dir
else
Ada.Directories.Current_Directory));
begin
Target.Code := Parsing.Parse_Statement_Sequence (Tokens);
end Compile;
-- --------------
-- -- Finalize --
-- --------------
--
-- overriding procedure Finalize (Object : in out Compiled_Code) is
-- begin
-- -- Put_Line ("Finalizing compiled code");
-- -- pragma Compile_Time_Warning (True, "Compiled code finalization disabled");
-- Code_Trees.Delete (Object.Code);
--
-- -- Put_Line ("Done");
-- end Finalize;
end Protypo.API.Interpreters;
|
-----------------------------------------------------------------------
-- util-encodes-tests - Test for encoding
-- Copyright (C) 2009, 2010, 2011, 2012, 2016, 2017, 2018, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with Util.Measures;
with Util.Strings.Transforms;
with Ada.Text_IO;
with Util.Encoders.SHA1;
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA1;
with Util.Encoders.HMAC.SHA256;
with Util.Encoders.Base16;
with Util.Encoders.Base64;
with Util.Encoders.AES;
with Util.Encoders.Quoted_Printable;
package body Util.Encoders.Tests is
use Util.Tests;
procedure Check_HMAC (T : in out Test'Class;
Key : in String;
Value : in String;
Expect : in String);
procedure Check_HMAC256 (T : in out Test'Class;
Key : in String;
Value : in String;
Expect : in String);
package Caller is new Util.Test_Caller (Test, "Encoders");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Encoders.Base16.Encode",
Test_Hex'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base16.Decode",
Test_Hex'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base64.Encode",
Test_Base64_Encode'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base64.Decode",
Test_Base64_Decode'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base64.Encode (URL)",
Test_Base64_URL_Encode'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base64.Decode (URL)",
Test_Base64_URL_Decode'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base64.Benchmark",
Test_Base64_Benchmark'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.SHA1.Encode",
Test_SHA1_Encode'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.SHA1.Benchmark",
Test_SHA1_Benchmark'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.SHA256.Encode",
Test_SHA256_Encode'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test1)",
Test_HMAC_SHA1_RFC2202_T1'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test2)",
Test_HMAC_SHA1_RFC2202_T2'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test3)",
Test_HMAC_SHA1_RFC2202_T3'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test4)",
Test_HMAC_SHA1_RFC2202_T4'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test5)",
Test_HMAC_SHA1_RFC2202_T5'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test6)",
Test_HMAC_SHA1_RFC2202_T6'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA1.Sign_SHA1 (RFC2202 test7)",
Test_HMAC_SHA1_RFC2202_T7'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Encode_LEB128",
Test_LEB128'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Base64.Encode",
Test_Base64_LEB128'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test1)",
Test_HMAC_SHA256_RFC4231_T1'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test2)",
Test_HMAC_SHA256_RFC4231_T2'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test3)",
Test_HMAC_SHA256_RFC4231_T3'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test4)",
Test_HMAC_SHA256_RFC4231_T4'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test5)",
Test_HMAC_SHA256_RFC4231_T5'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test6)",
Test_HMAC_SHA256_RFC4231_T6'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.HMAC.SHA256.Sign_SHA1 (RFC4231 test7)",
Test_HMAC_SHA256_RFC4231_T7'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.AES.Encrypt",
Test_AES'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.AES.Encrypt_Secret (CBC)",
Test_Encrypt_Decrypt_Secret'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.AES.Encrypt_Secret (CFB)",
Test_Encrypt_Decrypt_Secret_CFB'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.AES.Encrypt_Secret (OFB)",
Test_Encrypt_Decrypt_Secret_OFB'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.AES.Encrypt_Secret (CTR)",
Test_Encrypt_Decrypt_Secret_CTR'Access);
Caller.Add_Test (Suite, "Test Util.Encoders.Quoted_Printable.Decode",
Test_Decode_Quoted_Printable'Access);
end Add_Tests;
procedure Test_Base64_Encode (T : in out Test) is
C : constant Util.Encoders.Encoder := Create ("base64");
D : constant Util.Encoders.Decoder := Create ("base64");
begin
Assert_Equals (T, "YQ==", Util.Encoders.Encode (C, "a"));
Assert_Equals (T, "fA==", Util.Encoders.Encode (C, "|"));
Assert_Equals (T, "fHw=", Util.Encoders.Encode (C, "||"));
Assert_Equals (T, "fH5+", Util.Encoders.Encode (C, "|~~"));
Test_Encoder (T, C, D);
end Test_Base64_Encode;
procedure Test_Base64_Decode (T : in out Test) is
C : constant Util.Encoders.Encoder := Create ("base64");
D : constant Util.Encoders.Decoder := Create ("base64");
begin
Assert_Equals (T, "a", Util.Encoders.Decode (D, "YQ=="));
Assert_Equals (T, "|", Util.Encoders.Decode (D, "fA=="));
Assert_Equals (T, "||", Util.Encoders.Decode (D, "fHw="));
Assert_Equals (T, "|~~", Util.Encoders.Decode (D, "fH5+"));
Test_Encoder (T, C, D);
end Test_Base64_Decode;
procedure Test_Base64_URL_Encode (T : in out Test) is
C : constant Util.Encoders.Encoder := Create ("base64url");
D : constant Util.Encoders.Decoder := Create ("base64url");
begin
Assert_Equals (T, "YQ==", Util.Encoders.Encode (C, "a"));
Assert_Equals (T, "fA==", Util.Encoders.Encode (C, "|"));
Assert_Equals (T, "fHw=", Util.Encoders.Encode (C, "||"));
Assert_Equals (T, "fH5-", Util.Encoders.Encode (C, "|~~"));
Assert_Equals (T, "fH5_", Util.Encoders.Encode (C, "|~" & ASCII.DEL));
Test_Encoder (T, C, D);
end Test_Base64_URL_Encode;
procedure Test_Base64_URL_Decode (T : in out Test) is
C : constant Util.Encoders.Encoder := Create ("base64url");
D : constant Util.Encoders.Decoder := Create ("base64url");
begin
Assert_Equals (T, "a", Util.Encoders.Decode (D, "YQ=="));
Assert_Equals (T, "|", Util.Encoders.Decode (D, "fA=="));
Assert_Equals (T, "||", Util.Encoders.Decode (D, "fHw="));
Assert_Equals (T, "|~~", Util.Encoders.Decode (D, "fH5-"));
Assert_Equals (T, "|~" & ASCII.DEL, Util.Encoders.Decode (D, "fH5_"));
Test_Encoder (T, C, D);
end Test_Base64_URL_Decode;
procedure Test_Encoder (T : in out Test;
C : in Util.Encoders.Encoder;
D : in Util.Encoders.Decoder) is
begin
for I in 1 .. 334 loop
declare
Pattern : String (1 .. I);
begin
for J in Pattern'Range loop
Pattern (J) := Character'Val (((J + I) mod 63) + 32);
end loop;
declare
E : constant String := Util.Encoders.Encode (C, Pattern);
R : constant String := Util.Encoders.Decode (D, E);
begin
Assert_Equals (T, Pattern, R, "Encoding failed for length "
& Integer'Image (I) & " code: " & E);
end;
exception
when others =>
Ada.Text_IO.Put_Line ("Error at index " & Integer'Image (I));
raise;
end;
end loop;
end Test_Encoder;
procedure Test_Hex (T : in out Test) is
C : constant Util.Encoders.Encoder := Create ("hex");
D : constant Util.Encoders.Decoder := Create ("hex");
begin
Assert_Equals (T, "41424344", Util.Encoders.Encode (C, "ABCD"));
Assert_Equals (T, "ABCD", Util.Encoders.Decode (D, "41424344"));
Test_Encoder (T, C, D);
Assert_Equals (T, "ABCD", C.Encode_Unsigned_16 (16#abcd#));
Assert_Equals (T, "12345678", C.Encode_Unsigned_32 (16#12345678#));
Assert_Equals (T, "0000ABCD12345678", C.Encode_Unsigned_64 (16#abcd12345678#));
end Test_Hex;
procedure Test_Base64_Benchmark (T : in out Test) is
pragma Unreferenced (T);
C : constant Util.Encoders.Encoder := Create ("base64");
S : constant String (1 .. 1_024) := (others => 'a');
begin
declare
T : Util.Measures.Stamp;
R : constant String := Util.Encoders.Encode (C, S);
pragma Unreferenced (R);
begin
Util.Measures.Report (T, "Base64 encode 1024 bytes");
end;
end Test_Base64_Benchmark;
procedure Test_SHA1_Encode (T : in out Test) is
procedure Check_Hash (Value : in String;
Expect : in String);
C : Util.Encoders.SHA1.Context;
Hash : Util.Encoders.SHA1.Digest;
procedure Check_Hash (Value : in String;
Expect : in String) is
J, N : Natural;
Ctx : Util.Encoders.SHA1.Context;
begin
for I in 1 .. Value'Length loop
J := Value'First;
while J <= Value'Last loop
if J + I <= Value'Last then
N := J + I;
else
N := Value'Last;
end if;
Util.Encoders.SHA1.Update (Ctx, Value (J .. N));
J := N + 1;
end loop;
Util.Encoders.SHA1.Finish (Ctx, Hash);
Assert_Equals (T, Expect, Hash, "Invalid hash for: " & Value);
end loop;
end Check_Hash;
Hex_Decoder : Util.Encoders.Base16.Decoder;
Last : Ada.Streams.Stream_Element_Offset;
Sign : Util.Encoders.SHA1.Hash_Array;
begin
Util.Encoders.SHA1.Update (C, "a");
Util.Encoders.SHA1.Finish (C, Hash);
Assert_Equals (T, "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8", Hash,
"Invalid hash for 'a'");
Check_Hash ("ut", "E746699D3947443D84DAD1E0C58BF7AD34712438");
Check_Hash ("Uti", "2C669751BDC4929377245F5EEBEAED1CE4DA8A45");
Check_Hash ("Util", "4C31156EFED35EE7814650F8971C3698059440E3");
Check_Hash ("Util.Encoders", "7DB6007AD8BAEA7C167FF2AE06C9F50A4645F971");
Check_Hash ("e746699d3947443d84dad1e0c58bf7ad347124382C669751BDC492937"
& "7245F5EEBEAED1CE4DA8A45",
"875C9C0DE4CE91ED8F432DD02B5BB40CD35DAACD");
Util.Encoders.Transform (E => Hex_Decoder,
Data => "D803BA2155CD12D8997117E0846AD2D4555BEB28",
Into => Sign,
Last => Last);
Assert_Equals (T, Natural (Sign'Last), Natural (Last), "Decoding SHA1 failed");
Util.Encoders.Transform (E => Hex_Decoder,
Data => "D803BA2155CD12D8997117E0846AD2D4555BEB",
Into => Sign,
Last => Last);
Assert_Equals (T, Natural (Sign'Last) - 1, Natural (Last), "Decoding SHA1 failed");
begin
Util.Encoders.Transform (E => Hex_Decoder,
Data => "D803BA2155CD12D8997117E0846AD2D4555BEB2801",
Into => Sign,
Last => Last);
Fail (T, "No Encoding_Error exception raised");
exception
when Encoding_Error =>
null;
end;
end Test_SHA1_Encode;
-- ------------------------------
-- Benchmark test for SHA1
-- ------------------------------
procedure Test_SHA1_Benchmark (T : in out Test) is
pragma Unreferenced (T);
Hash : Util.Encoders.SHA1.Digest;
Sizes : constant array (1 .. 6) of Positive := (1, 10, 100, 1000, 10000, 100000);
begin
for I in Sizes'Range loop
declare
Size : constant Positive := Sizes (I);
S : constant String (1 .. Size) := (others => '0');
T1 : Util.Measures.Stamp;
C : Util.Encoders.SHA1.Context;
begin
Util.Encoders.SHA1.Update (C, S);
Util.Encoders.SHA1.Finish (C, Hash);
Util.Measures.Report (T1, "Encode SHA1" & Integer'Image (Size) & " bytes");
end;
end loop;
end Test_SHA1_Benchmark;
procedure Test_SHA256_Encode (T : in out Test) is
procedure Check_Hash (Value : in String;
Expect : in String);
C : Util.Encoders.SHA256.Context;
Hash : Util.Encoders.SHA256.Digest;
Digest : Util.Encoders.SHA256.Base64_Digest;
procedure Check_Hash (Value : in String;
Expect : in String) is
J, N : Natural;
Ctx : Util.Encoders.SHA256.Context;
begin
for I in 1 .. Value'Length loop
J := Value'First;
while J <= Value'Last loop
if J + I <= Value'Last then
N := J + I;
else
N := Value'Last;
end if;
Util.Encoders.SHA256.Update (Ctx, Value (J .. N));
J := N + 1;
end loop;
Util.Encoders.SHA256.Finish_Base64 (Ctx, Digest);
Ada.Text_IO.Put_Line ("Pass " & Natural'Image (Natural (I)) & ": " & Digest);
Assert_Equals (T, Expect, Digest, "Invalid SHA256-base64 digest for: " & Value);
end loop;
end Check_Hash;
begin
Util.Encoders.SHA256.Update (C, "a");
Util.Encoders.SHA256.Finish (C, Hash);
Assert_Equals (T, "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
Hash,
"Invalid hash for 'a'");
Check_Hash ("ut", "RpzGQ6Gft1kB5dMxuNwUvvqLmIELJGwvsi//DDgtw54=");
Check_Hash ("Uti", "cgM7MSIWSqV9OkdvuTPRKGlB3MWUVIaDLsZs/+7Wucs=");
Check_Hash ("Util", "+29Ow/TX6KR5mTjGr98WyuMeizmNl4g5XGZzpDYOn3A=");
Check_Hash ("Util.Encoders", "fzUVgu2+6QAfbf/CLYJeDFoeGTm7CHivxiFEUm0K80E=");
Check_Hash ("e746699d3947443d84dad1e0c58bf7ad347124382C669751BDC492937"
& "7245F5EEBEAED1CE4DA8A45",
"ZGrFiFCpzbCzN8xfRoVd5VmMlRU7PDMAPZRN34GaAJo=");
end Test_SHA256_Encode;
procedure Check_HMAC (T : in out Test'Class;
Key : in String;
Value : in String;
Expect : in String) is
H : constant String := Util.Encoders.HMAC.SHA1.Sign (Key, Value);
begin
Assert_Equals (T, Expect, Util.Strings.Transforms.To_Lower_Case (H),
"Invalid HMAC-SHA1");
end Check_HMAC;
procedure Check_HMAC256 (T : in out Test'Class;
Key : in String;
Value : in String;
Expect : in String) is
H : constant String := Util.Encoders.HMAC.SHA256.Sign (Key, Value);
B : constant Util.Encoders.SHA256.Hash_Array := Util.Encoders.HMAC.SHA256.Sign (Key, Value);
C : constant Encoders.SHA256.Base64_Digest := Encoders.HMAC.SHA256.Sign_Base64 (Key, Value);
B16 : constant Encoder := Create ("hex");
B64 : constant Decoder := Create ("base64");
B2 : constant Ada.Streams.Stream_Element_Array := B;
S : constant String := B16.Encode_Binary (B2);
B3 : constant Util.Encoders.SHA256.Hash_Array := B64.Decode_Binary (C);
begin
Assert_Equals (T, Expect, Util.Strings.Transforms.To_Lower_Case (H),
"Invalid HMAC-SHA256");
Assert_Equals (T, H, S, "Invalid HMAC-SHA256 binary");
if B /= B3 then
Ada.Text_IO.Put_Line ("Invalid binary");
end if;
Assert_Equals (T, H, B16.Encode_Binary (B3), "Invalid HMAC-SHA256 base64");
end Check_HMAC256;
-- ------------------------------
-- Test HMAC-SHA1
-- ------------------------------
procedure Test_HMAC_SHA1_RFC2202_T1 (T : in out Test) is
Key : constant String (1 .. 20) := (others => Character'Val (16#0b#));
begin
Check_HMAC (T, Key, "Hi There", "b617318655057264e28bc0b6fb378c8ef146be00");
end Test_HMAC_SHA1_RFC2202_T1;
procedure Test_HMAC_SHA1_RFC2202_T2 (T : in out Test) is
begin
Check_HMAC (T, "Jefe", "what do ya want for nothing?",
"effcdf6ae5eb2fa2d27416d5f184df9c259a7c79");
end Test_HMAC_SHA1_RFC2202_T2;
procedure Test_HMAC_SHA1_RFC2202_T3 (T : in out Test) is
Key : constant String (1 .. 20) := (others => Character'Val (16#aa#));
Data : constant String (1 .. 50) := (others => Character'Val (16#dd#));
begin
Check_HMAC (T, Key, Data,
"125d7342b9ac11cd91a39af48aa17b4f63f175d3");
end Test_HMAC_SHA1_RFC2202_T3;
procedure Test_HMAC_SHA1_RFC2202_T4 (T : in out Test) is
C : constant Util.Encoders.Decoder := Create ("hex");
Key : constant String := Util.Encoders.Decode (C, "0102030405060708090a0b0c0d0e0f"
& "10111213141516171819");
Data : constant String (1 .. 50) := (others => Character'Val (16#cd#));
begin
Check_HMAC (T, Key, Data,
"4c9007f4026250c6bc8414f9bf50c86c2d7235da");
end Test_HMAC_SHA1_RFC2202_T4;
procedure Test_HMAC_SHA1_RFC2202_T5 (T : in out Test) is
Key : constant String (1 .. 20) := (others => Character'Val (16#0c#));
begin
-- RFC2202 test case 5 but without truncation...
Check_HMAC (T, Key, "Test With Truncation",
"4c1a03424b55e07fe7f27be1d58bb9324a9a5a04");
end Test_HMAC_SHA1_RFC2202_T5;
procedure Test_HMAC_SHA1_RFC2202_T6 (T : in out Test) is
Key : constant String (1 .. 80) := (others => Character'Val (16#aa#));
begin
Check_HMAC (T, Key, "Test Using Larger Than Block-Size Key - Hash Key First",
"aa4ae5e15272d00e95705637ce8a3b55ed402112");
end Test_HMAC_SHA1_RFC2202_T6;
procedure Test_HMAC_SHA1_RFC2202_T7 (T : in out Test) is
Key : constant String (1 .. 80) := (others => Character'Val (16#Aa#));
begin
Check_HMAC (T, Key, "Test Using Larger Than Block-Size Key and Larger "
& "Than One Block-Size Data",
"e8e99d0f45237d786d6bbaa7965c7808bbff1a91");
end Test_HMAC_SHA1_RFC2202_T7;
-- ------------------------------
-- Test encoding leb128.
-- ------------------------------
procedure Test_LEB128 (T : in out Test) is
use type Interfaces.Unsigned_64;
Data : Ada.Streams.Stream_Element_Array (1 .. 100);
Last : Ada.Streams.Stream_Element_Offset;
Val : Interfaces.Unsigned_64;
Res : Interfaces.Unsigned_64;
begin
Encode_LEB128 (Into => Data,
Pos => Data'First,
Val => 1,
Last => Last);
Util.Tests.Assert_Equals (T, 1, Integer (Last), "Invalid last position");
Util.Tests.Assert_Equals (T, 1, Integer (Data (1)), "Invalid value");
Encode_LEB128 (Into => Data,
Pos => Data'First,
Val => 16#80#,
Last => Last);
Util.Tests.Assert_Equals (T, 2, Integer (Last), "Invalid last position");
Util.Tests.Assert_Equals (T, 16#80#, Integer (Data (1)), "Invalid value");
Util.Tests.Assert_Equals (T, 16#01#, Integer (Data (2)), "Invalid value");
for I in 0 .. 9 loop
Val := Interfaces.Shift_Left (1, 7 * I);
Encode_LEB128 (Into => Data,
Pos => Data'First,
Val => Val,
Last => Last);
Util.Tests.Assert_Equals (T, I + 1, Integer (Last), "Invalid last position");
Decode_LEB128 (From => Data,
Pos => Data'First,
Val => Res,
Last => Last);
Util.Tests.Assert_Equals (T, I + 2, Integer (Last), "Invalid last position after decode");
T.Assert (Val = Res, "Invalid decode with I " & Integer'Image (I));
end loop;
end Test_LEB128;
-- ------------------------------
-- Test encoding leb128 + base64
-- ------------------------------
procedure Test_Base64_LEB128 (T : in out Test) is
use type Interfaces.Unsigned_64;
Val : Interfaces.Unsigned_64 := 0;
Start : Util.Measures.Stamp;
begin
for I in 1 .. 100 loop
declare
S : constant String := Util.Encoders.Base64.Encode (Val);
V : constant Interfaces.Unsigned_64 := Util.Encoders.Base64.Decode (S);
begin
T.Assert (Val = V, "Invalid leb128+base64 encode/decode "
& Interfaces.Unsigned_64'Image (Val));
end;
Val := Val * 10 + 1;
end loop;
Util.Measures.Report (Start, "LEB128+Base64 encode and decode", 100);
end Test_Base64_LEB128;
-- ------------------------------
-- Test HMAC-SHA256
-- ------------------------------
procedure Test_HMAC_SHA256_RFC4231_T1 (T : in out Test) is
Key : constant String (1 .. 20) := (others => Character'Val (16#0b#));
begin
Check_HMAC256 (T, Key, "Hi There",
"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7");
end Test_HMAC_SHA256_RFC4231_T1;
procedure Test_HMAC_SHA256_RFC4231_T2 (T : in out Test) is
begin
Check_HMAC256 (T, "Jefe", "what do ya want for nothing?",
"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843");
end Test_HMAC_SHA256_RFC4231_T2;
procedure Test_HMAC_SHA256_RFC4231_T3 (T : in out Test) is
Key : constant String (1 .. 20) := (others => Character'Val (16#aa#));
Data : constant String (1 .. 50) := (others => Character'Val (16#dd#));
begin
Check_HMAC256 (T, Key, Data,
"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe");
end Test_HMAC_SHA256_RFC4231_T3;
procedure Test_HMAC_SHA256_RFC4231_T4 (T : in out Test) is
C : constant Util.Encoders.Decoder := Create ("hex");
Key : constant String := Util.Encoders.Decode (C, "0102030405060708090a0b0c0d0e0f"
& "10111213141516171819");
Data : constant String (1 .. 50) := (others => Character'Val (16#cd#));
begin
Check_HMAC256 (T, Key, Data,
"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b");
end Test_HMAC_SHA256_RFC4231_T4;
procedure Test_HMAC_SHA256_RFC4231_T5 (T : in out Test) is
Key : constant String (1 .. 20) := (others => Character'Val (16#0c#));
H : constant String := Util.Encoders.HMAC.SHA256.Sign (Key, "Test With Truncation");
begin
Assert_Equals (T, "a3b6167473100ee06e0c796c2955552b",
Util.Strings.Transforms.To_Lower_Case (H (1 .. 32)),
"Invalid HMAC-SHA256");
end Test_HMAC_SHA256_RFC4231_T5;
procedure Test_HMAC_SHA256_RFC4231_T6 (T : in out Test) is
Key : constant String (1 .. 131) := (others => Character'Val (16#aa#));
begin
Check_HMAC256 (T, Key, "Test Using Larger Than Block-Size Key - Hash Key First",
"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54");
end Test_HMAC_SHA256_RFC4231_T6;
procedure Test_HMAC_SHA256_RFC4231_T7 (T : in out Test) is
Key : constant String (1 .. 131) := (others => Character'Val (16#Aa#));
begin
Check_HMAC256 (T, Key, "This is a test using a larger than block-size ke"
& "y and a larger than block-size data. The key nee"
& "ds to be hashed before being used by the HMAC algorithm.",
"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2");
end Test_HMAC_SHA256_RFC4231_T7;
procedure Test_AES (T : in out Test) is
PK : constant Secret_Key := Create ("0123456789abcdef");
Key : Util.Encoders.AES.Key_Type;
B : Util.Encoders.AES.Block_Type := (others => 1);
E : Util.Encoders.AES.Block_Type := (others => 0);
Ok : Boolean;
begin
Util.Encoders.AES.Set_Encrypt_Key (Key, PK);
Util.Encoders.AES.Encrypt (B, E, Key);
Util.Encoders.AES.Set_Decrypt_Key (Key, PK);
Util.Encoders.AES.Decrypt (E, B, Key);
Ok := (for all E of B => E = 1);
T.Assert (Ok, "Encryption and decryption are invalid (block with 1)");
B := (others => 16#ab#);
Util.Encoders.AES.Set_Encrypt_Key (Key, PK);
Util.Encoders.AES.Encrypt (B, E, Key);
Util.Encoders.AES.Set_Decrypt_Key (Key, PK);
Util.Encoders.AES.Decrypt (E, B, Key);
Ok := (for all E of B => E = 16#ab#);
T.Assert (Ok, "Encryption and decryption are invalid (block with 16#AB#)");
end Test_AES;
-- ------------------------------
-- Test encrypt and decrypt operations.
-- ------------------------------
procedure Test_Encrypt_Decrypt_Secret (T : in out Test) is
Pk : constant Secret_Key := Create ("0123456789abcdef");
Cipher : Util.Encoders.AES.Encoder;
Decipher : Util.Encoders.AES.Decoder;
Data : Ada.Streams.Stream_Element_Array (1 .. 16);
Result : Secret_Key (16);
begin
Cipher.Set_Key (Pk, Util.Encoders.AES.CBC);
Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Decipher.Set_Key (Pk, Util.Encoders.AES.CBC);
Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Cipher.Encrypt_Secret (Pk, Data);
Decipher.Decrypt_Secret (Data, Result);
T.Assert (Result.Secret = Pk.Secret, "Encrypt_Secret and Decrypt_Secret failed");
end Test_Encrypt_Decrypt_Secret;
-- ------------------------------
-- Test encrypt and decrypt operations.
-- ------------------------------
procedure Test_Encrypt_Decrypt_Secret_CFB (T : in out Test) is
Pk : constant Secret_Key := Create ("0123456789abcdef0123456789abcdef");
Cipher : Util.Encoders.AES.Encoder;
Decipher : Util.Encoders.AES.Decoder;
Data : Ada.Streams.Stream_Element_Array (1 .. 32);
Result : Secret_Key (32);
begin
Cipher.Set_Key (Pk, Util.Encoders.AES.CFB);
Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Decipher.Set_Key (Pk, Util.Encoders.AES.CFB);
Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Cipher.Encrypt_Secret (Pk, Data);
Decipher.Decrypt_Secret (Data, Result);
T.Assert (Result.Secret = Pk.Secret, "CFB Encrypt_Secret and Decrypt_Secret failed");
end Test_Encrypt_Decrypt_Secret_CFB;
-- ------------------------------
-- Test encrypt and decrypt operations.
-- ------------------------------
procedure Test_Encrypt_Decrypt_Secret_OFB (T : in out Test) is
Pk : constant Secret_Key := Create ("0123456789abcdef0123456789abcdef");
Cipher : Util.Encoders.AES.Encoder;
Decipher : Util.Encoders.AES.Decoder;
Data : Ada.Streams.Stream_Element_Array (1 .. 32);
Result : Secret_Key (32);
begin
Cipher.Set_Key (Pk, Util.Encoders.AES.OFB);
Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Decipher.Set_Key (Pk, Util.Encoders.AES.OFB);
Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Cipher.Encrypt_Secret (Pk, Data);
Decipher.Decrypt_Secret (Data, Result);
T.Assert (Result.Secret = Pk.Secret, "OFB Encrypt_Secret and Decrypt_Secret failed");
end Test_Encrypt_Decrypt_Secret_OFB;
-- ------------------------------
-- Test encrypt and decrypt operations.
-- ------------------------------
procedure Test_Encrypt_Decrypt_Secret_CTR (T : in out Test) is
Pk : constant Secret_Key := Create ("0123456789abcdef0123456789abcdef");
Cipher : Util.Encoders.AES.Encoder;
Decipher : Util.Encoders.AES.Decoder;
Data : Ada.Streams.Stream_Element_Array (1 .. 32);
Result : Secret_Key (32);
begin
Cipher.Set_Key (Pk, Util.Encoders.AES.CTR);
Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Decipher.Set_Key (Pk, Util.Encoders.AES.CTR);
Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Cipher.Encrypt_Secret (Pk, Data);
Decipher.Decrypt_Secret (Data, Result);
T.Assert (Result.Secret = Pk.Secret, "CTR Encrypt_Secret and Decrypt_Secret failed");
end Test_Encrypt_Decrypt_Secret_CTR;
-- ------------------------------
-- Test Decode Quoted-Printable encoding.
-- ------------------------------
procedure Test_Decode_Quoted_Printable (T : in out Test) is
begin
Assert_Equals (T, "teams aren.t =way to protect yo",
Quoted_Printable.Decode ("teams aren=2Et =3Dway to protect yo="));
Assert_Equals (T, "====",
Quoted_Printable.Decode ("=3D=3D=3D=3D="));
Assert_Equals (T, "teams aren.t =way to protect yo",
Quoted_Printable.Q_Decode ("teams_aren=2Et_=3Dway_to_protect_yo="));
end Test_Decode_Quoted_Printable;
end Util.Encoders.Tests;
|
with GL;
with GLOBE_3D.Math;
package body Actors is
use GLOBE_3D, GLOBE_3D.Math, GLOBE_3D.REF, Game_Control, GL;
procedure Limited_Translation (actor : in out GLOBE_3D.Camera;
gc : Game_Control.Command_set;
gx, gy : GLOBE_3D.Real;
unitary_change : GLOBE_3D.Real;
deceleration : GLOBE_3D.Real;
time_step : GLOBE_3D.Real) is
pragma Unreferenced (gx);
unitary_movement, eye_movement : Real;
step : Vector_3D;
begin
unitary_movement := (case gc (run_mode) is
when True => 300.0,
when False => 100.0);
unitary_movement := unitary_movement * unitary_change;
eye_movement := unitary_movement * 2.0;
actor.Speed (2) := actor.Speed (2) + (case gc (go_forward) is
when True => -eye_movement,
when False => +eye_movement);
actor.Speed (1) := actor.Speed (1) + (if gc (slide_vertical_graduated) then +gy * 2.0 * unitary_movement
elsif gc (slide_down) then -eye_movement
elsif gc (slide_up) then +eye_movement
else 0.0);
actor.Speed (0) := actor.Speed (0) + (if gc (slide_vertical_graduated) then +gy * 2.0 * unitary_movement
elsif gc (slide_down) then -eye_movement
elsif gc (slide_up) then +eye_movement
else 0.0);
step := time_step * (Transpose (actor.World_Rotation) * actor.Speed);
-- (speed (0), -- lateral sliding
-- speed (1), -- vertical sliding
-- speed (2)); -- forward/backwards
-- -- ^ vector in the local referential
Limiting (step);
actor.Clipper.Eye_Position := actor.Clipper.Eye_Position + step;
actor.Speed := deceleration * actor.Speed;
end Limited_Translation;
procedure No_Limitation (step : in out GLOBE_3D.Vector_3D) is
null;
procedure Translation_inst is new Limited_Translation (No_Limitation);
procedure Translation (actor : in out GLOBE_3D.Camera;
gc : Game_Control.Command_set;
gx, gy : GLOBE_3D.Real;
unitary_change : GLOBE_3D.Real;
deceleration : GLOBE_3D.Real;
time_step : GLOBE_3D.Real) renames Translation_inst;
procedure Rotation (actor : in out GLOBE_3D.Camera;
gc : Game_Control.Command_set;
gx, gy : GLOBE_3D.Real;
unitary_change : GLOBE_3D.Real;
deceleration : GLOBE_3D.Real;
time_step : GLOBE_3D.Real) is
incremental_rotation : Vector_3D := (0.0, 0.0, 0.0);
begin
Abstract_rotation (gc, gx, gy,
unitary_change, deceleration, incremental_rotation, time_step,
actor.rotation_Speed);
actor.rotation := actor.rotation + incremental_rotation;
if actor.compose_rotations then
actor.World_Rotation :=
XYZ_rotation (incremental_rotation) * actor.World_Rotation;
Re_Orthonormalize (actor.World_Rotation);
else
declare
r : Vector_3D renames actor.rotation;
-- We need to turn around the axes in this order : Y, X, Z
begin
actor.World_Rotation :=
XYZ_rotation (0.0, 0.0, r (2)) * -- 3) turn around the nose
XYZ_rotation (r (0), 0.0, 0.0) * -- 2) lift or lower the head
XYZ_rotation (0.0, r (1), 0.0); -- 1) pivotate around the feet
end;
end if;
end Rotation;
procedure Abstract_rotation (gc : Game_Control.Command_set;
gx, gy : GLOBE_3D.Real;
unitary_change : GLOBE_3D.Real;
deceleration : GLOBE_3D.Real;
vector : in out GLOBE_3D.Vector_3D;
time_step : GLOBE_3D.Real;
rotation_speed : in out GLOBE_3D.Vector_3D) is
unitary_movement, mouse_rotation, key_rotation : Real;
begin
if gc (run_mode) then
unitary_movement := 40.0;
else
unitary_movement := 20.0;
end if;
unitary_movement := unitary_movement * unitary_change;
mouse_rotation := 2.0 * unitary_movement;
key_rotation := 0.17 * unitary_movement;
if gc (swing_plus) then
rotation_speed (2) := rotation_speed (2) + key_rotation;
end if;
if gc (swing_minus) then
rotation_speed (2) := rotation_speed (2) - key_rotation;
end if;
if gc (turn_left) then
rotation_speed (1) := rotation_speed (1) + key_rotation;
end if;
if gc (turn_right) then
rotation_speed (1) := rotation_speed (1) - key_rotation;
end if;
if gc (turn_up) then
rotation_speed (0) := rotation_speed (0) - key_rotation;
end if;
if gc (turn_down) then
rotation_speed (0) := rotation_speed (0) + key_rotation;
end if;
if gc (turn_lateral_graduated) then
rotation_speed (1) := rotation_speed (1) - gx * mouse_rotation;
end if;
if gc (turn_vertical_graduated) then
rotation_speed (0) := rotation_speed (0) - gy * mouse_rotation;
end if;
vector := vector + time_step * rotation_speed;
rotation_speed := deceleration * rotation_speed;
end Abstract_rotation;
procedure Abstract_rotation (gc : Game_Control.Command_set;
gx, gy : GLOBE_3D.Real;
unitary_change : GLOBE_3D.Real;
deceleration : GLOBE_3D.Real;
rot_matrix : in out GLOBE_3D.Matrix_33;
time_step : GLOBE_3D.Real;
rotation_speed : in out GLOBE_3D.Vector_3D) is
incremental_rotation : Vector_3D := (0.0, 0.0, 0.0);
begin
Abstract_rotation (gc, gx, gy,
unitary_change, deceleration, incremental_rotation, time_step,
rotation_speed);
rot_matrix := rot_matrix * XYZ_rotation (incremental_rotation);
end Abstract_rotation;
end Actors;
|
package body Spawn_Manager is
---------------------
-- Is_Exit_Message --
---------------------
function Is_Exit_Message (Request : Spawn_Request) return Boolean is
begin
return Request.Spawn_Type = Terminate_Server;
end Is_Exit_Message;
function WIFEXITED (Stat_Val : Status_Kind) return Boolean is
begin
return (Stat_Val and 16#FF_FF_FF_00#) = 0;
end WIFEXITED;
function WEXITSTATUS (Stat_Val : Status_Kind) return Integer is
begin
return Integer (Shift_Right (Stat_Val and 16#0000_FF_00#, 8));
end WEXITSTATUS;
-- function WIFSIGNALED (Stat_Val : Status_Kind) return Boolean is
-- pragma Unreferenced (Stat_Val);
-- begin
-- return False ; -- (((Stat_Val and 16#7F#) +1);
-- end WIFSIGNALED;
-- function WTERMSIG (Stat_Val : Status_Kind) return Boolean is
-- pragma Unreferenced (Stat_Val);
-- begin
-- return False;
-- end WTERMSIG;
-- function WIFSTOPPED (Stat_Val : Status_Kind) return Boolean is
-- begin
-- return (Stat_Val and 16#FF#) = 16#7F#;
-- end WIFSTOPPED;
-- pragma Unreferenced (WIFSTOPPED);
-- function WSTOPSIG (Stat_Val : Status_Kind) return Integer is
-- pragma Unreferenced (Stat_Val);
-- begin
-- return 0;
-- end WSTOPSIG;
-- pragma Unreferenced (WSTOPSIG);
function WIFCONTINUED (Stat_Val : Status_Kind) return Boolean is
begin
return Stat_Val = 16#FF_FF#;
end WIFCONTINUED;
end Spawn_Manager;
|
-- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
with Sf.Graphics.BlendMode;
with Sf.Graphics.Color;
with Sf.Graphics.Types;
package Sf.Graphics.Shape is
use Sf.Config;
use Sf.Graphics.BlendMode;
use Sf.Graphics.Color;
use Sf.Graphics.Types;
-- ////////////////////////////////////////////////////////////
-- /// Create a new shape
-- ///
-- /// \return A new sfShape object, or NULL if it failed
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_Create return sfShape_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Create a new shape made of a single line
-- ///
-- /// \param P1X, P1Y : Position of the first point
-- /// \param P2X, P2Y : Position second point
-- /// \param Thickness : Line thickness
-- /// \param Col : Color used to draw the line
-- /// \param Outline : Outline width
-- /// \param OutlineCol : Color used to draw the outline
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_CreateLine
(P1X : Float;
P1Y : Float;
P2X : Float;
P2Y : Float;
Thickness : Float;
Col : sfColor;
Outline : Float;
OutlineCol : sfColor)
return sfShape_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Create a new shape made of a single rectangle
-- ///
-- /// \param P1X, P1Y : Position of the first point
-- /// \param P2X, P2Y : Position second point
-- /// \param Col : Color used to fill the rectangle
-- /// \param Outline : Outline width
-- /// \param OutlineCol : Color used to draw the outline
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_CreateRectangle
(P1X : Float;
P1Y : Float;
P2X : Float;
P2Y : Float;
Col : sfColor;
Outline : Float;
OutlineCol : sfColor)
return sfShape_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Create a new shape made of a single circle
-- ///
-- /// \param X, Y : Position of the center
-- /// \param Radius : Radius
-- /// \param Col : Color used to fill the circle
-- /// \param Outline : Outline width
-- /// \param OutlineCol : Color used to draw the outline
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_CreateCircle
(X : Float;
Y : Float;
Radius : Float;
Col : sfColor;
Outline : Float;
OutlineCol : sfColor)
return sfShape_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing Shape
-- ///
-- /// \param Shape : Shape to delete
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_Destroy (Shape : sfShape_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Set the X position of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param X : New X coordinate
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetX (Shape : sfShape_Ptr; X : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the Y position of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Y : New Y coordinate
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetY (Shape : sfShape_Ptr; Y : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the position of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param X : New X coordinate
-- /// \param Y : New Y coordinate
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetPosition (Shape : sfShape_Ptr; X : Float; Y : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the horizontal scale of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Scale : New scale (must be strictly positive)
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetScaleX (Shape : sfShape_Ptr; Scale : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the vertical scale of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Scale : New scale (must be strictly positive)
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetScaleY (Shape : sfShape_Ptr; Scale : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the scale of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param ScaleX : New horizontal scale (must be strictly positive)
-- /// \param ScaleY : New vertical scale (must be strictly positive)
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetScale (Shape : sfShape_Ptr; ScaleX : Float; ScaleY : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the orientation of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Rotation : Angle of rotation, in degrees
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetRotation (Shape : sfShape_Ptr; Rotation : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the center of a shape, in coordinates relative to
-- /// its left-top corner
-- ///
-- /// \param Shape : Shape to modify
-- /// \param X : X coordinate of the center
-- /// \param Y : Y coordinate of the center
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetCenter (Shape : sfShape_Ptr; X : Float; Y : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the color of a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Color : New color
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetColor (Shape : sfShape_Ptr; Color : sfColor);
-- ////////////////////////////////////////////////////////////
-- /// Set the blending mode for a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Mode : New blending mode
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetBlendMode (Shape : sfShape_Ptr; Mode : sfBlendMode);
-- ////////////////////////////////////////////////////////////
-- /// Get the X position of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current X position
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetX (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the Y position of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current Y position
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetY (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the horizontal scale of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current X scale factor (always positive)
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetScaleX (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the vertical scale of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current Y scale factor (always positive)
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetScaleY (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the orientation of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current rotation, in degrees
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetRotation (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the X position of the center a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current X center
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetCenterX (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the Y position of the center a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current Y center
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetCenterY (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the color of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current color
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetColor (Shape : sfShape_Ptr) return sfColor;
-- ////////////////////////////////////////////////////////////
-- /// Get the current blending mode of a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Current blending mode
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetBlendMode (Shape : sfShape_Ptr) return sfBlendMode;
-- ////////////////////////////////////////////////////////////
-- /// Move a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param OffsetX : Offset on the X axis
-- /// \param OffsetY : Offset on the Y axis
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_Move (Shape : sfShape_Ptr; OffsetX : Float; OffsetY : Float);
-- ////////////////////////////////////////////////////////////
-- /// Scale a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param FactorX : Horizontal scaling factor (must be strictly positive)
-- /// \param FactorY : Vertical scaling factor (must be strictly positive)
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_Scale (Shape : sfShape_Ptr; FactorX : Float; FactorY : Float);
-- ////////////////////////////////////////////////////////////
-- /// Rotate a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Angle : Angle of rotation, in degrees
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_Rotate (Shape : sfShape_Ptr; Angle : Float);
-- ////////////////////////////////////////////////////////////
-- /// Transform a point from global coordinates into the shape's local coordinates
-- /// (ie it applies the inverse of object's center, translation, rotation and scale to the point)
-- ///
-- /// \param Shape : Shape object
-- /// \param PointX : X coordinate of the point to transform
-- /// \param PointY : Y coordinate of the point to transform
-- /// \param X : Value to fill with the X coordinate of the converted point
-- /// \param Y : Value to fill with the y coordinate of the converted point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_TransformToLocal
(Shape : sfShape_Ptr;
PointX : Float;
PointY : Float;
X : access Float;
Y : access Float);
-- ////////////////////////////////////////////////////////////
-- /// Transform a point from the shape's local coordinates into global coordinates
-- /// (ie it applies the object's center, translation, rotation and scale to the point)
-- ///
-- /// \param Shape : Shape object
-- /// \param PointX : X coordinate of the point to transform
-- /// \param PointY : Y coordinate of the point to transform
-- /// \param X : Value to fill with the X coordinate of the converted point
-- /// \param Y : Value to fill with the y coordinate of the converted point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_TransformToGlobal
(Shape : sfShape_Ptr;
PointX : Float;
PointY : Float;
X : access Float;
Y : access Float);
-- ////////////////////////////////////////////////////////////
-- /// Add a point to a shape
-- ///
-- /// \param Shape : Shape to modify
-- /// \param X, Y : Position of the point
-- /// \param Col : Color of the point
-- /// \param OutlineCol : Outline color of the point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_AddPoint
(Shape : sfShape_Ptr;
X : Float;
Y : Float;
Col : sfColor;
OutlineCol : sfColor);
-- ////////////////////////////////////////////////////////////
-- /// Enable or disable filling a shape.
-- /// Fill is enabled by default
-- ///
-- /// \param Enable : True to enable, false to disable
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_EnableFill (Shape : sfShape_Ptr; Enable : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Enable or disable drawing a shape outline.
-- /// Outline is enabled by default
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Enable : True to enable, false to disable
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_EnableOutline (Shape : sfShape_Ptr; Enable : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Change the width of a shape outline
-- ///
-- /// \param Shape : Shape to modify
-- /// \param Width : New width
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetOutlineWidth (Shape : sfShape_Ptr; Width : Float);
-- ////////////////////////////////////////////////////////////
-- /// Get the width of a shape outline
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \param return Current outline width
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetOutlineWidth (Shape : sfShape_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the number of points composing a shape
-- ///
-- /// \param Shape : Shape to read
-- ///
-- /// \return Total number of points
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetNbPoints (Shape : sfShape_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get a the position of a shape's point
-- ///
-- /// \param Shape : Shape to read
-- /// \param Index : Index of the point to get
-- /// \param X : Variable to fill with the X coordinate of the point
-- /// \param Y : Variable to fill with the Y coordinate of the point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_GetPointPosition
(Shape : sfShape_Ptr;
Index : sfUint32;
X : access Float;
Y : access Float);
-- ////////////////////////////////////////////////////////////
-- /// Get a the color of a shape's point
-- ///
-- /// \param Shape : Shape to read
-- /// \param Index : Index of the point to get
-- ///
-- /// \return Color of the point
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetPointColor (Shape : sfShape_Ptr; Index : sfUint32) return sfColor;
-- ////////////////////////////////////////////////////////////
-- /// Get a the outline color of a shape's point
-- ///
-- /// \param Shape : Shape to read
-- /// \param Index : Index of the point to get
-- ///
-- /// \return Outline color of the point
-- ///
-- ////////////////////////////////////////////////////////////
function sfShape_GetPointOutlineColor (Shape : sfShape_Ptr; Index : sfUint32) return sfColor;
-- ////////////////////////////////////////////////////////////
-- /// Set a the position of a shape's point
-- ///
-- /// \param Shape : Shape to read
-- /// \param Index : Index of the point to get
-- /// \param X : X coordinate of the point
-- /// \param Y : Y coordinate of the point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetPointPosition
(Shape : sfShape_Ptr;
Index : sfUint32;
X : Float;
Y : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set a the color of a shape's point
-- ///
-- /// \param Shape : Shape to read
-- /// \param Index : Index of the point to get
-- /// \param Color : Color of the point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetPointColor (Shape : sfShape_Ptr; Index : sfUint32; Color : sfColor);
-- ////////////////////////////////////////////////////////////
-- /// Set a the outline color of a shape's point
-- ///
-- /// \param Shape : Shape to read
-- /// \param Index : Index of the point to get
-- /// \param Color : Outline color of the point
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfShape_SetPointOutlineColor (Shape : sfShape_Ptr; Index : sfUint32; Color : sfColor);
private
pragma Import (C, sfShape_Create, "sfShape_Create");
pragma Import (C, sfShape_CreateLine, "sfShape_CreateLine");
pragma Import (C, sfShape_CreateRectangle, "sfShape_CreateRectangle");
pragma Import (C, sfShape_CreateCircle, "sfShape_CreateCircle");
pragma Import (C, sfShape_Destroy, "sfShape_Destroy");
pragma Import (C, sfShape_SetX, "sfShape_SetX");
pragma Import (C, sfShape_SetY, "sfShape_SetY");
pragma Import (C, sfShape_SetPosition, "sfShape_SetPosition");
pragma Import (C, sfShape_SetScaleX, "sfShape_SetScaleX");
pragma Import (C, sfShape_SetScaleY, "sfShape_SetScaleY");
pragma Import (C, sfShape_SetScale, "sfShape_SetScale");
pragma Import (C, sfShape_SetRotation, "sfShape_SetRotation");
pragma Import (C, sfShape_SetCenter, "sfShape_SetCenter");
pragma Import (C, sfShape_SetColor, "sfShape_SetColor");
pragma Import (C, sfShape_SetBlendMode, "sfShape_SetBlendMode");
pragma Import (C, sfShape_GetX, "sfShape_GetX");
pragma Import (C, sfShape_GetY, "sfShape_GetY");
pragma Import (C, sfShape_GetScaleX, "sfShape_GetScaleX");
pragma Import (C, sfShape_GetScaleY, "sfShape_GetScaleY");
pragma Import (C, sfShape_GetRotation, "sfShape_GetRotation");
pragma Import (C, sfShape_GetCenterX, "sfShape_GetCenterX");
pragma Import (C, sfShape_GetCenterY, "sfShape_GetCenterY");
pragma Import (C, sfShape_GetColor, "sfShape_GetColor");
pragma Import (C, sfShape_GetBlendMode, "sfShape_GetBlendMode");
pragma Import (C, sfShape_Move, "sfShape_Move");
pragma Import (C, sfShape_Scale, "sfShape_Scale");
pragma Import (C, sfShape_Rotate, "sfShape_Rotate");
pragma Import (C, sfShape_TransformToLocal, "sfShape_TransformToLocal");
pragma Import (C, sfShape_TransformToGlobal, "sfShape_TransformToGlobal");
pragma Import (C, sfShape_AddPoint, "sfShape_AddPoint");
pragma Import (C, sfShape_EnableFill, "sfShape_EnableFill");
pragma Import (C, sfShape_EnableOutline, "sfShape_EnableOutline");
pragma Import (C, sfShape_SetOutlineWidth, "sfShape_SetOutlineWidth");
pragma Import (C, sfShape_GetOutlineWidth, "sfShape_GetOutlineWidth");
pragma Import (C, sfShape_GetNbPoints, "sfShape_GetNbPoints");
pragma Import (C, sfShape_GetPointPosition, "sfShape_GetPointPosition");
pragma Import (C, sfShape_GetPointColor, "sfShape_GetPointColor");
pragma Import (C, sfShape_GetPointOutlineColor, "sfShape_GetPointOutlineColor");
pragma Import (C, sfShape_SetPointPosition, "sfShape_SetPointPosition");
pragma Import (C, sfShape_SetPointColor, "sfShape_SetPointColor");
pragma Import (C, sfShape_SetPointOutlineColor, "sfShape_SetPointOutlineColor");
end Sf.Graphics.Shape;
|
package body agar.gui.draw is
package cbinds is
procedure box_rounded
(widget : agar.gui.widget.widget_access_t;
rect : agar.gui.rect.rect_t;
z : c.int;
radius : c.int;
color : agar.core.types.uint32_t);
pragma import (c, box_rounded, "agar_draw_box_rounded");
procedure box_rounded_top
(widget : agar.gui.widget.widget_access_t;
rect : agar.gui.rect.rect_t;
z : c.int;
radius : c.int;
color : agar.core.types.uint32_t);
pragma import (c, box_rounded_top, "agar_draw_box_rounded_top");
procedure circle
(widget : agar.gui.widget.widget_access_t;
x : c.int;
y : c.int;
radius : c.int;
color : agar.core.types.uint32_t);
pragma import (c, circle, "agar_draw_circle");
procedure circle2
(widget : agar.gui.widget.widget_access_t;
x : c.int;
y : c.int;
radius : c.int;
color : agar.core.types.uint32_t);
pragma import (c, circle2, "agar_draw_circle2");
procedure line
(widget : agar.gui.widget.widget_access_t;
x1 : c.int;
y1 : c.int;
x2 : c.int;
y2 : c.int;
color : agar.core.types.uint32_t);
pragma import (c, line, "agar_draw_line");
procedure line_horizontal
(widget : agar.gui.widget.widget_access_t;
x1 : c.int;
x2 : c.int;
y : c.int;
color : agar.core.types.uint32_t);
pragma import (c, line_horizontal, "agar_draw_line_horizontal");
procedure line_vertical
(widget : agar.gui.widget.widget_access_t;
x : c.int;
y1 : c.int;
y2 : c.int;
color : agar.core.types.uint32_t);
pragma import (c, line_vertical, "agar_draw_line_vertical");
end cbinds;
procedure box_rounded
(widget : agar.gui.widget.widget_access_t;
rect : agar.gui.rect.rect_t;
z : natural;
radius : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.box_rounded
(widget => widget,
rect => rect,
z => c.int (z),
radius => c.int (radius),
color => color);
end box_rounded;
procedure box_rounded_top
(widget : agar.gui.widget.widget_access_t;
rect : agar.gui.rect.rect_t;
z : natural;
radius : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.box_rounded_top
(widget => widget,
rect => rect,
z => c.int (z),
radius => c.int (radius),
color => color);
end box_rounded_top;
procedure circle
(widget : agar.gui.widget.widget_access_t;
x : natural;
y : natural;
radius : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.circle
(widget => widget,
x => c.int (x),
y => c.int (y),
radius => c.int (radius),
color => color);
end circle;
procedure circle2
(widget : agar.gui.widget.widget_access_t;
x : natural;
y : natural;
radius : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.circle2
(widget => widget,
x => c.int (x),
y => c.int (y),
radius => c.int (radius),
color => color);
end circle2;
procedure line
(widget : agar.gui.widget.widget_access_t;
x1 : natural;
y1 : natural;
x2 : natural;
y2 : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.line
(widget => widget,
x1 => c.int (x1),
y1 => c.int (y1),
x2 => c.int (x2),
y2 => c.int (y2),
color => color);
end line;
procedure line_horizontal
(widget : agar.gui.widget.widget_access_t;
x1 : natural;
x2 : natural;
y : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.line_horizontal
(widget => widget,
x1 => c.int (x1),
x2 => c.int (x2),
y => c.int (y),
color => color);
end line_horizontal;
procedure line_vertical
(widget : agar.gui.widget.widget_access_t;
x : natural;
y1 : natural;
y2 : natural;
color : agar.core.types.uint32_t) is
begin
cbinds.line_vertical
(widget => widget,
x => c.int (x),
y1 => c.int (y1),
y2 => c.int (y2),
color => color);
end line_vertical;
end agar.gui.draw;
|
with Ada.Containers; use Ada.Containers;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libadalang.Common; use Libadalang.Common;
with Rejuvenation; use Rejuvenation;
with Rejuvenation.Finder; use Rejuvenation.Finder;
with Rejuvenation.Node_Locations; use Rejuvenation.Node_Locations;
with Rejuvenation.Match_Patterns; use Rejuvenation.Match_Patterns;
with Rejuvenation.Pretty_Print; use Rejuvenation.Pretty_Print;
with Rejuvenation.Simple_Factory; use Rejuvenation.Simple_Factory;
with Rejuvenation.Text_Rewrites; use Rejuvenation.Text_Rewrites;
with Rewriters_Sequence_Utils; use Rewriters_Sequence_Utils;
with Rewriters_Context_Utils; use Rewriters_Context_Utils;
package body Rewriters_Find_And_Replace is
function Node_To_Rule (Node : Ada_Node) return Grammar_Rule;
function Node_To_Rule (Node : Ada_Node) return Grammar_Rule is
begin
case Node.Kind is
when Ada_Stmt =>
-- We allow the replacement of a single statement by multiple statements.
-- So we have to expect not just a single but multiple statements.
return Stmts_Rule;
when Ada_Basic_Decl =>
-- We allow the replacement of a single declaration by multiple declarations.
-- So we have to expect not just a single but multiple declarations.
return Basic_Decls_Rule;
when Ada_Expr =>
return Expr_Rule;
-- other possibilities due to context enlargements
when Ada_Stmt_List =>
return Stmts_Rule;
when Ada_Handled_Stmts =>
return Handled_Stmts_Rule;
when Ada_Param_Assoc =>
return Param_Assoc_Rule;
when Ada_Aggregate_Assoc =>
return Aggregate_Assoc_Rule;
when Ada_Pragma_Argument_Assoc =>
return Pragma_Argument_Rule;
when Ada_Ada_Node_List =>
return Decl_Part_Rule;
when others =>
declare
Node_To_Rule_Expection : exception;
begin
raise Node_To_Rule_Expection
with "Node_To_Rule: unhandled " & Node.Kind'Image;
-- when we are convinced we have all kinds covered,
-- we can remove the exception
return Default_Grammar_Rule;
end;
end case;
end Node_To_Rule;
function Make_Contexts
(Matches : Match_Pattern_List.Vector; Accept_Match : Match_Accepter;
Rewriters : Rewriters_Sequence.Vector) return Node_List.Vector;
function Make_Contexts
(Matches : Match_Pattern_List.Vector; Accept_Match : Match_Accepter;
Rewriters : Rewriters_Sequence.Vector) return Node_List.Vector
is
Contexts : Node_List.Vector;
begin
for Match of Matches loop
if Accept_Match (Match) then
declare
Match_Nodes : constant Node_List.Vector := Match.Get_Nodes;
Match_Node : constant Ada_Node :=
(if Match_Nodes.Length = 1 then Match_Nodes.First_Element
else Match_Nodes.First_Element.Parent);
Match_Context : constant Ada_Node :=
Rewrite_Context (Rewriters, Match_Node);
begin
if
(for all Context of Contexts =>
not Is_Reflexive_Ancestor (Context, Match_Context))
then
declare
New_Contexts : Node_List.Vector :=
Node_List.To_Vector (Match_Context, 1);
begin
for Context of Contexts loop
if not Is_Ancestor (Match_Context, Context) then
New_Contexts.Append (Context);
end if;
end loop;
Node_List.Assign (Contexts, New_Contexts);
end;
end if;
end;
end if;
end loop;
return Contexts;
end Make_Contexts;
overriding function Rewrite
(RFR : Rewriter_Find_And_Replace; Node : Ada_Node'Class;
Top_Level : Boolean := True) return String
is
TN : Text_Rewrite :=
Make_Text_Rewrite_Node
(Node, Trivia_On_Same_Line, Trivia_On_Same_Line);
Matches : constant Match_Pattern_List.Vector :=
(if RFR.F_Find_Pattern.As_Ada_Node.Kind in Ada_Ada_List then
Find_Non_Contained_Sub_List (Node, RFR.F_Find_Pattern)
else Find_Non_Contained_Full (Node, RFR.F_Find_Pattern));
Contexts : constant Node_List.Vector :=
Make_Contexts (Matches, RFR.F_Match_Accepter, RFR.F_Rewriters);
begin
for Context of Contexts loop
declare
Supported_Context : constant Ada_Node :=
To_Supported_Context (Context);
TR : Text_Rewrite := Make_Text_Rewrite_Node (Supported_Context);
begin
Find_And_Replace
(TR, Supported_Context, RFR.F_Find_Pattern,
RFR.F_Replace_Pattern, RFR.F_Match_Accepter);
declare
Rule : constant Grammar_Rule :=
Node_To_Rule (Supported_Context);
Match_Unit : constant Analysis_Unit :=
Analyze_Fragment (TR.ApplyToString, Rule);
Rewritten_Instance : constant String :=
Rewrite (RFR.F_Rewriters, Match_Unit.Root, False, Rule);
begin
TN.Replace (Supported_Context, Rewritten_Instance);
if Top_Level then
Surround_Node_By_Pretty_Print_Section
(TN, Supported_Context);
end if;
end;
exception
when others =>
Put_Line
(Image (Supported_Context.Full_Sloc_Image) &
"Error in Context");
raise;
end;
end loop;
return TN.ApplyToString;
exception
when Error : others =>
Put_Line
("Error in Rewrite - Rewriter_Find_And_Replace " &
Exception_Message (Error));
raise;
end Rewrite;
overriding function Rewrite_Context
(RFR : Rewriter_Find_And_Replace; Node : Ada_Node'Class) return Ada_Node
is
begin
return Rewrite_Context (RFR.F_Rewriters, Node);
end Rewrite_Context;
end Rewriters_Find_And_Replace;
|
package Bitmap_Store is
type Luminance is mod 2**8;
type Pixel is record
R, G, B : Luminance;
end record;
Black : constant Pixel := (others => 0);
White : constant Pixel := (others => 255);
type Image is array (Positive range <>, Positive range <>) of Pixel;
procedure Fill (Picture : in out Image; Color : Pixel);
procedure Print (Picture : Image);
type Point is record
X, Y : Positive;
end record;
end Bitmap_Store;
|
package Aliasing3_Pkg is
type Arr is array (1..3) of Integer;
procedure Test (A : Arr);
pragma Inline (Test);
type My_Arr is new Arr;
type Rec is record
A : My_Arr;
end record;
type Ptr is access all Rec;
Block : aliased Rec;
Pointer : Ptr := Block'Access;
end Aliasing3_Pkg;
|
pragma License (Unrestricted);
with System.WCh_Con;
with GNAT.Encode_String;
package GNAT.Encode_UTF8_String is
new GNAT.Encode_String (System.WCh_Con.WCEM_UTF8);
pragma Pure (GNAT.Encode_UTF8_String);
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ E L A B --
-- --
-- S p e c --
-- --
-- Copyright (C) 1997-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the routines used to deal with issuing warnings
-- for cases of calls that may require warnings about possible access
-- before elaboration.
with Types; use Types;
package Sem_Elab is
-----------------------------
-- Description of Approach --
-----------------------------
-- Every non-static call that is encountered by Sem_Res results in a call
-- to Check_Elab_Call, with N being the call node, and Outer set to its
-- default value of True. In addition X'Access is treated like a call
-- for the access-to-procedure case, and in SPARK mode only we also
-- check variable references.
-- The goal of Check_Elab_Call is to determine whether or not the reference
-- in question can generate an access before elaboration error (raising
-- Program_Error) either by directly calling a subprogram whose body
-- has not yet been elaborated, or indirectly, by calling a subprogram
-- whose body has been elaborated, but which contains a call to such a
-- subprogram.
-- In addition, in SPARK mode, we are checking for a variable reference in
-- another package, which requires an explicit Elaborate_All pragma.
-- The only references that we need to look at the outer level are
-- references that occur in elaboration code. There are two cases. The
-- reference can be at the outer level of elaboration code, or it can
-- be within another unit, e.g. the elaboration code of a subprogram.
-- In the case of an elaboration call at the outer level, we must trace
-- all calls to outer level routines either within the current unit or to
-- other units that are with'ed. For calls within the current unit, we can
-- determine if the body has been elaborated or not, and if it has not,
-- then a warning is generated.
-- Note that there are two subcases. If the original call directly calls a
-- subprogram whose body has not been elaborated, then we know that an ABE
-- will take place, and we replace the call by a raise of Program_Error.
-- If the call is indirect, then we don't know that the PE will be raised,
-- since the call might be guarded by a conditional. In this case we set
-- Do_Elab_Check on the call so that a dynamic check is generated, and
-- output a warning.
-- For calls to a subprogram in a with'ed unit or a 'Access or variable
-- refernece (SPARK mode case), we require that a pragma Elaborate_All
-- or pragma Elaborate be present, or that the referenced unit have a
-- pragma Preelaborate, pragma Pure, or pragma Elaborate_Body. If none
-- of these conditions is met, then a warning is generated that a pragma
-- Elaborate_All may be needed (error in the SPARK case), or an implicit
-- pragma is generated.
-- For the case of an elaboration call at some inner level, we are
-- interested in tracing only calls to subprograms at the same level,
-- i.e. those that can be called during elaboration. Any calls to
-- outer level routines cannot cause ABE's as a result of the original
-- call (there might be an outer level call to the subprogram from
-- outside that causes the ABE, but that gets analyzed separately).
-- Note that we never trace calls to inner level subprograms, since
-- these cannot result in ABE's unless there is an elaboration problem
-- at a lower level, which will be separately detected.
-- Note on pragma Elaborate. The checking here assumes that a pragma
-- Elaborate on a with'ed unit guarantees that subprograms within the
-- unit can be called without causing an ABE. This is not in fact the
-- case since pragma Elaborate does not guarantee the transitive
-- coverage guaranteed by Elaborate_All. However, we decide to trust
-- the user in this case.
--------------------------------------
-- Instantiation Elaboration Errors --
--------------------------------------
-- A special case arises when an instantiation appears in a context
-- that is known to be before the body is elaborated, e.g.
-- generic package x is ...
-- ...
-- package xx is new x;
-- ...
-- package body x is ...
-- In this situation it is certain that an elaboration error will
-- occur, and an unconditional raise Program_Error statement is
-- inserted before the instantiation, and a warning generated.
-- The problem is that in this case we have no place to put the
-- body of the instantiation. We can't put it in the normal place,
-- because it is too early, and will cause errors to occur as a
-- result of referencing entities before they are declared.
-- Our approach in this case is simply to avoid creating the body
-- of the instantiation in such a case. The instantiation spec is
-- modified to include dummy bodies for all subprograms, so that
-- the resulting code does not contain subprogram specs with no
-- corresponding bodies.
procedure Check_Elab_Call
(N : Node_Id;
Outer_Scope : Entity_Id := Empty;
In_Init_Proc : Boolean := False);
-- Check a call for possible elaboration problems. The node N is either an
-- N_Function_Call or N_Procedure_Call_Statement node or an access
-- attribute reference whose prefix is a subprogram.
--
-- If SPARK_Mode is On, then N can also be a variablr reference, since
-- SPARK requires the use of Elaborate_All for references to variables
-- in other packages.
-- The Outer_Scope argument indicates whether this is an outer level
-- call from Sem_Res (Outer_Scope set to Empty), or an internal recursive
-- call (Outer_Scope set to entity of outermost call, see body). The flag
-- In_Init_Proc should be set whenever the current context is a type
-- init proc.
-- Note: this might better be called Check_Elab_Reference (to recognize
-- the SPARK case), but we prefer to keep the original name, since this
-- is primarily used for checking for calls that could generate an ABE).
procedure Check_Elab_Calls;
-- Not all the processing for Check_Elab_Call can be done at the time
-- of calls to Check_Elab_Call. This is because for internal calls, we
-- need to wait to complete the check until all generic bodies have been
-- instantiated. The Check_Elab_Calls procedure cleans up these waiting
-- checks. It is called once after the completion of instantiation.
procedure Check_Elab_Assign (N : Node_Id);
-- N is either the left side of an assignment, or a procedure argument for
-- a mode OUT or IN OUT formal. This procedure checks for a possible case
-- of access to an entity from elaboration code before the entity has been
-- initialized, and issues appropriate warnings.
procedure Check_Elab_Instantiation
(N : Node_Id;
Outer_Scope : Entity_Id := Empty);
-- Check an instantiation for possible elaboration problems. N is an
-- instantiation node (N_Package_Instantiation, N_Function_Instantiation,
-- or N_Procedure_Instantiation), and Outer_Scope indicates if this is
-- an outer level call from Sem_Ch12 (Outer_Scope set to Empty), or an
-- internal recursive call (Outer_Scope set to scope of outermost call,
-- see body for further details). The returned value is relevant only
-- for an outer level call, and is set to False if an elaboration error
-- is bound to occur on the instantiation, and True otherwise. This is
-- used by the caller to signal that the body of the instance should
-- not be generated (see detailed description in body).
procedure Check_Task_Activation (N : Node_Id);
-- Tt the point at which tasks are activated in a package body, check
-- that the bodies of the tasks are elaborated.
end Sem_Elab;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . S T A G E S --
-- --
-- S p e c --
-- --
-- $Revision: 2 $ --
-- --
-- Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved --
-- --
-- GNARL 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. GNARL is distributed in the hope that it will be use- --
-- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- --
-- eral Library Public License for more details. You should have received --
-- a copy of the GNU Library General Public License along with GNARL; see --
-- file COPYING.LIB. If not, write to the Free Software Foundation, 675 --
-- Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
package System.Tasking.Stages is
-- This interface is described in the document
-- Gnu Ada Runtime Library Interface (GNARLI).
pragma Elaborate_Body (System.Tasking.Stages);
function Current_Master return Master_ID;
procedure Enter_Master;
procedure Complete_Master;
procedure Create_Task
(Size : Size_Type;
Priority : Integer;
Num_Entries : Task_Entry_Index;
Master : Master_ID;
State : Task_Procedure_Access;
Discriminants : System.Address;
Elaborated : Access_Boolean;
Chain : in out Activation_Chain;
Created_Task : out Task_ID);
procedure Activate_Tasks (Chain_Access : Activation_Chain_Access);
procedure Expunge_Unactivated_Tasks (Chain : in out Activation_Chain);
procedure Complete_Activation;
procedure Complete_Task;
function Terminated (T : Task_ID) return Boolean;
-------------------------------
-- RTS Internal Declarations --
-------------------------------
-- These declarations are not part of the GNARLI.
procedure Leave_Task;
-- Export for abortion
procedure Init_Master (M : out Master_ID);
pragma Inline (Init_Master);
function Increment_Master (M : Master_ID) return Master_ID;
pragma Inline (Increment_Master);
function Decrement_Master (M : Master_ID) return Master_ID;
pragma Inline (Decrement_Master);
end System.Tasking.Stages;
|
with LATIN_FILE_NAMES; use LATIN_FILE_NAMES;
with PREFACE;
package body INFLECTIONS_PACKAGE is
use TEXT_IO;
function "<" (LEFT, RIGHT : DECN_RECORD) return BOOLEAN is
begin
if LEFT.WHICH < RIGHT.WHICH or else
(LEFT.WHICH = RIGHT.WHICH and then
LEFT.VAR < RIGHT.VAR) then
return TRUE;
else
return FALSE;
end if;
end "<";
function "<" (LEFT, RIGHT : QUALITY_RECORD) return BOOLEAN is
begin
if LEFT.POFS = RIGHT.POFS then
case LEFT.POFS is
when N =>
if LEFT.N.DECL.WHICH < RIGHT.N.DECL.WHICH or else
(LEFT.N.DECL.WHICH = RIGHT.N.DECL.WHICH and then
LEFT.N.DECL.VAR < RIGHT.N.DECL.VAR) or else
(LEFT.N.DECL.WHICH = RIGHT.N.DECL.WHICH and then
LEFT.N.DECL.VAR = RIGHT.N.DECL.VAR and then
LEFT.N.NUMBER < RIGHT.N.NUMBER) or else
(LEFT.N.DECL.WHICH = RIGHT.N.DECL.WHICH and then
LEFT.N.DECL.VAR = RIGHT.N.DECL.VAR and then
LEFT.N.NUMBER = RIGHT.N.NUMBER and then
LEFT.N.CS < RIGHT.N.CS) or else
(LEFT.N.DECL.WHICH = RIGHT.N.DECL.WHICH and then
LEFT.N.DECL.VAR = RIGHT.N.DECL.VAR and then
LEFT.N.NUMBER = RIGHT.N.NUMBER and then
LEFT.N.CS = RIGHT.N.CS and then
LEFT.N.GENDER < RIGHT.N.GENDER) then
return TRUE;
end if;
when PRON =>
if LEFT.PRON.DECL.WHICH < RIGHT.PRON.DECL.WHICH or else
(LEFT.PRON.DECL.WHICH = RIGHT.PRON.DECL.WHICH and then
LEFT.PRON.DECL.VAR < RIGHT.PRON.DECL.VAR) or else
(LEFT.PRON.DECL.WHICH = RIGHT.PRON.DECL.WHICH and then
LEFT.PRON.DECL.VAR = RIGHT.PRON.DECL.VAR and then
LEFT.PRON.NUMBER < RIGHT.PRON.NUMBER) or else
(LEFT.PRON.DECL.WHICH = RIGHT.PRON.DECL.WHICH and then
LEFT.PRON.DECL.VAR = RIGHT.PRON.DECL.VAR and then
LEFT.PRON.NUMBER = RIGHT.PRON.NUMBER and then
LEFT.PRON.CS < RIGHT.PRON.CS) or else
(LEFT.PRON.DECL.WHICH = RIGHT.PRON.DECL.WHICH and then
LEFT.PRON.DECL.VAR = RIGHT.PRON.DECL.VAR and then
LEFT.PRON.NUMBER = RIGHT.PRON.NUMBER and then
LEFT.PRON.CS = RIGHT.PRON.CS and then
LEFT.PRON.GENDER < RIGHT.PRON.GENDER) then
return TRUE;
end if;
when PACK =>
if LEFT.PACK.DECL.WHICH < RIGHT.PACK.DECL.WHICH or else
(LEFT.PACK.DECL.WHICH = RIGHT.PACK.DECL.WHICH and then
LEFT.PACK.DECL.VAR < RIGHT.PACK.DECL.VAR) or else
(LEFT.PACK.DECL.WHICH = RIGHT.PACK.DECL.WHICH and then
LEFT.PACK.DECL.VAR = RIGHT.PACK.DECL.VAR and then
LEFT.PACK.NUMBER < RIGHT.PACK.NUMBER) or else
(LEFT.PACK.DECL.WHICH = RIGHT.PACK.DECL.WHICH and then
LEFT.PACK.DECL.VAR = RIGHT.PACK.DECL.VAR and then
LEFT.PACK.NUMBER = RIGHT.PACK.NUMBER and then
LEFT.PACK.CS < RIGHT.PACK.CS) or else
(LEFT.PACK.DECL.WHICH = RIGHT.PACK.DECL.WHICH and then
LEFT.PACK.DECL.VAR = RIGHT.PACK.DECL.VAR and then
LEFT.PACK.NUMBER = RIGHT.PACK.NUMBER and then
LEFT.PACK.CS = RIGHT.PACK.CS and then
LEFT.PACK.GENDER < RIGHT.PACK.GENDER) then
return TRUE;
end if;
when ADJ =>
if LEFT.ADJ.DECL.WHICH < RIGHT.ADJ.DECL.WHICH or else
(LEFT.ADJ.DECL.WHICH = RIGHT.ADJ.DECL.WHICH and then
LEFT.ADJ.DECL.VAR < RIGHT.ADJ.DECL.VAR) or else
(LEFT.ADJ.DECL.WHICH = RIGHT.ADJ.DECL.WHICH and then
LEFT.ADJ.DECL.VAR = RIGHT.ADJ.DECL.VAR and then
LEFT.ADJ.NUMBER < RIGHT.ADJ.NUMBER) or else
(LEFT.ADJ.DECL.WHICH = RIGHT.ADJ.DECL.WHICH and then
LEFT.ADJ.DECL.VAR = RIGHT.ADJ.DECL.VAR and then
LEFT.ADJ.NUMBER = RIGHT.ADJ.NUMBER and then
LEFT.ADJ.CS < RIGHT.ADJ.CS) or else
(LEFT.ADJ.DECL.WHICH = RIGHT.ADJ.DECL.WHICH and then
LEFT.ADJ.DECL.VAR = RIGHT.ADJ.DECL.VAR and then
LEFT.ADJ.NUMBER = RIGHT.ADJ.NUMBER and then
LEFT.ADJ.CS = RIGHT.ADJ.CS and then
LEFT.ADJ.GENDER < RIGHT.ADJ.GENDER) or else
(LEFT.ADJ.DECL.WHICH = RIGHT.ADJ.DECL.WHICH and then
LEFT.ADJ.DECL.VAR = RIGHT.ADJ.DECL.VAR and then
LEFT.ADJ.NUMBER = RIGHT.ADJ.NUMBER and then
LEFT.ADJ.CS = RIGHT.ADJ.CS and then
LEFT.ADJ.GENDER = RIGHT.ADJ.GENDER and then
LEFT.ADJ.CO < RIGHT.ADJ.CO) then
return TRUE;
end if;
when ADV =>
return LEFT.ADV.CO < RIGHT.ADV.CO;
when V =>
if (LEFT.V.CON.WHICH < RIGHT.V.CON.WHICH) or else
(LEFT.V.CON.WHICH = RIGHT.V.CON.WHICH and then
LEFT.V.CON.VAR < RIGHT.V.CON.VAR) or else
(LEFT.V.CON.WHICH = RIGHT.V.CON.WHICH and then
LEFT.V.CON.VAR = RIGHT.V.CON.VAR and then
LEFT.V.NUMBER < RIGHT.V.NUMBER) or else
(LEFT.V.CON.WHICH = RIGHT.V.CON.WHICH and then
LEFT.V.CON.VAR = RIGHT.V.CON.VAR and then
LEFT.V.NUMBER = RIGHT.V.NUMBER and then
LEFT.V.TENSE_VOICE_MOOD.TENSE < RIGHT.V.TENSE_VOICE_MOOD.TENSE) or else
(LEFT.V.CON.WHICH = RIGHT.V.CON.WHICH and then
LEFT.V.CON.VAR = RIGHT.V.CON.VAR and then
LEFT.V.NUMBER = RIGHT.V.NUMBER and then
LEFT.V.TENSE_VOICE_MOOD.TENSE = RIGHT.V.TENSE_VOICE_MOOD.TENSE and then
LEFT.V.TENSE_VOICE_MOOD.VOICE < RIGHT.V.TENSE_VOICE_MOOD.VOICE) or else
(LEFT.V.CON.WHICH = RIGHT.V.CON.WHICH and then
LEFT.V.CON.VAR = RIGHT.V.CON.VAR and then
LEFT.V.NUMBER = RIGHT.V.NUMBER and then
LEFT.V.TENSE_VOICE_MOOD.TENSE = RIGHT.V.TENSE_VOICE_MOOD.TENSE and then
LEFT.V.TENSE_VOICE_MOOD.VOICE = RIGHT.V.TENSE_VOICE_MOOD.VOICE and then
LEFT.V.TENSE_VOICE_MOOD.MOOD < RIGHT.V.TENSE_VOICE_MOOD.MOOD ) or else
(LEFT.V.CON.WHICH = RIGHT.V.CON.WHICH and then
LEFT.V.CON.VAR = RIGHT.V.CON.VAR and then
LEFT.V.NUMBER = RIGHT.V.NUMBER and then
LEFT.V.TENSE_VOICE_MOOD.TENSE = RIGHT.V.TENSE_VOICE_MOOD.TENSE and then
LEFT.V.TENSE_VOICE_MOOD.VOICE = RIGHT.V.TENSE_VOICE_MOOD.VOICE and then
LEFT.V.TENSE_VOICE_MOOD.MOOD = RIGHT.V.TENSE_VOICE_MOOD.MOOD and then
LEFT.V.PERSON < RIGHT.V.PERSON) then
return TRUE;
end if;
when VPAR =>
if LEFT.VPAR.CON.WHICH < RIGHT.VPAR.CON.WHICH or else
(LEFT.VPAR.CON.WHICH = RIGHT.VPAR.CON.WHICH and then
LEFT.VPAR.CON.VAR < RIGHT.VPAR.CON.VAR) or else
(LEFT.VPAR.CON.WHICH = RIGHT.VPAR.CON.WHICH and then
LEFT.VPAR.CON.VAR = RIGHT.VPAR.CON.VAR and then
LEFT.VPAR.NUMBER < RIGHT.VPAR.NUMBER) or else
(LEFT.VPAR.CON.WHICH = RIGHT.VPAR.CON.WHICH and then
LEFT.VPAR.CON.VAR = RIGHT.VPAR.CON.VAR and then
LEFT.VPAR.NUMBER = RIGHT.VPAR.NUMBER and then
LEFT.VPAR.CS < RIGHT.VPAR.CS) or else
(LEFT.VPAR.CON.WHICH = RIGHT.VPAR.CON.WHICH and then
LEFT.VPAR.CON.VAR = RIGHT.VPAR.CON.VAR and then
LEFT.VPAR.NUMBER = RIGHT.VPAR.NUMBER and then
LEFT.VPAR.CS = RIGHT.VPAR.CS and then
LEFT.VPAR.GENDER < RIGHT.VPAR.GENDER) then
return TRUE;
end if;
when SUPINE =>
if LEFT.SUPINE.CON.WHICH < RIGHT.SUPINE.CON.WHICH or else
(LEFT.SUPINE.CON.WHICH = RIGHT.SUPINE.CON.WHICH and then
LEFT.SUPINE.CON.VAR < RIGHT.SUPINE.CON.VAR) or else
(LEFT.SUPINE.CON.WHICH = RIGHT.SUPINE.CON.WHICH and then
LEFT.SUPINE.CON.VAR = RIGHT.SUPINE.CON.VAR and then
LEFT.SUPINE.NUMBER < RIGHT.SUPINE.NUMBER) or else
(LEFT.SUPINE.CON.WHICH = RIGHT.SUPINE.CON.WHICH and then
LEFT.SUPINE.CON.VAR = RIGHT.SUPINE.CON.VAR and then
LEFT.SUPINE.NUMBER = RIGHT.SUPINE.NUMBER and then
LEFT.SUPINE.CS < RIGHT.SUPINE.CS) or else
(LEFT.SUPINE.CON.WHICH = RIGHT.SUPINE.CON.WHICH and then
LEFT.SUPINE.CON.VAR = RIGHT.SUPINE.CON.VAR and then
LEFT.SUPINE.NUMBER = RIGHT.SUPINE.NUMBER and then
LEFT.SUPINE.CS = RIGHT.SUPINE.CS and then
LEFT.SUPINE.GENDER < RIGHT.SUPINE.GENDER) then
return TRUE;
end if;
when PREP =>
return LEFT.PREP.OBJ < RIGHT.PREP.OBJ;
when CONJ =>
null;
when INTERJ =>
null;
when NUM =>
if LEFT.NUM.DECL.WHICH < RIGHT.NUM.DECL.WHICH or else
(LEFT.NUM.DECL.WHICH = RIGHT.NUM.DECL.WHICH and then
LEFT.NUM.DECL.VAR < RIGHT.NUM.DECL.VAR) or else
(LEFT.NUM.DECL.WHICH = RIGHT.NUM.DECL.WHICH and then
LEFT.NUM.DECL.VAR = RIGHT.NUM.DECL.VAR and then
LEFT.NUM.NUMBER < RIGHT.NUM.NUMBER) or else
(LEFT.NUM.DECL.WHICH = RIGHT.NUM.DECL.WHICH and then
LEFT.NUM.DECL.VAR = RIGHT.NUM.DECL.VAR and then
LEFT.NUM.NUMBER = RIGHT.NUM.NUMBER and then
LEFT.NUM.CS < RIGHT.NUM.CS) or else
(LEFT.NUM.DECL.WHICH = RIGHT.NUM.DECL.WHICH and then
LEFT.NUM.DECL.VAR = RIGHT.NUM.DECL.VAR and then
LEFT.NUM.NUMBER = RIGHT.NUM.NUMBER and then
LEFT.NUM.CS = RIGHT.NUM.CS and then
LEFT.NUM.GENDER < RIGHT.NUM.GENDER) or else
(LEFT.NUM.DECL.WHICH = RIGHT.NUM.DECL.WHICH and then
LEFT.NUM.DECL.VAR = RIGHT.NUM.DECL.VAR and then
LEFT.NUM.NUMBER = RIGHT.NUM.NUMBER and then
LEFT.NUM.CS = RIGHT.NUM.CS and then
LEFT.NUM.GENDER = RIGHT.NUM.GENDER and then
LEFT.NUM.SORT < RIGHT.NUM.SORT) then
return TRUE;
end if;
when TACKON =>
null;
when PREFIX =>
null;
when SUFFIX =>
null;
when others =>
null;
end case;
else
return LEFT.POFS < RIGHT.POFS;
end if;
return FALSE;
exception
when CONSTRAINT_ERROR =>
return LEFT.POFS < RIGHT.POFS;
end "<";
function "<=" (LEFT, RIGHT : PART_OF_SPEECH_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
(LEFT = PACK and RIGHT = PRON) or else
RIGHT = X then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : DECN_RECORD) return BOOLEAN is
begin
if RIGHT = LEFT or else
(RIGHT = DECN_RECORD'(0, 0) and LEFT.WHICH /= 9) or else
RIGHT = DECN_RECORD'(LEFT.WHICH, 0) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : GENDER_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = X or else
(RIGHT = C and then (LEFT = M or LEFT = F)) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : CASE_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = X then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : NUMBER_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = X then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : PERSON_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = 0 then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : COMPARISON_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = X then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : TENSE_VOICE_MOOD_RECORD) return BOOLEAN is
begin
if (RIGHT.TENSE = LEFT.TENSE or else
RIGHT.TENSE = X) and then
(RIGHT.VOICE = LEFT.VOICE or else
RIGHT.VOICE = X) and then
(RIGHT.MOOD = LEFT.MOOD or else
RIGHT.MOOD = X) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : NOUN_KIND_TYPE) return BOOLEAN is
begin
if (RIGHT = LEFT or else
RIGHT = X) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : PRONOUN_KIND_TYPE) return BOOLEAN is
begin
if (RIGHT = LEFT or else
RIGHT = X) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : VERB_KIND_TYPE) return BOOLEAN is
begin
if (RIGHT = LEFT or else
RIGHT = X) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : NUMERAL_SORT_TYPE) return BOOLEAN is
begin
if (RIGHT = LEFT or else
RIGHT = X) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : STEM_KEY_TYPE) return BOOLEAN is
begin -- Only works for 2 stem parts, not verbs
if (RIGHT = LEFT or else
RIGHT = 0) then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : AGE_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = X then
return TRUE;
else
return FALSE;
end if;
end "<=";
function "<=" (LEFT, RIGHT : FREQUENCY_TYPE) return BOOLEAN is
begin
if RIGHT = LEFT or else
RIGHT = X then
return TRUE;
else
return FALSE;
end if;
end "<=";
package body STEM_TYPE_IO is
procedure GET(F : in FILE_TYPE; D : out STEM_TYPE) is
C : CHARACTER := ' ';
begin
D := NULL_STEM_TYPE;
for I in 1..STEM_TYPE_IO.DEFAULT_WIDTH loop
GET(F, C);
if (C not in 'A'..'Z') and (C not in 'a'..'z') then
exit;
else
D(I) := C;
end if;
end loop;
end GET;
procedure GET(D : out STEM_TYPE) is
C : CHARACTER := ' ';
begin
D := NULL_STEM_TYPE;
for I in 1..STEM_TYPE_IO.DEFAULT_WIDTH loop
TEXT_IO.GET(C);
if (C not in 'A'..'Z') and (C not in 'a'..'z') then
exit;
else
D(I) := C;
end if;
end loop;
end GET;
procedure PUT(F : in FILE_TYPE; D : in STEM_TYPE) is
begin
TEXT_IO.PUT(F, D);
end PUT;
procedure PUT(D : in STEM_TYPE) is
begin
TEXT_IO.PUT(D);
end PUT;
procedure GET(S : in STRING; D : out STEM_TYPE;
LAST : out INTEGER) is
C : CHARACTER;
begin
D := NULL_STEM_TYPE;
LAST := 0;
for I in 1..STEM_TYPE_IO.DEFAULT_WIDTH loop
C := S(I);
if (C not in 'A'..'Z') and (C not in 'a'..'z') then
exit;
else
D(I) := C;
LAST := I;
end if;
end loop;
end GET;
procedure PUT(S : out STRING; D : in STEM_TYPE) is
begin
S(S'FIRST..S'FIRST+STEM_TYPE_IO.DEFAULT_WIDTH-1) := D;
end PUT;
end STEM_TYPE_IO;
package body DECN_RECORD_IO is
-- This package will carry the documentation for all the following packages
-- Must have "use" for _IO for each of the components of the record
use INTEGER_IO;
-- This is a dummy used to GET the space character PUT between components
SPACER : CHARACTER := ' ';
-- The standard 6 procedures are defined as in TEXT_IO
procedure GET(F : in FILE_TYPE; D : out DECN_RECORD) is
-- Get from a file
begin
-- Get the first component
GET(F, D.WHICH);
-- Then Get (and ignore) space character which is Put between components
GET(F, SPACER);
-- Get the next component
GET(F, D.VAR);
end GET;
procedure GET(D : out DECN_RECORD) is
-- Get from the current input, in the same manner
begin
GET(D.WHICH);
GET(SPACER);
GET(D.VAR);
end GET;
procedure PUT(F : in FILE_TYPE; D : in DECN_RECORD) is
-- Put to a file
begin
-- Put the first component, with whatever Put is applicable (and use'd)
PUT(F, D.WHICH, 1);
-- Put the blank character between components
PUT(F, ' ');
-- Put the next component
PUT(F, D.VAR, 1);
end PUT;
procedure PUT(D : in DECN_RECORD) is
-- Likewise for Put to current output
begin
PUT(D.WHICH, 1);
PUT(' ');
PUT(D.VAR, 1);
end PUT;
procedure GET(S : in STRING;
D : out DECN_RECORD; LAST : out INTEGER) is
-- Get from a string
-- Initialize the string position parameter
-- Make it first-1 so the first string specification looks like later ones
L : INTEGER := S'FIRST - 1;
begin
-- Get with the use'd _IO package the first component
GET(S(L+1..S'LAST), D.WHICH, L);
-- The L is the last position read, so add one to skip the spacer
L := L + 1;
-- Get the next component
GET(S(L+1..S'LAST), D.VAR, LAST);
end GET;
procedure PUT(S : out STRING; D : in DECN_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
-- Make a place the DEFAULT_WIDTH of the component to be Put
-- The DEFAULT_WIDTH has been set for these _IO packages to be
-- the LONGEST component width, not the normal Ada default
M := L + 1; -- But WHICH is to be PUT WIDTH 1
-- Put onto the substring that is exactly the DEFAULT (LONGEST) size
PUT(S(L+1..M), D.WHICH);
-- Advance the position by 1 to the position to make the blank
L := M + 1;
-- Write the blank
S(L) := ' ';
-- Calculate the next substring, of DEFAULT_WIDTH for next component
M := L + 1;
-- Put the next component
PUT(S(L+1..M), D.VAR);
-- The following may be necessary to fill the out string
-- but usually the out string has been specified exactly
S(M+1..S'LAST) := (others => ' ');
end PUT;
end DECN_RECORD_IO;
package body TENSE_VOICE_MOOD_RECORD_IO is
use TENSE_TYPE_IO;
use VOICE_TYPE_IO;
use MOOD_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; T : out TENSE_VOICE_MOOD_RECORD) is
begin
GET(F, T.TENSE);
GET(F, SPACER);
GET(F, T.VOICE);
GET(F, SPACER);
GET(F, T.MOOD);
end GET;
procedure GET(T : out TENSE_VOICE_MOOD_RECORD) is
begin
GET(T.TENSE);
GET(SPACER);
GET(T.VOICE);
GET(SPACER);
GET(T.MOOD);
end GET;
procedure PUT(F : in FILE_TYPE; T : in TENSE_VOICE_MOOD_RECORD) is
begin
PUT(F, T.TENSE);
PUT(F, ' ');
PUT(F, T.VOICE);
PUT(F, ' ');
PUT(F, T.MOOD);
end PUT;
procedure PUT(T : in TENSE_VOICE_MOOD_RECORD) is
begin
PUT(T.TENSE);
PUT(' ');
PUT(T.VOICE);
PUT(' ');
PUT(T.MOOD);
end PUT;
procedure GET(S : in STRING;
T : out TENSE_VOICE_MOOD_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), T.TENSE, L);
L := L + 1;
GET(S(L+1..S'LAST), T.VOICE, L);
L := L + 1;
GET(S(L+1..S'LAST), T.MOOD, LAST);
end GET;
procedure PUT(S : out STRING; T : in TENSE_VOICE_MOOD_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + TENSE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), T.TENSE);
L := M + 1;
S(L) := ' ';
M := L + VOICE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), T.VOICE);
L := M + 1;
S(L) := ' ';
M := L + MOOD_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), T.MOOD);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end TENSE_VOICE_MOOD_RECORD_IO;
package body NOUN_RECORD_IO is
use DECN_RECORD_IO;
use CASE_TYPE_IO;
use GENDER_TYPE_IO;
use NUMBER_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; N : out NOUN_RECORD) is
begin
GET(F, N.DECL);
GET(F, SPACER);
GET(F, N.CS);
GET(F, SPACER);
GET(F, N.NUMBER);
GET(F, SPACER);
GET(F, N.GENDER);
end GET;
procedure GET(N : out NOUN_RECORD) is
begin
GET(N.DECL);
GET(SPACER);
GET(N.CS);
GET(SPACER);
GET(N.NUMBER);
GET(SPACER);
GET(N.GENDER);
end GET;
procedure PUT(F : in FILE_TYPE; N : in NOUN_RECORD) is
begin
PUT(F, N.DECL);
PUT(F, ' ');
PUT(F, N.CS);
PUT(F, ' ');
PUT(F, N.NUMBER);
PUT(F, ' ');
PUT(F, N.GENDER);
end PUT;
procedure PUT(N : in NOUN_RECORD) is
begin
PUT(N.DECL);
PUT(' ');
PUT(N.CS);
PUT(' ');
PUT(N.NUMBER);
PUT(' ');
PUT(N.GENDER);
end PUT;
procedure GET(S : in STRING; N : out NOUN_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), N.DECL, L);
L := L + 1;
GET(S(L+1..S'LAST), N.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), N.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), N.GENDER, LAST);
end GET;
procedure PUT(S : out STRING; N : in NOUN_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), N.DECL);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), N.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), N.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), N.GENDER);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end NOUN_RECORD_IO;
package body PRONOUN_RECORD_IO is
use DECN_RECORD_IO;
use CASE_TYPE_IO;
use GENDER_TYPE_IO;
use NUMBER_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; P : out PRONOUN_RECORD) is
begin
GET(F, P.DECL);
GET(F, SPACER);
GET(F, P.CS);
GET(F, SPACER);
GET(F, P.NUMBER);
GET(F, SPACER);
GET(F, P.GENDER);
end GET;
procedure GET(P : out PRONOUN_RECORD) is
begin
GET(P.DECL);
GET(SPACER);
GET(P.CS);
GET(SPACER);
GET(P.NUMBER);
GET(SPACER);
GET(P.GENDER);
end GET;
procedure PUT(F : in FILE_TYPE; P : in PRONOUN_RECORD) is
begin
PUT(F, P.DECL);
PUT(F, ' ');
PUT(F, P.CS);
PUT(F, ' ');
PUT(F, P.NUMBER);
PUT(F, ' ');
PUT(F, P.GENDER);
end PUT;
procedure PUT(P : in PRONOUN_RECORD) is
begin
PUT(P.DECL);
PUT(' ');
PUT(P.CS);
PUT(' ');
PUT(P.NUMBER);
PUT(' ');
PUT(P.GENDER);
end PUT;
procedure GET(S : in STRING; P : out PRONOUN_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), P.DECL, L);
L := L + 1;
GET(S(L+1..S'LAST), P.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), P.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), P.GENDER, LAST);
end GET;
procedure PUT(S : out STRING; P : in PRONOUN_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.DECL);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.GENDER);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end PRONOUN_RECORD_IO;
package body PROPACK_RECORD_IO is
use DECN_RECORD_IO;
use CASE_TYPE_IO;
use NUMBER_TYPE_IO;
use GENDER_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; P : out PROPACK_RECORD) is
begin
GET(F, P.DECL);
GET(F, SPACER);
GET(F, P.CS);
GET(F, SPACER);
GET(F, P.NUMBER);
GET(F, SPACER);
GET(F, P.GENDER);
end GET;
procedure GET(P : out PROPACK_RECORD) is
begin
GET(P.DECL);
GET(SPACER);
GET(P.CS);
GET(SPACER);
GET(P.NUMBER);
GET(SPACER);
GET(P.GENDER);
end GET;
procedure PUT(F : in FILE_TYPE; P : in PROPACK_RECORD) is
begin
PUT(F, P.DECL);
PUT(F, ' ');
PUT(F, P.CS);
PUT(F, ' ');
PUT(F, P.NUMBER);
PUT(F, ' ');
PUT(F, P.GENDER);
end PUT;
procedure PUT(P : in PROPACK_RECORD) is
begin
PUT(P.DECL);
PUT(' ');
PUT(P.CS);
PUT(' ');
PUT(P.NUMBER);
PUT(' ');
PUT(P.GENDER);
end PUT;
procedure GET(S : in STRING; P : out PROPACK_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), P.DECL, L);
L := L + 1;
GET(S(L+1..S'LAST), P.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), P.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), P.GENDER, LAST);
end GET;
procedure PUT(S : out STRING; P : in PROPACK_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.DECL);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.GENDER);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end PROPACK_RECORD_IO;
package body ADJECTIVE_RECORD_IO is
use DECN_RECORD_IO;
use GENDER_TYPE_IO;
use CASE_TYPE_IO;
use NUMBER_TYPE_IO;
use COMPARISON_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; A : out ADJECTIVE_RECORD) is
begin
GET(F, A.DECL);
GET(F, SPACER);
GET(F, A.CS);
GET(F, SPACER);
GET(F, A.NUMBER);
GET(F, SPACER);
GET(F, A.GENDER);
GET(F, SPACER);
GET(F, A.CO);
end GET;
procedure GET(A : out ADJECTIVE_RECORD) is
begin
GET(A.DECL);
GET(SPACER);
GET(A.CS);
GET(SPACER);
GET(A.NUMBER);
GET(SPACER);
GET(A.GENDER);
GET(SPACER);
GET(A.CO);
end GET;
procedure PUT(F : in FILE_TYPE; A : in ADJECTIVE_RECORD) is
begin
PUT(F, A.DECL);
PUT(F, ' ');
PUT(F, A.CS);
PUT(F, ' ');
PUT(F, A.NUMBER);
PUT(F, ' ');
PUT(F, A.GENDER);
PUT(F, ' ');
PUT(F, A.CO);
end PUT;
procedure PUT(A : in ADJECTIVE_RECORD) is
begin
PUT(A.DECL);
PUT(' ');
PUT(A.CS);
PUT(' ');
PUT(A.NUMBER);
PUT(' ');
PUT(A.GENDER);
PUT(' ');
PUT(A.CO);
end PUT;
procedure GET(S : in STRING; A : out ADJECTIVE_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), A.DECL, L);
L := L + 1;
GET(S(L+1..S'LAST), A.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), A.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), A.GENDER, L);
L := L + 1;
GET(S(L+1..S'LAST), A.CO, LAST);
end GET;
procedure PUT(S : out STRING; A : in ADJECTIVE_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), A.DECL);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), A.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), A.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), A.GENDER);
L := M + 1;
S(L) := ' ';
M := L + COMPARISON_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), A.CO);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end ADJECTIVE_RECORD_IO;
package body NUMERAL_RECORD_IO is
use DECN_RECORD_IO;
use CASE_TYPE_IO;
use NUMBER_TYPE_IO;
use GENDER_TYPE_IO;
use NUMERAL_SORT_TYPE_IO;
use GENDER_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; NUM : out NUMERAL_RECORD) is
begin
GET(F, NUM.DECL);
GET(F, SPACER);
GET(F, NUM.CS);
GET(F, SPACER);
GET(F, NUM.NUMBER);
GET(F, SPACER);
GET(F, NUM.GENDER);
GET(F, SPACER);
GET(F, NUM.SORT);
end GET;
procedure GET(NUM : out NUMERAL_RECORD) is
begin
GET(NUM.DECL);
GET(SPACER);
GET(SPACER);
GET(NUM.NUMBER);
GET(SPACER);
GET(NUM.GENDER);
GET(SPACER);
GET(NUM.SORT);
end GET;
procedure PUT(F : in FILE_TYPE; NUM : in NUMERAL_RECORD) is
begin
PUT(F, NUM.DECL);
PUT(F, ' ');
PUT(F, NUM.CS);
PUT(F, ' ');
PUT(F, NUM.NUMBER);
PUT(F, ' ');
PUT(F, NUM.GENDER);
PUT(F, ' ');
PUT(F, NUM.SORT);
end PUT;
procedure PUT(NUM : in NUMERAL_RECORD) is
begin
PUT(NUM.DECL);
PUT(' ');
PUT(NUM.CS);
PUT(' ');
PUT(NUM.NUMBER);
PUT(' ');
PUT(NUM.GENDER);
PUT(' ');
PUT(NUM.SORT);
end PUT;
procedure GET(S : in STRING; NUM : out NUMERAL_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), NUM.DECL, L);
L := L + 1;
GET(S(L+1..S'LAST), NUM.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), NUM.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), NUM.GENDER, L);
L := L + 1;
GET(S(L+1..S'LAST), NUM.SORT, LAST);
end GET;
procedure PUT(S : out STRING; NUM : in NUMERAL_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), NUM.DECL);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), NUM.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), NUM.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), NUM.GENDER);
L := M + 1;
S(L) := ' ';
M := L + NUMERAL_SORT_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), NUM.SORT);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end NUMERAL_RECORD_IO;
package body ADVERB_RECORD_IO is
use COMPARISON_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; A : out ADVERB_RECORD) is
begin
GET(F, A.CO);
end GET;
procedure GET(A : out ADVERB_RECORD) is
begin
GET(A.CO);
end GET;
procedure PUT(F : in FILE_TYPE; A : in ADVERB_RECORD) is
begin
PUT(F, A.CO);
end PUT;
procedure PUT(A : in ADVERB_RECORD) is
begin
PUT(A.CO);
end PUT;
procedure GET(S : in STRING; A : out ADVERB_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), A.CO, LAST);
end GET;
procedure PUT(S : out STRING; A : in ADVERB_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + COMPARISON_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), A.CO);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end ADVERB_RECORD_IO;
package body VERB_RECORD_IO is
use DECN_RECORD_IO;
use TENSE_VOICE_MOOD_RECORD_IO;
use PERSON_TYPE_IO;
use NUMBER_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; V : out VERB_RECORD) is
begin
GET(F, V.CON);
GET(F, SPACER);
GET(F, V.TENSE_VOICE_MOOD);
GET(F, SPACER);
GET(F, V.PERSON);
GET(F, SPACER);
GET(F, V.NUMBER);
end GET;
procedure GET(V : out VERB_RECORD) is
begin
GET(V.CON);
GET(SPACER);
GET(V.TENSE_VOICE_MOOD);
GET(SPACER);
GET(V.PERSON);
GET(SPACER);
GET(V.NUMBER);
end GET;
procedure PUT(F : in FILE_TYPE; V : in VERB_RECORD) is
begin
PUT(F, V.CON);
PUT(F, ' ');
PUT(F, V.TENSE_VOICE_MOOD);
PUT(F, ' ');
PUT(F, V.PERSON);
PUT(F, ' ');
PUT(F, V.NUMBER);
end PUT;
procedure PUT(V : in VERB_RECORD) is
begin
PUT(V.CON);
PUT(' ');
PUT(V.TENSE_VOICE_MOOD);
PUT(' ');
PUT(V.PERSON);
PUT(' ');
PUT(V.NUMBER);
end PUT;
procedure GET(S : in STRING; V : out VERB_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), V.CON, L);
L := L + 1;
GET(S(L+1..S'LAST), V.TENSE_VOICE_MOOD, L);
L := L + 1;
GET(S(L+1..S'LAST), V.PERSON, L);
L := L + 1;
GET(S(L+1..S'LAST), V.NUMBER, LAST);
end GET;
procedure PUT(S : out STRING; V : in VERB_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), V.CON);
L := M + 1;
S(L) := ' ';
M := L + TENSE_VOICE_MOOD_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), V.TENSE_VOICE_MOOD);
L := M + 1;
S(L) := ' ';
M := L + PERSON_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), V.PERSON);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), V.NUMBER);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end VERB_RECORD_IO;
package body VPAR_RECORD_IO is
use DECN_RECORD_IO;
use CASE_TYPE_IO;
use NUMBER_TYPE_IO;
use GENDER_TYPE_IO;
use TENSE_VOICE_MOOD_RECORD_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; VP : out VPAR_RECORD) is
begin
GET(F, VP.CON);
GET(F, SPACER);
GET(F, VP.CS);
GET(F, SPACER);
GET(F, VP.NUMBER);
GET(F, SPACER);
GET(F, VP.GENDER);
GET(F, SPACER);
GET(F, VP.TENSE_VOICE_MOOD);
end GET;
procedure GET(VP : out VPAR_RECORD) is
begin
GET(VP.CON);
GET(SPACER);
GET(VP.CS);
GET(SPACER);
GET(VP.NUMBER);
GET(SPACER);
GET(VP.GENDER);
GET(SPACER);
GET(VP.TENSE_VOICE_MOOD);
end GET;
procedure PUT(F : in FILE_TYPE; VP : in VPAR_RECORD) is
begin
PUT(F, VP.CON);
PUT(F, ' ');
PUT(F, VP.CS);
PUT(F, ' ');
PUT(F, VP.NUMBER);
PUT(F, ' ');
PUT(F, VP.GENDER);
PUT(F, ' ');
PUT(F, VP.TENSE_VOICE_MOOD);
end PUT;
procedure PUT(VP : in VPAR_RECORD) is
begin
PUT(VP.CON);
PUT(' ');
PUT(VP.CS);
PUT(' ');
PUT(VP.NUMBER);
PUT(' ');
PUT(VP.GENDER);
PUT(' ');
PUT(VP.TENSE_VOICE_MOOD);
end PUT;
procedure GET(S : in STRING; VP : out VPAR_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), VP.CON, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.GENDER, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.TENSE_VOICE_MOOD, LAST);
end GET;
procedure PUT(S : out STRING; VP : in VPAR_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.CON);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.GENDER);
L := M + 1;
S(L) := ' ';
M := L + TENSE_VOICE_MOOD_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.TENSE_VOICE_MOOD);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end VPAR_RECORD_IO;
package body SUPINE_RECORD_IO is
use DECN_RECORD_IO;
use CASE_TYPE_IO;
use NUMBER_TYPE_IO;
use GENDER_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; VP : out SUPINE_RECORD) is
begin
GET(F, VP.CON);
GET(F, SPACER);
GET(F, VP.CS);
GET(F, SPACER);
GET(F, VP.NUMBER);
GET(F, SPACER);
GET(F, VP.GENDER);
end GET;
procedure GET(VP : out SUPINE_RECORD) is
begin
GET(VP.CON);
GET(SPACER);
GET(VP.CS);
GET(SPACER);
GET(VP.NUMBER);
GET(SPACER);
GET(VP.GENDER);
end GET;
procedure PUT(F : in FILE_TYPE; VP : in SUPINE_RECORD) is
begin
PUT(F, VP.CON);
PUT(F, ' ');
PUT(F, VP.CS);
PUT(F, ' ');
PUT(F, VP.NUMBER);
PUT(F, ' ');
PUT(F, VP.GENDER);
end PUT;
procedure PUT(VP : in SUPINE_RECORD) is
begin
PUT(VP.CON);
PUT(' ');
PUT(VP.CS);
PUT(' ');
PUT(VP.NUMBER);
PUT(' ');
PUT(VP.GENDER);
end PUT;
procedure GET(S : in STRING; VP : out SUPINE_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), VP.CON, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.CS, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.NUMBER, L);
L := L + 1;
GET(S(L+1..S'LAST), VP.GENDER, LAST);
end GET;
procedure PUT(S : out STRING; VP : in SUPINE_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + DECN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.CON);
L := M + 1;
S(L) := ' ';
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.CS);
L := M + 1;
S(L) := ' ';
M := L + NUMBER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.NUMBER);
L := M + 1;
S(L) := ' ';
M := L + GENDER_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), VP.GENDER);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end SUPINE_RECORD_IO;
package body PREPOSITION_RECORD_IO is
use CASE_TYPE_IO;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; P : out PREPOSITION_RECORD) is
begin
GET(F, P.OBJ);
end GET;
procedure GET(P : out PREPOSITION_RECORD) is
begin
GET(P.OBJ);
end GET;
procedure PUT(F : in FILE_TYPE; P : in PREPOSITION_RECORD) is
begin
PUT(F, P.OBJ);
end PUT;
procedure PUT(P : in PREPOSITION_RECORD) is
begin
PUT(P.OBJ);
end PUT;
procedure GET(S : in STRING; P : out PREPOSITION_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
GET(S(L+1..S'LAST), P.OBJ, LAST);
end GET;
procedure PUT(S : out STRING; P : in PREPOSITION_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + CASE_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.OBJ);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end PREPOSITION_RECORD_IO;
package body CONJUNCTION_RECORD_IO is
NULL_CONJUNCTION_RECORD : CONJUNCTION_RECORD;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; C : out CONJUNCTION_RECORD) is
-- There is actually nothing to a CONJUNCTION_RECORD, no compoonents
begin
C := NULL_CONJUNCTION_RECORD;
end GET;
procedure GET(C : out CONJUNCTION_RECORD) is
begin
C := NULL_CONJUNCTION_RECORD;
end GET;
procedure PUT(F : in FILE_TYPE; C : in CONJUNCTION_RECORD) is
begin
null;
end PUT;
procedure PUT(C : in CONJUNCTION_RECORD) is
begin
null;
end PUT;
procedure GET(S : in STRING; C : out CONJUNCTION_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
C := NULL_CONJUNCTION_RECORD;
LAST := L - 1; -- LAST did not even get to S'FIRST, since nothing to read
end GET;
procedure PUT(S : out STRING; C : in CONJUNCTION_RECORD) is
-- Since there is no component, just make the out string blank
begin
S(S'FIRST..S'LAST) := (others => ' ');
end PUT;
end CONJUNCTION_RECORD_IO;
package body INTERJECTION_RECORD_IO is
NULL_INTERJECTION_RECORD : INTERJECTION_RECORD;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; I : out INTERJECTION_RECORD) is
begin
I := NULL_INTERJECTION_RECORD;
end GET;
procedure GET(I : out INTERJECTION_RECORD) is
begin
I := NULL_INTERJECTION_RECORD;
end GET;
procedure PUT(F : in FILE_TYPE; I : in INTERJECTION_RECORD) is
begin
null;
end PUT;
procedure PUT(I : in INTERJECTION_RECORD) is
begin
null;
end PUT;
procedure GET(S : in STRING; I : out INTERJECTION_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
I := NULL_INTERJECTION_RECORD;
LAST := L - 1;
end GET;
procedure PUT(S : out STRING; I : in INTERJECTION_RECORD) is
begin
S(S'FIRST..S'LAST) := (others => ' ');
end PUT;
end INTERJECTION_RECORD_IO;
package body TACKON_RECORD_IO is
NULL_TACKON_RECORD : TACKON_RECORD;
SPACER : CHARACTER := ' ';
procedure GET(F : in FILE_TYPE; I : out TACKON_RECORD) is
begin
I := NULL_TACKON_RECORD;
end GET;
procedure GET(I : out TACKON_RECORD) is
begin
I := NULL_TACKON_RECORD;
end GET;
procedure PUT(F : in FILE_TYPE; I : in TACKON_RECORD) is
begin
null;
end PUT;
procedure PUT(I : in TACKON_RECORD) is
begin
null;
end PUT;
procedure GET(S : in STRING; I : out TACKON_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
I := NULL_TACKON_RECORD;
LAST := L - 1;
end GET;
procedure PUT(S : out STRING; I : in TACKON_RECORD) is
begin
S(S'FIRST..S'LAST) := (others => ' ');
end PUT;
end TACKON_RECORD_IO;
package body PREFIX_RECORD_IO is
procedure GET(F : in FILE_TYPE; P : out PREFIX_RECORD) is
begin
P := NULL_PREFIX_RECORD;
end GET;
procedure GET(P : out PREFIX_RECORD) is
begin
P := NULL_PREFIX_RECORD;
end GET;
procedure PUT(F : in FILE_TYPE; P : in PREFIX_RECORD) is
begin
null;
end PUT;
procedure PUT(P : in PREFIX_RECORD) is
begin
null;
end PUT;
procedure GET(S : in STRING; P : out PREFIX_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
P := NULL_PREFIX_RECORD;
LAST := L - 1;
end GET;
procedure PUT(S : out STRING; P : in PREFIX_RECORD) is
begin
S(S'FIRST..S'LAST) := (others => ' ');
end PUT;
end PREFIX_RECORD_IO;
package body SUFFIX_RECORD_IO is
procedure GET(F : in FILE_TYPE; P : out SUFFIX_RECORD) is
begin
P := NULL_SUFFIX_RECORD;
end GET;
procedure GET(P : out SUFFIX_RECORD) is
begin
P := NULL_SUFFIX_RECORD;
end GET;
procedure PUT(F : in FILE_TYPE; P : in SUFFIX_RECORD) is
begin
null;
end PUT;
procedure PUT(P : in SUFFIX_RECORD) is
begin
null;
end PUT;
procedure GET(S : in STRING; P : out SUFFIX_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
P := NULL_SUFFIX_RECORD;
LAST := L - 1;
end GET;
procedure PUT(S : out STRING; P : in SUFFIX_RECORD) is
begin
S(S'FIRST..S'LAST) := (others => ' ');
end PUT;
end SUFFIX_RECORD_IO;
package body QUALITY_RECORD_IO is
use PART_OF_SPEECH_TYPE_IO;
use NOUN_RECORD_IO;
use PRONOUN_RECORD_IO;
use PROPACK_RECORD_IO;
use ADJECTIVE_RECORD_IO;
use NUMERAL_RECORD_IO;
use ADVERB_RECORD_IO;
use VERB_RECORD_IO;
use VPAR_RECORD_IO;
use SUPINE_RECORD_IO;
use PREPOSITION_RECORD_IO;
use CONJUNCTION_RECORD_IO;
use INTERJECTION_RECORD_IO;
use TACKON_RECORD_IO;
use PREFIX_RECORD_IO;
use SUFFIX_RECORD_IO;
SPACER : CHARACTER := ' ';
NOUN : NOUN_RECORD;
PRONOUN : PRONOUN_RECORD;
PROPACK : PROPACK_RECORD;
ADJECTIVE : ADJECTIVE_RECORD;
ADVERB : ADVERB_RECORD;
VERB : VERB_RECORD;
VPARTICIPLE : VPAR_RECORD;
SUPIN : SUPINE_RECORD;
PREPOSITION : PREPOSITION_RECORD;
CONJUNCTION : CONJUNCTION_RECORD;
INTERJECTION : INTERJECTION_RECORD;
NUMERAL : NUMERAL_RECORD;
TACKN : TACKON_RECORD;
PREFX : PREFIX_RECORD;
SUFFX : SUFFIX_RECORD;
PR : QUALITY_RECORD;
procedure GET(F : in FILE_TYPE; P : out QUALITY_RECORD) is
PS : PART_OF_SPEECH_TYPE := X;
begin
GET(F, PS);
GET(F, SPACER);
case PS is
when N =>
GET(F, NOUN);
P := (N, NOUN);
when PRON =>
GET(F, PRONOUN);
P := (PRON, PRONOUN);
when PACK =>
GET(F, PROPACK);
P := (PACK, PROPACK);
when ADJ =>
GET(F, ADJECTIVE);
P := (ADJ, ADJECTIVE);
when NUM =>
GET(F, NUMERAL);
P := (NUM, NUMERAL);
when ADV =>
GET(F, ADVERB);
P := (ADV, ADVERB);
when V =>
GET(F, VERB);
P := (V, VERB);
when VPAR =>
GET(F, VPARTICIPLE);
P := (VPAR, VPARTICIPLE);
when SUPINE =>
GET(F, SUPIN);
P := (SUPINE, SUPIN);
when PREP =>
GET(F, PREPOSITION);
P := (PREP, PREPOSITION);
when CONJ =>
GET(F, CONJUNCTION);
P := (CONJ, CONJUNCTION);
when INTERJ =>
GET(F, INTERJECTION);
P := (INTERJ, INTERJECTION);
when TACKON =>
GET(F, TACKN);
P := (TACKON, TACKN);
when PREFIX =>
GET(F, PREFX);
P := (PREFIX, PREFX);
when SUFFIX =>
GET(F, SUFFX);
P := (SUFFIX, SUFFX);
when X =>
P := (POFS => X);
end case;
return;
end GET;
procedure GET(P : out QUALITY_RECORD) is
PS : PART_OF_SPEECH_TYPE := X;
begin
GET(PS);
GET(SPACER);
case PS is
when N =>
GET(NOUN);
P := (N, NOUN);
when PRON =>
GET(PRONOUN);
P := (PRON, PRONOUN);
when PACK =>
GET(PROPACK);
P := (PACK, PROPACK);
when ADJ =>
GET(ADJECTIVE);
P := (ADJ, ADJECTIVE);
when NUM =>
GET(NUMERAL);
P := (NUM, NUMERAL);
when ADV =>
GET(ADVERB);
P := (ADV, ADVERB);
when V =>
GET(VERB);
P := (V, VERB);
when VPAR =>
GET(VPARTICIPLE);
P := (VPAR, VPARTICIPLE);
when SUPINE =>
GET(SUPIN);
P := (SUPINE, SUPIN);
when PREP =>
GET(PREPOSITION);
P := (PREP, PREPOSITION);
when CONJ =>
GET(CONJUNCTION);
P := (CONJ, CONJUNCTION);
when INTERJ =>
GET(INTERJECTION);
P := (INTERJ, INTERJECTION);
when TACKON =>
GET(TACKN);
P := (TACKON, TACKN);
when PREFIX =>
GET(PREFX);
P := (PREFIX, PREFX);
when SUFFIX =>
GET(SUFFX);
P := (SUFFIX, SUFFX);
when X =>
P := (POFS => X);
end case;
return;
end GET;
procedure PUT(F : in FILE_TYPE; P : in QUALITY_RECORD) is
C : POSITIVE := POSITIVE(COL(F));
begin
PUT(F, P.POFS);
PUT(F, ' ');
case P.POFS is
when N =>
PUT(F, P.N);
when PRON =>
PUT(F, P.PRON);
when PACK =>
PUT(F, P.PACK);
when ADJ =>
PUT(F, P.ADJ);
when NUM =>
PUT(F, P.NUM);
when ADV =>
PUT(F, P.ADV);
when V =>
PUT(F, P.V);
when VPAR =>
PUT(F, P.VPAR);
when SUPINE =>
PUT(F, P.SUPINE);
when PREP =>
PUT(F, P.PREP);
when CONJ =>
PUT(F, P.CONJ);
when INTERJ =>
PUT(F, P.INTERJ);
when TACKON =>
PUT(F, P.TACKON);
when PREFIX =>
PUT(F, P.PREFIX);
when SUFFIX =>
PUT(F, P.SUFFIX);
when others =>
null;
end case;
PUT(F, STRING'((INTEGER(COL(F))..QUALITY_RECORD_IO.DEFAULT_WIDTH+C-1 => ' ')));
return;
end PUT;
procedure PUT(P : in QUALITY_RECORD) is
C : POSITIVE := POSITIVE(COL);
begin
PUT(P.POFS);
PUT(' ');
case P.POFS is
when N =>
PUT(P.N);
when PRON =>
PUT(P.PRON);
when PACK =>
PUT(P.PACK);
when ADJ =>
PUT(P.ADJ);
when NUM =>
PUT(P.NUM);
when ADV =>
PUT(P.ADV);
when V =>
PUT(P.V);
when VPAR =>
PUT(P.VPAR);
when SUPINE =>
PUT(P.SUPINE);
when PREP =>
PUT(P.PREP);
when CONJ =>
PUT(P.CONJ);
when INTERJ =>
PUT(P.INTERJ);
when TACKON =>
PUT(P.TACKON);
when PREFIX =>
PUT(P.PREFIX);
when SUFFIX =>
PUT(P.SUFFIX);
when others =>
null;
end case;
PUT(STRING'((INTEGER(COL)..QUALITY_RECORD_IO.DEFAULT_WIDTH+C-1 => ' ')));
return;
end PUT;
procedure GET(S : in STRING; P : out QUALITY_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
PS : PART_OF_SPEECH_TYPE := X;
begin
GET(S, PS, L);
LAST := L; -- In case it is not set later
L := L + 1;
case PS is
when N =>
GET(S(L+1..S'LAST), NOUN, LAST);
P := (N, NOUN);
when PRON =>
GET(S(L+1..S'LAST), PRONOUN, LAST);
P := (PRON, PRONOUN);
when PACK =>
GET(S(L+1..S'LAST), PROPACK, LAST);
P := (PACK, PROPACK);
when ADJ =>
GET(S(L+1..S'LAST), ADJECTIVE, LAST);
P := (ADJ, ADJECTIVE);
when NUM =>
GET(S(L+1..S'LAST), NUMERAL, LAST);
P := (NUM, NUMERAL);
when ADV =>
GET(S(L+1..S'LAST), ADVERB, LAST);
P := (ADV, ADVERB);
when V =>
GET(S(L+1..S'LAST), VERB, LAST);
P := (V, VERB);
when VPAR =>
GET(S(L+1..S'LAST), VPARTICIPLE, LAST);
P := (VPAR, VPARTICIPLE);
when SUPINE =>
GET(S(L+1..S'LAST), SUPIN, LAST);
P := (SUPINE, SUPIN);
when PREP =>
GET(S(L+1..S'LAST), PREPOSITION, LAST);
P := (PREP, PREPOSITION);
when CONJ =>
GET(S(L+1..S'LAST), CONJUNCTION, LAST);
P := (CONJ, CONJUNCTION);
when INTERJ =>
GET(S(L+1..S'LAST), INTERJECTION, LAST);
P := (INTERJ, INTERJECTION);
when TACKON =>
GET(S(L+1..S'LAST), TACKN, LAST);
P := (TACKON, TACKN);
when PREFIX =>
GET(S(L+1..S'LAST), PREFX, LAST);
P := (PREFIX, PREFX);
when SUFFIX =>
GET(S(L+1..S'LAST), SUFFX, LAST);
P := (SUFFIX, SUFFX);
when X =>
P := (POFS => X);
end case;
return;
end GET;
procedure PUT(S : out STRING; P : in QUALITY_RECORD) is
-- Note that this does not Put with a uniform width
-- which would require a constant QUALITY_RECORD_IO.DEFAULT_WIDTH
-- Rather we Put to minimal size with NOUN_RECORD_IO.DEFAULT_WIDTH,
-- PRONOUN_RECORD_IO,DEFAULT_WIDTH, ...
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + PART_OF_SPEECH_TYPE_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.POFS);
L := M + 1;
S(L) := ' ';
case P.POFS is
when N =>
M := L + NOUN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.N);
when PRON =>
M := L + PRONOUN_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.PRON);
when PACK =>
M := L + PROPACK_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.PACK);
when ADJ =>
M := L + ADJECTIVE_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.ADJ);
when NUM =>
M := L + NUMERAL_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.NUM);
when ADV =>
M := L + ADVERB_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.ADV);
when V =>
M := L + VERB_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.V);
when VPAR =>
M := L + VPAR_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.VPAR);
when SUPINE =>
M := L + SUPINE_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.SUPINE);
when PREP =>
M := L + PREPOSITION_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.PREP);
when CONJ =>
M := L + CONJUNCTION_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.CONJ);
when INTERJ =>
M := L + INTERJECTION_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.INTERJ);
when TACKON =>
M := L + TACKON_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.TACKON);
when PREFIX =>
M := L + PREFIX_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.PREFIX);
when SUFFIX =>
M := L + SUFFIX_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.SUFFIX);
when others =>
null;
end case;
S(M+1..S'LAST) := (others => ' ');
end PUT;
end QUALITY_RECORD_IO;
package body ENDING_RECORD_IO is
use INTEGER_IO;
use TEXT_IO;
SPACER : CHARACTER := ' ';
SF, BLANKS : ENDING := (others => ' ');
N : ENDING_SIZE_TYPE := 0;
procedure GET(F : in FILE_TYPE; X : out ENDING_RECORD) is
begin
SF := BLANKS;
GET(F, N);
if N = 0 then
X := NULL_ENDING_RECORD;
else
GET(F, SPACER); -- Note this means exactly one blank
GET(F, SF(1..N));
X := (N, SF);
end if;
end GET;
procedure GET(X : out ENDING_RECORD) is
begin
SF := BLANKS;
GET(N);
if N = 0 then
X := NULL_ENDING_RECORD;
else
GET(SPACER);
GET(SF(1..N));
X := (N, SF);
end if;
end GET;
procedure PUT(F : in FILE_TYPE; X : in ENDING_RECORD) is
begin
PUT(F, X.SIZE, 1);
PUT(F, ' ');
PUT(F, X.SUF(1..X.SIZE) & BLANKS(X.SIZE+1..MAX_ENDING_SIZE));
end PUT;
procedure PUT(X : in ENDING_RECORD) is
begin
PUT(X.SIZE, 1);
PUT(' ');
PUT(X.SUF(1..X.SIZE) & BLANKS(X.SIZE+1..MAX_ENDING_SIZE));
end PUT;
procedure GET(S : in STRING; X : out ENDING_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
SF := BLANKS;
GET(S(L+1..S'LAST), N, L);
if N = 0 then
X := NULL_ENDING_RECORD;
LAST := L;
else
L := L + 1;
--if S(L+N-1) = ' ' or else
-- S(L+N+1) /= ' ' then
--if
-- S(L+N+1) /= ' ' then
-- TEXT_IO.PUT_LINE("ERROR in INFLECTION =>" & S);
--else
SF := S(L+1..L+N) & BLANKS(N+1..MAX_ENDING_SIZE);
LAST := L + N;
X := (N, SF(1..N) & BLANKS(N+1..MAX_ENDING_SIZE));
--end if;
end if;
exception
when others =>
TEXT_IO.PUT_LINE("ENDING ERRROR " & S);
end GET;
procedure PUT(S : out STRING; X : in ENDING_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + 2;
PUT(S(L+1..M), X.SIZE);
M := M + 1;
S(M) := ' ';
if X.SIZE > 0 then
L := M;
M := L + X.SIZE;
S(L+1..M) := X.SUF(1..X.SIZE);
end if;
-- Being very careful here, first to fill out to the MAX_ENDING_SIZE
L := M;
M := L + MAX_ENDING_SIZE - X.SIZE;
S(L+1..M) := (others => ' ');
-- Then to fill out the rest of the out string, if any
S(M+1..S'LAST) := (others => ' ');
end PUT;
end ENDING_RECORD_IO;
package body INFLECTION_RECORD_IO is
use QUALITY_RECORD_IO;
use STEM_KEY_TYPE_IO;
use ENDING_RECORD_IO;
use AGE_TYPE_IO;
use FREQUENCY_TYPE_IO;
SPACER : CHARACTER := ' ';
PE : INFLECTION_RECORD;
procedure GET(F : in FILE_TYPE; P : out INFLECTION_RECORD) is
begin
GET(F, P.QUAL);
GET(F, SPACER);
GET(F, P.KEY);
GET(F, SPACER);
GET(F, P.ENDING);
GET(F, SPACER);
GET(F, P.AGE);
GET(F, SPACER);
GET(F, P.FREQ);
end GET;
procedure GET(P : out INFLECTION_RECORD) is
begin
GET(P.QUAL);
GET(SPACER);
GET(P.KEY);
GET(SPACER);
GET(P.ENDING);
GET(SPACER);
GET(P.AGE);
GET(SPACER);
GET(P.FREQ);
end GET;
procedure PUT(F : in FILE_TYPE; P : in INFLECTION_RECORD) is
begin
PUT(F, P.QUAL);
PUT(F, ' ');
PUT(F, P.KEY, 1);
PUT(F, ' ');
PUT(F, P.ENDING);
PUT(F, ' ');
PUT(F, P.AGE);
PUT(F, ' ');
PUT(F, P.FREQ);
end PUT;
procedure PUT(P : in INFLECTION_RECORD) is
begin
PUT(P.QUAL);
PUT(' ');
PUT(P.KEY, 1);
PUT(' ');
PUT(P.ENDING);
PUT(' ');
PUT(P.AGE);
PUT(' ');
PUT(P.FREQ);
end PUT;
procedure GET(S : in STRING; P : out INFLECTION_RECORD; LAST : out INTEGER) is
L : INTEGER := S'FIRST - 1;
begin
LAST := 0;
P := PE;
GET(S(L+1..S'LAST), P.QUAL, L);
L := L + 1;
GET(S(L+1..S'LAST), P.KEY, L);
L := L + 1;
GET(S(L+1..S'LAST), P.ENDING, L);
L := L + 1;
GET(S(L+1..S'LAST), P.AGE, L);
L := L + 1;
GET(S(L+1..S'LAST), P.FREQ, LAST);
end GET;
procedure PUT(S : out STRING; P : in INFLECTION_RECORD) is
L : INTEGER := S'FIRST - 1;
M : INTEGER := 0;
begin
M := L + QUALITY_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.QUAL);
L := M + 1;
S(L) := ' ';
M := L + 1;
PUT(S(L+1..M), P.KEY);
L := M + 1;
S(L) := ' ';
M := L + ENDING_RECORD_IO.DEFAULT_WIDTH;
PUT(S(L+1..M), P.ENDING);
L := M + 1;
S(L) := ' ';
M := L + 1;
PUT(S(L+1..M), P.AGE);
L := M + 1;
S(L) := ' ';
M := L + 1;
PUT(S(L+1..M), P.FREQ);
S(M+1..S'LAST) := (others => ' ');
end PUT;
end INFLECTION_RECORD_IO;
procedure ESTABLISH_INFLECTIONS_SECTION is
-- Loads the inflection array from the file prepared in FILE_INFLECTIONS_SECTION
-- If N = 0 (an artifical flag for the section for blank inflections = 5)
-- computes the LELL..LELF indices for use in WORD
use TEXT_IO;
use INFLECTION_RECORD_IO;
use LEL_SECTION_IO;
procedure LOAD_LEL_INDEXES is
-- Load arrays from file
I : INTEGER := 0;
--IR : INFLECTION_RECORD;
N, XN : INTEGER := 0;
CH, XCH : CHARACTER := ' ';
INFLECTIONS_SECTIONS_FILE : LEL_SECTION_IO.FILE_TYPE;
begin
OPEN(INFLECTIONS_SECTIONS_FILE, IN_FILE, INFLECTIONS_SECTIONS_NAME);
NUMBER_OF_INFLECTIONS := 0;
LEL_SECTION_IO.READ(INFLECTIONS_SECTIONS_FILE,
LEL,
LEL_SECTION_IO.POSITIVE_COUNT(5));
I := 1;
BELF(0, ' ') := I;
BELL(0, ' ') := 0;
loop
exit when LEL(I) = NULL_INFLECTION_RECORD;
BEL(I) := LEL(I);
BELL(0, ' ') := I;
I := I + 1;
end loop;
NUMBER_OF_INFLECTIONS := NUMBER_OF_INFLECTIONS + I - 1;
LEL_SECTION_IO.READ(INFLECTIONS_SECTIONS_FILE,
LEL,
LEL_SECTION_IO.POSITIVE_COUNT(1));
I := 1;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
XN := N;
XCH := CH;
LELF(N, CH) := I;
C1_LOOP:
loop
N1_LOOP:
loop
exit C1_LOOP when LEL(I) = NULL_INFLECTION_RECORD;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
if CH /= XCH then
LELL(XN, XCH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XCH := CH;
XN := N;
elsif N /= XN then
LELL(XN, CH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XN := N;
exit N1_LOOP;
end if;
I := I + 1;
end loop N1_LOOP;
end loop C1_LOOP;
LELL(XN, XCH) := I - 1;
NUMBER_OF_INFLECTIONS := NUMBER_OF_INFLECTIONS + I - 1;
LEL_SECTION_IO.READ(INFLECTIONS_SECTIONS_FILE,
LEL,
LEL_SECTION_IO.POSITIVE_COUNT(2));
I := 1;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
XN := N;
XCH := CH;
LELF(N, CH) := I;
C2_LOOP:
loop
N2_LOOP:
loop
exit C2_LOOP when LEL(I) = NULL_INFLECTION_RECORD;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
exit when CH > 'r';
if CH /= XCH then
LELL(XN, XCH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XCH := CH;
XN := N;
elsif N /= XN then
LELL(XN, CH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XN := N;
exit N2_LOOP;
end if;
I := I + 1;
end loop N2_LOOP;
end loop C2_LOOP;
LELL(XN, XCH) := I - 1;
NUMBER_OF_INFLECTIONS := NUMBER_OF_INFLECTIONS + I - 1;
LEL_SECTION_IO.READ(INFLECTIONS_SECTIONS_FILE,
LEL,
LEL_SECTION_IO.POSITIVE_COUNT(3));
I := 1;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
XN := N;
XCH := CH;
LELF(N, CH) := I;
C3_LOOP:
loop
N3_LOOP:
loop
exit C3_LOOP when LEL(I) = NULL_INFLECTION_RECORD;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
exit when CH > 's';
if CH /= XCH then
LELL(XN, XCH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XCH := CH;
XN := N;
elsif N /= XN then
LELL(XN, CH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XN := N;
exit N3_LOOP;
end if;
I := I + 1;
end loop N3_LOOP;
end loop C3_LOOP;
LELL(XN, XCH) := I - 1;
NUMBER_OF_INFLECTIONS := NUMBER_OF_INFLECTIONS + I - 1;
LEL_SECTION_IO.READ(INFLECTIONS_SECTIONS_FILE,
LEL,
LEL_SECTION_IO.POSITIVE_COUNT(4));
I := 1;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
XN := N;
XCH := CH;
LELF(N, CH) := I;
C4_LOOP:
loop
N4_LOOP:
loop
exit C4_LOOP when LEL(I).QUAL.POFS = PRON and then
(LEL(I).QUAL.PRON.DECL.WHICH = 1 or
LEL(I).QUAL.PRON.DECL.WHICH = 2);
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
if CH /= XCH then
LELL(XN, XCH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XCH := CH;
XN := N;
elsif N /= XN then
LELL(XN, CH) := I - 1;
LELF(N, CH) := I;
LELL(N, CH) := 0;
XN := N;
exit N4_LOOP;
end if;
I := I + 1;
end loop N4_LOOP;
end loop C4_LOOP;
LELL(XN, XCH) := I - 1;
begin
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
XN := N;
XCH := CH;
PELF(N, CH) := I;
PELL(N, CH) := 0;
C_P_LOOP:
loop
N_P_LOOP:
loop
exit C_P_LOOP when LEL(I) = NULL_INFLECTION_RECORD;
N := LEL(I).ENDING.SIZE;
CH := LEL(I).ENDING.SUF(N);
if CH /= XCH then
PELL(XN, XCH) := I - 1;
PELF(N, CH) := I;
PELL(N, CH) := 0;
XCH := CH;
XN := N;
elsif N /= XN then
PELL(XN, CH) := I - 1;
PELF(N, CH) := I;
PELL(N, CH) := 0;
XN := N;
exit N_P_LOOP;
end if;
I := I + 1;
end loop N_P_LOOP;
end loop C_P_LOOP;
exception
when CONSTRAINT_ERROR => null;
end;
PELL(XN, XCH) := I - 1;
NUMBER_OF_INFLECTIONS := NUMBER_OF_INFLECTIONS + I - 1;
CLOSE(INFLECTIONS_SECTIONS_FILE);
end LOAD_LEL_INDEXES;
begin
PREFACE.PUT("INFLECTION_ARRAY being loaded");
PREFACE.SET_COL(33);
PREFACE.PUT("-- ");
LOAD_LEL_INDEXES; -- Makes indexes from array
PREFACE.PUT(NUMBER_OF_INFLECTIONS, 6);
PREFACE.PUT(" entries");
PREFACE.SET_COL(55); PREFACE.PUT_LINE("-- Loaded correctly");
exception
when Text_IO.Name_Error =>
NEW_LINE;
PUT_LINE("There is no " & INFLECTIONS_SECTIONS_NAME & " file.");
PUT_LINE("The program cannot work without one.");
PUT_LINE("Make sure you are in the subdirectory containing the files");
PUT_LINE("for inflections, dictionary, addons and uniques.");
raise GIVE_UP;
end ESTABLISH_INFLECTIONS_SECTION;
begin -- initialization of body of INFLECTIONS_PACKAGE
--TEXT_IO.PUT_LINE("Initializing INFLECTIONS_PACKAGE");
PART_OF_SPEECH_TYPE_IO.DEFAULT_WIDTH := PART_OF_SPEECH_TYPE'WIDTH;
GENDER_TYPE_IO.DEFAULT_WIDTH := GENDER_TYPE'WIDTH;
CASE_TYPE_IO.DEFAULT_WIDTH := CASE_TYPE'WIDTH;
NUMBER_TYPE_IO.DEFAULT_WIDTH := NUMBER_TYPE'WIDTH;
PERSON_TYPE_IO.DEFAULT_WIDTH := 1;
COMPARISON_TYPE_IO.DEFAULT_WIDTH := COMPARISON_TYPE'WIDTH;
TENSE_TYPE_IO.DEFAULT_WIDTH := TENSE_TYPE'WIDTH;
VOICE_TYPE_IO.DEFAULT_WIDTH := VOICE_TYPE'WIDTH;
MOOD_TYPE_IO.DEFAULT_WIDTH := MOOD_TYPE'WIDTH;
NOUN_KIND_TYPE_IO.DEFAULT_WIDTH := NOUN_KIND_TYPE'WIDTH;
PRONOUN_KIND_TYPE_IO.DEFAULT_WIDTH := PRONOUN_KIND_TYPE'WIDTH;
VERB_KIND_TYPE_IO.DEFAULT_WIDTH := VERB_KIND_TYPE'WIDTH;
NUMERAL_SORT_TYPE_IO.DEFAULT_WIDTH := NUMERAL_SORT_TYPE'WIDTH;
AGE_TYPE_IO.DEFAULT_WIDTH := AGE_TYPE'WIDTH;
FREQUENCY_TYPE_IO.DEFAULT_WIDTH := FREQUENCY_TYPE'WIDTH;
DECN_RECORD_IO.DEFAULT_WIDTH :=
1 + 1 + --WHICH_TYPE_IO_DEFAULT_WIDTH + 1 +
1; --VARIANT_TYPE_IO_DEFAULT_WIDTH;
TENSE_VOICE_MOOD_RECORD_IO.DEFAULT_WIDTH :=
TENSE_TYPE_IO.DEFAULT_WIDTH + 1 +
VOICE_TYPE_IO.DEFAULT_WIDTH + 1 +
MOOD_TYPE_IO.DEFAULT_WIDTH;
NOUN_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH;
PRONOUN_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH;
PROPACK_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH;
ADJECTIVE_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH + 1 +
COMPARISON_TYPE_IO.DEFAULT_WIDTH;
ADVERB_RECORD_IO.DEFAULT_WIDTH :=
COMPARISON_TYPE_IO.DEFAULT_WIDTH;
VERB_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
TENSE_VOICE_MOOD_RECORD_IO.DEFAULT_WIDTH + 1 +
PERSON_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH;
VPAR_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH + 1 +
TENSE_VOICE_MOOD_RECORD_IO.DEFAULT_WIDTH;
SUPINE_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH;
PREPOSITION_RECORD_IO.DEFAULT_WIDTH := CASE_TYPE_IO.DEFAULT_WIDTH;
CONJUNCTION_RECORD_IO.DEFAULT_WIDTH := 0;
INTERJECTION_RECORD_IO.DEFAULT_WIDTH := 0;
NUMERAL_RECORD_IO.DEFAULT_WIDTH :=
DECN_RECORD_IO.DEFAULT_WIDTH + 1 +
CASE_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMBER_TYPE_IO.DEFAULT_WIDTH + 1 +
GENDER_TYPE_IO.DEFAULT_WIDTH + 1 +
NUMERAL_SORT_TYPE_IO.DEFAULT_WIDTH;
TACKON_RECORD_IO.DEFAULT_WIDTH := 0;
PREFIX_RECORD_IO.DEFAULT_WIDTH := 0;
SUFFIX_RECORD_IO.DEFAULT_WIDTH := 0;
QUALITY_RECORD_IO.DEFAULT_WIDTH := PART_OF_SPEECH_TYPE_IO.DEFAULT_WIDTH + 1 +
VPAR_RECORD_IO.DEFAULT_WIDTH; -- Largest
ENDING_RECORD_IO.DEFAULT_WIDTH := 3 + 1 +
MAX_ENDING_SIZE;
INFLECTION_RECORD_IO.DEFAULT_WIDTH := QUALITY_RECORD_IO.DEFAULT_WIDTH + 1 +
1 + 1 +
ENDING_RECORD_IO.DEFAULT_WIDTH + 1 +
AGE_TYPE_IO.DEFAULT_WIDTH + 1 +
FREQUENCY_TYPE_IO.DEFAULT_WIDTH;
end INFLECTIONS_PACKAGE;
|
-- CC1227A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK, WHEN DERIVING FROM A FORMAL TYPE, THAT ALL THE PREDEFINED
-- OPERATIONS ASSOCIATED WITH THE CLASS OF THE FORMAL TYPE ARE
-- DECLARED FOR THE DERIVED TYPE.
-- HISTORY:
-- BCB 04/04/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
WITH SYSTEM; USE SYSTEM;
PROCEDURE CC1227A IS
GENERIC
TYPE FORM IS RANGE <>;
PACKAGE P IS
TYPE DER_FORM IS NEW FORM;
FUNCTION IDENT_DER(X : DER_FORM) RETURN DER_FORM;
FUNCTION IDENT_ADR(Y : ADDRESS) RETURN ADDRESS;
END P;
PACKAGE BODY P IS
DER_VAR : DER_FORM;
DER_FORM_BASE_FIRST : DER_FORM;
DER_FORM_FIRST : DER_FORM;
DER_FORM_LAST : DER_FORM;
DER_FORM_SIZE : DER_FORM;
DER_FORM_WIDTH : DER_FORM;
DER_FORM_POS : DER_FORM;
DER_FORM_VAL : DER_FORM;
DER_FORM_SUCC : DER_FORM;
DER_FORM_PRED : DER_FORM;
DER_FORM_IMAGE : STRING(1..5);
DER_FORM_VALUE : DER_FORM;
DER_VAR_SIZE : DER_FORM;
DER_VAR_ADDRESS : ADDRESS;
DER_EQUAL, DER_UNEQUAL : DER_FORM;
DER_GREATER : DER_FORM;
DER_MOD, DER_REM : DER_FORM;
DER_ABS, DER_EXP : DER_FORM;
INT : INTEGER := 5;
FUNCTION IDENT_DER(X : DER_FORM) RETURN DER_FORM IS
BEGIN
IF EQUAL(3,3) THEN
RETURN X;
END IF;
RETURN 0;
END IDENT_DER;
FUNCTION IDENT_ADR(Y : ADDRESS) RETURN ADDRESS IS
X : DER_FORM;
BEGIN
IF EQUAL(3,3) THEN
RETURN Y;
END IF;
RETURN X'ADDRESS;
END IDENT_ADR;
BEGIN
TEST ("CC1227A", "CHECK, WHEN DERIVING FROM A FORMAL TYPE, " &
"THAT ALL THE PREDEFINED OPERATIONS " &
"ASSOCIATED WITH THE CLASS OF THE FORMAL " &
"TYPE ARE DECLARED FOR THE DERIVED TYPE");
DER_VAR := IDENT_DER(1);
IF DER_VAR /= 1 THEN
FAILED ("IMPROPER VALUE FROM ASSIGNMENT OPERATION");
END IF;
IF DER_VAR NOT IN DER_FORM THEN
FAILED ("IMPROPER RESULT FROM MEMBERSHIP TEST");
END IF;
DER_VAR := DER_FORM'(2);
IF DER_VAR /= IDENT_DER(2) THEN
FAILED ("IMPROPER RESULT FROM QUALIFICATION");
END IF;
DER_VAR := DER_FORM(INT);
IF DER_VAR /= IDENT_DER(5) THEN
FAILED ("IMPROPER RESULT FROM EXPLICIT CONVERSION - " &
"INTEGER");
END IF;
DER_VAR := DER_FORM(3.0);
IF DER_VAR /= IDENT_DER(3) THEN
FAILED ("IMPROPER RESULT FROM EXPLICIT CONVERSION - " &
"FLOAT");
END IF;
DER_VAR := 1_000;
IF DER_VAR /= IDENT_DER(1000) THEN
FAILED ("IMPROPER RESULT FROM IMPLICIT CONVERSION");
END IF;
DER_FORM_BASE_FIRST := DER_FORM'BASE'FIRST;
DER_FORM_FIRST := DER_FORM'FIRST;
IF DER_FORM_BASE_FIRST /= IDENT_DER(DER_FORM_FIRST) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'BASE'FIRST");
END IF;
IF DER_FORM_FIRST /= IDENT_DER(DER_FORM'FIRST) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'FIRST");
END IF;
DER_FORM_LAST := DER_FORM'LAST;
IF DER_FORM_LAST /= IDENT_DER(DER_FORM'LAST) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'LAST");
END IF;
DER_FORM_SIZE := DER_FORM(DER_FORM'SIZE);
IF DER_FORM_SIZE /= IDENT_DER(DER_FORM(DER_FORM'SIZE)) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'SIZE");
END IF;
DER_FORM_WIDTH := DER_FORM(DER_FORM'WIDTH);
IF DER_FORM_WIDTH /= IDENT_DER(DER_FORM(DER_FORM'WIDTH)) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'WIDTH");
END IF;
DER_FORM_POS := DER_FORM(DER_FORM'POS(DER_VAR));
IF DER_FORM_POS /= IDENT_DER(DER_FORM(DER_FORM'POS(DER_VAR)))
THEN FAILED ("IMPROPER VALUE FOR DER_FORM'POS(DER_VAR)");
END IF;
DER_FORM_VAL := DER_FORM'VAL(DER_VAR);
IF DER_FORM_VAL /= IDENT_DER(DER_FORM'VAL(DER_VAR)) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'VAL(DER_VAR)");
END IF;
DER_FORM_SUCC := DER_FORM'SUCC(DER_VAR);
IF DER_FORM_SUCC /= IDENT_DER(DER_FORM'SUCC(DER_VAR)) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'SUCC(DER_VAR)");
END IF;
DER_FORM_PRED := DER_FORM'PRED(DER_VAR);
IF DER_FORM_PRED /= IDENT_DER(DER_FORM'PRED(DER_VAR)) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'PRED(DER_VAR)");
END IF;
DER_FORM_IMAGE := DER_FORM'IMAGE(DER_VAR);
IF DER_FORM_IMAGE(2..5) /= "1000" THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'IMAGE(DER_VAR)");
END IF;
DER_FORM_VALUE := DER_FORM'VALUE(DER_FORM_IMAGE);
IF DER_FORM_VALUE /= IDENT_DER(1000) THEN
FAILED ("IMPROPER VALUE FOR DER_FORM'VALUE" &
"(DER_FORM_IMAGE)");
END IF;
DER_VAR_SIZE := DER_FORM(DER_VAR'SIZE);
IF DER_VAR_SIZE /= IDENT_DER(DER_FORM(DER_VAR'SIZE)) THEN
FAILED ("IMPROPER VALUE FOR DER_VAR'SIZE");
END IF;
DER_VAR_ADDRESS := DER_VAR'ADDRESS;
IF DER_VAR_ADDRESS /= IDENT_ADR(DER_VAR'ADDRESS) THEN
FAILED ("IMPROPER VALUE FOR DER_VAR'ADDRESS");
END IF;
DER_EQUAL := IDENT_DER(1000);
IF DER_VAR /= DER_EQUAL THEN
FAILED ("IMPROPER RESULT FROM INEQUALITY OPERATOR");
END IF;
DER_UNEQUAL := IDENT_DER(500);
IF DER_VAR = DER_UNEQUAL THEN
FAILED ("IMPROPER RESULT FROM EQUALITY OPERATOR");
END IF;
IF DER_VAR < DER_UNEQUAL THEN
FAILED ("IMPROPER RESULT FROM LESS THAN OPERATOR");
END IF;
IF DER_VAR <= DER_UNEQUAL THEN
FAILED ("IMPROPER RESULT FROM LESS THAN OR EQUAL TO " &
"OPERATOR");
END IF;
DER_GREATER := IDENT_DER(1500);
IF DER_VAR > DER_GREATER THEN
FAILED ("IMPROPER RESULT FROM GREATER THAN OPERATOR");
END IF;
IF DER_VAR >= DER_GREATER THEN
FAILED ("IMPROPER RESULT FROM GREATER THAN OR EQUAL " &
"TO OPERATOR");
END IF;
DER_VAR := DER_VAR + DER_EQUAL;
IF DER_VAR /= IDENT_DER(2000) THEN
FAILED ("IMPROPER RESULT FROM ADDITION OPERATOR");
END IF;
DER_VAR := DER_VAR - DER_EQUAL;
IF DER_VAR /= IDENT_DER(1000) THEN
FAILED ("IMPROPER RESULT FROM SUBTRACTION OPERATOR");
END IF;
DER_VAR := DER_VAR * IDENT_DER(2);
IF DER_VAR /= IDENT_DER(2000) THEN
FAILED ("IMPROPER RESULT FROM MULTIPLICATION OPERATOR");
END IF;
DER_VAR := DER_VAR / IDENT_DER(2);
IF DER_VAR /= IDENT_DER(1000) THEN
FAILED ("IMPROPER RESULT FROM DIVISION OPERATOR");
END IF;
DER_MOD := DER_GREATER MOD DER_VAR;
IF DER_MOD /= IDENT_DER(500) THEN
FAILED ("IMPROPER RESULT FROM MOD OPERATOR");
END IF;
DER_REM := DER_GREATER REM DER_VAR;
IF DER_REM /= IDENT_DER(500) THEN
FAILED ("IMPROPER RESULT FROM REM OPERATOR");
END IF;
DER_ABS := ABS(IDENT_DER(-1500));
IF DER_ABS /= IDENT_DER(DER_GREATER) THEN
FAILED ("IMPROPER RESULT FROM ABS OPERATOR");
END IF;
DER_EXP := IDENT_DER(2) ** IDENT_INT(2);
IF DER_EXP /= IDENT_DER(4) THEN
FAILED ("IMPROPER RESULT FROM EXPONENTIATION OPERATOR");
END IF;
RESULT;
END P;
PACKAGE PACK IS NEW P(INTEGER);
BEGIN
NULL;
END CC1227A;
|
package I_Am_Ada is
procedure Ada_Procedure;
pragma Export (C, Ada_Procedure, "ada_procedure");
end I_Am_Ada;
|
--------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Vulkan.Math.GenType;
with Vulkan.Math.GenBType;
with Vulkan.Math.GenUType;
use Vulkan.Math.GenBType;
use Vulkan.Math.GenUType;
--------------------------------------------------------------------------------
--< @group Vulkan Math GenType
--------------------------------------------------------------------------------
--< @summary
--< This package describes any length vector of Vkm_Int type.
--<
--< @description
--< Provides an instantiation of the generic GenType package with a Base_Type of
--< Vkm_Int. This is used to provide the Vkm_GenIType subtype for the Vulkan Math
--< library.
--------------------------------------------------------------------------------
package Vulkan.Math.GenIType is
pragma Preelaborate;
pragma Pure;
--< @private
--< An instance of the generic GenType package, with Vkm_Int as the Base_Type.
package GIT is new Vulkan.Math.GenType(
Base_Type => Vkm_Int,
Default_Value => 0,
Image => Vkm_Int'Image,
Unary_Minus => "-",
Multiply => "*");
--< A subtype of the instantiated Vkm_GenType that represents the GenIType
--< described in the GLSL specification.
subtype Vkm_GenIType is GIT.Vkm_GenType;
----------------------------------------------------------------------------
-- Generic Operations
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--< @summary
--< Apply function for parameters of Vkm_Int and Vkm_Bool type to GenIType
--< and GenBType vectors.
--<
--< @description
--< Applies a supplied function component wise on two GenIType vectors and
--< a GenBType vector returning a GenIType vector.
--<
--< RVI := [Func(IVI1.x, IVI2.x, IVB1.x) ... Func(IVI1.w, IVI2.w, IVB1.w)]
--<
--< @param IVI1
--< The first input GenIType parameter.
--<
--< @param IVI2
--< The second input GenIType parameter.
--<
--< @param IVB1
--< The first input GenBType parameter.
--<
--< @return
--< The result GenIType vector, RVI.
----------------------------------------------------------------------------
generic
with function Func(ISI1, ISI2 : in Vkm_Int;
ISB1 : in Vkm_Bool ) return Vkm_Int;
function Apply_Func_IVI_IVI_IVB_RVI(IVI1, IVI2 : in Vkm_GenIType;
IVB1 : in Vkm_GenBType) return Vkm_GenIType;
----------------------------------------------------------------------------
--< @summary
--< Apply function on two Vkm_Int inputs that returns a Vkm_Bool component-wise
--< to two Vkm_GenIType vectors.
--<
--< @description
--< Applies a supplied function component wise on two GenIType vectors,
--< returning a GenBType vector.
--<
--< RVB := [Func(IVI1.x,IVI2.x) ... Func(IVI1.w,IVI2.w)]
--<
--< @param IVI1
--< The first input GenIType parameter.
--<
--< @param IVI2
--< The second input GenIType parameter.
--<
--< @return
--< The resulting GenBType vector, RVB.
----------------------------------------------------------------------------
generic
with function Func(ISI1, ISI2 : in Vkm_Int) return Vkm_Bool;
function Apply_Func_IVI_IVI_RVB(IVI1, IVI2 : in Vkm_GenIType) return Vkm_GenBType;
----------------------------------------------------------------------------
--< @summary
--< Apply function on a Vkm_Uint input that returns a Vkm_Int component-wise
--< on a Vkm_GenUType vector.
--<
--< @description
--< Applies a supplied function component wise on a GenUType vectors,
--< returning a GenIType vector.
--<
--< RVU := [Func(IVI1.x) ... Func(IVI1.w)]
--<
--< @param IVU1
--< The first input GenIType parameter.
--<
--< @return
--< The resulting GenIType vector, RVI.
----------------------------------------------------------------------------
generic
with function Func(ISU1 : in Vkm_Uint) return Vkm_Int;
function Apply_Func_IVU_RVI(IVU1 : in Vkm_GenUType) return Vkm_GenIType;
end Vulkan.Math.GenIType;
|
package body Runtime is
procedure OS_Exit
(Status : Integer)
is
pragma Unreferenced (Status);
begin
null;
end OS_Exit;
procedure HardFault_Handler is
begin
loop
null;
end loop;
end HardFault_Handler;
end Runtime;
|
with Ada.Text_IO, Ada.Numerics.Float_Random;
procedure One_Of_N is
Num_Of_Lines: constant Positive := 10;
package Rnd renames Ada.Numerics.Float_Random;
Gen: Rnd.Generator; -- used globally
function Choose_One_Of_N(Last_Line_Number: Positive) return Natural is
Current_Choice: Natural := 0;
begin
for Line_Number in 1 .. Last_Line_Number loop
if (Rnd.Random(Gen) * Float(Line_Number) <= 1.0) then
Current_Choice := Line_Number;
end if;
end loop;
return Current_Choice;
end Choose_One_Of_N;
Results: array(1 .. Num_Of_Lines) of Natural := (others => 0);
Index: Integer range 1 .. Num_Of_Lines;
begin
Rnd.Reset(Gen);
for I in 1 .. 1_000_000 loop -- compute results
Index := Choose_One_Of_N(Num_Of_Lines);
Results(Index) := Results(Index) + 1;
end loop;
for R in Results'Range loop -- output results
Ada.Text_IO.Put(Integer'Image(Results(R)));
end loop;
end One_Of_N;
|
-- reference:
-- http://www.mudpedia.org/mediawiki/index.php/Xterm_256_colors
with System.Address_To_Named_Access_Conversions;
with System.Formatting;
with System.Long_Long_Integer_Types;
with System.Once;
with C.stdlib;
package body System.Native_Text_IO.Terminal_Colors is
use type C.char_array;
use type C.char_ptr;
use type C.signed_int;
use type C.size_t;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
function strlen (s : not null access constant C.char) return C.size_t
with Import,
Convention => Intrinsic, External_Name => "__builtin_strlen";
package char_ptr_Conv is
new Address_To_Named_Access_Conversions (C.char, C.char_ptr);
TERM_Variable : constant C.char_array (0 .. 4) := "TERM" & C.char'Val (0);
xterm_256color : constant String (1 .. 14) := "xterm-256color";
Support_256_Color_Flag : aliased Once.Flag := 0;
Support_256_Color : Boolean;
procedure Support_256_Color_Init;
procedure Support_256_Color_Init is
TERM : C.char_ptr;
begin
TERM := C.stdlib.getenv (TERM_Variable (0)'Access);
if TERM /= null
and then strlen (TERM) = xterm_256color'Length
then
declare
TERM_All : String (1 .. xterm_256color'Length);
for TERM_All'Address use char_ptr_Conv.To_Address (TERM);
begin
Support_256_Color := TERM_All = xterm_256color;
end;
else
Support_256_Color := False;
end if;
end Support_256_Color_Init;
procedure Initialize;
procedure Initialize is
begin
Once.Initialize (
Support_256_Color_Flag'Access,
Support_256_Color_Init'Access);
end Initialize;
function RGB_To_256_Color (Item : Ada.Colors.RGB) return Color;
function RGB_To_256_Color (Item : Ada.Colors.RGB) return Color is
subtype B is Ada.Colors.Brightness'Base;
function Color_Scale (Item : B) return Color;
function Color_Scale (Item : B) return Color is
begin
if Item < (0.0 + 16#5F.0#) / 2.0 / 255.0 then
return 0;
elsif Item < (16#5F.0# + 16#87.0#) / 2.0 / 255.0 then
return 1;
elsif Item < (16#87.0# + 16#AF.0#) / 2.0 / 255.0 then
return 2;
elsif Item < (16#AF.0# + 16#D7.0#) / 2.0 / 255.0 then
return 3;
elsif Item < (16#D7.0# + 16#FF.0#) / 2.0 / 255.0 then
return 4;
else
return 5;
end if;
end Color_Scale;
begin
return 16
+ 36 * Color_Scale (Item.Red)
+ 6 * Color_Scale (Item.Green)
+ Color_Scale (Item.Blue);
end RGB_To_256_Color;
function Brightness_To_Grayscale_256_Color (Item : Ada.Colors.Brightness)
return Color;
function Brightness_To_Grayscale_256_Color (Item : Ada.Colors.Brightness)
return Color
is
subtype B is Ada.Colors.Brightness'Base;
Grayscale_Index : constant Integer :=
(Integer (B'Floor (Item * B'Pred (250.0))) + 5) / 10 - 1 + 232;
begin
if Grayscale_Index < 232 then
return 16; -- 16#00#
elsif Grayscale_Index <= 255 then -- in 232 .. 255
return Color (Grayscale_Index);
else
return 16 + 6#555#; -- 16#FF#
end if;
end Brightness_To_Grayscale_256_Color;
function RGB_To_System_Color (Item : Ada.Colors.RGB) return Color;
function RGB_To_System_Color (Item : Ada.Colors.RGB) return Color is
subtype B is Ada.Colors.Brightness'Base;
Result : Color;
begin
if Item.Red in 0.25 .. B'Pred (0.675)
and then Item.Green in 0.25 .. B'Pred (0.675)
and then Item.Blue in 0.25 .. B'Pred (0.675)
then -- Dark_Gray = (16#80#, 16#80#, 16#80#)
Result := 8;
elsif Item.Red >= 0.875
or else Item.Green >= 0.875
or else Item.Blue >= 0.875
then -- bright colors
Result := 8;
if Item.Red >= 0.875 then
Result := Result or 1;
end if;
if Item.Green >= 0.875 then
Result := Result or 2;
end if;
if Item.Blue >= 0.875 then
Result := Result or 4;
end if;
else -- dark colors
Result := 0;
if Item.Red >= 0.375 then
Result := Result or 1;
end if;
if Item.Green >= 0.375 then
Result := Result or 2;
end if;
if Item.Blue >= 0.375 then
Result := Result or 4;
end if;
end if;
return Result;
end RGB_To_System_Color;
function Brightness_To_Grayscale_System_Color (Item : Ada.Colors.Brightness)
return Color;
function Brightness_To_Grayscale_System_Color (Item : Ada.Colors.Brightness)
return Color is
begin
-- [0.000 .. 0.250) => 0
-- [0.250 .. 0.625) => 16#80# = 8
-- [0.625 .. 0.875) => 16#C0# = 7
-- [0.875 .. 1.000] => 16#FF# = 15
return RGB_To_System_Color ((Red => Item, Green => Item, Blue => Item));
end Brightness_To_Grayscale_System_Color;
-- implementation
function RGB_To_Color (Item : Ada.Colors.RGB) return Color is
begin
Initialize;
if Support_256_Color then
return RGB_To_256_Color (Item);
else
return RGB_To_System_Color (Item);
end if;
end RGB_To_Color;
function Brightness_To_Grayscale_Color (Item : Ada.Colors.Brightness)
return Color is
begin
Initialize;
if Support_256_Color then
return Brightness_To_Grayscale_256_Color (Item);
else
return Brightness_To_Grayscale_System_Color (Item);
end if;
end Brightness_To_Grayscale_Color;
procedure Set (
Handle : Handle_Type;
Reset : Boolean;
Bold_Changing : Boolean;
Bold : Boolean;
Underline_Changing : Boolean;
Underline : Boolean;
Blink_Changing : Boolean;
Blink : Boolean;
Reversed_Changing : Boolean;
Reversed : Boolean;
Foreground_Changing : Boolean;
Foreground : Color;
Background_Changing : Boolean;
Background : Color)
is
Seq : String (1 .. 256);
Last : Natural;
Error : Boolean;
begin
Seq (1) := Character'Val (16#1B#);
Seq (2) := '[';
Last := 2;
-- changing
if Reset then
Last := Last + 1;
Seq (Last) := '0';
end if;
if Bold_Changing and then Bold then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '1';
end if;
if Underline_Changing and then Underline then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '4';
end if;
if Blink_Changing and then Blink then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '5';
end if;
if Reversed_Changing and then Reversed then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '7';
end if;
if Foreground_Changing then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
declare
Color_Index : Word_Unsigned := Word_Unsigned (Foreground);
begin
if Foreground < 16#10# then
-- system color
if (Foreground and 8) = 0 then
Last := Last + 1;
Seq (Last) := '3';
else
Last := Last + 1;
Seq (Last) := '9';
Color_Index := Word_Unsigned (Foreground and 7);
end if;
else
-- 256 color
Seq (Last + 1 .. Last + 5) := "38;5;";
Last := Last + 5;
end if;
Formatting.Image (
Color_Index,
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
end;
end if;
if Background_Changing then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
declare
Color_Index : Word_Unsigned := Word_Unsigned (Background);
begin
if Background < 16#10# then
-- system color
if (Background and 8) = 0 then
Last := Last + 1;
Seq (Last) := '4';
else
Last := Last + 1;
Seq (Last) := '1';
Last := Last + 1;
Seq (Last) := '0';
Color_Index := Word_Unsigned (Background and 7);
end if;
else
-- 256 color
Seq (Last + 1 .. Last + 5) := "48;5;";
Last := Last + 5;
end if;
Formatting.Image (
Color_Index,
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
end;
end if;
-- setting
if Last > 2 then
Last := Last + 1;
Seq (Last) := 'm';
Write_Just (Handle, Seq (1 .. Last));
end if;
end Set;
procedure Reset (
Handle : Handle_Type)
is
Seq : constant String (1 .. 4) :=
(Character'Val (16#1b#), '[', '0', 'm');
begin
Write_Just (Handle, Seq);
end Reset;
end System.Native_Text_IO.Terminal_Colors;
|
-- This spec has been automatically generated from STM32F103.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.AFIO is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype EVCR_PIN_Field is STM32_SVD.UInt4;
subtype EVCR_PORT_Field is STM32_SVD.UInt3;
subtype EVCR_EVOE_Field is STM32_SVD.Bit;
-- Event Control Register (AFIO_EVCR)
type EVCR_Register is record
-- Pin selection
PIN : EVCR_PIN_Field := 16#0#;
-- Port selection
PORT : EVCR_PORT_Field := 16#0#;
-- Event Output Enable
EVOE : EVCR_EVOE_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EVCR_Register use record
PIN at 0 range 0 .. 3;
PORT at 0 range 4 .. 6;
EVOE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype MAPR_SPI1_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_I2C1_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_USART1_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_USART2_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_USART3_REMAP_Field is STM32_SVD.UInt2;
subtype MAPR_TIM1_REMAP_Field is STM32_SVD.UInt2;
subtype MAPR_TIM2_REMAP_Field is STM32_SVD.UInt2;
subtype MAPR_TIM3_REMAP_Field is STM32_SVD.UInt2;
subtype MAPR_TIM4_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_CAN_REMAP_Field is STM32_SVD.UInt2;
subtype MAPR_PD01_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_TIM5CH4_IREMAP_Field is STM32_SVD.Bit;
subtype MAPR_ADC1_ETRGINJ_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_ADC1_ETRGREG_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_ADC2_ETRGINJ_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_ADC2_ETRGREG_REMAP_Field is STM32_SVD.Bit;
subtype MAPR_SWJ_CFG_Field is STM32_SVD.UInt3;
-- AF remap and debug I/O configuration register (AFIO_MAPR)
type MAPR_Register is record
-- SPI1 remapping
SPI1_REMAP : MAPR_SPI1_REMAP_Field := 16#0#;
-- I2C1 remapping
I2C1_REMAP : MAPR_I2C1_REMAP_Field := 16#0#;
-- USART1 remapping
USART1_REMAP : MAPR_USART1_REMAP_Field := 16#0#;
-- USART2 remapping
USART2_REMAP : MAPR_USART2_REMAP_Field := 16#0#;
-- USART3 remapping
USART3_REMAP : MAPR_USART3_REMAP_Field := 16#0#;
-- TIM1 remapping
TIM1_REMAP : MAPR_TIM1_REMAP_Field := 16#0#;
-- TIM2 remapping
TIM2_REMAP : MAPR_TIM2_REMAP_Field := 16#0#;
-- TIM3 remapping
TIM3_REMAP : MAPR_TIM3_REMAP_Field := 16#0#;
-- TIM4 remapping
TIM4_REMAP : MAPR_TIM4_REMAP_Field := 16#0#;
-- CAN1 remapping
CAN_REMAP : MAPR_CAN_REMAP_Field := 16#0#;
-- Port D0/Port D1 mapping on OSCIN/OSCOUT
PD01_REMAP : MAPR_PD01_REMAP_Field := 16#0#;
-- Set and cleared by software
TIM5CH4_IREMAP : MAPR_TIM5CH4_IREMAP_Field := 16#0#;
-- ADC 1 External trigger injected conversion remapping
ADC1_ETRGINJ_REMAP : MAPR_ADC1_ETRGINJ_REMAP_Field := 16#0#;
-- ADC 1 external trigger regular conversion remapping
ADC1_ETRGREG_REMAP : MAPR_ADC1_ETRGREG_REMAP_Field := 16#0#;
-- ADC 2 external trigger injected conversion remapping
ADC2_ETRGINJ_REMAP : MAPR_ADC2_ETRGINJ_REMAP_Field := 16#0#;
-- ADC 2 external trigger regular conversion remapping
ADC2_ETRGREG_REMAP : MAPR_ADC2_ETRGREG_REMAP_Field := 16#0#;
-- unspecified
Reserved_21_23 : STM32_SVD.UInt3 := 16#0#;
-- Write-only. Serial wire JTAG configuration
SWJ_CFG : MAPR_SWJ_CFG_Field := 16#0#;
-- unspecified
Reserved_27_31 : STM32_SVD.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MAPR_Register use record
SPI1_REMAP at 0 range 0 .. 0;
I2C1_REMAP at 0 range 1 .. 1;
USART1_REMAP at 0 range 2 .. 2;
USART2_REMAP at 0 range 3 .. 3;
USART3_REMAP at 0 range 4 .. 5;
TIM1_REMAP at 0 range 6 .. 7;
TIM2_REMAP at 0 range 8 .. 9;
TIM3_REMAP at 0 range 10 .. 11;
TIM4_REMAP at 0 range 12 .. 12;
CAN_REMAP at 0 range 13 .. 14;
PD01_REMAP at 0 range 15 .. 15;
TIM5CH4_IREMAP at 0 range 16 .. 16;
ADC1_ETRGINJ_REMAP at 0 range 17 .. 17;
ADC1_ETRGREG_REMAP at 0 range 18 .. 18;
ADC2_ETRGINJ_REMAP at 0 range 19 .. 19;
ADC2_ETRGREG_REMAP at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
SWJ_CFG at 0 range 24 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-- EXTICR1_EXTI array element
subtype EXTICR1_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR1_EXTI array
type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR1_EXTI
type EXTICR1_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR1_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR1_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 1 (AFIO_EXTICR1)
type EXTICR1_Register is record
-- EXTI0 configuration
EXTI : EXTICR1_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR1_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR2_EXTI array element
subtype EXTICR2_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR2_EXTI array
type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR2_EXTI
type EXTICR2_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR2_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR2_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 2 (AFIO_EXTICR2)
type EXTICR2_Register is record
-- EXTI4 configuration
EXTI : EXTICR2_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR2_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR3_EXTI array element
subtype EXTICR3_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR3_EXTI array
type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR3_EXTI
type EXTICR3_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR3_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR3_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 3 (AFIO_EXTICR3)
type EXTICR3_Register is record
-- EXTI8 configuration
EXTI : EXTICR3_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR3_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR4_EXTI array element
subtype EXTICR4_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR4_EXTI array
type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR4_EXTI
type EXTICR4_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR4_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR4_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 4 (AFIO_EXTICR4)
type EXTICR4_Register is record
-- EXTI12 configuration
EXTI : EXTICR4_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR4_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype MAPR2_TIM9_REMAP_Field is STM32_SVD.Bit;
subtype MAPR2_TIM10_REMAP_Field is STM32_SVD.Bit;
subtype MAPR2_TIM11_REMAP_Field is STM32_SVD.Bit;
subtype MAPR2_TIM13_REMAP_Field is STM32_SVD.Bit;
subtype MAPR2_TIM14_REMAP_Field is STM32_SVD.Bit;
subtype MAPR2_FSMC_NADV_Field is STM32_SVD.Bit;
-- AF remap and debug I/O configuration register
type MAPR2_Register is record
-- unspecified
Reserved_0_4 : STM32_SVD.UInt5 := 16#0#;
-- TIM9 remapping
TIM9_REMAP : MAPR2_TIM9_REMAP_Field := 16#0#;
-- TIM10 remapping
TIM10_REMAP : MAPR2_TIM10_REMAP_Field := 16#0#;
-- TIM11 remapping
TIM11_REMAP : MAPR2_TIM11_REMAP_Field := 16#0#;
-- TIM13 remapping
TIM13_REMAP : MAPR2_TIM13_REMAP_Field := 16#0#;
-- TIM14 remapping
TIM14_REMAP : MAPR2_TIM14_REMAP_Field := 16#0#;
-- NADV connect/disconnect
FSMC_NADV : MAPR2_FSMC_NADV_Field := 16#0#;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MAPR2_Register use record
Reserved_0_4 at 0 range 0 .. 4;
TIM9_REMAP at 0 range 5 .. 5;
TIM10_REMAP at 0 range 6 .. 6;
TIM11_REMAP at 0 range 7 .. 7;
TIM13_REMAP at 0 range 8 .. 8;
TIM14_REMAP at 0 range 9 .. 9;
FSMC_NADV at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Alternate function I/O
type AFIO_Peripheral is record
-- Event Control Register (AFIO_EVCR)
EVCR : aliased EVCR_Register;
-- AF remap and debug I/O configuration register (AFIO_MAPR)
MAPR : aliased MAPR_Register;
-- External interrupt configuration register 1 (AFIO_EXTICR1)
EXTICR1 : aliased EXTICR1_Register;
-- External interrupt configuration register 2 (AFIO_EXTICR2)
EXTICR2 : aliased EXTICR2_Register;
-- External interrupt configuration register 3 (AFIO_EXTICR3)
EXTICR3 : aliased EXTICR3_Register;
-- External interrupt configuration register 4 (AFIO_EXTICR4)
EXTICR4 : aliased EXTICR4_Register;
-- AF remap and debug I/O configuration register
MAPR2 : aliased MAPR2_Register;
end record
with Volatile;
for AFIO_Peripheral use record
EVCR at 16#0# range 0 .. 31;
MAPR at 16#4# range 0 .. 31;
EXTICR1 at 16#8# range 0 .. 31;
EXTICR2 at 16#C# range 0 .. 31;
EXTICR3 at 16#10# range 0 .. 31;
EXTICR4 at 16#14# range 0 .. 31;
MAPR2 at 16#1C# range 0 .. 31;
end record;
-- Alternate function I/O
AFIO_Periph : aliased AFIO_Peripheral
with Import, Address => System'To_Address (16#40010000#);
end STM32_SVD.AFIO;
|
-- { dg-do run }
-- { dg-options "-gnatp" }
-- This test requires architecture- and OS-specific support code for unwinding
-- through signal frames (typically located in *-unwind.h) to pass. Feel free
-- to disable it if this code hasn't been implemented yet.
procedure Null_Pointer_Deref2 is
task T;
task body T is
type Int_Ptr is access all Integer;
function Ident return Int_Ptr is
begin
return null;
end;
Data : Int_Ptr := Ident;
begin
Data.all := 1;
exception
when others => null;
end T;
begin
null;
end;
|
with Ada.Text_IO; use Ada.Text_IO;
package body HTTP.Request is
package body Parse is
procedure Debug (Ctx : in Context; Str : in String) is
function Slice (Idx: in HTTP.Indexes; Str : in String) return String
is (Str (Idx.First .. Idx.Last));
begin
Put_Line ("KIND: " & Slice (Ctx.Split.Line.Kind, Str));
Put_Line ("PATH: " & Slice (Ctx.Split.Line.Path, Str));
Put_Line ("VERS: " & Slice (Ctx.Split.Line.Vers, Str));
for I in Integer range 1 .. Ctx.Split.Cnt-1 loop
Put_Line ("["
& Slice (Ctx.Split.Headers (I).Key, Str) & ": "
& Slice (Ctx.Split.Headers (I).Val, Str)
&
"]");
end loop;
Put_Line ("TERMINAL STATE: " & Parse_State'Image (Ctx.State));
end Debug;
package State is
type Char_Table is array (Character) of Parse_State;
type Step_Table is array (Parse_State) of Char_Table;
subtype Up is Character range 'A' .. 'Z';
subtype Low is Character range 'a' .. 'z';
subtype Num is Character range '0' .. '9';
CR : constant Character := ASCII.CR; LF : constant Character := ASCII.LF;
-- A mealy machine expressed as a lookup table, for request parsing;
Table : Step_Table :=
(
Kind => (Up => Kind, ' ' => Path, others => Err),
Path => (Up | Low |'/' | '.' => Path, ' ' => Pref, others => Err),
Pref => (Up | Num |'/' | '.' => Pref, CR => Line, others => Err),
--------------------------------------------------------------------
-- TODO: ... Perhaps put the transitions for Responses here.
--------------------------------------------------------------------
Line => ( LF => Head, others => Err),
Head => (Up|Low|'-' => Head, ':' => SSep, CR => Term, others => Err),
SSep => ( ' ' => HBod, others => Err ),
HBod => (CR => Line, others => HBod),
Term => (LF => Done, others => Err ),
Done => (others => Overread),
Overread => (others => Overread), -- Maps to itself.
Err => (others => Err )); -- Maps to itself.
function Step (St : Parse_State; Ch : Character) return Parse_State
is (State.Table (St) (Ch));
end State;
procedure Update_Split (Req : in out As_Sliced;
Prv, Nxt : in Parse_State;
Count : in Natural) is
procedure Update (Next_Indxs : in out Indexes;
Transition : in Boolean) is
begin
if Transition then Next_Indxs.First := Count + 1; end if;
Next_Indxs.Last := Count;
end Update;
Trans : Boolean := Prv /= Nxt;
begin -- TODO: Use inheiritance + casting to have a single function.
case Nxt is
when Kind => Update (Req.Line.Kind, False);
when Path => Update (Req.Line.Path, Trans);
when Pref => Update (Req.Line.Vers, Trans);
when Head => Update (Req.Headers (Req.Cnt).Key, Trans);
when HBod => Update (Req.Headers (Req.Cnt).Val, Trans);
when Line => Req.Cnt := Req.Cnt + 1;
when others => null;
end case;
end Update_Split;
procedure One_Char (Ctx : in out Context; Char : in Character) is
Next_State : Parse_State;
begin
Next_State := State.Step(Ctx.State, Char);
Update_Split (Ctx.Split, Ctx.State, Next_State, Ctx.Count);
Ctx. Count := Ctx. Count + 1;
Ctx. State := Next_State;
end One_Char;
procedure Str_Read (Ctx: in out Context; Str: in String; Cnt: out Natural) is
Original : Positive := Ctx.Count;
begin
for I in Str'Range loop
One_Char (Ctx, Str (I));
exit when Ctx. State = Done;
end loop;
Cnt := Ctx. Count - Original;
end Str_Read;
end Parse;
end HTTP.Request;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T R A C E S . T A S K I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2005 Free Software Foundation, Inc. --
-- --
-- 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 2, 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Tasking; use System.Tasking;
with System.Soft_Links;
with System.Parameters;
with System.Traces.Format; use System.Traces.Format;
with System.Traces; use System.Traces;
package body System.Traces.Tasking is
use System.Traces;
package SSL renames System.Soft_Links;
function Extract_Accepts (Task_Name : Task_Id) return String_Trace;
-- This function is used to extract data joined with
-- W_Select, WT_Select, W_Accept events
---------------------
-- Send_Trace_Info --
---------------------
procedure Send_Trace_Info (Id : Trace_T; Task_Name2 : Task_Id) is
Task_S : constant String := SSL.Task_Name.all;
Task2_S : constant String :=
Task_Name2.Common.Task_Image
(1 .. Task_Name2.Common.Task_Image_Len);
Trace_S : String (1 .. 6 + Task_S'Length + Task2_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task2_S'Length;
begin
if Parameters.Runtime_Traces then
case Id is
when M_RDV_Complete | PO_Done =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/C:";
Trace_S (7 + L0 .. Trace_S'Last) := Task2_S;
Send_Trace (Id, Trace_S);
when E_Missed =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/A:";
Trace_S (7 + L0 .. Trace_S'Last) := Task2_S;
Send_Trace (Id, Trace_S);
when E_Kill =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L1) := Task2_S;
Trace_S (4 + L1 .. Trace_S'Last) := (others => ' ');
Send_Trace (Id, Trace_S);
when T_Create =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L1) := Task2_S;
Trace_S (4 + L1 .. Trace_S'Last) := (others => ' ');
Send_Trace (Id, Trace_S);
when others =>
null;
-- should raise an exception ???
end case;
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Task_Name2 : Task_Id;
Entry_Number : Entry_Index)
is
Task_S : constant String := SSL.Task_Name.all;
Task2_S : constant String :=
Task_Name2.Common.Task_Image
(1 .. Task_Name2.Common.Task_Image_Len);
Entry_S : constant String := Integer'Image (Integer (Entry_Number));
Trace_S : String (1 .. 9 + Task_S'Length
+ Task2_S'Length + Entry_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task_S'Length + Entry_S'Length;
L2 : constant Integer := Task_S'Length + Task2_S'Length;
begin
if Parameters.Runtime_Traces then
case Id is
when M_Accept_Complete =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/E:";
Trace_S (7 + L0 .. 6 + L1) := Entry_S;
Trace_S (7 + L1 .. 9 + L1) := "/C:";
Trace_S (10 + L1 .. Trace_S'Last) := Task2_S;
Send_Trace (Id, Trace_S);
when W_Call =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/A:";
Trace_S (7 + L0 .. 6 + L2) := Task2_S;
Trace_S (7 + L2 .. 9 + L2) := "/C:";
Trace_S (10 + L2 .. Trace_S'Last) := Entry_S;
Send_Trace (Id, Trace_S);
when others =>
null;
-- should raise an exception ???
end case;
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Task_Name : Task_Id;
Task_Name2 : Task_Id;
Entry_Number : Entry_Index)
is
Task_S : constant String :=
Task_Name.Common.Task_Image
(1 .. Task_Name.Common.Task_Image_Len);
Task2_S : constant String :=
Task_Name2.Common.Task_Image
(1 .. Task_Name2.Common.Task_Image_Len);
Entry_S : constant String := Integer'Image (Integer (Entry_Number));
Trace_S : String (1 .. 9 + Task_S'Length
+ Task2_S'Length + Entry_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task_S'Length + Entry_S'Length;
begin
if Parameters.Runtime_Traces then
case Id is
when PO_Run =>
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/E:";
Trace_S (7 + L0 .. 6 + L1) := Entry_S;
Trace_S (7 + L1 .. 9 + L1) := "/C:";
Trace_S (10 + L1 .. Trace_S'Last) := Task2_S;
Send_Trace (Id, Trace_S);
when others =>
null;
-- should raise an exception ???
end case;
end if;
end Send_Trace_Info;
procedure Send_Trace_Info (Id : Trace_T; Entry_Number : Entry_Index) is
Task_S : constant String := SSL.Task_Name.all;
Entry_S : constant String := Integer'Image (Integer (Entry_Number));
Trace_S : String (1 .. 6 + Task_S'Length + Entry_S'Length);
L0 : constant Integer := Task_S'Length;
begin
if Parameters.Runtime_Traces then
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/E:";
Trace_S (7 + L0 .. Trace_S'Last) := Entry_S;
Send_Trace (Id, Trace_S);
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Task_Name : Task_Id;
Task_Name2 : Task_Id)
is
Task_S : constant String :=
Task_Name.Common.Task_Image
(1 .. Task_Name.Common.Task_Image_Len);
Task2_S : constant String :=
Task_Name2.Common.Task_Image
(1 .. Task_Name2.Common.Task_Image_Len);
Trace_S : String (1 .. 6 + Task_S'Length + Task2_S'Length);
L0 : constant Integer := Task2_S'Length;
begin
if Parameters.Runtime_Traces then
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task2_S;
Trace_S (4 + L0 .. 6 + L0) := "/P:";
Trace_S (7 + L0 .. Trace_S'Last) := Task_S;
Send_Trace (Id, Trace_S);
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Acceptor : Task_Id;
Entry_Number : Entry_Index;
Timeout : Duration)
is
Task_S : constant String := SSL.Task_Name.all;
Acceptor_S : constant String :=
Acceptor.Common.Task_Image
(1 .. Acceptor.Common.Task_Image_Len);
Entry_S : constant String := Integer'Image (Integer (Entry_Number));
Timeout_S : constant String := Duration'Image (Timeout);
Trace_S : String (1 .. 12 + Task_S'Length + Acceptor_S'Length
+ Entry_S'Length + Timeout_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task_S'Length + Acceptor_S'Length;
L2 : constant Integer :=
Task_S'Length + Acceptor_S'Length + Entry_S'Length;
begin
if Parameters.Runtime_Traces then
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/A:";
Trace_S (7 + L0 .. 6 + L1) := Acceptor_S;
Trace_S (7 + L1 .. 9 + L1) := "/E:";
Trace_S (10 + L1 .. 9 + L2) := Entry_S;
Trace_S (10 + L2 .. 12 + L2) := "/T:";
Trace_S (13 + L2 .. Trace_S'Last) := Timeout_S;
Send_Trace (Id, Trace_S);
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Entry_Number : Entry_Index;
Timeout : Duration)
is
Task_S : constant String := SSL.Task_Name.all;
Entry_S : constant String := Integer'Image (Integer (Entry_Number));
Timeout_S : constant String := Duration'Image (Timeout);
Trace_S : String (1 .. 9 + Task_S'Length
+ Entry_S'Length + Timeout_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task_S'Length + Entry_S'Length;
begin
if Parameters.Runtime_Traces then
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/E:";
Trace_S (7 + L0 .. 6 + L1) := Entry_S;
Trace_S (7 + L1 .. 9 + L1) := "/T:";
Trace_S (10 + L1 .. Trace_S'Last) := Timeout_S;
Send_Trace (Id, Trace_S);
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Task_Name : Task_Id;
Number : Integer)
is
Task_S : constant String := SSL.Task_Name.all;
Number_S : constant String := Integer'Image (Number);
Accepts_S : constant String := Extract_Accepts (Task_Name);
Trace_S : String (1 .. 9 + Task_S'Length
+ Number_S'Length + Accepts_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task_S'Length + Number_S'Length;
begin
if Parameters.Runtime_Traces then
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/#:";
Trace_S (7 + L0 .. 6 + L1) := Number_S;
Trace_S (7 + L1 .. 9 + L1) := "/E:";
Trace_S (10 + L1 .. Trace_S'Last) := Accepts_S;
Send_Trace (Id, Trace_S);
end if;
end Send_Trace_Info;
procedure Send_Trace_Info
(Id : Trace_T;
Task_Name : Task_Id;
Number : Integer;
Timeout : Duration)
is
Task_S : constant String := SSL.Task_Name.all;
Timeout_S : constant String := Duration'Image (Timeout);
Number_S : constant String := Integer'Image (Number);
Accepts_S : constant String := Extract_Accepts (Task_Name);
Trace_S : String (1 .. 12 + Task_S'Length + Timeout_S'Length
+ Number_S'Length + Accepts_S'Length);
L0 : constant Integer := Task_S'Length;
L1 : constant Integer := Task_S'Length + Timeout_S'Length;
L2 : constant Integer :=
Task_S'Length + Timeout_S'Length + Number_S'Length;
begin
if Parameters.Runtime_Traces then
Trace_S (1 .. 3) := "/N:";
Trace_S (4 .. 3 + L0) := Task_S;
Trace_S (4 + L0 .. 6 + L0) := "/T:";
Trace_S (7 + L0 .. 6 + L1) := Timeout_S;
Trace_S (7 + L1 .. 9 + L1) := "/#:";
Trace_S (10 + L1 .. 9 + L2) := Number_S;
Trace_S (10 + L2 .. 12 + L2) := "/E:";
Trace_S (13 + L2 .. Trace_S'Last) := Accepts_S;
Send_Trace (Id, Trace_S);
end if;
end Send_Trace_Info;
---------------------
-- Extract_Accepts --
---------------------
-- This function returns a string in which all opened
-- Accepts or Selects are given, separated by semi-colons.
function Extract_Accepts (Task_Name : Task_Id) return String_Trace is
Info_Annex : String_Trace := (ASCII.NUL, others => ' ');
begin
for J in Task_Name.Open_Accepts'First ..
Task_Name.Open_Accepts'Last - 1
loop
Info_Annex := Append (Info_Annex, Integer'Image
(Integer (Task_Name.Open_Accepts (J).S)) & ",");
end loop;
Info_Annex := Append (Info_Annex,
Integer'Image (Integer
(Task_Name.Open_Accepts
(Task_Name.Open_Accepts'Last).S)));
return Info_Annex;
end Extract_Accepts;
end System.Traces.Tasking;
|
-- This file is generated by SWIG. Please do *not* modify by hand.
--
with fann_c.fann_callback_type;
with fann_c.fann_layer;
with fann_c.fann_neuron;
with interfaces.c;
with interfaces.c.strings;
with swig;
with interfaces.C;
package fann_c.fann is
-- Item
--
type Item is
record
errno_f : aliased fann_c.fann_errno_enum;
error_log : access fann_c.FILE;
errstr : aliased interfaces.c.strings.chars_ptr;
learning_rate : aliased interfaces.c.c_float;
learning_momentum : aliased interfaces.c.c_float;
connection_rate : aliased interfaces.c.c_float;
network_type : aliased fann_c.fann_nettype_enum;
first_layer : access fann_c.fann_layer.Item;
last_layer : access fann_c.fann_layer.Item;
total_neurons : aliased interfaces.c.unsigned;
num_input : aliased interfaces.c.unsigned;
num_output : aliased interfaces.c.unsigned;
weights : access fann_c.fann_type;
connections : access fann_c.fann_neuron.Pointer;
train_errors : access fann_c.fann_type;
training_algorithm : aliased fann_c.fann_train_enum;
total_connections : aliased interfaces.c.unsigned;
output : access fann_c.fann_type;
num_MSE : aliased interfaces.c.unsigned;
MSE_value : aliased interfaces.c.c_float;
num_bit_fail : aliased interfaces.c.unsigned;
bit_fail_limit : aliased fann_c.fann_type;
train_error_function : aliased fann_c.fann_errorfunc_enum;
train_stop_function : aliased fann_c.fann_stopfunc_enum;
callback : aliased fann_c.fann_callback_type.Item;
user_data : aliased swig.void_ptr;
cascade_output_change_fraction : aliased interfaces.c.c_float;
cascade_output_stagnation_epochs : aliased interfaces.c.unsigned;
cascade_candidate_change_fraction : aliased interfaces.c.c_float;
cascade_candidate_stagnation_epochs : aliased interfaces.c.unsigned;
cascade_best_candidate : aliased interfaces.c.unsigned;
cascade_candidate_limit : aliased fann_c.fann_type;
cascade_weight_multiplier : aliased fann_c.fann_type;
cascade_max_out_epochs : aliased interfaces.c.unsigned;
cascade_max_cand_epochs : aliased interfaces.c.unsigned;
cascade_min_out_epochs : aliased interfaces.c.unsigned;
cascade_min_cand_epochs : aliased interfaces.c.unsigned;
cascade_activation_functions : access fann_c.fann_activationfunc_enum;
cascade_activation_functions_count : aliased interfaces.c.unsigned;
cascade_activation_steepnesses : access fann_c.fann_type;
cascade_activation_steepnesses_count : aliased interfaces.c.unsigned;
cascade_num_candidate_groups : aliased interfaces.c.unsigned;
cascade_candidate_scores : access fann_c.fann_type;
total_neurons_allocated : aliased interfaces.c.unsigned;
total_connections_allocated : aliased interfaces.c.unsigned;
quickprop_decay : aliased interfaces.c.c_float;
quickprop_mu : aliased interfaces.c.c_float;
rprop_increase_factor : aliased interfaces.c.c_float;
rprop_decrease_factor : aliased interfaces.c.c_float;
rprop_delta_min : aliased interfaces.c.c_float;
rprop_delta_max : aliased interfaces.c.c_float;
rprop_delta_zero : aliased interfaces.c.c_float;
sarprop_weight_decay_shift : aliased interfaces.c.c_float;
sarprop_step_error_threshold_factor : aliased interfaces.c.c_float;
sarprop_step_error_shift : aliased interfaces.c.c_float;
sarprop_temperature : aliased interfaces.c.c_float;
sarprop_epoch : aliased interfaces.c.unsigned;
train_slopes : access fann_c.fann_type;
prev_steps : access fann_c.fann_type;
prev_train_slopes : access fann_c.fann_type;
prev_weights_deltas : access fann_c.fann_type;
scale_mean_in : access interfaces.c.c_float;
scale_deviation_in : access interfaces.c.c_float;
scale_new_min_in : access interfaces.c.c_float;
scale_factor_in : access interfaces.c.c_float;
scale_mean_out : access interfaces.c.c_float;
scale_deviation_out : access interfaces.c.c_float;
scale_new_min_out : access interfaces.c.c_float;
scale_factor_out : access interfaces.c.c_float;
end record;
-- Items
--
type Items is array (interfaces.C.Size_t range <>) of aliased fann_c.fann.Item;
-- Pointer
--
type Pointer is access all fann_c.fann.Item;
-- Pointers
--
type Pointers is array (interfaces.C.Size_t range <>) of aliased fann_c.fann.Pointer;
-- Pointer_Pointer
--
type Pointer_Pointer is access all fann_c.fann.Pointer;
end fann_c.fann;
|
with Varsize3_Pkg1; use Varsize3_Pkg1;
package Varsize3_1 is
pragma Elaborate_Body;
Filter : constant Object := True;
end Varsize3_1;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2011, 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 package provides declaration of several data types related to Unicode
-- standard as well as simple useful subprograms.
package Matreshka.Internals.Unicode is
pragma Pure;
-- Unicode code units.
type Code_Unit_16 is mod 2**16;
type Code_Unit_32 is mod 2**32;
-- Unicode code point.
subtype Code_Point is Code_Unit_32 range 0 .. 16#10_FFFF#;
-- Unicode code point or Unicode scalar value.
-- GNAT produce most efficient code for this type comparing with others
-- way of it declaration.
function Is_Valid (Code : Code_Unit_32) return Boolean;
pragma Inline (Is_Valid);
-- Returns True when specified code is valid Unicode scalar value (it
-- is in range of Code_Point and not in surrogate block.
-- Surrogate ranges.
Surrogate_First : constant := 16#D800#;
High_Surrogate_First : constant := 16#D800#;
High_Surrogate_Last : constant := 16#DBFF#;
Low_Surrogate_First : constant := 16#DC00#;
Low_Surrogate_Last : constant := 16#DFFF#;
Surrogate_Last : constant := 16#DFFF#;
-- Hangul syllables constants.
Hangul_Syllable_First : constant := 16#AC00#;
Hangul_Syllable_Last : constant := 16#D7A3#;
S_Base : constant := Hangul_Syllable_First;
L_Base : constant := 16#1100#;
V_Base : constant := 16#1161#; -- Note, it is Vowel_First + 1
T_Base : constant := 16#11A7#; -- Note, it is Trailing_First - 1
L_Count : constant := 19;
V_Count : constant := 21;
T_Count : constant := 28;
N_Count : constant := V_Count * T_Count; -- 588
S_Count : constant := L_Count * N_Count; -- 11172
-- CJK Ideographs constants, used by collation algoriphm.
CJK_Unified_Ideographs_First : constant := 16#4E00#;
CJK_Unified_Ideographs_Last : constant := 16#9FFF#;
CJK_Compatibility_Ideographs_First : constant := 16#F900#;
CJK_Compatibility_Ideographs_Last : constant := 16#FAFF#;
end Matreshka.Internals.Unicode;
|
-- { dg-do compile }
package Pack33 is
Bits : constant := 33;
type Bits_33 is mod 2 ** Bits;
for Bits_33'Size use Bits;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_33;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
end Pack33;
|
------------------------------------------------------------------------------
-- Copyright (c) 2013-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.String_Slices provide an object that represents a substring of a --
-- shared parent string. --
------------------------------------------------------------------------------
private with Natools.References;
private with Natools.Storage_Pools;
package Natools.String_Slices is
pragma Preelaborate (String_Slices);
-----------------------
-- String range type --
-----------------------
type String_Range is record
First : Positive;
Length : Natural;
end record;
function Is_In (Point : Natural; Reference : String_Range) return Boolean;
function Is_Subrange (Sample, Reference : String_Range) return Boolean;
-- Inclusion tests
function Last (Self : String_Range) return Natural;
-- Return last bound of the given range
function To_Range (First : Positive; Last : Natural) return String_Range;
-- Create a range with the given bounds
function Get_Range (S : String) return String_Range;
-- Return the String_Range representation of S index range.
-- Semantically equivalent to (To_Range (S'First, S'Last))
-- and to (String_Range'(First => S'First, Length => S'Length)).
procedure Set_First (Self : in out String_Range; New_First : in Positive);
-- Update first bound keeping last bound intact
procedure Set_Last (Self : in out String_Range; New_Last : in Natural);
-- Update range for the given last bound, keeping the first one intact
procedure Set_Length (Self : in out String_Range; New_Length : in Natural);
-- Basic mutator included for completeness sake
function Image (Interval : String_Range) return String;
-- Interval representation of the given range
----------------
-- Slice type --
----------------
type Slice is tagged private;
pragma Preelaborable_Initialization (Slice);
Null_Slice : constant Slice;
--------------------------
-- Conversion functions --
--------------------------
function New_Slice
(First : Positive;
Last : Natural;
Initialize : not null access procedure (S : out String))
return Slice;
-- Create a callback-initialized slice
function To_Slice (S : String) return Slice;
-- Create a new slice containing the whole given string
function To_String (S : Slice) return String;
-- Return the string represented by the slice
---------------
-- Accessors --
---------------
procedure Export (S : in Slice; Output : out String);
-- Fill Output with string contents in S
-- Raise Constraint_Error when Output'Length /= Length(S)
procedure Query
(S : in Slice;
Process : not null access procedure (Text : in String));
-- Query the string object directly from memory
function Get_Range (S : Slice) return String_Range;
-- Return the range embedded in S
function First (S : Slice) return Positive;
-- Return the lowest index of S
function Last (S : Slice) return Natural;
-- Return the largest index of S
function Length (S : Slice) return Natural;
-- Return the length of S
---------------
-- Extenders --
---------------
-- These subprograms allow access to the parent string beyond the
-- current range. However Constraint_Error is raised when trying to reach
-- beyond the parent string range.
function Parent (S : Slice) return Slice;
-- Return a slice representing the whole string available
function Extend (S : Slice; New_Range : in String_Range) return Slice;
function Extend (S : Slice; First : Positive; Last : Natural) return Slice;
procedure Extend (S : in out Slice; New_Range : in String_Range);
procedure Extend (S : in out Slice; First : in Positive; Last : in Natural);
-- Extend the range represented by S
-----------------
-- Restrictors --
-----------------
-- All the subprograms here raise Constraint_Error when the new range
-- is not a subrange of the source range.
function Subslice (S : Slice; New_Range : String_Range) return Slice;
function Subslice (S : Slice; First : Positive; Last : Natural)
return Slice;
-- Return a subslice of S
procedure Restrict (S : in out Slice; New_Range : in String_Range);
procedure Restrict
(S : in out Slice; First : in Positive; Last : in Natural);
-- Update the range in S
procedure Set_First (S : in out Slice; New_First : in Positive);
-- Update the range of S keeping the upper bound intact
procedure Set_Last (S : in out Slice; New_Last : in Natural);
-- Update the range of S keeping the lower bound intact
procedure Set_Length (S : in out Slice; New_Length : in Natural);
-- Truncate S range to the given length, keeping the lower bound intact
----------------------
-- Slice comparison --
----------------------
function Is_Empty (S : Slice) return Boolean;
-- Return whether the slice represents an empty string.
-- Semantically equivalent to (To_String (S) = "").
function Is_Null (S : Slice) return Boolean;
-- Return whether the slice has a parent string
function Is_Related (Left, Right : Slice) return Boolean;
-- Return whether both slices have the same parent string
function Is_Subslice (S, Reference : Slice) return Boolean;
-- Return whether S represent of a subrange of Reference with the
-- same parent string.
function Duplicate (S : Slice) return Slice;
-- Create a new parent string and a slice designating it.
-- This does not copy parts of S parent string outside of S range.
-- Semantically equivalent to (To_Slice (To_String (S))).
private
package String_Refs is new References
(String,
Storage_Pools.Access_In_Default_Pool'Storage_Pool,
Storage_Pools.Access_In_Default_Pool'Storage_Pool);
type Slice is tagged record
Bounds : String_Range := (1, 0);
Ref : String_Refs.Immutable_Reference;
end record;
Null_Slice : constant Slice := ((1, 0), Ref => <>);
end Natools.String_Slices;
|
--
-- Copyright (C) 2019, AdaCore
--
-- Copyright (c) 2010 - 2018, 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:
--
-- 1. Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update
-- for such product, 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 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.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be
-- reverse engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR
-- ASA 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 nrf52840.svd
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Interfaces.NRF52.GPIO is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
-- Pin 0
type OUT_PIN0_Field is
(-- Pin driver is low
Low,
-- Pin driver is high
High)
with Size => 1;
for OUT_PIN0_Field use
(Low => 0,
High => 1);
-- OUT_PIN array
type OUT_PIN_Field_Array is array (0 .. 31) of OUT_PIN0_Field
with Component_Size => 1, Size => 32;
-- Write GPIO port
type OUT_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : OUT_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for OUT_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Pin 0
type OUTSET_PIN0_Field is
(-- Read: pin driver is low
Low,
-- Read: pin driver is high
High)
with Size => 1;
for OUTSET_PIN0_Field use
(Low => 0,
High => 1);
-- Pin 0
type OUTSET_PIN0_Field_1 is
(-- Reset value for the field
Outset_Pin0_Field_Reset,
-- Write: writing a '1' sets the pin high; writing a '0' has no effect
Set)
with Size => 1;
for OUTSET_PIN0_Field_1 use
(Outset_Pin0_Field_Reset => 0,
Set => 1);
-- OUTSET_PIN array
type OUTSET_PIN_Field_Array is array (0 .. 31) of OUTSET_PIN0_Field_1
with Component_Size => 1, Size => 32;
-- Set individual bits in GPIO port
type OUTSET_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : OUTSET_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for OUTSET_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Pin 0
type OUTCLR_PIN0_Field is
(-- Read: pin driver is low
Low,
-- Read: pin driver is high
High)
with Size => 1;
for OUTCLR_PIN0_Field use
(Low => 0,
High => 1);
-- Pin 0
type OUTCLR_PIN0_Field_1 is
(-- Reset value for the field
Outclr_Pin0_Field_Reset,
-- Write: writing a '1' sets the pin low; writing a '0' has no effect
Clear)
with Size => 1;
for OUTCLR_PIN0_Field_1 use
(Outclr_Pin0_Field_Reset => 0,
Clear => 1);
-- OUTCLR_PIN array
type OUTCLR_PIN_Field_Array is array (0 .. 31) of OUTCLR_PIN0_Field_1
with Component_Size => 1, Size => 32;
-- Clear individual bits in GPIO port
type OUTCLR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : OUTCLR_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for OUTCLR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Pin 0
type IN_PIN0_Field is
(-- Pin input is low
Low,
-- Pin input is high
High)
with Size => 1;
for IN_PIN0_Field use
(Low => 0,
High => 1);
-- IN_PIN array
type IN_PIN_Field_Array is array (0 .. 31) of IN_PIN0_Field
with Component_Size => 1, Size => 32;
-- Read GPIO port
type IN_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : IN_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for IN_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Pin 0
type DIR_PIN0_Field is
(-- Pin set as input
Input,
-- Pin set as output
Output)
with Size => 1;
for DIR_PIN0_Field use
(Input => 0,
Output => 1);
-- DIR_PIN array
type DIR_PIN_Field_Array is array (0 .. 31) of DIR_PIN0_Field
with Component_Size => 1, Size => 32;
-- Direction of GPIO pins
type DIR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : DIR_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for DIR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Set as output pin 0
type DIRSET_PIN0_Field is
(-- Read: pin set as input
Input,
-- Read: pin set as output
Output)
with Size => 1;
for DIRSET_PIN0_Field use
(Input => 0,
Output => 1);
-- Set as output pin 0
type DIRSET_PIN0_Field_1 is
(-- Reset value for the field
Dirset_Pin0_Field_Reset,
-- Write: writing a '1' sets pin to output; writing a '0' has no effect
Set)
with Size => 1;
for DIRSET_PIN0_Field_1 use
(Dirset_Pin0_Field_Reset => 0,
Set => 1);
-- DIRSET_PIN array
type DIRSET_PIN_Field_Array is array (0 .. 31) of DIRSET_PIN0_Field_1
with Component_Size => 1, Size => 32;
-- DIR set register
type DIRSET_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : DIRSET_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for DIRSET_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Set as input pin 0
type DIRCLR_PIN0_Field is
(-- Read: pin set as input
Input,
-- Read: pin set as output
Output)
with Size => 1;
for DIRCLR_PIN0_Field use
(Input => 0,
Output => 1);
-- Set as input pin 0
type DIRCLR_PIN0_Field_1 is
(-- Reset value for the field
Dirclr_Pin0_Field_Reset,
-- Write: writing a '1' sets pin to input; writing a '0' has no effect
Clear)
with Size => 1;
for DIRCLR_PIN0_Field_1 use
(Dirclr_Pin0_Field_Reset => 0,
Clear => 1);
-- DIRCLR_PIN array
type DIRCLR_PIN_Field_Array is array (0 .. 31) of DIRCLR_PIN0_Field_1
with Component_Size => 1, Size => 32;
-- DIR clear register
type DIRCLR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : DIRCLR_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for DIRCLR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Status on whether PIN0 has met criteria set in PIN_CNF0.SENSE register.
-- Write '1' to clear.
type LATCH_PIN0_Field is
(-- Criteria has not been met
Notlatched,
-- Criteria has been met
Latched)
with Size => 1;
for LATCH_PIN0_Field use
(Notlatched => 0,
Latched => 1);
-- LATCH_PIN array
type LATCH_PIN_Field_Array is array (0 .. 31) of LATCH_PIN0_Field
with Component_Size => 1, Size => 32;
-- Latch register indicating what GPIO pins that have met the criteria set
-- in the PIN_CNF[n].SENSE registers
type LATCH_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PIN as a value
Val : Interfaces.NRF52.UInt32;
when True =>
-- PIN as an array
Arr : LATCH_PIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for LATCH_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Select between default DETECT signal behaviour and LDETECT mode
type DETECTMODE_DETECTMODE_Field is
(-- DETECT directly connected to PIN DETECT signals
Default,
-- Use the latched LDETECT behaviour
Ldetect)
with Size => 1;
for DETECTMODE_DETECTMODE_Field use
(Default => 0,
Ldetect => 1);
-- Select between default DETECT signal behaviour and LDETECT mode
type DETECTMODE_Register is record
-- Select between default DETECT signal behaviour and LDETECT mode
DETECTMODE : DETECTMODE_DETECTMODE_Field :=
Interfaces.NRF52.GPIO.Default;
-- unspecified
Reserved_1_31 : Interfaces.NRF52.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DETECTMODE_Register use record
DETECTMODE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Pin direction. Same physical register as DIR register
type PIN_CNF_DIR_Field is
(-- Configure pin as an input pin
Input,
-- Configure pin as an output pin
Output)
with Size => 1;
for PIN_CNF_DIR_Field use
(Input => 0,
Output => 1);
-- Connect or disconnect input buffer
type PIN_CNF_INPUT_Field is
(-- Connect input buffer
Connect,
-- Disconnect input buffer
Disconnect)
with Size => 1;
for PIN_CNF_INPUT_Field use
(Connect => 0,
Disconnect => 1);
-- Pull configuration
type PIN_CNF_PULL_Field is
(-- No pull
Disabled,
-- Pull down on pin
Pulldown,
-- Pull up on pin
Pullup)
with Size => 2;
for PIN_CNF_PULL_Field use
(Disabled => 0,
Pulldown => 1,
Pullup => 3);
-- Drive configuration
type PIN_CNF_DRIVE_Field is
(-- Standard '0', standard '1'
S0S1,
-- High drive '0', standard '1'
H0S1,
-- Standard '0', high drive '1'
S0H1,
-- High drive '0', high 'drive '1''
H0H1,
-- Disconnect '0' standard '1' (normally used for wired-or connections)
D0S1,
-- Disconnect '0', high drive '1' (normally used for wired-or connections)
D0H1,
-- Standard '0'. disconnect '1' (normally used for wired-and connections)
S0D1,
-- High drive '0', disconnect '1' (normally used for wired-and connections)
H0D1)
with Size => 3;
for PIN_CNF_DRIVE_Field use
(S0S1 => 0,
H0S1 => 1,
S0H1 => 2,
H0H1 => 3,
D0S1 => 4,
D0H1 => 5,
S0D1 => 6,
H0D1 => 7);
-- Pin sensing mechanism
type PIN_CNF_SENSE_Field is
(-- Disabled
Disabled,
-- Sense for high level
High,
-- Sense for low level
Low)
with Size => 2;
for PIN_CNF_SENSE_Field use
(Disabled => 0,
High => 2,
Low => 3);
-- Description collection[n]: Configuration of GPIO pins
type PIN_CNF_Register is record
-- Pin direction. Same physical register as DIR register
DIR : PIN_CNF_DIR_Field := Interfaces.NRF52.GPIO.Input;
-- Connect or disconnect input buffer
INPUT : PIN_CNF_INPUT_Field :=
Interfaces.NRF52.GPIO.Disconnect;
-- Pull configuration
PULL : PIN_CNF_PULL_Field := Interfaces.NRF52.GPIO.Disabled;
-- unspecified
Reserved_4_7 : Interfaces.NRF52.UInt4 := 16#0#;
-- Drive configuration
DRIVE : PIN_CNF_DRIVE_Field := Interfaces.NRF52.GPIO.S0S1;
-- unspecified
Reserved_11_15 : Interfaces.NRF52.UInt5 := 16#0#;
-- Pin sensing mechanism
SENSE : PIN_CNF_SENSE_Field := Interfaces.NRF52.GPIO.Disabled;
-- unspecified
Reserved_18_31 : Interfaces.NRF52.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PIN_CNF_Register use record
DIR at 0 range 0 .. 0;
INPUT at 0 range 1 .. 1;
PULL at 0 range 2 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
DRIVE at 0 range 8 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
SENSE at 0 range 16 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Description collection[n]: Configuration of GPIO pins
type PIN_CNF_Registers is array (0 .. 31) of PIN_CNF_Register;
-----------------
-- Peripherals --
-----------------
-- GPIO Port 1
type GPIO_Peripheral is record
-- Write GPIO port
OUT_k : aliased OUT_Register;
-- Set individual bits in GPIO port
OUTSET : aliased OUTSET_Register;
-- Clear individual bits in GPIO port
OUTCLR : aliased OUTCLR_Register;
-- Read GPIO port
IN_k : aliased IN_Register;
-- Direction of GPIO pins
DIR : aliased DIR_Register;
-- DIR set register
DIRSET : aliased DIRSET_Register;
-- DIR clear register
DIRCLR : aliased DIRCLR_Register;
-- Latch register indicating what GPIO pins that have met the criteria
-- set in the PIN_CNF[n].SENSE registers
LATCH : aliased LATCH_Register;
-- Select between default DETECT signal behaviour and LDETECT mode
DETECTMODE : aliased DETECTMODE_Register;
-- Description collection[n]: Configuration of GPIO pins
PIN_CNF : aliased PIN_CNF_Registers;
end record
with Volatile;
for GPIO_Peripheral use record
OUT_k at 16#504# range 0 .. 31;
OUTSET at 16#508# range 0 .. 31;
OUTCLR at 16#50C# range 0 .. 31;
IN_k at 16#510# range 0 .. 31;
DIR at 16#514# range 0 .. 31;
DIRSET at 16#518# range 0 .. 31;
DIRCLR at 16#51C# range 0 .. 31;
LATCH at 16#520# range 0 .. 31;
DETECTMODE at 16#524# range 0 .. 31;
PIN_CNF at 16#700# range 0 .. 1023;
end record;
-- GPIO Port 1
P0_Periph : aliased GPIO_Peripheral
with Import, Address => P0_Base;
-- GPIO Port 2
P1_Periph : aliased GPIO_Peripheral
with Import, Address => P1_Base;
end Interfaces.NRF52.GPIO;
|
with Ada.Containers.Ordered_Sets;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
procedure Solution is
use Ada.Containers;
package Line_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Unbounded_String);
use Line_Vectors;
package Character_Set is new Ada.Containers.Ordered_Sets
(Element_Type => Character);
use Character_Set;
function Read_Input(Filename : String) return Vector is
File : File_Type;
Lines : Vector;
begin
Open (File => File,
Mode => In_File,
Name => Filename);
while not End_Of_File (File) loop
Append (Lines, To_Unbounded_String (Get_Line (File)));
end loop;
Close(File);
return Lines;
end Read_Input;
function Answers(Line : Unbounded_String) return Set is
Characters : Set := Empty_Set;
begin
for Char of To_String (Line) loop
Include (Characters, Char);
end loop;
return Characters;
end Answers;
function Part_One(Lines : Vector) return Count_Type is
Characters : Set := Empty_Set;
Sum : Count_Type := 0;
begin
for Line of Lines loop
if Line /= Null_Unbounded_String then
Union (Characters, Answers (Line));
else
Sum := Sum + Length (Characters);
Clear (Characters);
end if;
end loop;
if not Is_Empty (Characters) then
Sum := Sum + Length (Characters);
end if;
return Sum;
end Part_One;
function Part_Two(Lines : Vector) return Count_Type is
Characters : Set := Empty_Set;
Sum : Count_Type := 0;
New_Group : Boolean := True;
begin
for Line of Lines loop
if Line /= Null_Unbounded_String then
if New_Group then
Union (Characters, Answers (Line));
New_Group := False;
else
Intersection (Characters, Answers (Line));
end if;
else
Sum := Sum + Length (Characters);
Clear (Characters);
New_Group := True;
end if;
end loop;
if not Is_Empty (Characters) then
Sum := Sum + Length (Characters);
end if;
return Sum;
end Part_Two;
Lines : Vector;
begin
Lines := Read_Input("input.txt");
Put_Line ("Part I: " & Count_Type'Image(Part_One (Lines)));
Put_Line ("Part II: " & Count_Type'Image(Part_Two (Lines)));
end Solution;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.API.Singles;
with GL.API.Ints;
with GL.API.UInts;
with GL.Low_Level;
package body GL.Uniforms is
procedure Set_Single (Location : Uniform; Value : Single) is
begin
API.Singles.Uniform1 (Location, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; V1, V2 : Single) is
begin
API.Singles.Uniform2 (Location, V1, V2);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector2) is
begin
API.Singles.Uniform2v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; V1, V2, V3 : Single) is
begin
API.Singles.Uniform3 (Location, V1, V2, V3);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector3) is
begin
API.Singles.Uniform3v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; V1, V2, V3, V4 : Single) is
begin
API.Singles.Uniform4 (Location, V1, V2, V3, V4);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector4) is
begin
API.Singles.Uniform4v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Single_Array) is
begin
API.Singles.Uniform1v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector2_Array) is
begin
API.Singles.Uniform2v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector3_Array) is
begin
API.Singles.Uniform3v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector4_Array) is
begin
API.Singles.Uniform4v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix2) is
begin
API.Singles.Uniform_Matrix2 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix3) is
begin
API.Singles.Uniform_Matrix3 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix4) is
begin
API.Singles.Uniform_Matrix4 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix2_Array) is
begin
API.Singles.Uniform_Matrix2
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix3_Array) is
begin
API.Singles.Uniform_Matrix3
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix4_Array) is
begin
API.Singles.Uniform_Matrix4
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Int (Location : Uniform; Value : Int) is
begin
API.Ints.Uniform1 (Location, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; V1, V2 : Int) is
begin
API.Ints.Uniform2 (Location, V1, V2);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector2) is
begin
API.Ints.Uniform2v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; V1, V2, V3 : Int) is
begin
API.Ints.Uniform3 (Location, V1, V2, V3);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector3) is
begin
API.Ints.Uniform3v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; V1, V2, V3, V4 : Int) is
begin
API.Ints.Uniform4 (Location, V1, V2, V3, V4);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector4) is
begin
API.Ints.Uniform4v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Int_Array) is
begin
API.Ints.Uniform1v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector2_Array) is
begin
API.Ints.Uniform2v (Location, Value'Length * 2, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector3_Array) is
begin
API.Ints.Uniform3v (Location, Value'Length * 3, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector4_Array) is
begin
API.Ints.Uniform4v (Location, Value'Length * 4, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix2) is
begin
API.Ints.Uniform_Matrix2 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix3) is
begin
API.Ints.Uniform_Matrix3 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix4) is
begin
API.Ints.Uniform_Matrix4 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix2_Array) is
begin
API.Ints.Uniform_Matrix2
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix3_Array) is
begin
API.Ints.Uniform_Matrix3
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix4_Array) is
begin
API.Ints.Uniform_Matrix4
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_UInt (Location : Uniform; Value : UInt) is
begin
API.UInts.Uniform1 (Location, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; V1, V2 : UInt) is
begin
API.UInts.Uniform2 (Location, V1, V2);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector2) is
begin
API.UInts.Uniform2v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; V1, V2, V3 : UInt) is
begin
API.UInts.Uniform3 (Location, V1, V2, V3);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector3) is
begin
API.UInts.Uniform3v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; V1, V2, V3, V4 : UInt) is
begin
API.UInts.Uniform4 (Location, V1, V2, V3, V4);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector4) is
begin
API.UInts.Uniform4v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInt_Array) is
begin
API.UInts.Uniform1v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector2_Array) is
begin
API.UInts.Uniform2v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector3_Array) is
begin
API.UInts.Uniform3v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector4_Array) is
begin
API.UInts.Uniform4v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix2) is
begin
API.UInts.Uniform_Matrix2 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix3) is
begin
API.UInts.Uniform_Matrix3 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix4) is
begin
API.UInts.Uniform_Matrix4 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix2_Array) is
begin
API.UInts.Uniform_Matrix2
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix3_Array) is
begin
API.UInts.Uniform_Matrix3
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix4_Array) is
begin
API.UInts.Uniform_Matrix4
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
end GL.Uniforms;
|
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Incr.Nodes.Joints;
package body Tests.Parser_Data is
-------------
-- Actions --
-------------
overriding function Actions
(Self : Provider) return P.Action_Table_Access is
begin
return P.Action_Table_Access (Self.Actions);
end Actions;
package body Constructors is
function Create
(Document : Incr.Documents.Document_Access;
NT : Node_Kind_Array;
Parts : P.Parts_Count_Table;
Names : League.String_Vectors.Universal_String_Vector;
Max_State : P.Parser_State;
Max_Term : Incr.Nodes.Token_Kind) return Provider
is
use type Incr.Nodes.Node_Kind;
begin
return Result : Provider
(Document)
do
Result.Max_Term := Max_Term;
Result.Max_NT := Max_Term;
Result.Names := Names;
Result.Actions := new P.Action_Table
(1 .. Max_State, 1 .. Result.Max_NT);
Result.States := new P.State_Table
(1 .. Max_State, Max_Term + 1 .. Result.Max_NT);
Result.NT := new Node_Kind_Array'(NT);
Result.Parts := new P.Parts_Count_Table'(Parts);
end return;
end Create;
end Constructors;
-----------------
-- Create_Node --
-----------------
overriding procedure Create_Node
(Self : aliased in out Provider;
Prod : Incr.Parsers.Incremental.
Parser_Data_Providers.Production_Index;
Children : Incr.Nodes.Node_Array;
Node : out Incr.Nodes.Node_Access;
Kind : out Incr.Nodes.Node_Kind)
is
Result : Incr.Nodes.Joints.Joint_Access;
begin
Kind := Self.NT (Prod);
if Children'Length = 0 then
Node := null;
return;
end if;
Result := new Incr.Nodes.Joints.Joint (Self.Document, Children'Length);
Incr.Nodes.Joints.Constructors.Initialize (Result.all, Kind, Children);
Node := Incr.Nodes.Node_Access (Result);
end Create_Node;
----------------
-- Kind_Image --
----------------
overriding function Kind_Image
(Self : Provider;
Kind : Incr.Nodes.Node_Kind) return Wide_Wide_String
is
use type Incr.Nodes.Node_Kind;
begin
if Kind = 0 then
return "EOF";
elsif Positive (Kind) <= Self.Names.Length then
return Self.Names (Positive (Kind)).To_Wide_Wide_String;
else
return "unknown";
end if;
end Kind_Image;
------------
-- States --
------------
overriding function States (Self : Provider) return P.State_Table_Access is
begin
return P.State_Table_Access (Self.States);
end States;
-----------------
-- Part_Counts --
-----------------
overriding function Part_Counts
(Self : Provider) return P.Parts_Count_Table_Access is
begin
return P.Parts_Count_Table_Access (Self.Parts);
end Part_Counts;
end Tests.Parser_Data;
|
-----------------------------------------------------------------------
-- mat-events-targets - Events received and collected from a target
-- Copyright (C) 2014, 2015, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers.Ordered_Maps;
with Ada.Finalization;
with Util.Concurrent.Counters;
with MAT.Events.Tools;
package MAT.Events.Targets is
type Target_Events is tagged limited private;
type Target_Events_Access is access all Target_Events'Class;
-- Add the event in the list of events and increment the event counter.
-- Update the event instance to allocate the event Id.
procedure Insert (Target : in out Target_Events;
Event : in out Target_Event_Type);
-- Update the Size and Prev_Id information in the event identified by <tt>Id</tt>.
-- Update the event represented by <tt>Prev_Id</tt> so that its Next_Id refers
-- to the <tt>Id</tt> event.
procedure Update_Event (Target : in out Target_Events;
Id : in Event_Id_Type;
Size : in MAT.Types.Target_Size;
Prev_Id : in Event_Id_Type);
procedure Get_Events (Target : in out Target_Events;
Start : in MAT.Types.Target_Time;
Finish : in MAT.Types.Target_Time;
Into : in out MAT.Events.Tools.Target_Event_Vector);
-- Get the start and finish time for the events that have been received.
procedure Get_Time_Range (Target : in out Target_Events;
Start : out MAT.Types.Target_Time;
Finish : out MAT.Types.Target_Time);
-- Get the probe event with the given allocated unique id.
function Get_Event (Target : in Target_Events;
Id : in Event_Id_Type) return Target_Event_Type;
-- Get the first and last event that have been received.
procedure Get_Limits (Target : in out Target_Events;
First : out Target_Event_Type;
Last : out Target_Event_Type);
-- Get the current event counter.
function Get_Event_Counter (Target : in Target_Events) return Integer;
-- Iterate over the events starting from the <tt>Start</tt> event and until the
-- <tt>Finish</tt> event is found (inclusive). Execute the <tt>Process</tt> procedure
-- with each event instance.
procedure Iterate (Target : in out Target_Events;
Start : in Event_Id_Type;
Finish : in Event_Id_Type;
Process : access procedure (Event : in Target_Event_Type));
-- Iterate over the events starting from first first event up to the last event collected.
-- Execute the <tt>Process</tt> procedure with each event instance.
procedure Iterate (Target : in out Target_Events;
Process : access procedure (Event : in Target_Event_Type));
private
EVENT_BLOCK_SIZE : constant Event_Id_Type := 1024;
type Probe_Event_Array is array (1 .. EVENT_BLOCK_SIZE) of Target_Event_Type;
type Event_Block is record
Start : MAT.Types.Target_Time;
Finish : MAT.Types.Target_Time;
Count : Event_Id_Type := 0;
Events : Probe_Event_Array;
end record;
type Event_Block_Access is access all Event_Block;
use type MAT.Types.Target_Time;
package Event_Maps is
new Ada.Containers.Ordered_Maps (Key_Type => MAT.Types.Target_Time,
Element_Type => Event_Block_Access);
subtype Event_Map is Event_Maps.Map;
subtype Event_Cursor is Event_Maps.Cursor;
package Event_Id_Maps is
new Ada.Containers.Ordered_Maps (Key_Type => Event_Id_Type,
Element_Type => Event_Block_Access);
subtype Event_Id_Map is Event_Id_Maps.Map;
subtype Event_Id_Cursor is Event_Id_Maps.Cursor;
protected type Event_Collector is
-- Update the Size and Prev_Id information in the event identified by <tt>Id</tt>.
-- Update the event represented by <tt>Prev_Id</tt> so that its Next_Id refers
-- to the <tt>Id</tt> event.
procedure Update_Event (Id : in Event_Id_Type;
Size : in MAT.Types.Target_Size;
Prev_Id : in Event_Id_Type);
-- Add the event in the list of events.
-- Update the event instance to allocate the event Id.
procedure Insert (Event : in out Target_Event_Type);
procedure Get_Events (Start : in MAT.Types.Target_Time;
Finish : in MAT.Types.Target_Time;
Into : in out MAT.Events.Tools.Target_Event_Vector);
-- Get the first and last event that have been received.
procedure Get_Limits (First : out Target_Event_Type;
Last : out Target_Event_Type);
-- Get the start and finish time for the events that have been received.
procedure Get_Time_Range (Start : out MAT.Types.Target_Time;
Finish : out MAT.Types.Target_Time);
-- Get the probe event with the given allocated unique id.
function Get_Event (Id : in Event_Id_Type) return Target_Event_Type;
-- Iterate over the events starting from the <tt>Start</tt> event and until the
-- <tt>Finish</tt> event is found (inclusive). Execute the <tt>Process</tt> procedure
-- with each event instance.
procedure Iterate (Start : in Event_Id_Type;
Finish : in Event_Id_Type;
Process : access procedure (Event : in Target_Event_Type));
-- Clear the events.
procedure Clear;
private
Current : Event_Block_Access := null;
Events : Event_Map;
Ids : Event_Id_Map;
Last_Id : Event_Id_Type := 0;
end Event_Collector;
type Target_Events is new Ada.Finalization.Limited_Controlled with record
Events : Event_Collector;
Event_Count : Util.Concurrent.Counters.Counter;
end record;
-- Release the storage allocated for the events.
overriding
procedure Finalize (Target : in out Target_Events);
end MAT.Events.Targets;
|
generic
type Element_Type is private;
Zero : Element_Type;
One : Element_Type;
with function "+" (Left, Right : Element_Type) return Element_Type is <>;
with function "-" (Left, Right : Element_Type) return Element_Type is <>;
with function "*" (Left, Right : Element_Type) return Element_Type is <>;
with function "/" (Left, Right : Element_Type) return Element_Type is <>;
package Matrices is
type Vector is array (Positive range <>) of Element_Type;
type Matrix is
array (Positive range <>, Positive range <>) of Element_Type;
function "*" (Left, Right : Matrix) return Matrix;
function Invert (Source : Matrix) return Matrix;
function Reduced_Row_Echelon_Form (Source : Matrix) return Matrix;
function Regression_Coefficients
(Source : Vector;
Regressors : Matrix)
return Vector;
function To_Column_Vector
(Source : Matrix;
Row : Positive := 1)
return Vector;
function To_Matrix
(Source : Vector;
Column_Vector : Boolean := True)
return Matrix;
function To_Row_Vector
(Source : Matrix;
Column : Positive := 1)
return Vector;
function Transpose (Source : Matrix) return Matrix;
Size_Mismatch : exception;
Not_Square_Matrix : exception;
Not_Invertible : exception;
end Matrices;
|
pragma Ada_2012;
with Ada.Unchecked_Deallocation;
with Ada.Numerics.Elementary_Functions;
package body DSP.Generic_Functions is
use type Complex_Types.Complex;
procedure Free is
new Ada.Unchecked_Deallocation (Object => Scalar_Array,
Name => Scalar_Array_Access);
pragma Unreferenced (Free);
procedure Free is
new Ada.Unchecked_Deallocation (Object => Complex_Array,
Name => Complex_Array_Access);
----------------
-- To_Complex --
----------------
function To_Complex (X : Scalar_Array) return Complex_Array
is
Result : Complex_Array (X'Range);
begin
for K in X'Range loop
Result (K) := (X (K), 0.0);
end loop;
return Result;
end To_Complex;
------------
-- Filter --
------------
function Filter
(Item : in out Complex_FIR;
Input : Complex_Type)
return Complex_Type
is
Result : constant Complex_Type := Input * Item.Spec (0)+ Item.Buffer (1);
Len : constant Positive := Item.Buffer'Last;
begin
pragma Assert (Item.Spec.all'First = 0
and Item.Buffer.all'First = 1
and Item.Buffer.all'Last = Item.Spec.all'Last);
for K in 1 .. Len - 1 loop
Item.Buffer (K) := Item.Buffer (K + 1) + Input * Item.Spec (K);
end loop;
Item.Buffer (Len) := Input * Item.Spec (Len);
return Result;
end Filter;
---------
-- Set --
---------
procedure Set
(Filter : in out Complex_FIR;
Impulse_Response : Complex_Array)
is
begin
Filter.Buffer := new Complex_Array (1 .. Impulse_Response'Last);
Filter.Buffer.all := (others => (0.0, 0.0));
Filter.Spec := new Complex_Array (0 .. Impulse_Response'Last);
Filter.Spec.all := (others => (0.0, 0.0));
for K in Impulse_Response'Range loop
Filter.Spec (K) := Impulse_Response (K);
end loop;
end Set;
---------
-- Set --
---------
procedure Set (Filter : in out Complex_FIR;
Impulse_Response : Scalar_Array)
is
begin
Filter.Set (To_Complex (Impulse_Response));
end Set;
overriding procedure Finalize (Object : in out Complex_FIR)
is
begin
if Object.Spec /= null then
pragma Assert (Object.Buffer /= null);
Free (Object.Spec);
Free (Object.Buffer);
end if;
end Finalize;
overriding procedure Finalize (Object : in out Complex_IIR)
is
begin
if Object.Num /= null then
pragma Assert (Object.Buffer /= null);
Free (Object.Num);
Free (Object.Den);
Free (Object.Buffer);
end if;
end Finalize;
------------
-- Filter --
------------
function Filter
(Item : in out Complex_IIR;
Input : Complex_Type)
return Complex_Type
is
Result : constant Complex_Type := Input * Item.Num (0)+ Item.Buffer (1);
Len : constant Positive := Item.Buffer'Last;
begin
pragma Assert (Item.Num.all'First = 0
and Item.Den.all'First = 1
and Item.Buffer.all'First = 1
and Item.Buffer.all'Last = Item.Num.all'Last
and Item.Buffer.all'Last = Item.Den.all'Last);
for K in 1 .. Len - 1 loop
Item.Buffer (K) := Item.Buffer (K + 1)
+ Input * Item.Num (K)
- Result * Item.Den (K);
end loop;
Item.Buffer (Len) := Input * Item.Num (Len) - Result * Item.Den (Len);
return Result;
end Filter;
---------
-- Set --
---------
procedure Set
(Filter : in out Complex_IIR;
Specs : Complex_IIR_Spec)
is
Last : constant Positive := Positive'Max (Specs.Num_Deg, Specs.Den_Deg);
begin
Filter.Buffer := new Complex_Array (1 .. Last);
Filter.Buffer.all := (others => (0.0, 0.0));
Filter.Num := new Complex_Array (0 .. Last);
Filter.Num.all := (others => (0.0, 0.0));
for K in Specs.Numerator'Range loop
Filter.Num (K) := Specs.Numerator (K);
end loop;
Filter.Den := new Complex_Array (1 .. Last);
Filter.Den.all := (others => (0.0, 0.0));
for K in Specs.Denominator'Range loop
Filter.Den (K) := Specs.Denominator (K);
end loop;
end Set;
---------
-- Set --
---------
procedure Set (Filter : in out Complex_IIR;
Numerator : Complex_Array;
Denominator : Complex_Array)
is
Tmp : Complex_IIR_Spec := (Num_Deg => Numerator'Last,
Den_Deg => Denominator'Last,
Numerator => (others => (0.0, 0.0)),
Denominator => (others => (0.0, 0.0)));
begin
for K in Integer'Max (Tmp.Numerator'First, Numerator'First) .. Numerator'Last loop
Tmp.Numerator (K) := Numerator (K);
end loop;
for K in Integer'Max (Tmp.Denominator'First, Denominator'First) .. Denominator'Last loop
Tmp.Denominator (K) := Denominator (K);
end loop;
Filter.Set (Tmp);
end Set;
---------
-- Set --
---------
procedure Set (Filter : in out Complex_IIR;
Numerator : Scalar_Array;
Denominator : Scalar_Array)
is
begin
Filter.Set (To_Complex (Numerator), To_Complex (Denominator));
end Set;
function Notch_Specs (Freq : Normalized_Frequency;
Pole_Radius : Float;
Class : Notch_Type := Stopband)
return Complex_IIR_Spec
is
use Ada.Numerics;
use Ada.Numerics.Elementary_Functions;
C : constant Scalar_Type := Scalar_Type (2.0 * Cos (2.0 * Pi * Freq));
R : constant Scalar_Type := Scalar_Type (Pole_Radius);
begin
case Class is
when Stopband =>
return Complex_IIR_Spec'(Num_Deg => 2,
Den_Deg => 2,
Numerator =>
(0 => (1.0, 0.0),
1 => (-C, 0.0),
2 => (1.0, 0.0)),
Denominator =>
(1 => (-R * C, 0.0),
2 => (R ** 2, 0.0)));
when Passband =>
return Complex_IIR_Spec'(Num_Deg => 1,
Den_Deg => 2,
Numerator =>
(0 => (C * (1.0 - R), 0.0),
1 => (R ** 2 - 1.0, 0.0)),
Denominator =>
(1 => (-R * C, 0.0),
2 => (R ** 2, 0.0)));
end case;
end Notch_Specs;
end DSP.Generic_Functions;
|
package body Mod_Inv is
procedure X_GCD(A, B: in Natural; D, X, Y: out Integer) is
-- the Extended Euclidean Algorithm
-- finds (D, X, Y) with D = GCD(A, B) = A*X + B*Y
R: Natural := A mod B;
begin
if R=0 then
D := B;
X := 0;
Y := 1;
else
X_GCD(B, R, D, Y, X);
Y := Y - (A/B)*X;
end if;
end X_GCD;
function Inverse(A, M: Integer) return Integer is
-- computes the multiplicative inverse of A mod M, using X_GCD
Result, GCD, Dummy: Integer;
begin
X_GCD(A, M, GCD, Result, Dummy);
if GCD /= 1 then -- inverse does not exist!
raise Constraint_Error with
"GCD (" & Integer'Image(A) & "," & Integer'Image(M) & " ) =" &
Integer'Image(GCD) & " /= 1";
else -- make sure Result is in {0, ..., M-1}
if Result < 0 then
return Result+M;
else
return Result;
end if;
end if;
end Inverse;
end Mod_Inv;
|
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to ayacc-info@ics.uci.edu
-- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : parse_table_body.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:33:16
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxparse_table_body.ada
-- $Header: parse_table_body.a,v 0.1 86/04/01 15:08:38 ada Exp $
-- $Log: parse_table_body.a,v $
-- Revision 0.1 86/04/01 15:08:38 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:39:53 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
with LALR_Symbol_Info, LR0_Machine, Symbol_Table, Rule_Table,
Text_IO, Symbol_Info, Verbose_File, Options, Goto_File,
Shift_Reduce_File;
use LALR_Symbol_Info, LR0_Machine, Symbol_Table, Rule_Table,
Text_IO, Symbol_Info, Options;
package body Parse_Table is
SCCS_ID : constant String := "@(#) parse_table_body.ada, Version 1.2";
Rcs_ID : constant String := "$Header: parse_table_body.a,v 0.1 86/04/01 15:08:38 ada Exp $";
Show_Verbose : Boolean; -- Set to options.verbose
--
-- The following declarations are for the "action" table.
--
type Action_Type is (Undefined, Error, Shift, Reduce, Accept_Input);
-- UNDEFINED and ERROR are the same accept you cannot replace
-- ERROR entries by a default reduction.
type Action_Table_Entry(Action : Action_Type := Undefined) is
record
case Action is
when Shift =>
State_ID : Parse_State;
when Reduce =>
Rule_ID : Rule;
when Accept_Input | Error | Undefined =>
null;
end case;
end record;
type Action_Table_Array is
array(Grammar_Symbol range <>) of Action_Table_Entry;
type Action_Table_Array_Pointer is access Action_Table_Array;
Action_Table_Row : Action_Table_Array_Pointer;
Default_Action : Action_Table_Entry;
--
-- The following declarations are for the "goto" table
--
type Goto_Table_Array is
array(Grammar_Symbol range <>) of Parse_State;
type Goto_Table_Array_Pointer is access Goto_Table_Array;
Goto_Table_Row : Goto_Table_Array_Pointer;
--
type Goto_Offset_Array is array(Parse_State range <>) of Integer;
type Goto_Offset_Array_Pointer is access Goto_Offset_Array;
Goto_Offset : Goto_Offset_Array_Pointer;
type Action_Offset_Array is array(Parse_State range <>) of Integer;
type Action_Offset_Array_Pointer is access Action_Offset_Array;
Action_Offset : Action_Offset_Array_Pointer;
--
Error_Code : constant := -3000; -- generated parser must use these
Accept_Code : constant := -3001;
Num_of_Goto_Entries : Integer := 0;
Num_of_Action_Entries : Integer := 0;
Num_Shift_Reduce_Conflicts : Natural := 0;
Num_Reduce_Reduce_Conflicts : Natural := 0;
function Shift_Reduce_Conflicts return Natural is
begin
return Num_Shift_Reduce_Conflicts;
end;
function Reduce_Reduce_Conflicts return Natural is
begin
return Num_Reduce_Reduce_Conflicts;
end;
function Number_of_States return Natural is
begin
return Natural(LR0_Machine.Last_Parse_State + 1);
end;
function Size_of_Goto_Table return Natural is
begin
return Num_of_Goto_Entries;
end;
function Size_of_Action_Table return Natural is
begin
return Num_of_Action_Entries;
end;
procedure Print_Goto_Row_Verbose is
begin
for Sym in Goto_Table_Row.all'range loop
if Goto_Table_Row(Sym) /= Null_Parse_State then
Verbose_File.Write(Ascii.Ht);
Verbose_File.Print_Grammar_Symbol(Sym);
Verbose_File.Write(" " & Ascii.Ht);
Verbose_File.Write_Line
("goto " & Parse_State'Image(Goto_Table_Row(Sym)));
end if;
end loop;
end Print_Goto_Row_Verbose;
procedure Print_Goto_Row(State: in Parse_State) is
S: Parse_State;
begin
Goto_Offset(State) := Num_of_Goto_Entries;
Goto_File.Write_Line
("-- State " & Parse_State'Image(State));
for I in Goto_Table_Row.all'range loop
S := Goto_Table_Row(I);
if S /= -1 then
Goto_File.Write(",");
Goto_File.Write("(" & Grammar_Symbol'Image(I) & "," &
Parse_State'Image(S) & ")" );
Num_of_Goto_Entries := Num_of_Goto_Entries + 1;
if Num_of_Goto_Entries mod 4 = 0 then
Goto_File.Write_Line("");
end if;
end if;
end loop;
Goto_File.Write_Line("");
end Print_Goto_Row;
-----------------------------------------------------------------------
procedure Print_Action_Row(State: in Parse_State) is
Temp : Action_Table_Entry;
X : Integer;
Default : Integer;
function Get_Default_Entry return Integer is
begin
for I in Action_Table_Row.all'range loop
if Action_Table_Row(I).Action = Reduce then
return -Integer(Action_Table_Row(I).Rule_ID);
end if;
end loop;
return Error_Code;
end Get_Default_Entry;
begin
Action_Offset(State) := Num_of_Action_Entries;
Shift_Reduce_File.Write_Line
("-- state " & Parse_State'Image(State));
Default := Get_Default_Entry;
for I in Action_Table_Row.all'range loop
Temp := Action_Table_Row(I);
case Temp.Action is
when Undefined =>
X := Default;
when Shift =>
X := Integer(Temp.State_ID);
when Reduce =>
X := - Integer(Temp.Rule_ID);
when Accept_Input =>
X := Accept_Code;
when Error =>
X := Error_Code;
end case;
if X /= Default then
Shift_Reduce_File.Write(",");
Shift_Reduce_File.Write("(" & Grammar_Symbol'Image(I) & ",");
Shift_Reduce_File.Write(Integer'Image(X) & ")" );
Num_of_Action_Entries := Num_of_Action_Entries + 1;
if Num_of_Action_Entries mod 4 = 0 then
Shift_Reduce_File.Write_Line("");
end if;
if Show_Verbose then
Verbose_File.Write(" " & Ascii.Ht);
Verbose_File.Print_Grammar_Symbol(I);
Verbose_File.Write(" " & Ascii.Ht);
if X = Accept_Code then
Verbose_File.Write_Line("accept");
elsif X = Error_Code then
Verbose_File.Write_Line("error");
elsif X > 0 then -- SHIFT
Verbose_File.Write_Line("shift " & Integer'Image(X));
else -- REDUCE
Verbose_File.Write_Line("reduce " & Integer'Image(-X));
end if;
end if;
end if;
end loop;
if Show_Verbose then
Verbose_File.Write(" " & Ascii.Ht);
Verbose_File.Write("default " & Ascii.Ht);
if Default = Accept_Code then
Verbose_File.Write_Line("accept");
elsif Default = Error_Code then
Verbose_File.Write_Line("error");
else -- reduce. never shift
Verbose_File.Write_Line("reduce " & Integer'Image(-Default));
end if;
end if;
Shift_Reduce_File.Write(",");
Shift_Reduce_File.Write("(" & Grammar_Symbol'Image(-1) & ",");
Shift_Reduce_File.Write(Integer'Image(Default) & ")" );
Num_of_Action_Entries := Num_of_Action_Entries + 1;
if Num_of_Action_Entries mod 4 = 0 then
Shift_Reduce_File.Write_Line("");
end if;
Shift_Reduce_File.Write_Line("");
end Print_Action_Row;
-----------------------------------------------------------------------
procedure Init_Table_Files is
begin
Goto_Offset := new Goto_Offset_Array
(First_Parse_State..Last_Parse_State);
Action_Offset := new Action_Offset_Array
(First_Parse_State..Last_Parse_State);
Goto_File.Open_Write;
Shift_Reduce_File.Open_Write;
end Init_Table_Files;
procedure Finish_Table_Files is
begin
Goto_File.Write_Line(");");
Goto_File.Write_Line("-- The offset vector");
Goto_File.Write("GOTO_OFFSET : array (0..");
Goto_File.Write(Parse_State'Image(Goto_Offset.all'Last) & ')');
Goto_File.Write_Line(" of Integer :=");
Goto_File.Write("(");
for I in Goto_Offset.all'First .. Goto_Offset.all'Last-1 loop
Goto_File.Write(Integer'Image(Goto_Offset(I)) & ",");
if I mod 10 = 0 then Goto_File.Write_Line(""); end if;
end loop;
Goto_File.Write
(Integer'Image(Goto_Offset(Goto_Offset.all'Last)));
Goto_File.Write_Line(");");
Goto_File.Close_Write;
Shift_Reduce_File.Write_Line(");");
Shift_Reduce_File.Write_Line("-- The offset vector");
Shift_Reduce_File.Write("SHIFT_REDUCE_OFFSET : array (0..");
Shift_Reduce_File.Write
(Parse_State'Image(Action_Offset.all'Last) & ')');
Shift_Reduce_File.Write_Line(" of Integer :=");
Shift_Reduce_File.Write("(");
for I in Action_Offset.all'First..Action_Offset.all'Last-1
loop
Shift_Reduce_File.Write
(Integer'Image(Action_Offset(I)) & ",");
if I mod 10 = 0 then Shift_Reduce_File.Write_Line(""); end if;
end loop;
Shift_Reduce_File.Write
(Integer'Image(Action_Offset(Action_Offset.all'Last)));
Shift_Reduce_File.Write_Line(");");
Shift_Reduce_File.Close_Write;
end Finish_Table_Files;
procedure Compute_Parse_Table is
use Transition_Set_Pack;
use Item_Set_Pack;
use Grammar_Symbol_Set_Pack;
Trans : Transition;
Nonterm_Iter : Nt_Transition_Iterator;
Term_Iter : T_Transition_Iterator;
Item_Set_1 : Item_Set;
Item_Iter : Item_Iterator;
Temp_Item : Item;
Lookahead_Set : Grammar_Symbol_Set;
Sym_Iter : Grammar_Symbol_Iterator;
Sym : Grammar_Symbol;
-- these variables are used for resolving conflicts
Sym_Prec : Precedence;
Rule_Prec : Precedence;
Sym_Assoc : Associativity;
-- recduce by r or action in action_table_row(sym);
procedure Report_Conflict(R: Rule; Sym : in Grammar_Symbol) is
begin
if Show_Verbose then
Verbose_File.Write("*** Conflict on input ");
Verbose_File.Print_Grammar_Symbol(Sym);
Verbose_File.Write_Line;
Verbose_File.Write(Ascii.Ht);
Verbose_File.Write("Reduce " & Rule'Image(R));
Verbose_File.Write(Ascii.Ht);
Verbose_File.Write("or");
Verbose_File.Write(Ascii.Ht);
end if;
case Action_Table_Row(Sym).Action is
when Shift =>
Num_Shift_Reduce_Conflicts :=
Num_Shift_Reduce_Conflicts + 1;
if Show_Verbose then
Verbose_File.Write("Shift ");
Verbose_File.Write_Line
(Parse_State'Image(Action_Table_Row(Sym).State_ID));
end if;
when Reduce =>
Num_Reduce_Reduce_Conflicts :=
Num_Reduce_Reduce_Conflicts + 1;
if Show_Verbose then
Verbose_File.Write("Reduce ");
Verbose_File.Write_Line
(Rule'Image(Action_Table_Row(Sym).Rule_ID));
end if;
when Accept_Input =>
if Show_Verbose then
Verbose_File.Write("Accept???"); -- won't happen
end if;
Put_Line("Ayacc: Internal Error in Report Conflict!");
when Error =>
if Show_Verbose then
Verbose_File.Write_Line("Error???"); -- won't happen
end if;
Put_Line("Ayacc: Internal Error in Report Conflict!");
when Undefined =>
Put_Line("Ayacc: Internal Error in Report Conflict!");
end case;
if Show_Verbose then
Verbose_File.Write_Line;
end if;
end;
begin
Action_Table_Row := new Action_Table_Array
(First_Symbol(Terminal)..Last_Symbol(Terminal));
Goto_Table_Row := new Goto_Table_Array
(First_Symbol(Nonterminal)..Last_Symbol(Nonterminal));
Init_Table_Files;
for S in First_Parse_State..Last_Parse_State loop
--& The verdix compiler apparently ALOCATES more memory for the following
--& assignments. We commented them out and replaced these statements by
--& the for loops
--& action_table_row.all :=
--& (action_table_row.all'range => (action => undefined));
--& goto_table_row.all :=
--& (goto_table_row.all'range => null_parse_state);
for I in Action_Table_Row.all'range loop
Action_Table_Row(I) := (Action => Undefined);
end loop;
for I in Goto_Table_Row.all'range loop
Goto_Table_Row(I) := Null_Parse_State;
end loop;
Make_Null(Item_Set_1);
Get_Kernel(S, Item_Set_1);
if Show_Verbose then
Verbose_File.Write_Line("------------------");
Verbose_File.Write_Line("State " & Parse_State'Image(S));
Verbose_File.Write_Line;
Verbose_File.Write_Line("Kernel");
Verbose_File.Print_Item_Set(Item_Set_1);
end if;
Closure(Item_Set_1);
if Show_Verbose then
Verbose_File.Write_Line;
Verbose_File.Write_Line("Closure");
Verbose_File.Print_Item_Set(Item_Set_1);
Verbose_File.Write_Line;
Verbose_File.Write_Line;
end if;
-- Make Shift Entries --
Initialize(Term_Iter, S);
while More(Term_Iter) loop
Next(Term_Iter, Trans);
if Trans.Symbol = End_Symbol then
Action_Table_Row(Trans.Symbol) :=
(Action => Accept_Input);
else
Action_Table_Row(Trans.Symbol) :=
(Action => Shift, State_ID => Trans.State_ID);
end if;
end loop;
-- Make Goto Entries --
Initialize(Nonterm_Iter, S);
while More(Nonterm_Iter) loop
Next(Nonterm_Iter, Trans);
Goto_Table_Row(Trans.Symbol) := Trans.State_ID;
end loop;
-- Make Reduce Entries ----
Initialize(Item_Iter, Item_Set_1);
-- check for degenerate reduce --
if Size_of(Item_Set_1) = 1 then
Next(Item_Iter, Temp_Item);
if Temp_Item.Dot_Position = Length_of(Temp_Item.Rule_ID)
and then Temp_Item.Rule_ID /= First_Rule
then
Action_Table_Row(First_Symbol(Terminal)) :=
(Action => Reduce,
Rule_ID => Temp_Item.Rule_ID);
end if;
goto Continue_Loop;
end if;
-- The following is really messy. It used to be ok before
-- we added precedence. Some day we should rewrite it.
while More(Item_Iter) loop
Next(Item_Iter, Temp_Item);
if Temp_Item.Dot_Position = Length_of(Temp_Item.Rule_ID)
and then Temp_Item.Rule_ID /= First_Rule
then
Make_Null(Lookahead_Set);
Get_LA(S, Temp_Item, Lookahead_Set);
Initialize(Sym_Iter, Lookahead_Set);
while More(Sym_Iter) loop
Next(Sym_Iter, Sym);
case Action_Table_Row(Sym).Action is
when Undefined =>
Action_Table_Row(Sym) :=
(Action => Reduce,
Rule_ID => Temp_Item.Rule_ID);
when Shift =>
Sym_Prec :=
Get_Precedence(Sym);
Rule_Prec :=
Get_Rule_Precedence(Temp_Item.Rule_ID);
if Sym_Prec = 0 or else Rule_Prec = 0 then
Report_Conflict(Temp_Item.Rule_ID, Sym);
elsif Rule_Prec > Sym_Prec then
Action_Table_Row(Sym) :=
(Action => Reduce,
Rule_ID => Temp_Item.Rule_ID);
elsif Sym_Prec > Rule_Prec then
null; -- already ok
else
Sym_Assoc :=
Get_Associativity(Sym);
if Sym_Assoc = Left_Associative then
Action_Table_Row(Sym) :=
(Action => Reduce,
Rule_ID => Temp_Item.Rule_ID);
elsif Sym_Assoc = Right_Associative then
null;
elsif Sym_Assoc = Nonassociative then
Action_Table_Row(Sym) :=
(Action => Error);
else
Put_Line("Ayacc: Possible Error in " &
"Conflict Resolution.");
end if;
end if;
when Reduce =>
Report_Conflict(Temp_Item.Rule_ID, Sym);
when Error =>
Put_Line("Ayacc: Internal Error in Conflict!!!");
Put_Line("Ayacc: Use Verbose Option!");
Report_Conflict(Temp_Item.Rule_ID, Sym);
when Accept_Input =>
Put_Line("Ayacc: Internal Error in Conflict!!!");
Put_Line("Ayacc: Use Verbose Option!");
Report_Conflict(Temp_Item.Rule_ID, Sym);
end case;
end loop;
end if;
end loop;
<<Continue_Loop>>
if Show_Verbose then
Print_Goto_Row_Verbose;
end if;
Print_Goto_Row(S);
Print_Action_Row(S);
end loop;
Finish_Table_Files;
end Compute_Parse_Table;
procedure Make_Parse_Table is
begin
Show_Verbose := Options.Verbose;
if Show_Verbose then
Verbose_File.Open;
end if;
Symbol_Info.Initialize;
if Options.Loud then
Put_Line("Ayacc: Making LR(0) Machine.");
end if;
LR0_Machine.LR0_Initialize;
if Options.Loud then
Put_Line("Ayacc: Making Follow Sets.");
end if;
Make_LALR_Sets;
if Options.Loud then
Put_Line("Ayacc: Making Parse Table.");
end if;
Compute_Parse_Table;
if Show_Verbose then
Verbose_File.Close;
end if;
end Make_Parse_Table;
end Parse_Table;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A L I . U T I L --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Debug; use Debug;
with Binderr; use Binderr;
with Opt; use Opt;
with Output; use Output;
with Osint; use Osint;
with Scans; use Scans;
with Scng;
with Sinput.C;
with Snames; use Snames;
with Stringt;
with Styleg;
with System.OS_Lib; use System.OS_Lib;
package body ALI.Util is
-- Empty procedures needed to instantiate Scng. Error procedures are
-- empty, because we don't want to report any errors when computing
-- a source checksum.
procedure Post_Scan;
procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
procedure Error_Msg_S (Msg : String);
procedure Error_Msg_SC (Msg : String);
procedure Error_Msg_SP (Msg : String);
-- Instantiation of Styleg, needed to instantiate Scng
package Style is new Styleg
(Error_Msg, Error_Msg_S, Error_Msg_SC, Error_Msg_SP);
-- A Scanner is needed to get checksum of a source (procedure
-- Get_File_Checksum).
package Scanner is new Scng
(Post_Scan, Error_Msg, Error_Msg_S, Error_Msg_SC, Error_Msg_SP, Style);
type Header_Num is range 0 .. 1_000;
function Hash (F : File_Name_Type) return Header_Num;
-- Function used to compute hash of ALI file name
package Interfaces is new Simple_HTable (
Header_Num => Header_Num,
Element => Boolean,
No_Element => False,
Key => File_Name_Type,
Hash => Hash,
Equal => "=");
---------------------
-- Checksums_Match --
---------------------
function Checksums_Match (Checksum1, Checksum2 : Word) return Boolean is
begin
return Checksum1 = Checksum2 and then Checksum1 /= Checksum_Error;
end Checksums_Match;
---------------
-- Error_Msg --
---------------
procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr) is
pragma Warnings (Off, Msg);
pragma Warnings (Off, Flag_Location);
begin
null;
end Error_Msg;
-----------------
-- Error_Msg_S --
-----------------
procedure Error_Msg_S (Msg : String) is
pragma Warnings (Off, Msg);
begin
null;
end Error_Msg_S;
------------------
-- Error_Msg_SC --
------------------
procedure Error_Msg_SC (Msg : String) is
pragma Warnings (Off, Msg);
begin
null;
end Error_Msg_SC;
------------------
-- Error_Msg_SP --
------------------
procedure Error_Msg_SP (Msg : String) is
pragma Warnings (Off, Msg);
begin
null;
end Error_Msg_SP;
-----------------------
-- Get_File_Checksum --
-----------------------
function Get_File_Checksum (Fname : File_Name_Type) return Word is
Full_Name : File_Name_Type;
Source_Index : Source_File_Index;
begin
Full_Name := Find_File (Fname, Osint.Source);
-- If we cannot find the file, then return an impossible checksum,
-- impossible because checksums have the high order bit zero, so
-- that checksums do not match.
if Full_Name = No_File then
return Checksum_Error;
end if;
Source_Index := Sinput.C.Load_File (Get_Name_String (Full_Name));
if Source_Index = No_Source_File then
return Checksum_Error;
end if;
Scanner.Initialize_Scanner (Source_Index);
-- Make sure that the project language reserved words are not
-- recognized as reserved words, but as identifiers. The byte info for
-- those names have been set if we are in gnatmake.
Set_Name_Table_Byte (Name_Project, 0);
Set_Name_Table_Byte (Name_Extends, 0);
Set_Name_Table_Byte (Name_External, 0);
Set_Name_Table_Byte (Name_External_As_List, 0);
-- Scan the complete file to compute its checksum
loop
Scanner.Scan;
exit when Token = Tok_EOF;
end loop;
return Scans.Checksum;
end Get_File_Checksum;
----------
-- Hash --
----------
function Hash (F : File_Name_Type) return Header_Num is
begin
return Header_Num (Int (F) rem Header_Num'Range_Length);
end Hash;
---------------------------
-- Initialize_ALI_Source --
---------------------------
procedure Initialize_ALI_Source is
begin
-- When (re)initializing ALI data structures the ALI user expects to
-- get a fresh set of data structures. Thus we first need to erase the
-- marks put in the name table by the previous set of ALI routine calls.
-- This loop is empty and harmless the first time in.
for J in Source.First .. Source.Last loop
Set_Name_Table_Int (Source.Table (J).Sfile, 0);
Source.Table (J).Source_Found := False;
end loop;
Source.Init;
Interfaces.Reset;
end Initialize_ALI_Source;
---------------
-- Post_Scan --
---------------
procedure Post_Scan is
begin
null;
end Post_Scan;
----------------------
-- Read_Withed_ALIs --
----------------------
procedure Read_Withed_ALIs
(Id : ALI_Id;
Ignore_Errors : Boolean := False)
is
Afile : File_Name_Type;
Text : Text_Buffer_Ptr;
Idread : ALI_Id;
begin
-- Process all dependent units
for U in ALIs.Table (Id).First_Unit .. ALIs.Table (Id).Last_Unit loop
for
W in Units.Table (U).First_With .. Units.Table (U).Last_With
loop
Afile := Withs.Table (W).Afile;
-- Only process if not a generic (Afile /= No_File) and if
-- file has not been processed already.
if Afile /= No_File
and then Get_Name_Table_Int (Afile) = 0
then
Text := Read_Library_Info (Afile);
-- Unless Ignore_Errors is true, return with an error if source
-- cannot be found. We used to skip this check when we did not
-- compile library generics separately, but we now always do,
-- so there is no special case here anymore.
if Text = null then
if not Ignore_Errors then
Error_Msg_File_1 := Afile;
Error_Msg_File_2 := Withs.Table (W).Sfile;
Error_Msg ("{ not found, { must be compiled");
Set_Name_Table_Int (Afile, Int (No_Unit_Id));
return;
end if;
else
-- Enter in ALIs table
Idread :=
Scan_ALI
(F => Afile,
T => Text,
Ignore_ED => False,
Err => False);
Free (Text);
if ALIs.Table (Idread).Compile_Errors
and then not Ignore_Errors
then
Error_Msg_File_1 := Withs.Table (W).Sfile;
Error_Msg ("{ had errors, must be fixed, and recompiled");
Set_Name_Table_Int (Afile, Int (No_Unit_Id));
-- In GNATprove mode, object files are never generated, so
-- No_Object=True is not considered an error.
elsif ALIs.Table (Idread).No_Object
and then not GNATprove_Mode
and then not Ignore_Errors
then
Error_Msg_File_1 := Withs.Table (W).Sfile;
Error_Msg ("{ must be recompiled");
Set_Name_Table_Int (Afile, Int (No_Unit_Id));
end if;
-- If the Unit is an Interface to a Stand-Alone Library,
-- set the Interface flag in the Withs table, so that its
-- dependant are not considered for elaboration order.
if ALIs.Table (Idread).SAL_Interface then
Withs.Table (W).SAL_Interface := True;
Interface_Library_Unit := True;
-- Set the entry in the Interfaces hash table, so that
-- other units that import this unit will set the flag
-- in their entry in the Withs table.
Interfaces.Set (Afile, True);
else
-- Otherwise, recurse to get new dependents
Read_Withed_ALIs (Idread);
end if;
end if;
-- If the ALI file has already been processed and is an interface,
-- set the flag in the entry of the Withs table.
elsif Interface_Library_Unit and then Interfaces.Get (Afile) then
Withs.Table (W).SAL_Interface := True;
end if;
end loop;
end loop;
end Read_Withed_ALIs;
----------------------
-- Set_Source_Table --
----------------------
procedure Set_Source_Table (A : ALI_Id) is
F : File_Name_Type;
S : Source_Id;
Stamp : Time_Stamp_Type;
begin
Sdep_Loop : for D in
ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
loop
F := Sdep.Table (D).Sfile;
if F /= No_File then
-- If this is the first time we are seeing this source file,
-- then make a new entry in the source table.
if Get_Name_Table_Int (F) = 0 then
Source.Increment_Last;
S := Source.Last;
Set_Name_Table_Int (F, Int (S));
Source.Table (S).Sfile := F;
Source.Table (S).All_Timestamps_Match := True;
-- Initialize checksum fields
Source.Table (S).Checksum := Sdep.Table (D).Checksum;
Source.Table (S).All_Checksums_Match := True;
-- In check source files mode, try to get time stamp from file
if Opt.Check_Source_Files then
Stamp := Source_File_Stamp (F);
-- If we got the stamp, then set the stamp in the source
-- table entry and mark it as set from the source so that
-- it does not get subsequently changed.
if Stamp (Stamp'First) /= ' ' then
Source.Table (S).Stamp := Stamp;
Source.Table (S).Source_Found := True;
Source.Table (S).Stamp_File := F;
-- If we could not find the file, then the stamp is set
-- from the dependency table entry (to be possibly reset
-- if we find a later stamp in subsequent processing)
else
Source.Table (S).Stamp := Sdep.Table (D).Stamp;
Source.Table (S).Source_Found := False;
Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
-- In All_Sources mode, flag error of file not found
if Opt.All_Sources then
Error_Msg_File_1 := F;
Error_Msg ("cannot locate {");
end if;
end if;
-- First time for this source file, but Check_Source_Files
-- is off, so simply initialize the stamp from the Sdep entry
else
Source.Table (S).Stamp := Sdep.Table (D).Stamp;
Source.Table (S).Source_Found := False;
Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
end if;
-- Here if this is not the first time for this source file,
-- so that the source table entry is already constructed.
else
S := Source_Id (Get_Name_Table_Int (F));
-- Update checksum flag
if not Checksums_Match
(Sdep.Table (D).Checksum, Source.Table (S).Checksum)
then
Source.Table (S).All_Checksums_Match := False;
end if;
-- Check for time stamp mismatch
if Sdep.Table (D).Stamp /= Source.Table (S).Stamp then
Source.Table (S).All_Timestamps_Match := False;
-- When we have a time stamp mismatch, we go look for the
-- source file even if Check_Source_Files is false, since
-- if we find it, then we can use it to resolve which of the
-- two timestamps in the ALI files is likely to be correct.
-- We only look in the current directory, because when
-- Check_Source_Files is false, other search directories are
-- likely to be incorrect.
if not Check_Source_Files
and then Is_Regular_File (Get_Name_String (F))
then
Stamp := Source_File_Stamp (F);
if Stamp (Stamp'First) /= ' ' then
Source.Table (S).Stamp := Stamp;
Source.Table (S).Source_Found := True;
Source.Table (S).Stamp_File := F;
end if;
end if;
-- If the stamp in the source table entry was set from the
-- source file, then we do not change it (the stamp in the
-- source file is always taken as the "right" one).
if Source.Table (S).Source_Found then
null;
-- Otherwise, we have no source file available, so we guess
-- that the later of the two timestamps is the right one.
-- Note that this guess only affects which error messages
-- are issued later on, not correct functionality.
else
if Sdep.Table (D).Stamp > Source.Table (S).Stamp then
Source.Table (S).Stamp := Sdep.Table (D).Stamp;
Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
end if;
end if;
end if;
end if;
-- Set the checksum value in the source table
S := Source_Id (Get_Name_Table_Int (F));
Source.Table (S).Checksum := Sdep.Table (D).Checksum;
end if;
end loop Sdep_Loop;
end Set_Source_Table;
----------------------
-- Set_Source_Table --
----------------------
procedure Set_Source_Table is
begin
for A in ALIs.First .. ALIs.Last loop
Set_Source_Table (A);
end loop;
end Set_Source_Table;
-------------------------
-- Time_Stamp_Mismatch --
-------------------------
function Time_Stamp_Mismatch
(A : ALI_Id;
Read_Only : Boolean := False) return File_Name_Type
is
Src : Source_Id;
-- Source file Id for the current Sdep entry
begin
for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop
Src := Source_Id (Get_Name_Table_Int (Sdep.Table (D).Sfile));
if Opt.Minimal_Recompilation
and then Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
then
-- If minimal recompilation is in action, replace the stamp
-- of the source file in the table if checksums match.
-- ??? It is probably worth updating the ALI file with a new
-- field to avoid recomputing it each time. In any case we ensure
-- that we don't gobble up string table space by doing a mark
-- release around this computation.
Stringt.Mark;
if Checksums_Match
(Get_File_Checksum (Sdep.Table (D).Sfile),
Source.Table (Src).Checksum)
then
if Verbose_Mode then
Write_Str (" ");
Write_Str (Get_Name_String (Sdep.Table (D).Sfile));
Write_Str (": up to date, different timestamps " &
"but same checksum");
Write_Eol;
end if;
Sdep.Table (D).Stamp := Source.Table (Src).Stamp;
end if;
Stringt.Release;
end if;
if (not Read_Only) or else Source.Table (Src).Source_Found then
if not Source.Table (Src).Source_Found
or else Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
then
-- If -dt debug flag set, output time stamp found/expected
if Source.Table (Src).Source_Found and then Debug_Flag_T then
Write_Str ("Source: """);
Get_Name_String (Sdep.Table (D).Sfile);
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Line ("""");
Write_Str (" time stamp expected: ");
Write_Line (String (Sdep.Table (D).Stamp));
Write_Str (" time stamp found: ");
Write_Line (String (Source.Table (Src).Stamp));
end if;
-- Return the source file
return Source.Table (Src).Sfile;
end if;
end if;
end loop;
return No_File;
end Time_Stamp_Mismatch;
end ALI.Util;
|
-- Simple password generator
-- Luke A. Guest
-- 23/01/10
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Characters.Latin_1;
procedure Password is
package L1 renames Ada.Characters.Latin_1;
package Random_Char is new Ada.Numerics.Discrete_Random (Character);
Gen : Random_Char.Generator;
begin
if Ada.Command_Line.Argument_Count /= 1 then
Ada.Text_IO.Put_Line (" Usage: password <length>");
Ada.Text_IO.Put_Line (" Creates a random set of characters from the range of [a..zA..Z0..9]");
else
declare
Current : Character := Character'First;
Length : constant Integer := Integer'Value (Ada.Command_Line.Argument (1));
Pass : String (1 .. Length) := (others => L1.Space);
Index : Positive := Positive'First;
begin
Random_Char.Reset (Gen);
while Index /= Length loop
Current := Random_Char.Random (Gen);
if Current in L1.Exclamation .. L1.Solidus
| '0' .. '9'
| L1.Colon .. L1.Commercial_At
| 'A' .. 'Z'
| L1.Left_Square_Bracket .. L1.Low_Line
| L1.LC_A .. L1.Tilde
then
Pass (Index) := Current;
Index := @ + 1; -- New Ada 2020 feature!
end if;
end loop;
Ada.Text_IO.Put_Line ("Password is: " & Pass);
end;
end if;
end Password;
|
with Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;
with mylog; use mylog;
with LogQueue;
procedure main with SPARK_Mode is
m : mylog.logmsg;
now : Ada.Real_Time.Time;
buffer : mylog.msgarray (1 .. 10);
begin
LogQueue.myqueue.Put (m);
buffer (1) := m;
now := Ada.Real_Time.Clock;
m := (t => now, typ => mylog.GPS, lat => 11.1, lon => 48.0);
buffer (2) := m;
LogQueue.myqueue.Put (m);
m := (typ => TEXT, t => now, txt => (others => Character'Val(0)), txt_last => 0);
LogQueue.myqueue.Put (m);
buffer (3) := m;
for k in buffer'Range loop
Put_Line ("Buffer(" & Integer'Image (k) & ")=" & mylog.msgtype'Image (buffer (k).typ));
end loop;
LogQueue.mytest; --crash
Put_Line ("done");
end main;
|
-- This spec has been automatically generated from STM32F103.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.USB_OTG_FS is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype FS_DCFG_DSPD_Field is STM32_SVD.UInt2;
subtype FS_DCFG_NZLSOHSK_Field is STM32_SVD.Bit;
subtype FS_DCFG_DAD_Field is STM32_SVD.UInt7;
subtype FS_DCFG_PFIVL_Field is STM32_SVD.UInt2;
-- OTG_FS device configuration register (OTG_FS_DCFG)
type FS_DCFG_Register is record
-- Device speed
DSPD : FS_DCFG_DSPD_Field := 16#0#;
-- Non-zero-length status OUT handshake
NZLSOHSK : FS_DCFG_NZLSOHSK_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- Device address
DAD : FS_DCFG_DAD_Field := 16#0#;
-- Periodic frame interval
PFIVL : FS_DCFG_PFIVL_Field := 16#0#;
-- unspecified
Reserved_13_31 : STM32_SVD.UInt19 := 16#1100#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DCFG_Register use record
DSPD at 0 range 0 .. 1;
NZLSOHSK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
DAD at 0 range 4 .. 10;
PFIVL at 0 range 11 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
subtype FS_DCTL_RWUSIG_Field is STM32_SVD.Bit;
subtype FS_DCTL_SDIS_Field is STM32_SVD.Bit;
subtype FS_DCTL_GINSTS_Field is STM32_SVD.Bit;
subtype FS_DCTL_GONSTS_Field is STM32_SVD.Bit;
subtype FS_DCTL_TCTL_Field is STM32_SVD.UInt3;
subtype FS_DCTL_SGINAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_CGINAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_SGONAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_CGONAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_POPRGDNE_Field is STM32_SVD.Bit;
-- OTG_FS device control register (OTG_FS_DCTL)
type FS_DCTL_Register is record
-- Remote wakeup signaling
RWUSIG : FS_DCTL_RWUSIG_Field := 16#0#;
-- Soft disconnect
SDIS : FS_DCTL_SDIS_Field := 16#0#;
-- Read-only. Global IN NAK status
GINSTS : FS_DCTL_GINSTS_Field := 16#0#;
-- Read-only. Global OUT NAK status
GONSTS : FS_DCTL_GONSTS_Field := 16#0#;
-- Test control
TCTL : FS_DCTL_TCTL_Field := 16#0#;
-- Set global IN NAK
SGINAK : FS_DCTL_SGINAK_Field := 16#0#;
-- Clear global IN NAK
CGINAK : FS_DCTL_CGINAK_Field := 16#0#;
-- Set global OUT NAK
SGONAK : FS_DCTL_SGONAK_Field := 16#0#;
-- Clear global OUT NAK
CGONAK : FS_DCTL_CGONAK_Field := 16#0#;
-- Power-on programming done
POPRGDNE : FS_DCTL_POPRGDNE_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DCTL_Register use record
RWUSIG at 0 range 0 .. 0;
SDIS at 0 range 1 .. 1;
GINSTS at 0 range 2 .. 2;
GONSTS at 0 range 3 .. 3;
TCTL at 0 range 4 .. 6;
SGINAK at 0 range 7 .. 7;
CGINAK at 0 range 8 .. 8;
SGONAK at 0 range 9 .. 9;
CGONAK at 0 range 10 .. 10;
POPRGDNE at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype FS_DSTS_SUSPSTS_Field is STM32_SVD.Bit;
subtype FS_DSTS_ENUMSPD_Field is STM32_SVD.UInt2;
subtype FS_DSTS_EERR_Field is STM32_SVD.Bit;
subtype FS_DSTS_FNSOF_Field is STM32_SVD.UInt14;
-- OTG_FS device status register (OTG_FS_DSTS)
type FS_DSTS_Register is record
-- Read-only. Suspend status
SUSPSTS : FS_DSTS_SUSPSTS_Field;
-- Read-only. Enumerated speed
ENUMSPD : FS_DSTS_ENUMSPD_Field;
-- Read-only. Erratic error
EERR : FS_DSTS_EERR_Field;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4;
-- Read-only. Frame number of the received SOF
FNSOF : FS_DSTS_FNSOF_Field;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DSTS_Register use record
SUSPSTS at 0 range 0 .. 0;
ENUMSPD at 0 range 1 .. 2;
EERR at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
FNSOF at 0 range 8 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype FS_DIEPMSK_XFRCM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_EPDM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_TOM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_ITTXFEMSK_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_INEPNMM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_INEPNEM_Field is STM32_SVD.Bit;
-- OTG_FS device IN endpoint common interrupt mask register
-- (OTG_FS_DIEPMSK)
type FS_DIEPMSK_Register is record
-- Transfer completed interrupt mask
XFRCM : FS_DIEPMSK_XFRCM_Field := 16#0#;
-- Endpoint disabled interrupt mask
EPDM : FS_DIEPMSK_EPDM_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- Timeout condition mask (Non-isochronous endpoints)
TOM : FS_DIEPMSK_TOM_Field := 16#0#;
-- IN token received when TxFIFO empty mask
ITTXFEMSK : FS_DIEPMSK_ITTXFEMSK_Field := 16#0#;
-- IN token received with EP mismatch mask
INEPNMM : FS_DIEPMSK_INEPNMM_Field := 16#0#;
-- IN endpoint NAK effective mask
INEPNEM : FS_DIEPMSK_INEPNEM_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32_SVD.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DIEPMSK_Register use record
XFRCM at 0 range 0 .. 0;
EPDM at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
TOM at 0 range 3 .. 3;
ITTXFEMSK at 0 range 4 .. 4;
INEPNMM at 0 range 5 .. 5;
INEPNEM at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype FS_DOEPMSK_XFRCM_Field is STM32_SVD.Bit;
subtype FS_DOEPMSK_EPDM_Field is STM32_SVD.Bit;
subtype FS_DOEPMSK_STUPM_Field is STM32_SVD.Bit;
subtype FS_DOEPMSK_OTEPDM_Field is STM32_SVD.Bit;
-- OTG_FS device OUT endpoint common interrupt mask register
-- (OTG_FS_DOEPMSK)
type FS_DOEPMSK_Register is record
-- Transfer completed interrupt mask
XFRCM : FS_DOEPMSK_XFRCM_Field := 16#0#;
-- Endpoint disabled interrupt mask
EPDM : FS_DOEPMSK_EPDM_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- SETUP phase done mask
STUPM : FS_DOEPMSK_STUPM_Field := 16#0#;
-- OUT token received when endpoint disabled mask
OTEPDM : FS_DOEPMSK_OTEPDM_Field := 16#0#;
-- unspecified
Reserved_5_31 : STM32_SVD.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DOEPMSK_Register use record
XFRCM at 0 range 0 .. 0;
EPDM at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STUPM at 0 range 3 .. 3;
OTEPDM at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype FS_DAINT_IEPINT_Field is STM32_SVD.UInt16;
subtype FS_DAINT_OEPINT_Field is STM32_SVD.UInt16;
-- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT)
type FS_DAINT_Register is record
-- Read-only. IN endpoint interrupt bits
IEPINT : FS_DAINT_IEPINT_Field;
-- Read-only. OUT endpoint interrupt bits
OEPINT : FS_DAINT_OEPINT_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DAINT_Register use record
IEPINT at 0 range 0 .. 15;
OEPINT at 0 range 16 .. 31;
end record;
subtype FS_DAINTMSK_IEPM_Field is STM32_SVD.UInt16;
subtype FS_DAINTMSK_OEPINT_Field is STM32_SVD.UInt16;
-- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK)
type FS_DAINTMSK_Register is record
-- IN EP interrupt mask bits
IEPM : FS_DAINTMSK_IEPM_Field := 16#0#;
-- OUT endpoint interrupt bits
OEPINT : FS_DAINTMSK_OEPINT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DAINTMSK_Register use record
IEPM at 0 range 0 .. 15;
OEPINT at 0 range 16 .. 31;
end record;
subtype DVBUSDIS_VBUSDT_Field is STM32_SVD.UInt16;
-- OTG_FS device VBUS discharge time register
type DVBUSDIS_Register is record
-- Device VBUS discharge time
VBUSDT : DVBUSDIS_VBUSDT_Field := 16#17D7#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DVBUSDIS_Register use record
VBUSDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DVBUSPULSE_DVBUSP_Field is STM32_SVD.UInt12;
-- OTG_FS device VBUS pulsing time register
type DVBUSPULSE_Register is record
-- Device VBUS pulsing time
DVBUSP : DVBUSPULSE_DVBUSP_Field := 16#5B8#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DVBUSPULSE_Register use record
DVBUSP at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype DIEPEMPMSK_INEPTXFEM_Field is STM32_SVD.UInt16;
-- OTG_FS device IN endpoint FIFO empty interrupt mask register
type DIEPEMPMSK_Register is record
-- IN EP Tx FIFO empty interrupt mask bits
INEPTXFEM : DIEPEMPMSK_INEPTXFEM_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPEMPMSK_Register use record
INEPTXFEM at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_DIEPCTL0_MPSIZ_Field is STM32_SVD.UInt2;
subtype FS_DIEPCTL0_USBAEP_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_NAKSTS_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_EPTYP_Field is STM32_SVD.UInt2;
subtype FS_DIEPCTL0_STALL_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_TXFNUM_Field is STM32_SVD.UInt4;
subtype FS_DIEPCTL0_CNAK_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_SNAK_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_EPDIS_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_EPENA_Field is STM32_SVD.Bit;
-- OTG_FS device control IN endpoint 0 control register (OTG_FS_DIEPCTL0)
type FS_DIEPCTL0_Register is record
-- Maximum packet size
MPSIZ : FS_DIEPCTL0_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_2_14 : STM32_SVD.UInt13 := 16#0#;
-- Read-only. USB active endpoint
USBAEP : FS_DIEPCTL0_USBAEP_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Read-only. NAK status
NAKSTS : FS_DIEPCTL0_NAKSTS_Field := 16#0#;
-- Read-only. Endpoint type
EPTYP : FS_DIEPCTL0_EPTYP_Field := 16#0#;
-- unspecified
Reserved_20_20 : STM32_SVD.Bit := 16#0#;
-- STALL handshake
STALL : FS_DIEPCTL0_STALL_Field := 16#0#;
-- TxFIFO number
TXFNUM : FS_DIEPCTL0_TXFNUM_Field := 16#0#;
-- Write-only. Clear NAK
CNAK : FS_DIEPCTL0_CNAK_Field := 16#0#;
-- Write-only. Set NAK
SNAK : FS_DIEPCTL0_SNAK_Field := 16#0#;
-- unspecified
Reserved_28_29 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. Endpoint disable
EPDIS : FS_DIEPCTL0_EPDIS_Field := 16#0#;
-- Read-only. Endpoint enable
EPENA : FS_DIEPCTL0_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DIEPCTL0_Register use record
MPSIZ at 0 range 0 .. 1;
Reserved_2_14 at 0 range 2 .. 14;
USBAEP at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
STALL at 0 range 21 .. 21;
TXFNUM at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
Reserved_28_29 at 0 range 28 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DIEPINT_XFRC_Field is STM32_SVD.Bit;
subtype DIEPINT_EPDISD_Field is STM32_SVD.Bit;
subtype DIEPINT_TOC_Field is STM32_SVD.Bit;
subtype DIEPINT_ITTXFE_Field is STM32_SVD.Bit;
subtype DIEPINT_INEPNE_Field is STM32_SVD.Bit;
subtype DIEPINT_TXFE_Field is STM32_SVD.Bit;
-- device endpoint-x interrupt register
type DIEPINT_Register is record
-- XFRC
XFRC : DIEPINT_XFRC_Field := 16#0#;
-- EPDISD
EPDISD : DIEPINT_EPDISD_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- TOC
TOC : DIEPINT_TOC_Field := 16#0#;
-- ITTXFE
ITTXFE : DIEPINT_ITTXFE_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- INEPNE
INEPNE : DIEPINT_INEPNE_Field := 16#0#;
-- Read-only. TXFE
TXFE : DIEPINT_TXFE_Field := 16#1#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPINT_Register use record
XFRC at 0 range 0 .. 0;
EPDISD at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
TOC at 0 range 3 .. 3;
ITTXFE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
INEPNE at 0 range 6 .. 6;
TXFE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype DIEPTSIZ0_XFRSIZ_Field is STM32_SVD.UInt7;
subtype DIEPTSIZ0_PKTCNT_Field is STM32_SVD.UInt2;
-- device endpoint-0 transfer size register
type DIEPTSIZ0_Register is record
-- Transfer size
XFRSIZ : DIEPTSIZ0_XFRSIZ_Field := 16#0#;
-- unspecified
Reserved_7_18 : STM32_SVD.UInt12 := 16#0#;
-- Packet count
PKTCNT : DIEPTSIZ0_PKTCNT_Field := 16#0#;
-- unspecified
Reserved_21_31 : STM32_SVD.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPTSIZ0_Register use record
XFRSIZ at 0 range 0 .. 6;
Reserved_7_18 at 0 range 7 .. 18;
PKTCNT at 0 range 19 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype DTXFSTS_INEPTFSAV_Field is STM32_SVD.UInt16;
-- OTG_FS device IN endpoint transmit FIFO status register
type DTXFSTS_Register is record
-- Read-only. IN endpoint TxFIFO space available
INEPTFSAV : DTXFSTS_INEPTFSAV_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DTXFSTS_Register use record
INEPTFSAV at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DIEPCTL1_MPSIZ_Field is STM32_SVD.UInt11;
subtype DIEPCTL1_USBAEP_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EONUM_DPID_Field is STM32_SVD.Bit;
subtype DIEPCTL1_NAKSTS_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EPTYP_Field is STM32_SVD.UInt2;
subtype DIEPCTL1_Stall_Field is STM32_SVD.Bit;
subtype DIEPCTL1_TXFNUM_Field is STM32_SVD.UInt4;
subtype DIEPCTL1_CNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL1_SNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL1_SD0PID_SEVNFRM_Field is STM32_SVD.Bit;
subtype DIEPCTL1_SODDFRM_SD1PID_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EPDIS_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EPENA_Field is STM32_SVD.Bit;
-- OTG device endpoint-1 control register
type DIEPCTL1_Register is record
-- MPSIZ
MPSIZ : DIEPCTL1_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- USBAEP
USBAEP : DIEPCTL1_USBAEP_Field := 16#0#;
-- Read-only. EONUM/DPID
EONUM_DPID : DIEPCTL1_EONUM_DPID_Field := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DIEPCTL1_NAKSTS_Field := 16#0#;
-- EPTYP
EPTYP : DIEPCTL1_EPTYP_Field := 16#0#;
-- unspecified
Reserved_20_20 : STM32_SVD.Bit := 16#0#;
-- Stall
Stall : DIEPCTL1_Stall_Field := 16#0#;
-- TXFNUM
TXFNUM : DIEPCTL1_TXFNUM_Field := 16#0#;
-- Write-only. CNAK
CNAK : DIEPCTL1_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DIEPCTL1_SNAK_Field := 16#0#;
-- Write-only. SD0PID/SEVNFRM
SD0PID_SEVNFRM : DIEPCTL1_SD0PID_SEVNFRM_Field := 16#0#;
-- Write-only. SODDFRM/SD1PID
SODDFRM_SD1PID : DIEPCTL1_SODDFRM_SD1PID_Field := 16#0#;
-- EPDIS
EPDIS : DIEPCTL1_EPDIS_Field := 16#0#;
-- EPENA
EPENA : DIEPCTL1_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPCTL1_Register use record
MPSIZ at 0 range 0 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
USBAEP at 0 range 15 .. 15;
EONUM_DPID at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
TXFNUM at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
SD0PID_SEVNFRM at 0 range 28 .. 28;
SODDFRM_SD1PID at 0 range 29 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DIEPTSIZ_XFRSIZ_Field is STM32_SVD.UInt19;
subtype DIEPTSIZ_PKTCNT_Field is STM32_SVD.UInt10;
subtype DIEPTSIZ_MCNT_Field is STM32_SVD.UInt2;
-- device endpoint-1 transfer size register
type DIEPTSIZ_Register is record
-- Transfer size
XFRSIZ : DIEPTSIZ_XFRSIZ_Field := 16#0#;
-- Packet count
PKTCNT : DIEPTSIZ_PKTCNT_Field := 16#0#;
-- Multi count
MCNT : DIEPTSIZ_MCNT_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPTSIZ_Register use record
XFRSIZ at 0 range 0 .. 18;
PKTCNT at 0 range 19 .. 28;
MCNT at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype DIEPCTL_MPSIZ_Field is STM32_SVD.UInt11;
subtype DIEPCTL_USBAEP_Field is STM32_SVD.Bit;
subtype DIEPCTL_EONUM_DPID_Field is STM32_SVD.Bit;
subtype DIEPCTL_NAKSTS_Field is STM32_SVD.Bit;
subtype DIEPCTL_EPTYP_Field is STM32_SVD.UInt2;
subtype DIEPCTL_Stall_Field is STM32_SVD.Bit;
subtype DIEPCTL_TXFNUM_Field is STM32_SVD.UInt4;
subtype DIEPCTL_CNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL_SNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL_SD0PID_SEVNFRM_Field is STM32_SVD.Bit;
subtype DIEPCTL_SODDFRM_Field is STM32_SVD.Bit;
subtype DIEPCTL_EPDIS_Field is STM32_SVD.Bit;
subtype DIEPCTL_EPENA_Field is STM32_SVD.Bit;
-- OTG device endpoint-2 control register
type DIEPCTL_Register is record
-- MPSIZ
MPSIZ : DIEPCTL_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- USBAEP
USBAEP : DIEPCTL_USBAEP_Field := 16#0#;
-- Read-only. EONUM/DPID
EONUM_DPID : DIEPCTL_EONUM_DPID_Field := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DIEPCTL_NAKSTS_Field := 16#0#;
-- EPTYP
EPTYP : DIEPCTL_EPTYP_Field := 16#0#;
-- unspecified
Reserved_20_20 : STM32_SVD.Bit := 16#0#;
-- Stall
Stall : DIEPCTL_Stall_Field := 16#0#;
-- TXFNUM
TXFNUM : DIEPCTL_TXFNUM_Field := 16#0#;
-- Write-only. CNAK
CNAK : DIEPCTL_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DIEPCTL_SNAK_Field := 16#0#;
-- Write-only. SD0PID/SEVNFRM
SD0PID_SEVNFRM : DIEPCTL_SD0PID_SEVNFRM_Field := 16#0#;
-- Write-only. SODDFRM
SODDFRM : DIEPCTL_SODDFRM_Field := 16#0#;
-- EPDIS
EPDIS : DIEPCTL_EPDIS_Field := 16#0#;
-- EPENA
EPENA : DIEPCTL_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPCTL_Register use record
MPSIZ at 0 range 0 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
USBAEP at 0 range 15 .. 15;
EONUM_DPID at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
TXFNUM at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
SD0PID_SEVNFRM at 0 range 28 .. 28;
SODDFRM at 0 range 29 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DOEPCTL0_MPSIZ_Field is STM32_SVD.UInt2;
subtype DOEPCTL0_USBAEP_Field is STM32_SVD.Bit;
subtype DOEPCTL0_NAKSTS_Field is STM32_SVD.Bit;
subtype DOEPCTL0_EPTYP_Field is STM32_SVD.UInt2;
subtype DOEPCTL0_SNPM_Field is STM32_SVD.Bit;
subtype DOEPCTL0_Stall_Field is STM32_SVD.Bit;
subtype DOEPCTL0_CNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL0_SNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL0_EPDIS_Field is STM32_SVD.Bit;
subtype DOEPCTL0_EPENA_Field is STM32_SVD.Bit;
-- device endpoint-0 control register
type DOEPCTL0_Register is record
-- Read-only. MPSIZ
MPSIZ : DOEPCTL0_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_2_14 : STM32_SVD.UInt13 := 16#0#;
-- Read-only. USBAEP
USBAEP : DOEPCTL0_USBAEP_Field := 16#1#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DOEPCTL0_NAKSTS_Field := 16#0#;
-- Read-only. EPTYP
EPTYP : DOEPCTL0_EPTYP_Field := 16#0#;
-- SNPM
SNPM : DOEPCTL0_SNPM_Field := 16#0#;
-- Stall
Stall : DOEPCTL0_Stall_Field := 16#0#;
-- unspecified
Reserved_22_25 : STM32_SVD.UInt4 := 16#0#;
-- Write-only. CNAK
CNAK : DOEPCTL0_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DOEPCTL0_SNAK_Field := 16#0#;
-- unspecified
Reserved_28_29 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. EPDIS
EPDIS : DOEPCTL0_EPDIS_Field := 16#0#;
-- Write-only. EPENA
EPENA : DOEPCTL0_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPCTL0_Register use record
MPSIZ at 0 range 0 .. 1;
Reserved_2_14 at 0 range 2 .. 14;
USBAEP at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
SNPM at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
Reserved_22_25 at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
Reserved_28_29 at 0 range 28 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DOEPINT_XFRC_Field is STM32_SVD.Bit;
subtype DOEPINT_EPDISD_Field is STM32_SVD.Bit;
subtype DOEPINT_STUP_Field is STM32_SVD.Bit;
subtype DOEPINT_OTEPDIS_Field is STM32_SVD.Bit;
subtype DOEPINT_B2BSTUP_Field is STM32_SVD.Bit;
-- device endpoint-0 interrupt register
type DOEPINT_Register is record
-- XFRC
XFRC : DOEPINT_XFRC_Field := 16#0#;
-- EPDISD
EPDISD : DOEPINT_EPDISD_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- STUP
STUP : DOEPINT_STUP_Field := 16#0#;
-- OTEPDIS
OTEPDIS : DOEPINT_OTEPDIS_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- B2BSTUP
B2BSTUP : DOEPINT_B2BSTUP_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32_SVD.UInt25 := 16#1#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPINT_Register use record
XFRC at 0 range 0 .. 0;
EPDISD at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STUP at 0 range 3 .. 3;
OTEPDIS at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
B2BSTUP at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype DOEPTSIZ0_XFRSIZ_Field is STM32_SVD.UInt7;
subtype DOEPTSIZ0_PKTCNT_Field is STM32_SVD.Bit;
subtype DOEPTSIZ0_STUPCNT_Field is STM32_SVD.UInt2;
-- device OUT endpoint-0 transfer size register
type DOEPTSIZ0_Register is record
-- Transfer size
XFRSIZ : DOEPTSIZ0_XFRSIZ_Field := 16#0#;
-- unspecified
Reserved_7_18 : STM32_SVD.UInt12 := 16#0#;
-- Packet count
PKTCNT : DOEPTSIZ0_PKTCNT_Field := 16#0#;
-- unspecified
Reserved_20_28 : STM32_SVD.UInt9 := 16#0#;
-- SETUP packet count
STUPCNT : DOEPTSIZ0_STUPCNT_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPTSIZ0_Register use record
XFRSIZ at 0 range 0 .. 6;
Reserved_7_18 at 0 range 7 .. 18;
PKTCNT at 0 range 19 .. 19;
Reserved_20_28 at 0 range 20 .. 28;
STUPCNT at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype DOEPCTL_MPSIZ_Field is STM32_SVD.UInt11;
subtype DOEPCTL_USBAEP_Field is STM32_SVD.Bit;
subtype DOEPCTL_EONUM_DPID_Field is STM32_SVD.Bit;
subtype DOEPCTL_NAKSTS_Field is STM32_SVD.Bit;
subtype DOEPCTL_EPTYP_Field is STM32_SVD.UInt2;
subtype DOEPCTL_SNPM_Field is STM32_SVD.Bit;
subtype DOEPCTL_Stall_Field is STM32_SVD.Bit;
subtype DOEPCTL_CNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL_SNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL_SD0PID_SEVNFRM_Field is STM32_SVD.Bit;
subtype DOEPCTL_SODDFRM_Field is STM32_SVD.Bit;
subtype DOEPCTL_EPDIS_Field is STM32_SVD.Bit;
subtype DOEPCTL_EPENA_Field is STM32_SVD.Bit;
-- device endpoint-1 control register
type DOEPCTL_Register is record
-- MPSIZ
MPSIZ : DOEPCTL_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- USBAEP
USBAEP : DOEPCTL_USBAEP_Field := 16#0#;
-- Read-only. EONUM/DPID
EONUM_DPID : DOEPCTL_EONUM_DPID_Field := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DOEPCTL_NAKSTS_Field := 16#0#;
-- EPTYP
EPTYP : DOEPCTL_EPTYP_Field := 16#0#;
-- SNPM
SNPM : DOEPCTL_SNPM_Field := 16#0#;
-- Stall
Stall : DOEPCTL_Stall_Field := 16#0#;
-- unspecified
Reserved_22_25 : STM32_SVD.UInt4 := 16#0#;
-- Write-only. CNAK
CNAK : DOEPCTL_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DOEPCTL_SNAK_Field := 16#0#;
-- Write-only. SD0PID/SEVNFRM
SD0PID_SEVNFRM : DOEPCTL_SD0PID_SEVNFRM_Field := 16#0#;
-- Write-only. SODDFRM
SODDFRM : DOEPCTL_SODDFRM_Field := 16#0#;
-- EPDIS
EPDIS : DOEPCTL_EPDIS_Field := 16#0#;
-- EPENA
EPENA : DOEPCTL_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPCTL_Register use record
MPSIZ at 0 range 0 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
USBAEP at 0 range 15 .. 15;
EONUM_DPID at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
SNPM at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
Reserved_22_25 at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
SD0PID_SEVNFRM at 0 range 28 .. 28;
SODDFRM at 0 range 29 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DOEPTSIZ_XFRSIZ_Field is STM32_SVD.UInt19;
subtype DOEPTSIZ_PKTCNT_Field is STM32_SVD.UInt10;
subtype DOEPTSIZ_RXDPID_STUPCNT_Field is STM32_SVD.UInt2;
-- device OUT endpoint-1 transfer size register
type DOEPTSIZ_Register is record
-- Transfer size
XFRSIZ : DOEPTSIZ_XFRSIZ_Field := 16#0#;
-- Packet count
PKTCNT : DOEPTSIZ_PKTCNT_Field := 16#0#;
-- Received data PID/SETUP packet count
RXDPID_STUPCNT : DOEPTSIZ_RXDPID_STUPCNT_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPTSIZ_Register use record
XFRSIZ at 0 range 0 .. 18;
PKTCNT at 0 range 19 .. 28;
RXDPID_STUPCNT at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FS_GOTGCTL_SRQSCS_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_SRQ_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_HNGSCS_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_HNPRQ_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_HSHNPEN_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_DHNPEN_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_CIDSTS_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_DBCT_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_ASVLD_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_BSVLD_Field is STM32_SVD.Bit;
-- OTG_FS control and status register (OTG_FS_GOTGCTL)
type FS_GOTGCTL_Register is record
-- Read-only. Session request success
SRQSCS : FS_GOTGCTL_SRQSCS_Field := 16#0#;
-- Session request
SRQ : FS_GOTGCTL_SRQ_Field := 16#0#;
-- unspecified
Reserved_2_7 : STM32_SVD.UInt6 := 16#0#;
-- Read-only. Host negotiation success
HNGSCS : FS_GOTGCTL_HNGSCS_Field := 16#0#;
-- HNP request
HNPRQ : FS_GOTGCTL_HNPRQ_Field := 16#0#;
-- Host set HNP enable
HSHNPEN : FS_GOTGCTL_HSHNPEN_Field := 16#0#;
-- Device HNP enabled
DHNPEN : FS_GOTGCTL_DHNPEN_Field := 16#1#;
-- unspecified
Reserved_12_15 : STM32_SVD.UInt4 := 16#0#;
-- Read-only. Connector ID status
CIDSTS : FS_GOTGCTL_CIDSTS_Field := 16#0#;
-- Read-only. Long/short debounce time
DBCT : FS_GOTGCTL_DBCT_Field := 16#0#;
-- Read-only. A-session valid
ASVLD : FS_GOTGCTL_ASVLD_Field := 16#0#;
-- Read-only. B-session valid
BSVLD : FS_GOTGCTL_BSVLD_Field := 16#0#;
-- unspecified
Reserved_20_31 : STM32_SVD.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GOTGCTL_Register use record
SRQSCS at 0 range 0 .. 0;
SRQ at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
HNGSCS at 0 range 8 .. 8;
HNPRQ at 0 range 9 .. 9;
HSHNPEN at 0 range 10 .. 10;
DHNPEN at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
CIDSTS at 0 range 16 .. 16;
DBCT at 0 range 17 .. 17;
ASVLD at 0 range 18 .. 18;
BSVLD at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype FS_GOTGINT_SEDET_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_SRSSCHG_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_HNSSCHG_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_HNGDET_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_ADTOCHG_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_DBCDNE_Field is STM32_SVD.Bit;
-- OTG_FS interrupt register (OTG_FS_GOTGINT)
type FS_GOTGINT_Register is record
-- unspecified
Reserved_0_1 : STM32_SVD.UInt2 := 16#0#;
-- Session end detected
SEDET : FS_GOTGINT_SEDET_Field := 16#0#;
-- unspecified
Reserved_3_7 : STM32_SVD.UInt5 := 16#0#;
-- Session request success status change
SRSSCHG : FS_GOTGINT_SRSSCHG_Field := 16#0#;
-- Host negotiation success status change
HNSSCHG : FS_GOTGINT_HNSSCHG_Field := 16#0#;
-- unspecified
Reserved_10_16 : STM32_SVD.UInt7 := 16#0#;
-- Host negotiation detected
HNGDET : FS_GOTGINT_HNGDET_Field := 16#0#;
-- A-device timeout change
ADTOCHG : FS_GOTGINT_ADTOCHG_Field := 16#0#;
-- Debounce done
DBCDNE : FS_GOTGINT_DBCDNE_Field := 16#0#;
-- unspecified
Reserved_20_31 : STM32_SVD.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GOTGINT_Register use record
Reserved_0_1 at 0 range 0 .. 1;
SEDET at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
SRSSCHG at 0 range 8 .. 8;
HNSSCHG at 0 range 9 .. 9;
Reserved_10_16 at 0 range 10 .. 16;
HNGDET at 0 range 17 .. 17;
ADTOCHG at 0 range 18 .. 18;
DBCDNE at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype FS_GAHBCFG_GINT_Field is STM32_SVD.Bit;
subtype FS_GAHBCFG_TXFELVL_Field is STM32_SVD.Bit;
subtype FS_GAHBCFG_PTXFELVL_Field is STM32_SVD.Bit;
-- OTG_FS AHB configuration register (OTG_FS_GAHBCFG)
type FS_GAHBCFG_Register is record
-- Global interrupt mask
GINT : FS_GAHBCFG_GINT_Field := 16#0#;
-- unspecified
Reserved_1_6 : STM32_SVD.UInt6 := 16#0#;
-- TxFIFO empty level
TXFELVL : FS_GAHBCFG_TXFELVL_Field := 16#0#;
-- Periodic TxFIFO empty level
PTXFELVL : FS_GAHBCFG_PTXFELVL_Field := 16#0#;
-- unspecified
Reserved_9_31 : STM32_SVD.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GAHBCFG_Register use record
GINT at 0 range 0 .. 0;
Reserved_1_6 at 0 range 1 .. 6;
TXFELVL at 0 range 7 .. 7;
PTXFELVL at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
subtype FS_GUSBCFG_TOCAL_Field is STM32_SVD.UInt3;
subtype FS_GUSBCFG_PHYSEL_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_SRPCAP_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_HNPCAP_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_TRDT_Field is STM32_SVD.UInt4;
subtype FS_GUSBCFG_FHMOD_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_FDMOD_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_CTXPKT_Field is STM32_SVD.Bit;
-- OTG_FS USB configuration register (OTG_FS_GUSBCFG)
type FS_GUSBCFG_Register is record
-- FS timeout calibration
TOCAL : FS_GUSBCFG_TOCAL_Field := 16#0#;
-- unspecified
Reserved_3_5 : STM32_SVD.UInt3 := 16#0#;
-- Write-only. Full Speed serial transceiver select
PHYSEL : FS_GUSBCFG_PHYSEL_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- SRP-capable
SRPCAP : FS_GUSBCFG_SRPCAP_Field := 16#0#;
-- HNP-capable
HNPCAP : FS_GUSBCFG_HNPCAP_Field := 16#1#;
-- USB turnaround time
TRDT : FS_GUSBCFG_TRDT_Field := 16#2#;
-- unspecified
Reserved_14_28 : STM32_SVD.UInt15 := 16#0#;
-- Force host mode
FHMOD : FS_GUSBCFG_FHMOD_Field := 16#0#;
-- Force device mode
FDMOD : FS_GUSBCFG_FDMOD_Field := 16#0#;
-- Corrupt Tx packet
CTXPKT : FS_GUSBCFG_CTXPKT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GUSBCFG_Register use record
TOCAL at 0 range 0 .. 2;
Reserved_3_5 at 0 range 3 .. 5;
PHYSEL at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
SRPCAP at 0 range 8 .. 8;
HNPCAP at 0 range 9 .. 9;
TRDT at 0 range 10 .. 13;
Reserved_14_28 at 0 range 14 .. 28;
FHMOD at 0 range 29 .. 29;
FDMOD at 0 range 30 .. 30;
CTXPKT at 0 range 31 .. 31;
end record;
subtype FS_GRSTCTL_CSRST_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_HSRST_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_FCRST_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_RXFFLSH_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_TXFFLSH_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_TXFNUM_Field is STM32_SVD.UInt5;
subtype FS_GRSTCTL_AHBIDL_Field is STM32_SVD.Bit;
-- OTG_FS reset register (OTG_FS_GRSTCTL)
type FS_GRSTCTL_Register is record
-- Core soft reset
CSRST : FS_GRSTCTL_CSRST_Field := 16#0#;
-- HCLK soft reset
HSRST : FS_GRSTCTL_HSRST_Field := 16#0#;
-- Host frame counter reset
FCRST : FS_GRSTCTL_FCRST_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- RxFIFO flush
RXFFLSH : FS_GRSTCTL_RXFFLSH_Field := 16#0#;
-- TxFIFO flush
TXFFLSH : FS_GRSTCTL_TXFFLSH_Field := 16#0#;
-- TxFIFO number
TXFNUM : FS_GRSTCTL_TXFNUM_Field := 16#0#;
-- unspecified
Reserved_11_30 : STM32_SVD.UInt20 := 16#40000#;
-- Read-only. AHB master idle
AHBIDL : FS_GRSTCTL_AHBIDL_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRSTCTL_Register use record
CSRST at 0 range 0 .. 0;
HSRST at 0 range 1 .. 1;
FCRST at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
RXFFLSH at 0 range 4 .. 4;
TXFFLSH at 0 range 5 .. 5;
TXFNUM at 0 range 6 .. 10;
Reserved_11_30 at 0 range 11 .. 30;
AHBIDL at 0 range 31 .. 31;
end record;
subtype FS_GINTSTS_CMOD_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_MMIS_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_OTGINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_SOF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_RXFLVL_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_NPTXFE_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_GINAKEFF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_GOUTNAKEFF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_ESUSP_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_USBSUSP_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_USBRST_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_ENUMDNE_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_ISOODRP_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_EOPF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_IEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_OEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_IISOIXFR_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_IPXFR_INCOMPISOOUT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_HPRTINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_HCINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_PTXFE_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_CIDSCHG_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_DISCINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_SRQINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_WKUPINT_Field is STM32_SVD.Bit;
-- OTG_FS core interrupt register (OTG_FS_GINTSTS)
type FS_GINTSTS_Register is record
-- Read-only. Current mode of operation
CMOD : FS_GINTSTS_CMOD_Field := 16#0#;
-- Mode mismatch interrupt
MMIS : FS_GINTSTS_MMIS_Field := 16#0#;
-- Read-only. OTG interrupt
OTGINT : FS_GINTSTS_OTGINT_Field := 16#0#;
-- Start of frame
SOF : FS_GINTSTS_SOF_Field := 16#0#;
-- Read-only. RxFIFO non-empty
RXFLVL : FS_GINTSTS_RXFLVL_Field := 16#0#;
-- Read-only. Non-periodic TxFIFO empty
NPTXFE : FS_GINTSTS_NPTXFE_Field := 16#1#;
-- Read-only. Global IN non-periodic NAK effective
GINAKEFF : FS_GINTSTS_GINAKEFF_Field := 16#0#;
-- Read-only. Global OUT NAK effective
GOUTNAKEFF : FS_GINTSTS_GOUTNAKEFF_Field := 16#0#;
-- unspecified
Reserved_8_9 : STM32_SVD.UInt2 := 16#0#;
-- Early suspend
ESUSP : FS_GINTSTS_ESUSP_Field := 16#0#;
-- USB suspend
USBSUSP : FS_GINTSTS_USBSUSP_Field := 16#0#;
-- USB reset
USBRST : FS_GINTSTS_USBRST_Field := 16#0#;
-- Enumeration done
ENUMDNE : FS_GINTSTS_ENUMDNE_Field := 16#0#;
-- Isochronous OUT packet dropped interrupt
ISOODRP : FS_GINTSTS_ISOODRP_Field := 16#0#;
-- End of periodic frame interrupt
EOPF : FS_GINTSTS_EOPF_Field := 16#0#;
-- unspecified
Reserved_16_17 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. IN endpoint interrupt
IEPINT : FS_GINTSTS_IEPINT_Field := 16#0#;
-- Read-only. OUT endpoint interrupt
OEPINT : FS_GINTSTS_OEPINT_Field := 16#0#;
-- Incomplete isochronous IN transfer
IISOIXFR : FS_GINTSTS_IISOIXFR_Field := 16#0#;
-- Incomplete periodic transfer(Host mode)/Incomplete isochronous OUT
-- transfer(Device mode)
IPXFR_INCOMPISOOUT : FS_GINTSTS_IPXFR_INCOMPISOOUT_Field := 16#0#;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. Host port interrupt
HPRTINT : FS_GINTSTS_HPRTINT_Field := 16#0#;
-- Read-only. Host channels interrupt
HCINT : FS_GINTSTS_HCINT_Field := 16#0#;
-- Read-only. Periodic TxFIFO empty
PTXFE : FS_GINTSTS_PTXFE_Field := 16#1#;
-- unspecified
Reserved_27_27 : STM32_SVD.Bit := 16#0#;
-- Connector ID status change
CIDSCHG : FS_GINTSTS_CIDSCHG_Field := 16#0#;
-- Disconnect detected interrupt
DISCINT : FS_GINTSTS_DISCINT_Field := 16#0#;
-- Session request/new session detected interrupt
SRQINT : FS_GINTSTS_SRQINT_Field := 16#0#;
-- Resume/remote wakeup detected interrupt
WKUPINT : FS_GINTSTS_WKUPINT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GINTSTS_Register use record
CMOD at 0 range 0 .. 0;
MMIS at 0 range 1 .. 1;
OTGINT at 0 range 2 .. 2;
SOF at 0 range 3 .. 3;
RXFLVL at 0 range 4 .. 4;
NPTXFE at 0 range 5 .. 5;
GINAKEFF at 0 range 6 .. 6;
GOUTNAKEFF at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
ESUSP at 0 range 10 .. 10;
USBSUSP at 0 range 11 .. 11;
USBRST at 0 range 12 .. 12;
ENUMDNE at 0 range 13 .. 13;
ISOODRP at 0 range 14 .. 14;
EOPF at 0 range 15 .. 15;
Reserved_16_17 at 0 range 16 .. 17;
IEPINT at 0 range 18 .. 18;
OEPINT at 0 range 19 .. 19;
IISOIXFR at 0 range 20 .. 20;
IPXFR_INCOMPISOOUT at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
HPRTINT at 0 range 24 .. 24;
HCINT at 0 range 25 .. 25;
PTXFE at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
CIDSCHG at 0 range 28 .. 28;
DISCINT at 0 range 29 .. 29;
SRQINT at 0 range 30 .. 30;
WKUPINT at 0 range 31 .. 31;
end record;
subtype FS_GINTMSK_MMISM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_OTGINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_SOFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_RXFLVLM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_NPTXFEM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_GINAKEFFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_GONAKEFFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_ESUSPM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_USBSUSPM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_USBRST_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_ENUMDNEM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_ISOODRPM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_EOPFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_EPMISM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_IEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_OEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_IISOIXFRM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_IPXFRM_IISOOXFRM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_PRTIM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_HCIM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_PTXFEM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_CIDSCHGM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_DISCINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_SRQIM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_WUIM_Field is STM32_SVD.Bit;
-- OTG_FS interrupt mask register (OTG_FS_GINTMSK)
type FS_GINTMSK_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit := 16#0#;
-- Mode mismatch interrupt mask
MMISM : FS_GINTMSK_MMISM_Field := 16#0#;
-- OTG interrupt mask
OTGINT : FS_GINTMSK_OTGINT_Field := 16#0#;
-- Start of frame mask
SOFM : FS_GINTMSK_SOFM_Field := 16#0#;
-- Receive FIFO non-empty mask
RXFLVLM : FS_GINTMSK_RXFLVLM_Field := 16#0#;
-- Non-periodic TxFIFO empty mask
NPTXFEM : FS_GINTMSK_NPTXFEM_Field := 16#0#;
-- Global non-periodic IN NAK effective mask
GINAKEFFM : FS_GINTMSK_GINAKEFFM_Field := 16#0#;
-- Global OUT NAK effective mask
GONAKEFFM : FS_GINTMSK_GONAKEFFM_Field := 16#0#;
-- unspecified
Reserved_8_9 : STM32_SVD.UInt2 := 16#0#;
-- Early suspend mask
ESUSPM : FS_GINTMSK_ESUSPM_Field := 16#0#;
-- USB suspend mask
USBSUSPM : FS_GINTMSK_USBSUSPM_Field := 16#0#;
-- USB reset mask
USBRST : FS_GINTMSK_USBRST_Field := 16#0#;
-- Enumeration done mask
ENUMDNEM : FS_GINTMSK_ENUMDNEM_Field := 16#0#;
-- Isochronous OUT packet dropped interrupt mask
ISOODRPM : FS_GINTMSK_ISOODRPM_Field := 16#0#;
-- End of periodic frame interrupt mask
EOPFM : FS_GINTMSK_EOPFM_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Endpoint mismatch interrupt mask
EPMISM : FS_GINTMSK_EPMISM_Field := 16#0#;
-- IN endpoints interrupt mask
IEPINT : FS_GINTMSK_IEPINT_Field := 16#0#;
-- OUT endpoints interrupt mask
OEPINT : FS_GINTMSK_OEPINT_Field := 16#0#;
-- Incomplete isochronous IN transfer mask
IISOIXFRM : FS_GINTMSK_IISOIXFRM_Field := 16#0#;
-- Incomplete periodic transfer mask(Host mode)/Incomplete isochronous
-- OUT transfer mask(Device mode)
IPXFRM_IISOOXFRM : FS_GINTMSK_IPXFRM_IISOOXFRM_Field := 16#0#;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. Host port interrupt mask
PRTIM : FS_GINTMSK_PRTIM_Field := 16#0#;
-- Host channels interrupt mask
HCIM : FS_GINTMSK_HCIM_Field := 16#0#;
-- Periodic TxFIFO empty mask
PTXFEM : FS_GINTMSK_PTXFEM_Field := 16#0#;
-- unspecified
Reserved_27_27 : STM32_SVD.Bit := 16#0#;
-- Connector ID status change mask
CIDSCHGM : FS_GINTMSK_CIDSCHGM_Field := 16#0#;
-- Disconnect detected interrupt mask
DISCINT : FS_GINTMSK_DISCINT_Field := 16#0#;
-- Session request/new session detected interrupt mask
SRQIM : FS_GINTMSK_SRQIM_Field := 16#0#;
-- Resume/remote wakeup detected interrupt mask
WUIM : FS_GINTMSK_WUIM_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GINTMSK_Register use record
Reserved_0_0 at 0 range 0 .. 0;
MMISM at 0 range 1 .. 1;
OTGINT at 0 range 2 .. 2;
SOFM at 0 range 3 .. 3;
RXFLVLM at 0 range 4 .. 4;
NPTXFEM at 0 range 5 .. 5;
GINAKEFFM at 0 range 6 .. 6;
GONAKEFFM at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
ESUSPM at 0 range 10 .. 10;
USBSUSPM at 0 range 11 .. 11;
USBRST at 0 range 12 .. 12;
ENUMDNEM at 0 range 13 .. 13;
ISOODRPM at 0 range 14 .. 14;
EOPFM at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
EPMISM at 0 range 17 .. 17;
IEPINT at 0 range 18 .. 18;
OEPINT at 0 range 19 .. 19;
IISOIXFRM at 0 range 20 .. 20;
IPXFRM_IISOOXFRM at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
PRTIM at 0 range 24 .. 24;
HCIM at 0 range 25 .. 25;
PTXFEM at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
CIDSCHGM at 0 range 28 .. 28;
DISCINT at 0 range 29 .. 29;
SRQIM at 0 range 30 .. 30;
WUIM at 0 range 31 .. 31;
end record;
subtype FS_GRXSTSR_Device_EPNUM_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Device_BCNT_Field is STM32_SVD.UInt11;
subtype FS_GRXSTSR_Device_DPID_Field is STM32_SVD.UInt2;
subtype FS_GRXSTSR_Device_PKTSTS_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Device_FRMNUM_Field is STM32_SVD.UInt4;
-- OTG_FS Receive status debug read(Device mode)
type FS_GRXSTSR_Device_Register is record
-- Read-only. Endpoint number
EPNUM : FS_GRXSTSR_Device_EPNUM_Field;
-- Read-only. Byte count
BCNT : FS_GRXSTSR_Device_BCNT_Field;
-- Read-only. Data PID
DPID : FS_GRXSTSR_Device_DPID_Field;
-- Read-only. Packet status
PKTSTS : FS_GRXSTSR_Device_PKTSTS_Field;
-- Read-only. Frame number
FRMNUM : FS_GRXSTSR_Device_FRMNUM_Field;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRXSTSR_Device_Register use record
EPNUM at 0 range 0 .. 3;
BCNT at 0 range 4 .. 14;
DPID at 0 range 15 .. 16;
PKTSTS at 0 range 17 .. 20;
FRMNUM at 0 range 21 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype FS_GRXSTSR_Host_EPNUM_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Host_BCNT_Field is STM32_SVD.UInt11;
subtype FS_GRXSTSR_Host_DPID_Field is STM32_SVD.UInt2;
subtype FS_GRXSTSR_Host_PKTSTS_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Host_FRMNUM_Field is STM32_SVD.UInt4;
-- OTG_FS Receive status debug read(Host mode)
type FS_GRXSTSR_Host_Register is record
-- Read-only. Endpoint number
EPNUM : FS_GRXSTSR_Host_EPNUM_Field;
-- Read-only. Byte count
BCNT : FS_GRXSTSR_Host_BCNT_Field;
-- Read-only. Data PID
DPID : FS_GRXSTSR_Host_DPID_Field;
-- Read-only. Packet status
PKTSTS : FS_GRXSTSR_Host_PKTSTS_Field;
-- Read-only. Frame number
FRMNUM : FS_GRXSTSR_Host_FRMNUM_Field;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRXSTSR_Host_Register use record
EPNUM at 0 range 0 .. 3;
BCNT at 0 range 4 .. 14;
DPID at 0 range 15 .. 16;
PKTSTS at 0 range 17 .. 20;
FRMNUM at 0 range 21 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype FS_GRXFSIZ_RXFD_Field is STM32_SVD.UInt16;
-- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ)
type FS_GRXFSIZ_Register is record
-- RxFIFO depth
RXFD : FS_GRXFSIZ_RXFD_Field := 16#200#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRXFSIZ_Register use record
RXFD at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_GNPTXFSIZ_Device_TX0FSA_Field is STM32_SVD.UInt16;
subtype FS_GNPTXFSIZ_Device_TX0FD_Field is STM32_SVD.UInt16;
-- OTG_FS non-periodic transmit FIFO size register (Device mode)
type FS_GNPTXFSIZ_Device_Register is record
-- Endpoint 0 transmit RAM start address
TX0FSA : FS_GNPTXFSIZ_Device_TX0FSA_Field := 16#200#;
-- Endpoint 0 TxFIFO depth
TX0FD : FS_GNPTXFSIZ_Device_TX0FD_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GNPTXFSIZ_Device_Register use record
TX0FSA at 0 range 0 .. 15;
TX0FD at 0 range 16 .. 31;
end record;
subtype FS_GNPTXFSIZ_Host_NPTXFSA_Field is STM32_SVD.UInt16;
subtype FS_GNPTXFSIZ_Host_NPTXFD_Field is STM32_SVD.UInt16;
-- OTG_FS non-periodic transmit FIFO size register (Host mode)
type FS_GNPTXFSIZ_Host_Register is record
-- Non-periodic transmit RAM start address
NPTXFSA : FS_GNPTXFSIZ_Host_NPTXFSA_Field := 16#200#;
-- Non-periodic TxFIFO depth
NPTXFD : FS_GNPTXFSIZ_Host_NPTXFD_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GNPTXFSIZ_Host_Register use record
NPTXFSA at 0 range 0 .. 15;
NPTXFD at 0 range 16 .. 31;
end record;
subtype FS_GNPTXSTS_NPTXFSAV_Field is STM32_SVD.UInt16;
subtype FS_GNPTXSTS_NPTQXSAV_Field is STM32_SVD.Byte;
subtype FS_GNPTXSTS_NPTXQTOP_Field is STM32_SVD.UInt7;
-- OTG_FS non-periodic transmit FIFO/queue status register
-- (OTG_FS_GNPTXSTS)
type FS_GNPTXSTS_Register is record
-- Read-only. Non-periodic TxFIFO space available
NPTXFSAV : FS_GNPTXSTS_NPTXFSAV_Field;
-- Read-only. Non-periodic transmit request queue space available
NPTQXSAV : FS_GNPTXSTS_NPTQXSAV_Field;
-- Read-only. Top of the non-periodic transmit request queue
NPTXQTOP : FS_GNPTXSTS_NPTXQTOP_Field;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GNPTXSTS_Register use record
NPTXFSAV at 0 range 0 .. 15;
NPTQXSAV at 0 range 16 .. 23;
NPTXQTOP at 0 range 24 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FS_GCCFG_PWRDWN_Field is STM32_SVD.Bit;
subtype FS_GCCFG_VBUSASEN_Field is STM32_SVD.Bit;
subtype FS_GCCFG_VBUSBSEN_Field is STM32_SVD.Bit;
subtype FS_GCCFG_SOFOUTEN_Field is STM32_SVD.Bit;
-- OTG_FS general core configuration register (OTG_FS_GCCFG)
type FS_GCCFG_Register is record
-- unspecified
Reserved_0_15 : STM32_SVD.UInt16 := 16#0#;
-- Power down
PWRDWN : FS_GCCFG_PWRDWN_Field := 16#0#;
-- unspecified
Reserved_17_17 : STM32_SVD.Bit := 16#0#;
-- Enable the VBUS sensing device
VBUSASEN : FS_GCCFG_VBUSASEN_Field := 16#0#;
-- Enable the VBUS sensing device
VBUSBSEN : FS_GCCFG_VBUSBSEN_Field := 16#0#;
-- SOF output enable
SOFOUTEN : FS_GCCFG_SOFOUTEN_Field := 16#0#;
-- unspecified
Reserved_21_31 : STM32_SVD.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GCCFG_Register use record
Reserved_0_15 at 0 range 0 .. 15;
PWRDWN at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
VBUSASEN at 0 range 18 .. 18;
VBUSBSEN at 0 range 19 .. 19;
SOFOUTEN at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype FS_HPTXFSIZ_PTXSA_Field is STM32_SVD.UInt16;
subtype FS_HPTXFSIZ_PTXFSIZ_Field is STM32_SVD.UInt16;
-- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ)
type FS_HPTXFSIZ_Register is record
-- Host periodic TxFIFO start address
PTXSA : FS_HPTXFSIZ_PTXSA_Field := 16#600#;
-- Host periodic TxFIFO depth
PTXFSIZ : FS_HPTXFSIZ_PTXFSIZ_Field := 16#200#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HPTXFSIZ_Register use record
PTXSA at 0 range 0 .. 15;
PTXFSIZ at 0 range 16 .. 31;
end record;
subtype FS_DIEPTXF_INEPTXSA_Field is STM32_SVD.UInt16;
subtype FS_DIEPTXF_INEPTXFD_Field is STM32_SVD.UInt16;
-- OTG_FS device IN endpoint transmit FIFO size register (OTG_FS_DIEPTXF2)
type FS_DIEPTXF_Register is record
-- IN endpoint FIFO2 transmit RAM start address
INEPTXSA : FS_DIEPTXF_INEPTXSA_Field := 16#400#;
-- IN endpoint TxFIFO depth
INEPTXFD : FS_DIEPTXF_INEPTXFD_Field := 16#200#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DIEPTXF_Register use record
INEPTXSA at 0 range 0 .. 15;
INEPTXFD at 0 range 16 .. 31;
end record;
subtype FS_HCFG_FSLSPCS_Field is STM32_SVD.UInt2;
subtype FS_HCFG_FSLSS_Field is STM32_SVD.Bit;
-- OTG_FS host configuration register (OTG_FS_HCFG)
type FS_HCFG_Register is record
-- FS/LS PHY clock select
FSLSPCS : FS_HCFG_FSLSPCS_Field := 16#0#;
-- Read-only. FS- and LS-only support
FSLSS : FS_HCFG_FSLSS_Field := 16#0#;
-- unspecified
Reserved_3_31 : STM32_SVD.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCFG_Register use record
FSLSPCS at 0 range 0 .. 1;
FSLSS at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype HFIR_FRIVL_Field is STM32_SVD.UInt16;
-- OTG_FS Host frame interval register
type HFIR_Register is record
-- Frame interval
FRIVL : HFIR_FRIVL_Field := 16#EA60#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HFIR_Register use record
FRIVL at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_HFNUM_FRNUM_Field is STM32_SVD.UInt16;
subtype FS_HFNUM_FTREM_Field is STM32_SVD.UInt16;
-- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM)
type FS_HFNUM_Register is record
-- Read-only. Frame number
FRNUM : FS_HFNUM_FRNUM_Field;
-- Read-only. Frame time remaining
FTREM : FS_HFNUM_FTREM_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HFNUM_Register use record
FRNUM at 0 range 0 .. 15;
FTREM at 0 range 16 .. 31;
end record;
subtype FS_HPTXSTS_PTXFSAVL_Field is STM32_SVD.UInt16;
subtype FS_HPTXSTS_PTXQSAV_Field is STM32_SVD.Byte;
subtype FS_HPTXSTS_PTXQTOP_Field is STM32_SVD.Byte;
-- OTG_FS_Host periodic transmit FIFO/queue status register
-- (OTG_FS_HPTXSTS)
type FS_HPTXSTS_Register is record
-- Periodic transmit data FIFO space available
PTXFSAVL : FS_HPTXSTS_PTXFSAVL_Field := 16#100#;
-- Read-only. Periodic transmit request queue space available
PTXQSAV : FS_HPTXSTS_PTXQSAV_Field := 16#8#;
-- Read-only. Top of the periodic transmit request queue
PTXQTOP : FS_HPTXSTS_PTXQTOP_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HPTXSTS_Register use record
PTXFSAVL at 0 range 0 .. 15;
PTXQSAV at 0 range 16 .. 23;
PTXQTOP at 0 range 24 .. 31;
end record;
subtype HAINT_HAINT_Field is STM32_SVD.UInt16;
-- OTG_FS Host all channels interrupt register
type HAINT_Register is record
-- Read-only. Channel interrupts
HAINT : HAINT_HAINT_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HAINT_Register use record
HAINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype HAINTMSK_HAINTM_Field is STM32_SVD.UInt16;
-- OTG_FS host all channels interrupt mask register
type HAINTMSK_Register is record
-- Channel interrupt mask
HAINTM : HAINTMSK_HAINTM_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HAINTMSK_Register use record
HAINTM at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_HPRT_PCSTS_Field is STM32_SVD.Bit;
subtype FS_HPRT_PCDET_Field is STM32_SVD.Bit;
subtype FS_HPRT_PENA_Field is STM32_SVD.Bit;
subtype FS_HPRT_PENCHNG_Field is STM32_SVD.Bit;
subtype FS_HPRT_POCA_Field is STM32_SVD.Bit;
subtype FS_HPRT_POCCHNG_Field is STM32_SVD.Bit;
subtype FS_HPRT_PRES_Field is STM32_SVD.Bit;
subtype FS_HPRT_PSUSP_Field is STM32_SVD.Bit;
subtype FS_HPRT_PRST_Field is STM32_SVD.Bit;
subtype FS_HPRT_PLSTS_Field is STM32_SVD.UInt2;
subtype FS_HPRT_PPWR_Field is STM32_SVD.Bit;
subtype FS_HPRT_PTCTL_Field is STM32_SVD.UInt4;
subtype FS_HPRT_PSPD_Field is STM32_SVD.UInt2;
-- OTG_FS host port control and status register (OTG_FS_HPRT)
type FS_HPRT_Register is record
-- Read-only. Port connect status
PCSTS : FS_HPRT_PCSTS_Field := 16#0#;
-- Port connect detected
PCDET : FS_HPRT_PCDET_Field := 16#0#;
-- Port enable
PENA : FS_HPRT_PENA_Field := 16#0#;
-- Port enable/disable change
PENCHNG : FS_HPRT_PENCHNG_Field := 16#0#;
-- Read-only. Port overcurrent active
POCA : FS_HPRT_POCA_Field := 16#0#;
-- Port overcurrent change
POCCHNG : FS_HPRT_POCCHNG_Field := 16#0#;
-- Port resume
PRES : FS_HPRT_PRES_Field := 16#0#;
-- Port suspend
PSUSP : FS_HPRT_PSUSP_Field := 16#0#;
-- Port reset
PRST : FS_HPRT_PRST_Field := 16#0#;
-- unspecified
Reserved_9_9 : STM32_SVD.Bit := 16#0#;
-- Read-only. Port line status
PLSTS : FS_HPRT_PLSTS_Field := 16#0#;
-- Port power
PPWR : FS_HPRT_PPWR_Field := 16#0#;
-- Port test control
PTCTL : FS_HPRT_PTCTL_Field := 16#0#;
-- Read-only. Port speed
PSPD : FS_HPRT_PSPD_Field := 16#0#;
-- unspecified
Reserved_19_31 : STM32_SVD.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HPRT_Register use record
PCSTS at 0 range 0 .. 0;
PCDET at 0 range 1 .. 1;
PENA at 0 range 2 .. 2;
PENCHNG at 0 range 3 .. 3;
POCA at 0 range 4 .. 4;
POCCHNG at 0 range 5 .. 5;
PRES at 0 range 6 .. 6;
PSUSP at 0 range 7 .. 7;
PRST at 0 range 8 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
PLSTS at 0 range 10 .. 11;
PPWR at 0 range 12 .. 12;
PTCTL at 0 range 13 .. 16;
PSPD at 0 range 17 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype FS_HCCHAR_MPSIZ_Field is STM32_SVD.UInt11;
subtype FS_HCCHAR_EPNUM_Field is STM32_SVD.UInt4;
subtype FS_HCCHAR_EPDIR_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_LSDEV_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_EPTYP_Field is STM32_SVD.UInt2;
subtype FS_HCCHAR_MCNT_Field is STM32_SVD.UInt2;
subtype FS_HCCHAR_DAD_Field is STM32_SVD.UInt7;
subtype FS_HCCHAR_ODDFRM_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_CHDIS_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_CHENA_Field is STM32_SVD.Bit;
-- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0)
type FS_HCCHAR_Register is record
-- Maximum packet size
MPSIZ : FS_HCCHAR_MPSIZ_Field := 16#0#;
-- Endpoint number
EPNUM : FS_HCCHAR_EPNUM_Field := 16#0#;
-- Endpoint direction
EPDIR : FS_HCCHAR_EPDIR_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Low-speed device
LSDEV : FS_HCCHAR_LSDEV_Field := 16#0#;
-- Endpoint type
EPTYP : FS_HCCHAR_EPTYP_Field := 16#0#;
-- Multicount
MCNT : FS_HCCHAR_MCNT_Field := 16#0#;
-- Device address
DAD : FS_HCCHAR_DAD_Field := 16#0#;
-- Odd frame
ODDFRM : FS_HCCHAR_ODDFRM_Field := 16#0#;
-- Channel disable
CHDIS : FS_HCCHAR_CHDIS_Field := 16#0#;
-- Channel enable
CHENA : FS_HCCHAR_CHENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCCHAR_Register use record
MPSIZ at 0 range 0 .. 10;
EPNUM at 0 range 11 .. 14;
EPDIR at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
LSDEV at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
MCNT at 0 range 20 .. 21;
DAD at 0 range 22 .. 28;
ODDFRM at 0 range 29 .. 29;
CHDIS at 0 range 30 .. 30;
CHENA at 0 range 31 .. 31;
end record;
subtype FS_HCINT_XFRC_Field is STM32_SVD.Bit;
subtype FS_HCINT_CHH_Field is STM32_SVD.Bit;
subtype FS_HCINT_STALL_Field is STM32_SVD.Bit;
subtype FS_HCINT_NAK_Field is STM32_SVD.Bit;
subtype FS_HCINT_ACK_Field is STM32_SVD.Bit;
subtype FS_HCINT_TXERR_Field is STM32_SVD.Bit;
subtype FS_HCINT_BBERR_Field is STM32_SVD.Bit;
subtype FS_HCINT_FRMOR_Field is STM32_SVD.Bit;
subtype FS_HCINT_DTERR_Field is STM32_SVD.Bit;
-- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0)
type FS_HCINT_Register is record
-- Transfer completed
XFRC : FS_HCINT_XFRC_Field := 16#0#;
-- Channel halted
CHH : FS_HCINT_CHH_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- STALL response received interrupt
STALL : FS_HCINT_STALL_Field := 16#0#;
-- NAK response received interrupt
NAK : FS_HCINT_NAK_Field := 16#0#;
-- ACK response received/transmitted interrupt
ACK : FS_HCINT_ACK_Field := 16#0#;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Transaction error
TXERR : FS_HCINT_TXERR_Field := 16#0#;
-- Babble error
BBERR : FS_HCINT_BBERR_Field := 16#0#;
-- Frame overrun
FRMOR : FS_HCINT_FRMOR_Field := 16#0#;
-- Data toggle error
DTERR : FS_HCINT_DTERR_Field := 16#0#;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCINT_Register use record
XFRC at 0 range 0 .. 0;
CHH at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STALL at 0 range 3 .. 3;
NAK at 0 range 4 .. 4;
ACK at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
TXERR at 0 range 7 .. 7;
BBERR at 0 range 8 .. 8;
FRMOR at 0 range 9 .. 9;
DTERR at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype FS_HCINTMSK_XFRCM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_CHHM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_STALLM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_NAKM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_ACKM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_NYET_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_TXERRM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_BBERRM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_FRMORM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_DTERRM_Field is STM32_SVD.Bit;
-- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0)
type FS_HCINTMSK_Register is record
-- Transfer completed mask
XFRCM : FS_HCINTMSK_XFRCM_Field := 16#0#;
-- Channel halted mask
CHHM : FS_HCINTMSK_CHHM_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- STALL response received interrupt mask
STALLM : FS_HCINTMSK_STALLM_Field := 16#0#;
-- NAK response received interrupt mask
NAKM : FS_HCINTMSK_NAKM_Field := 16#0#;
-- ACK response received/transmitted interrupt mask
ACKM : FS_HCINTMSK_ACKM_Field := 16#0#;
-- response received interrupt mask
NYET : FS_HCINTMSK_NYET_Field := 16#0#;
-- Transaction error mask
TXERRM : FS_HCINTMSK_TXERRM_Field := 16#0#;
-- Babble error mask
BBERRM : FS_HCINTMSK_BBERRM_Field := 16#0#;
-- Frame overrun mask
FRMORM : FS_HCINTMSK_FRMORM_Field := 16#0#;
-- Data toggle error mask
DTERRM : FS_HCINTMSK_DTERRM_Field := 16#0#;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCINTMSK_Register use record
XFRCM at 0 range 0 .. 0;
CHHM at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STALLM at 0 range 3 .. 3;
NAKM at 0 range 4 .. 4;
ACKM at 0 range 5 .. 5;
NYET at 0 range 6 .. 6;
TXERRM at 0 range 7 .. 7;
BBERRM at 0 range 8 .. 8;
FRMORM at 0 range 9 .. 9;
DTERRM at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype FS_HCTSIZ_XFRSIZ_Field is STM32_SVD.UInt19;
subtype FS_HCTSIZ_PKTCNT_Field is STM32_SVD.UInt10;
subtype FS_HCTSIZ_DPID_Field is STM32_SVD.UInt2;
-- OTG_FS host channel-0 transfer size register
type FS_HCTSIZ_Register is record
-- Transfer size
XFRSIZ : FS_HCTSIZ_XFRSIZ_Field := 16#0#;
-- Packet count
PKTCNT : FS_HCTSIZ_PKTCNT_Field := 16#0#;
-- Data PID
DPID : FS_HCTSIZ_DPID_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCTSIZ_Register use record
XFRSIZ at 0 range 0 .. 18;
PKTCNT at 0 range 19 .. 28;
DPID at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FS_PCGCCTL_STPPCLK_Field is STM32_SVD.Bit;
subtype FS_PCGCCTL_GATEHCLK_Field is STM32_SVD.Bit;
subtype FS_PCGCCTL_PHYSUSP_Field is STM32_SVD.Bit;
-- OTG_FS power and clock gating control register
type FS_PCGCCTL_Register is record
-- Stop PHY clock
STPPCLK : FS_PCGCCTL_STPPCLK_Field := 16#0#;
-- Gate HCLK
GATEHCLK : FS_PCGCCTL_GATEHCLK_Field := 16#0#;
-- unspecified
Reserved_2_3 : STM32_SVD.UInt2 := 16#0#;
-- PHY Suspended
PHYSUSP : FS_PCGCCTL_PHYSUSP_Field := 16#0#;
-- unspecified
Reserved_5_31 : STM32_SVD.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_PCGCCTL_Register use record
STPPCLK at 0 range 0 .. 0;
GATEHCLK at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
PHYSUSP at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- USB on the go full speed
type OTG_FS_DEVICE_Peripheral is record
-- OTG_FS device configuration register (OTG_FS_DCFG)
FS_DCFG : aliased FS_DCFG_Register;
-- OTG_FS device control register (OTG_FS_DCTL)
FS_DCTL : aliased FS_DCTL_Register;
-- OTG_FS device status register (OTG_FS_DSTS)
FS_DSTS : aliased FS_DSTS_Register;
-- OTG_FS device IN endpoint common interrupt mask register
-- (OTG_FS_DIEPMSK)
FS_DIEPMSK : aliased FS_DIEPMSK_Register;
-- OTG_FS device OUT endpoint common interrupt mask register
-- (OTG_FS_DOEPMSK)
FS_DOEPMSK : aliased FS_DOEPMSK_Register;
-- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT)
FS_DAINT : aliased FS_DAINT_Register;
-- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK)
FS_DAINTMSK : aliased FS_DAINTMSK_Register;
-- OTG_FS device VBUS discharge time register
DVBUSDIS : aliased DVBUSDIS_Register;
-- OTG_FS device VBUS pulsing time register
DVBUSPULSE : aliased DVBUSPULSE_Register;
-- OTG_FS device IN endpoint FIFO empty interrupt mask register
DIEPEMPMSK : aliased DIEPEMPMSK_Register;
-- OTG_FS device control IN endpoint 0 control register
-- (OTG_FS_DIEPCTL0)
FS_DIEPCTL0 : aliased FS_DIEPCTL0_Register;
-- device endpoint-x interrupt register
DIEPINT0 : aliased DIEPINT_Register;
-- device endpoint-0 transfer size register
DIEPTSIZ0 : aliased DIEPTSIZ0_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS0 : aliased DTXFSTS_Register;
-- OTG device endpoint-1 control register
DIEPCTL1 : aliased DIEPCTL1_Register;
-- device endpoint-1 interrupt register
DIEPINT1 : aliased DIEPINT_Register;
-- device endpoint-1 transfer size register
DIEPTSIZ1 : aliased DIEPTSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS1 : aliased DTXFSTS_Register;
-- OTG device endpoint-2 control register
DIEPCTL2 : aliased DIEPCTL_Register;
-- device endpoint-2 interrupt register
DIEPINT2 : aliased DIEPINT_Register;
-- device endpoint-2 transfer size register
DIEPTSIZ2 : aliased DIEPTSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS2 : aliased DTXFSTS_Register;
-- OTG device endpoint-3 control register
DIEPCTL3 : aliased DIEPCTL_Register;
-- device endpoint-3 interrupt register
DIEPINT3 : aliased DIEPINT_Register;
-- device endpoint-3 transfer size register
DIEPTSIZ3 : aliased DIEPTSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS3 : aliased DTXFSTS_Register;
-- device endpoint-0 control register
DOEPCTL0 : aliased DOEPCTL0_Register;
-- device endpoint-0 interrupt register
DOEPINT0 : aliased DOEPINT_Register;
-- device OUT endpoint-0 transfer size register
DOEPTSIZ0 : aliased DOEPTSIZ0_Register;
-- device endpoint-1 control register
DOEPCTL1 : aliased DOEPCTL_Register;
-- device endpoint-1 interrupt register
DOEPINT1 : aliased DOEPINT_Register;
-- device OUT endpoint-1 transfer size register
DOEPTSIZ1 : aliased DOEPTSIZ_Register;
-- device endpoint-2 control register
DOEPCTL2 : aliased DOEPCTL_Register;
-- device endpoint-2 interrupt register
DOEPINT2 : aliased DOEPINT_Register;
-- device OUT endpoint-2 transfer size register
DOEPTSIZ2 : aliased DOEPTSIZ_Register;
-- device endpoint-3 control register
DOEPCTL3 : aliased DOEPCTL_Register;
-- device endpoint-3 interrupt register
DOEPINT3 : aliased DOEPINT_Register;
-- device OUT endpoint-3 transfer size register
DOEPTSIZ3 : aliased DOEPTSIZ_Register;
end record
with Volatile;
for OTG_FS_DEVICE_Peripheral use record
FS_DCFG at 16#0# range 0 .. 31;
FS_DCTL at 16#4# range 0 .. 31;
FS_DSTS at 16#8# range 0 .. 31;
FS_DIEPMSK at 16#10# range 0 .. 31;
FS_DOEPMSK at 16#14# range 0 .. 31;
FS_DAINT at 16#18# range 0 .. 31;
FS_DAINTMSK at 16#1C# range 0 .. 31;
DVBUSDIS at 16#28# range 0 .. 31;
DVBUSPULSE at 16#2C# range 0 .. 31;
DIEPEMPMSK at 16#34# range 0 .. 31;
FS_DIEPCTL0 at 16#100# range 0 .. 31;
DIEPINT0 at 16#108# range 0 .. 31;
DIEPTSIZ0 at 16#110# range 0 .. 31;
DTXFSTS0 at 16#118# range 0 .. 31;
DIEPCTL1 at 16#120# range 0 .. 31;
DIEPINT1 at 16#128# range 0 .. 31;
DIEPTSIZ1 at 16#130# range 0 .. 31;
DTXFSTS1 at 16#138# range 0 .. 31;
DIEPCTL2 at 16#140# range 0 .. 31;
DIEPINT2 at 16#148# range 0 .. 31;
DIEPTSIZ2 at 16#150# range 0 .. 31;
DTXFSTS2 at 16#158# range 0 .. 31;
DIEPCTL3 at 16#160# range 0 .. 31;
DIEPINT3 at 16#168# range 0 .. 31;
DIEPTSIZ3 at 16#170# range 0 .. 31;
DTXFSTS3 at 16#178# range 0 .. 31;
DOEPCTL0 at 16#300# range 0 .. 31;
DOEPINT0 at 16#308# range 0 .. 31;
DOEPTSIZ0 at 16#310# range 0 .. 31;
DOEPCTL1 at 16#320# range 0 .. 31;
DOEPINT1 at 16#328# range 0 .. 31;
DOEPTSIZ1 at 16#330# range 0 .. 31;
DOEPCTL2 at 16#340# range 0 .. 31;
DOEPINT2 at 16#348# range 0 .. 31;
DOEPTSIZ2 at 16#350# range 0 .. 31;
DOEPCTL3 at 16#360# range 0 .. 31;
DOEPINT3 at 16#368# range 0 .. 31;
DOEPTSIZ3 at 16#370# range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_DEVICE_Periph : aliased OTG_FS_DEVICE_Peripheral
with Import, Address => System'To_Address (16#50000800#);
type OTG_FS_GLOBAL_Disc is
(
Device,
Host);
-- USB on the go full speed
type OTG_FS_GLOBAL_Peripheral
(Discriminent : OTG_FS_GLOBAL_Disc := Device)
is record
-- OTG_FS control and status register (OTG_FS_GOTGCTL)
FS_GOTGCTL : aliased FS_GOTGCTL_Register;
-- OTG_FS interrupt register (OTG_FS_GOTGINT)
FS_GOTGINT : aliased FS_GOTGINT_Register;
-- OTG_FS AHB configuration register (OTG_FS_GAHBCFG)
FS_GAHBCFG : aliased FS_GAHBCFG_Register;
-- OTG_FS USB configuration register (OTG_FS_GUSBCFG)
FS_GUSBCFG : aliased FS_GUSBCFG_Register;
-- OTG_FS reset register (OTG_FS_GRSTCTL)
FS_GRSTCTL : aliased FS_GRSTCTL_Register;
-- OTG_FS core interrupt register (OTG_FS_GINTSTS)
FS_GINTSTS : aliased FS_GINTSTS_Register;
-- OTG_FS interrupt mask register (OTG_FS_GINTMSK)
FS_GINTMSK : aliased FS_GINTMSK_Register;
-- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ)
FS_GRXFSIZ : aliased FS_GRXFSIZ_Register;
-- OTG_FS non-periodic transmit FIFO/queue status register
-- (OTG_FS_GNPTXSTS)
FS_GNPTXSTS : aliased FS_GNPTXSTS_Register;
-- OTG_FS general core configuration register (OTG_FS_GCCFG)
FS_GCCFG : aliased FS_GCCFG_Register;
-- core ID register
FS_CID : aliased STM32_SVD.UInt32;
-- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ)
FS_HPTXFSIZ : aliased FS_HPTXFSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO size register
-- (OTG_FS_DIEPTXF2)
FS_DIEPTXF1 : aliased FS_DIEPTXF_Register;
-- OTG_FS device IN endpoint transmit FIFO size register
-- (OTG_FS_DIEPTXF3)
FS_DIEPTXF2 : aliased FS_DIEPTXF_Register;
-- OTG_FS device IN endpoint transmit FIFO size register
-- (OTG_FS_DIEPTXF4)
FS_DIEPTXF3 : aliased FS_DIEPTXF_Register;
case Discriminent is
when Device =>
-- OTG_FS Receive status debug read(Device mode)
FS_GRXSTSR_Device : aliased FS_GRXSTSR_Device_Register;
-- OTG_FS non-periodic transmit FIFO size register (Device mode)
FS_GNPTXFSIZ_Device : aliased FS_GNPTXFSIZ_Device_Register;
when Host =>
-- OTG_FS Receive status debug read(Host mode)
FS_GRXSTSR_Host : aliased FS_GRXSTSR_Host_Register;
-- OTG_FS non-periodic transmit FIFO size register (Host mode)
FS_GNPTXFSIZ_Host : aliased FS_GNPTXFSIZ_Host_Register;
end case;
end record
with Unchecked_Union, Volatile;
for OTG_FS_GLOBAL_Peripheral use record
FS_GOTGCTL at 16#0# range 0 .. 31;
FS_GOTGINT at 16#4# range 0 .. 31;
FS_GAHBCFG at 16#8# range 0 .. 31;
FS_GUSBCFG at 16#C# range 0 .. 31;
FS_GRSTCTL at 16#10# range 0 .. 31;
FS_GINTSTS at 16#14# range 0 .. 31;
FS_GINTMSK at 16#18# range 0 .. 31;
FS_GRXFSIZ at 16#24# range 0 .. 31;
FS_GNPTXSTS at 16#2C# range 0 .. 31;
FS_GCCFG at 16#38# range 0 .. 31;
FS_CID at 16#3C# range 0 .. 31;
FS_HPTXFSIZ at 16#100# range 0 .. 31;
FS_DIEPTXF1 at 16#104# range 0 .. 31;
FS_DIEPTXF2 at 16#108# range 0 .. 31;
FS_DIEPTXF3 at 16#10C# range 0 .. 31;
FS_GRXSTSR_Device at 16#1C# range 0 .. 31;
FS_GNPTXFSIZ_Device at 16#28# range 0 .. 31;
FS_GRXSTSR_Host at 16#1C# range 0 .. 31;
FS_GNPTXFSIZ_Host at 16#28# range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_GLOBAL_Periph : aliased OTG_FS_GLOBAL_Peripheral
with Import, Address => System'To_Address (16#50000000#);
-- USB on the go full speed
type OTG_FS_HOST_Peripheral is record
-- OTG_FS host configuration register (OTG_FS_HCFG)
FS_HCFG : aliased FS_HCFG_Register;
-- OTG_FS Host frame interval register
HFIR : aliased HFIR_Register;
-- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM)
FS_HFNUM : aliased FS_HFNUM_Register;
-- OTG_FS_Host periodic transmit FIFO/queue status register
-- (OTG_FS_HPTXSTS)
FS_HPTXSTS : aliased FS_HPTXSTS_Register;
-- OTG_FS Host all channels interrupt register
HAINT : aliased HAINT_Register;
-- OTG_FS host all channels interrupt mask register
HAINTMSK : aliased HAINTMSK_Register;
-- OTG_FS host port control and status register (OTG_FS_HPRT)
FS_HPRT : aliased FS_HPRT_Register;
-- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0)
FS_HCCHAR0 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0)
FS_HCINT0 : aliased FS_HCINT_Register;
-- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0)
FS_HCINTMSK0 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-0 transfer size register
FS_HCTSIZ0 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-1 characteristics register (OTG_FS_HCCHAR1)
FS_HCCHAR1 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-1 interrupt register (OTG_FS_HCINT1)
FS_HCINT1 : aliased FS_HCINT_Register;
-- OTG_FS host channel-1 mask register (OTG_FS_HCINTMSK1)
FS_HCINTMSK1 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-1 transfer size register
FS_HCTSIZ1 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-2 characteristics register (OTG_FS_HCCHAR2)
FS_HCCHAR2 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-2 interrupt register (OTG_FS_HCINT2)
FS_HCINT2 : aliased FS_HCINT_Register;
-- OTG_FS host channel-2 mask register (OTG_FS_HCINTMSK2)
FS_HCINTMSK2 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-2 transfer size register
FS_HCTSIZ2 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-3 characteristics register (OTG_FS_HCCHAR3)
FS_HCCHAR3 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-3 interrupt register (OTG_FS_HCINT3)
FS_HCINT3 : aliased FS_HCINT_Register;
-- OTG_FS host channel-3 mask register (OTG_FS_HCINTMSK3)
FS_HCINTMSK3 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-3 transfer size register
FS_HCTSIZ3 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-4 characteristics register (OTG_FS_HCCHAR4)
FS_HCCHAR4 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-4 interrupt register (OTG_FS_HCINT4)
FS_HCINT4 : aliased FS_HCINT_Register;
-- OTG_FS host channel-4 mask register (OTG_FS_HCINTMSK4)
FS_HCINTMSK4 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-x transfer size register
FS_HCTSIZ4 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-5 characteristics register (OTG_FS_HCCHAR5)
FS_HCCHAR5 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-5 interrupt register (OTG_FS_HCINT5)
FS_HCINT5 : aliased FS_HCINT_Register;
-- OTG_FS host channel-5 mask register (OTG_FS_HCINTMSK5)
FS_HCINTMSK5 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-5 transfer size register
FS_HCTSIZ5 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-6 characteristics register (OTG_FS_HCCHAR6)
FS_HCCHAR6 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-6 interrupt register (OTG_FS_HCINT6)
FS_HCINT6 : aliased FS_HCINT_Register;
-- OTG_FS host channel-6 mask register (OTG_FS_HCINTMSK6)
FS_HCINTMSK6 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-6 transfer size register
FS_HCTSIZ6 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-7 characteristics register (OTG_FS_HCCHAR7)
FS_HCCHAR7 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-7 interrupt register (OTG_FS_HCINT7)
FS_HCINT7 : aliased FS_HCINT_Register;
-- OTG_FS host channel-7 mask register (OTG_FS_HCINTMSK7)
FS_HCINTMSK7 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-7 transfer size register
FS_HCTSIZ7 : aliased FS_HCTSIZ_Register;
end record
with Volatile;
for OTG_FS_HOST_Peripheral use record
FS_HCFG at 16#0# range 0 .. 31;
HFIR at 16#4# range 0 .. 31;
FS_HFNUM at 16#8# range 0 .. 31;
FS_HPTXSTS at 16#10# range 0 .. 31;
HAINT at 16#14# range 0 .. 31;
HAINTMSK at 16#18# range 0 .. 31;
FS_HPRT at 16#40# range 0 .. 31;
FS_HCCHAR0 at 16#100# range 0 .. 31;
FS_HCINT0 at 16#108# range 0 .. 31;
FS_HCINTMSK0 at 16#10C# range 0 .. 31;
FS_HCTSIZ0 at 16#110# range 0 .. 31;
FS_HCCHAR1 at 16#120# range 0 .. 31;
FS_HCINT1 at 16#128# range 0 .. 31;
FS_HCINTMSK1 at 16#12C# range 0 .. 31;
FS_HCTSIZ1 at 16#130# range 0 .. 31;
FS_HCCHAR2 at 16#140# range 0 .. 31;
FS_HCINT2 at 16#148# range 0 .. 31;
FS_HCINTMSK2 at 16#14C# range 0 .. 31;
FS_HCTSIZ2 at 16#150# range 0 .. 31;
FS_HCCHAR3 at 16#160# range 0 .. 31;
FS_HCINT3 at 16#168# range 0 .. 31;
FS_HCINTMSK3 at 16#16C# range 0 .. 31;
FS_HCTSIZ3 at 16#170# range 0 .. 31;
FS_HCCHAR4 at 16#180# range 0 .. 31;
FS_HCINT4 at 16#188# range 0 .. 31;
FS_HCINTMSK4 at 16#18C# range 0 .. 31;
FS_HCTSIZ4 at 16#190# range 0 .. 31;
FS_HCCHAR5 at 16#1A0# range 0 .. 31;
FS_HCINT5 at 16#1A8# range 0 .. 31;
FS_HCINTMSK5 at 16#1AC# range 0 .. 31;
FS_HCTSIZ5 at 16#1B0# range 0 .. 31;
FS_HCCHAR6 at 16#1C0# range 0 .. 31;
FS_HCINT6 at 16#1C8# range 0 .. 31;
FS_HCINTMSK6 at 16#1CC# range 0 .. 31;
FS_HCTSIZ6 at 16#1D0# range 0 .. 31;
FS_HCCHAR7 at 16#1E0# range 0 .. 31;
FS_HCINT7 at 16#1E8# range 0 .. 31;
FS_HCINTMSK7 at 16#1EC# range 0 .. 31;
FS_HCTSIZ7 at 16#1F0# range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_HOST_Periph : aliased OTG_FS_HOST_Peripheral
with Import, Address => System'To_Address (16#50000400#);
-- USB on the go full speed
type OTG_FS_PWRCLK_Peripheral is record
-- OTG_FS power and clock gating control register
FS_PCGCCTL : aliased FS_PCGCCTL_Register;
end record
with Volatile;
for OTG_FS_PWRCLK_Peripheral use record
FS_PCGCCTL at 0 range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_PWRCLK_Periph : aliased OTG_FS_PWRCLK_Peripheral
with Import, Address => System'To_Address (16#50000E00#);
end STM32_SVD.USB_OTG_FS;
|
-- $Id: Position.mi,v 1.4 1994/08/15 22:13:23 grosch rel $
-- $Log: Position.mi,v $
-- Ich, Doktor Josef Grosch, Informatiker, Aug. 1994
with Text_Io; use Text_Io;
package body Position is
package Int_Io is new Integer_IO (Integer); use Int_Io;
function Compare (Position1, Position2: tPosition) return Integer is
begin
if Position1.Line < Position2.Line then return -1; end if;
if Position1.Line > Position2.Line then return 1; end if;
if Position1.Column < Position2.Column then return -1; end if;
if Position1.Column > Position2.Column then return 1; end if;
return 0;
end Compare;
procedure WritePosition (File: File_Type; Position: tPosition) is
begin
if Compare (Position, NoPosition) = 0 then
Set_Col (File, Col (File) + 8);
else
Put (File, Position.Line , 4);
Put (File, ',');
Put (File, Position.Column, 3);
end if;
end WritePosition;
procedure ReadPosition (File: File_Type; Position: out tPosition) is
c : Character;
begin
Get (File, Position.Line);
Get (File, c);
Get (File, Position.Column);
end ReadPosition;
end Position;
|
-----------------------------------------------------------------------
-- helios-reports-remote -- Send reports to a remote server using REST API
-- 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 Util.Serialize.IO.JSON;
with Util.Streams.Texts;
with Util.Http.Clients;
with Util.Log.Loggers;
with Util.Strings;
with Util.Beans.Objects;
with Helios.Monitor;
package body Helios.Reports.Remote is
use Ada.Strings.Unbounded;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Helios.Reports.Remote");
task body Report_Task_Type is
R : Remote_Report_Access;
Data : Helios.Datas.Report_Queue_Type;
begin
select
accept Start (Report : in Remote_Report_Access) do
R := Report;
end Start;
end select;
loop
R.Queue.Dequeue (Data);
R.Send (Data);
end loop;
end Report_Task_Type;
procedure Start (Report : in Remote_Report_Access) is
begin
Log.Info ("Starting remote report task");
Report.Reporter := new Report_Task_Type;
Report.Reporter.Start (Report);
end Start;
-- ------------------------------
-- The timer handler executed when the timer deadline has passed.
-- ------------------------------
overriding
procedure Time_Handler (Report : in out Remote_Report_Type;
Event : in out Util.Events.Timers.Timer_Ref'Class) is
use type Ada.Real_Time.Time_Span;
begin
Report.Queue.Enqueue (Helios.Monitor.Get_Report);
if Report.Period /= Ada.Real_Time.Time_Span_Zero then
Event.Repeat (Report.Period);
end if;
end Time_Handler;
-- Set the remote report configuration to connect to the server.
procedure Set_Server_Config (Report : in out Remote_Report_Type;
Config : in Util.Properties.Manager) is
Value : Util.Beans.Objects.Object;
URI : Ada.Strings.Unbounded.Unbounded_String;
begin
Value := Config.Get_Value ("host_id");
if Util.Beans.Objects.Is_Null (Value) then
return;
end if;
Report.Host_Id := Util.Beans.Objects.To_Integer (Value);
Report.Host_Key := Config.Get ("host_key");
Report.Username := Config.Get ("username");
Report.Password := Config.Get ("password");
Report.Scope := To_Unbounded_String ("write:snapshot");
URI := Config.Get ("server_url");
Report.URI := URI;
Append (Report.URI, "/hosts/");
Append (Report.URI, Util.Strings.Image (Report.Host_Id));
Append (Report.URI, "/snapshot");
-- Step 1: get an OAuth access token.
Report.Cred.Set_Application_Identifier (Config.Get ("client_id"));
Report.Cred.Set_Application_Secret (Config.get ("client_secret"));
Report.Cred.Set_Provider_URI (Config.Get ("server_oauth_url"));
Report.Cred.Request_Token (To_String (Report.Username),
To_String (Report.Password),
To_String (Report.Scope));
end Set_Server_Config;
-- ------------------------------
-- Send a snapshot report to the server.
-- ------------------------------
procedure Send (Report : in out Remote_Report_Type;
Data : in Helios.Datas.Report_Queue_Type) is
Output : aliased Util.Streams.Texts.Print_Stream;
Stream : Util.Serialize.IO.JSON.Output_Stream;
Response : Util.Http.Clients.Response;
Http : Util.Http.Clients.Client;
URI : constant String := To_String (Report.URI);
procedure Write (Data : in Helios.Datas.Snapshot_Type;
Node : in Helios.Schemas.Definition_Type_Access) is
begin
Write_Snapshot (Stream, Data, Node);
end Write;
begin
Output.Initialize (Size => 1_000_000);
Stream.Initialize (Output'Unchecked_Access);
Stream.Start_Document;
Stream.Start_Entity ("");
Stream.Write_Entity ("host_key", Report.Host_Key);
Stream.Start_Entity ("snapshot");
Helios.Datas.Iterate (Data, Write'Access);
Stream.End_Entity ("snapshot");
Stream.End_Entity ("");
Stream.End_Document;
Stream.Close;
Http.Add_Header ("X-Requested-By", "helios");
Http.Add_Header ("Content-Type", "application/json");
Http.Add_Header ("Accept", "application/json");
for Retry in 1 .. 5 loop
Report.Cred.Set_Credentials (Http);
Log.Info ("Sending report to {0}", URI);
Http.Post (URI, Util.Streams.Texts.To_String (Output), Response);
exit when Response.Get_Status = 200;
if Response.Get_Status = 401 then
Report.Cred.Request_Token (To_String (Report.Username),
To_String (Report.Password),
To_String (Report.Scope));
end if;
if Response.Get_Status /= 200 then
Log.Error ("Sending snapshot failed");
end if;
end loop;
exception
when E : others =>
Log.Error ("Error when sending report", E);
end Send;
end Helios.Reports.Remote;
|
-- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Calendar is
type Time is private;
subtype Year_Number is Integer range 1901 .. 2399;
subtype Month_Number is Integer range 1 .. 12;
subtype Day_Number is Integer range 1 .. 31;
subtype Day_Duration is Duration range 0.0 .. 86_400.0;
function Clock return Time;
function Year (Date : Time) return Year_Number;
function Month (Date : Time) return Month_Number;
function Day (Date : Time) return Day_Number;
function Seconds(Date : Time) return Day_Duration;
procedure Split (Date : in Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Seconds : out Day_Duration);
function Time_Of(Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration := 0.0)
return Time;
function "+" (Left : Time; Right : Duration) return Time;
function "+" (Left : Duration; Right : Time) return Time;
function "-" (Left : Time; Right : Duration) return Time;
function "-" (Left : Time; Right : Time) return Duration;
function "<" (Left, Right : Time) return Boolean;
function "<="(Left, Right : Time) return Boolean;
function ">" (Left, Right : Time) return Boolean;
function ">="(Left, Right : Time) return Boolean;
Time_Error : exception;
private
pragma Import (Ada, Time);
end Ada.Calendar;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C;
private package Glfw.Enums is
type Window_Info is
(Focused, Iconified, Resizable, Visible, Decorated, Auto_Iconify, Floating,
Maximized, Center_Cursor, Transparent_Framebuffer, Hovered, Focus_On_Show,
Red_Bits, Green_Bits, Blue_Bits, Alpha_Bits, Depth_Bits, Stencil_Bits,
Accum_Red_Bits, Accum_Green_Bits, Accum_Blue_Bits, Accum_Alpha_Bits,
Aux_Buffers, Stereo, Samples, SRGB_Capable, Refresh_Rate, Doublebuffer,
Client_API, Context_Version_Major, Context_Version_Minor,
Context_Revision, Context_Robustness, OpenGL_Forward_Compat,
OpenGL_Debug_Context, OpenGL_Profile, Scale_To_Monitor);
for Window_Info use (Focused => 16#20001#,
Iconified => 16#20002#,
Resizable => 16#20003#,
Visible => 16#20004#,
Decorated => 16#20005#,
Auto_Iconify => 16#20006#,
Floating => 16#20007#,
Maximized => 16#20008#,
Center_Cursor => 16#20009#,
Transparent_Framebuffer => 16#2000A#,
Hovered => 16#2000B#,
Focus_On_Show => 16#2000C#,
Red_Bits => 16#21001#,
Green_Bits => 16#21002#,
Blue_Bits => 16#21003#,
Alpha_Bits => 16#21004#,
Depth_Bits => 16#21005#,
Stencil_Bits => 16#21006#,
Accum_Red_Bits => 16#21007#,
Accum_Green_Bits => 16#21008#,
Accum_Blue_Bits => 16#21009#,
Accum_Alpha_Bits => 16#2100A#,
Aux_Buffers => 16#2100B#,
Stereo => 16#2100C#,
Samples => 16#2100D#,
SRGB_Capable => 16#2100E#,
Refresh_Rate => 16#2100F#,
Doublebuffer => 16#21010#,
Client_API => 16#22001#,
Context_Version_Major => 16#22002#,
Context_Version_Minor => 16#22003#,
Context_Revision => 16#22004#,
Context_Robustness => 16#22005#,
OpenGL_Forward_Compat => 16#22006#,
OpenGL_Debug_Context => 16#22007#,
OpenGL_Profile => 16#22008#,
Scale_To_Monitor => 16#2200C#);
for Window_Info'Size use Interfaces.C.int'Size;
type Input_Toggle is (Mouse_Cursor);
for Input_Toggle use (Mouse_Cursor => 16#33001#);
for Input_Toggle'Size use Interfaces.C.int'Size;
type Joystick_ID is (
Joystick_1, Joystick_2, Joystick_3, Joystick_4, Joystick_5,
Joystick_6, Joystick_7, Joystick_8, Joystick_9, Joystick_10,
Joystick_11, Joystick_12, Joystick_13, Joystick_14,
Joystick_15, Joystick_16);
for Joystick_ID use (
Joystick_1 => 0, Joystick_2 => 1, Joystick_3 => 2,
Joystick_4 => 3, Joystick_5 => 4, Joystick_6 => 5,
Joystick_7 => 6, Joystick_8 => 7, Joystick_9 => 8,
Joystick_10 => 9, Joystick_11 => 10, Joystick_12 => 11,
Joystick_13 => 12, Joystick_14 => 13, Joystick_15 => 14,
Joystick_16 => 15
);
for Joystick_ID'Size use Interfaces.C.int'Size;
type Joystick_Param is (Present, Axis, Buttons);
for Joystick_Param use (Present => 16#50001#,
Axis => 16#50002#,
Buttons => 16#50003#);
for Joystick_Param'Size use C.int'Size;
end Glfw.Enums;
|
-------------------------------------------------------------------------------
-- File: adaid-generate.ads
-- Description: UUID Generation
-- Author: Anthony Arnold
-- License: Simplified BSD License (see LICENSE)
-------------------------------------------------------------------------------
-- AdaID.Generate defines the functions required to generate UUIDs using
-- different standard methods.
package AdaID.Generate is
Invalid_String : exception;
-- Thrown when invalid strings are passed to From_String
procedure Nil (id : in out UUID);
-- Set a UUID to Nil
procedure Random (id : in out UUID);
-- Generate a random UUID
procedure From_Name
(namespace : in UUID;
name : in String;
id : in out UUID);
-- Generate a UUID based on a name
procedure From_String (str : in String; id : in out UUID);
-- Generate a UUID from a string.
-- This is not so much generation, but reconstruction
end AdaID.Generate;
|
with Unicode_Strings; use Unicode_Strings;
with Ada.Task_Termination;
with Ada.Task_Identification;
with Ada.Exceptions;
package Logging is
type Verbosity_Level is (Log_Error, Log_Warning, Log_Info, Log_Chatty);
task Log is
entry Set_Verbosity
(User_Verbosity : Verbosity_Level);
entry Chat
(Text : Wide_Wide_String;
Suffix : Wide_Wide_Character := Characters.LF);
entry Info
(Text : Wide_Wide_String;
Suffix : Wide_Wide_Character := Characters.LF);
entry Warning
(Text : Wide_Wide_String;
Suffix : Wide_Wide_Character := Characters.LF);
entry Error
(Text : Wide_Wide_String;
Suffix : Wide_Wide_Character := Characters.LF);
end Log;
use Ada.Task_Termination;
use Ada.Task_Identification;
use Ada.Exceptions;
protected Logging_Termination_Handler is
procedure Log_Termination_Cause
(C : Cause_Of_Termination; T : Task_Id; X : Exception_Occurrence);
end Logging_Termination_Handler;
end Logging;
|
--
-- Copyright (C) 2017, AdaCore
--
-- This spec has been automatically generated from M2Sxxx.svd
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Interfaces.SF2.MMUART is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
-- Interupt Enable Register
type IER_Register is record
-- Enables received data available interrupt
ERBFI : Boolean := False;
-- Transmitter holding register empty interrupt enable
ETBEI : Boolean := False;
-- Receiver line status interrupt enable
ELSI : Boolean := False;
-- Modem status interrupt enable
EDSSI : Boolean := False;
-- unspecified
Reserved_4_7 : Interfaces.SF2.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for IER_Register use record
ERBFI at 0 range 0 .. 0;
ETBEI at 0 range 1 .. 1;
ELSI at 0 range 2 .. 2;
EDSSI at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
-- These bits are used to set the trigger level for the Rx FIFO interrupt.
-- Rx FIFO trigger level (bytes) are: 0b00: 1 byte 0b01: 4 bytes 0b10: 8
-- bytes 0b11: 14 bytes
type FCR_RX_TRIG_Field is
(
Fifo_1_Byte,
Fifo_4_Bytes,
Fifo_8_Bytes,
Fifo_14_Bytes)
with Size => 2;
for FCR_RX_TRIG_Field use
(Fifo_1_Byte => 0,
Fifo_4_Bytes => 1,
Fifo_8_Bytes => 2,
Fifo_14_Bytes => 3);
-- FIFO control register
type FCR_Register is record
-- Write-only. It enables both the Tx and Rx FIFOs and is hardwired to
-- 1, which means it is always enabled and cannot be changed.
ENABLE_TX_RX_FIFO : Boolean := False;
-- Write-only. Clears all bytes in Rx FIFO and resets counter logic.
-- This shift register is not cleared. 0: Disabled (default) 1: Enabled
CLEAR_RX_FIFO : Boolean := False;
-- Write-only. Clears all bytes in the Tx FIFO and resets its counter
-- logic. The shift register is not cleared. 0: Disabled (default) 1:
-- Enabled
CLEAR_TX_FIFO : Boolean := False;
-- Write-only. Software must always set this bit to 1 for efficient data
-- transfer from transmit FIFO to PDMA.
ENABLE_TXRDY_RXRDY : Boolean := False;
-- unspecified
Reserved_4_5 : Interfaces.SF2.UInt2 := 16#0#;
-- Write-only. These bits are used to set the trigger level for the Rx
-- FIFO interrupt. Rx FIFO trigger level (bytes) are: 0b00: 1 byte 0b01:
-- 4 bytes 0b10: 8 bytes 0b11: 14 bytes
RX_TRIG : FCR_RX_TRIG_Field :=
Interfaces.SF2.MMUART.Fifo_1_Byte;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for FCR_Register use record
ENABLE_TX_RX_FIFO at 0 range 0 .. 0;
CLEAR_RX_FIFO at 0 range 1 .. 1;
CLEAR_TX_FIFO at 0 range 2 .. 2;
ENABLE_TXRDY_RXRDY at 0 range 3 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
RX_TRIG at 0 range 6 .. 7;
end record;
-- Interrupt identification bits.
type IIR_IIR_Field is
(
-- Fourth priority. Modem status interrupt due to clear to send, data
-- set ready, ring indicator, or data carrier detect being asserted.
-- Reading the modem status register resets this interrupt.
Modem_Status,
-- Third priority. Transmit holding register empty interrupt. Reading
-- the IIR or writing to the transmit holding register (THR) resets the
-- interrupt.
Transmitter_Holding_Register_Empty,
-- Fifth priority. Multi-mode interrupts can occur due to any of the
-- interrupts mentioned in IIM. For more details refer to Table 12-15.
Multi_Mode_Interrupt,
-- Second priority. Receive data available interrupt modem status
-- interrupt. Reading the receiver buffer register (RBR) or the FIFO
-- drops below the trigger level resets this interrupt.
Receiver_Data_Available,
-- Highest priority. Receiver line status interrupts due to overrun
-- error, parity error, framing error, or break interrupt. Reading the
-- line status register resets this interrupt.
Receiver_Line_Status,
-- Second priority. Character timeout indication interrupt occurs when
-- no characters have been read from the Rx FIFO during the last four
-- character times and there was at least one character in it during
-- this time. Reading the RBR resets this interrupt.
Character_Timeout_Indication)
with Size => 4;
for IIR_IIR_Field use
(Modem_Status => 0,
Transmitter_Holding_Register_Empty => 2,
Multi_Mode_Interrupt => 3,
Receiver_Data_Available => 4,
Receiver_Line_Status => 6,
Character_Timeout_Indication => 12);
subtype IIR_Mode_Field is Interfaces.SF2.UInt2;
-- Interrupt identification register
type IIR_Register is record
-- Read-only. Interrupt identification bits.
IIR : IIR_IIR_Field;
-- unspecified
Reserved_4_5 : Interfaces.SF2.UInt2;
-- Read-only. Always 0b11. Enables FIFO mode.
Mode : IIR_Mode_Field;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for IIR_Register use record
IIR at 0 range 0 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
Mode at 0 range 6 .. 7;
end record;
-- Word length select
type LCR_WLS_Field is
(
Length_5_Bits,
Length_6_Bits,
Length_7_Bits,
Length_8_Bits)
with Size => 2;
for LCR_WLS_Field use
(Length_5_Bits => 0,
Length_6_Bits => 1,
Length_7_Bits => 2,
Length_8_Bits => 3);
-- Number of stop bits (STB)
type LCR_STB_Field is
(
-- 1 stop bit
Stop_Bit_1,
-- 1 1/2 stop bits when WLS=00. The number of stop bits is 2 for all
-- other cases not described above (STB=1 and WLS=01, 10, or 11).
Stop_Bit_1_AND_HALF)
with Size => 1;
for LCR_STB_Field use
(Stop_Bit_1 => 0,
Stop_Bit_1_AND_HALF => 1);
-- Even parity select
type LCR_EPS_Field is
(
-- Odd parity
Odd,
-- Even parity
Even)
with Size => 1;
for LCR_EPS_Field use
(Odd => 0,
Even => 1);
-- Line Control register
type LCR_Register is record
-- Word length select
WLS : LCR_WLS_Field := Interfaces.SF2.MMUART.Length_5_Bits;
-- Number of stop bits (STB)
STB : LCR_STB_Field := Interfaces.SF2.MMUART.Stop_Bit_1;
-- Parity enable
PEN : Boolean := False;
-- Even parity select
EPS : LCR_EPS_Field := Interfaces.SF2.MMUART.Odd;
-- Stick parity. When stick parity is enabled, the parity is set
-- according to bits [4:3] as follows: 11: 0 will be sent as a parity
-- bit and checked when receiving. 01: 1 will be sent as a parity bit
-- and checked when receiving.
SP : Boolean := False;
-- Set break. Enabling this bit sets MMUART_x_TXD to 0. This does not
-- have any effect on transmitter logic.
SB : Boolean := False;
-- Divisor latch access bit. Enables access to the divisor latch
-- registers during read or write operation to address 0 and 1.
DLAB : Boolean := False;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for LCR_Register use record
WLS at 0 range 0 .. 1;
STB at 0 range 2 .. 2;
PEN at 0 range 3 .. 3;
EPS at 0 range 4 .. 4;
SP at 0 range 5 .. 5;
SB at 0 range 6 .. 6;
DLAB at 0 range 7 .. 7;
end record;
-- Data terminal ready (MMUART_x_DTR) output. Active Low
type MCR_DTR_Field is
(
Set_1,
Set_0)
with Size => 1;
for MCR_DTR_Field use
(Set_1 => 0,
Set_0 => 1);
-- Controls the request to send (MMUART_x_RTS) signal. Active Low
type MCR_RTS_Field is
(
Set_1,
Set_0)
with Size => 1;
for MCR_RTS_Field use
(Set_1 => 0,
Set_0 => 1);
-- Controls the output1 (OUT1) signal. Active Low
type MCR_OUT_1_Field is
(
Set_1,
Set_0)
with Size => 1;
for MCR_OUT_1_Field use
(Set_1 => 0,
Set_0 => 1);
-- Controls the output2 (OUT2) signal. Active Low
type MCR_OUT_2_Field is
(
Set_1,
Set_0)
with Size => 1;
for MCR_OUT_2_Field use
(Set_1 => 0,
Set_0 => 1);
-- Remote loopback enable bits. In the Remote loopback mode, when a bit is
-- received, it is sent directly out the transmit line, bypassing the
-- transmitter block, and disabling the receiver. In the Automatic echo
-- mode, when a bit is received, it is sent directly out the transmit line,
-- bypassing the transmitter block, while the receiver is still enabled.
type MCR_RLoop_Field is
(
Disabled,
-- Remote loopback enabled
Enabled,
-- Automatic echo enabled
Echo)
with Size => 2;
for MCR_RLoop_Field use
(Disabled => 0,
Enabled => 1,
Echo => 2);
-- Modem Control register
type MCR_Register is record
-- Data terminal ready (MMUART_x_DTR) output. Active Low
DTR : MCR_DTR_Field := Interfaces.SF2.MMUART.Set_1;
-- Controls the request to send (MMUART_x_RTS) signal. Active Low
RTS : MCR_RTS_Field := Interfaces.SF2.MMUART.Set_1;
-- Controls the output1 (OUT1) signal. Active Low
OUT_1 : MCR_OUT_1_Field := Interfaces.SF2.MMUART.Set_1;
-- Controls the output2 (OUT2) signal. Active Low
OUT_2 : MCR_OUT_2_Field := Interfaces.SF2.MMUART.Set_1;
-- In the Loopback mode, MMUART_x_TXD is set to 1. The MMUART_x_RXD,
-- MMUART_x_DSR, MMUART_x_CTS, MMUART_x_RI, and MMUART_x_DCD inputs are
-- disconnected. The output of the transmitter shift register is looped
-- back into the receiver shift register. The modem control outputs
-- (MMUART_x_DTR, MMUART_x_RTS, MMUART_x_OUT1, and MMUART_x_OUT2) are
-- connected internally to the modem control inputs, and the modem
-- control output pins are set as 1. The transmitted data is immediately
-- received, allowing Cortex-M3 processor to check the operation of the
-- MMUART_x. The interrupts are operating in the Loopback mode.
Loopback : Boolean := False;
-- Remote loopback enable bits. In the Remote loopback mode, when a bit
-- is received, it is sent directly out the transmit line, bypassing the
-- transmitter block, and disabling the receiver. In the Automatic echo
-- mode, when a bit is received, it is sent directly out the transmit
-- line, bypassing the transmitter block, while the receiver is still
-- enabled.
RLoop : MCR_RLoop_Field := Interfaces.SF2.MMUART.Disabled;
-- unspecified
Reserved_7_7 : Interfaces.SF2.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for MCR_Register use record
DTR at 0 range 0 .. 0;
RTS at 0 range 1 .. 1;
OUT_1 at 0 range 2 .. 2;
OUT_2 at 0 range 3 .. 3;
Loopback at 0 range 4 .. 4;
RLoop at 0 range 5 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
-- Line Status register
type LSR_Register is record
-- Read-only. Data ready (DR). Indicates when a data byte is received
-- and stored in the receive buffer or the FIFO. DR is cleared to 0 when
-- the Cortex-M3 processor reads the data from the receive buffer or the
-- FIFO.
DR : Boolean;
-- Read-only. Overrun error (OE). Indicates that the new byte was
-- received before the Cortex-M3 processor reads the byte from the
-- receive buffer, and that the earlier data byte was destroyed. OE is
-- cleared when the Cortex-M3 processor reads the LSR. If the data
-- continues to fill the FIFO beyond the trigger level, an overrun error
-- occurs once the FIFO is full and the next character has been
-- completely received in the shift register. The character in the shift
-- register is overwritten, but it is not transferred to the FIFO.
OE : Boolean;
-- Read-only. Parity error (PE). Indicates that the receive byte had a
-- parity error. PE is cleared when the Cortex-M3 processor reads the
-- LSR. This error is revealed to the Cortex-M3 processor when it is
-- associated character is at the top of the FIFO.
PE : Boolean;
-- Read-only. Framing error (FE). Indicates that the receive byte did
-- not have a valid stop bit. FE is cleared when Cortex-M3 processor
-- reads the LSR. The MMUART_x tries to resynchronize after a framing
-- error. To do this, it assumes that the framing error was due to the
-- next start bit, so it samples this start bit twice, and then starts
-- receiving the data. This error is revealed to Cortex-M3 processor
-- when it is associated character is at the top of the FIFO.
FE : Boolean;
-- Read-only. Break interrupt (BI). Indicates that the receive data is
-- at 0 longer than a full word transmission time (start bit + data bits
-- + parity + stop bits). BI is cleared when Cortex-M3 processor reads
-- the line status register (LSR). This error is revealed to the
-- Cortex-M3 processor when it is associated character is at the top of
-- the FIFO. When break occurs, only one zero character is loaded into
-- the FIFO.
BI : Boolean;
-- Read-only. Transmitter holding register empty (THRE). Indicates that
-- the MMUART_x is ready to transmit a new data byte. THRE causes an
-- interrupt to the Cortex-M3 processor when bit 1 (ETBEI) in the
-- interrupt enable register is 1. This bit is set when the Tx FIFO is
-- empty. It is cleared when at least one byte is written to the Tx
-- FIFO.
THRE : Boolean;
-- Read-only. Transmit empty (TEMT). This bit is set to 1 when both the
-- transmitter FIFO and shift registers are empty.
TEMT : Boolean;
-- Read-only. This bit is set when there is at least one parity error,
-- framing error, or break indication in the FIFO. FIER is cleared when
-- Cortex-M3 processor reads the LSR, if there are no subsequent errors
-- in the FIFO.
FIER : Boolean;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for LSR_Register use record
DR at 0 range 0 .. 0;
OE at 0 range 1 .. 1;
PE at 0 range 2 .. 2;
FE at 0 range 3 .. 3;
BI at 0 range 4 .. 4;
THRE at 0 range 5 .. 5;
TEMT at 0 range 6 .. 6;
FIER at 0 range 7 .. 7;
end record;
-- Modem Status register
type MSR_Register is record
-- Read-only. Delta clear to send (DCTS) indicator. Indicates that the
-- CTSn input has changed state since the last time it was read by the
-- Cortex-M3 processor. Whenever bit 0, 1, 2, or 3 is set to 1, a modem
-- status interrupt is generated.
DCTS : Boolean;
-- Read-only. Delta data set ready (DDSR) indicator. Indicates that the
-- DSRn input has changed state since the last time it was read by the
-- Cortex-M3 processor. Whenever bit 0, 1, 2, or 3 is set to 1, a modem
-- status interrupt is generated.
DDSR : Boolean;
-- Read-only. Trailing edge of ring indicator (TERI) detector. Indicates
-- that RI input has changed from 0 to 1. Whenever bit 0, 1, 2, or 3 is
-- set to 1, a modem status interrupt is generated.
TERI : Boolean;
-- Read-only. Delta data carrier detect (DDCD) indicator. Indicates that
-- DCD input has changed state. Whenever bit 0, 1, 2, or 3 is set to 1,
-- a modem status interrupt is generated.
DDCD : Boolean;
-- Read-only. Clear to send (CTS) (MMUART_x_CTS). The complement of the
-- CTS input. When bit 4 of the MCR is set to 1 (loop), this bit is
-- equivalent to DTR in the MCR.
CTS : Boolean;
-- Read-only. Data set ready (DSR) (MMUART_x_DSR). The complement of the
-- DSR input. When bit 4 of the MCR is set to 1 (loop), this bit is
-- equivalent to RTS in the MCR.
DSR : Boolean;
-- Read-only. Ring indicator (RI) (MMUART_x_RI). The complement of the
-- RI input. When bit 4 of the MCR is set to 1 (loop), this bit is
-- equivalent to OUT1 in the MCR.
RI : Boolean;
-- Read-only. Data carrier detect (DCD) (MMUART_x_DCD).The complement of
-- DCD input. When bit 4 of the MCR is set to 1 (loop), this bit is
-- equivalent to OUT2 in the MCR.
DCD : Boolean;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for MSR_Register use record
DCTS at 0 range 0 .. 0;
DDSR at 0 range 1 .. 1;
TERI at 0 range 2 .. 2;
DDCD at 0 range 3 .. 3;
CTS at 0 range 4 .. 4;
DSR at 0 range 5 .. 5;
RI at 0 range 6 .. 6;
DCD at 0 range 7 .. 7;
end record;
-- Multi-mode interrupt enable register
type IEM_Register is record
-- Enables receiver timeout interrupt
ERTOI : Boolean := False;
-- Enables NACK interrupt
ENACKI : Boolean := False;
-- Enables PID parity error interrupt
EPID_PEI : Boolean := False;
-- Enables LIN break interrupt
ELINBI : Boolean := False;
-- Enables the LIN sync detection interrupt
ELINSI : Boolean := False;
-- unspecified
Reserved_5_7 : Interfaces.SF2.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for IEM_Register use record
ERTOI at 0 range 0 .. 0;
ENACKI at 0 range 1 .. 1;
EPID_PEI at 0 range 2 .. 2;
ELINBI at 0 range 3 .. 3;
ELINSI at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- Multi-mode Interrupt identification register
type IIM_Register is record
-- Receiver time-out (RTO) interrupt ID. RTO interrupt is asserted when
-- RTO value is reached by the counter. It gets cleared when writing to
-- the RTO register.
RTOII : Boolean := False;
-- NACK interrupt is asserted when EERR bit is set in MM2. Reading the
-- MM2 clears the interrupt.
NACKI : Boolean := False;
-- Protected identifier field (PID) parity error interrupt is generated
-- when there is a mismatch in PID in LIN header, that is, when either
-- the P0 or P1 bits in the incoming PID byte do not match the
-- calculated P0 and P1 error.
PID_PEI : Boolean := False;
-- LIN break interrupt, set automatically when break length of 11.5
-- Tbits is detected. Reading the IIM register clears this interrupt.
LINBI : Boolean := True;
-- LIN sync detection interrupt ID. This bit set when 5th falling edge
-- is detected by the sync timer. It resets the FIFO address pointers so
-- that the PID will be in the first location. Reading the IIM register
-- clears this interrupt.
LINSI : Boolean := False;
-- unspecified
Reserved_5_7 : Interfaces.SF2.UInt3 := 16#1#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for IIM_Register use record
RTOII at 0 range 0 .. 0;
NACKI at 0 range 1 .. 1;
PID_PEI at 0 range 2 .. 2;
LINBI at 0 range 3 .. 3;
LINSI at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- Enable synchronous operation. There are four types of Synchronous
-- Operation modes that can be enabled.
type MM0_ESYN_Field is
(
-- Disabled, that is, Asynchronous mode
Disabled,
-- Synchronous slave enabled, positive-edge clock
Slave_Positive_Edge,
-- Synchronous slave enabled, negative-edge clock
Slave_Negative_Edge,
-- Synchronous master enabled, positive-edge clock
Master_Positive_Edge,
-- Synchronous master enabled, negative-edge clock
Master_Negative_Edge)
with Size => 3;
for MM0_ESYN_Field use
(Disabled => 0,
Slave_Positive_Edge => 1,
Slave_Negative_Edge => 2,
Master_Positive_Edge => 3,
Master_Negative_Edge => 4);
-- Multi-mode control register 0
type MM0_Register is record
-- Enable synchronous operation. There are four types of Synchronous
-- Operation modes that can be enabled.
ESYN : MM0_ESYN_Field := Interfaces.SF2.MMUART.Disabled;
-- Enable LIN header detection and automatic baud rate calculation.
ELIN : Boolean := False;
-- unspecified
Reserved_4_4 : Interfaces.SF2.Bit := 16#0#;
-- Enable transmitter time guard (TTG). The time guard value is
-- determined by the TTG Register.
ETTG : Boolean := False;
-- Enable receiver timeout (RTO). Writing this bit enables the timeout
-- and restarts the counter value. The timeout value is determined by
-- the RTO register.
ERTO : Boolean := False;
-- Enable fractional baud rate (FBR) mode.
EFBR : Boolean := False;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for MM0_Register use record
ESYN at 0 range 0 .. 2;
ELIN at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
ETTG at 0 range 5 .. 5;
ERTO at 0 range 6 .. 6;
EFBR at 0 range 7 .. 7;
end record;
-- You can configure input polarity for RZI demodulation.
type MM1_EIRX_Field is
(
-- RZI input pulses are active Low, signifying a low NRZ value
Active_Low,
-- RZI input pulses are active High, signifying a high NRZ value
Active_High)
with Size => 1;
for MM1_EIRX_Field use
(Active_Low => 0,
Active_High => 1);
-- You can configure output polarity for RZI modulation.
type MM1_EITX_Field is
(
-- RZI output pulses are active Low, signifying a low NRZ value
Active_Low,
-- RZI output pulses are active High, signifying a high NRZ value
Active_High)
with Size => 1;
for MM1_EITX_Field use
(Active_Low => 0,
Active_High => 1);
-- Output pulse width for RZI mod can be modified using this bit.
type MM1_EITP_Field is
(
-- 3/16th Tbit pulse width
Width_3_16,
-- 1/4th Tbit pulse width.
Width_1_4)
with Size => 1;
for MM1_EITP_Field use
(Width_3_16 => 0,
Width_1_4 => 1);
-- Multi-mode control register 1
type MM1_Register is record
-- LSB or MSB can be received first by configuring this bit. By default,
-- the receiver buffer register's (RBR) bit 0 is the LSB, and is the
-- first received bit. Bit 0 of the RBR may be configured as the last
-- received bit, MSB.
E_MSB_RX : Boolean := False;
-- LSB or MSB can be sent first by configuring this bit. By default, the
-- "THR" bit 0 is the LSB, and is the first transmitted bit. Bit 0 of
-- the THR may be configured as the last transmitted bit, MSB.
E_MSB_TX : Boolean := False;
-- Enables RZI modulation/demodulation.
EIRD : Boolean := False;
-- You can configure input polarity for RZI demodulation.
EIRX : MM1_EIRX_Field := Interfaces.SF2.MMUART.Active_Low;
-- You can configure output polarity for RZI modulation.
EITX : MM1_EITX_Field := Interfaces.SF2.MMUART.Active_Low;
-- Output pulse width for RZI mod can be modified using this bit.
EITP : MM1_EITP_Field := Interfaces.SF2.MMUART.Width_3_16;
-- unspecified
Reserved_6_7 : Interfaces.SF2.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for MM1_Register use record
E_MSB_RX at 0 range 0 .. 0;
E_MSB_TX at 0 range 1 .. 1;
EIRD at 0 range 2 .. 2;
EIRX at 0 range 3 .. 3;
EITX at 0 range 4 .. 4;
EITP at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- Multi-mode control register 2
type MM2_Register is record
-- When the EERR bit is set, the receiver forces an error signal
-- transmit out, if an incoming parity error is detected. Error signal
-- (ACK/NACK) is sent during stop time enable.
EERR : Boolean := False;
-- Enable automatic 9-bit address flag mode (EAFM). It should be noted
-- that for enabling this bit it requires, the LCR should be in an 8-bit
-- and stick parity (SP) bit configured to 0. If EAFM bit is disabled,
-- the Rx FIFO is enabled by receiving all the bytes. When EAFM bit is
-- enabled, the Rx FIFO is disabled until an address flag with matching
-- address is received.
EAFM : Boolean := False;
-- Enable a flag clear (EAFC). When EAFM is enabled the Rx FIFO is
-- disabled until another address flag with matching address is
-- received. The bit gets cleared on write in multi-mode control
-- registers 2.
EAFC : Boolean := False;
-- Enable single-wire, half-duplex mode.
ESWM : Boolean := False;
-- unspecified
Reserved_4_7 : Interfaces.SF2.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for MM2_Register use record
EERR at 0 range 0 .. 0;
EAFM at 0 range 1 .. 1;
EAFC at 0 range 2 .. 2;
ESWM at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
subtype DFR_DFR_Field is Interfaces.SF2.UInt6;
-- Divisor Fractional Register
type DFR_Register is record
-- The fractional divisor register (DFR) is used to store the fractional
-- divisor used to calculate the fractional baud rate value in 1/64th
-- using EQ 5. 0x0: 0/64 0x1: 1/64 etc.
DFR : DFR_DFR_Field := 16#0#;
-- unspecified
Reserved_6_7 : Interfaces.SF2.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for DFR_Register use record
DFR at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
type GFR_GLR_Field is
(
-- Two resynchronize flip-flops are used but there is no spike
-- suppression.
Two_Flip_Flops_No_Spike,
-- Three resynchronize flip-flops are used but there is no spike
-- suppression.
Three_Flip_Flops_No_Spike,
-- Three resynchronize flip-flops are used and it also causes 1 APB
-- clock cycle suppression.
Three_Flip_Flops_1_Cycle_Suppression,
-- Three resynchronize flip-flops are used and it also causes 2 APB
-- clock cycle suppression.
Three_Flip_Flops_2_Cycle_Suppression,
-- Three resynchronize flip-flops are used and it also causes 3 APB
-- clock cycle suppression.
Three_Flip_Flops_3_Cycle_Suppression,
-- Three resynchronize flip-flops are used and it also causes 4 APB
-- clock cycle suppression.
Three_Flip_Flops_4_Cycle_Suppression,
-- Three resynchronize flip-flops are used and it also causes 5 APB
-- clock cycle suppression.
Three_Flip_Flops_5_Cycle_Suppression,
-- Three resynchronize flip-flops are used and it also causes 6 APB
-- clock cycle suppression.
Three_Flip_Flops_6_Cycle_Suppression)
with Size => 3;
for GFR_GLR_Field use
(Two_Flip_Flops_No_Spike => 0,
Three_Flip_Flops_No_Spike => 1,
Three_Flip_Flops_1_Cycle_Suppression => 2,
Three_Flip_Flops_2_Cycle_Suppression => 3,
Three_Flip_Flops_3_Cycle_Suppression => 4,
Three_Flip_Flops_4_Cycle_Suppression => 5,
Three_Flip_Flops_5_Cycle_Suppression => 6,
Three_Flip_Flops_6_Cycle_Suppression => 7);
-- Glitch filter register
type GFR_Register is record
GLR : GFR_GLR_Field :=
Interfaces.SF2.MMUART.Two_Flip_Flops_No_Spike;
-- unspecified
Reserved_3_7 : Interfaces.SF2.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for GFR_Register use record
GLR at 0 range 0 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-----------------
-- Peripherals --
-----------------
type MMUART_0_Disc is
(
Mode_1,
Mode_2,
Mode_3);
-- Multi-mode universal asynchronous/synchronous receiver/transmitter
-- peripheral
type MMUART_Peripheral
(Discriminent : MMUART_0_Disc := Mode_1)
is record
-- Line Control register
LCR : aliased LCR_Register;
-- Modem Control register
MCR : aliased MCR_Register;
-- Line Status register
LSR : aliased LSR_Register;
-- Modem Status register
MSR : aliased MSR_Register;
-- Scratch register. This register has no effect on MMUART_x operation.
SR : aliased Interfaces.SF2.Byte;
-- Multi-mode interrupt enable register
IEM : aliased IEM_Register;
-- Multi-mode Interrupt identification register
IIM : aliased IIM_Register;
-- Multi-mode control register 0
MM0 : aliased MM0_Register;
-- Multi-mode control register 1
MM1 : aliased MM1_Register;
-- Multi-mode control register 2
MM2 : aliased MM2_Register;
-- Divisor Fractional Register
DFR : aliased DFR_Register;
-- Glitch filter register
GFR : aliased GFR_Register;
-- Transmitter time guard register. If the transmitter time guard is
-- enabled from the multi-mode control register 0 (MM0), the transmitter
-- time guard value determines the amount of system clock cycles to wait
-- between transmissions. The time guard equation is based on the baud
-- rate bit time (Tbit) value as follows: Tx Time Guard Value = TTG x
-- Bit Time (Tbit)
TTG : aliased Interfaces.SF2.Byte;
-- Receiver time-tou receiver. Writing to the RTO register sets the
-- counter value and enables, if the ERTO bit in the MM0 is enabled. You
-- can configure the timeout value by writing into this register. The
-- RTO counts when the Rx block input state is idle; is reset when a
-- start condition occurs, and restarts counting upon returning to the
-- idle state. When the RTO value is reached, the RTOII interrupt is
-- set. Re-writing the RTO register clears the interrupt and sets the
-- counter. The receiver timeout value equation is based on the baud
-- rate bit time (Tbit) as follows: Rx Timeout Value = 4 x RTO x Bit
-- Time (Tbit)
RTO : aliased Interfaces.SF2.Byte;
-- Address register. The address register is used in 9-bit Address Flag
-- mode. When an address flag is received on the 9th bit, and EAFM is
-- set in MM2, the incoming data is checked against the address
-- register. If a match occurs, the Rx FIFO is enabled.
ADR : aliased Interfaces.SF2.Byte;
case Discriminent is
when Mode_1 =>
-- Receiver buffer register. This register holds the receive data
-- bits for MMUART_x. The default value is unknown since the
-- register is loaded with data in the receive FIFO. Bit 0 is the
-- LSB and it is the first bit received. It may be configured as
-- the MSB by configuring the E_MSB_RX bit in the MM1. The divisor
-- latch access bit (DLAB), bit 7 of LCR, must be 0 to read this
-- register. This register is read only. Writing to this register
-- with the DLAB 0 changes the transmit holding register (THR)
-- register value.
RBR : aliased Interfaces.SF2.Byte;
-- Divisor latch (MSB)
DMR : aliased Interfaces.SF2.Byte;
-- FIFO control register
FCR : aliased FCR_Register;
when Mode_2 =>
-- Transmit holding register. This register holds the data bits to
-- be transmitted. Bit 0 is the LSB and is transmitted first. The
-- MSB may be transmitted first, if it is configured with the
-- E_MSB_TX bit in the MM1. The reset value is unknown since the
-- register is loaded with data in the transmit FIFO. The DLAB,
-- bit 7 of LCR, must be 0 to write to this register. This
-- register is write only. Reading from this register with the
-- DLAB 0 reads the RBR register value.
THR : aliased Interfaces.SF2.Byte;
-- Interupt Enable Register
IER : aliased IER_Register;
-- Interrupt identification register
IIR : aliased IIR_Register;
when Mode_3 =>
-- Divisor latch (LSB)
DLR : aliased Interfaces.SF2.Byte;
end case;
end record
with Unchecked_Union, Volatile;
for MMUART_Peripheral use record
LCR at 16#C# range 0 .. 7;
MCR at 16#10# range 0 .. 7;
LSR at 16#14# range 0 .. 7;
MSR at 16#18# range 0 .. 7;
SR at 16#1C# range 0 .. 7;
IEM at 16#24# range 0 .. 7;
IIM at 16#28# range 0 .. 7;
MM0 at 16#30# range 0 .. 7;
MM1 at 16#34# range 0 .. 7;
MM2 at 16#38# range 0 .. 7;
DFR at 16#3C# range 0 .. 7;
GFR at 16#44# range 0 .. 7;
TTG at 16#48# range 0 .. 7;
RTO at 16#4C# range 0 .. 7;
ADR at 16#50# range 0 .. 7;
RBR at 16#0# range 0 .. 7;
DMR at 16#4# range 0 .. 7;
FCR at 16#8# range 0 .. 7;
THR at 16#0# range 0 .. 7;
IER at 16#4# range 0 .. 7;
IIR at 16#8# range 0 .. 7;
DLR at 16#0# range 0 .. 7;
end record;
-- Multi-mode universal asynchronous/synchronous receiver/transmitter
-- peripheral
MMUART_0_Periph : aliased MMUART_Peripheral
with Import, Address => System'To_Address (16#40000000#);
-- Multi-mode universal asynchronous/synchronous receiver/transmitter
-- peripheral
MMUART_1_Periph : aliased MMUART_Peripheral
with Import, Address => System'To_Address (16#40010000#);
end Interfaces.SF2.MMUART;
|
with Ada.Text_IO, Ada.Containers.Indefinite_Vectors, Ada.Strings.Fixed, Ada.Strings.Maps;
use Ada.Text_IO, Ada.Containers, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps;
procedure Tokenize is
package String_Vectors is new Indefinite_Vectors (Positive, String);
use String_Vectors;
Input : String := "Hello,How,Are,You,Today";
Start : Positive := Input'First;
Finish : Natural := 0;
Output : Vector := Empty_Vector;
begin
while Start <= Input'Last loop
Find_Token (Input, To_Set (','), Start, Outside, Start, Finish);
exit when Start > Finish;
Output.Append (Input (Start .. Finish));
Start := Finish + 1;
end loop;
for S of Output loop
Put (S & ".");
end loop;
end Tokenize;
|
with Ada.Text_Io, copia_examenes;
with escribir_sospechosos,rellenar_aula_1,escribir_aula_act;
use copia_examenes;
use Ada.Text_Io;
procedure prueba_escribir_sospechosos is
aula1: T_aula;
procedure Pedir_Return is
begin
Put_Line("pulsa return para continuar ");
Skip_Line;
New_Line(4);
end Pedir_Return;
begin -- programa principal
-- Casos de prueba:
Put_Line("Programa de prueba: ");
Put_Line("*********");
Put_Line("Caso de prueba 1: ");
rellenar_aula_1(aula1);
escribir_aula_act(aula1);
new_line;
Put("Presiona cualquier tecla para saber la respuesta de tu programa");
Skip_line;
new_line(4);
Put_Line(" Tu programa deberia decir que: ");
new_line;
put_line(" (1,3) y (2,3) se han copiado");
put_line(" (2,1) y (2,2) se han copiado");
put_line(" (2,9) y (2,10) se han copiado");
put_line(" (3,1) y (4,1) se han copiado");
put_line(" (4,1) y (5,1) se han copiado");
put_line(" (9,1) y (9,2) se han copiado");
put_line(" (9,9) y (9,10) se han copiado");
put_line(" (9,10) y (10,10) se han copiado");
put_line(" (10,1) y (10,2) se han copiado");
new_line(2);
Pedir_Return;
Put_Line(" Y tu programa dice: ");
new_line;
escribir_sospechosos(aula1);
New_Line;
Put("Presiona cualquier tecla");
Skip_line;
end prueba_escribir_sospechosos;
|
Pragma Ada_2012;
With
Gnoga.Types,
Ada.Strings.Fixed,
Ada.Strings.Equal_Case_Insensitive,
Ada.Containers.Indefinite_Multiway_Trees;
Function NSO.JSON.Parameters_to_JSON( Input : in out Gnoga.Types.Data_Map_Type )
return NSO.JSON.Instance'Class is
-- PT is a package for the construction of a textual-tree from the submitted
-- values; we use this because the values, whether indexed or not, form a
-- tree structure.
--
-- The values of Input are such that the common portions of the text-string
-- may be rooted in a common object, with the root-object holding all values
-- which have been submitted.
--
-- EXAMPLE:
-- *Input: ("Item[Color]":"Brown"; "Item[Number]":"3"; "Name":"Steve")
-- *Output: {"Item" : { "Color" : "Brown", "Number" : "3"}
-- "Name" : "Steve"
-- }
Package PT is New Ada.Containers.Indefinite_Multiway_Trees
(Element_Type => String,
"=" => Ada.Strings.Equal_Case_Insensitive
);
-- This function creates a JSON object from the traversal of the tree we
-- created from the passed parameters.
Function From_Tree( Input : in PT.Tree ) return NSO.JSON.Object_Object;
-- This function creates a tree from the traversal of the parameters we
-- obtain from the submission of the Form data.
Function To_Tree ( Input : in Gnoga.Types.Data_Map_Type ) return PT.Tree;
-- Return either a single String value, or an array of values delimited by
-- the Unit_Seperator control-character.
-- Note: The parameter 'Value' is the string associated with a given key.
Function Handle_Value( Value: String ) return Instance'Class;
---------------------
-- IMPLEMENTATIONS --
---------------------
Function To_Tree( Input : in Gnoga.Types.Data_Map_Type ) return PT.Tree is
Open : Constant Character := '[';
Close : Constant Character := ']';
Result : PT.Tree := PT.Empty_Tree;
-- We use this procedure to track our position within the tree, as the
-- creation of trees from the indexed-keys lends itself to a recursive
-- implementation. We default 'Current' to the tree's root, but with
-- subsequent non-defaulted parameters so that it may only be used with
-- named parameter-association; the recursive calls should not use the
-- named parameter association.
Procedure To_Tree( Current : PT.Cursor:= Result.Root;
Key, Value : String
) is
Function First_Index(Bracket : Character) return Natural is
(Ada.Strings.Fixed.Index(
Source => Key,
Pattern => (1 => Bracket),
From => Key'First,
Going => Ada.Strings.Forward
)
) with Inline;
First_Open : Natural renames First_Index( Open );
First_Close : Natural renames First_Index( Close );
This : PT.Cursor;
Begin
-- There's something before the index.
-- So we create a node for it, then pass the remainder recursively.
if First_Open > Key'First then
Result.Insert_Child(
Parent => Current,
Before => PT.No_Element,
New_Item => Key(Key'First..First_Open-1),
Position => This
);
To_Tree( This, Key(First_Open..key'Last), Value );
-- There's no indexing at all.
-- We create a node for this, the key of the pair, then we create
-- a node directly under it for the value of the pair.
elsif First_Open = First_Close then -- no indexing,
Result.Insert_Child(
Parent => Current,
Before => PT.No_Element,
New_Item => Key,
Position => This
);
Result.Insert_Child(
Parent => This,
Before => PT.No_Element,
New_Item => Value,
Position => This
);
-- The 'normal' case.
-- We create a node for this name, then we check to see if this is
-- the final index: if it is, then we create a child-node for the
-- associated value; if not, recursively call with the next index.
elsif First_Open < First_Close then
Result.Insert_Child(
Parent => Current,
Before => PT.No_Element,
New_Item => Key(First_Open+1..First_Close-1),
Position => This
);
if First_Close = Key'Last then
Result.Insert_Child(
Parent => This,
Before => PT.No_Element,
New_Item => Value,
Position => This
);
else
To_Tree(This, Key(First_Close+1..Key'Last), Value);
end if;
-- Malformed indexing.
-- The only way we get First_Open > First_Close is to have a key
-- containing a close-index prior to an open-index; this may be due
-- to a bad form-input naming or creation. Check the names.
else
raise NSO.JSON.Parse_Error with "Bad indexing: '" & Key & "'.";
end if;
End To_Tree;
Begin
-- Here we operate on the Key-Value Pairs that are the parameters being
-- passed from the form submission; we are using the default parameter
-- for CURRENT so that the root-node assocites with the first call into
-- the procedure.
for KVP in Input.Iterate loop
To_Tree(
Key => Gnoga.Types.Data_Maps.Key(KVP),
Value => Gnoga.Types.Data_Maps.Element(KVP)
);
end loop;
Return Result;
End To_Tree;
Function From_Tree( Input : PT.Tree ) return NSO.JSON.Object_Object is
-- We need four values to return from the KIND function, these were
-- chosen to coorespond to the four cases we have to deal with.
Subtype Value_Style is Value_Kind
with Static_Predicate => Value_Style in
VK_Null | VK_String | VK_Array | VK_Object;
-- If all children are leaves then:
-- 0 children -> This is a leaf -> VK_Null.
-- 1 child -> child is a value -> VK_String.
-- more children -> children are an array -> VK_Array.
-- Otherwise:
-- This is an object w/ more processing to do -> VK_Object.
--
-- WARNING: These are NOT the actual parsed-types, but rather used to
-- indicate what sort of structure we are dealing with in the tree.
Function Kind(Position : in PT.Cursor) return Value_Style with Inline is
Children : constant Natural :=
Natural(PT.Child_Count(Position));
Are_Children_Leaves: constant Boolean :=
(for all Child in Input.Iterate_Children(Position) =>
PT.Is_Leaf(Child) );
Begin
Return (if not Are_Children_Leaves then VK_Object
else (case Children is
when 0 => VK_Null,
when 1 => VK_String,
when others => VK_Array
)
);
End Kind;
-- Given a position, and a current-object, we traverse the tree in order
-- to create the cooresponding object.
Procedure Make_Instance(
Position : in PT.Cursor;
Current : in out Object_Object
) is
Style : Value_Style renames Kind( Position );
Begin
Declare
Text : String renames PT.Element(Position);
Result : Instance'Class:=
(case Style is
when VK_Array => Make_Array,
when VK_String => Handle_Value( PT.Element(PT.First_Child(Position)) ),
when VK_Null => Handle_Value( PT.Element(Position) ),
when VK_Object => (if Current.Exists(Text)
then Current.Value(Text)
else Make_Object
)
);
Begin
case Style is
-- We should already have created the node from a prior call.
when VK_Null => Return;
-- All we need to do is let the call to value below
-- associate the result above with this node's text.
when VK_String => null;
-- Add the children-nodes to the result-array's data.
when VK_Array =>
declare
Object : Array_Object renames Array_Object(Result);
Item : PT.Cursor:= PT.First_Child(Position);
begin
loop
Object.Append( Handle_Value(PT.Element(Item)) );
PT.Next_Sibling(Item);
exit when not PT.Has_Element( Item );
end loop;
end;
-- Recursively call this function for child-nodes.
when VK_Object =>
declare
Object : Object_Object renames Object_Object(Result);
Item : PT.Cursor:= PT.First_Child(Position);
begin
loop
Make_Instance(Item, Object);
PT.Next_Sibling(Item);
exit when not PT.Has_Element( Item );
end loop;
end;
end case;
-- Associate the result-object with this node's textual-value.
Current.Value(Text, Result);
End;
End Make_Instance;
begin
-- We create an empty object, and then use it as our 'current' in our
-- calls to Make_Instance, thus constructing our JSON object.
Return Result : Object_Object:= Object_Object(NSO.JSON.Make_Object) do
For Child in Input.Iterate_Children(Input.Root) loop
Make_Instance(Child, Result);
End loop;
End return;
end From_Tree;
Function Handle_Value( Value: String ) return Instance'Class is
Unit_Separator : Constant Character := Character'Val( 31 );
US_STR : Constant String := (1 => Unit_Separator);
First_Index : Natural := Value'First;
Last_Index : Natural :=
Ada.Strings.Fixed.Index(
Pattern => US_STR,
Source => Value,
From => First_Index
);
Begin
if Last_Index not in Positive then
Return Make( Value );
else
Return Result : Array_Object := Array_Object(Make_Array) do
COLLECT_ELEMENTS:
loop
declare
Marker : Constant Natural:=
(if Last_Index in Positive
then Positive'Pred(Last_Index)
else Value'last
);
Subtype Slice is Positive range First_Index..Marker;
Data : String renames Value(Slice);
begin
Array_Object(Result).Append( Make(Data) );
exit COLLECT_ELEMENTS when Slice'Last = Value'Last;
First_Index:= Last_Index + US_STR'Length;
Last_Index := Ada.Strings.Fixed.Index(
Pattern => US_STR,
Source => Value,
From => First_Index
);
end;
end loop COLLECT_ELEMENTS;
End return;
end if;
End Handle_Value;
Begin
Return Result : Constant Instance'Class:= From_Tree( To_Tree( Input ) ) do
Input.Clear;
End return;
End NSO.JSON.Parameters_to_JSON;
|
-----------------------------------------------------------------------
-- components-utils-scrollers -- Data scrollers
-- Copyright (C) 2013, 2015 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Contexts.Writer;
package body ASF.Components.Utils.Scrollers is
-- ------------------------------
-- Get the list value holder that the scroller is controlling.
-- ------------------------------
function Get_List (UI : in UIScroller;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return Holders.List_Holder_Access is
use type Base.UIComponent_Access;
Id : constant String := UI.Get_Attribute ("for", Context, "");
C : Base.UIComponent_Access;
begin
C := UI.Find (Id);
if C = null then
return null;
elsif not (C.all in Holders.List_Holder'Class) then
return null;
else
return Holders.List_Holder'Class (C.all)'Access;
end if;
end Get_List;
-- Encode the data scroller.
overriding
procedure Encode_Children (UI : in UIScroller;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
use type Holders.List_Holder_Access;
List : Holders.List_Holder_Access;
begin
if not UI.Is_Rendered (Context) then
return;
end if;
List := UIScroller'Class (UI).Get_List (Context);
if List = null then
Base.Log_Error (UI, "There is no list object associated with the scroller");
return;
end if;
declare
Id : constant Ada.Strings.Unbounded.Unbounded_String := UI.Get_Client_Id;
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
Row_Count : constant Natural := List.Get_Row_Count; -- (Context);
Row_Per_Page : constant Natural := List.Get_Row_Per_Page; -- (Context);
Current_Page : constant Natural := List.Get_Current_Page; -- (Context);
Page_Count : constant Natural := (Row_Count + Row_Per_Page - 1) / Row_Per_Page;
begin
Writer.Start_Element ("div");
UI.Render_Attributes (Context, Writer);
if Current_Page > 1 then
UI.Render_Page ("first", 1, Context);
end if;
if Current_Page > 1 then
UI.Render_Page ("previous", Current_Page - 1, Context);
end if;
if Current_Page < Page_Count then
UI.Render_Page ("next", Current_Page + 1, Context);
end if;
if Current_Page < Page_Count then
UI.Render_Page ("last", Page_Count, Context);
end if;
Writer.End_Element ("div");
Writer.Queue_Script ("$('#" & Id & "').scroller();");
end;
end Encode_Children;
procedure Render_Page (UI : in UIScroller;
Name : in String;
Page : in Positive;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
use type ASF.Components.Base.UIComponent_Access;
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
F : constant ASF.Components.Base.UIComponent_Access := UI.Get_Facet (Name);
begin
Writer.Start_Element ("div");
Writer.Write_Attribute ("class", "asf-scroll-" & Name);
if F /= null then
F.Encode_All (Context);
else
Writer.Write_Text (Positive'Image (Page));
end if;
Writer.End_Element ("div");
end Render_Page;
end ASF.Components.Utils.Scrollers;
|
with Ada.Finalization;
...
type Node is abstract new Ada.Finalization.Limited_Controlled and Queue with record
Previous : not null access Node'Class := Node'Unchecked_Access;
Next : not null access Node'Class := Node'Unchecked_Access;
end record;
overriding procedure Finalize (X : in out Node); -- Removes the node from its list if any
overriding procedure Dequeue (Lounge : in out Node; Item : in out Element);
overriding procedure Enqueue (Lounge : in out Node; Item : in out Element);
procedure Process (X : in out Node) is abstract; -- To be implemented
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . I N T E R R U P T S --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1991-2000 Free Software Foundation, Inc. --
-- --
-- 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 2, 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is an OpenVMS/Alpha version of this package.
-- Invariants:
-- Once we associate a Server_Task with an interrupt, the task never
-- goes away, and we never remove the association.
-- There is no more than one interrupt per Server_Task and no more than
-- one Server_Task per interrupt.
-- Within this package, the lock L is used to protect the various status
-- tables. If there is a Server_Task associated with an interrupt, we use
-- the per-task lock of the Server_Task instead so that we protect the
-- status between Interrupt_Manager and Server_Task. Protection among
-- service requests are done using User Request to Interrupt_Manager
-- rendezvous.
with Ada.Task_Identification;
-- used for Task_ID type
with Ada.Exceptions;
-- used for Raise_Exception
with System.Task_Primitives;
-- used for RTS_Lock
-- Self
with System.Interrupt_Management;
-- used for Reserve
-- Interrupt_ID
-- Interrupt_Mask
-- Abort_Task_Interrupt
with System.Interrupt_Management.Operations;
-- used for Thread_Block_Interrupt
-- Thread_Unblock_Interrupt
-- Install_Default_Action
-- Install_Ignore_Action
-- Copy_Interrupt_Mask
-- Set_Interrupt_Mask
-- Empty_Interrupt_Mask
-- Fill_Interrupt_Mask
-- Add_To_Interrupt_Mask
-- Delete_From_Interrupt_Mask
-- Interrupt_Wait
-- Interrupt_Self_Process
-- Get_Interrupt_Mask
-- Set_Interrupt_Mask
-- IS_Member
-- Environment_Mask
-- All_Tasks_Mask
pragma Elaborate_All (System.Interrupt_Management.Operations);
with System.Error_Reporting;
pragma Warnings (Off, System.Error_Reporting);
-- used for Shutdown
with System.Task_Primitives.Operations;
-- used for Write_Lock
-- Unlock
-- Abort
-- Wakeup_Task
-- Sleep
-- Initialize_Lock
with System.Task_Primitives.Interrupt_Operations;
-- used for Set_Interrupt_ID
with System.Storage_Elements;
-- used for To_Address
-- To_Integer
-- Integer_Address
with System.Tasking;
-- used for Task_ID
-- Task_Entry_Index
-- Null_Task
-- Self
-- Interrupt_Manager_ID
with System.Tasking.Utilities;
-- used for Make_Independent
with System.Tasking.Rendezvous;
-- used for Call_Simple
pragma Elaborate_All (System.Tasking.Rendezvous);
with System.Tasking.Initialization;
-- used for Defer_Abort
-- Undefer_Abort
with Unchecked_Conversion;
package body System.Interrupts is
use Tasking;
use System.Error_Reporting;
use Ada.Exceptions;
package PRI renames System.Task_Primitives;
package POP renames System.Task_Primitives.Operations;
package PIO renames System.Task_Primitives.Interrupt_Operations;
package IMNG renames System.Interrupt_Management;
package IMOP renames System.Interrupt_Management.Operations;
function To_System is new Unchecked_Conversion
(Ada.Task_Identification.Task_Id, Task_ID);
-----------------
-- Local Tasks --
-----------------
-- WARNING: System.Tasking.Utilities performs calls to this task
-- with low-level constructs. Do not change this spec without synchro-
-- nizing it.
task Interrupt_Manager is
entry Initialize (Mask : IMNG.Interrupt_Mask);
entry Attach_Handler
(New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean;
Restoration : in Boolean := False);
entry Exchange_Handler
(Old_Handler : out Parameterless_Handler;
New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean);
entry Detach_Handler
(Interrupt : in Interrupt_ID;
Static : in Boolean);
entry Bind_Interrupt_To_Entry
(T : Task_ID;
E : Task_Entry_Index;
Interrupt : Interrupt_ID);
entry Detach_Interrupt_Entries (T : Task_ID);
entry Block_Interrupt (Interrupt : Interrupt_ID);
entry Unblock_Interrupt (Interrupt : Interrupt_ID);
entry Ignore_Interrupt (Interrupt : Interrupt_ID);
entry Unignore_Interrupt (Interrupt : Interrupt_ID);
pragma Interrupt_Priority (System.Interrupt_Priority'Last);
end Interrupt_Manager;
task type Server_Task (Interrupt : Interrupt_ID) is
pragma Priority (System.Interrupt_Priority'Last);
end Server_Task;
type Server_Task_Access is access Server_Task;
--------------------------------
-- Local Types and Variables --
--------------------------------
type Entry_Assoc is record
T : Task_ID;
E : Task_Entry_Index;
end record;
type Handler_Assoc is record
H : Parameterless_Handler;
Static : Boolean; -- Indicates static binding;
end record;
User_Handler : array (Interrupt_ID'Range) of Handler_Assoc :=
(others => (null, Static => False));
pragma Volatile_Components (User_Handler);
-- Holds the protected procedure handler (if any) and its Static
-- information for each interrupt. A handler is a Static one if
-- it is specified through the pragma Attach_Handler.
-- Attach_Handler. Otherwise, not static)
User_Entry : array (Interrupt_ID'Range) of Entry_Assoc :=
(others => (T => Null_Task, E => Null_Task_Entry));
pragma Volatile_Components (User_Entry);
-- Holds the task and entry index (if any) for each interrupt
Blocked : array (Interrupt_ID'Range) of Boolean := (others => False);
pragma Volatile_Components (Blocked);
-- True iff the corresponding interrupt is blocked in the process level
Ignored : array (Interrupt_ID'Range) of Boolean := (others => False);
pragma Volatile_Components (Ignored);
-- True iff the corresponding interrupt is blocked in the process level
Last_Unblocker :
array (Interrupt_ID'Range) of Task_ID := (others => Null_Task);
pragma Volatile_Components (Last_Unblocker);
-- Holds the ID of the last Task which Unblocked this Interrupt.
-- It contains Null_Task if no tasks have ever requested the
-- Unblocking operation or the Interrupt is currently Blocked.
Server_ID : array (Interrupt_ID'Range) of Task_ID :=
(others => Null_Task);
pragma Atomic_Components (Server_ID);
-- Holds the Task_ID of the Server_Task for each interrupt.
-- Task_ID is needed to accomplish locking per Interrupt base. Also
-- is needed to decide whether to create a new Server_Task.
-- Type and Head, Tail of the list containing Registered Interrupt
-- Handlers. These definitions are used to register the handlers
-- specified by the pragma Interrupt_Handler.
type Registered_Handler;
type R_Link is access all Registered_Handler;
type Registered_Handler is record
H : System.Address := System.Null_Address;
Next : R_Link := null;
end record;
Registered_Handler_Head : R_Link := null;
Registered_Handler_Tail : R_Link := null;
Access_Hold : Server_Task_Access;
-- variable used to allocate Server_Task using "new".
L : aliased PRI.RTS_Lock;
-- L protects contents in tables above corresponding to interrupts
-- for which Server_ID (T) = null.
--
-- If Server_ID (T) /= null then protection is via
-- per-task (TCB) lock of Server_ID (T).
--
-- For deadlock prevention, L should not be locked after
-- any other lock is held.
Task_Lock : array (Interrupt_ID'Range) of Boolean := (others => False);
-- Boolean flags to give matching Locking and Unlocking. See the comments
-- in Lock_Interrupt.
-----------------------
-- Local Subprograms --
-----------------------
procedure Lock_Interrupt
(Self_ID : Task_ID;
Interrupt : Interrupt_ID);
-- protect the tables using L or per-task lock. Set the Boolean
-- value Task_Lock if the lock is made using per-task lock.
-- This information is needed so that Unlock_Interrupt
-- performs unlocking on the same lock. The situation we are preventing
-- is, for example, when Attach_Handler is called for the first time
-- we lock L and create an Server_Task. For a matching unlocking, if we
-- rely on the fact that there is a Server_Task, we will unlock the
-- per-task lock.
procedure Unlock_Interrupt
(Self_ID : Task_ID;
Interrupt : Interrupt_ID);
function Is_Registered (Handler : Parameterless_Handler) return Boolean;
--------------------
-- Lock_Interrupt --
--------------------
-- ?????
-- This package has been modified several times.
-- Do we still need this fancy locking scheme, now that more operations
-- are entries of the interrupt manager task?
-- ?????
-- More likely, we will need to convert one or more entry calls to
-- protected operations, because presently we are violating locking order
-- rules by calling a task entry from within the runtime system.
procedure Lock_Interrupt
(Self_ID : Task_ID;
Interrupt : Interrupt_ID)
is
begin
Initialization.Defer_Abort (Self_ID);
POP.Write_Lock (L'Access);
if Task_Lock (Interrupt) then
-- We need to use per-task lock.
POP.Unlock (L'Access);
POP.Write_Lock (Server_ID (Interrupt));
-- Rely on the fact that once Server_ID is set to a non-null
-- value it will never be set back to null.
elsif Server_ID (Interrupt) /= Null_Task then
-- We need to use per-task lock.
Task_Lock (Interrupt) := True;
POP.Unlock (L'Access);
POP.Write_Lock (Server_ID (Interrupt));
end if;
end Lock_Interrupt;
----------------------
-- Unlock_Interrupt --
----------------------
procedure Unlock_Interrupt
(Self_ID : Task_ID;
Interrupt : Interrupt_ID)
is
begin
if Task_Lock (Interrupt) then
POP.Unlock (Server_ID (Interrupt));
else
POP.Unlock (L'Access);
end if;
Initialization.Undefer_Abort (Self_ID);
end Unlock_Interrupt;
----------------------------------
-- Register_Interrupt_Handler --
----------------------------------
procedure Register_Interrupt_Handler (Handler_Addr : System.Address) is
New_Node_Ptr : R_Link;
begin
-- This routine registers the Handler as usable for Dynamic
-- Interrupt Handler. Routines attaching and detaching Handler
-- dynamically should first consult if the Handler is rgistered.
-- A Program Error should be raised if it is not registered.
-- The pragma Interrupt_Handler can only appear in the library
-- level PO definition and instantiation. Therefore, we do not need
-- to implement Unregistering operation. Neither we need to
-- protect the queue structure using a Lock.
pragma Assert (Handler_Addr /= System.Null_Address);
New_Node_Ptr := new Registered_Handler;
New_Node_Ptr.H := Handler_Addr;
if Registered_Handler_Head = null then
Registered_Handler_Head := New_Node_Ptr;
Registered_Handler_Tail := New_Node_Ptr;
else
Registered_Handler_Tail.Next := New_Node_Ptr;
Registered_Handler_Tail := New_Node_Ptr;
end if;
end Register_Interrupt_Handler;
-------------------
-- Is_Registered --
-------------------
-- See if the Handler has been "pragma"ed using Interrupt_Handler.
-- Always consider a null handler as registered.
function Is_Registered (Handler : Parameterless_Handler) return Boolean is
type Fat_Ptr is record
Object_Addr : System.Address;
Handler_Addr : System.Address;
end record;
function To_Fat_Ptr is new Unchecked_Conversion
(Parameterless_Handler, Fat_Ptr);
Ptr : R_Link;
Fat : Fat_Ptr;
begin
if Handler = null then
return True;
end if;
Fat := To_Fat_Ptr (Handler);
Ptr := Registered_Handler_Head;
while (Ptr /= null) loop
if Ptr.H = Fat.Handler_Addr then
return True;
end if;
Ptr := Ptr.Next;
end loop;
return False;
end Is_Registered;
-----------------
-- Is_Reserved --
-----------------
function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is
begin
return IMNG.Reserve (IMNG.Interrupt_ID (Interrupt));
end Is_Reserved;
-----------------------
-- Is_Entry_Attached --
-----------------------
function Is_Entry_Attached (Interrupt : Interrupt_ID) return Boolean is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
return User_Entry (Interrupt).T /= Null_Task;
end Is_Entry_Attached;
-------------------------
-- Is_Handler_Attached --
-------------------------
function Is_Handler_Attached (Interrupt : Interrupt_ID) return Boolean is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
return User_Handler (Interrupt).H /= null;
end Is_Handler_Attached;
----------------
-- Is_Blocked --
----------------
function Is_Blocked (Interrupt : Interrupt_ID) return Boolean is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
return Blocked (Interrupt);
end Is_Blocked;
----------------
-- Is_Ignored --
----------------
function Is_Ignored (Interrupt : Interrupt_ID) return Boolean is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
return Ignored (Interrupt);
end Is_Ignored;
---------------------
-- Current_Handler --
---------------------
function Current_Handler (Interrupt : Interrupt_ID)
return Parameterless_Handler is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
-- ??? Since Parameterless_Handler is not Atomic, the
-- current implementation is wrong. We need a new service in
-- Interrupt_Manager to ensure atomicity.
return User_Handler (Interrupt).H;
end Current_Handler;
--------------------
-- Attach_Handler --
--------------------
-- Calling this procedure with New_Handler = null and Static = True
-- means we want to detach the current handler regardless of the
-- previous handler's binding status (ie. do not care if it is a
-- dynamic or static handler).
-- This option is needed so that during the finalization of a PO, we
-- can detach handlers attached through pragma Attach_Handler.
procedure Attach_Handler
(New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean := False)
is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Attach_Handler (New_Handler, Interrupt, Static);
end Attach_Handler;
----------------------
-- Exchange_Handler --
----------------------
-- Calling this procedure with New_Handler = null and Static = True
-- means we want to detach the current handler regardless of the
-- previous handler's binding status (ie. do not care if it is a
-- dynamic or static handler).
-- This option is needed so that during the finalization of a PO, we
-- can detach handlers attached through pragma Attach_Handler.
procedure Exchange_Handler
(Old_Handler : out Parameterless_Handler;
New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean := False)
is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Exchange_Handler
(Old_Handler, New_Handler, Interrupt, Static);
end Exchange_Handler;
--------------------
-- Detach_Handler --
--------------------
-- Calling this procedure with Static = True means we want to Detach the
-- current handler regardless of the previous handler's binding status
-- (i.e. do not care if it is a dynamic or static handler).
-- This option is needed so that during the finalization of a PO, we can
-- detach handlers attached through pragma Attach_Handler.
procedure Detach_Handler
(Interrupt : in Interrupt_ID;
Static : in Boolean := False)
is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Detach_Handler (Interrupt, Static);
end Detach_Handler;
---------------
-- Reference --
---------------
function Reference (Interrupt : Interrupt_ID) return System.Address is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
return Storage_Elements.To_Address
(Storage_Elements.Integer_Address (Interrupt));
end Reference;
-----------------------------
-- Bind_Interrupt_To_Entry --
-----------------------------
-- This procedure raises a Program_Error if it tries to
-- bind an interrupt to which an Entry or a Procedure is
-- already bound.
procedure Bind_Interrupt_To_Entry
(T : Task_ID;
E : Task_Entry_Index;
Int_Ref : System.Address)
is
Interrupt : constant Interrupt_ID :=
Interrupt_ID (Storage_Elements.To_Integer (Int_Ref));
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Bind_Interrupt_To_Entry (T, E, Interrupt);
end Bind_Interrupt_To_Entry;
------------------------------
-- Detach_Interrupt_Entries --
------------------------------
procedure Detach_Interrupt_Entries (T : Task_ID) is
begin
Interrupt_Manager.Detach_Interrupt_Entries (T);
end Detach_Interrupt_Entries;
---------------------
-- Block_Interrupt --
---------------------
procedure Block_Interrupt (Interrupt : Interrupt_ID) is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Block_Interrupt (Interrupt);
end Block_Interrupt;
-----------------------
-- Unblock_Interrupt --
-----------------------
procedure Unblock_Interrupt (Interrupt : Interrupt_ID) is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Unblock_Interrupt (Interrupt);
end Unblock_Interrupt;
------------------
-- Unblocked_By --
------------------
function Unblocked_By
(Interrupt : Interrupt_ID)
return System.Tasking.Task_ID
is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
return Last_Unblocker (Interrupt);
end Unblocked_By;
----------------------
-- Ignore_Interrupt --
----------------------
procedure Ignore_Interrupt (Interrupt : Interrupt_ID) is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Ignore_Interrupt (Interrupt);
end Ignore_Interrupt;
------------------------
-- Unignore_Interrupt --
------------------------
procedure Unignore_Interrupt (Interrupt : Interrupt_ID) is
begin
if Is_Reserved (Interrupt) then
Raise_Exception (Program_Error'Identity, "Interrupt" &
Interrupt_ID'Image (Interrupt) & " is reserved");
end if;
Interrupt_Manager.Unignore_Interrupt (Interrupt);
end Unignore_Interrupt;
-----------------------
-- Interrupt_Manager --
-----------------------
task body Interrupt_Manager is
----------------------
-- Local Variables --
----------------------
Intwait_Mask : aliased IMNG.Interrupt_Mask;
Ret_Interrupt : Interrupt_ID;
Old_Mask : aliased IMNG.Interrupt_Mask;
Self_ID : Task_ID := POP.Self;
---------------------
-- Local Routines --
---------------------
procedure Unprotected_Exchange_Handler
(Old_Handler : out Parameterless_Handler;
New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean;
Restoration : in Boolean := False);
procedure Unprotected_Detach_Handler
(Interrupt : in Interrupt_ID;
Static : in Boolean);
----------------------------------
-- Unprotected_Exchange_Handler --
----------------------------------
procedure Unprotected_Exchange_Handler
(Old_Handler : out Parameterless_Handler;
New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean;
Restoration : in Boolean := False)
is
begin
if User_Entry (Interrupt).T /= Null_Task then
-- In case we have an Interrupt Entry already installed.
-- raise a program error. (propagate it to the caller).
Unlock_Interrupt (Self_ID, Interrupt);
Raise_Exception (Program_Error'Identity,
"An interrupt is already installed");
end if;
-- Note : A null handler with Static = True will
-- pass the following check. That is the case when we want to
-- Detach a handler regardless of the Static status
-- of the current_Handler.
-- We don't check anything if Restoration is True, since we
-- may be detaching a static handler to restore a dynamic one.
if not Restoration and then not Static
-- Tries to overwrite a static Interrupt Handler with a
-- dynamic Handler
and then (User_Handler (Interrupt).Static
-- The new handler is not specified as an
-- Interrupt Handler by a pragma.
or else not Is_Registered (New_Handler))
then
Unlock_Interrupt (Self_ID, Interrupt);
Raise_Exception (Program_Error'Identity,
"Trying to overwrite a static Interrupt Handler with a " &
"dynamic Handler");
end if;
-- The interrupt should no longer be ingnored if
-- it was ever ignored.
Ignored (Interrupt) := False;
-- Save the old handler
Old_Handler := User_Handler (Interrupt).H;
-- The new handler
User_Handler (Interrupt).H := New_Handler;
if New_Handler = null then
-- The null handler means we are detaching the handler.
User_Handler (Interrupt).Static := False;
else
User_Handler (Interrupt).Static := Static;
end if;
-- Invoke a corresponding Server_Task if not yet created.
-- Place Task_ID info in Server_ID array.
if Server_ID (Interrupt) = Null_Task then
Access_Hold := new Server_Task (Interrupt);
Server_ID (Interrupt) := To_System (Access_Hold.all'Identity);
else
POP.Wakeup (Server_ID (Interrupt), Interrupt_Server_Idle_Sleep);
end if;
end Unprotected_Exchange_Handler;
--------------------------------
-- Unprotected_Detach_Handler --
--------------------------------
procedure Unprotected_Detach_Handler
(Interrupt : in Interrupt_ID;
Static : in Boolean)
is
Old_Handler : Parameterless_Handler;
begin
if User_Entry (Interrupt).T /= Null_Task then
-- In case we have an Interrupt Entry installed.
-- raise a program error. (propagate it to the caller).
Unlock_Interrupt (Self_ID, Interrupt);
Raise_Exception (Program_Error'Identity,
"An interrupt entry is already installed");
end if;
-- Note : Static = True will pass the following check. That is the
-- case when we want to detach a handler regardless of the static
-- status of the current_Handler.
if not Static and then User_Handler (Interrupt).Static then
-- Tries to detach a static Interrupt Handler.
-- raise a program error.
Unlock_Interrupt (Self_ID, Interrupt);
Raise_Exception (Program_Error'Identity,
"Trying to detach a static Interrupt Handler");
end if;
-- The interrupt should no longer be ignored if
-- it was ever ignored.
Ignored (Interrupt) := False;
Old_Handler := User_Handler (Interrupt).H;
-- The new handler
User_Handler (Interrupt).H := null;
User_Handler (Interrupt).Static := False;
IMOP.Interrupt_Self_Process (IMNG.Interrupt_ID (Interrupt));
end Unprotected_Detach_Handler;
-- Start of processing for Interrupt_Manager
begin
-- By making this task independent of master, when the process
-- goes away, the Interrupt_Manager will terminate gracefully.
System.Tasking.Utilities.Make_Independent;
-- Environmen task gets its own interrupt mask, saves it,
-- and then masks all interrupts except the Keep_Unmasked set.
-- During rendezvous, the Interrupt_Manager receives the old
-- interrupt mask of the environment task, and sets its own
-- interrupt mask to that value.
-- The environment task will call the entry of Interrupt_Manager some
-- during elaboration of the body of this package.
accept Initialize (Mask : IMNG.Interrupt_Mask) do
null;
end Initialize;
-- Note: All tasks in RTS will have all the Reserve Interrupts
-- being masked (except the Interrupt_Manager) and Keep_Unmasked
-- unmasked when created.
-- Abort_Task_Interrupt is one of the Interrupt unmasked
-- in all tasks. We mask the Interrupt in this particular task
-- so that "sigwait" is possible to catch an explicitly sent
-- Abort_Task_Interrupt from the Server_Tasks.
-- This sigwaiting is needed so that we make sure a Server_Task is
-- out of its own sigwait state. This extra synchronization is
-- necessary to prevent following senarios.
-- 1) Interrupt_Manager sends an Abort_Task_Interrupt to the
-- Server_Task then changes its own interrupt mask (OS level).
-- If an interrupt (corresponding to the Server_Task) arrives
-- in the nean time we have the Interrupt_Manager umnasked and
-- the Server_Task waiting on sigwait.
-- 2) For unbinding handler, we install a default action in the
-- Interrupt_Manager. POSIX.1c states that the result of using
-- "sigwait" and "sigaction" simaltaneously on the same interrupt
-- is undefined. Therefore, we need to be informed from the
-- Server_Task of the fact that the Server_Task is out of its
-- sigwait stage.
loop
-- A block is needed to absorb Program_Error exception
declare
Old_Handler : Parameterless_Handler;
begin
select
accept Attach_Handler
(New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean;
Restoration : in Boolean := False)
do
Lock_Interrupt (Self_ID, Interrupt);
Unprotected_Exchange_Handler
(Old_Handler, New_Handler, Interrupt, Static, Restoration);
Unlock_Interrupt (Self_ID, Interrupt);
end Attach_Handler;
or accept Exchange_Handler
(Old_Handler : out Parameterless_Handler;
New_Handler : in Parameterless_Handler;
Interrupt : in Interrupt_ID;
Static : in Boolean)
do
Lock_Interrupt (Self_ID, Interrupt);
Unprotected_Exchange_Handler
(Old_Handler, New_Handler, Interrupt, Static);
Unlock_Interrupt (Self_ID, Interrupt);
end Exchange_Handler;
or accept Detach_Handler
(Interrupt : in Interrupt_ID;
Static : in Boolean)
do
Lock_Interrupt (Self_ID, Interrupt);
Unprotected_Detach_Handler (Interrupt, Static);
Unlock_Interrupt (Self_ID, Interrupt);
end Detach_Handler;
or accept Bind_Interrupt_To_Entry
(T : Task_ID;
E : Task_Entry_Index;
Interrupt : Interrupt_ID)
do
Lock_Interrupt (Self_ID, Interrupt);
-- if there is a binding already (either a procedure or an
-- entry), raise Program_Error (propagate it to the caller).
if User_Handler (Interrupt).H /= null
or else User_Entry (Interrupt).T /= Null_Task
then
Unlock_Interrupt (Self_ID, Interrupt);
Raise_Exception (Program_Error'Identity,
"A binding for this interrupt is already present");
end if;
-- The interrupt should no longer be ingnored if
-- it was ever ignored.
Ignored (Interrupt) := False;
User_Entry (Interrupt) := Entry_Assoc' (T => T, E => E);
-- Indicate the attachment of Interrupt Entry in ATCB.
-- This is need so that when an Interrupt Entry task
-- terminates the binding can be cleaned.
-- The call to unbinding must be
-- make by the task before it terminates.
T.Interrupt_Entry := True;
-- Invoke a corresponding Server_Task if not yet created.
-- Place Task_ID info in Server_ID array.
if Server_ID (Interrupt) = Null_Task then
Access_Hold := new Server_Task (Interrupt);
Server_ID (Interrupt) :=
To_System (Access_Hold.all'Identity);
else
POP.Wakeup (Server_ID (Interrupt),
Interrupt_Server_Idle_Sleep);
end if;
Unlock_Interrupt (Self_ID, Interrupt);
end Bind_Interrupt_To_Entry;
or accept Detach_Interrupt_Entries (T : Task_ID)
do
for I in Interrupt_ID'Range loop
if not Is_Reserved (I) then
Lock_Interrupt (Self_ID, I);
if User_Entry (I).T = T then
-- The interrupt should no longer be ignored if
-- it was ever ignored.
Ignored (I) := False;
User_Entry (I) := Entry_Assoc'
(T => Null_Task, E => Null_Task_Entry);
IMOP.Interrupt_Self_Process (IMNG.Interrupt_ID (I));
end if;
Unlock_Interrupt (Self_ID, I);
end if;
end loop;
-- Indicate in ATCB that no Interrupt Entries are attached.
T.Interrupt_Entry := False;
end Detach_Interrupt_Entries;
or accept Block_Interrupt (Interrupt : Interrupt_ID) do
raise Program_Error;
end Block_Interrupt;
or accept Unblock_Interrupt (Interrupt : Interrupt_ID) do
raise Program_Error;
end Unblock_Interrupt;
or accept Ignore_Interrupt (Interrupt : Interrupt_ID) do
raise Program_Error;
end Ignore_Interrupt;
or accept Unignore_Interrupt (Interrupt : Interrupt_ID) do
raise Program_Error;
end Unignore_Interrupt;
end select;
exception
-- If there is a program error we just want to propagate it
-- to the caller and do not want to stop this task.
when Program_Error =>
null;
when others =>
pragma Assert
(Shutdown ("Interrupt_Manager---exception not expected"));
null;
end;
end loop;
pragma Assert (Shutdown ("Interrupt_Manager---should not get here"));
end Interrupt_Manager;
-----------------
-- Server_Task --
-----------------
task body Server_Task is
Self_ID : Task_ID := Self;
Tmp_Handler : Parameterless_Handler;
Tmp_ID : Task_ID;
Tmp_Entry_Index : Task_Entry_Index;
Intwait_Mask : aliased IMNG.Interrupt_Mask;
Ret_Interrupt : IMNG.Interrupt_ID;
begin
-- By making this task independent of master, when the process
-- goes away, the Server_Task will terminate gracefully.
System.Tasking.Utilities.Make_Independent;
-- Install default action in system level.
IMOP.Install_Default_Action (IMNG.Interrupt_ID (Interrupt));
-- Set up the mask (also clears the event flag)
IMOP.Empty_Interrupt_Mask (Intwait_Mask'Access);
IMOP.Add_To_Interrupt_Mask
(Intwait_Mask'Access, IMNG.Interrupt_ID (Interrupt));
-- Remember the Interrupt_ID for Abort_Task.
PIO.Set_Interrupt_ID (IMNG.Interrupt_ID (Interrupt), Self_ID);
-- Note: All tasks in RTS will have all the Reserve Interrupts
-- being masked (except the Interrupt_Manager) and Keep_Unmasked
-- unmasked when created.
loop
System.Tasking.Initialization.Defer_Abort (Self_ID);
-- A Handler or an Entry is installed. At this point all tasks
-- mask for the Interrupt is masked. Catch the Interrupt using
-- sigwait.
-- This task may wake up from sigwait by receiving an interrupt
-- (Abort_Task_Interrupt) from the Interrupt_Manager for unbinding
-- a Procedure Handler or an Entry. Or it could be a wake up
-- from status change (Unblocked -> Blocked). If that is not
-- the case, we should exceute the attached Procedure or Entry.
POP.Write_Lock (Self_ID);
if User_Handler (Interrupt).H = null
and then User_Entry (Interrupt).T = Null_Task
then
-- No Interrupt binding. If there is an interrupt,
-- Interrupt_Manager will take default action.
Self_ID.Common.State := Interrupt_Server_Idle_Sleep;
POP.Sleep (Self_ID, Interrupt_Server_Idle_Sleep);
Self_ID.Common.State := Runnable;
else
Self_ID.Common.State := Interrupt_Server_Blocked_On_Event_Flag;
Ret_Interrupt := IMOP.Interrupt_Wait (Intwait_Mask'Access);
Self_ID.Common.State := Runnable;
if not (Self_ID.Deferral_Level = 0
and then Self_ID.Pending_ATC_Level
< Self_ID.ATC_Nesting_Level)
then
if User_Handler (Interrupt).H /= null then
Tmp_Handler := User_Handler (Interrupt).H;
-- RTS calls should not be made with self being locked.
POP.Unlock (Self_ID);
Tmp_Handler.all;
POP.Write_Lock (Self_ID);
elsif User_Entry (Interrupt).T /= Null_Task then
Tmp_ID := User_Entry (Interrupt).T;
Tmp_Entry_Index := User_Entry (Interrupt).E;
-- RTS calls should not be made with self being locked.
POP.Unlock (Self_ID);
System.Tasking.Rendezvous.Call_Simple
(Tmp_ID, Tmp_Entry_Index, System.Null_Address);
POP.Write_Lock (Self_ID);
end if;
end if;
end if;
POP.Unlock (Self_ID);
System.Tasking.Initialization.Undefer_Abort (Self_ID);
-- Undefer abort here to allow a window for this task
-- to be aborted at the time of system shutdown.
end loop;
pragma Assert (Shutdown ("Server_Task---should not get here"));
end Server_Task;
-------------------------------------
-- Has_Interrupt_Or_Attach_Handler --
-------------------------------------
function Has_Interrupt_Or_Attach_Handler
(Object : access Dynamic_Interrupt_Protection) return Boolean is
begin
return True;
end Has_Interrupt_Or_Attach_Handler;
----------------
-- Finalize --
----------------
procedure Finalize (Object : in out Static_Interrupt_Protection) is
begin
-- ??? loop to be executed only when we're not doing library level
-- finalization, since in this case all interrupt tasks are gone.
if not Interrupt_Manager'Terminated then
for N in reverse Object.Previous_Handlers'Range loop
Interrupt_Manager.Attach_Handler
(New_Handler => Object.Previous_Handlers (N).Handler,
Interrupt => Object.Previous_Handlers (N).Interrupt,
Static => Object.Previous_Handlers (N).Static,
Restoration => True);
end loop;
end if;
Tasking.Protected_Objects.Entries.Finalize
(Tasking.Protected_Objects.Entries.Protection_Entries (Object));
end Finalize;
-------------------------------------
-- Has_Interrupt_Or_Attach_Handler --
-------------------------------------
function Has_Interrupt_Or_Attach_Handler
(Object : access Static_Interrupt_Protection)
return Boolean
is
begin
return True;
end Has_Interrupt_Or_Attach_Handler;
----------------------
-- Install_Handlers --
----------------------
procedure Install_Handlers
(Object : access Static_Interrupt_Protection;
New_Handlers : in New_Handler_Array)
is
begin
for N in New_Handlers'Range loop
-- We need a lock around this ???
Object.Previous_Handlers (N).Interrupt := New_Handlers (N).Interrupt;
Object.Previous_Handlers (N).Static := User_Handler
(New_Handlers (N).Interrupt).Static;
-- We call Exchange_Handler and not directly Interrupt_Manager.
-- Exchange_Handler so we get the Is_Reserved check.
Exchange_Handler
(Old_Handler => Object.Previous_Handlers (N).Handler,
New_Handler => New_Handlers (N).Handler,
Interrupt => New_Handlers (N).Interrupt,
Static => True);
end loop;
end Install_Handlers;
-- Elaboration code for package System.Interrupts
begin
-- Get Interrupt_Manager's ID so that Abort_Interrupt can be sent.
Interrupt_Manager_ID := To_System (Interrupt_Manager'Identity);
-- Initialize the lock L.
Initialization.Defer_Abort (Self);
POP.Initialize_Lock (L'Access, POP.ATCB_Level);
Initialization.Undefer_Abort (Self);
-- During the elaboration of this package body we want RTS to
-- inherit the interrupt mask from the Environment Task.
-- The Environment Task should have gotten its mask from
-- the enclosing process during the RTS start up. (See
-- in s-inmaop.adb). Pass the Interrupt_Mask of the Environment
-- task to the Interrupt_Manager.
-- Note : At this point we know that all tasks (including
-- RTS internal servers) are masked for non-reserved signals
-- (see s-taprop.adb). Only the Interrupt_Manager will have
-- masks set up differently inheriting the original Environment
-- Task's mask.
Interrupt_Manager.Initialize (IMOP.Environment_Mask);
end System.Interrupts;
|
package body Dse_Step is
procedure Do_Step (This : in out Counter) is
begin
This.Value := This.Value + This.Step;
end;
procedure Step_From (Start : in My_Counter) is
Lc : My_Counter := Start;
begin
while Nsteps > 0 loop
Do_Step (Lc);
Nsteps := Nsteps - 1;
end loop;
Mv := Lc.Value;
end;
end;
|
with System;
with Lv.Style;
with Lv.Objx.Textarea;
package Lv.Objx.Keyboard is
subtype Instance is Obj_T;
type Mode_T is (Mode_Text, Mode_Num);
type Style_T is
(Style_Bg,
Style_Btn_Rel,
Style_Btn_Pr,
Style_Btn_Tgl_Rel,
Style_Btn_Tgl_Pr,
Style_Btn_Ina);
-- Create a keyboard objects
-- @param par pointer to an object, it will be the parent of the new keyboard
-- @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it
-- @return pointer to the created keyboard
function Create (Par : Obj_T; Copy : Instance) return Instance;
----------------------
-- Setter functions --
----------------------
-- Assign a Text Area to the Keyboard. The pressed characters will be put there.
-- @param self pointer to a Keyboard object
-- @param ta pointer to a Text Area object to write there
procedure Set_Textarea (Self : Instance; Ta : Textarea.Instance);
-- Set a new a mode (text or number map)
-- @param self pointer to a Keyboard object
-- @param mode the mode from 'lv_kb_mode_t'
procedure Set_Mode (Self : Instance; Mode : Mode_T);
-- Automatically hide or show the cursor of the current Text Area
-- @param self pointer to a Keyboard object
-- @param en true: show cursor on the current text area, false: hide cursor
procedure Set_Cursor_Manage (Self : Instance; En : U_Bool);
-- Set call back to call when the "Ok" button is pressed
-- @param self pointer to Keyboard object
-- @param action a callback with 'lv_action_t' type
procedure Set_Ok_Action (Self : Instance; Action : Action_Func_T);
-- Set call back to call when the "Hide" button is pressed
-- @param self pointer to Keyboard object
-- @param action a callback with 'lv_action_t' type
procedure Set_Hide_Action (Self : Instance; Action : Action_Func_T);
-- Set a new map for the keyboard
-- @param self pointer to a Keyboard object
-- @param map pointer to a string array to describe the map.
-- See 'lv_btnm_set_map()' for more info.
procedure Set_Map (Self : Instance; Map : System.Address);
-- Set a style of a keyboard
-- @param self pointer to a keyboard object
-- @param type which style should be set
-- @param style pointer to a style
procedure Set_Style
(Self : Instance;
Type_P : Style_T;
Style : access Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Assign a Text Area to the Keyboard. The pressed characters will be put there.
-- @param self pointer to a Keyboard object
-- @return pointer to the assigned Text Area object
function Textarea (Self : Instance) return Textarea.Instance;
-- Set a new a mode (text or number map)
-- @param self pointer to a Keyboard object
-- @return the current mode from 'lv_kb_mode_t'
function Mode (Self : Instance) return Mode_T;
-- Get the current cursor manage mode.
-- @param self pointer to a Keyboard object
-- @return true: show cursor on the current text area, false: hide cursor
function Cursor_Manage (Self : Instance) return U_Bool;
-- Get the callback to call when the "Ok" button is pressed
-- @param self pointer to Keyboard object
-- @return the ok callback
function Ok_Action (Self : Instance) return Action_Func_T;
-- Get the callback to call when the "Hide" button is pressed
-- @param self pointer to Keyboard object
-- @return the close callback
function Hide_Action (Self : Instance) return Action_Func_T;
-- Get a style of a keyboard
-- @param self pointer to a keyboard object
-- @param type which style should be get
-- @return style pointer to a style
function Style
(Self : Instance;
Type_P : Style_T) return access Lv.Style.Style;
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_kb_create");
pragma Import (C, Set_Textarea, "lv_kb_set_ta");
pragma Import (C, Set_Mode, "lv_kb_set_mode");
pragma Import (C, Set_Cursor_Manage, "lv_kb_set_cursor_manage");
pragma Import (C, Set_Ok_Action, "lv_kb_set_ok_action");
pragma Import (C, Set_Hide_Action, "lv_kb_set_hide_action");
pragma Import (C, Set_Map, "lv_kb_set_map_inline");
pragma Import (C, Set_Style, "lv_kb_set_style");
pragma Import (C, Textarea, "lv_kb_get_ta");
pragma Import (C, Mode, "lv_kb_get_mode");
pragma Import (C, Cursor_Manage, "lv_kb_get_cursor_manage");
pragma Import (C, Ok_Action, "lv_kb_get_ok_action");
pragma Import (C, Hide_Action, "lv_kb_get_hide_action");
pragma Import (C, Style, "lv_kb_get_style");
for Mode_T'Size use 8;
for Mode_T use (Mode_Text => 0, Mode_Num => 1);
for Style_T'Size use 8;
for Style_T use
(Style_Bg => 0,
Style_Btn_Rel => 1,
Style_Btn_Pr => 2,
Style_Btn_Tgl_Rel => 3,
Style_Btn_Tgl_Pr => 4,
Style_Btn_Ina => 5);
end Lv.Objx.Keyboard;
|
with Ada.Assertions; use Ada.Assertions;
with Libadalang.Common; use Libadalang.Common;
package body Rewriters_Context_Utils is
function Combine_Contexts (C1, C2 : Ada_Node) return Ada_Node
is
begin
if Is_Reflexive_Ancestor (C1, C2)
then
return C1;
else
Assert (Check => Is_Reflexive_Ancestor (C2, C1),
Message => "Unexpectedly, contexts don't share same node.");
return C2;
end if;
end Combine_Contexts;
function To_Supported_Context (C : Ada_Node) return Ada_Node
is
begin
-- workaround for https://gt3-prod-1.adacore.com/#/tickets/UB17-030
-- solved in libadalang version 23.0 and higher
case C.Kind is
when Ada_While_Loop_Spec | Ada_Elsif_Stmt_Part_List =>
return C.Parent;
when Ada_Case_Stmt_Alternative | Ada_Elsif_Stmt_Part =>
return C.Parent.Parent;
when others =>
return C;
end case;
end To_Supported_Context;
end Rewriters_Context_Utils;
|
package body Benchmark.QSort is
function Create_QSort return Benchmark_Pointer is
begin
return new QSort_Type;
end Create_QSort;
procedure Set_Argument(benchmark : in out QSort_Type;
arg : in String) is
value : constant String := Extract_Argument(arg);
begin
if Check_Argument(arg, "size") then
benchmark.size := Positive'Value(value);
else
Set_Argument(Benchmark_Type(benchmark), arg);
end if;
exception
when others =>
raise Invalid_Argument;
end Set_Argument;
procedure Sort(benchmark : in QSort_Type;
left, right : in Integer) is
a : Integer := left;
b : Integer := right;
av : Integer;
bv : Integer;
pivot : constant Integer := Read_Value(benchmark, left);
begin
loop
while a <= right loop
av := Read_Value(benchmark, a);
exit when av >= pivot;
a := a + 1;
end loop;
while b >= left loop
bv := Read_Value(benchmark, b);
exit when bv <= pivot;
b := b - 1;
end loop;
exit when a > b;
Write_Value(benchmark, a, bv);
Write_Value(benchmark, b, av);
a := a + 1;
b := b - 1;
end loop;
if a - 1 > left then
Sort(benchmark, left, a - 1);
end if;
if right > a then
Sort(benchmark, a, right);
end if;
end Sort;
procedure Run(benchmark : in QSort_Type) is
begin
-- Generate the data set.
for i in 0 .. benchmark.size - 1 loop
Write_Value(benchmark, i, Get_Random(benchmark));
end loop;
-- Sort in place.
Sort(benchmark, 0, benchmark.size - 1);
end Run;
end Benchmark.QSort;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2011, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
-- This is the generic bare board version of this package
-- This package contains all the GNULL primitives that interface directly with
-- the underlying kernel.
pragma Restrictions (No_Elaboration_Code);
with Ada.Unchecked_Conversion;
with System.Storage_Elements;
with System.Tasking.Debug;
package body System.Task_Primitives.Operations is
use System.OS_Interface;
use System.Parameters;
use System.Storage_Elements;
use type System.Tasking.Task_Id;
---------------------
-- Local Functions --
---------------------
function To_Address is new
Ada.Unchecked_Conversion (ST.Task_Id, System.Address);
function To_Task_Id is new
Ada.Unchecked_Conversion (System.Address, ST.Task_Id);
----------
-- Self --
----------
function Self return ST.Task_Id is
begin
return To_Task_Id (System.OS_Interface.Get_ATCB);
end Self;
-----------
-- Sleep --
-----------
procedure Sleep
(Self_ID : ST.Task_Id;
Reason : System.Tasking.Task_States)
is
pragma Unreferenced (Reason);
begin
-- A task can only suspend itself
pragma Assert (Self_ID = Self);
System.OS_Interface.Sleep;
end Sleep;
-----------------
-- Delay_Until --
-----------------
procedure Delay_Until (Abs_Time : Time) is
Self_ID : constant ST.Task_Id := Self;
begin
Self_ID.Common.State := ST.Delay_Sleep;
System.OS_Interface.Delay_Until (System.OS_Interface.Time (Abs_Time));
Self_ID.Common.State := ST.Runnable;
end Delay_Until;
---------------------
-- Monotonic_Clock --
---------------------
function Monotonic_Clock return Time is
begin
return Time (System.OS_Interface.Clock);
end Monotonic_Clock;
------------
-- Wakeup --
------------
procedure Wakeup (T : ST.Task_Id; Reason : System.Tasking.Task_States) is
pragma Unreferenced (Reason);
begin
System.OS_Interface.Wakeup (T.Common.LL.Thread);
end Wakeup;
------------------
-- Set_Priority --
------------------
procedure Set_Priority (T : ST.Task_Id; Prio : System.Any_Priority) is
begin
-- A task can only change its own priority
pragma Assert (T = Self);
-- Change the priority in the underlying executive
System.OS_Interface.Set_Priority (Prio);
end Set_Priority;
------------------
-- Get_Priority --
------------------
function Get_Priority (T : ST.Task_Id) return System.Any_Priority is
begin
-- Get current active priority
return System.OS_Interface.Get_Priority (T.Common.LL.Thread);
end Get_Priority;
------------------
-- Get_Affinity --
------------------
function Get_Affinity
(T : ST.Task_Id) return System.Multiprocessors.CPU_Range
is
begin
return System.OS_Interface.Get_Affinity (T.Common.LL.Thread);
end Get_Affinity;
-------------
-- Get_CPU --
-------------
function Get_CPU (T : ST.Task_Id) return System.Multiprocessors.CPU is
begin
return System.OS_Interface.Get_CPU (T.Common.LL.Thread);
end Get_CPU;
-------------------
-- Get_Thread_Id --
-------------------
function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
begin
return T.Common.LL.Thread;
end Get_Thread_Id;
----------------
-- Enter_Task --
----------------
procedure Enter_Task (Self_ID : ST.Task_Id) is
begin
-- Notify the underlying executive about the Ada task that is being
-- executed by the running thread.
System.OS_Interface.Set_ATCB (To_Address (Self_ID));
-- Set lwp (for gdb)
Self_ID.Common.LL.Lwp := Lwp_Self;
-- Register the task to System.Tasking.Debug
System.Tasking.Debug.Add_Task_Id (Self_ID);
-- Ensure that the task has the right priority priority at the end
-- of its initialization (before calling the task's code).
System.OS_Interface.Set_Priority (Self_ID.Common.Base_Priority);
end Enter_Task;
--------------------
-- Initialize_TCB --
--------------------
procedure Initialize_TCB (Self_ID : ST.Task_Id; Succeeded : out Boolean) is
pragma Unreferenced (Self_ID);
begin
-- Nothing to be done as part of the initialization of TCBs
Succeeded := True;
end Initialize_TCB;
-----------------
-- Create_Task --
-----------------
procedure Create_Task
(T : ST.Task_Id;
Wrapper : System.Address;
Stack_Size : System.Parameters.Size_Type;
Priority : System.Any_Priority;
Base_CPU : System.Multiprocessors.CPU_Range;
Succeeded : out Boolean)
is
begin
-- The stack has been preallocated for these targets
pragma Assert
(T.Common.Compiler_Data.Pri_Stack_Info.Start_Address /= Null_Address
and then Storage_Offset (Stack_Size) =
T.Common.Compiler_Data.Pri_Stack_Info.Size);
T.Common.LL.Thread := T.Common.LL.Thread_Desc'Access;
-- Create the underlying task
System.OS_Interface.Thread_Create
(T.Common.LL.Thread,
Wrapper,
To_Address (T),
Priority,
Base_CPU,
T.Common.Compiler_Data.Pri_Stack_Info.Start_Address,
Size_Type (T.Common.Compiler_Data.Pri_Stack_Info.Size));
Succeeded := True;
end Create_Task;
----------------
-- Initialize --
----------------
procedure Initialize (Environment_Task : ST.Task_Id) is
begin
Environment_Task.Common.LL.Thread :=
Environment_Task.Common.LL.Thread_Desc'Access;
-- Clear Activation_Link, as required by Add_Task_Id
Environment_Task.Common.Activation_Link := null;
-- First the underlying multitasking executive must be initialized
System.OS_Interface.Initialize
(Environment_Task.Common.LL.Thread,
Environment_Task.Common.Base_Priority);
-- The environment task must also execute its initialization
Enter_Task (Environment_Task);
end Initialize;
----------------------
-- Initialize_Slave --
----------------------
procedure Initialize_Slave (Environment_Task : ST.Task_Id) is
begin
Environment_Task.Common.LL.Thread :=
Environment_Task.Common.LL.Thread_Desc'Access;
-- Clear Activation_Link, as required by Add_Task_Id
Environment_Task.Common.Activation_Link := null;
-- Initialize the environment thread
System.OS_Interface.Initialize_Slave_Environment
(Environment_Task.Common.LL.Thread);
-- The environment task must also execute its initialization
Enter_Task (Environment_Task);
end Initialize_Slave;
---------------------
-- Is_Task_Context --
---------------------
function Is_Task_Context return Boolean is
begin
return System.OS_Interface.Current_Interrupt = No_Interrupt;
end Is_Task_Context;
end System.Task_Primitives.Operations;
|
with Ada.Text_Io; use Ada.Text_Io;
procedure Cocktail_Sort_Test is
procedure Cocktail_Sort (Item : in out String) is
procedure Swap(Left, Right : in out Character) is
Temp : Character := Left;
begin
Left := Right;
Right := Temp;
end Swap;
Swapped : Boolean := False;
begin
loop
for I in 1..Item'Last - 1 loop
if Item(I) > Item(I + 1) then
Swap(Item(I), Item(I + 1));
Swapped := True;
end if;
end loop;
if not Swapped then
for I in reverse 1..Item'Last - 1 loop
if Item(I) > Item(I + 1) then
Swap(Item(I), Item(I + 1));
Swapped := True;
end if;
end loop;
end if;
exit when not Swapped;
Swapped := False;
end loop;
end Cocktail_Sort;
Data : String := "big fjords vex quick waltz nymph";
begin
Put_Line(Data);
Cocktail_Sort(Data);
Put_Line(Data);
end Cocktail_Sort_Test;
|
-- Shoot'n'loot
-- Copyright (c) 2020 Fabien Chouteau
with HAL; use HAL;
with GESTE;
with GESTE.Tile_Bank;
with GESTE.Grid;
with GESTE.Sprite;
with GESTE_Config; use GESTE_Config;
with Render;
with Game;
with Sound;
with PyGamer.Time;
with PyGamer.Controls;
use PyGamer;
with Game_Assets.title_screen;
with Game_Assets.Tileset;
with Game_Assets.Tileset_Collisions;
with Game_Assets.Misc_Objects;
package body Menus is
Tile_Bank : aliased GESTE.Tile_Bank.Instance
(Game_Assets.Tileset.Tiles'Access,
Game_Assets.Tileset_Collisions.Tiles'Access,
Game_Assets.Palette'Access);
Back_Grid : aliased GESTE.Grid.Instance
(Game_Assets.title_screen.Back.Data'Access,
Tile_Bank'Access);
Menu_Grid : aliased GESTE.Grid.Instance
(Game_Assets.title_screen.Menu.Data'Access,
Tile_Bank'Access);
Help_Grid : aliased GESTE.Grid.Instance
(Game_Assets.title_screen.Help.Data'Access,
Tile_Bank'Access);
Credits_Grid : aliased GESTE.Grid.Instance
(Game_Assets.title_screen.Credits.Data'Access,
Tile_Bank'Access);
Cursor : aliased GESTE.Sprite.Instance
(Tile_Bank'Access, Game_Assets.Misc_Objects.Item.Menu_Cursor.Tile_Id);
type Selection_Kind is (Play, Help, Credits);
Current_Selection : Selection_Kind := Play;
Current_Screen : Selection_Kind := Play;
Cursor_Position : constant array (Selection_Kind) of GESTE.Pix_Point :=
(Play => (6 * Tile_Size, 10 * Tile_Size),
Help => (6 * Tile_Size, 11 * Tile_Size),
Credits => (6 * Tile_Size, 12 * Tile_Size));
Time_In_Game : Time.Time_Ms := 0;
procedure Scroll_Screen (Screen : Selection_Kind);
-------------------
-- Scroll_Screen --
-------------------
procedure Scroll_Screen (Screen : Selection_Kind) is
begin
GESTE.Remove_All;
Back_Grid.Move ((0, 0));
GESTE.Add (Back_Grid'Access, 0);
case Screen is
when Play =>
Cursor.Move ((Cursor_Position (Current_Selection)));
GESTE.Add (Cursor'Access, 1);
Menu_Grid.Move ((0, 0));
GESTE.Add (Menu_Grid'Access, 1);
when Help =>
Help_Grid.Move ((0, 0));
GESTE.Add (Help_Grid'Access, 1);
when Credits =>
Credits_Grid.Move ((0, 0));
GESTE.Add (Credits_Grid'Access, 1);
end case;
Render.Scroll_New_Scene (Render.Background_Color);
Current_Screen := Screen;
end Scroll_Screen;
---------
-- Run --
---------
procedure Run is
Period : constant Time.Time_Ms := 1000 / 60;
Next_Release : Time.Time_Ms;
begin
Scroll_Screen (Play);
Next_Release := Time.Clock;
Sound.Play_Main_Theme;
loop
Controls.Scan;
case Current_Screen is
when Play =>
-- Next menu item selection
if Controls.Falling (Controls.Down)
or else
Controls.Falling (Controls.Sel)
then
Sound.Play_Coin;
if Current_Selection = Selection_Kind'Last then
Current_Selection := Selection_Kind'First;
else
Current_Selection :=
Selection_Kind'Succ (Current_Selection);
end if;
end if;
-- Previous menu item selection
if Controls.Falling (Controls.Up) then
Sound.Play_Coin;
if Current_Selection = Selection_Kind'First then
Current_Selection := Selection_Kind'Last;
else
Current_Selection :=
Selection_Kind'Pred (Current_Selection);
end if;
end if;
-- Enter menu page or return to start playing
if Controls.Falling (Controls.Start)
or else
Controls.Falling (Controls.A)
or else
Controls.Falling (Controls.B)
then
if Current_Selection = Play then
GESTE.Remove_All;
Sound.Play_Gameplay;
-- Start the game and wait for result
if Game.Game_Loop (Time_In_Game) then
-- Victory! Let's have a look at the credits
Scroll_Screen (Credits);
else
-- Game-over, back to the title screen
Scroll_Screen (Play);
end if;
Sound.Play_Main_Theme;
else
Scroll_Screen (Current_Selection);
end if;
Next_Release := Time.Clock;
end if;
-- Move the cursor
Cursor.Move ((Cursor_Position (Current_Selection)));
when others =>
if (for some Button in Controls.Buttons
=> Controls.Falling (Button))
then
Scroll_Screen (Play);
Next_Release := Time.Clock;
end if;
end case;
Sound.Tick;
Render.Render_Dirty (Render.Background_Color);
Time.Delay_Until (Next_Release);
Next_Release := Next_Release + Period;
end loop;
end Run;
end Menus;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . H E A P _ S O R T _ G --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2019, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body GNAT.Heap_Sort_G is
----------
-- Sort --
----------
-- We are using the classical heapsort algorithm (i.e. Floyd's Treesort3)
-- as described by Knuth ("The Art of Programming", Volume III, first
-- edition, section 5.2.3, p. 145-147) with the modification that is
-- mentioned in exercise 18. For more details on this algorithm, see
-- Robert B. K. Dewar PhD thesis "The use of Computers in the X-ray
-- Phase Problem". University of Chicago, 1968, which was the first
-- publication of the modification, which reduces the number of compares
-- from 2NlogN to NlogN.
procedure Sort (N : Natural) is
Max : Natural := N;
-- Current Max index in tree being sifted
procedure Sift (S : Positive);
-- This procedure sifts up node S, i.e. converts the subtree rooted
-- at node S into a heap, given the precondition that any sons of
-- S are already heaps. On entry, the contents of node S is found
-- in the temporary (index 0), the actual contents of node S on
-- entry are irrelevant. This is just a minor optimization to avoid
-- what would otherwise be two junk moves in phase two of the sort.
----------
-- Sift --
----------
procedure Sift (S : Positive) is
C : Positive := S;
Son : Positive;
Father : Positive;
-- Note: by making the above all Positive, we ensure that a test
-- against zero for the temporary location can be resolved on the
-- basis of types when the routines are inlined.
begin
-- This is where the optimization is done, normally we would do a
-- comparison at each stage between the current node and the larger
-- of the two sons, and continue the sift only if the current node
-- was less than this maximum. In this modified optimized version,
-- we assume that the current node will be less than the larger
-- son, and unconditionally sift up. Then when we get to the bottom
-- of the tree, we check parents to make sure that we did not make
-- a mistake. This roughly cuts the number of comparisons in half,
-- since it is almost always the case that our assumption is correct.
-- Loop to pull up larger sons
loop
Son := 2 * C;
if Son < Max then
if Lt (Son, Son + 1) then
Son := Son + 1;
end if;
elsif Son > Max then
exit;
end if;
Move (Son, C);
C := Son;
end loop;
-- Loop to check fathers
while C /= S loop
Father := C / 2;
if Lt (Father, 0) then
Move (Father, C);
C := Father;
else
exit;
end if;
end loop;
-- Last step is to pop the sifted node into place
Move (0, C);
end Sift;
-- Start of processing for Sort
begin
-- Phase one of heapsort is to build the heap. This is done by
-- sifting nodes N/2 .. 1 in sequence.
for J in reverse 1 .. N / 2 loop
Move (J, 0);
Sift (J);
end loop;
-- In phase 2, the largest node is moved to end, reducing the size
-- of the tree by one, and the displaced node is sifted down from
-- the top, so that the largest node is again at the top.
while Max > 1 loop
Move (Max, 0);
Move (1, Max);
Max := Max - 1;
Sift (1);
end loop;
end Sort;
end GNAT.Heap_Sort_G;
|
with Arduino_Nano_33_Ble_Sense.IOs;
with HCSR04;
procedure Main is
Testing_Sensor_Echo : constant Arduino_Nano_33_Ble_Sense.IOs.Pin_Id := 44;
Testing_Sensor_Trig : constant Arduino_Nano_33_Ble_Sense.IOs.Pin_Id := 43;
Distance_Value : Float;
begin
loop
Distance_Value := HCSR04.Distance(Testing_Sensor_Trig, Testing_Sensor_Echo);
end loop;
end Main;
|
-- Copyright 2020-2021 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Value is
function Create return T is
begin
return (One => (Well => Value_Name.No,
Unique_Name => (X1 => 1, X2 => 2)),
Two => (Well => Value_Name.Yes,
Name => "abcdefgh"));
end Create;
function Name (Of_Value : T) return Value_Name.T is
begin
return Of_Value.Two;
end Name;
end Value;
|
with System.Address_To_Named_Access_Conversions;
with System.Growth;
with System.Debug; -- assertions
with C.basetsd;
with C.winbase;
with C.windef;
package body System.Unbounded_Allocators is
use type Storage_Elements.Storage_Offset;
use type C.size_t;
use type C.basetsd.SSIZE_T;
use type C.windef.WORD;
use type C.windef.WINBOOL;
use type C.winnt.HANDLE; -- C.void_ptr
package HANDLE_ptr_Conv is
new Address_To_Named_Access_Conversions (
C.winnt.HANDLE,
C.winnt.HANDLE_ptr);
type HANDLE_array is array (C.size_t range <>) of C.winnt.HANDLE
with Convention => C;
function Is_In (Storage_Address : Address; Heap : C.winnt.HANDLE)
return Boolean;
function Is_In (Storage_Address : Address; Heap : C.winnt.HANDLE)
return Boolean
is
Result : Boolean := False;
begin
Result :=
C.winbase.HeapValidate (
Heap,
0,
C.void_const_ptr (Storage_Address)) /=
C.windef.FALSE;
-- Result := False;
-- Dummy := C.winbase.HeapLock (Heap);
-- declare
-- Heap_Entry : aliased C.winbase.PROCESS_HEAP_ENTRY :=
-- (lpData => C.void_ptr (Null_Address), others => <>);
-- begin
-- while C.winbase.HeapWalk (Heap, Heap_Entry'Access) /=
-- C.windef.FALSE
-- loop
-- if (Heap_Entry.wFlags and C.winbase.PROCESS_HEAP_REGION) /= 0
-- and then Storage_Address >=
-- Address (Heap_Entry.anonymous_1.Region.lpFirstBlock)
-- and then Storage_Address <
-- Address (Heap_Entry.anonymous_1.Region.lpLastBlock)
-- then
-- Result := True;
-- exit;
-- end if;
-- end loop;
-- end;
-- Dummy := C.winbase.HeapUnlock (Heap);
return Result;
end Is_In;
-- implementation
procedure Initialize (Object : in out Unbounded_Allocator) is
begin
Object := Unbounded_Allocator (C.winbase.HeapCreate (0, 0, 0));
end Initialize;
procedure Finalize (Object : in out Unbounded_Allocator) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.HeapDestroy (C.winnt.HANDLE (Object));
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("HeapDestroy failed"));
end Finalize;
procedure Allocate (
Allocator : Unbounded_Allocator;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
Storage_Address := Address (
C.winbase.HeapAlloc (
C.winnt.HANDLE (Allocator),
0,
C.basetsd.SIZE_T (Size_In_Storage_Elements)));
if Storage_Address = Null_Address then
raise Storage_Error;
elsif Storage_Address mod Alignment /= 0 then
Deallocate (
Allocator,
Storage_Address,
Size_In_Storage_Elements,
Alignment);
raise Storage_Error;
end if;
end Allocate;
procedure Deallocate (
Allocator : Unbounded_Allocator;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
pragma Unreferenced (Size_In_Storage_Elements);
pragma Unreferenced (Alignment);
Success : C.windef.WINBOOL;
begin
Success := C.winbase.HeapFree (
C.winnt.HANDLE (Allocator),
0,
C.windef.LPVOID (Storage_Address));
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("HeapFree failed"));
end Deallocate;
function Allocator_Of (Storage_Address : Address)
return Unbounded_Allocator
is
package Holder is
new Growth.Scoped_Holder (
C.basetsd.SSIZE_T,
Component_Size => HANDLE_array'Component_Size);
Buffer_Length : C.size_t;
begin
Holder.Reserve_Capacity (64);
loop
declare
Length : C.basetsd.SSIZE_T;
begin
Length :=
C.basetsd.SSIZE_T (
C.winbase.GetProcessHeaps (
C.windef.DWORD (Holder.Capacity),
HANDLE_ptr_Conv.To_Pointer (Holder.Storage_Address)));
if Length = 0 then
raise Program_Error; -- GetProcessHeaps failed
end if;
if Length <= Holder.Capacity then
Buffer_Length := C.size_t (Length);
exit;
end if;
end;
-- growth
declare
function Grow is new Growth.Fast_Grow (C.basetsd.SSIZE_T);
begin
Holder.Reserve_Capacity (Grow (Holder.Capacity));
end;
end loop;
declare
Heaps : HANDLE_array (0 .. Buffer_Length - 1);
for Heaps'Address use Holder.Storage_Address;
begin
for I in Heaps'Range loop
if Is_In (Storage_Address, Heaps (I)) then
return Unbounded_Allocator (Heaps (I)); -- found
end if;
end loop;
end;
raise Program_Error; -- not found
end Allocator_Of;
end System.Unbounded_Allocators;
|
-----------------------------------------------------------------------
-- Sessions Tests - Unit tests for Servlet.Sessions
-- Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2018, 2019, 2020, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Strings;
with Util.Test_Caller;
with Util.Measures;
with EL.Contexts.Default;
with Servlet.Streams;
with Servlet.Routes.Servlets;
with Servlet.Requests.Mockup;
with Servlet.Responses.Mockup;
with Servlet.Parts;
with Servlet.Filters.Dump;
with Servlet.Filters.Cache_Control;
with Servlet.Filters.Tests;
with Servlet.Resolvers;
with Servlet.Core.Configs;
with Servlet.Routes.Servlets.Faces;
package body Servlet.Core.Tests is
use Util.Tests;
-- ------------------------------
-- Get the value identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Form_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "email" then
return Util.Beans.Objects.To_Object (From.Email);
elsif Name = "password" then
return Util.Beans.Objects.To_Object (From.Password);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (From.Name);
elsif Name = "gender" then
return Util.Beans.Objects.To_Object (From.Gender);
elsif Name = "called" then
return Util.Beans.Objects.To_Object (From.Called);
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- 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) is
begin
if Name = "email" then
From.Email := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "password" then
From.Password := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "name" then
From.Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "gender" then
From.Gender := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
procedure Do_Get (Server : in Test_Servlet1;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class) is
ELContext : aliased EL.Contexts.Default.Default_Context;
Root_Resolver : aliased Resolvers.ELResolver;
Output : Streams.Print_Stream := Response.Get_Output_Stream;
begin
-- Minimal setting for the EL context creation to inject URI parameters in an Ada bean.
Root_Resolver.Initialize (null, Request'Unchecked_Access);
ELContext.Set_Resolver (Root_Resolver'Unchecked_Access);
Request.Inject_Parameters (ELContext);
if Server.Add_Resource then
Response.Set_Header ("Resource", Request.Get_Resource ("/tests/form-text.xhtml"));
end if;
Output.Write ("URI: " & Request.Get_Request_URI);
Response.Set_Status (Responses.SC_OK);
end Do_Get;
procedure Do_Post (Server : in Test_Servlet2;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class) is
pragma Unreferenced (Server);
procedure Process (Part : in Parts.Part'Class);
procedure Process (Part : in Parts.Part'Class) is
begin
Response.Set_Content_Type (Part.Get_Content_Type);
end Process;
begin
if Request.Get_Part_Count > 0 then
Response.Set_Header ("Part_Count", Util.Strings.Image (Request.Get_Part_Count));
Request.Process_Part (1, Process'Access);
end if;
end Do_Post;
procedure Do_Get (Server : in Test_Servlet3;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class) is
pragma Unreferenced (Request, Response);
begin
if Server.Raise_Exception then
raise Constraint_Error with "fake constraint error from servlet";
end if;
end Do_Get;
S1 : aliased Test_Servlet1;
S2 : aliased Test_Servlet2;
-- ------------------------------
-- 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) is
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => URI);
Req : Requests.Mockup.Request;
Resp : Responses.Mockup.Response;
Result : Unbounded_String;
begin
T.Assert (not Dispatcher.Context.Is_Null, "No mapping found for " & URI);
Req.Set_Request_URI ("test1");
Req.Set_Method ("GET");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Servlet_Path, Req.Get_Servlet_Path, "Invalid servlet path");
Assert_Equals (T, Path_Info, Req.Get_Path_Info,
"The request path info is invalid");
-- Check the response after the Test_Servlet1.Do_Get method execution.
Resp.Read_Content (Result);
Assert_Equals (T, Responses.SC_OK, Resp.Get_Status, "Invalid status");
Assert_Equals (T, "URI: test1", Result, "Invalid content");
Req.Set_Method ("POST");
Forward (Dispatcher, Req, Resp);
-- Assert_Equals (T, Responses.SC_METHOD_NOT_ALLOWED, Resp.Get_Status,
-- "Invalid status for an operation not implemented");
Req.Set_Method ("PUT");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Responses.SC_METHOD_NOT_ALLOWED, Resp.Get_Status,
"Invalid status for an operation not implemented");
Req.Set_Method ("DELETE");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Responses.SC_METHOD_NOT_ALLOWED, Resp.Get_Status,
"Invalid status for an operation not implemented");
Req.Set_Method ("OPTIONS");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Responses.SC_METHOD_NOT_ALLOWED, Resp.Get_Status,
"Invalid status for an operation not implemented");
Req.Set_Method ("TRACE");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Responses.SC_METHOD_NOT_ALLOWED, Resp.Get_Status,
"Invalid status for an operation not implemented");
Req.Set_Method ("PATCH");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Responses.SC_METHOD_NOT_ALLOWED, Resp.Get_Status,
"Invalid status for an operation not implemented");
Req.Set_Method ("CONNECT");
Forward (Dispatcher, Req, Resp);
Assert_Equals (T, Responses.SC_NOT_IMPLEMENTED, Resp.Get_Status,
"Invalid status for an operation not implemented");
end Check_Request;
-- ------------------------------
-- Test request dispatcher and servlet invocation
-- ------------------------------
procedure Test_Request_Dispatcher (T : in out Test) is
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Mapping (Pattern => "*.jsf", Name => "Faces");
Ctx.Add_Mapping (Pattern => "/p1/p2/p3/*", Name => "Faces");
Check_Request (T, Ctx, "/home/test.jsf", "/home/test.jsf", "");
end Test_Request_Dispatcher;
-- ------------------------------
-- Test mapping and servlet path on a request.
-- ------------------------------
procedure Test_Servlet_Path (T : in out Test) is
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Mapping (Pattern => "*.jsf", Name => "Faces");
Ctx.Add_Mapping (Pattern => "/p1/p2/p3/*", Name => "Faces");
Check_Request (T, Ctx, "/p1/p2/p3/home/test.html", "/p1/p2/p3", "/home/test.html");
Check_Request (T, Ctx, "/root/home/test.jsf", "/root/home/test.jsf", "");
Check_Request (T, Ctx, "/test.jsf", "/test.jsf", "");
end Test_Servlet_Path;
-- ------------------------------
-- Test mapping and servlet path on a request.
-- ------------------------------
procedure Test_Filter_Mapping (T : in out Test) is
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
S2 : aliased Test_Servlet2;
F1 : aliased Filters.Dump.Dump_Filter;
F2 : aliased Filters.Dump.Dump_Filter;
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Servlet ("Json", S2'Unchecked_Access);
Ctx.Add_Filter ("Dump", F1'Unchecked_Access);
Ctx.Add_Filter ("Dump2", F2'Unchecked_Access);
Ctx.Add_Mapping (Pattern => "*.html", Name => "Faces");
Ctx.Add_Mapping (Pattern => "*.json", Name => "Json");
Ctx.Add_Filter_Mapping (Pattern => "/dump/file.html", Name => "Dump");
Ctx.Add_Filter_Mapping (Pattern => "/dump/result/test.html", Name => "Dump");
Ctx.Add_Filter_Mapping (Pattern => "/dump/result/test.html", Name => "Dump2");
Ctx.Start;
T.Check_Mapping (Ctx, "test.html", S1'Unchecked_Access);
T.Check_Mapping (Ctx, "file.html", S1'Unchecked_Access);
T.Check_Mapping (Ctx, "/dump/test.html", S1'Unchecked_Access);
T.Check_Mapping (Ctx, "/dump/file.html", S1'Unchecked_Access, 1);
T.Check_Mapping (Ctx, "/dump/result/test.html", S1'Unchecked_Access, 2);
T.Check_Mapping (Ctx, "test.json", S2'Unchecked_Access);
end Test_Filter_Mapping;
-- ------------------------------
-- Test execution of filters
-- ------------------------------
procedure Test_Filter_Execution (T : in out Test) is
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
S2 : aliased Test_Servlet2;
F1 : aliased Filters.Tests.Test_Filter;
F2 : aliased Filters.Tests.Test_Filter;
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Servlet ("Json", S2'Unchecked_Access);
Ctx.Add_Filter ("F1", F1'Unchecked_Access);
Ctx.Add_Filter ("F2", F2'Unchecked_Access);
Ctx.Add_Mapping (Pattern => "*.html", Name => "Faces");
Ctx.Add_Mapping (Pattern => "*.json", Name => "Json");
Ctx.Add_Filter_Mapping (Pattern => "/html/*.html", Name => "F1");
Ctx.Add_Filter_Mapping (Pattern => "/json/*.json", Name => "F2");
Ctx.Add_Filter_Mapping (Pattern => "/list/*.html", Name => "F1");
Ctx.Add_Filter_Mapping (Pattern => "/list/*.json", Name => "F1");
Ctx.Add_Filter_Mapping (Pattern => "/list/admin/*.html", Name => "F2");
Ctx.Add_Filter_Mapping (Pattern => "/list/admin/*.json", Name => "F2");
Ctx.Start;
Ctx.Dump_Routes (Util.Log.INFO_LEVEL);
-- Filter not traversed.
T.Check_Mapping (Ctx, "test.html", S1'Unchecked_Access);
T.Check_Mapping (Ctx, "test.json", S2'Unchecked_Access);
T.Check_Request (Ctx, "test.html", "test.html", "");
Assert_Equals (T, 0, F1.Counter, "Filter was not executed for *.html and *.json");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for *.html and *.json");
T.Check_Mapping (Ctx, "/html/test.json", S2'Unchecked_Access);
T.Check_Request (Ctx, "/html/test.json", "/html/test.json", "");
Assert_Equals (T, 0, F1.Counter, "Filter was executed for /html/*.json");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for /html/*.json");
T.Check_Mapping (Ctx, "/json/test.html", S1'Unchecked_Access);
T.Check_Request (Ctx, "/json/test.html", "/json/test.html", "");
Assert_Equals (T, 0, F1.Counter, "Filter was not executed for /json/*.html");
Assert_Equals (T, 0, F2.Counter, "Filter was executed for /json/*.html");
-- Only one filter is traversed.
F1.Counter := 0;
F2.Counter := 0;
T.Check_Mapping (Ctx, "/html/test.html", S1'Unchecked_Access, 1);
T.Check_Request (Ctx, "/html/test.html", "/html/test.html", "");
Assert_Equals (T, 8, F1.Counter, "Filter was executed for /html/*.html");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for /html/*.html");
F1.Counter := 0;
F2.Counter := 0;
T.Check_Mapping (Ctx, "/json/test.json", S2'Unchecked_Access, 1);
T.Check_Request (Ctx, "/json/test.json", "/json/test.json", "");
Assert_Equals (T, 0, F1.Counter, "Filter was not executed for /json/*.json");
Assert_Equals (T, 8, F2.Counter, "Filter was executed for /json/*.json");
F1.Counter := 0;
F2.Counter := 0;
T.Check_Mapping (Ctx, "/list/test.html", S1'Unchecked_Access, 1);
T.Check_Request (Ctx, "/list/test.html", "/list/test.html", "");
Assert_Equals (T, 8, F1.Counter, "Filter was executed for /list/*.html");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for /list/*.html");
F1.Counter := 0;
F2.Counter := 0;
T.Check_Mapping (Ctx, "/list/test.json", S2'Unchecked_Access, 1);
T.Check_Request (Ctx, "/list/test.json", "/list/test.json", "");
Assert_Equals (T, 8, F1.Counter, "Filter was executed for /list/*.json");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for /list/*.json");
-- Both filters are traversed.
F1.Counter := 0;
F2.Counter := 0;
T.Check_Mapping (Ctx, "/list/admin/test.json", S2'Unchecked_Access, 2);
T.Check_Request (Ctx, "/list/admin/test.json", "/list/admin/test.json", "");
Assert_Equals (T, 8, F1.Counter, "Filter was executed for /list/admin/*.json");
Assert_Equals (T, 8, F2.Counter, "Filter was executed for /list/admin/*.json");
F1.Counter := 0;
F2.Counter := 0;
T.Check_Mapping (Ctx, "/list/admin/test.html", S1'Unchecked_Access, 2);
T.Check_Request (Ctx, "/list/admin/test.html", "/list/admin/test.html", "");
Assert_Equals (T, 8, F1.Counter, "Filter was executed for /list/admin/*.html");
Assert_Equals (T, 8, F2.Counter, "Filter was executed for /list/admin/*.html");
end Test_Filter_Execution;
-- ------------------------------
-- Test execution of filters on complex mapping.
-- ------------------------------
procedure Test_Complex_Filter_Execution (T : in out Test) is
use Util.Beans.Objects;
procedure Insert (Route : in out Routes.Route_Type_Ref);
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
F1 : aliased Filters.Tests.Test_Filter;
F2 : aliased Filters.Tests.Test_Filter;
User : aliased Form_Bean;
EL_Ctx : EL.Contexts.Default.Default_Context;
Request : Requests.Mockup.Request;
Reply : Responses.Mockup.Response;
procedure Insert (Route : in out Routes.Route_Type_Ref) is
To : Routes.Servlets.Faces.Faces_Route_Type_Access;
begin
To := new Routes.Servlets.Faces.Faces_Route_Type;
To.Servlet := S1'Unchecked_Access;
Route := Routes.Route_Type_Refs.Create (To.all'Access);
end Insert;
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Filter ("F1", F1'Unchecked_Access);
Ctx.Add_Filter ("F2", F2'Unchecked_Access);
Ctx.Add_Route (Pattern => "/wikis/#{user.name}/#{user.email}/view.html",
ELContext => EL_Ctx,
Process => Insert'Access);
Ctx.Add_Route (Pattern => "/wikis/#{user.name}/#{user.email}/view",
ELContext => EL_Ctx,
Process => Insert'Access);
Ctx.Add_Mapping (Pattern => "/wikis/*.html", Name => "Faces");
Ctx.Add_Filter_Mapping (Pattern => "/wikis/*", Name => "F1");
Ctx.Add_Filter_Mapping (Pattern => "/wikis/admin/*", Name => "F2");
Ctx.Start;
Ctx.Dump_Routes (Util.Log.INFO_LEVEL);
Request.Set_Attribute ("user",
To_Object (Value => User'Unchecked_Access, Storage => STATIC));
Request.Set_Method ("GET");
declare
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => "/wikis/Gandalf/Mithrandir/view.html");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
Request.Set_Request_URI ("/wikis/Gandalf/Mithrandir/view.html");
Forward (Dispatcher, Request, Reply);
-- Check the response after the Test_Servlet1.Do_Get method execution.
Reply.Read_Content (Result);
Assert_Equals (T, Responses.SC_OK, Reply.Get_Status, "Invalid status");
Assert_Equals (T, "URI: /wikis/Gandalf/Mithrandir/view.html", Result, "Invalid content");
Assert_Equals (T, "Gandalf", User.Name, "User name was not extracted from the URI");
-- And verify that the filter are traversed.
Assert_Equals (T, 1, F1.Counter, "Filter was executed for /html/*.html");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for /html/*.html");
end;
F1.Counter := 0;
declare
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => "/wikis/Gandalf/Mithrandir/view");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
User.Name := Ada.Strings.Unbounded.To_Unbounded_String ("");
Request.Set_Request_URI ("/wikis/Gandalf/Mithrandir/view");
Forward (Dispatcher, Request, Reply);
-- Check the response after the Test_Servlet1.Do_Get method execution.
Reply.Read_Content (Result);
Assert_Equals (T, Responses.SC_OK, Reply.Get_Status, "Invalid status");
Assert_Equals (T, "URI: /wikis/Gandalf/Mithrandir/view", Result, "Invalid content");
Assert_Equals (T, "Gandalf", User.Name, "User name was not extracted from the URI");
-- And verify that the filter are traversed.
Assert_Equals (T, 1, F1.Counter, "Filter was executed for /html/*.html");
Assert_Equals (T, 0, F2.Counter, "Filter was not executed for /html/*.html");
end;
end Test_Complex_Filter_Execution;
-- ------------------------------
-- Test execution of the cache control filter.
-- ------------------------------
procedure Test_Cache_Control_Filter (T : in out Test) is
use Util.Beans.Objects;
procedure Insert (Route : in out Routes.Route_Type_Ref);
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
F1 : aliased Filters.Cache_Control.Cache_Control_Filter;
F2 : aliased Filters.Cache_Control.Cache_Control_Filter;
User : aliased Form_Bean;
EL_Ctx : EL.Contexts.Default.Default_Context;
Request : Requests.Mockup.Request;
procedure Insert (Route : in out Routes.Route_Type_Ref) is
To : Routes.Servlets.Faces.Faces_Route_Type_Access;
begin
To := new Routes.Servlets.Faces.Faces_Route_Type;
To.Servlet := S1'Unchecked_Access;
Route := Routes.Route_Type_Refs.Create (To.all'Access);
end Insert;
begin
Ctx.Set_Init_Parameter ("F1." & Filters.Cache_Control.CACHE_CONTROL_PARAM, "no-cache");
Ctx.Set_Init_Parameter ("F2." & Filters.Cache_Control.CACHE_CONTROL_PARAM,
"max-age: 10");
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Filter ("F1", F1'Unchecked_Access);
Ctx.Add_Route (Pattern => "/wikis/no-cache/view.html",
ELContext => EL_Ctx,
Process => Insert'Access);
Ctx.Add_Filter ("F2", F2'Unchecked_Access);
Ctx.Add_Route (Pattern => "/wikis/cache/view.html",
ELContext => EL_Ctx,
Process => Insert'Access);
Ctx.Add_Filter_Mapping (Pattern => "/wikis/no-cache/*", Name => "F1");
Ctx.Add_Filter_Mapping (Pattern => "/wikis/cache/*", Name => "F2");
Ctx.Start;
Request.Set_Attribute ("user",
To_Object (Value => User'Unchecked_Access, Storage => STATIC));
Request.Set_Method ("GET");
declare
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => "/wikis/no-cache/view.html");
Result : Ada.Strings.Unbounded.Unbounded_String;
Reply : Responses.Mockup.Response;
begin
Request.Set_Request_URI ("/wikis/no-cache/view.html");
Forward (Dispatcher, Request, Reply);
-- Check the response after the Test_Servlet1.Do_Get method execution.
Reply.Read_Content (Result);
Assert_Equals (T, Responses.SC_OK, Reply.Get_Status, "Invalid status");
T.Assert (Reply.Contains_Header ("Cache-Control"),
"A Cache-Control is missing in the response");
Assert_Equals (T, "no-cache", Reply.Get_Header ("Cache-Control"),
"Invalid Cache-Control header");
end;
declare
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => "/wikis/cache/view.html");
Result : Ada.Strings.Unbounded.Unbounded_String;
Reply : Responses.Mockup.Response;
begin
Request.Set_Request_URI ("/wikis/cache/view.html");
Forward (Dispatcher, Request, Reply);
-- Check the response after the Test_Servlet1.Do_Get method execution.
Reply.Read_Content (Result);
Assert_Equals (T, Responses.SC_OK, Reply.Get_Status, "Invalid status");
T.Assert (Reply.Contains_Header ("Cache-Control"),
"A Cache-Control is missing in the response");
Assert_Equals (T, "max-age: 10", Reply.Get_Header ("Cache-Control"),
"Invalid Cache-Control header");
end;
end Test_Cache_Control_Filter;
-- ------------------------------
-- Test add servlet
-- ------------------------------
procedure Test_Add_Servlet (T : in out Test) is
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Assert_Equals (T, "Faces", S1.Get_Name, "Invalid name for the servlet");
begin
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
T.Assert (False, "No exception raised if the servlet is registered several times");
exception
when Servlet_Error =>
null;
end;
end Test_Add_Servlet;
-- ------------------------------
-- Test getting a resource path
-- ------------------------------
procedure Test_Get_Resource (T : in out Test) is
Ctx : Servlet_Registry;
Conf : Util.Properties.Manager;
S1 : aliased Test_Servlet1;
Dir : constant String := "regtests/files";
Path : constant String := Util.Tests.Get_Path (Dir);
Request : Requests.Mockup.Request;
begin
S1.Add_Resource := True;
Conf.Load_Properties ("regtests/view.properties");
Conf.Set ("view.dir", Path);
Ctx.Set_Init_Parameters (Conf);
Ctx.Add_Servlet ("Faces", S1'Unchecked_Access);
Ctx.Add_Mapping (Pattern => "/wikis/*", Name => "Faces");
-- Resource exist, check the returned path.
declare
P : constant String := Ctx.Get_Resource ("/tests/form-text.xhtml");
begin
Assert_Matches (T, ".*/regtests/files/tests/form-text.xhtml",
P, "Invalid resource path");
end;
-- Resource does not exist
declare
P : constant String := Ctx.Get_Resource ("/tests/form-text-missing.xhtml");
begin
Assert_Equals (T, "", P, "Invalid resource path for missing resource");
end;
declare
Reply : Responses.Mockup.Response;
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => "/wikis/no-cache/view.html");
begin
Request.Set_Method ("GET");
Request.Set_Request_URI ("/wikis/no-cache/view.html");
Forward (Dispatcher, Request, Reply);
-- Check the response after the Test_Servlet1.Do_Get method execution.
Assert_Equals (T, Responses.SC_OK, Reply.Get_Status, "Invalid status");
T.Assert (Reply.Contains_Header ("Resource"),
"A Resource header is missing in the response");
Assert_Matches (T, ".*/regtests/files/tests/form-text.xhtml",
Reply.Get_Header ("Resource"), "Invalid resource path");
end;
end Test_Get_Resource;
-- ------------------------------
-- Test reading XML configuration file.
-- ------------------------------
procedure Test_Read_Configuration (T : in out Test) is
Ctx : Servlet_Registry;
Dir : constant String := Util.Tests.Get_Path ("regtests/config/");
begin
Core.Configs.Read_Configuration (Ctx, Dir & "empty.xml");
Util.Tests.Assert_Equals (T, "", String '(Ctx.Get_Init_Parameter ("content-type.default")),
"Parameter 'content-type.default' must be "
& "empty after Read_Configuration");
T.Assert (Ctx.Error_Pages.Is_Empty, "There is no error page configuration");
Core.Configs.Read_Configuration (Ctx, Dir & "test-config.xml");
Util.Tests.Assert_Equals (T, "text/plain",
String '(Ctx.Get_Init_Parameter ("content-type.default")),
"Parameter 'content-type.default' must be set "
& "after Read_Configuration");
T.Assert (not Ctx.Error_Pages.Is_Empty, "There is some error page configuration");
T.Assert (Ctx.Error_Pages.Contains (404), "The 404 error have an error page configured");
Util.Tests.Assert_Equals (T, "/tests/404.html", Ctx.Error_Pages.Element (404),
"Invalid 404 error page");
Core.Configs.Read_Configuration (Ctx, Dir & "test-error.xml");
end Test_Read_Configuration;
-- ------------------------------
-- Test the Get_Name_Dispatcher.
-- ------------------------------
procedure Test_Name_Dispatcher (T : in out Test) is
Ctx : Servlet_Registry;
S1 : aliased Test_Servlet1;
S2 : aliased Test_Servlet1;
begin
Ctx.Add_Servlet (Name => "Faces", Server => S1'Unchecked_Access);
Ctx.Add_Servlet (Name => "Text", Server => S2'Unchecked_Access);
declare
Disp : constant Request_Dispatcher := Ctx.Get_Name_Dispatcher ("Faces");
begin
T.Assert (Get_Servlet (Disp) /= null, "Get_Name_Dispatcher returned null");
end;
begin
-- Use local declared variable to avoid a bug in init/finalization by GNAT 2019.
declare
D : constant Request_Dispatcher := Ctx.Get_Name_Dispatcher ("wrong-servlet");
begin
T.Assert (Get_Servlet (D) = null,
"Get_Name_Dispatcher returned something!");
T.Fail ("No Servlet_Error exception was raised by Get_Name_Dispatcher");
end;
exception
when Servlet_Error =>
null;
end;
end Test_Name_Dispatcher;
-- ------------------------------
-- 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) is
use Routes.Servlets;
Disp : constant Request_Dispatcher := Ctx.Get_Request_Dispatcher (URI);
Route : constant Routes.Route_Type_Ref := Disp.Context.Get_Route;
begin
if Server = null then
T.Assert (Route.Is_Null, "No mapping returned for URI: " & URI);
else
T.Assert (not Route.Is_Null, "A mapping is returned for URI: " & URI);
T.Assert (Route.Value in Routes.Servlets.Servlet_Route_Type'Class,
"The route is not a Servlet route");
T.Assert (Servlet_Route_Type'Class (Route.Value.Element.all).Servlet = Server,
"Invalid mapping returned for URI: " & URI);
if Filter = 0 then
T.Assert (Disp.Filters = null,
"Filters are configured for URI: " & URI);
else
T.Assert (Disp.Filters /= null, "No filter on the route URI: " & URI);
Util.Tests.Assert_Equals (T, Filter, Disp.Filters'Length,
"Invalid mapping returned for URI: " & URI);
end if;
T.Assert (Get_Servlet (Disp) /= null, "A null servlet is returned by Get_Servlet");
T.Assert (Get_Servlet (Disp) = Servlet_Route_Type'Class (Route.Value.Element.all).Servlet,
"Invalid servlet returned by Get_Servlet");
end if;
end Check_Mapping;
-- ------------------------------
-- Test session creation.
-- ------------------------------
procedure Test_Create_Servlet (T : in out Test) is
Ctx : Servlet_Registry;
begin
Ctx.Add_Servlet (Name => "Faces", Server => S1'Access);
Ctx.Add_Servlet (Name => "Text", Server => S2'Access);
Ctx.Add_Mapping (Pattern => "*.jsf", Name => "Faces");
Ctx.Add_Mapping (Pattern => "*.html", Name => "Faces");
Ctx.Add_Mapping (Pattern => "*.txt", Name => "Text");
-- Ctx.Add_Mapping (Pattern => "/server", Server => S2'Access);
Ctx.Add_Mapping (Pattern => "/server/john/*", Server => S2'Access);
Ctx.Add_Mapping (Pattern => "/server/info", Server => S1'Access);
Ctx.Add_Mapping (Pattern => "/server/list", Server => S1'Access);
Ctx.Add_Mapping (Pattern => "/server/list2", Server => S2'Access);
Ctx.Add_Mapping (Pattern => "/1/2/3/4/5/6/7/8/9/server/list2", Server => S2'Access);
Ctx.Add_Mapping (Pattern => "/1/2/3/4/5/6/7/8/A/server/list2", Server => S1'Access);
-- Ctx.Mappings.Dump_Map (" ");
T.Check_Mapping (Ctx, "/joe/black/joe.jsf", S1'Access);
T.Check_Mapping (Ctx, "/joe/black/joe.txt", S2'Access);
T.Check_Mapping (Ctx, "/server/info", S1'Access);
T.Check_Mapping (Ctx, "/server/list2", S2'Access);
T.Check_Mapping (Ctx, "/1/2/3/4/5/6/7/8/9/server/list2", S2'Access);
T.Check_Mapping (Ctx, "/1/2/3/4/5/6/7/8/A/server/list2", S1'Access);
declare
St : Util.Measures.Stamp;
begin
for I in 1 .. 1000 loop
declare
Disp : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => "/joe/black/joe.jsf");
begin
T.Assert (not Disp.Context.Is_Null,
"No mapping found for /joe/black/joe.jsf");
end;
end loop;
Util.Measures.Report (St, "Find 1000 mapping (extension)");
end;
-- T.Assert (Map /= null, "No mapping for 'joe.jsf'");
-- T.Assert (Map.Servlet /= null, "No servlet for mapping for 'joe.jsf'");
-- T.Assert (Map.Servlet = S1'Access, "Invalid servlet");
-- Util.Measures.Report (St, "10 Session create");
-- declare
-- St : Util.Measures.Stamp;
-- begin
-- for I in 1 .. 1000 loop
-- Map := Ctx.Find_Mapping (URI => "/1/2/3/4/5/6/7/8/9/server/list2");
-- end loop;
-- Util.Measures.Report (St, "Find 1000 mapping (path)");
-- end;
--
-- T.Assert (Map /= null, "No mapping for '/server/john/joe.jsf'");
-- T.Assert (Map.Servlet /= null, "No servlet for mapping for 'joe.jsf'");
-- T.Assert (Map.Servlet = S2'Access, "Invalid servlet");
-- Util.Measures.Report (St, "10 Session create");
end Test_Create_Servlet;
package Caller is new Util.Test_Caller (Test, "Core");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
-- To document what is tested, register the test methods for each
-- operation that is tested.
Caller.Add_Test (Suite, "Test Servlet.Core.Add_Mapping,Find_Mapping",
Test_Create_Servlet'Access);
Caller.Add_Test (Suite, "Test Servlet.Core.Add_Servlet",
Test_Add_Servlet'Access);
Caller.Add_Test (Suite, "Test Servlet.Core.Get_Request_Dispatcher",
Test_Request_Dispatcher'Access);
Caller.Add_Test (Suite, "Test Servlet.Core.Get_Resource",
Test_Get_Resource'Access);
Caller.Add_Test (Suite, "Test Servlet.Core.Read_Configuration",
Test_Read_Configuration'Access);
Caller.Add_Test (Suite, "Test Servlet.Core.Get_Name_Dispatcher",
Test_Name_Dispatcher'Access);
Caller.Add_Test (Suite, "Test Servlet.Requests.Get_Servlet_Path",
Test_Servlet_Path'Access);
Caller.Add_Test (Suite, "Test Servlet.Core.Add_Filter",
Test_Filter_Mapping'Access);
Caller.Add_Test (Suite, "Test Servlet.Filters.Do_Filter",
Test_Filter_Execution'Access);
Caller.Add_Test (Suite, "Test Servlet.Filters.Do_Filter (complex)",
Test_Complex_Filter_Execution'Access);
Caller.Add_Test (Suite, "Test Servlet.Filters.Cache_Control.Do_Filter",
Test_Cache_Control_Filter'Access);
end Add_Tests;
end Servlet.Core.Tests;
|
--
-- Copyright 2021 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
-- private with Edc_Client.Alpha.Common;
private with Edc_Client.Alpha.Common;
package body Edc_Client.Alpha.Block1 is
Block : constant Character := '1';
--------------------------------------------------------------------------
-- see .ads
procedure Show_Single_Letter (Position : Single_Letter_Positions;
Value : Single_Letter_String) is
begin
Edc_Client.Alpha.Common.Show_Single_Letter (Position => Position,
Block => Block,
Value => Value);
end Show_Single_Letter;
--------------------------------------------------------------------------
-- see .ads
procedure Show_Double_Letters (Position : Double_Letters_Positions;
Value : Double_Letters_String) is
begin
Edc_Client.Alpha.Common.Show_Double_Letters (Position => Position,
Block => Block,
Value => Value);
end Show_Double_Letters;
--------------------------------------------------------------------------
-- see .ads
procedure Show_Four_Letters (Position : Four_Letters_Positions;
Value : Four_Letters_String) is
begin
Edc_Client.Alpha.Common.Show_Four_Letters (Position => Position,
Block => Block,
Value => Value);
end Show_Four_Letters;
--------------------------------------------------------------------------
-- see .ads
procedure Show_Eight_Letters (Value : Eight_Letters_String) is
Command : Cmd_Eight_Letters_String := "A1D1CCCCCCCC";
begin
Command (2) := Block;
Command (5 .. 12) := Value (1 .. 8);
Transmitter (Command);
end Show_Eight_Letters;
end Edc_Client.Alpha.Block1;
|
with Lto9_Pkg2;
package Lto9_Pkg1 is
subtype Lengths is Natural range 0 .. 50;
type Subscriber (NLen, ALen: Lengths := 50) is record
Name : String(1 .. NLen);
Address : String(1 .. ALen);
end record;
type Subscriber_Ptr is access all Subscriber;
package District_Subscription_Lists is new Lto9_Pkg2
(Element_Type => Subscriber,
Element_Ptr => Subscriber_Ptr,
Size => 100);
District_01_Subscribers : District_Subscription_Lists.List_Type;
New_Subscriber_01 : aliased Subscriber :=
(12, 23, "Brown, Silas", "King's Pyland, Dartmoor");
end Lto9_Pkg1;
|
-- part of FreeTypeAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with FT.Faces;
package FT.Utilities is
procedure Print_Bitmap_Metadata (Bitmap : FT.Bitmap_Record);
procedure Print_Character_Metadata (aFace : FT.Faces.Face_Reference;
aChar : Character);
end FT.Utilities;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.