content
stringlengths 23
1.05M
|
|---|
with ada.text_io; use ada.text_io;
with screen; use screen;
with NPC_PC; use NPC_PC;
with enemy_bst; use enemy_bst;
with intro; use intro;
with w_gen; use w_gen;
with list_lib; use list_lib;
procedure adventure is
-----------------------------------------------
-- Name: Jon Spohn
-- David Rogina
-- Date: 4/20/07
-- The Legend of Zelba: Wink's Awakening
-- Hello, This is our final game project.
-- It is titled after The Legend of Zelda: Link's Awakening.
-- This program makes use of a few advanced data structures such
-- as a Linked List and a Binary Search Tree to hold the games
-- objectives. The object of the game is to go through the dungeon
-- kill all the monsters and collect all the keys (which have to be done
-- in a specific order). Once these objectives are done you will get the
-- Thank you screen and the credits. Directions on how to play are provided
-- in a welcome start up screen.
-- NOTE: The provided w_gen package and screen package are included.
-- However only one procedure was used from the to help clear the
-- Screen, but the procedures are still included. Same as the BST
-- packages were modified to be used in this game and some procedures
-- are left in them that are not used in the program.
-----------------------------------------------
map:map_array; --map of dungeon
file:file_type; --file input variable
choice : character := 'o'; --character to advance pause screen
Hero : HeroClass; --hero record
ET : EnemyTree; --enemy record
List : LL_Type; --Key List
begin --game
--Opening Title Screen
open(file,in_file,"Zelba.txt");
title_page(file);
close(file);
w_gen.clr_scr;
--Welcome Screen/Story/Instructions
open(file,in_file,"Welcome.txt");
title_page(file);
close(file);
w_gen.clr_scr;
--Create enemies and create map array
InitLL(List);
Initialize(ET);
open(file,in_file,"Map.txt");
map_input(file,map,Hero,et,List);
print_map(map,hero);
new_line(spacing=>5);
--Play game while hero health > 0 and
while((choice /= 'g' and (GetHeroH(Hero) > 0)) and (isNull(et) /= 0 or noKey(list) /= 0)) loop
--menu
put_line("*************");
put_line("(v)iew stats");
put_line("(w) move north");
put_line("(s) move south");
put_line("(a) move west");
put_line("(d) move east");
put_line("(g)ive up like a scared little girl.");
put_line("*************");
put("Choice: ");
get(choice);
--move character on map
if (choice = 'w' or choice = 'a' or choice = 's' or choice = 'd') then
Move(choice,map,Hero,et,list);
--view character stats
elsif choice = 'v' then
Viewstats(Hero);
end if;
--clear and redraw screen with updated info
w_gen.clr_scr;
print_map(map,hero);
new_line(spacing=>5);
end loop;
w_gen.clr_scr;
close(file);
if isNull(et) = 0 then
open(file,in_file,"Win.txt");
title_page(file);
close(file);
end if;
end adventure;
|
-- Generic Buffer
-- Author: Emanuel Regnath (emanuel.regnath@tum.de)
-- Can be used as ring buffer or queue
-- FIXME: consider SPARK formal containers to replace this
-- Note: Since this used OO features (class-wide types), the Liskov Subsitution Principle (LSP)
-- applies. That is, all contracts on primitives of the derived types must be *weaker*
-- than the contracts given here, so that the derived types can always safely be substituted
-- with the base type.
-- For that reason, all contracts given here must apply to the class-wide type (denoted by
-- Pre'Class, Post'Class, etc.)
-- To avoid this, remove "tagged".
generic
type Index_Type is mod <>;
type Element_Type is private;
package Generic_Queue with SPARK_Mode is
subtype Length_Type is Natural range 0 .. Integer( Index_Type'Last ) + 1;
type Element_Array is array (Length_Type range <>) of Element_Type;
type Mode_Type is (RING, QUEUE);
type Buffer_Element_Array is private;
type Buffer_Tag is tagged private;
procedure clear( Self : in out Buffer_Tag )
with Post'Class => Self.Empty;
-- remove all elements
--procedure fill( Self : in out Buffer_Tag )
--with Post'Class => Self.Full;
-- FIXME: needs a value to fill with
procedure push_back( Self : in out Buffer_Tag; element : Element_Type )
with Post'Class => not Self.Empty;
-- append new element at back
procedure push_front( Self : in out Buffer_Tag; element : Element_Type )
with Post'Class => not Self.Empty;
-- prepend new element at front
procedure pop_front( Self : in out Buffer_Tag; element : out Element_Type )
with Pre'Class => not Self.Empty,
Post'Class => not Self.Full;
-- read and remove element at front
procedure pop_front( Self : in out Buffer_Tag; elements : out Element_Array )
with Pre'Class => elements'Length <= Self.Length;
-- read and remove n elements at front
-- entry pop_front_blocking( Self : in out Buffer_Tag; element : out Element_Type );
-- wait until buffer is not empty then read and remove element at front
procedure pop_back( Self : in out Buffer_Tag; element : out Element_Type)
with Pre'Class => not Self.Empty,
Post'Class => not Self.Full;
-- read and remove element at back
procedure pop_all( Self : in out Buffer_Tag; elements : out Element_Array )
with Pre'Class => elements'Length = Self.Length,
Post'Class => Self.Empty;
-- read and remove all elements, front first
procedure get_front( Self : in Buffer_Tag; element : out Element_Type )
with Pre'Class => not Self.Empty,
Post'Class => Self.Length = Self.Length'Old;
-- read first element at front
procedure get_front( Self : in Buffer_Tag; elements : out Element_Array )
with Pre'Class => elements'Length <= Self.Length,
Post'Class => Self.Length = Self.Length'Old;
-- read n elements at front
procedure get_back( Self : in Buffer_Tag; element : out Element_Type )
with Pre'Class => not Self.Empty,
Post'Class => Self.Length = Self.Length'Old;
-- read first element at back
procedure get_all( Self : in Buffer_Tag; elements : out Element_Array )
with Pre'Class => elements'Length = Self.Length,
Post'Class => Self.Length = Self.Length'Old;
-- read all elements, front first
procedure get_nth_first( Self : in Buffer_Tag; nth : Index_Type; element : out Element_Type)
with Post'Class => Self.Length = Self.Length'Old;
-- read nth element, nth = 0 is front
procedure get_nth_last( Self : in Buffer_Tag; nth : Index_Type; element : out Element_Type)
with Post'Class => Self.Length = Self.Length'Old;
-- read nth element, nth = 0 is back
function Length( Self : in Buffer_Tag) return Length_Type;
-- number of elements in buffer
function Empty( Self : in Buffer_Tag) return Boolean;
-- true if buffer is empty
function Full( Self : in Buffer_Tag) return Boolean;
-- true if buffer is full
function Overflows( Self : in Buffer_Tag) return Natural;
-- number of buffer overflows
private
type Buffer_Element_Array is array (Index_Type) of Element_Type;
type Buffer_Tag is tagged record
mode : Mode_Type := RING;
buffer : Buffer_Element_Array; -- := (others => Element_Type'First);
index_head : Index_Type := 0;
index_tail : Index_Type := 0;
hasElements : Boolean := False;
Num_Overflows : Natural := 0;
end record;
end Generic_Queue;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ implementation of builtin field types --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
with Ada.Containers;
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Containers.Hashed_Maps;
with Ada.Containers.Hashed_Sets;
with Ada.Containers.Vectors;
with Skill.Types;
with Skill.Hashes; use Skill.Hashes;
with Skill.Types.Pools;
with Ada.Tags;
package body Skill.Field_Types.Builtin.String_Type_P is
function Get_Id_Map (THis : access Field_Type_T) return ID_Map is
begin
return THis.String_IDs'Access;
end Get_Id_Map;
procedure Write_Box
(This : access Field_Type_T;
Output : Streams.Writer.Sub_Stream;
Target : Types.Box)
is
V : Types.String_Access := Unboxed (Target);
use type Types.String_Access;
begin
if null = V then
Output.I8 (0);
else
Output.V64 (Types.v64 (This.String_IDs.Element (V)));
end if;
end Write_Box;
procedure Write_Single_Field
(THis : access Field_Type_T;
V : Types.String_Access;
Output : Skill.Streams.Writer.Sub_Stream)
is
use type Types.String_Access;
begin
if null = V then
Output.I8 (0);
else
Output.V64 (Types.v64 (THis.String_IDs.Element (V)));
end if;
end Write_Single_Field;
end Skill.Field_Types.Builtin.String_Type_P;
|
------------------------------------------------------------------------------
-- --
-- Internet Protocol Suite Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains a set of OS-specific constants imported from system
-- header files for use in direct calls to the various system/libc calls
with Interfaces.C; use Interfaces.C;
pragma External_With ("inet-internal-os_constants-sys.c");
package INET.Internal.OS_Constants is
-----------
-- Types --
-----------
-- in_port_t --
subtype in_port_t is Interfaces.Unsigned_16;
-- socklen_t --
subtype socklen_t is Interfaces.C.unsigned;
-- POSIX says that socklen_t should be at a minimum a 32-bit unsigned value.
-- Most libraries apparently misattribute it to an "int". In any case,
-- we will check this with an assertion pragma, but deviation is probably
-- very rare
function sizeof_socklen_t return size_t with
Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_sizeof_socklen_t";
pragma Assert (Check => sizeof_socklen_t = (socklen_t'Size / 8),
Message => "socklen_t is not the expected size. "
& "INET.OS_Constants will need to be modified.");
-- ssize_t --
type ssize_t is new Interfaces.Integer_64;
function sizeof_ssize_t return size_t with
Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_sizeof_ssize_t";
pragma Assert (Check => sizeof_ssize_t = (ssize_t'Size / 8),
Message => "ssize_t is not the expected size. "
& "INET.OS_Constants will need to be modified.");
-- struct timespec --
-- See <sys/time.h>
type time_t is new Interfaces.Integer_64
with Convention => C;
-- Most systems will have this as Integer_64. Otherwise they are
-- susceptible to the Y2038 problem, which at the time of writing,
-- is "only" 18 years away.
--
-- It seems in most cases, it is only i386 that still uses a 32-bit
-- int. We will have a separate codepath for those cases for the time
-- being.
--
-- Note that the size of time_t will be implicitly checked when
-- the size of timespec is checked.
-- see clock_gettime(2) - posix
type timespec is
record
tv_sec : time_t;
tv_nsec: long;
end record
with Convention => C;
function sizeof_struct_timespec return size_t with
Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_sizeof_struct_timespec";
pragma Assert (Check => sizeof_struct_timespec = (timespec'Size / 8),
Message => "struct timespec is not the expected size. "
& "INET.OS_Constants will need to be modified.");
function To_Timespec (T: Duration) return timespec;
-- Converts an Ada duration value into the corresponding timeval struct
-- value
---------------
-- Constants --
---------------
-- Open(2) Flags --
O_RDWR: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_O_RDWR";
O_CLOEXEC: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_O_CLOEXEC";
-- Address Families --
AF_INET: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_AF_INET";
AF_INET6: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_AF_INET6";
AF_UNSPEC: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_AF_UNSPEC";
-- Protocol Families --
PF_INET: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_PF_INET";
PF_INET6: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_PF_INET6";
-- IPPROTO Values (getaddrinfo) <netinet/in.h> --
IPPROTO_TCP: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_IPPROTO_TCP";
IPPROTO_UDP: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_IPPROTO_UDP";
IPPROTO_SCTP: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_IPPROTO_SCTP";
-- Socket Types and Options --
SOCK_STREAM: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SOCK_STREAM";
SOCK_DGRAM: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SOCK_DGRAM";
SOCK_SEQPACKET: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SOCK_SEQPACKET";
SOCK_CLOEXEC: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SOCK_CLOEXEC";
SOCK_NONBLOCK: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SOCK_NONBLOCK";
SOL_SOCKET: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SOL_SOCKET";
-- Message flags --
MSG_PEEK: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_MSG_PEEK";
MSG_NOSIGNAL: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_MSG_NOSIGNAL";
-- Shutdown "hows" --
SHUT_RD: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SHUT_RD";
SHUT_WR: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SHUT_WR";
SHUT_RDWR: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_SHUT_RDWR";
-- Polling - poll(2) events flags --
POLLIN : constant short with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_POLLIN";
POLLOUT: constant short with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_POLLOUT";
-- getaddrinfo flags <netdb.h> --
AI_ADDRCONFIG: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_AI_ADDRCONFIG";
AI_CANONNAME: constant int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_AI_CANONNAME";
-- Errno
function Get_Errno return int with Import => True, Convention => C,
External_Name => "__inet_internal_os_constants_sys_get_errno";
end INET.Internal.OS_Constants;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with AWS.Log;
package GAWS_Log is
Log : AWS.Log.Object;
procedure Start;
procedure Stop;
procedure Flush;
procedure Put_Horizontal_Line (Length : in Natural := 60;
Marker : in Character := '-');
procedure Put_Line (Item : in String);
procedure Put_Register_Hosts (Success : in Boolean);
end GAWS_Log;
|
--
-----------------------------------------------------------------------
-- package Predictor_2, 20th order Predictor-Corrector
-- Copyright (C) 2008-2009 Jonathan S. Parker.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-----------------------------------------------------------------------
-- PACKAGE Predictor_2
--
-- 20th order Predictor-Corrector for conservative differential equations.
--
-- The program integrates (d/dt)**2 Y = F (t, Y) where t is the
-- independent variable (e.g. time), vector Y is the
-- dependent variable, and F is some function. Certain higher order
-- equations can be reduced to this form.
--
-- Notice that F in independent of dY/dt.
--
-- NOTES ON USE
--
-- The following version assumes that the Dynamical Variable is
-- a 1 dimensional array of Real numbers.
--
-- The user plugs in the function F(t,Y) as a generic formal function.
-- Even if F is t or Y independent, it must be in the form F(t,Y).
-- The user must do all of the work to convert higher order
-- equations to 2nd order equations.
--
generic
type Real is digits <>;
-- The independent variable. It's called Time
-- throughout the package as though the differential
-- equation dY/dt = F (t, Y) were time dependent.
type Dyn_Index is range <>;
type Dynamical_Variable is array(Dyn_Index) of Real;
-- The dependent variable.
-- We require its exact form here so that some inner loop
-- optimizations can be performed below.
with function F
(Time : Real;
Y : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Defines the equation to be integrated as
-- dY/dt = F (t, Y). Even if the equation is t or Y
-- independent, it must be entered in this form.
with function "*"
(Left : Real;
Right : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Defines multiplication of the independent by the
-- dependent variable. An operation of this sort must exist by
-- definition of the derivative, dY/dt = (Y(t+dt) - Y(t)) / dt,
-- which requires multiplication of the (inverse) independent
-- variable t, by the Dynamical variable Y (the dependent variable).
with function "+"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Defines summation of the dependent variable. Again, this
-- operation must exist by the definition of the derivative,
-- dY/dt = (Y(t+dt) - Y(t)) / dt = (Y(t+dt) + (-1)*Y(t)) / dt.
with function "-"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Operation must exist by the definition of the derivative,
-- dY/dt = (Y(t+dt) - Y(t)) / dt
package Predictor_2 is
-- You must init. all elements of array Initial_Y, Initial_deriv_Of_Y.
procedure Integrate
(Final_Y : out Dynamical_Variable;
Final_deriv_Of_Y : out Dynamical_Variable;
Final_Time : in Real;
Initial_Y : in Dynamical_Variable;
Initial_deriv_Of_Y : in Dynamical_Variable;
Initial_Time : in Real;
No_Of_Steps : in Real);
No_Of_Corrector_Evaluate_Iterations : constant Integer := 1;
-- 1 is good here.
Final_Corrector_Desired : constant Boolean := True;
-- True is good here.
Extrapolation_Desired : constant Boolean := True;
end Predictor_2;
|
-----------------------------------------------------------------------
-- hestia-main -- Hestia main program
-- Copyright (C) 2016, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Real_Time;
with STM32.Board;
with HAL.Bitmap;
with UI.Displays;
with Hestia.Network;
with Hestia.Display.Instances;
with Hestia.Ports;
-- The main EtherScope task must run at a lower priority as it takes care
-- of displaying results on the screen while the EtherScope receiver's task
-- waits for packets and analyzes them. All the hardware initialization must
-- be done here because STM32.SDRAM is not protected against concurrent accesses.
procedure Hestia.Main is -- with Priority => System.Priority'First is
use type Ada.Real_Time.Time;
use type Ada.Real_Time.Time_Span;
-- Display refresh period.
REFRESH_PERIOD : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (500);
-- The network processing deadline.
Net_Deadline : Ada.Real_Time.Time;
begin
-- Initialize the display and draw the main/fixed frames in both buffers.
UI.Displays.Initialize;
Hestia.Ports.Initialize;
-- Initialize and start the network stack.
Hestia.Network.Initialize;
UI.Displays.Push_Display (Hestia.Display.Instances.Display'Access);
-- Loop to retrieve the analysis and display them.
loop
declare
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Buffer : constant HAL.Bitmap.Any_Bitmap_Buffer := STM32.Board.Display.Hidden_Buffer (1);
Display : UI.Displays.Display_Access := UI.Displays.Current_Display;
begin
Display.Process_Event (Buffer.all, Now);
-- Refresh the display only when it needs.
Display := UI.Displays.Current_Display;
if Display.Need_Refresh (Now) then
Display.Refresh (Buffer.all);
end if;
Hestia.Network.Process (Net_Deadline);
delay until Now + Ada.Real_Time.Milliseconds (100);
end;
end loop;
end Hestia.Main;
|
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Containers.Indefinite_Ordered_Sets;
with Ada.Strings.Bounded;
package Symbolic_Identifiers is
Max_ID_Length : constant Positive := 256;
package Bounded_IDs is
new Ada.Strings.Bounded.Generic_Bounded_Length (Max_ID_Length);
subtype Bounded_ID is Bounded_IDs.Bounded_String;
-- A valid identifier:
-- * every character is a letter, a digit or an underscore
-- * the first character must be a letter
-- * the last character cannot be an underscore
-- * it cannot have two consecutive underscores
function Is_Valid_Simple_Name (X : String) return Boolean
is (
(X'Length > 0)
and then (Is_Letter (X (X'First))
and Is_Alphanumeric (X (X'Last)))
and then (for all I in X'Range =>
(Is_Alphanumeric (X (I))
or (X (I) = '_' and Is_Alphanumeric (X (I + 1)))))
);
--
-- Function to check if X satisfies the syntax of IDs. Inofrmally, an
-- ID has a syntax similar to an Ada identifier with the following additions
--
-- (1) "." can be used inside the identifier so that "foo.bar" is OK
-- (2) An identifier cannot begin nor end with "_" or "."
-- (3) "_" must always be followed by an alphanumeric char
-- (4) "." must always be followed by a letter
--
function Is_Valid_Variable (X : String) return Boolean
is (
(X'Length > 0)
and then (X'Length <= Max_ID_Length)
and then (Is_Letter (X (X'First))
and Is_Alphanumeric (X (X'Last)))
and then (for all I in X'Range =>
(Is_Alphanumeric (X (I))
or else (X (I) = '_' and then Is_Alphanumeric (X (I + 1)))
or else (X (I) = '.' and then Is_Letter (X (I + 1)))))
-- Note : in the condition above I+1 is always well defined since
-- if X(X'Last) is alphanumeric, the last two tests are cutted
-- away by the "or else" after Is_Alphanumeric (X (I)), otherwise
-- if X(X'Last) is not alphanumeric, the "for all" will not checked
-- at all because of the preceding "and then"
);
type Simple_Identifier is new Bounded_IDs.Bounded_String
with Dynamic_Predicate =>
Is_Valid_Simple_Name (Bounded_IDs.To_String (Bounded_ID (Simple_Identifier)));
subtype Function_Name is Simple_Identifier;
function To_ID (X : String) return Simple_Identifier
is (Simple_Identifier (Bounded_IDs.To_Bounded_String (X)))
with Pre =>
Is_Valid_Simple_Name (X);
type Variable_Name is new Bounded_IDs.Bounded_String
with Dynamic_Predicate =>
Is_Valid_Variable (Bounded_IDs.To_String (Bounded_ID (Variable_Name)));
function To_Var (X : String) return Variable_Name
is (Variable_Name (Bounded_IDs.To_Bounded_String (X)))
with Pre =>
Is_Valid_Variable (X);
function Join (Var : Variable_Name;
Field : Simple_Identifier) return Variable_Name
is (Var & "." & Variable_Name (Field));
end Symbolic_Identifiers;
|
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.Base64 Luebeck --
-- Implementation Autumn, 2014 --
-- --
-- Last revision : 18:40 01 Aug 2019 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.Exceptions; use Ada.Exceptions;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
package body Strings_Edit.Base64 is
Stream_Is_Full : constant String := "Stream buffer is full";
Invalid_Character : constant String := "Non-Base64 character '";
Unexpected_Equality : constant String := "Unexpected character '='";
type Base64_Encoding is
array (Unsigned_16 range 0..63) of Character;
Base64 : constant Base64_Encoding := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
"abcdefghijklmnopqrstuvwxyz" &
"0123456789+/";
procedure Not_Available
( Stream : Base64_Stream'Class;
Length : Stream_Element_Count
) is
begin
Raise_Exception
( Use_Error'Identity,
( "Not enough space to write"
& Stream_Element_Offset'Image (Length)
& " elements (only"
& Stream_Element_Offset'Image (Free (Stream))
& " available)"
) );
end Not_Available;
procedure Too_Large
( Stream : Base64_Stream'Class;
Length : Stream_Element_Count
) is
begin
Raise_Exception
( Use_Error'Identity,
( "Writing"
& Stream_Element_Offset'Image (Length)
& " elements into stream capable of only"
& Stream_Element_Offset'Image (Size (Stream))
) );
end Too_Large;
procedure Flush (Stream : in out Base64_Encoder) is
Accum : Unsigned_16 renames Stream.Accum;
Bits : Natural renames Stream.Bits;
begin
case Bits is
when 2 =>
if Free (Stream) < 3 then
if Size (Stream) < 3 then
Too_Large (Stream, 3);
else
Not_Available (Stream, 3);
end if;
end if;
Store (Stream, Character'Pos (Base64 (Accum * 2**4)));
Store (Stream, Character'Pos ('='));
Store (Stream, Character'Pos ('='));
when 4 =>
if Free (Stream) < 1 then
Not_Available (Stream, 1);
end if;
Store (Stream, Character'Pos (Base64 (Accum * 2**2)));
Store (Stream, Character'Pos ('='));
when others =>
null;
end case;
end Flush;
function From_Base64 (Text : String) return String is
Result : String (1..(Text'Length * 3 + 3) / 4);
This : Unsigned_16;
Accum : Unsigned_16 := 0;
Bits : Natural := 0;
Pointer : Integer := 1;
begin
for Index in Text'Range loop
This := Character'Pos (Text (Index));
case This is
when Character'Pos ('A')..Character'Pos ('Z') =>
Accum := Accum * 64 + This - Character'Pos ('A');
when Character'Pos ('a')..Character'Pos ('z') =>
Accum := Accum * 64 + This - Character'Pos ('a') + 26;
when Character'Pos ('0')..Character'Pos ('9') =>
Accum := Accum * 64 + This - Character'Pos ('0') + 52;
when Character'Pos ('+') =>
Accum := Accum * 64 + 62;
when Character'Pos ('/') =>
Accum := Accum * 64 + 63;
when Character'Pos ('=') =>
if Index = Text'Last then -- 2 bytes accumulated
exit when Bits = 2;
elsif Index + 1 = Text'Last then -- 1 byte accumulated
exit when Text (Index + 1) = '=' and then Bits = 4;
end if;
Raise_Exception
( Data_Error'Identity,
Unexpected_Equality
);
when others =>
Raise_Exception
( Data_Error'Identity,
Invalid_Character & Text (Index) & '''
);
end case;
Bits := Bits + 6;
if Bits >= 8 then
Bits := Bits - 8;
This := Accum / 2**Bits;
Result (Pointer) :=
Character'Val ((Accum / 2**Bits) and 16#FF#);
Pointer := Pointer + 1;
Accum := Accum mod 2**Bits;
end if;
end loop;
return Result (1..Pointer - 1);
end From_Base64;
function Free (Stream : Base64_Decoder)
return Stream_Element_Count is
begin
return ((Stream.Size - 1 - Used (Stream)) * 4) / 3;
end Free;
function Free (Stream : Base64_Encoder)
return Stream_Element_Count is
begin
return ((Stream.Size - 1 - Used (Stream)) * 3) / 4;
end Free;
function Is_Empty (Stream : Base64_Decoder) return Boolean is
begin
return Stream.Item_In = Stream.Item_Out;
end Is_Empty;
function Is_Empty (Stream : Base64_Encoder) return Boolean is
begin
return Stream.Item_In = Stream.Item_Out;
end Is_Empty;
function Is_Full (Stream : Base64_Decoder) return Boolean is
begin
return Free (Stream) = 0;
end Is_Full;
function Is_Full (Stream : Base64_Encoder) return Boolean is
begin
return Free (Stream) = 0;
end Is_Full;
procedure Read
( Stream : in out Base64_Stream;
Data : out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
Item_In : Stream_Element_Count renames Stream.Item_In;
Item_Out : Stream_Element_Count renames Stream.Item_Out;
FIFO : Stream_Element_Array renames Stream.FIFO;
begin
Last := Data'First - 1;
while Item_In /= Item_Out and then Last < Data'Last loop
Last := Last + 1;
Data (Last) := FIFO (Item_Out);
if Item_Out = FIFO'Last then
Item_Out := 1;
else
Item_Out := Item_Out + 1;
end if;
end loop;
end Read;
procedure Reset (Stream : in out Base64_Decoder) is
begin
Stream.Item_In := 1;
Stream.Item_Out := 1;
Stream.Accum := 0;
Stream.Bits := 0;
Stream.Equality := False;
end Reset;
procedure Reset (Stream : in out Base64_Encoder) is
begin
Stream.Item_In := 1;
Stream.Item_Out := 1;
Stream.Accum := 0;
Stream.Bits := 0;
end Reset;
function Size (Stream : Base64_Decoder)
return Stream_Element_Count is
begin
return ((Stream.Size - 1) * 4) / 3;
end Size;
function Size (Stream : Base64_Encoder)
return Stream_Element_Count is
begin
return ((Stream.Size - 1) * 3) / 4;
end Size;
procedure Store
( Stream : in out Base64_Stream;
Item : Stream_Element
) is
begin
if Stream.Item_In = Stream.FIFO'Last then
if Stream.Item_Out = 1 then
Raise_Exception (Status_Error'Identity, Stream_Is_Full);
end if;
Stream.FIFO (Stream.FIFO'Last) := Item;
Stream.Item_In := 1;
else
if Stream.Item_In + 1 = Stream.Item_Out then
Raise_Exception (Status_Error'Identity, Stream_Is_Full);
end if;
Stream.FIFO (Stream.Item_In) := Item;
Stream.Item_In := Stream.Item_In + 1;
end if;
end Store;
procedure Write
( Stream : in out Base64_Decoder;
Data : Stream_Element_Array
) is
Accum : Unsigned_16 renames Stream.Accum;
Bits : Natural renames Stream.Bits;
This : Unsigned_16;
begin
if Stream.Equality then -- Equality seen
if Data'Length = 0 then
return;
elsif Data (Data'First) = Character'Pos ('=') then
if Data'Length = 1 and then Bits = 4 then
Bits := 0;
return;
else
Raise_Exception
( Data_Error'Identity,
Unexpected_Equality
);
end if;
else
Raise_Exception
( Data_Error'Identity,
( Invalid_Character
& Character'Val (Data (Data'First))
& '''
) );
end if;
elsif Free (Stream) < Data'Length then
if Size (Stream) < Data'Length then
Too_Large (Stream, Data'Length);
else
Not_Available (Stream, Data'Length);
end if;
end if;
for Index in Data'Range loop
This := Unsigned_16 (Data (Index));
case This is
when Character'Pos ('A')..Character'Pos ('Z') =>
Accum := Accum * 64 + This - Character'Pos ('A');
when Character'Pos ('a')..Character'Pos ('z') =>
Accum := Accum * 64 + This - Character'Pos ('a') + 26;
when Character'Pos ('0')..Character'Pos ('9') =>
Accum := Accum * 64 + This - Character'Pos ('0') + 52;
when Character'Pos ('+') =>
Accum := Accum * 64 + 62;
when Character'Pos ('/') =>
Accum := Accum * 64 + 63;
when Character'Pos ('=') =>
Stream.Equality := True;
if Index = Data'Last then -- 2 bytes accumulated
exit when Bits = 2 or else Bits = 4;
elsif Index + 1 = Data'Last then -- 1 byte accumulated
exit when Data (Index + 1) = Character'Pos ('=')
and then Bits = 4;
end if;
Raise_Exception
( Data_Error'Identity,
Unexpected_Equality
);
when others =>
Raise_Exception
( Data_Error'Identity,
Invalid_Character & Character'Val (Data (Index)) & '''
);
end case;
Bits := Bits + 6;
if Bits >= 8 then
Bits := Bits - 8;
This := Accum / 2**Bits;
Store
( Stream,
Stream_Element ((Accum / 2**Bits) and 16#FF#)
);
Accum := Accum mod 2**Bits;
end if;
end loop;
end Write;
procedure Write
( Stream : in out Base64_Encoder;
Data : Stream_Element_Array
) is
Accum : Unsigned_16 renames Stream.Accum;
Bits : Natural renames Stream.Bits;
begin
if Free (Stream) < Data'Length then
if Size (Stream) < Data'Length then
Too_Large (Stream, Data'Length);
else
Not_Available (Stream, Data'Length);
end if;
end if;
for Index in Data'Range loop
Accum := Accum * 256 + Unsigned_16 (Data (Index));
Bits := Bits + 8;
if Bits >= 12 then
Bits := Bits - 6;
Store
( Stream,
Character'Pos (Base64 ((Accum / 2**Bits) and 2#11_1111#))
);
Accum := Accum mod 2**Bits;
end if;
if Bits >= 6 then
Bits := Bits - 6;
Store
( Stream,
Character'Pos (Base64 ((Accum / 2**Bits) and 2#11_1111#))
);
Accum := Accum mod 2**Bits;
end if;
end loop;
end Write;
function To_Base64 (Text : String) return String is
Result : String (1..(Text'Length + 3 / 3) * 4);
Pointer : Integer := 1;
Bits : Natural := 0;
Accum : Unsigned_16 := 0;
begin
for Index in Text'Range loop
Accum := Accum * 256 + Character'Pos (Text (Index));
Bits := Bits + 8;
if Bits >= 12 then
Bits := Bits - 6;
Result (Pointer) :=
Base64 ((Accum / 2**Bits) and 2#11_1111#);
Accum := Accum mod 2**Bits;
Pointer := Pointer + 1;
end if;
if Bits >= 6 then
Bits := Bits - 6;
Result (Pointer) :=
Base64 ((Accum / 2**Bits) and 2#11_1111#);
Accum := Accum mod 2**Bits;
Pointer := Pointer + 1;
end if;
end loop;
case Bits is
when 2 =>
Result (Pointer) := Base64 (Accum * 2**4);
Pointer := Pointer + 1;
Result (Pointer) := '=';
Pointer := Pointer + 1;
Result (Pointer) := '=';
Pointer := Pointer + 1;
when 4 =>
Result (Pointer) := Base64 (Accum * 2**2);
Pointer := Pointer + 1;
Result (Pointer) := '=';
Pointer := Pointer + 1;
when others =>
null;
end case;
return Result (1..Pointer - 1);
end To_Base64;
function Used (Stream : Base64_Decoder)
return Stream_Element_Count is
Diff : constant Stream_Element_Offset :=
Stream.Item_In - Stream.Item_Out;
begin
if Diff < 0 then
return Stream.Size + Diff;
else
return Diff;
end if;
end Used;
function Used (Stream : Base64_Encoder)
return Stream_Element_Count is
Diff : constant Stream_Element_Offset :=
Stream.Item_In - Stream.Item_Out;
begin
if Diff < 0 then
return Stream.Size + Diff;
else
return Diff;
end if;
end Used;
end Strings_Edit.Base64;
|
-----------------------------------------------------------------------
-- are-main -- Main tool program
-- Copyright (C) 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with Ada.Command_Line;
with Ada.Exceptions;
with GNAT.Command_Line;
with Util.Log.Loggers;
with Are.Generator;
procedure Are.Main is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Are.Main");
begin
Are.Configure_Logs (Debug => False, Verbose => False);
Are.Generator.Main;
exception
when GNAT.Command_Line.Exit_From_Command_Line | GNAT.Command_Line.Invalid_Switch =>
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
when E : Ada.IO_Exceptions.Name_Error =>
Log.Error (-("cannot access file: {0}"), Ada.Exceptions.Exception_Message (E));
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
when E : others =>
Log.Error (-("some internal error occurred"), E, True);
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end Are.Main;
|
-- C74406A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT THE FULL DECLARATION OF A LIMITED PRIVATE TYPE CAN
-- DECLARE A TASK TYPE, A TYPE DERIVED FROM A LIMITED PRIVATE TYPE,
-- AND A COMPOSITE TYPE WITH A COMPONENT OF A LIMITED TYPE.
-- HISTORY:
-- BCB 03/10/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C74406A IS
PACKAGE TP IS
TYPE T IS LIMITED PRIVATE;
PROCEDURE INIT (Z1 : OUT T; Z2 : INTEGER);
FUNCTION EQUAL_T (ONE, TWO : T) RETURN BOOLEAN;
PRIVATE
TYPE T IS RANGE 1 .. 100;
END TP;
PACKAGE BODY TP IS
PROCEDURE INIT (Z1 : OUT T; Z2 : INTEGER) IS
BEGIN
Z1 := T (Z2);
END INIT;
FUNCTION EQUAL_T (ONE, TWO : T) RETURN BOOLEAN IS
BEGIN
IF EQUAL(3,3) THEN
RETURN ONE = TWO;
ELSE
RETURN ONE /= TWO;
END IF;
END EQUAL_T;
BEGIN
NULL;
END TP;
USE TP;
PACKAGE P IS
TYPE T1 IS LIMITED PRIVATE;
TYPE T2 IS LIMITED PRIVATE;
TYPE T3 IS LIMITED PRIVATE;
TYPE T4 IS LIMITED PRIVATE;
PRIVATE
TASK TYPE T1 IS
ENTRY HERE(VAL1 : IN OUT INTEGER);
END T1;
TYPE T2 IS NEW T;
TYPE T3 IS RECORD
INT : T;
END RECORD;
TYPE T4 IS ARRAY(1..5) OF T;
END P;
PACKAGE BODY P IS
X1 : T1;
X3 : T3;
X4 : T4;
VAR : INTEGER := 25;
TASK BODY T1 IS
BEGIN
ACCEPT HERE(VAL1 : IN OUT INTEGER) DO
VAL1 := VAL1 * 2;
END HERE;
END T1;
BEGIN
TEST ("C74406A", "CHECK THAT THE FULL DECLARATION OF A " &
"LIMITED PRIVATE TYPE CAN DECLARE A TASK " &
"TYPE, A TYPE DERIVED FROM A LIMITED " &
"PRIVATE TYPE, AND A COMPOSITE TYPE WITH " &
"A COMPONENT OF A LIMITED TYPE");
X1.HERE(VAR);
IF NOT EQUAL(VAR,IDENT_INT(50)) THEN
FAILED ("IMPROPER VALUE FOR VAL");
END IF;
INIT (X3.INT, 50);
IF X3.INT NOT IN T THEN
FAILED ("IMPROPER RESULT FROM MEMBERSHIP TEST");
END IF;
INIT (X4(3), 17);
IF NOT EQUAL_T(T'(X4(3)),T(X4(3))) THEN
FAILED ("IMPROPER RESULT FROM QUALIFICATION AND " &
"EXPLICIT CONVERSION");
END IF;
RESULT;
END P;
USE P;
BEGIN
NULL;
END C74406A;
|
package body SPARKNaCl.Hashing
with SPARK_Mode => On
is
pragma Warnings (GNATProve, Off, "pragma * ignored (not yet supported)");
subtype Index_80 is I32 range 0 .. 79;
type K_Table is array (Index_80) of U64;
K : constant K_Table :=
(16#428a2f98d728ae22#, 16#7137449123ef65cd#,
16#b5c0fbcfec4d3b2f#, 16#e9b5dba58189dbbc#,
16#3956c25bf348b538#, 16#59f111f1b605d019#,
16#923f82a4af194f9b#, 16#ab1c5ed5da6d8118#,
16#d807aa98a3030242#, 16#12835b0145706fbe#,
16#243185be4ee4b28c#, 16#550c7dc3d5ffb4e2#,
16#72be5d74f27b896f#, 16#80deb1fe3b1696b1#,
16#9bdc06a725c71235#, 16#c19bf174cf692694#,
16#e49b69c19ef14ad2#, 16#efbe4786384f25e3#,
16#0fc19dc68b8cd5b5#, 16#240ca1cc77ac9c65#,
16#2de92c6f592b0275#, 16#4a7484aa6ea6e483#,
16#5cb0a9dcbd41fbd4#, 16#76f988da831153b5#,
16#983e5152ee66dfab#, 16#a831c66d2db43210#,
16#b00327c898fb213f#, 16#bf597fc7beef0ee4#,
16#c6e00bf33da88fc2#, 16#d5a79147930aa725#,
16#06ca6351e003826f#, 16#142929670a0e6e70#,
16#27b70a8546d22ffc#, 16#2e1b21385c26c926#,
16#4d2c6dfc5ac42aed#, 16#53380d139d95b3df#,
16#650a73548baf63de#, 16#766a0abb3c77b2a8#,
16#81c2c92e47edaee6#, 16#92722c851482353b#,
16#a2bfe8a14cf10364#, 16#a81a664bbc423001#,
16#c24b8b70d0f89791#, 16#c76c51a30654be30#,
16#d192e819d6ef5218#, 16#d69906245565a910#,
16#f40e35855771202a#, 16#106aa07032bbd1b8#,
16#19a4c116b8d2d0c8#, 16#1e376c085141ab53#,
16#2748774cdf8eeb99#, 16#34b0bcb5e19b48a8#,
16#391c0cb3c5c95a63#, 16#4ed8aa4ae3418acb#,
16#5b9cca4f7763e373#, 16#682e6ff3d6b2b8a3#,
16#748f82ee5defb2fc#, 16#78a5636f43172f60#,
16#84c87814a1f0ab72#, 16#8cc702081a6439ec#,
16#90befffa23631e28#, 16#a4506cebde82bde9#,
16#bef9a3f7b2c67915#, 16#c67178f2e372532b#,
16#ca273eceea26619c#, 16#d186b8c721c0c207#,
16#eada7dd6cde0eb1e#, 16#f57d4f7fee6ed178#,
16#06f067aa72176fba#, 16#0a637dc5a2c898a6#,
16#113f9804bef90dae#, 16#1b710b35131c471b#,
16#28db77f523047d84#, 16#32caab7b40c72493#,
16#3c9ebe0a15c9bebc#, 16#431d67c49c100d4c#,
16#4cc5d4becb3e42b6#, 16#597f299cfc657e2a#,
16#5fcb6fab3ad6faec#, 16#6c44198c4a475817#);
function TS64 (U : in U64) return Bytes_8
with Global => null;
function TS64 (U : in U64) return Bytes_8
is
X : Bytes_8;
T : U64 := U;
begin
for I in reverse Index_8 loop
pragma Loop_Optimize (No_Unroll);
X (I) := Byte (T mod 256);
T := Shift_Right (T, 8);
end loop;
return X;
end TS64;
-- Big-Endian 8 bytes to U64. The input bytes are in
-- X (I) (the MSB) through X (I + 8) (the LSB)
function DL64 (X : in Byte_Seq;
I : in N32) return U64
with Global => null,
Pre => X'Length >= 8 and then
I >= X'First and then
I <= X'Last - 7;
function DL64 (X : in Byte_Seq;
I : in N32) return U64
is
LSW, MSW : U32;
begin
-- Doing this in two 32-bit groups avoids the need
-- for 64-bit shifts on 32-bit machines.
MSW := Shift_Left (U32 (X (I)), 24) or
Shift_Left (U32 (X (I + 1)), 16) or
Shift_Left (U32 (X (I + 2)), 8) or
U32 (X (I + 3));
LSW := Shift_Left (U32 (X (I + 4)), 24) or
Shift_Left (U32 (X (I + 5)), 16) or
Shift_Left (U32 (X (I + 6)), 8) or
U32 (X (I + 7));
return Shift_Left (U64 (MSW), 32) or U64 (LSW);
end DL64;
procedure Hashblocks
(X : in out Digest;
M : in Byte_Seq)
is
Z, B, A : U64_Seq_8;
W : U64_Seq_16;
T : U64;
LN : I64;
CB : I32;
function RR64 (X : in U64;
C : in Natural) return U64
renames Rotate_Right;
function Ch (X, Y, Z : in U64) return U64
is ((X and Y) xor ((not X) and Z))
with Global => null;
function Maj (X, Y, Z : in U64) return U64
is ((X and Y) xor (X and Z) xor (Y and Z))
with Global => null;
-- Sigma0 with an upper-case S!
function UC_Sigma0 (X : in U64) return U64
is (RR64 (X, 28) xor RR64 (X, 34) xor RR64 (X, 39))
with Global => null;
-- Sigma1 with an upper-case S!
function UC_Sigma1 (X : in U64) return U64
is (RR64 (X, 14) xor RR64 (X, 18) xor RR64 (X, 41))
with Global => null;
-- sigma0 with a lower-case s!
function LC_Sigma0 (X : in U64) return U64
is (RR64 (X, 1) xor RR64 (X, 8) xor Shift_Right (X, 7))
with Global => null;
-- sigma1 with a lower-case s!
function LC_Sigma1 (X : in U64) return U64
is (RR64 (X, 19) xor RR64 (X, 61) xor Shift_Right (X, 6))
with Global => null;
begin
A := (0 => DL64 (X, 0),
1 => DL64 (X, 8),
2 => DL64 (X, 16),
3 => DL64 (X, 24),
4 => DL64 (X, 32),
5 => DL64 (X, 40),
6 => DL64 (X, 48),
7 => DL64 (X, 56));
Z := A;
LN := I64 (M'Length);
CB := M'First; -- Current block base offset
while (LN >= 128) loop
pragma Loop_Optimize (No_Unroll);
pragma Warnings (Off, "lower bound test*");
pragma Loop_Invariant
((LN + I64 (CB) = I64 (M'Last) + 1) and
(LN in 128 .. M'Length) and
(CB in M'First .. (M'Last - 127)));
W := (0 => DL64 (M, CB),
1 => DL64 (M, CB + 8),
2 => DL64 (M, CB + 16),
3 => DL64 (M, CB + 24),
4 => DL64 (M, CB + 32),
5 => DL64 (M, CB + 40),
6 => DL64 (M, CB + 48),
7 => DL64 (M, CB + 56),
8 => DL64 (M, CB + 64),
9 => DL64 (M, CB + 72),
10 => DL64 (M, CB + 80),
11 => DL64 (M, CB + 88),
12 => DL64 (M, CB + 96),
13 => DL64 (M, CB + 104),
14 => DL64 (M, CB + 112),
15 => DL64 (M, CB + 120));
for I in Index_80 loop
pragma Loop_Optimize (No_Unroll);
pragma Loop_Invariant ((LN + I64 (CB) = I64 (M'Last) + 1) and
(LN in 128 .. M'Length) and
(CB in M'First .. (M'Last - 127)));
B := A;
T := A (7) + UC_Sigma1 (A (4)) + Ch (A (4), A (5), A (6)) +
K (I) + W (I mod 16);
B (7) := T + UC_Sigma0 (A (0)) + Maj (A (0), A (1), A (2));
B (3) := B (3) + T;
A := (0 => B (7),
1 => B (0),
2 => B (1),
3 => B (2),
4 => B (3),
5 => B (4),
6 => B (5),
7 => B (6));
if (I mod 16 = 15) then
for J in Index_16 loop
pragma Loop_Optimize (No_Unroll);
W (J) := W (J) + W ((J + 9) mod 16) +
LC_Sigma0 (W ((J + 1) mod 16)) +
LC_Sigma1 (W ((J + 14) mod 16));
end loop;
end if;
end loop;
for I in Index_8 loop
pragma Loop_Optimize (No_Unroll);
A (I) := A (I) + Z (I);
Z (I) := A (I);
end loop;
exit when LN < 256;
pragma Assert (LN >= 128);
CB := CB + 128;
LN := LN - 128;
end loop;
for I in Index_8 loop
pragma Loop_Optimize (No_Unroll);
X (8 * I .. (8 * I + 7)) := TS64 (Z (I));
end loop;
end Hashblocks;
procedure Hash (Output : out Digest;
M : in Byte_Seq)
is
subtype Final_Block_Length is I32 range 0 .. 127;
H : Bytes_64;
X : Bytes_256;
B : Final_Block_Length;
Final_Block_First : I32;
ML_MSB : Byte;
ML_LSBs : U64;
begin
H := IV;
X := (others => 0);
Hashblocks (H, M);
B := Final_Block_Length (I64 (M'Length) mod 128);
if B > 0 then
Final_Block_First := (M'Last - B) + 1;
X (0 .. B - 1) := M (Final_Block_First .. M'Last);
end if;
X (B) := 128;
-- Final 9 bytes are the length of M in bits
ML_MSB := Byte (Shift_Right (U64'(M'Length), 61));
ML_LSBs := U64 (M'Length) * 8;
if B < 112 then
X (119) := ML_MSB;
X (120 .. 127) := TS64 (ML_LSBs);
Hashblocks (H, X (0 .. 127));
else
X (247) := ML_MSB;
X (248 .. 255) := TS64 (ML_LSBs);
Hashblocks (H, X);
end if;
Output := H;
end Hash;
function Hash (M : in Byte_Seq) return Digest
is
R : Digest;
begin
Hash (R, M);
return R;
end Hash;
end SPARKNaCl.Hashing;
|
with Ada.Text_IO;
use Ada.Text_IO;
package body kv.avm.Vole_Lex is
procedure Report is
begin
Put_Line(yytext);
end Report;
procedure Inc_Line is
begin
Line_Number := Line_Number + 1;
end Inc_Line;
function YYLex return Token is
subtype short is integer range -32768..32767;
yy_act : integer;
yy_c : short;
-- returned upon end-of-file
YY_END_TOK : constant integer := 0;
YY_END_OF_BUFFER : constant := 75;
subtype yy_state_type is integer;
yy_current_state : yy_state_type;
INITIAL : constant := 0;
yy_accept : constant array(0..242) of short :=
( 0,
0, 0, 75, 74, 73, 72, 47, 74, 71, 36,
44, 67, 68, 34, 32, 63, 33, 62, 35, 59,
61, 64, 42, 37, 39, 57, 57, 57, 57, 57,
57, 57, 57, 69, 70, 57, 57, 57, 57, 57,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
65, 45, 66, 73, 38, 0, 60, 0, 71, 31,
0, 59, 0, 43, 29, 41, 37, 40, 30, 57,
0, 57, 57, 57, 57, 57, 57, 57, 57, 57,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
57, 12, 57, 57, 57, 57, 57, 57, 45, 57,
57, 57, 57, 57, 57, 57, 57, 58, 57, 57,
57, 57, 57, 57, 57, 57, 57, 57, 44, 57,
57, 57, 57, 57, 57, 57, 57, 11, 57, 57,
57, 57, 57, 36, 27, 47, 57, 57, 57, 57,
57, 57, 57, 57, 57, 46, 58, 0, 0, 57,
57, 57, 57, 57, 57, 55, 57, 57, 57, 57,
57, 4, 57, 6, 8, 57, 57, 57, 57, 26,
57, 57, 57, 57, 19, 20, 57, 22, 57, 24,
57, 0, 58, 48, 57, 56, 52, 57, 57, 54,
57, 1, 57, 57, 57, 57, 9, 57, 57, 16,
57, 57, 57, 57, 21, 23, 25, 58, 0, 57,
57, 53, 57, 2, 57, 57, 7, 57, 13, 57,
18, 57, 14, 49, 50, 57, 57, 57, 10, 17,
57, 15, 51, 57, 57, 57, 3, 57, 28, 57,
5, 0
) ;
yy_ec : constant array(ASCII.NUL..Character'Last) of short :=
( 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 4, 5, 6, 1, 7, 8, 1, 9,
10, 11, 12, 13, 14, 15, 16, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 18, 19, 20,
21, 22, 1, 1, 23, 24, 25, 25, 26, 27,
25, 25, 28, 25, 25, 25, 25, 25, 25, 25,
25, 25, 29, 30, 31, 25, 25, 25, 25, 25,
32, 33, 34, 1, 35, 1, 36, 37, 38, 39,
40, 41, 42, 43, 44, 25, 25, 45, 46, 47,
48, 49, 25, 50, 51, 52, 53, 25, 54, 55,
25, 25, 56, 57, 58, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
) ;
yy_meta : constant array(0..58) of short :=
( 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
3, 1, 1, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 1, 1, 1
) ;
yy_base : constant array(0..245) of short :=
( 0,
0, 0, 456, 457, 453, 457, 433, 54, 0, 457,
457, 457, 457, 442, 457, 457, 457, 457, 431, 45,
430, 457, 43, 429, 44, 32, 26, 414, 33, 36,
37, 38, 46, 457, 457, 47, 60, 55, 44, 68,
49, 71, 72, 78, 80, 81, 82, 83, 88, 89,
457, 457, 457, 446, 457, 71, 457, 444, 0, 457,
429, 110, 428, 457, 457, 457, 457, 457, 457, 409,
408, 94, 99, 97, 103, 98, 104, 105, 106, 108,
109, 113, 114, 118, 121, 122, 125, 42, 127, 128,
129, 407, 132, 136, 138, 143, 133, 140, 406, 148,
142, 150, 151, 156, 158, 164, 163, 184, 167, 171,
170, 176, 174, 182, 183, 185, 187, 190, 405, 192,
193, 194, 198, 200, 201, 202, 204, 404, 206, 212,
207, 210, 215, 403, 402, 401, 216, 217, 222, 225,
227, 224, 230, 231, 234, 400, 251, 268, 417, 237,
241, 248, 238, 254, 257, 398, 258, 259, 249, 260,
262, 397, 265, 267, 396, 268, 272, 270, 273, 395,
277, 279, 280, 281, 394, 393, 286, 392, 288, 391,
290, 408, 305, 389, 297, 388, 387, 294, 300, 386,
291, 385, 302, 304, 308, 309, 384, 310, 311, 383,
313, 312, 318, 317, 382, 381, 380, 340, 397, 324,
326, 378, 325, 376, 327, 331, 370, 332, 369, 333,
366, 334, 337, 365, 364, 339, 342, 344, 362, 361,
346, 360, 358, 350, 351, 352, 239, 354, 168, 356,
70, 457, 406, 409, 72
) ;
yy_def : constant array(0..245) of short :=
( 0,
242, 1, 242, 242, 242, 242, 242, 243, 244, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 245, 245, 245, 245, 245,
245, 245, 245, 242, 242, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
242, 242, 242, 242, 242, 243, 242, 243, 244, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 242, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 242, 242, 242, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 242, 242, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 242, 242, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
245, 0, 242, 242, 242
) ;
yy_nxt : constant array(0..515) of short :=
( 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 28, 29, 30, 31, 32,
33, 34, 4, 35, 4, 36, 28, 37, 28, 38,
39, 28, 28, 40, 41, 42, 43, 44, 45, 46,
47, 48, 28, 49, 50, 51, 52, 53, 57, 61,
71, 62, 65, 66, 68, 69, 71, 71, 74, 72,
71, 71, 71, 73, 70, 57, 71, 75, 71, 63,
71, 71, 76, 71, 81, 125, 58, 78, 77, 71,
79, 91, 80, 82, 71, 85, 94, 83, 84, 87,
88, 89, 71, 58, 71, 71, 71, 86, 92, 90,
95, 97, 71, 93, 71, 71, 71, 71, 96, 98,
101, 102, 71, 71, 61, 104, 62, 99, 71, 100,
106, 71, 71, 71, 103, 105, 107, 71, 71, 71,
71, 111, 71, 71, 63, 109, 110, 71, 71, 113,
112, 119, 71, 114, 116, 71, 71, 115, 117, 71,
118, 71, 71, 71, 120, 126, 71, 71, 123, 121,
71, 122, 71, 130, 71, 124, 71, 71, 128, 127,
129, 134, 71, 131, 71, 71, 135, 137, 132, 133,
71, 136, 71, 138, 139, 142, 140, 71, 71, 141,
147, 71, 71, 144, 71, 71, 143, 145, 71, 148,
71, 153, 146, 154, 150, 151, 71, 71, 149, 71,
152, 71, 156, 148, 71, 155, 71, 71, 71, 157,
158, 160, 71, 162, 71, 71, 71, 159, 71, 164,
71, 71, 161, 167, 71, 166, 71, 169, 163, 71,
71, 71, 165, 168, 173, 170, 71, 172, 71, 71,
171, 71, 175, 176, 71, 71, 177, 147, 71, 174,
178, 71, 71, 71, 179, 71, 148, 180, 181, 182,
185, 182, 71, 71, 183, 149, 184, 186, 71, 187,
148, 71, 71, 71, 71, 188, 71, 190, 192, 71,
191, 71, 71, 189, 71, 194, 71, 71, 197, 193,
196, 71, 201, 71, 71, 71, 195, 200, 198, 199,
71, 208, 71, 203, 71, 71, 202, 206, 71, 207,
204, 71, 210, 211, 71, 205, 71, 213, 71, 209,
215, 212, 71, 71, 71, 71, 71, 71, 218, 217,
221, 71, 71, 214, 220, 222, 208, 216, 71, 71,
71, 71, 219, 223, 226, 71, 71, 71, 71, 231,
224, 71, 230, 71, 209, 225, 71, 233, 71, 227,
71, 235, 229, 228, 71, 71, 71, 232, 71, 237,
71, 239, 71, 234, 71, 71, 71, 236, 71, 71,
71, 240, 238, 71, 71, 241, 56, 56, 56, 59,
71, 59, 71, 208, 71, 71, 71, 71, 71, 71,
71, 71, 71, 71, 183, 71, 71, 71, 71, 71,
71, 71, 71, 147, 71, 71, 71, 71, 71, 71,
71, 71, 242, 71, 62, 108, 242, 54, 71, 67,
64, 55, 60, 55, 54, 242, 3, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242
) ;
yy_chk : constant array(0..515) of short :=
( 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 8, 20,
27, 20, 23, 23, 25, 25, 26, 29, 29, 26,
30, 31, 32, 27, 245, 56, 88, 29, 39, 20,
33, 36, 30, 41, 36, 88, 8, 32, 31, 38,
32, 39, 33, 36, 37, 37, 41, 36, 36, 38,
38, 38, 40, 56, 241, 42, 43, 37, 40, 38,
42, 43, 44, 40, 45, 46, 47, 48, 42, 43,
46, 47, 49, 50, 62, 48, 62, 44, 72, 45,
49, 74, 76, 73, 47, 48, 50, 75, 77, 78,
79, 74, 80, 81, 62, 72, 73, 82, 83, 76,
75, 82, 84, 77, 79, 85, 86, 78, 80, 87,
81, 89, 90, 91, 83, 89, 93, 97, 86, 84,
94, 85, 95, 94, 98, 87, 101, 96, 91, 90,
93, 96, 100, 94, 102, 103, 97, 100, 95, 95,
104, 98, 105, 101, 102, 104, 102, 107, 106, 103,
108, 109, 239, 106, 111, 110, 105, 106, 113, 108,
112, 112, 107, 113, 109, 110, 114, 115, 108, 116,
111, 117, 115, 108, 118, 114, 120, 121, 122, 116,
117, 120, 123, 122, 124, 125, 126, 118, 127, 124,
129, 131, 121, 127, 132, 126, 130, 130, 123, 133,
137, 138, 125, 129, 137, 131, 139, 133, 142, 140,
132, 141, 139, 140, 143, 144, 141, 147, 145, 138,
142, 150, 153, 237, 143, 151, 147, 144, 145, 148,
151, 148, 152, 159, 148, 147, 150, 152, 154, 153,
147, 155, 157, 158, 160, 154, 161, 157, 159, 163,
158, 164, 166, 155, 168, 161, 167, 169, 166, 160,
164, 171, 171, 172, 173, 174, 163, 169, 167, 168,
177, 183, 179, 173, 181, 191, 172, 179, 188, 181,
174, 185, 185, 188, 189, 177, 193, 191, 194, 183,
194, 189, 195, 196, 198, 199, 202, 201, 198, 196,
202, 204, 203, 193, 201, 203, 208, 195, 210, 213,
211, 215, 199, 204, 213, 216, 218, 220, 222, 222,
210, 223, 220, 226, 208, 211, 227, 226, 228, 215,
231, 228, 218, 216, 234, 235, 236, 223, 238, 234,
240, 236, 233, 227, 232, 230, 229, 231, 225, 224,
221, 238, 235, 219, 217, 240, 243, 243, 243, 244,
214, 244, 212, 209, 207, 206, 205, 200, 197, 192,
190, 187, 186, 184, 182, 180, 178, 176, 175, 170,
165, 162, 156, 149, 146, 136, 135, 134, 128, 119,
99, 92, 71, 70, 63, 61, 58, 54, 28, 24,
21, 19, 14, 7, 5, 3, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
242, 242, 242, 242, 242
) ;
-- copy whatever the last rule matched to the standard output
procedure ECHO is
begin
if (text_io.is_open(user_output_file)) then
text_io.put( user_output_file, yytext );
else
text_io.put( yytext );
end if;
end ECHO;
-- enter a start condition.
-- Using procedure requires a () after the ENTER, but makes everything
-- much neater.
procedure ENTER( state : integer ) is
begin
yy_start := 1 + 2 * state;
end ENTER;
-- action number for EOF rule of a given start state
function YY_STATE_EOF(state : integer) return integer is
begin
return YY_END_OF_BUFFER + state + 1;
end YY_STATE_EOF;
-- return all but the first 'n' matched characters back to the input stream
procedure yyless(n : integer) is
begin
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + n;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
end yyless;
-- redefine this if you have something you want each time.
procedure YY_USER_ACTION is
begin
null;
end;
-- yy_get_previous_state - get the state just before the EOB char was reached
function yy_get_previous_state return yy_state_type is
yy_current_state : yy_state_type;
yy_c : short;
begin
yy_current_state := yy_start;
for yy_cp in yytext_ptr..yy_c_buf_p - 1 loop
yy_c := yy_ec(yy_ch_buf(yy_cp));
if ( yy_accept(yy_current_state) /= 0 ) then
yy_last_accepting_state := yy_current_state;
yy_last_accepting_cpos := yy_cp;
end if;
while ( yy_chk(yy_base(yy_current_state) + yy_c) /= yy_current_state ) loop
yy_current_state := yy_def(yy_current_state);
if ( yy_current_state >= 243 ) then
yy_c := yy_meta(yy_c);
end if;
end loop;
yy_current_state := yy_nxt(yy_base(yy_current_state) + yy_c);
end loop;
return yy_current_state;
end yy_get_previous_state;
procedure yyrestart( input_file : file_type ) is
begin
open_input(text_io.name(input_file));
end yyrestart;
begin -- of YYLex
<<new_file>>
-- this is where we enter upon encountering an end-of-file and
-- yywrap() indicating that we should continue processing
if ( yy_init ) then
if ( yy_start = 0 ) then
yy_start := 1; -- first start state
end if;
-- we put in the '\n' and start reading from [1] so that an
-- initial match-at-newline will be true.
yy_ch_buf(0) := ASCII.LF;
yy_n_chars := 1;
-- we always need two end-of-buffer characters. The first causes
-- a transition to the end-of-buffer state. The second causes
-- a jam in that state.
yy_ch_buf(yy_n_chars) := YY_END_OF_BUFFER_CHAR;
yy_ch_buf(yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;
yy_eof_has_been_seen := false;
yytext_ptr := 1;
yy_c_buf_p := yytext_ptr;
yy_hold_char := yy_ch_buf(yy_c_buf_p);
yy_init := false;
end if; -- yy_init
loop -- loops until end-of-file is reached
yy_cp := yy_c_buf_p;
-- support of yytext
yy_ch_buf(yy_cp) := yy_hold_char;
-- yy_bp points to the position in yy_ch_buf of the start of the
-- current run.
yy_bp := yy_cp;
yy_current_state := yy_start;
loop
yy_c := yy_ec(yy_ch_buf(yy_cp));
if ( yy_accept(yy_current_state) /= 0 ) then
yy_last_accepting_state := yy_current_state;
yy_last_accepting_cpos := yy_cp;
end if;
while ( yy_chk(yy_base(yy_current_state) + yy_c) /= yy_current_state ) loop
yy_current_state := yy_def(yy_current_state);
if ( yy_current_state >= 243 ) then
yy_c := yy_meta(yy_c);
end if;
end loop;
yy_current_state := yy_nxt(yy_base(yy_current_state) + yy_c);
yy_cp := yy_cp + 1;
if ( yy_current_state = 242 ) then
exit;
end if;
end loop;
yy_cp := yy_last_accepting_cpos;
yy_current_state := yy_last_accepting_state;
<<next_action>>
yy_act := yy_accept(yy_current_state);
YY_DO_BEFORE_ACTION;
YY_USER_ACTION;
if aflex_debug then -- output acceptance info. for (-d) debug mode
text_io.put( Standard_Error, "--accepting rule #" );
text_io.put( Standard_Error, INTEGER'IMAGE(yy_act) );
text_io.put_line( Standard_Error, "(""" & yytext & """)");
end if;
<<do_action>> -- this label is used only to access EOF actions
case yy_act is
when 0 => -- must backtrack
-- undo the effects of YY_DO_BEFORE_ACTION
yy_ch_buf(yy_cp) := yy_hold_char;
yy_cp := yy_last_accepting_cpos;
yy_current_state := yy_last_accepting_state;
goto next_action;
when 1 =>
--# line 14 "vole_lex.l"
return Key_Actor;
when 2 =>
--# line 15 "vole_lex.l"
return Key_Assert;
when 3 =>
--# line 16 "vole_lex.l"
return Key_Attribute;
when 4 =>
--# line 17 "vole_lex.l"
return Key_Case;
when 5 =>
--# line 18 "vole_lex.l"
return Key_Constructor;
when 6 =>
--# line 19 "vole_lex.l"
return Key_Else;
when 7 =>
--# line 20 "vole_lex.l"
return Key_Elseif;
when 8 =>
--# line 21 "vole_lex.l"
return Key_Emit;
when 9 =>
--# line 22 "vole_lex.l"
return Key_Endif;
when 10 =>
--# line 23 "vole_lex.l"
return Key_Extends;
when 11 =>
--# line 24 "vole_lex.l"
return Key_For;
when 12 =>
--# line 25 "vole_lex.l"
return Key_If;
when 13 =>
--# line 26 "vole_lex.l"
return Key_Import;
when 14 =>
--# line 27 "vole_lex.l"
return Key_Return;
when 15 =>
--# line 28 "vole_lex.l"
return Key_Returns;
when 16 =>
--# line 29 "vole_lex.l"
return Key_Local;
when 17 =>
--# line 30 "vole_lex.l"
return Key_Message;
when 18 =>
--# line 31 "vole_lex.l"
return Key_Method;
when 19 =>
--# line 32 "vole_lex.l"
return Key_Self;
when 20 =>
--# line 33 "vole_lex.l"
return Key_Send;
when 21 =>
--# line 34 "vole_lex.l"
return Key_Super;
when 22 =>
--# line 35 "vole_lex.l"
return Key_Then;
when 23 =>
--# line 36 "vole_lex.l"
return Key_Tuple;
when 24 =>
--# line 37 "vole_lex.l"
return Key_When;
when 25 =>
--# line 38 "vole_lex.l"
return Key_While;
when 26 =>
--# line 39 "vole_lex.l"
return Key_Loop;
when 27 =>
--# line 40 "vole_lex.l"
return Key_New;
when 28 =>
--# line 41 "vole_lex.l"
return Key_Predicate;
when 29 =>
--# line 43 "vole_lex.l"
return Op_Shift_Left;
when 30 =>
--# line 44 "vole_lex.l"
return Op_Shift_Right;
when 31 =>
--# line 45 "vole_lex.l"
return Op_Exp;
when 32 =>
--# line 46 "vole_lex.l"
return Op_Add;
when 33 =>
--# line 47 "vole_lex.l"
return Op_Sub;
when 34 =>
--# line 48 "vole_lex.l"
return Op_Mul;
when 35 =>
--# line 49 "vole_lex.l"
return Op_Div;
when 36 =>
--# line 50 "vole_lex.l"
return Op_Mod;
when 37 =>
--# line 51 "vole_lex.l"
return Op_Eq;
when 38 =>
--# line 52 "vole_lex.l"
return Op_Not_Eq;
when 39 =>
--# line 53 "vole_lex.l"
return Op_Gt;
when 40 =>
--# line 54 "vole_lex.l"
return Op_Gt_Eq;
when 41 =>
--# line 55 "vole_lex.l"
return Op_Lt_Eq;
when 42 =>
--# line 56 "vole_lex.l"
return Op_Lt;
when 43 =>
--# line 57 "vole_lex.l"
return Op_Assign;
when 44 =>
--# line 58 "vole_lex.l"
return Op_And;
when 45 =>
--# line 59 "vole_lex.l"
return Op_Or;
when 46 =>
--# line 60 "vole_lex.l"
return Op_Xor;
when 47 =>
--# line 61 "vole_lex.l"
return Op_Not;
when 48 =>
--# line 63 "vole_lex.l"
return Actor_Type;
when 49 =>
--# line 64 "vole_lex.l"
return Boolean_Type;
when 50 =>
--# line 65 "vole_lex.l"
return Integer_Type;
when 51 =>
--# line 66 "vole_lex.l"
return Unsigned_Type;
when 52 =>
--# line 67 "vole_lex.l"
return Float_Type;
when 53 =>
--# line 68 "vole_lex.l"
return String_Type;
when 54 =>
--# line 69 "vole_lex.l"
return Tuple_Type;
when 55 =>
--# line 71 "vole_lex.l"
return True_Literal;
when 56 =>
--# line 72 "vole_lex.l"
return False_Literal;
when 57 =>
--# line 74 "vole_lex.l"
return Id_Token;
when 58 =>
--# line 76 "vole_lex.l"
return Float_Literal;
when 59 =>
--# line 78 "vole_lex.l"
return Integer_Literal;
when 60 =>
--# line 80 "vole_lex.l"
return String_Literal;
when 61 =>
--# line 82 "vole_lex.l"
return Colon_Token;
when 62 =>
--# line 83 "vole_lex.l"
return Dot_Token;
when 63 =>
--# line 84 "vole_lex.l"
return Comma_Token;
when 64 =>
--# line 85 "vole_lex.l"
return Eos_Token;
when 65 =>
--# line 86 "vole_lex.l"
return Block_Begin;
when 66 =>
--# line 87 "vole_lex.l"
return Block_End;
when 67 =>
--# line 88 "vole_lex.l"
return Paren_Begin;
when 68 =>
--# line 89 "vole_lex.l"
return Paren_End;
when 69 =>
--# line 90 "vole_lex.l"
return Tuple_Begin;
when 70 =>
--# line 91 "vole_lex.l"
return Tuple_End;
when 71 =>
--# line 93 "vole_lex.l"
null;
when 72 =>
--# line 94 "vole_lex.l"
Inc_Line;
when 73 =>
--# line 96 "vole_lex.l"
null;
when 74 =>
--# line 99 "vole_lex.l"
ECHO;
when YY_END_OF_BUFFER + INITIAL + 1 =>
return End_Of_Input;
when YY_END_OF_BUFFER =>
-- undo the effects of YY_DO_BEFORE_ACTION
yy_ch_buf(yy_cp) := yy_hold_char;
yytext_ptr := yy_bp;
case yy_get_next_buffer is
when EOB_ACT_END_OF_FILE =>
begin
if ( yywrap ) then
-- note: because we've taken care in
-- yy_get_next_buffer() to have set up yytext,
-- we can now set up yy_c_buf_p so that if some
-- total hoser (like aflex itself) wants
-- to call the scanner after we return the
-- End_Of_Input, it'll still work - another
-- End_Of_Input will get returned.
yy_c_buf_p := yytext_ptr;
yy_act := YY_STATE_EOF((yy_start - 1) / 2);
goto do_action;
else
-- start processing a new file
yy_init := true;
goto new_file;
end if;
end;
when EOB_ACT_RESTART_SCAN =>
yy_c_buf_p := yytext_ptr;
yy_hold_char := yy_ch_buf(yy_c_buf_p);
when EOB_ACT_LAST_MATCH =>
yy_c_buf_p := yy_n_chars;
yy_current_state := yy_get_previous_state;
yy_cp := yy_c_buf_p;
yy_bp := yytext_ptr;
goto next_action;
when others => null;
end case; -- case yy_get_next_buffer()
when others =>
text_io.put( "action # " );
text_io.put( INTEGER'IMAGE(yy_act) );
text_io.new_line;
raise AFLEX_INTERNAL_ERROR;
end case; -- case (yy_act)
end loop; -- end of loop waiting for end of file
end YYLex;
--# line 99 "vole_lex.l"
end kv.avm.Vole_Lex;
|
with PixelArray;
package ImageFilters is
type Kernel is array (Natural range <>) of Float;
function generateKernel(size: Positive; sigma: Float) return Kernel;
function gaussian(image: PixelArray.ImagePlane; size: Positive; sigma: Float) return PixelArray.ImagePlane;
end ImageFilters;
|
-- This spec has been automatically generated from cm7.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package Cortex_M_SVD.NVIC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Interrupt Set-Enable Registers
-- Interrupt Set-Enable Registers
type NVIC_ISER_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Clear-Enable Registers
-- Interrupt Clear-Enable Registers
type NVIC_ICER_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Set-Pending Registers
-- Interrupt Set-Pending Registers
type NVIC_ISPR_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Clear-Pending Registers
-- Interrupt Clear-Pending Registers
type NVIC_ICPR_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Active Bit Register
-- Interrupt Active Bit Register
type NVIC_IABR_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Priority Register
-- Interrupt Priority Register
type NVIC_IPR_Registers is array (0 .. 59) of HAL.UInt32
with Volatile;
subtype STIR_INTID_Field is HAL.UInt9;
-- Software Trigger Interrupt Register
type STIR_Register is record
-- Write-only. Interrupt ID of the interrupt to trigger, in the range
-- 0-239.
INTID : STIR_INTID_Field := 16#0#;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STIR_Register use record
INTID at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type NVIC_Peripheral is record
-- Interrupt Set-Enable Registers
NVIC_ISER : aliased NVIC_ISER_Registers;
-- Interrupt Clear-Enable Registers
NVIC_ICER : aliased NVIC_ICER_Registers;
-- Interrupt Set-Pending Registers
NVIC_ISPR : aliased NVIC_ISPR_Registers;
-- Interrupt Clear-Pending Registers
NVIC_ICPR : aliased NVIC_ICPR_Registers;
-- Interrupt Active Bit Register
NVIC_IABR : aliased NVIC_IABR_Registers;
-- Interrupt Priority Register
NVIC_IPR : aliased NVIC_IPR_Registers;
-- Software Trigger Interrupt Register
STIR : aliased STIR_Register;
end record
with Volatile;
for NVIC_Peripheral use record
NVIC_ISER at 16#0# range 0 .. 255;
NVIC_ICER at 16#80# range 0 .. 255;
NVIC_ISPR at 16#100# range 0 .. 255;
NVIC_ICPR at 16#180# range 0 .. 255;
NVIC_IABR at 16#200# range 0 .. 255;
NVIC_IPR at 16#300# range 0 .. 1919;
STIR at 16#E00# range 0 .. 31;
end record;
NVIC_Periph : aliased NVIC_Peripheral
with Import, Address => NVIC_Base;
end Cortex_M_SVD.NVIC;
|
with System;
--
package Application_Types is
type Time_Unit is (millisecond, second);
Time_Unit_First: constant Time_Unit := Time_Unit'first;
----------------------------------------------------------------------------------------------
type Base_Integer_Type is new integer;
function "+" (A : Base_Integer_Type;
B : Base_Integer_Type) return Base_Integer_Type;
function "-" (A : Base_Integer_Type;
B : Base_Integer_Type) return Base_Integer_Type;
function "*" (A : Base_Integer_Type;
B : Base_Integer_Type) return Base_Integer_Type;
function "/" (Numerator : Base_Integer_Type;
Denominator : Base_Integer_Type) return Base_Integer_Type;
type Base_Float_Type is new float;
function "+" (A : Base_Float_Type;
B : Base_Float_Type) return Base_Float_Type;
function "-" (A : Base_Float_Type;
B : Base_Float_Type) return Base_Float_Type;
function "*" (A : Base_Float_Type;
B : Base_Float_Type) return Base_Float_Type;
function "/" (Numerator : Base_Float_Type;
Denominator : Base_Float_Type) return Base_Float_Type;
function "**" (A : Base_Float_Type;
B : Integer) return Base_Float_Type;
-- Do not change this value without exceedingly good reasons.
Maximum_Number_Of_Characters_In_String : constant Positive := 32;
subtype Base_Text_Index_Type is Positive range 1 .. Maximum_Number_Of_Characters_In_String;
subtype Base_Text_Type is string (Base_Text_Index_Type'range);
subtype Base_Boolean_Type is Boolean;
----------------------------------------------------------------------------------------------
Base_Integer_Type_First : constant Base_Integer_Type := 0;
Base_Float_Type_First : constant Base_Float_Type := 0.0;
Base_Boolean_Type_First : constant Boolean := False;
Boolean_First : constant Boolean := False; -- To be depracated by Base_Boolean_Type_First
Base_Text_Type_First : constant Base_Text_Type := (others => ' ');
Time_First : constant Base_Integer_Type := 0;
----------------------------------------------------------------------------------------------
-- JM Debug code GLOBAL DATA ACCESS for Debugging purposes.
--
Count_Of_Objects : integer := 0;
Count_Of_Relationships : integer := 0;
Count_Of_Lists : integer := 0;
Count_Of_Structures : integer := 0;
Count_Of_Events : integer := 0;
----------------------------------------------------------------------------------------------
--
-- This is a hard coded value, and should therefore be changed if any new
-- type or subtype is added. The count includes :
-- (1) Time_Unit
-- (2) Base_Integer_Type
-- (3) Base_Float_Type
-- (4) Base_Boolean_Type
-- (5) Base_Text_Type
-- (6) Base_Text_Index_Type
Types_And_Subtypes_Count : constant Base_Integer_Type := 6;
Stop_Application : exception;
----------------------------------------------------------------------------------------------
end Application_Types;
|
-----------------------------------------------------------------------
-- asf-tests - ASF Tests Framework
-- Copyright (C) 2011, 2012, 2013, 2015, 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Servlet.Core;
with ASF.Servlets.Faces;
with ASF.Servlets.Ajax;
with Servlet.Filters;
with Servlet.Core.Files;
with Servlet.Core.Measures;
with ASF.Responses;
with ASF.Contexts.Faces;
with EL.Variables.Default;
package body ASF.Tests is
CONTEXT_PATH : constant String := "/asfunit";
App_Created : ASF.Applications.Main.Application_Access;
App : ASF.Applications.Main.Application_Access;
Faces : aliased ASF.Servlets.Faces.Faces_Servlet;
Ajax : aliased ASF.Servlets.Ajax.Ajax_Servlet;
Files : aliased Servlet.Core.Files.File_Servlet;
Measures : aliased Servlet.Core.Measures.Measure_Servlet;
-- ------------------------------
-- Initialize the awa test framework mockup.
-- ------------------------------
procedure Initialize (Props : in Util.Properties.Manager;
Application : in ASF.Applications.Main.Application_Access := null;
Factory : in out ASF.Applications.Main.Application_Factory'Class) is
use type ASF.Applications.Main.Application_Access;
C : ASF.Applications.Config;
Empty : Util.Properties.Manager;
begin
if Application /= null then
App := Application;
else
if App_Created = null then
App_Created := new ASF.Applications.Main.Application;
end if;
App := App_Created;
end if;
C.Copy (Props);
App.Initialize (C, Factory);
App.Register ("layoutMsg", "layout");
App.Set_Global ("contextPath", CONTEXT_PATH);
-- Register the servlets and filters
App.Add_Servlet (Name => "faces", Server => Faces'Access);
App.Add_Servlet (Name => "ajax", Server => Ajax'Access);
App.Add_Servlet (Name => "files", Server => Files'Access);
App.Add_Servlet (Name => "measures", Server => Measures'Access);
App.Add_Filter (Name => "measures",
Filter => Servlet.Filters.Filter'Class (Measures)'Access);
-- Define servlet mappings
App.Add_Mapping (Name => "faces", Pattern => "*.html");
App.Add_Mapping (Name => "ajax", Pattern => "/ajax/*");
App.Add_Mapping (Name => "files", Pattern => "*.css");
App.Add_Mapping (Name => "files", Pattern => "*.js");
App.Add_Mapping (Name => "files", Pattern => "*.html");
App.Add_Mapping (Name => "files", Pattern => "*.txt");
App.Add_Mapping (Name => "files", Pattern => "*.png");
App.Add_Mapping (Name => "files", Pattern => "*.jpg");
App.Add_Mapping (Name => "files", Pattern => "*.gif");
App.Add_Mapping (Name => "files", Pattern => "*.pdf");
App.Add_Mapping (Name => "files", Pattern => "*.properties");
App.Add_Mapping (Name => "files", Pattern => "*.xhtml");
App.Add_Mapping (Name => "measures", Pattern => "stats.xml");
App.Add_Filter_Mapping (Name => "measures", Pattern => "*");
App.Add_Filter_Mapping (Name => "measures", Pattern => "/ajax/*");
App.Add_Filter_Mapping (Name => "measures", Pattern => "*.html");
App.Add_Filter_Mapping (Name => "measures", Pattern => "*.xhtml");
Servlet.Tests.Initialize (Empty, CONTEXT_PATH, App.all'Access);
end Initialize;
-- ------------------------------
-- Get the test application.
-- ------------------------------
function Get_Application return ASF.Applications.Main.Application_Access is
use type Servlet.Core.Servlet_Registry_Access;
Result : constant Servlet.Core.Servlet_Registry_Access := Servlet.Tests.Get_Application;
begin
if Result = null then
return App;
elsif Result.all in ASF.Applications.Main.Application'Class then
return ASF.Applications.Main.Application'Class (Result.all)'Access;
else
return App;
end if;
end Get_Application;
-- ------------------------------
-- Cleanup the test instance.
-- ------------------------------
overriding
procedure Tear_Down (T : in out EL_Test) is
procedure Free is
new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_Context'Class,
EL.Contexts.Default.Default_Context_Access);
procedure Free is
new Ada.Unchecked_Deallocation (EL.Variables.Variable_Mapper'Class,
EL.Variables.Variable_Mapper_Access);
procedure Free is
new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_ELResolver'Class,
EL.Contexts.Default.Default_ELResolver_Access);
begin
ASF.Contexts.Faces.Restore (null);
Free (T.ELContext);
Free (T.Variables);
Free (T.Root_Resolver);
end Tear_Down;
-- ------------------------------
-- Setup the test instance.
-- ------------------------------
overriding
procedure Set_Up (T : in out EL_Test) is
begin
T.ELContext := new EL.Contexts.Default.Default_Context;
T.Root_Resolver := new EL.Contexts.Default.Default_ELResolver;
T.Variables := new EL.Variables.Default.Default_Variable_Mapper;
T.ELContext.Set_Resolver (T.Root_Resolver.all'Access);
T.ELContext.Set_Variable_Mapper (T.Variables.all'Access);
end Set_Up;
end ASF.Tests;
|
with Giza.Timers; use Giza.Timers;
with Ada.Real_Time; use Ada.Real_Time;
with Giza.GUI; use Giza.GUI;
package body Timer_Callback is
Cnt : Integer := 0;
--------------
-- Callback --
--------------
function Callback return Boolean is
begin
-- Put_Line ("Here comes the callback:" & Cnt'Img);
Cnt := Cnt + 1;
Set_Timer (My_Timer'Unchecked_Access, Clock + Milliseconds (500));
return True;
end Callback;
task Touch_Screen is
end Touch_Screen;
task body Touch_Screen is
TS, Prev : Touch_State;
Evt : constant Click_Event_Ref := new Click_Event;
Released_Evt : constant Click_Released_Event_Ref :=
new Click_Released_Event;
begin
Prev.Touch_Detected := False;
loop
TS := Get_Touch_State;
if TS.Touch_Detected /= Prev.Touch_Detected then
if TS.Touch_Detected then
Evt.Pos.X := TS.X;
Evt.Pos.Y := TS.Y;
Emit (Event_Not_Null_Ref (Evt));
else
Emit (Event_Not_Null_Ref (Released_Evt));
end if;
end if;
Prev := TS;
end loop;
end Touch_Screen;
end Timer_Callback;
|
with Ahven; use Ahven;
with AdaBaseXClient; use AdaBaseXClient;
--
-- Requires BaseX server when testing
--
package body ClientTest is
procedure Initialize (T : in out Test) is
begin
Set_Name (T, "My tests");
T.Add_Test_Routine
(Routine => Unknown_Fail'Access, Name => "Unknown_Fail");
T.Add_Test_Routine
(Routine => Port_Fail'Access, Name => "Port_Fail");
T.Add_Test_Routine
(Routine => Connect_Auth'Access, Name => "Connect_Auth");
T.Add_Test_Routine
(Routine => Connect_Pass'Access, Name => "Connect_Pass");
T.Add_Test_Routine
(Routine => Execute_Test'Access, Name => "Execute_Test");
T.Add_Test_Routine
(Routine => Execute_Fail'Access, Name => "Execute_Fail");
T.Add_Test_Routine
(Routine => Create_Drop'Access, Name => "Create_Drop");
T.Add_Test_Routine (Routine => Add_Test'Access, Name => "Add_Test");
T.Add_Test_Routine
(Routine => Replace_Test'Access, Name => "Replace_Test");
T.Add_Test_Routine
(Routine => Query_Test'Access, Name => "Query_Test");
T.Add_Test_Routine
(Routine => Query_Bind'Access, Name => "Query_Bind");
end Initialize;
procedure Unknown_Fail is
result : Boolean;
begin
result := Connect ("unknown", 1_984);
Fail (Message => "Exception expected");
exception
when Error : BaseXException =>
null;
end Unknown_Fail;
procedure Port_Fail is
result : Boolean;
begin
result := Connect ("localhost", 1_985);
Fail (Message => "Exception expected");
exception
when Error : BaseXException =>
null;
end Port_Fail;
procedure Connect_Auth is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("unknown", "test");
Assert (Condition => result = False, Message => "Auth test");
Close;
end Connect_Auth;
procedure Connect_Pass is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
Close;
end Connect_Pass;
procedure Execute_Test is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : String := Execute ("xquery 1+1");
begin
Assert (Condition => Response = "2", Message => "Execute test");
end;
Close;
end Execute_Test;
procedure Execute_Fail is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : String := Execute ("xquery unknown");
begin
Fail (Message => "Exception expected");
end;
exception
when Error : BaseXException =>
Close;
end Execute_Fail;
procedure Create_Drop is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : String := Create ("database", "<x>Hello World!</x>");
begin
null;
end;
declare
Response : String := Execute ("xquery /");
begin
Assert
(Condition => Response = "<x>Hello World!</x>",
Message => "Query database");
end;
declare
Response : String := Execute ("drop db database");
begin
null;
end;
Close;
end Create_Drop;
procedure Add_Test is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : String := Create ("database", "");
begin
null;
end;
declare
Response : String := Add ("Ada.xml", "<x>Hello Ada!</x>");
begin
null;
end;
declare
Response : String := Execute ("xquery /");
begin
Assert
(Condition => Response = "<x>Hello Ada!</x>",
Message => "Query database");
end;
declare
Response : String := Execute ("drop db database");
begin
null;
end;
Close;
end Add_Test;
procedure Replace_Test is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : String := Create ("database", "");
begin
null;
end;
declare
Response : String := Add ("Ada.xml", "<x>Hello Ada!</x>");
begin
null;
end;
declare
Response : String :=
Replace ("Ada.xml", "<x>Ada is awesome!</x>");
begin
null;
end;
declare
Response : String := Execute ("xquery /");
begin
Assert
(Condition => Response = "<x>Ada is awesome!</x>",
Message => "Query database");
end;
declare
Response : String := Execute ("drop db database");
begin
null;
end;
Close;
end Replace_Test;
procedure Query_Test is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : Query := CreateQuery ("1+1");
V : String_Vectors.Vector;
begin
V := Response.Results;
Assert (Condition => V (0) = "2", Message => "Query test");
Response.Close;
end;
Close;
end Query_Test;
procedure Query_Bind is
result : Boolean;
begin
result := Connect ("localhost", 1_984);
Assert (Condition => result = True, Message => "Connect test");
result := Authenticate ("admin", "admin");
Assert (Condition => result = True, Message => "Auth test");
declare
Response : Query :=
CreateQuery
("declare variable $name external; for $i in 1 to 1 return element { $name } { $i }");
begin
Response.Bind ("name", "number", "");
declare
Res : String := Response.Execute;
begin
Assert
(Condition => Res = "<number>1</number>",
Message => "Query bind");
end;
Response.Close;
end;
Close;
end Query_Bind;
end ClientTest;
|
package body System.Fat_LLF is
function frexp (value : Long_Long_Float; exp : access Integer)
return Long_Long_Float
with Import,
Convention => Intrinsic, External_Name => "__builtin_frexpl";
function inf return Long_Long_Float
with Import, Convention => Intrinsic, External_Name => "__builtin_infl";
function isfinite (X : Long_Long_Float) return Integer
with Import,
Convention => Intrinsic, External_Name => "__builtin_isfinite";
pragma Warnings (Off, isfinite); -- [gcc 4.6] excessive prototype checking
package body Attr_Long_Long_Float is
function Compose (Fraction : Long_Long_Float; Exponent : Integer)
return Long_Long_Float is
begin
return Scaling (Attr_Long_Long_Float.Fraction (Fraction), Exponent);
end Compose;
function Exponent (X : Long_Long_Float) return Integer is
Result : aliased Integer;
Dummy : Long_Long_Float;
begin
Dummy := frexp (X, Result'Access);
return Result;
end Exponent;
function Fraction (X : Long_Long_Float) return Long_Long_Float is
Dummy : aliased Integer;
begin
return frexp (X, Dummy'Access);
end Fraction;
function Leading_Part (X : Long_Long_Float; Radix_Digits : Integer)
return Long_Long_Float
is
S : constant Integer := Radix_Digits - Exponent (X);
begin
return Scaling (Truncation (Scaling (X, S)), -S);
end Leading_Part;
function Machine (X : Long_Long_Float) return Long_Long_Float is
begin
return X; -- ???
end Machine;
function Pred (X : Long_Long_Float) return Long_Long_Float is
begin
return Adjacent (X, -inf);
end Pred;
function Succ (X : Long_Long_Float) return Long_Long_Float is
begin
return Adjacent (X, inf);
end Succ;
function Unbiased_Rounding (X : Long_Long_Float)
return Long_Long_Float is
begin
return X - Remainder (X, 1.0);
end Unbiased_Rounding;
function Valid (X : not null access Long_Long_Float) return Boolean is
begin
return isfinite (X.all) /= 0;
end Valid;
end Attr_Long_Long_Float;
end System.Fat_LLF;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Ver_Dicotomica is
type T_Vector is array (Positive range <>) of Integer;
Vector: T_Vector (1..10);
I: Integer;
function Dicotomica (Vector: T_Vector; N:Integer) return Integer is
mid : Integer := ((Vector'First + Vector'Last) / 2);
begin
-- COMPLETAR
if N > Vector'Size or Vector'Size = 0 then
return -1;
end if;
if Vector((mid)) = I then
return mid;
end if;
if Vector((mid)) > I then
return Dicotomica(Vector(Vector'First .. mid - 1), I);
end if;
if Vector((mid)) < I then
return Dicotomica(Vector(mid + 1 .. Vector'Last), I);
end if;
return -1;
end Dicotomica;
pos : Integer;
begin
Put_Line ("Dame un vector ordenado de menor a mayor de 10 enteros, un entero Por linea:");
for J in 1 .. 10 loop
Get(Vector(J));
end loop;
Put_Line ("Dame un entero a buscar:");
Get (I);
Put_line ("El resultado de la busqueda es:");
pos := Dicotomica(Vector,I);
if pos /= -1 then
Put_line("Encontrado y posicion: " & Integer'Image(pos));
else
Put_line("No encontrado.");
end if;
end Ver_Dicotomica;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . R I D E N T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package defines the set of restriction identifiers. It is a generic
-- package that is instantiated by the compiler/binder in package Rident, and
-- is instantiated in package System.Restrictions for use at run-time.
-- The reason that we make this a generic package is so that in the case of
-- the instantiation in Rident for use at compile time and bind time, we can
-- generate normal image tables for the enumeration types, which are needed
-- for diagnostic and informational messages. At run-time we really do not
-- want to waste the space for these image tables, and they are not needed,
-- so we can do the instantiation under control of Discard_Names to remove
-- the tables.
pragma Compiler_Unit;
generic
package System.Rident is
pragma Preelaborate;
-- The following enumeration type defines the set of restriction
-- identifiers that are implemented in GNAT.
-- To add a new restriction identifier, add an entry with the name to be
-- used in the pragma, and add calls to the Restrict.Check_Restriction
-- routine as appropriate.
type Restriction_Id is
-- The following cases are checked for consistency in the binder. The
-- binder will check that every unit either has the restriction set, or
-- does not violate the restriction.
(Simple_Barriers, -- GNAT (Ravenscar)
No_Abort_Statements, -- (RM D.7(5), H.4(3))
No_Access_Subprograms, -- (RM H.4(17))
No_Allocators, -- (RM H.4(7))
No_Allocators_After_Elaboration, -- Ada 2012 (RM D.7(19.1/2))
No_Anonymous_Allocators, -- Ada 2012 (RM H.4(8/1))
No_Asynchronous_Control, -- (RM D.7(10))
No_Calendar, -- GNAT
No_Default_Stream_Attributes, -- Ada 2012 (RM 13.12.1(4/2))
No_Delay, -- (RM H.4(21))
No_Direct_Boolean_Operators, -- GNAT
No_Dispatch, -- (RM H.4(19))
No_Dispatching_Calls, -- GNAT
No_Dynamic_Attachment, -- GNAT
No_Dynamic_Priorities, -- (RM D.9(9))
No_Enumeration_Maps, -- GNAT
No_Entry_Calls_In_Elaboration_Code, -- GNAT
No_Entry_Queue, -- GNAT (Ravenscar)
No_Exception_Handlers, -- GNAT
No_Exception_Propagation, -- GNAT
No_Exception_Registration, -- GNAT
No_Exceptions, -- (RM H.4(12))
No_Finalization, -- GNAT
No_Fixed_Point, -- (RM H.4(15))
No_Floating_Point, -- (RM H.4(14))
No_IO, -- (RM H.4(20))
No_Implicit_Conditionals, -- GNAT
No_Implicit_Dynamic_Code, -- GNAT
No_Implicit_Heap_Allocations, -- (RM D.8(8), H.4(3))
No_Implicit_Loops, -- GNAT
No_Initialize_Scalars, -- GNAT
No_Local_Allocators, -- (RM H.4(8))
No_Local_Timing_Events, -- (RM D.7(10.2/2))
No_Local_Protected_Objects, -- GNAT
No_Nested_Finalization, -- (RM D.7(4))
No_Protected_Type_Allocators, -- GNAT
No_Protected_Types, -- (RM H.4(5))
No_Recursion, -- (RM H.4(22))
No_Reentrancy, -- (RM H.4(23))
No_Relative_Delay, -- GNAT (Ravenscar)
No_Requeue_Statements, -- GNAT
No_Secondary_Stack, -- GNAT
No_Select_Statements, -- GNAT (Ravenscar)
No_Specific_Termination_Handlers, -- (RM D.7(10.7/2))
No_Standard_Storage_Pools, -- GNAT
No_Stream_Optimizations, -- GNAT
No_Streams, -- GNAT
No_Task_Allocators, -- (RM D.7(7))
No_Task_Attributes_Package, -- GNAT
No_Task_Hierarchy, -- (RM D.7(3), H.4(3))
No_Task_Termination, -- GNAT (Ravenscar)
No_Tasking, -- GNAT
No_Terminate_Alternatives, -- (RM D.7(6))
No_Unchecked_Access, -- (RM H.4(18))
No_Unchecked_Conversion, -- (RM H.4(16))
No_Unchecked_Deallocation, -- (RM H.4(9))
Static_Priorities, -- GNAT
Static_Storage_Size, -- GNAT
-- The following require consistency checking with special rules. See
-- individual routines in unit Bcheck for details of what is required.
No_Default_Initialization, -- GNAT
-- The following cases do not require consistency checking and if used
-- as a configuration pragma within a specific unit, apply only to that
-- unit (e.g. if used in the package spec, do not apply to the body)
-- Note: No_Elaboration_Code is handled specially. Like the other
-- non-partition-wide restrictions, it can only be set in a unit that
-- is part of the extended main source unit (body/spec/subunits). But
-- it is sticky, in that if it is found anywhere within any of these
-- units, it applies to all units in this extended main source.
Immediate_Reclamation, -- (RM H.4(10))
No_Implementation_Aspect_Specifications, -- Ada 2012 AI-241
No_Implementation_Attributes, -- Ada 2005 AI-257
No_Implementation_Identifiers, -- Ada 2012 AI-246
No_Implementation_Pragmas, -- Ada 2005 AI-257
No_Implementation_Restrictions, -- GNAT
No_Implementation_Units, -- Ada 2012 AI-242
No_Implicit_Aliasing, -- GNAT
No_Elaboration_Code, -- GNAT
No_Obsolescent_Features, -- Ada 2005 AI-368
No_Wide_Characters, -- GNAT
SPARK, -- GNAT
-- The following cases require a parameter value
-- The following entries are fully checked at compile/bind time, which
-- means that the compiler can in general tell the minimum value which
-- could be used with a restrictions pragma. The binder can deduce the
-- appropriate minimum value for the partition by taking the maximum
-- value required by any unit.
Max_Protected_Entries, -- (RM D.7(14))
Max_Select_Alternatives, -- (RM D.7(12))
Max_Task_Entries, -- (RM D.7(13), H.4(3))
-- The following entries are also fully checked at compile/bind time,
-- and the compiler can also at least in some cases tell the minimum
-- value which could be used with a restriction pragma. The difference
-- is that the contributions are additive, so the binder deduces this
-- value by adding the unit contributions.
Max_Tasks, -- (RM D.7(19), H.4(3))
-- The following entries are checked at compile time only for zero/
-- nonzero entries. This means that the compiler can tell at compile
-- time if a restriction value of zero is (would be) violated, but that
-- the compiler cannot distinguish between different non-zero values.
Max_Asynchronous_Select_Nesting, -- (RM D.7(18), H.4(3))
Max_Entry_Queue_Length, -- GNAT
-- The remaining entries are not checked at compile/bind time
Max_Storage_At_Blocking, -- (RM D.7(17))
Not_A_Restriction_Id);
-- Synonyms permitted for historical purposes of compatibility.
-- Must be coordinated with Restrict.Process_Restriction_Synonym.
Boolean_Entry_Barriers : Restriction_Id renames Simple_Barriers;
Max_Entry_Queue_Depth : Restriction_Id renames Max_Entry_Queue_Length;
No_Dynamic_Interrupts : Restriction_Id renames No_Dynamic_Attachment;
No_Requeue : Restriction_Id renames No_Requeue_Statements;
No_Task_Attributes : Restriction_Id renames No_Task_Attributes_Package;
subtype All_Restrictions is Restriction_Id range
Simple_Barriers .. Max_Storage_At_Blocking;
-- All restrictions (excluding only Not_A_Restriction_Id)
subtype All_Boolean_Restrictions is Restriction_Id range
Simple_Barriers .. SPARK;
-- All restrictions which do not take a parameter
subtype Partition_Boolean_Restrictions is All_Boolean_Restrictions range
Simple_Barriers .. Static_Storage_Size;
-- Boolean restrictions that are checked for partition consistency.
-- Note that all parameter restrictions are checked for partition
-- consistency by default, so this distinction is only needed in the
-- case of Boolean restrictions.
subtype Cunit_Boolean_Restrictions is All_Boolean_Restrictions range
Immediate_Reclamation .. SPARK;
-- Boolean restrictions that are not checked for partition consistency
-- and that thus apply only to the current unit. Note that for these
-- restrictions, the compiler does not apply restrictions found in
-- with'ed units, parent specs etc. to the main unit, and vice versa.
subtype All_Parameter_Restrictions is
Restriction_Id range
Max_Protected_Entries .. Max_Storage_At_Blocking;
-- All restrictions that take a parameter
subtype Checked_Parameter_Restrictions is
All_Parameter_Restrictions range
Max_Protected_Entries .. Max_Entry_Queue_Length;
-- These are the parameter restrictions that can be at least partially
-- checked at compile/binder time. Minimally, the compiler can detect
-- violations of a restriction pragma with a value of zero reliably.
subtype Checked_Max_Parameter_Restrictions is
Checked_Parameter_Restrictions range
Max_Protected_Entries .. Max_Task_Entries;
-- Restrictions with parameters that can be checked in some cases by
-- maximizing among statically detected instances where the compiler
-- can determine the count.
subtype Checked_Add_Parameter_Restrictions is
Checked_Parameter_Restrictions range
Max_Tasks .. Max_Tasks;
-- Restrictions with parameters that can be checked in some cases by
-- summing the statically detected instances where the compiler can
-- determine the count.
subtype Checked_Val_Parameter_Restrictions is
Checked_Parameter_Restrictions range
Max_Protected_Entries .. Max_Tasks;
-- Restrictions with parameter where the count is known at least in some
-- cases by the compiler/binder.
subtype Checked_Zero_Parameter_Restrictions is
Checked_Parameter_Restrictions range
Max_Asynchronous_Select_Nesting .. Max_Entry_Queue_Length;
-- Restrictions with parameters where the compiler can detect the use of
-- the feature, and hence violations of a restriction specifying a value
-- of zero, but cannot detect specific values other than zero/nonzero.
subtype Unchecked_Parameter_Restrictions is
All_Parameter_Restrictions range
Max_Storage_At_Blocking .. Max_Storage_At_Blocking;
-- Restrictions with parameters where the compiler cannot ever detect
-- corresponding compile time usage, so the binder and compiler never
-- detect violations of any restriction.
-------------------------------------
-- Restriction Status Declarations --
-------------------------------------
-- The following declarations are used to record the current status or
-- restrictions (for the current unit, or related units, at compile time,
-- and for all units in a partition at bind time or run time).
type Restriction_Flags is array (All_Restrictions) of Boolean;
type Restriction_Values is array (All_Parameter_Restrictions) of Natural;
type Parameter_Flags is array (All_Parameter_Restrictions) of Boolean;
type Restrictions_Info is record
Set : Restriction_Flags;
-- An entry is True in the Set array if a restrictions pragma has been
-- encountered for the given restriction. If the value is True for a
-- parameter restriction, then the corresponding entry in the Value
-- array gives the minimum value encountered for any such restriction.
Value : Restriction_Values;
-- If the entry for a parameter restriction in Set is True (i.e. a
-- restrictions pragma for the restriction has been encountered), then
-- the corresponding entry in the Value array is the minimum value
-- specified by any such restrictions pragma. Note that a restrictions
-- pragma specifying a value greater than Int'Last is simply ignored.
Violated : Restriction_Flags;
-- An entry is True in the violations array if the compiler has detected
-- a violation of the restriction. For a parameter restriction, the
-- Count and Unknown arrays have additional information.
Count : Restriction_Values;
-- If an entry for a parameter restriction is True in Violated, the
-- corresponding entry in the Count array may record additional
-- information. If the actual minimum count is known (by taking
-- maximums, or sums, depending on the restriction), it will be
-- recorded in this array. If not, then the value will remain zero.
-- The value is also zero for a non-violated restriction.
Unknown : Parameter_Flags;
-- If an entry for a parameter restriction is True in Violated, the
-- corresponding entry in the Unknown array may record additional
-- information. If the actual count is not known by the compiler (but
-- is known to be non-zero), then the entry in Unknown will be True.
-- This indicates that the value in Count is not known to be exact,
-- and the actual violation count may be higher.
-- Note: If Violated (K) is True, then either Count (K) > 0 or
-- Unknown (K) = True. It is possible for both these to be set.
-- For example, if Count (K) = 3 and Unknown (K) is True, it means
-- that the actual violation count is at least 3 but might be higher.
end record;
No_Restrictions : constant Restrictions_Info :=
(Set => (others => False),
Value => (others => 0),
Violated => (others => False),
Count => (others => 0),
Unknown => (others => False));
-- Used to initialize Restrictions_Info variables
----------------------------------
-- Profile Definitions and Data --
----------------------------------
-- Note: to add a profile, modify the following declarations appropriately,
-- add Name_xxx to Snames, and add a branch to the conditions for pragmas
-- Profile and Profile_Warnings in the body of Sem_Prag.
type Profile_Name is
(No_Profile,
No_Implementation_Extensions,
Ravenscar,
Restricted);
-- Names of recognized profiles. No_Profile is used to indicate that a
-- restriction came from pragma Restrictions[_Warning], as opposed to
-- pragma Profile[_Warning].
subtype Profile_Name_Actual is Profile_Name
range No_Implementation_Extensions .. Restricted;
-- Actual used profile names
type Profile_Data is record
Set : Restriction_Flags;
-- Set to True if given restriction must be set for the profile, and
-- False if it need not be set (False does not mean that it must not be
-- set, just that it need not be set). If the flag is True for a
-- parameter restriction, then the Value array gives the maximum value
-- permitted by the profile.
Value : Restriction_Values;
-- An entry in this array is meaningful only if the corresponding flag
-- in Set is True. In that case, the value in this array is the maximum
-- value of the parameter permitted by the profile.
end record;
Profile_Info : constant array (Profile_Name_Actual) of Profile_Data :=
(No_Implementation_Extensions =>
-- Restrictions for Restricted profile
(Set =>
(No_Implementation_Aspect_Specifications => True,
No_Implementation_Attributes => True,
No_Implementation_Identifiers => True,
No_Implementation_Pragmas => True,
No_Implementation_Units => True,
others => False),
-- Value settings for Restricted profile (none
Value =>
(others => 0)),
-- Restricted Profile
Restricted =>
-- Restrictions for Restricted profile
(Set =>
(No_Abort_Statements => True,
No_Asynchronous_Control => True,
No_Dynamic_Attachment => True,
No_Dynamic_Priorities => True,
No_Entry_Queue => True,
No_Local_Protected_Objects => True,
No_Protected_Type_Allocators => True,
No_Requeue_Statements => True,
No_Task_Allocators => True,
No_Task_Attributes_Package => True,
No_Task_Hierarchy => True,
No_Terminate_Alternatives => True,
Max_Asynchronous_Select_Nesting => True,
Max_Protected_Entries => True,
Max_Select_Alternatives => True,
Max_Task_Entries => True,
others => False),
-- Value settings for Restricted profile
Value =>
(Max_Asynchronous_Select_Nesting => 0,
Max_Protected_Entries => 1,
Max_Select_Alternatives => 0,
Max_Task_Entries => 0,
others => 0)),
-- Ravenscar Profile
-- Note: the table entries here only represent the
-- required restriction profile for Ravenscar. The
-- full Ravenscar profile also requires:
-- pragma Dispatching_Policy (FIFO_Within_Priorities);
-- pragma Locking_Policy (Ceiling_Locking);
-- pragma Detect_Blocking
Ravenscar =>
-- Restrictions for Ravenscar = Restricted profile ..
(Set =>
(No_Abort_Statements => True,
No_Asynchronous_Control => True,
No_Dynamic_Attachment => True,
No_Dynamic_Priorities => True,
No_Entry_Queue => True,
No_Local_Protected_Objects => True,
No_Protected_Type_Allocators => True,
No_Requeue_Statements => True,
No_Task_Allocators => True,
No_Task_Attributes_Package => True,
No_Task_Hierarchy => True,
No_Terminate_Alternatives => True,
Max_Asynchronous_Select_Nesting => True,
Max_Protected_Entries => True,
Max_Select_Alternatives => True,
Max_Task_Entries => True,
-- plus these additional restrictions:
No_Calendar => True,
No_Implicit_Heap_Allocations => True,
No_Relative_Delay => True,
No_Select_Statements => True,
No_Task_Termination => True,
Simple_Barriers => True,
others => False),
-- Value settings for Ravenscar (same as Restricted)
Value =>
(Max_Asynchronous_Select_Nesting => 0,
Max_Protected_Entries => 1,
Max_Select_Alternatives => 0,
Max_Task_Entries => 0,
others => 0)));
end System.Rident;
|
pragma License (Unrestricted);
with Ada.Strings.Bounded;
with Ada.Strings.Bounded_Strings;
with Ada.Text_IO.Generic_Bounded_IO;
generic
with package Bounded is new Strings.Bounded.Generic_Bounded_Length (<>);
package Ada.Text_IO.Bounded_IO is
-- for renaming
package Bounded_Strings_IO is
new Generic_Bounded_IO (
Strings.Bounded_Strings,
Bounded.Bounded_Strings,
Put => Put,
Put_Line => Put_Line,
Get_Line => Get_Line);
procedure Put (
File : File_Type; -- Output_File_Type
Item : Bounded.Bounded_String)
renames Bounded_Strings_IO.Put;
procedure Put (
Item : Bounded.Bounded_String)
renames Bounded_Strings_IO.Put;
procedure Put_Line (
File : File_Type; -- Output_File_Type
Item : Bounded.Bounded_String)
renames Bounded_Strings_IO.Put_Line;
procedure Put_Line (
Item : Bounded.Bounded_String)
renames Bounded_Strings_IO.Put_Line;
function Get_Line (
File : File_Type) -- Input_File_Type
return Bounded.Bounded_String
renames Bounded_Strings_IO.Get_Line;
function Get_Line
return Bounded.Bounded_String
renames Bounded_Strings_IO.Get_Line;
procedure Get_Line (
File : File_Type; -- Input_File_Type
Item : out Bounded.Bounded_String)
renames Bounded_Strings_IO.Get_Line;
procedure Get_Line (
Item : out Bounded.Bounded_String)
renames Bounded_Strings_IO.Get_Line;
end Ada.Text_IO.Bounded_IO;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Types;
package Database.Jobs is
function Get_Current_Job return Types.Job_Id;
-- Get current job from persistent database storage.
procedure Set_Current_Job (Job : in Types.Job_Id);
-- Set current job in persistent storage.
use type Types.Job_Id;
Top_Level : constant Types.Job_Id := 0;
All_Jobs : constant Types.Job_Id := -1;
function Get_Jobs (Top : in Types.Job_Id)
return Types.Job_Sets.Vector;
-- Get set of jobs at level Top.
function Get_Job_Info (Job : in Types.Job_Id)
return Types.Job_Info;
procedure Add_Job (Id : in Types.Job_Id;
Title : in String;
Parent : in Types.Job_Id;
Owner : in String);
function Get_New_Job_Id return Types.Job_Id;
-- Get an Job_Id for a new job.
procedure Transfer (Job : in Types.Job_Id;
To_Parent : in Types.Job_Id);
end Database.Jobs;
|
-----------------------------------------------------------------------
-- servlet-security-filters-oauth -- OAuth Security filter
-- Copyright (C) 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Fixed;
with Util.Log.Loggers;
package body Servlet.Security.Filters.OAuth is
use Ada.Strings.Unbounded;
use Servers;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.Filters.OAuth");
function Get_Access_Token (Request : in Servlet.Requests.Request'Class) return String;
-- ------------------------------
-- Called by the servlet container to indicate to a servlet that the servlet
-- is being placed into service.
-- ------------------------------
procedure Initialize (Server : in out Auth_Filter;
Config : in Servlet.Core.Filter_Config) is
begin
null;
end Initialize;
-- ------------------------------
-- Set the authorization manager that must be used to verify the OAuth token.
-- ------------------------------
procedure Set_Auth_Manager (Filter : in out Auth_Filter;
Manager : in Servers.Auth_Manager_Access) is
begin
Filter.Realm := Manager;
end Set_Auth_Manager;
function Get_Access_Token (Request : in Servlet.Requests.Request'Class) return String is
Header : constant String := Request.Get_Header (AUTHORIZATION_HEADER_NAME);
begin
if Header'Length < 7 or else Header (Header'First .. Header'First + 6) /= "Bearer " then
return "";
end if;
return Ada.Strings.Fixed.Trim (Header (Header'First + 7 .. Header'Last), Ada.Strings.Both);
end Get_Access_Token;
-- ------------------------------
-- Filter the request to make sure the user is authenticated.
-- Invokes the <b>Do_Login</b> procedure if there is no user.
-- If a permission manager is defined, check that the user has the permission
-- to view the page. Invokes the <b>Do_Deny</b> procedure if the permission
-- is denied.
-- ------------------------------
procedure Do_Filter (F : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class;
Chain : in out Servlet.Core.Filter_Chain) is
Servlet : constant String := Request.Get_Servlet_Path;
URL : constant String := Servlet & Request.Get_Path_Info;
begin
if F.Realm = null then
Log.Error ("Deny access on {0} due to missing realm", URL);
Auth_Filter'Class (F).Do_Deny (Request, Response);
return;
end if;
declare
Bearer : constant String := Get_Access_Token (Request);
-- Auth : Principal_Access;
Grant : Servers.Grant_Type;
begin
if Bearer'Length = 0 then
Log.Info ("Ask authentication on {0} due to missing access token", URL);
-- Auth_Filter'Class (F).Do_Login (Request, Response);
Core.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
return;
end if;
F.Realm.Authenticate (Bearer, Grant);
if Grant.Status /= Valid_Grant then
Log.Info ("Ask authentication on {0} due to missing access token", URL);
Auth_Filter'Class (F).Do_Deny (Request, Response);
return;
end if;
Request.Set_User_Principal (Grant.Auth.all'Access);
Core.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
end;
end Do_Filter;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
procedure Do_Login (F : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class) is
pragma Unreferenced (Request);
begin
Response.Send_Error (Servlet.Responses.SC_UNAUTHORIZED);
Response.Add_Header (WWW_AUTHENTICATE_HEADER_NAME,
"Bearer realm=""" & To_String (F.Realm_URL)
& """, error=""invalid_token""");
end Do_Login;
-- ------------------------------
-- Display the forbidden access page. This procedure is called when the user is not
-- authorized to see the page. The default implementation returns the SC_FORBIDDEN error.
-- ------------------------------
procedure Do_Deny (F : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class) is
pragma Unreferenced (Request);
begin
Response.Add_Header (WWW_AUTHENTICATE_HEADER_NAME,
"Bearer realm=""" & To_String (F.Realm_URL)
& """, error=""invalid_token""");
Response.Set_Status (Servlet.Responses.SC_FORBIDDEN);
end Do_Deny;
end Servlet.Security.Filters.OAuth;
|
-- domain package: ${self.name}
-- description: self.description
package ${root_package.name}.${self.name} is
end ${root_package.name}.${self.name};
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . E X T E N S I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-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 --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY 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 ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Declarations; use Asis.Declarations;
with Asis.Definitions; use Asis.Definitions;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Expressions; use Asis.Expressions;
with Asis.Statements; use Asis.Statements;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Opt; use A4G.A_Opt;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Contt; use A4G.Contt;
with A4G.Contt.TT; use A4G.Contt.TT;
with A4G.Contt.UT; use A4G.Contt.UT;
with A4G.DDA_Aux; use A4G.DDA_Aux;
with A4G.Decl_Sem; use A4G.Decl_Sem;
with A4G.Asis_Tables; use A4G.Asis_Tables;
with A4G.Expr_Sem; use A4G.Expr_Sem;
with A4G.GNAT_Int; use A4G.GNAT_Int;
with A4G.Mapping; use A4G.Mapping;
with A4G.Queries; use A4G.Queries;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Namet; use Namet;
with Nlists; use Nlists;
with Output; use Output;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with Uintp; use Uintp;
with Urealp; use Urealp;
package body Asis.Extensions is
Package_Name : constant String := "Asis.Extensions.";
-----------------------
-- Local subprograms --
-----------------------
function Is_Typeless_Subaggregate (Aggr : Node_Id) return Boolean;
-- Checks if Aggr represents an inner typeless subaggregate of
-- multi-dimensional array aggregate. A caller is responsible for providing
-- only nodes that represents components of array aggregates as actuals.
function Is_Expanded_Subprogram (N : Node_Id) return Boolean;
-- Checks if N corresponds to the spec of an expanded generic
-- subprogram. Is needed because Comes_From_Source in this case is
-- set OFF (opposite to expanded packages)
function Is_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean;
-- Checks if Op_Decl declares an operator function having a parameter
-- or a result of the type Type_Decl (Type_Decl is supposed to be a type
-- declaration name). Returns False for a function body if the body has
-- the separate spec
function Overrides_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean;
-- Provided that Is_Type_Operator (Op_Decl, Type_Decl) is True (note,
-- that this function does not check this, it should be checked by the
-- caller), checks if Op_Decl overrides a predefined or inherited
-- operator function that exists for Type_Decl
function Is_From_Import_Procedure_Pragma (N : Node_Id) return Boolean;
-- Checks a specific situation for an identifier specific to a pragma for
-- GNAT-specific pragmas Import_Procedure and Import_Valued_Procedure -
-- for components of MECHANISM_NAME having the form of A (B).
function Get_LF_From_Ureal (U : Ureal) return Long_Long_Float;
-- Converts universal real into Long_Float. This is a quick-and-dirty
-- solution for extending Static_Expression_Value_Image for real image,
-- it may blow up in case if numerator or denominator is too big. The
-- conversion does some arbitrary rounding (I believe this rounding is
-- reasonable, but I have no proof of this)
pragma Unreferenced (Get_LF_From_Ureal);
function Get_Implemented_Op
(Op_Decl : Asis.Element;
Type_Def : Asis.Element)
return Asis.Element;
pragma Unreferenced (Get_Implemented_Op);
-- Op_Decl is supposed to be a declaration of a dispatching operation for
-- that Is_Overriding_Operation is true. Type_Def is supposed to be an
-- interface type definition for some interface type that is included in
-- the interface list of the definition of the type that is the type
-- of dispatching operand(s) of Op_Decl. This function checks if Op_Decl
-- may implement some operation of this interface, and if it may returns
-- the declaration of this interface operation as a result, otherwise it
-- returns Nil_Element.
function Is_Procedure (Decl : Asis.Element) return Boolean;
pragma Unreferenced (Is_Procedure);
-- Checks that Decl declares a procedure
------------------
-- Acts_As_Spec --
------------------
function Acts_As_Spec (Declaration : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
Name_Node : Node_Id;
Spec_Node : Node_Id;
Arg_Ekind : Entity_Kind;
Result : Boolean := False;
begin
Check_Validity (Declaration, Package_Name & "Acts_As_Spec");
Arg_Node := Node (Declaration);
case Arg_Kind is
when A_Procedure_Body_Declaration |
A_Function_Body_Declaration =>
Result := Acts_As_Spec (Arg_Node);
-- The problem here is that for some subprogram bodies the
-- front-end creates artificial specs and sets OFF the
-- Acts_As_Spec flag for the body. At the moment we have detected
-- two such situations (and we exclude the case of expanded
-- subprogram body not to mix up with the similar situation in
-- the tree, see :
if not Result
and then
Special_Case (Declaration) /= Expanded_Subprogram_Instantiation
then
-- (1) Bodies declared immediately within protected bodies
if Nkind (Parent (Arg_Node)) = N_Protected_Body then
Spec_Node := Corresponding_Spec (Arg_Node);
if Is_Artificial_Protected_Op_Item_Spec (Spec_Node) then
Result := True;
end if;
else
-- (2) child subprogram bodies with no separate spec
Name_Node := Defining_Unit_Name (Specification (Arg_Node));
if Nkind (Name_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Corresponding_Spec (Arg_Node);
if Present (Arg_Node) then
while not
(Nkind (Arg_Node) = N_Subprogram_Declaration or else
Nkind (Arg_Node) = N_Generic_Subprogram_Declaration)
loop
Arg_Node := Parent (Arg_Node);
end loop;
Result := not Comes_From_Source (Arg_Node);
end if;
end if;
end if;
end if;
when A_Procedure_Body_Stub |
A_Function_Body_Stub =>
Arg_Ekind := Ekind (Defining_Unit_Name (Specification (Arg_Node)));
Result := Arg_Ekind = E_Function
or else Arg_Ekind = E_Procedure;
when An_Expression_Function_Declaration =>
if Is_Part_Of_Inherited (Declaration) then
Result := True;
else
Result :=
Nkind (R_Node (Declaration)) = N_Subprogram_Declaration;
end if;
when others => null;
end case;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Acts_As_Spec");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Acts_As_Spec",
Ex => Ex,
Arg_Element => Declaration);
end Acts_As_Spec;
------------------------------
-- Compilation_Dependencies --
------------------------------
function Compilation_Dependencies
(Main_Unit : Asis.Compilation_Unit)
return Asis.Compilation_Unit_List
is
Arg_Kind : constant Asis.Unit_Kinds := Kind (Main_Unit);
Arg_Unit_Id : Unit_Id;
Res_Cont_Id : Context_Id;
begin
Check_Validity (Main_Unit, Package_Name & "Compilation_Dependencies");
if Arg_Kind not in A_Procedure .. A_Protected_Body_Subunit then
Raise_ASIS_Inappropriate_Compilation_Unit
(Diagnosis => Package_Name & "Compilation_Dependencies");
end if;
Res_Cont_Id := Encl_Cont_Id (Main_Unit);
Reset_Context (Res_Cont_Id);
Arg_Unit_Id := Get_Unit_Id (Main_Unit);
declare
Result_Id_List : constant Unit_Id_List :=
GNAT_Compilation_Dependencies (Arg_Unit_Id);
Result_List : constant Compilation_Unit_List :=
Get_Comp_Unit_List (Result_Id_List, Res_Cont_Id);
begin
if Is_Nil (Result_List) then
Raise_ASIS_Inappropriate_Compilation_Unit
(Diagnosis => Package_Name & "Compilation_Dependencies");
else
return Result_List;
end if;
end;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Compilation_Dependencies");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Compilation_Dependencies",
Ex => Ex,
Arg_CU => Main_Unit);
end Compilation_Dependencies;
-------------
-- Compile --
-------------
procedure Compile
(Source_File : String_Access;
Args : Argument_List;
Success : out Boolean;
GCC : String_Access := null;
Use_GNATMAKE : Boolean := False;
Use_Temp_Prj : Boolean := False;
Compiler_Out : String := "";
All_Warnings_Off : Boolean := True;
Display_Call : Boolean := False)
is
Comp_Args : Argument_List (Args'First .. Args'Last + 12 + 1);
First_Idx : constant Integer := Comp_Args'First;
Last_Idx : Integer := First_Idx;
Obj_Name : String_Access;
Dot_Idx : Natural;
Is_GNAAMP_Call : Boolean := False;
-- In case of the call to GNAAMP we should not set '-x ada' flags
Is_GNATMAKE_Call : Boolean := Use_GNATMAKE;
begin
if Is_GNATMAKE_Call and then GCC = null then
-- We can not set gnatmake-specific parameters in this case
Is_GNATMAKE_Call := False;
end if;
if GCC /= null then
declare -- ??? What an awful code!
Name : constant String := To_Lower (Base_Name (GCC.all));
Dot_Idx : Positive := Name'Last;
begin
for J in reverse Name'Range loop
if Name (J) = '.' then
Dot_Idx := J - 1;
exit;
end if;
end loop;
if Name (Name'First .. Dot_Idx) = "gnaamp" then
Is_GNAAMP_Call := True;
end if;
end;
end if;
Comp_Args (Last_Idx) := Comp_Flag;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNAT_Flag_ct;
Last_Idx := Last_Idx + 1;
if Is_GNATMAKE_Call then
Comp_Args (Last_Idx) := GNATMAKE_Flag_u;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNATMAKE_Flag_f;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNATMAKE_Flag_q;
Last_Idx := Last_Idx + 1;
elsif not Is_GNAAMP_Call then
Comp_Args (Last_Idx) := GCC_Flag_X;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GCC_Par_Ada;
Last_Idx := Last_Idx + 1;
end if;
for J in Args'Range loop
Comp_Args (Last_Idx) := Args (J);
Last_Idx := Last_Idx + 1;
end loop;
if All_Warnings_Off then
Comp_Args (Last_Idx) := GNAT_Flag_ws;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNAT_Flag_yN;
Last_Idx := Last_Idx + 1;
end if;
Comp_Args (Last_Idx) := Source_File;
if Is_GNATMAKE_Call
and then
not Use_Temp_Prj
then
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GNATMAKE_Flag_cargs;
Last_Idx := Last_Idx + 1;
Comp_Args (Last_Idx) := GCC_Flag_o;
Last_Idx := Last_Idx + 1;
Obj_Name := new String'(Base_Name (Source_File.all));
Dot_Idx := Obj_Name'Last;
for J in reverse Obj_Name'Range loop
if Obj_Name (J) = '.' then
Dot_Idx := J - 1;
exit;
end if;
end loop;
Comp_Args (Last_Idx) := new String'
(Get_Current_Dir &
Directory_Separator &
Obj_Name (Obj_Name'First .. Dot_Idx) &
".o");
end if;
Success :=
Execute
(GCC, Comp_Args (Args'First .. Last_Idx), Compiler_Out,
Display_Call => Display_Call);
end Compile;
----------------
-- Components --
----------------
function Components (E : Asis.Element) return Asis.Element_List is
Child_Access : constant Query_Array := Appropriate_Queries (E);
Result_Length : Integer := 0;
begin
Check_Validity (E, Package_Name & "Components");
if Is_Nil (E) then
return Nil_Element_List;
end if;
-- first, we compute the result's length:
for Each_Query in Child_Access'Range loop
case Child_Access (Each_Query).Query_Kind is
when Bug =>
null;
when Single_Element_Query =>
if not Is_Nil (Child_Access (Each_Query).Func_Simple (E)) then
Result_Length := Result_Length + 1;
end if;
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (E);
begin
Result_Length := Result_Length + Child_List'Length;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(E, Child_Access (Each_Query).Bool);
begin
Result_Length := Result_Length + Child_List'Length;
end;
end case;
end loop;
-- and now, we define the result element list of Result_Length
-- length and fill it in by repeating the same loop. This is
-- not effective, and this will have to be revised.
if Result_Length = 0 then
return Nil_Element_List;
end if;
declare
Result_List : Asis.Element_List (1 .. Result_Length);
Next_Element : Integer := 1;
begin
for Each_Query in Child_Access'Range loop
case Child_Access (Each_Query).Query_Kind is
when Bug =>
null;
when Single_Element_Query =>
if not Is_Nil
(Child_Access (Each_Query).Func_Simple (E)) then
Result_List (Next_Element) :=
Child_Access (Each_Query).Func_Simple (E);
Next_Element := Next_Element + 1;
end if;
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (E);
begin
for I in Child_List'First .. Child_List'Last loop
Result_List (Next_Element) := Child_List (I);
Next_Element := Next_Element + 1;
end loop;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(E, Child_Access (Each_Query).Bool);
begin
for I in Child_List'First .. Child_List'Last loop
Result_List (Next_Element) := Child_List (I);
Next_Element := Next_Element + 1;
end loop;
end;
end case;
end loop;
return Result_List;
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => E,
Outer_Call => Package_Name & "Components");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Components",
Ex => Ex,
Arg_Element => E);
end Components;
-----------------------------------------------
-- Corresponding_Body_Parameter_Definition --
-----------------------------------------------
function Corresponding_Body_Parameter_Definition
(Defining_Name : Asis.Defining_Name)
return Asis.Defining_Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Defining_Name);
Encl_Constr : Asis.Element;
Encl_Constr_Kind : Internal_Element_Kinds;
Result : Asis.Element := Nil_Element;
begin
Check_Validity
(Defining_Name,
Package_Name & "Corresponding_Body_Parameter_Definition");
if Arg_Kind /= A_Defining_Identifier then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Body_Parameter_Definition",
Wrong_Kind => Arg_Kind);
end if;
Encl_Constr := Enclosing_Element (Defining_Name);
if Declaration_Kind (Encl_Constr) not in A_Formal_Declaration then
Encl_Constr := (Enclosing_Element (Encl_Constr));
end if;
Encl_Constr_Kind := Int_Kind (Encl_Constr);
case Encl_Constr_Kind is
when A_Procedure_Body_Declaration |
A_Function_Body_Declaration =>
Result := Defining_Name;
when A_Procedure_Body_Stub |
A_Function_Body_Stub =>
Encl_Constr := Corresponding_Subunit (Encl_Constr);
when A_Procedure_Declaration |
A_Function_Declaration |
A_Generic_Function_Declaration |
A_Generic_Procedure_Declaration =>
Encl_Constr := Corresponding_Body (Encl_Constr);
Encl_Constr_Kind := Int_Kind (Encl_Constr);
if Encl_Constr_Kind = A_Procedure_Body_Stub or else
Encl_Constr_Kind = A_Function_Body_Stub
then
Encl_Constr := Corresponding_Subunit (Encl_Constr);
elsif Encl_Constr_Kind = An_Import_Pragma then
Encl_Constr := Nil_Element;
end if;
when others =>
-- For all the other situations we can not return a parameter
-- definition in the body
Encl_Constr := Nil_Element;
end case;
if not Is_Nil (Result)
or else
Is_Nil (Encl_Constr)
or else
Declaration_Kind (Encl_Constr) = Not_A_Declaration
then
return Result;
end if;
Process_Parameter_Specifications : declare
Def_Name_Image : constant String
:= To_Lower (To_String (Defining_Name_Image (Defining_Name)));
Param_Specs : constant Asis.Element_List
:= Parameter_Profile (Encl_Constr);
begin
Through_Parameter_Specs : for I in Param_Specs'Range loop
Process_Parameter_Names : declare
Par_Names : constant Asis.Element_List :=
Names (Param_Specs (I));
begin
Through_Parameter_Names : for J in Par_Names'Range loop
if Def_Name_Image =
To_Lower (To_String (Defining_Name_Image
(Par_Names (J))))
then
Result := Par_Names (J);
exit Through_Parameter_Specs;
end if;
end loop Through_Parameter_Names;
end Process_Parameter_Names;
end loop Through_Parameter_Specs;
end Process_Parameter_Specifications;
pragma Assert (not Is_Nil (Result));
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Defining_Name,
Outer_Call => Package_Name &
"Corresponding_Body_Parameter_Definition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Body_Parameter_Definition",
Ex => Ex,
Arg_Element => Defining_Name);
end Corresponding_Body_Parameter_Definition;
-----------------------------------------
-- Corresponding_Called_Entity_Unwound --
-----------------------------------------
function Corresponding_Called_Entity_Unwound
(Statement : Asis.Statement)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Arg_Node_Kind : Node_Kind;
Result_Node : Node_Id;
Result_Unit : Compilation_Unit;
Res_Spec_Case : Special_Cases := Not_A_Special_Case;
begin
Check_Validity
(Statement, Package_Name & "Corresponding_Called_Entity_Unwound");
if not (Arg_Kind = An_Entry_Call_Statement or else
Arg_Kind = A_Procedure_Call_Statement)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Called_Entity_Unwound",
Wrong_Kind => Arg_Kind);
end if;
-- the implementation approach is similar to the approach taken for
-- Asis.Expressions.Corresponding_Called_Function
Arg_Node := R_Node (Statement);
-- To be on the safe side, we use R_Node instead of Node, but it looks
-- like in this case R_Node and Node should be the same
Arg_Node_Kind := Nkind (Arg_Node);
case Arg_Node_Kind is
when N_Attribute_Reference =>
return Nil_Element;
-- call to a procedure-attribute
when N_Entry_Call_Statement | N_Procedure_Call_Statement =>
-- here we have to filter out the case when Nil_Element
-- should be returned for a call through access-to-function:
if Nkind (Sinfo.Name (Arg_Node)) = N_Explicit_Dereference then
return Nil_Element;
end if;
-- ??? <tree problem 4>
-- this fragment should be revised when the problem is fixed (as it should)
if Arg_Node_Kind = N_Entry_Call_Statement then
Result_Node := Sinfo.Name (Arg_Node);
-- Result_Node points to the name of the called entry
if Nkind (Result_Node) = N_Indexed_Component then
-- this is the case for a call to an entry from an
-- entry family
Result_Node := Prefix (Result_Node);
end if;
Result_Node := Entity (Selector_Name (Result_Node));
else
Result_Node := Entity (Sinfo.Name (Arg_Node));
-- only this assignment is needed if tree problem 4 is
-- fixed
end if;
-- ??? <tree problem 4> - end
when others =>
pragma Assert (False);
null;
end case;
Result_Node := Unwind_Renaming (Result_Node);
if No (Result_Node) then
-- renaming of a procedure-attribute
return Nil_Element;
end if;
if not Comes_From_Source (Result_Node) then
return Nil_Element;
end if;
Result_Unit := Enclosing_Unit (Encl_Cont_Id (Statement), Result_Node);
-- if not Is_Consistent (Result_Unit, Encl_Unit (Statement)) then
-- return Nil_Element;
-- end if;
-- And now - from a defining name to a declaration itself
Result_Node := Parent (Result_Node);
if Nkind (Result_Node) in
N_Function_Specification .. N_Procedure_Specification
then
Result_Node := Parent (Result_Node);
end if;
if Is_Expanded_Subprogram (Result_Node) then
Res_Spec_Case := Expanded_Subprogram_Instantiation;
end if;
return Node_To_Element_New
(Node => Result_Node,
Spec_Case => Res_Spec_Case,
In_Unit => Result_Unit);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name &
"Corresponding_Called_Entity_Unwound");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Called_Entity_Unwound",
Ex => Ex,
Arg_Element => Statement);
end Corresponding_Called_Entity_Unwound;
-------------------------------------------
-- Corresponding_Called_Function_Unwound --
-------------------------------------------
function Corresponding_Called_Function_Unwound
(Expression : Asis.Expression)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Expression);
Arg_Node : Node_Id;
Arg_Node_Kind : Node_Kind;
Result_Node : Node_Id;
Result_Unit : Compilation_Unit;
Res_Spec_Case : Special_Cases := Not_A_Special_Case;
begin
Check_Validity
(Expression, Package_Name & "Corresponding_Called_Function_Unwound");
if not (Arg_Kind = A_Function_Call) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Called_Function_Unwound",
Wrong_Kind => Arg_Kind);
end if;
-- first, we have to filter out the cases when a Nil_Element
-- should be returned. For now, these cases include:
--
-- - calls to functions-attributes;
-- - all forms of calls to predefined operators;
-- - all forms of calls to inherited functions
--
-- We hope to implement the last case in future...
-- First, we try the simplest approach, and then we will add patches
-- if needed:
Arg_Node := R_Node (Expression);
Arg_Node_Kind := Nkind (Arg_Node);
-- Rewritten node should know everything. But if this node is the
-- result of compile-time optimization, we have to work with
-- original node only:
if Arg_Node_Kind = N_String_Literal or else
Arg_Node_Kind = N_Integer_Literal or else
Arg_Node_Kind = N_Real_Literal or else
Arg_Node_Kind = N_Character_Literal or else
Arg_Node_Kind = N_Raise_Constraint_Error or else
Arg_Node_Kind = N_Identifier
then
Arg_Node := Node (Expression);
Arg_Node_Kind := Nkind (Arg_Node);
elsif Arg_Node_Kind = N_Explicit_Dereference then
-- See F727-023
Arg_Node := Sinfo.Prefix (Arg_Node);
Arg_Node_Kind := Nkind (Arg_Node);
end if;
case Arg_Node_Kind is
when N_Attribute_Reference =>
return Nil_Element;
when N_Function_Call |
N_Procedure_Call_Statement =>
-- The second choice here corresponds to a procedure that is an
-- argument of Debug pragma
-- here we have to filter out the case when Nil_Element
-- should be returned for a call through access-to-function:
if Nkind (Sinfo.Name (Arg_Node)) = N_Explicit_Dereference then
return Nil_Element;
else
Result_Node := Entity (Sinfo.Name (Arg_Node));
end if;
when N_Op =>
-- all the predefined operations (??)
Result_Node := Entity (Arg_Node);
when others =>
pragma Assert (False);
null;
end case;
-- here we have Result_Node pointed to the defining occurrence of
-- the corresponding called function. Three things should be done:
-- 1. If Result_Node is defined in a renaming definition, we have
-- to unwind all the renamings till the defining occurrence of
-- the corresponding callable entity will be reached;
-- 2. If a given callable entity is implicitly defined, Nil_Element
-- should be returned;
-- 3. We have to come from a defining name to the corresponding
-- declaration and then we should return the Element
-- corresponding to this declaration
Result_Node := Unwind_Renaming (Result_Node);
if No (Result_Node) then
-- renaming of a function-attribute
return Nil_Element;
end if;
-- here we have Result_Node pointing to the defining occurrence of the
-- name of the corresponding called function. First, we have to
-- filter out implicitly declared functions:
if not Comes_From_Source (Result_Node) then
return Nil_Element;
end if;
Result_Unit := Enclosing_Unit (Encl_Cont_Id (Expression), Result_Node);
Result_Node := Parent (Result_Node);
if Nkind (Result_Node) = N_Defining_Program_Unit_Name then
Result_Node := Parent (Result_Node);
end if;
Result_Node := Parent (Result_Node);
-- to go from a defining name to a declaration itself
if Is_Expanded_Subprogram (Result_Node) then
Res_Spec_Case := Expanded_Subprogram_Instantiation;
end if;
return Node_To_Element_New
(Node => Result_Node,
Spec_Case => Res_Spec_Case,
In_Unit => Result_Unit);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name &
"Corresponding_Called_Function_Unwound");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Called_Function_Unwound",
Ex => Ex,
Arg_Element => Expression);
end Corresponding_Called_Function_Unwound;
------------------------------------
-- Corresponding_First_Definition --
------------------------------------
function Corresponding_First_Definition
(Defining_Name : Asis.Defining_Name)
return Asis.Defining_Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Defining_Name);
Is_Parameter : Boolean := False;
Encl_Constr : Asis.Element;
Encl_Constr_Kind : Internal_Element_Kinds;
First_Declaration : Asis.Element;
Result : Asis.Element := Nil_Element;
begin
Check_Validity
(Defining_Name, Package_Name & "Corresponding_First_Definition");
if Arg_Kind not in Internal_Defining_Name_Kinds then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_First_Definition",
Wrong_Kind => Arg_Kind);
end if;
Encl_Constr := Enclosing_Element (Defining_Name);
if Int_Kind (Encl_Constr) = A_Parameter_Specification then
Encl_Constr := Enclosing_Element (Encl_Constr);
Is_Parameter := True;
end if;
if Is_Subunit (Encl_Constr) then
Encl_Constr := Corresponding_Body_Stub (Encl_Constr);
end if;
Encl_Constr_Kind := Int_Kind (Encl_Constr);
case Encl_Constr_Kind is
when A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Function_Renaming_Declaration |
A_Procedure_Renaming_Declaration |
A_Procedure_Body_Stub |
A_Function_Body_Stub =>
if ((Encl_Constr_Kind = A_Procedure_Body_Declaration or else
Encl_Constr_Kind = A_Function_Body_Declaration or else
Encl_Constr_Kind = A_Procedure_Body_Stub or else
Encl_Constr_Kind = A_Function_Body_Stub)
and then (not (Acts_As_Spec (Encl_Constr))))
or else
((Encl_Constr_Kind = A_Function_Renaming_Declaration or else
Encl_Constr_Kind = A_Procedure_Renaming_Declaration)
and then Is_Renaming_As_Body (Encl_Constr))
then
-- there should be a corresponding spec where the first
-- definition should be:
if Is_Subunit (Encl_Constr) then
Encl_Constr := Corresponding_Body_Stub (Encl_Constr);
end if;
First_Declaration := Corresponding_Declaration (Encl_Constr);
if not Is_Parameter then
-- just returning a defining name from a declaration,
-- otherwise Result will remain nil, and we will have
-- to process the case of a formal parameter after this
-- case statement
Result := Names (First_Declaration) (1);
end if;
else
Result := Defining_Name;
end if;
when A_Package_Body_Declaration |
A_Task_Body_Declaration |
A_Protected_Body_Declaration |
A_Package_Body_Stub |
A_Task_Body_Stub |
A_Protected_Body_Stub |
An_Entry_Body_Declaration =>
First_Declaration := Corresponding_Declaration (Encl_Constr);
if not Is_Parameter then
Result := Names (First_Declaration) (1);
end if;
when An_Accept_Statement =>
First_Declaration := Corresponding_Entry (Encl_Constr);
when An_Ordinary_Type_Declaration =>
Result := Corresponding_Type_Declaration (Encl_Constr);
if Is_Nil (Result) then
-- Encl_Constr is not a completion of an incomplete or
-- private type declaration
Result := Defining_Name;
else
Result := Names (Result) (1);
end if;
when others =>
Result := Defining_Name;
end case;
if Is_Nil (Result) then
-- here we have to compute the first definition of the formal
-- parameter in a subprogram spec/entry declaration
Process_Parameter_Specifications : declare
Def_Name_Image : constant String
:= To_Lower (To_String (Defining_Name_Image (Defining_Name)));
Param_Specs : constant Asis.Element_List
:= Parameter_Profile (First_Declaration);
begin
Through_Parameter_Specs : for I in Param_Specs'Range loop
Process_Parameter_Names : declare
Par_Names : constant Asis.Element_List :=
Names (Param_Specs (I));
begin
Through_Parameter_Names : for J in Par_Names'Range loop
if Def_Name_Image =
To_Lower (To_String (Defining_Name_Image
(Par_Names (J))))
then
Result := Par_Names (J);
exit Through_Parameter_Specs;
end if;
end loop Through_Parameter_Names;
end Process_Parameter_Names;
end loop Through_Parameter_Specs;
end Process_Parameter_Specifications;
end if;
pragma Assert (not Is_Nil (Result));
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Defining_Name,
Outer_Call => Package_Name & "Corresponding_First_Definition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Corresponding_First_Definition",
Ex => Ex,
Arg_Element => Defining_Name);
end Corresponding_First_Definition;
----------------------------------------
-- Corresponding_Overridden_Operation --
----------------------------------------
function Corresponding_Overridden_Operation
(Declaration : Asis.Declaration)
return Asis.Declaration
is
Result : Asis.Element := Nil_Element;
Result_Unit : Compilation_Unit;
Result_Node : Node_Id;
Inherited : Boolean := False;
Association_Type : Node_Id;
begin
Check_Validity (Declaration,
Package_Name & "Corresponding_Overridden_Operation");
case Declaration_Kind (Declaration) is
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Instantiation |
A_Function_Instantiation |
A_Procedure_Body_Declaration |
A_Null_Procedure_Declaration |
A_Function_Body_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration =>
null;
when others =>
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name &
"Corresponding_Overridden_Operation",
Wrong_Kind => Int_Kind (Declaration));
end case;
if Is_Overriding_Operation (Declaration) then
if Declaration_Kind (Declaration) in
A_Procedure_Instantiation .. A_Function_Instantiation
then
Result_Node := Specification (Instance_Spec (Node (Declaration)));
Result_Node :=
Related_Instance (Defining_Unit_Name (Result_Node));
else
Result_Node :=
Defining_Unit_Name (Specification (Node (Declaration)));
end if;
Result_Node := Overridden_Operation (Result_Node);
Inherited := not Comes_From_Source (Result_Node);
if Inherited then
Association_Type := Result_Node;
Result_Node := Explicit_Parent_Subprogram (Result_Node);
Result_Unit :=
Enclosing_Unit (Encl_Cont_Id (Declaration), Association_Type);
Result := Node_To_Element_New (Node => Result_Node,
Node_Field_1 => Association_Type,
Inherited => True,
In_Unit => Result_Unit);
if Is_From_Instance (Association_Type) then
Set_From_Instance (Result, True);
else
Set_From_Instance (Result, False);
end if;
else
Result_Unit :=
Enclosing_Unit (Encl_Cont_Id (Declaration), Result_Node);
Result := Node_To_Element_New (Node => Result_Node,
In_Unit => Result_Unit);
end if;
Result := Enclosing_Element (Result);
if Special_Case (Result) = Expanded_Subprogram_Instantiation then
Result := Enclosing_Element (Result);
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name &
"Corresponding_Overridden_Operation");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Overridden_Operation",
Ex => Ex,
Arg_Element => Declaration);
end Corresponding_Overridden_Operation;
-----------------------------------------
-- Corresponding_Overridden_Operations --
-----------------------------------------
-- UNDER CONSTRUCTION!!!
pragma Warnings (Off);
function Corresponding_Overridden_Operations
(Declaration : Asis.Declaration)
return Asis.Element_List
is
Type_Def : Asis.Element;
Tmp_El : Asis.Element;
Result : Asis.Element := Nil_Element;
Arg_Node : Entity_Id;
Prim_Elmt : Elmt_Id;
Prim_Node : Entity_Id;
Res_Node : Node_Id;
begin
Check_Validity (Declaration,
Package_Name & "Corresponding_Overridden_Operations");
case Declaration_Kind (Declaration) is
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Instantiation |
A_Function_Instantiation |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration =>
null;
when others =>
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name &
"Corresponding_Overridden_Operations",
Wrong_Kind => Int_Kind (Declaration));
end case;
if not Is_Overriding_Operation (Declaration) then
return Nil_Element_List;
end if;
-- Simple case: single inheritance:
Type_Def := Primitive_Owner (Declaration);
if Is_Nil (Definition_Interface_List (Type_Def)) then
return (1 => Corresponding_Overridden_Operation (Declaration));
end if;
-- General case - multiple inheritance
Asis_Element_Table.Init;
Tmp_El := First_Name (Declaration);
Arg_Node := R_Node (Tmp_El);
Tmp_El := First_Name (Enclosing_Element (Type_Def));
Prim_Elmt := First_Elmt (Primitive_Operations (R_Node (Tmp_El)));
Prim_Node := Node (Prim_Elmt);
while Present (Prim_Elmt) loop
-- Check if Prim_Node corresponds to overridden primitive:
if Present (Interface_Alias (Prim_Node))
and then
Alias (Prim_Node) = Arg_Node
then
Res_Node := Interface_Alias (Prim_Node);
-- ???
-- !!! Here we have to form the element representing overridden
-- subprogram and to add it to Asis_Element_Table
end if;
Prim_Elmt := Next_Elmt (Prim_Elmt);
Prim_Node := Node (Prim_Elmt);
end loop;
-- ???
Asis_Element_Table.Append
(Corresponding_Overridden_Operation (Declaration));
return Asis.Declaration_List
(Asis_Element_Table.Table (1 .. Asis_Element_Table.Last));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name &
"Corresponding_Overridden_Operations");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Overridden_Operations",
Ex => Ex,
Arg_Element => Declaration);
end Corresponding_Overridden_Operations;
pragma Warnings (On);
-- function Corresponding_Overridden_Operations
-- (Declaration : Asis.Declaration)
-- return Asis.Element_List
-- is
-- Type_Def : Asis.Element;
-- Result : Asis.Element := Nil_Element;
-- begin
-- Check_Validity (Declaration,
-- Package_Name & "Corresponding_Overridden_Operations");
-- case Declaration_Kind (Declaration) is
-- when A_Procedure_Declaration |
-- A_Function_Declaration |
-- A_Procedure_Instantiation |
-- A_Function_Instantiation |
-- A_Procedure_Body_Declaration |
-- A_Function_Body_Declaration |
-- A_Procedure_Renaming_Declaration |
-- A_Function_Renaming_Declaration =>
-- null;
-- when others =>
-- Raise_ASIS_Inappropriate_Element
-- (Diagnosis => Package_Name &
-- "Corresponding_Overridden_Operations");
-- end case;
-- if not Is_Overriding_Operation (Declaration) then
-- return Nil_Element_List;
-- end if;
-- -- Simple case: single inheritance:
-- Type_Def := Primitive_Owner (Declaration);
-- if Is_Nil (Definition_Interface_List (Type_Def)) then
-- return (1 => Corresponding_Overridden_Operation (Declaration));
-- end if;
-- -- General case - multiple inheritance
-- declare
-- Interfaces : Asis.Element_List :=
-- Definition_Interface_List (Type_Def);
-- Start_From : Positive := Interfaces'First;
-- begin
-- Asis_Element_Table.Init;
-- Result := Corresponding_Overridden_Operation (Declaration);
-- Asis_Element_Table.Append (Result);
-- Type_Def := Primitive_Owner (Declaration);
-- -- First, replace each interface name in Interfaces with the
-- -- corresponding type definition and check if we may start further
-- -- processing not from the first interface in the list
-- for J in Interfaces'Range loop
-- Interfaces (J) :=
-- Type_Declaration_View
-- (Corresponding_Name_Definition
-- (Normalize_Reference (Interfaces (J))));
-- if Is_Equal (Interfaces (J), Type_Def) then
-- Start_From := J + 1;
-- end if;
-- end loop;
-- for J in Start_From .. Interfaces'Last loop
-- Result := Get_Implemented_Op (Declaration, Interfaces (J));
-- if not Is_Nil (Result) then
-- Asis_Element_Table.Append (Result);
-- end if;
-- end loop;
-- return Asis.Declaration_List
-- (Asis_Element_Table.Table (1 .. Asis_Element_Table.Last));
-- end;
-- exception
-- when ASIS_Inappropriate_Element =>
-- raise;
-- when ASIS_Failed =>
-- if Status_Indicator = Unhandled_Exception_Error then
-- Add_Call_Information
-- (Argument => Declaration,
-- Outer_Call => Package_Name &
-- "Corresponding_Overridden_Operations");
-- end if;
-- raise;
-- when Ex : others =>
-- Report_ASIS_Bug
-- (Query_Name => Package_Name &
-- "Corresponding_Overridden_Operations",
-- Ex => Ex,
-- Arg_Element => Declaration);
-- end Corresponding_Overridden_Operations;
----------------------------------------------
-- Corresponding_Parent_Subtype_Unwind_Base --
----------------------------------------------
function Corresponding_Parent_Subtype_Unwind_Base
(Type_Definition : Asis.Type_Definition)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition);
Arg_Elem : Asis.Element := Type_Definition;
Result : Asis.Element := Nil_Element;
begin
Check_Validity (Type_Definition,
Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base");
if not (Arg_Kind = A_Derived_Type_Definition or else
Arg_Kind = A_Derived_Record_Extension_Definition)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base",
Wrong_Kind => Arg_Kind);
end if;
Result := Corresponding_Parent_Subtype (Arg_Elem);
if Is_Nil (Result) then
-- The only possible case for this - we have a 'Base attribute
-- reference as a parent subtype mark
Arg_Elem := Parent_Subtype_Indication (Arg_Elem);
Arg_Elem := Asis.Definitions.Subtype_Mark (Arg_Elem);
while Attribute_Kind (Arg_Elem) = A_Base_Attribute loop
Arg_Elem := Prefix (Arg_Elem);
end loop;
if Expression_Kind (Arg_Elem) = A_Selected_Component then
Arg_Elem := Selector (Arg_Elem);
end if;
Arg_Elem := Corresponding_Name_Declaration (Arg_Elem);
if Declaration_Kind (Result) = A_Subtype_Declaration then
Result := Corresponding_First_Subtype (Arg_Elem);
else
Result := Arg_Elem;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Type_Definition,
Outer_Call => Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Parent_Subtype_Unwind_Base",
Ex => Ex,
Arg_Element => Type_Definition);
end Corresponding_Parent_Subtype_Unwind_Base;
----------------------
-- CU_Requires_Body --
----------------------
function CU_Requires_Body (Right : Asis.Compilation_Unit) return Boolean is
Unit_Kind : constant Asis.Unit_Kinds := Kind (Right);
Result : Boolean := False;
begin
Check_Validity (Right, Package_Name & "CU_Requires_Body");
Reset_Context (Encl_Cont_Id (Right));
case Unit_Kind is
when A_Generic_Procedure |
A_Generic_Function |
A_Procedure |
A_Function |
A_Package |
A_Generic_Package =>
Result := Asis.Set_Get.Is_Body_Required (Right);
when others =>
null;
end case;
return Result;
end CU_Requires_Body;
---------------------------
-- Elements_Hash_Wrapper --
---------------------------
function Elements_Hash_Wrapper
(E : Asis.Element)
return Ada.Containers.Hash_Type
is
use Ada.Containers;
Asis_Hash : constant Asis.ASIS_Integer := abs Asis.Elements.Hash (E);
Result : Ada.Containers.Hash_Type;
begin
Result := Ada.Containers.Hash_Type (Asis_Hash);
return Result;
exception
when Constraint_Error =>
return 0;
end Elements_Hash_Wrapper;
-------------------------------
-- Element_Image_In_Template --
-------------------------------
function Element_Image_In_Template
(Element : Asis.Element)
return Program_Text
is
Tmp_Element : Asis.Element := Element;
begin
Check_Validity (Element, Package_Name & "Element_Image_In_Template");
if Is_Part_Of_Implicit (Element) or else
not Is_Part_Of_Instance (Element)
then
return "";
else
-- What we are doing is tricky, but it gives the fast and
-- easy-to-maintain solution: we consider the argument as if it is
-- NOT from the expanded template, and we use the normal ASIS
-- Element_Span function for it. The idea is to use Sloc fields
-- from the element node which point to the corresponding positions
-- in the template.
Set_From_Instance (Tmp_Element, False);
return Element_Image (Tmp_Element);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Element_Image_In_Template");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Element_Image_In_Template",
Ex => Ex,
Arg_Element => Element);
end Element_Image_In_Template;
------------------------------
-- Element_Span_In_Template --
------------------------------
function Element_Span_In_Template
(Element : Asis.Element)
return Asis.Text.Span
is
Tmp_Element : Asis.Element := Element;
begin
Check_Validity (Element, Package_Name & "Element_Span_In_Template");
if Is_Part_Of_Implicit (Element) or else
not Is_Part_Of_Instance (Element)
then
return Nil_Span;
else
-- What we are doing is tricky, but it gives the fast and
-- easy-to-maintain solution: we consider the argument as if it is
-- NOT from the expanded template, and we use the normal ASIS
-- Element_Span function for it. The idea is to use Sloc fields
-- from the element node which point to the corresponding positions
-- in the template.
Set_From_Instance (Tmp_Element, False);
return Element_Span (Tmp_Element);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Element_Span_In_Template");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Element_Span_In_Template",
Ex => Ex,
Arg_Element => Element);
end Element_Span_In_Template;
-----------------------------
-- Explicit_Type_Operators --
-----------------------------
function Explicit_Type_Operators
(Type_Definition : Asis.Type_Definition)
return Asis.Declaration_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition);
Parent_El : Asis.Element;
-- The construct where the argument type is defined
Type_Decl : Asis.Element;
-- Declaration of the argument type
In_Package_Spec : Boolean;
-- If the argument type is declared not in a package spec, but it is
-- a derived type, we have to count all the explicit overridings of
-- inherited operators, but if we are in the package spec, we just
-- collect all the explicitly declared type operators
Is_Formal_Type : Boolean;
begin
Check_Validity (Type_Definition,
Package_Name & "Explicit_Type_Operators");
if not (Arg_Kind in Internal_Type_Kinds or else
Arg_Kind in Internal_Formal_Type_Kinds or else
Arg_Kind in A_Private_Type_Definition ..
A_Protected_Definition)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Explicit_Type_Operators",
Wrong_Kind => Arg_Kind);
end if;
Type_Decl := Enclosing_Element (Type_Definition);
Parent_El := Enclosing_Element (Type_Decl);
Is_Formal_Type := Arg_Kind in Internal_Formal_Type_Kinds;
In_Package_Spec :=
Declaration_Kind (Parent_El) = A_Package_Declaration or else
(not Is_Formal_Type and then
Declaration_Kind (Parent_El) = A_Formal_Package_Declaration);
declare
All_Comp : constant Asis.Element_List := Components (Parent_El);
Start_From : Natural;
Result : Asis.Element_List (All_Comp'Range);
Res_First : constant Natural := Result'First;
Res_Last : Natural := Res_First - 1;
begin
for J in All_Comp'Range loop
if Is_Equal (Type_Decl, All_Comp (J)) then
Start_From := J + 1;
exit;
end if;
end loop;
for J in Start_From .. All_Comp'Last loop
if Is_Formal_Type
and then
Declaration_Kind (All_Comp (J)) not in A_Formal_Declaration
then
exit;
end if;
if Is_Type_Operator (All_Comp (J), Type_Decl)
and then
(In_Package_Spec
or else
Overrides_Type_Operator (All_Comp (J), Type_Decl))
then
Res_Last := Res_Last + 1;
Result (Res_Last) := All_Comp (J);
if Is_Bool_Eq_Declaration (All_Comp (J)) then
Res_Last := Res_Last + 1;
Result (Res_Last) :=
Corresponding_Equality_Operator (All_Comp (J));
end if;
end if;
end loop;
return Result (Res_First .. Res_Last);
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Type_Definition,
Outer_Call => Package_Name & "Explicit_Type_Operators");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Explicit_Type_Operators",
Ex => Ex,
Arg_Element => Type_Definition);
end Explicit_Type_Operators;
----------------
-- First_Name --
----------------
function First_Name (Dcl : Asis.Element) return Asis.Element is
Name_List : constant Asis.Element_List := Names (Dcl);
begin
return Name_List (Name_List'First);
end First_Name;
-------------------------------
-- Formal_Subprogram_Default --
-------------------------------
function Formal_Subprogram_Default
(Declaration : Asis.Generic_Formal_Parameter)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
begin
Arg_Node := Node (Declaration);
Check_Validity (Declaration, Package_Name & "Formal_Subprogram_Default");
if not (Arg_Kind = A_Formal_Procedure_Declaration or else
Arg_Kind = A_Formal_Function_Declaration)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Formal_Subprogram_Default",
Wrong_Kind => Arg_Kind);
end if;
if not Present (Default_Name (Arg_Node)) then
return Nil_Element;
end if;
return Node_To_Element_New (Node => Default_Name (Arg_Node),
Starting_Element => Declaration);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Formal_Subprogram_Default");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Formal_Subprogram_Default",
Ex => Ex,
Arg_Element => Declaration);
end Formal_Subprogram_Default;
---------------------
-- Full_Name_Image --
---------------------
function Full_Name_Image
(Expression : Asis.Expression)
return Program_Text
is
begin
case Expression_Kind (Expression) is
when An_Identifier .. An_Enumeration_Literal =>
return Asis.Expressions.Name_Image (Expression);
when A_Selected_Component =>
return Full_Name_Image (Prefix (Expression)) & '.' &
Asis.Expressions.Name_Image (Selector (Expression));
when others =>
Raise_ASIS_Inappropriate_Element
(Package_Name & "Full_Name_Image",
Wrong_Kind => Int_Kind (Expression));
end case;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name & "Full_Name_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Full_Name_Image",
Ex => Ex,
Arg_Element => Expression);
end Full_Name_Image;
-------------------------
-- Get_Call_Parameters --
-------------------------
function Get_Call_Parameters
(Call : Asis.Element;
Normalized : Boolean := False)
return Asis.Element_List
is
begin
if Expression_Kind (Call) = A_Function_Call then
return Function_Call_Parameters (Call, Normalized);
else
return Call_Statement_Parameters (Call, Normalized);
end if;
end Get_Call_Parameters;
------------------------
-- Get_Implemented_Op --
------------------------
-- Under construction!
function Get_Implemented_Op
(Op_Decl : Asis.Element;
Type_Def : Asis.Element)
return Asis.Element
is
pragma Unreferenced (Op_Decl, Type_Def);
begin
return Nil_Element;
end Get_Implemented_Op;
-- function Get_Implemented_Op
-- (Op_Decl : Asis.Element;
-- Type_Def : Asis.Element)
-- return Asis.Element
-- is
-- Result : Asis.Element := Nil_Element;
-- Look_For_Proc : constant Boolean := Is_Procedure (Op_Decl);
-- Primitives : constant Asis.Element_List := Get_Primitives (Type_Def);
-- Arg_Chars : Name_Id;
-- Res_Chars : Name_Id;
-- Tmp_Node : Node_Id;
-- Tmp_El1 : Asis.Element;
-- Tmp_El2 : Asis.Element;
-- Success : Boolean;
-- Is_Controlling : Boolean;
-- Arg_Params : constant Asis.Element_List := Parameter_Profile (Op_Decl);
-- begin
-- Tmp_El := First_Name (Decl);
-- Arg_Chars := Chars (R_Node (Tmp_El));
-- Scan_Primitives : for J in Primitives'Range loop
-- if Look_For_Proc xor Is_Procedure (Primitives (J)) then
-- Res_Chars := Chars (R_Node (First_Name (Primitives (J))));
-- if Res_Chars = Arg_Chars
-- and then
-- Arg_Params'Length = Parameter_Profile (Primitives (J))'Length
-- then
-- -- Check parameter profiles:
-- Success := True;
-- if not Look_For_Proc then
-- -- Check for the result type
-- Tmp_El1 := First_Name (Op_Decl);
-- Tmp_El2 := First_Name (Primitives (J));
-- if Has_Controlling_Result (R_Node (Tmp_El1)) xor
-- Has_Controlling_Result (R_Node (Tmp_El2))
-- then
-- Success := False;
-- else
-- Is_Controlling :=
-- Has_Controlling_Result (R_Node (Tmp_El1));
-- Tmp_El1 := Result_Profile (Op_Decl);
-- Tmp_El2 := Result_Profile (Primitives (J));
-- if Definition_Kind (Tmp_El1) = An_Access_Definition
-- xor
-- Definition_Kind (Tmp_El2) = An_Access_Definition
-- then
-- Success := False;
-- elsif not Is_Controlling then
-- Succes := Are_Type_Conforming (Tmp_El1, Tmp_El2);
-- end if;
-- end if;
-- end if;
-- end if;
-- if Success then
-- declare
-- Res_Params : constant Asis.Element_List :=
-- Parameter_Profile (Primitives (J));
-- begin
-- Scan_Params : for P in Arg_Params'Range loop
-- if not Are_Conformant
-- (Arg_Params (P), Res_Params (P))
-- then
-- Success := False;
-- exit Scan_Params;
-- end if;
-- end loop;
-- end;
-- end if;
-- if Success then
-- Result := Primitives (J)
-- exit Scan_Primitives;
-- end if;
-- end if;
-- end if;
-- end loop Scan_Primitives;
-- return Result;
-- end Get_Implemented_Op;
------------------------
-- Get_Last_Component --
------------------------
function Get_Last_Component (E : Asis.Element) return Asis.Element is
Child_Access : constant Query_Array := Appropriate_Queries (E);
Child : Asis.Element := Asis.Nil_Element;
begin
Check_Validity (E, Package_Name & "Get_Last_Component");
if Is_Nil (E) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Get_Last_Component",
Wrong_Kind => Not_An_Element);
end if;
if Debug_Flag_X then
Write_Str (" Get_Last_Component - called for ");
Write_Str (Internal_Element_Kinds'Image (Int_Kind (E)));
Write_Eol;
end if;
for Each_Query in reverse Child_Access'Range loop
case Child_Access (Each_Query).Query_Kind is
when Bug =>
null;
when Single_Element_Query =>
Child := Child_Access (Each_Query).Func_Simple (E);
when Element_List_Query =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List (E);
begin
if not Is_Nil (Child_List) then
Child := Child_List (Child_List'Last);
end if;
end;
when Element_List_Query_With_Boolean =>
declare
Child_List : constant Asis.Element_List :=
Child_Access (Each_Query).Func_List_Boolean
(E, Child_Access (Each_Query).Bool);
begin
if not Is_Nil (Child_List) then
Child := Child_List (Child_List'Last);
end if;
end;
end case;
exit when not Is_Nil (Child);
end loop;
if Debug_Flag_X then
Write_Str (" Get_Last_Component - returns ");
Write_Str (Internal_Element_Kinds'Image (Int_Kind (Child)));
Write_Eol;
end if;
return Child;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => E,
Outer_Call => Package_Name & "Get_Last_Component");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Get_Last_Component",
Ex => Ex,
Arg_Element => E);
end Get_Last_Component;
-----------------------
-- Get_LF_From_Ureal --
-----------------------
function Get_LF_From_Ureal (U : Ureal) return Long_Long_Float is
Result : Long_Long_Float;
Base : constant Nat := Rbase (U);
U_Num : constant Uint := Numerator (U);
U_Denum : constant Uint := Denominator (U);
Num : Long_Long_Integer;
Denum : Long_Long_Integer;
begin
UI_Image (U_Num, Format => Decimal);
Num := Long_Long_Integer'Value (UI_Image_Buffer (1 .. UI_Image_Length));
UI_Image (U_Denum, Format => Decimal);
Denum :=
Long_Long_Integer'Value (UI_Image_Buffer (1 .. UI_Image_Length));
if Base /= 0 then
Denum := Long_Long_Integer (2 ** Natural (Denum));
end if;
Result := Long_Long_Float (Num) / Long_Long_Float (Denum);
if UR_Is_Negative (U) then
Result := -Result;
end if;
return Result;
end Get_LF_From_Ureal;
--------------------------
-- Has_Enumeration_Type --
--------------------------
function Has_Enumeration_Type
(Expression : Asis.Expression)
return Boolean
is
Result : Boolean := False;
begin
Check_Validity (Expression, Package_Name & "Has_Enumeration_Type");
if Ekind (Etype (R_Node (Expression))) in Enumeration_Kind then
Result := True;
end if;
return Result;
end Has_Enumeration_Type;
----------------------
-- Has_Integer_Type --
----------------------
function Has_Integer_Type (Expression : Asis.Expression) return Boolean is
Result : Boolean := False;
begin
Check_Validity (Expression, Package_Name & "Has_Integer_Type");
if Ekind (Etype (R_Node (Expression))) in Integer_Kind then
Result := True;
end if;
return Result;
end Has_Integer_Type;
------------------------------
-- Inherited_Type_Operators --
------------------------------
function Inherited_Type_Operators
(Type_Definition : Asis.Type_Definition)
return Asis.Declaration_List
is
Arg_Kind : constant Internal_Element_Kinds :=
Int_Kind (Type_Definition);
Type_Decl : Asis.Element;
begin
Check_Validity (Type_Definition,
Package_Name & "Inherited_Type_Operators");
if not (Arg_Kind in Internal_Type_Kinds or else
Arg_Kind in Internal_Formal_Type_Kinds or else
Arg_Kind in A_Private_Type_Definition ..
A_Protected_Definition)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Inherited_Type_Operators",
Wrong_Kind => Arg_Kind);
end if;
if not (Arg_Kind = A_Private_Extension_Definition or else
Arg_Kind = A_Derived_Type_Definition or else
Arg_Kind = A_Derived_Record_Extension_Definition or else
Arg_Kind = A_Formal_Derived_Type_Definition)
then
return Nil_Element_List;
end if;
declare
All_Inherited_Ops : constant Asis.Declaration_List :=
Implicit_Inherited_Subprograms (Type_Definition);
Result : Asis.Declaration_List (All_Inherited_Ops'Range);
Res_First : constant Natural := Result'First;
Res_Last : Natural := Res_First - 1;
begin
Type_Decl := Enclosing_Element (Type_Definition);
for J in All_Inherited_Ops'Range loop
if Is_Type_Operator (All_Inherited_Ops (J), Type_Decl) then
Res_Last := Res_Last + 1;
Result (Res_Last) := All_Inherited_Ops (J);
end if;
end loop;
return Result (Res_First .. Res_Last);
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Type_Definition,
Outer_Call => Package_Name & "Inherited_Type_Operators");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Inherited_Type_Operators",
Ex => Ex,
Arg_Element => Type_Definition);
end Inherited_Type_Operators;
--------------------
-- Is_Aspect_Mark --
--------------------
function Is_Aspect_Mark (Element : Asis.Element) return Boolean is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Expression_Kind (Element) = An_Identifier or else
Attribute_Kind (Element) = A_Class_Attribute
then
Tmp := R_Node (Element);
Result := Nkind (Parent (Tmp)) = N_Aspect_Specification and then
Tmp = Sinfo.Identifier (Parent (Tmp));
end if;
return Result;
end Is_Aspect_Mark;
-----------------------------------
-- Is_Aspect_Specific_Identifier --
-----------------------------------
function Is_Aspect_Specific_Identifier
(Element : Asis.Element)
return Boolean
is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Expression_Kind (Element) = An_Identifier then
Tmp := R_Node (Element);
if Nkind (Tmp) = N_Identifier
and then
not Present (Entity (Tmp))
then
Tmp := Parent (Tmp);
if Present (Tmp) then
case Nkind (Tmp) is
when N_Component_Association =>
if Nkind (Parent (Parent (Tmp))) =
N_Aspect_Specification
then
Result := True;
end if;
when N_Aspect_Specification =>
Result := R_Node (Element) /= Sinfo.Identifier (Tmp);
-- ... to be continued...
when others =>
null;
end case;
end if;
end if;
end if;
return Result;
end Is_Aspect_Specific_Identifier;
----------------------------
-- Is_Bool_Eq_Declaration --
----------------------------
function Is_Bool_Eq_Declaration
(Declaration : Asis.Element)
return Boolean
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Result : Boolean := False;
Op_Node : Node_Id;
Op_Etype : Node_Id;
begin
Check_Validity (Declaration, Package_Name & "Is_Bool_Eq_Declaration");
if Arg_Kind = A_Function_Declaration
or else
(Arg_Kind = A_Function_Body_Declaration
and then
Acts_As_Spec (Declaration))
or else
Arg_Kind = A_Function_Renaming_Declaration
then
Op_Node := Defining_Unit_Name (Specification (Node (Declaration)));
Op_Etype := Etype (Op_Node);
if Is_Generic_Instance (Op_Node) then
Op_Node :=
Defining_Unit_Name (Node (Enclosing_Element (Declaration)));
end if;
if Nkind (Op_Node) = N_Defining_Program_Unit_Name then
Op_Node := Defining_Identifier (Op_Node);
end if;
if Nkind (Op_Node) = N_Defining_Operator_Symbol
and then
Chars (Op_Node) = Name_Op_Eq
and then
Op_Etype = Standard_Boolean
then
Result := True;
end if;
end if;
return Result;
end Is_Bool_Eq_Declaration;
-------------------
-- Is_Class_Wide --
-------------------
function Is_Class_Wide
(Declaration : Asis.Declaration)
return Boolean
is
Result : Boolean := False;
Subtype_Entity : Entity_Id;
begin
if Declaration_Kind (Declaration) = A_Subtype_Declaration then
Subtype_Entity := R_Node (Declaration);
Subtype_Entity := Defining_Identifier (Subtype_Entity);
Result := Ekind (Subtype_Entity) = E_Class_Wide_Subtype;
end if;
return Result;
end Is_Class_Wide;
------------------
-- Is_Completed --
------------------
function Is_Completed (Declaration : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Declaration, Package_Name & "Is_Completed");
-- JUNK IMPLEMENTATION!!!
if not (Arg_Kind = A_Procedure_Declaration or else
Arg_Kind = A_Function_Declaration)
or else
Is_Part_Of_Inherited (Declaration)
then
return False;
end if;
Arg_Node := Defining_Unit_Name (Specification (Node (Declaration)));
Result := Has_Completion (Arg_Node);
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Is_Completed");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Completed",
Ex => Ex,
Arg_Element => Declaration);
end Is_Completed;
-----------------------------------
-- Is_Default_For_Null_Procedure --
-----------------------------------
function Is_Default_For_Null_Procedure
(Reference : Asis.Element)
return Boolean
is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Expression_Kind (Reference) = An_Identifier
and then
Is_Part_Of_Instance (Reference)
then
Tmp := R_Node (Reference);
if Nkind (Tmp) in N_Has_Entity then
Tmp := Entity (Tmp);
if Present (Tmp) and then Ekind (Tmp) = E_Procedure then
Tmp := Parent (Parent (Tmp));
Result :=
Nkind (Tmp) = N_Subprogram_Body
and then
Nkind (Parent (Tmp)) = N_Package_Specification;
end if;
end if;
end if;
return Result;
end Is_Default_For_Null_Procedure;
----------------------------
-- Is_Expanded_Subprogram --
----------------------------
function Is_Expanded_Subprogram (N : Node_Id) return Boolean is
Result : Boolean := False;
Tmp : Node_Id;
begin
if Nkind (N) = N_Subprogram_Declaration then
Tmp := Defining_Unit_Name (Specification (N));
if Nkind (Tmp) = N_Defining_Program_Unit_Name then
Tmp := Defining_Identifier (Tmp);
end if;
if Is_Generic_Instance (Tmp) then
Result := True;
end if;
end if;
return Result;
end Is_Expanded_Subprogram;
-----------------
-- Is_Exported --
-----------------
function Is_Exported (Defining_Name : Asis.Defining_Name) return Boolean is
Arg_Node : Node_Id;
Tmp : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Defining_Name, Package_Name & "Is_Exported");
if Int_Kind (Defining_Name) not in Internal_Defining_Name_Kinds then
return False;
end if;
Arg_Node := R_Node (Defining_Name);
if Nkind (Arg_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Defining_Identifier (Arg_Node);
end if;
if Ekind (Arg_Node) = E_Subprogram_Body then
-- Go to the corresponding spec entity
Tmp := Parent (Arg_Node);
while Nkind (Tmp) not in N_Subprogram_Specification loop
Tmp := Parent (Tmp);
end loop;
Tmp := Parent (Tmp);
Tmp := Corresponding_Decl_Node (Tmp);
Arg_Node := Defining_Unit_Name (Specification (Tmp));
if Nkind (Arg_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Defining_Identifier (Arg_Node);
end if;
end if;
Result := Is_Exported (Arg_Node);
return Result;
end Is_Exported;
-------------------------------------
-- Is_From_Import_Procedure_Pragma --
-------------------------------------
function Is_From_Import_Procedure_Pragma (N : Node_Id) return Boolean is
Tmp : Node_Id := Parent (N);
Result : Boolean := False;
begin
if Nkind (Tmp) = N_Indexed_Component then
Tmp := Parent (Tmp);
if Nkind (Tmp) = N_Aggregate then
Tmp := Parent (Tmp);
if Nkind (Tmp) = N_Pragma_Argument_Association then
Tmp := Pragma_Identifier (Parent (Tmp));
Result := Chars (Tmp) = Name_Import_Procedure
or else
Chars (Tmp) = Name_Import_Valued_Procedure;
end if;
end if;
end if;
return Result;
end Is_From_Import_Procedure_Pragma;
---------------------------------
-- Is_Implicit_Neq_Declaration --
---------------------------------
function Is_Implicit_Neq_Declaration
(Declaration : Asis.Element)
return Boolean
is
begin
return
Declaration_Kind (Declaration) = A_Function_Declaration
and then
Special_Case (Declaration) = Is_From_Imp_Neq_Declaration;
end Is_Implicit_Neq_Declaration;
--------------
-- Is_Label --
--------------
function Is_Label (Defining_Name : Asis.Defining_Name) return Boolean is
N : constant Node_Id := Node (Defining_Name);
Result : Boolean := False;
begin
if Int_Kind (Defining_Name) = A_Defining_Identifier then
if Nkind (N) = N_Label then
Result := True;
elsif Nkind (N) = N_Identifier
and then
Nkind (Parent (N)) = N_Loop_Statement
and then
Nkind (Original_Node (Parent (N))) = N_Goto_Statement
then
-- An infinite loop is implemented with goto statement
Result := True;
end if;
end if;
return Result;
end Is_Label;
--------------------------
-- Is_Main_Unit_In_Tree --
--------------------------
function Is_Main_Unit_In_Tree
(Right : Asis.Compilation_Unit)
return Boolean
is
Arg_Kind : constant Unit_Kinds := Kind (Right);
Arg_Unit_Id : Unit_Id;
Arg_Cont_Id : Context_Id;
begin
Check_Validity (Right, Package_Name & "Is_Main_Unit_In_Tree");
Arg_Cont_Id := Encl_Cont_Id (Right);
Reset_Context (Arg_Cont_Id);
Arg_Unit_Id := Get_Unit_Id (Right);
if Arg_Kind in A_Procedure .. A_Protected_Body_Subunit then
return GNAT_Compilation_Dependencies (Arg_Unit_Id) /=
Nil_Unit_Id_List;
else
return False;
end if;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Is_Main_Unit_In_Tree");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Main_Unit_In_Tree",
Ex => Ex,
Arg_CU => Right);
end Is_Main_Unit_In_Tree;
-----------------
-- Is_Obsolete --
-----------------
function Is_Obsolete (Right : Asis.Compilation_Unit) return Boolean is
Arg_Kind : constant Unit_Kinds := Kind (Right);
Arg_Id : Unit_Id;
Result : Boolean := True;
begin
Check_Validity (Right, Package_Name & "Is_Obsolete");
case Arg_Kind is
when Not_A_Unit |
A_Nonexistent_Declaration |
A_Nonexistent_Body |
An_Unknown_Unit =>
null;
when others =>
Arg_Id := Get_Unit_Id (Right);
if Arg_Id = Standard_Id then
Result := False;
else
Result := not (Source_Status (Right) = Up_To_Date);
end if;
end case;
return Result;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Is_Obsolete");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Obsolete",
Ex => Ex,
Arg_CU => Right);
end Is_Obsolete;
-----------------------------
-- Is_Overriding_Operation --
-----------------------------
function Is_Overriding_Operation
(Declaration : Asis.Element)
return Boolean
is
Result : Boolean := False;
Entity_N : Entity_Id := Empty;
begin
case Declaration_Kind (Declaration) is
when A_Procedure_Instantiation |
A_Function_Instantiation =>
Entity_N := Specification (Instance_Spec (Node (Declaration)));
Entity_N := Related_Instance (Defining_Unit_Name (Entity_N));
when A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Renaming_Declaration |
A_Function_Renaming_Declaration =>
if not Is_Part_Of_Implicit (Declaration) then
Entity_N := Specification (Node (Declaration));
Entity_N := Defining_Unit_Name (Entity_N);
end if;
when others =>
null;
end case;
if Present (Entity_N)
and then
Nkind (Entity_N) in
N_Defining_Identifier .. N_Defining_Operator_Symbol
then
Result := Present (Overridden_Operation (Entity_N));
end if;
return Result;
end Is_Overriding_Operation;
----------------------------
-- Is_Predefined_Operator --
----------------------------
function Is_Predefined_Operator
(Operator : Asis.Element)
return Boolean
is
Result : Boolean := False;
Entity_N : Entity_Id;
begin
if Expression_Kind (Operator) = An_Operator_Symbol then
Entity_N := Entity (Node (Operator));
Result := Present (Entity_N) and then Is_Predefined (Entity_N);
end if;
return Result;
end Is_Predefined_Operator;
----------------
-- Is_Private --
----------------
function Is_Private (Declaration : Asis.Element) return Boolean is
Arg_Element : Element := Declaration;
Result : Boolean := False;
Next_Node : Node_Id;
Enclosing_List : List_Id;
Enclosing_Node : Node_Id;
begin
Check_Validity (Declaration, Package_Name & "Is_Private");
if Declaration_Kind (Declaration) = Not_A_Declaration or else
Declaration_Kind (Declaration) in
A_Loop_Parameter_Specification .. An_Element_Iterator_Specification
then
return False;
end if;
-- In case of an implicit Element we go to the "enclosing" explicit
-- Element to get the node stored in R_Node field which can safely be
-- used for tree traversal (for implicit Elements R_Node may be of
-- special use and it may have the Parent field set to Empty
while Is_Part_Of_Implicit (Arg_Element)
and then
Special_Case (Arg_Element) /= From_Limited_View
loop
Arg_Element := Enclosing_Element (Arg_Element);
end loop;
Next_Node := R_Node (Arg_Element);
while Nkind (Next_Node) /= N_Compilation_Unit and then
not Is_List_Member (Next_Node)
loop
Next_Node := Parent (Next_Node);
end loop;
while Nkind (Next_Node) /= N_Compilation_Unit loop
-- If we are here, we have Next_Node being a list member
Enclosing_List := List_Containing (Next_Node);
Enclosing_Node := Parent (Enclosing_List);
case Nkind (Enclosing_Node) is
when N_Statement_Other_Than_Procedure_Call =>
-- We can not be in any private part
exit;
when N_Package_Specification |
N_Task_Definition |
N_Protected_Definition =>
if Enclosing_List = Private_Declarations (Enclosing_Node) then
Result := True;
exit;
end if;
when others =>
null;
end case;
Next_Node := Parent (Next_Node);
while Nkind (Next_Node) /= N_Compilation_Unit and then
not Is_List_Member (Next_Node)
loop
Next_Node := Parent (Next_Node);
end loop;
end loop;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Is_Private");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Private",
Ex => Ex,
Arg_Element => Declaration);
end Is_Private;
------------------
-- Is_Procedure --
------------------
function Is_Procedure (Decl : Asis.Element) return Boolean is
Result : Boolean := False;
begin
case Declaration_Kind (Decl) is
when A_Procedure_Declaration |
A_Procedure_Instantiation |
A_Procedure_Body_Declaration |
A_Null_Procedure_Declaration |
A_Procedure_Renaming_Declaration =>
Result := True;
when others =>
null;
end case;
return Result;
end Is_Procedure;
-----------------
-- Is_RCI_Unit --
-----------------
function Is_RCI_Unit (C : Asis.Compilation_Unit) return Boolean is
Arg_Node : Node_Id;
Result : Boolean := False;
begin
if Is_Standard (C) then
return False;
end if;
case Unit_Kind (C) is
when A_Package |
A_Procedure_Body |
A_Function_Body |
A_Generic_Package =>
Arg_Node := Unit (Top (C));
Arg_Node := Defining_Unit_Name (Specification (Arg_Node));
if Nkind (Arg_Node) = N_Defining_Program_Unit_Name then
Arg_Node := Defining_Identifier (Arg_Node);
end if;
Result := Is_Remote_Call_Interface (Arg_Node);
when others => null;
end case;
return Result;
end Is_RCI_Unit;
-------------------------
-- Is_Renaming_As_Body --
-------------------------
function Is_Renaming_As_Body (Declaration : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Declaration, Package_Name & "Is_Renaming_As_Body");
if Arg_Kind = A_Procedure_Renaming_Declaration or else
Arg_Kind = A_Function_Renaming_Declaration
then
Arg_Node := R_Node (Declaration);
if Nkind (Arg_Node) /= N_Subprogram_Declaration then
Result := Present (Corresponding_Spec (Arg_Node));
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Is_Renaming_As_Body");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Renaming_As_Body",
Ex => Ex,
Arg_Element => Declaration);
end Is_Renaming_As_Body;
---------------
-- Is_Static --
---------------
function Is_Static (Element : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Element);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Element, Package_Name & "Is_Static");
if Arg_Kind in Internal_Expression_Kinds and then
Is_True_Expression (Element)
then
Result := Sinfo.Is_Static_Expression (R_Node (Element));
elsif Arg_Kind = A_Range_Attribute_Reference or else
Arg_Kind =
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
or else
Arg_Kind = A_Discrete_Range_Attribute_Reference
then
Arg_Node := R_Node (Element);
if Nkind (Arg_Node) = N_Range_Constraint then
Arg_Node := Range_Expression (Arg_Node);
end if;
if Nkind (Arg_Node) = N_Range and then
Is_Static_Expression (Low_Bound (Arg_Node)) and then
Is_Static_Expression (High_Bound (Arg_Node))
then
Result := True;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Is_Static");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Static",
Ex => Ex,
Arg_Element => Element);
end Is_Static;
------------------------
-- Is_True_Expression --
------------------------
function Is_True_Expression
(Expression : Asis.Expression)
return Boolean
is
Arg_Node : Node_Id := Node (Expression);
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Expression);
Expr_Chars : Name_Id;
Entity_Node : Entity_Id;
Result : Boolean := True;
-- the idea of the implementation is to find out the cases when
-- Expression is NOT a true exception, so we initialize Result
-- as True
begin
Check_Validity (Expression, Package_Name & "Is_True_Expression");
if Arg_Kind not in Internal_Expression_Kinds then
return False;
end if;
if Nkind (Arg_Node) = N_Identifier and then
Nkind (Parent (Arg_Node)) = N_Expanded_Name and then
Arg_Node = Selector_Name (Parent (Arg_Node))
then
-- selector in an expanded name - all the semantic fields
-- are set for the whole name, but not for this selector.
-- So:
Arg_Node := Parent (Arg_Node);
end if;
if Nkind (Arg_Node) not in N_Has_Etype or else
No (Etype (Arg_Node)) or else
Is_Anonymous (Ekind (Etype (Arg_Node))) or else
Ekind (Etype (Arg_Node)) = E_Subprogram_Type
then
-- Expression may be a true expression, but it may have a type which
-- cannot be represented in ASIS (such as an anonymous access type),
-- in such cases we also classify it as being not true expression
Result := False;
else
-- in some cases more detailed analysis is required.
-- ??? This part may require some more analysis - it may be
-- somewhat redundant
case Arg_Kind is
when An_Identifier | A_Selected_Component =>
-- and here we have to investigate whether or not this
-- Expression is a "naming expression"
if Special_Case (Expression) = Rewritten_Named_Number then
return True;
end if;
-- ??? <tree problem 1>
-- this fragment should be revised when the problem is fixed (as it should)
if Nkind (Arg_Node) = N_Selected_Component and then
Etype (Arg_Node) = Any_Type
-- for now (GNAT 3.05) this means, that Expression is an
-- expanded name of the character literal of ether a
-- predefined character type or of the type derived from a
-- predefined character type; the problem is that the
-- Entity field is not set for such a node
then
return True;
end if;
-- ??? <tree problem 1> - end
-- now taking the Entity field (if any) and looking,
-- what we have:
if Nkind (Arg_Node) = N_Selected_Component then
Entity_Node := Entity (Selector_Name (Arg_Node));
elsif Nkind (Arg_Node) = N_Attribute_Definition_Clause then
-- the attribute designator in an attribute definition
-- clause
Entity_Node := Empty;
else
Entity_Node := Entity (Arg_Node);
end if;
if No (Entity_Node) then
Result := False;
elsif Ekind (Entity_Node) = E_Enumeration_Literal then
null;
else
case Ekind (Entity_Node) is
-- the first choice in this case statement should
-- filter in entities which *ARE* expressions in Ada
-- sense
when E_Variable =>
-- tasks and protected objects declared by _single_
-- task/protected declarations do not have
-- corresponding type declarations which can be
-- represented in ASIS
Result := Comes_From_Source (Parent (Entity_Node));
when E_Component |
E_Constant |
E_Discriminant |
E_Loop_Parameter |
E_In_Out_Parameter |
E_In_Parameter |
E_Out_Parameter |
E_Generic_In_Out_Parameter |
E_Generic_In_Parameter |
E_Named_Integer |
E_Named_Real |
E_Enumeration_Literal |
-- ??? (see elsif path)
-- enumeration literals are not treated as
-- functions in ASIS
E_Entry_Index_Parameter |
E_Protected_Object =>
null;
-- simply keeping the initialization of Result
when others =>
Result := False;
end case;
end if;
when Internal_Operator_Symbol_Kinds =>
Result := False;
when Internal_Attribute_Reference_Kinds =>
case Internal_Attribute_Reference_Kinds (Arg_Kind) is
when An_Adjacent_Attribute |
A_Base_Attribute |
A_Ceiling_Attribute |
A_Class_Attribute |
A_Compose_Attribute |
A_Copy_Sign_Attribute |
An_Exponent_Attribute |
A_Floor_Attribute |
A_Fraction_Attribute |
An_Image_Attribute |
An_Input_Attribute |
A_Leading_Part_Attribute |
A_Machine_Attribute |
A_Max_Attribute |
A_Min_Attribute |
A_Model_Attribute |
An_Output_Attribute |
A_Pos_Attribute |
A_Pred_Attribute |
A_Range_Attribute |
A_Read_Attribute |
A_Remainder_Attribute |
A_Round_Attribute |
A_Rounding_Attribute |
A_Scaling_Attribute |
A_Succ_Attribute |
A_Truncation_Attribute |
An_Unbiased_Rounding_Attribute |
A_Val_Attribute |
A_Value_Attribute |
A_Wide_Image_Attribute |
A_Wide_Value_Attribute |
A_Write_Attribute =>
Result := False;
when An_Implementation_Defined_Attribute =>
Expr_Chars := Attribute_Name (Arg_Node);
if Expr_Chars = Name_Abort_Signal or else
Expr_Chars = Name_Elab_Body or else
Expr_Chars = Name_Elab_Spec
then
Result := False;
end if;
when others =>
null;
end case;
when A_Positional_Array_Aggregate | A_Named_Array_Aggregate =>
if Nkind (Parent (Arg_Node)) =
N_Enumeration_Representation_Clause
or else
Is_Typeless_Subaggregate (Arg_Node)
then
Result := False;
end if;
when others =>
null;
end case;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name & "Is_True_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_True_Expression",
Ex => Ex,
Arg_Element => Expression);
end Is_True_Expression;
----------------------
-- Is_Type_Operator --
----------------------
function Is_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Op_Decl);
Result : Boolean := False;
Next_Type : Asis.Element;
begin
if (Arg_Kind = A_Function_Declaration
or else
((Arg_Kind = A_Function_Body_Declaration
or else
Arg_Kind = A_Function_Body_Stub
or else
Arg_Kind = A_Function_Renaming_Declaration)
and then
not (Is_Equal (Corresponding_Declaration (Op_Decl), Op_Decl)))
or else
Arg_Kind = A_Function_Instantiation
or else
Arg_Kind = A_Formal_Function_Declaration)
and then
Int_Kind (Names (Op_Decl) (1)) in Internal_Defining_Operator_Kinds
then
-- First, check the result type
Next_Type := Result_Profile (Op_Decl);
if Int_Kind (Next_Type) = A_Selected_Component then
Next_Type := Selector (Next_Type);
end if;
if Int_Kind (Next_Type) = An_Identifier then
Next_Type := Corresponding_Name_Declaration (Next_Type);
Next_Type := Corresponding_First_Subtype (Next_Type);
if Is_Equal (Next_Type, Type_Decl) then
Result := True;
end if;
end if;
if not Result then
-- check parameter types
declare
Params : constant Asis.Element_List :=
Parameter_Profile (Op_Decl);
begin
for J in Params'Range loop
Next_Type := Object_Declaration_View (Params (J));
if Int_Kind (Next_Type) = A_Selected_Component then
Next_Type := Selector (Next_Type);
end if;
if Int_Kind (Next_Type) = An_Identifier then
Next_Type := Corresponding_Name_Declaration (Next_Type);
Next_Type := Corresponding_First_Subtype (Next_Type);
if Is_Equal (Next_Type, Type_Decl) then
Result := True;
exit;
end if;
end if;
end loop;
end;
end if;
end if;
return Result;
end Is_Type_Operator;
------------------------------
-- Is_Typeless_Subaggregate --
------------------------------
function Is_Typeless_Subaggregate (Aggr : Node_Id) return Boolean is
Parent_Node : Node_Id := Parent (Aggr);
Result : Boolean := False;
Arg_Type : Entity_Id;
Parent_Type : Entity_Id;
begin
if Nkind (Parent_Node) = N_Component_Association then
Parent_Node := Parent (Parent_Node);
end if;
if Nkind (Parent_Node) = N_Aggregate then
Arg_Type := Etype (Aggr);
while Present (Arg_Type) and then Etype (Arg_Type) /= Arg_Type loop
Arg_Type := Etype (Arg_Type);
end loop;
Parent_Type := Etype (Parent_Node);
while Present (Parent_Type)
and then Etype (Parent_Type) /= Parent_Type
loop
Parent_Type := Etype (Parent_Type);
end loop;
Result := Arg_Type = Parent_Type;
end if;
return Result;
end Is_Typeless_Subaggregate;
-------------------------
-- Is_Uniquely_Defined --
-------------------------
function Is_Uniquely_Defined (Reference : Asis.Expression) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Reference);
Arg_Node : Node_Id;
Result : Boolean := False;
begin
Check_Validity (Reference, Package_Name & "Is_Uniquely_Defined");
if Arg_Kind = An_Identifier or else
Arg_Kind in Internal_Operator_Symbol_Kinds or else
Arg_Kind = A_Character_Literal or else
Arg_Kind = An_Enumeration_Literal
then
Result := True;
-- We suppose, that in general case we have a unique declaration,
-- and now let's try to detect if we have a special case:
Arg_Node := Node (Reference);
-- first, the situation when "passed a portion of a pragma that
-- was "ignored" by the compiler", it relates to pragma arguments
-- only, but not to pragma element identifiers:
-- GNAT rewrites the tree structure for non-recognized pragma as
-- if it is a null statement, so:
if Nkind (Parent (Parent (Arg_Node))) = N_Null_Statement then
Result := False;
end if;
if Arg_Kind = An_Identifier then
-- There are three checks specific to arguments of An_Identifier
-- kind only: a pragma_argument_identifier, an identifier specific
-- to a pragma and a reference to an attribute_designator:
if Nkind (Arg_Node) = N_Pragma_Argument_Association
-- a reference to a pragma_argument_identifier
or else
(Nkind (Arg_Node) in N_Has_Entity
and then
No (Entity (Arg_Node))
and then
(Nkind (Parent (Arg_Node)) = N_Pragma_Argument_Association
or else
Is_From_Import_Procedure_Pragma (Arg_Node)))
-- an identifier specific to a pragma, we make a guess that
-- any identifier on the place of a pragma argument is
-- specific to the pragma, if the Entity field is not set
-- for this identifier. Is it really true???
or else
Nkind (Arg_Node) = N_Attribute_Reference
or else
Special_Case (Reference) = Dummy_Class_Attribute_Designator
-- a reference to an attribute_designator
or else
Nkind (Arg_Node) = N_Attribute_Definition_Clause
-- attribute designator from an attribute definition clause
then
Result := False;
end if;
end if;
-- One more check for pragma argument. It corresponds to the
-- situation when the identifier is specific for a pragma, but in
-- the same time it is a part of other expression. This check is
-- specific to extended Import and Export pragmas applying to
-- subprograms.
if Result and then
Special_Case (Reference) = Not_A_Special_Case and then
Arg_Kind = An_Identifier and then
No (Entity (Arg_Node))
then
-- The first possibility:
--
-- pragma Import_Function (Internal => Unix_Code_Mappings,
-- External => "unix_code_mappings",
-- Result_Type => Integer,
-- Mechanism => (Value));
--
-- Value is rewritten into N_Aggregate
--
-- The second possibility:
--
-- pragma Import_Procedure (Internal => Ignore_Signal,
-- External => "ignore_signal",
-- Mechanism => (Value, Value));
--
-- Value is not rewritten and it is represented as a "normal"
-- aggregate component
--
-- And the third possibility:
--
-- pragma Export_Procedure
-- (Internal => Reset,
-- External => "",
-- Parameter_Types => (File_Type, File_Mode),
-- Mechanism => (File => Reference));
--
-- Here we have an aggregate with named associations:
if (Nkind (R_Node (Reference)) = N_Aggregate and then
(Nkind (Parent (R_Node (Reference)))) =
N_Pragma_Argument_Association)
or else
(Nkind (R_Node (Reference)) = N_Identifier
and then
not (Is_Rewrite_Substitution (R_Node (Reference)))
and then
((Nkind (Parent (R_Node (Reference))) = N_Aggregate
and then
Nkind (Parent (Parent (R_Node (Reference)))) =
N_Pragma_Argument_Association)
or else
(Nkind (Parent (R_Node (Reference))) =
N_Component_Association
and then
Nkind (Parent (Parent (R_Node (Reference)))) =
N_Aggregate
and then
Nkind (Parent (Parent (Parent ((R_Node (Reference)))))) =
N_Pragma_Argument_Association)
)
)
then
Result := False;
end if;
end if;
-- Then check for the situation when if passed a portion of a pragma
-- that may be an ambiguous reference to more than one entity.
if Result and then
Nkind (Parent (Arg_Node)) = N_Pragma_Argument_Association and then
Needs_List (Reference)
then
declare
Res_List : constant Asis.Element_List :=
Corresponding_Name_Definition_List (Reference);
begin
if Res_List'Length /= 1 then
Result := False;
end if;
end;
end if;
end if;
-- Case when the argument is a parameter of Source_File_Name pragma or
-- component thereof
if Result then
while not Is_List_Member (Arg_Node) and then
Present (Arg_Node)
loop
Arg_Node := Parent (Arg_Node);
end loop;
if Nkind (Arg_Node) = N_Pragma_Argument_Association
and then
Pragma_Name (Parent (Arg_Node)) = Name_Source_File_Name
then
Result := False;
end if;
end if;
-- Case when the argument is the (component of the) prefix of the
-- GNAT-specific attribute 'Elab_Body or 'Elab_Spec
if Result then
Arg_Node := Parent (R_Node (Reference));
while Nkind (Arg_Node) = N_Selected_Component loop
Arg_Node := Parent (Arg_Node);
end loop;
if Nkind (Arg_Node) = N_Attribute_Reference
and then
Attribute_Name (Arg_Node) in Name_Elab_Body .. Name_Elab_Spec
then
Result := False;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Reference,
Outer_Call => Package_Name & "Is_Uniquely_Defined");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Uniquely_Defined",
Ex => Ex,
Arg_Element => Reference);
end Is_Uniquely_Defined;
-------------------------------
-- Main_Unit_In_Current_Tree --
-------------------------------
function Main_Unit_In_Current_Tree
(The_Context : Asis.Context)
return Asis.Compilation_Unit
is
Curr_Tree_Id : Tree_Id;
Curr_Cont_Id : Context_Id;
Res_Unit_Id : Unit_Id := Nil_Unit;
begin
Check_Validity (The_Context, Package_Name & "Main_Unit_In_Current_Tree");
Curr_Cont_Id := Get_Current_Cont;
Curr_Tree_Id := Get_Current_Tree;
if Tree_Processing_Mode (Get_Cont_Id (The_Context)) = GNSA then
-- Note, that for GNSA Context no check is made! This works correctly
-- only for -GNSA -C1 Context and if only this Context Is_Open
-- at the moment
Res_Unit_Id := Config_Comp_Id + 1; -- ???
-- Not a good approach!!!
elsif Get_Cont_Id (The_Context) = Curr_Cont_Id and then
Curr_Cont_Id /= Nil_Context_Id and then
Present (Curr_Tree_Id)
then
Res_Unit_Id := Main_Unit_Id;
elsif Get_Cont_Id (The_Context) /= Nil_Context_Id then
Reset_Context (Get_Cont_Id (The_Context));
if Tree_Processing_Mode (Get_Cont_Id (The_Context)) = GNSA then
-- Note, that for GNSA Context no check is made! This works
-- correctly only for -GNSA -C1 Context and if only this Context
-- Is_Open at the moment
Res_Unit_Id := Config_Comp_Id + 1; -- ???
-- Not a good approach!!!
elsif Last_Tree (Get_Cont_Id (The_Context)) >= First_Tree_Id then
Res_Unit_Id := Main_Unit_Id (First_Tree_Id);
end if;
end if;
if Present (Res_Unit_Id) then
return Get_Comp_Unit (Res_Unit_Id, Get_Cont_Id (The_Context));
else
return Nil_Compilation_Unit;
end if;
exception
when ASIS_Inappropriate_Context =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Main_Unit_In_Current_Tree");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Main_Unit_In_Current_Tree",
Ex => Ex);
end Main_Unit_In_Current_Tree;
-----------
-- No_Op --
-----------
procedure No_Op
(Element : Asis.Element;
Control : in out Traverse_Control;
State : in out No_State)
is
begin
pragma Unreferenced (Element);
pragma Unreferenced (Control);
pragma Unreferenced (State);
null;
end No_Op;
-------------------------
-- Normalize_Reference --
-------------------------
function Normalize_Reference (Ref : Asis.Element) return Asis.Element is
Result : Asis.Element := Ref;
begin
case Expression_Kind (Ref) is
when A_Selected_Component =>
Result := Selector (Ref);
when An_Attribute_Reference =>
Result := Normalize_Reference (Prefix (Ref));
when others =>
null;
end case;
return Result;
end Normalize_Reference;
--------------------------
-- Original_Line_Number --
--------------------------
function Original_Line_Number
(Element : Asis.Element;
Compiled_Line : Line_Number_Positive)
return Line_Number
is
SFI : Source_File_Index;
Result : Line_Number := 0;
begin
Check_Validity (Element, Package_Name & "Original_Line_Number");
if Is_Text_Available (Element) then
if Compiled_Line > Line_Number (Number_Of_Lines (Element)) then
Raise_ASIS_Inappropriate_Line_Number
(Package_Name & "Original_Line_Number");
end if;
SFI := Get_Source_File_Index (Location (Element));
Result :=
Line_Number (Sinput.Physical_To_Logical
(Physical_Line_Number (Compiled_Line), SFI));
end if;
return Result;
exception
when ASIS_Inappropriate_Element | ASIS_Inappropriate_Line_Number =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Element,
Outer_Call => Package_Name & "Original_Line_Number");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Original_Line_Number",
Ex => Ex,
Arg_Element => Element);
end Original_Line_Number;
------------------------
-- Original_Text_Name --
------------------------
function Original_Text_Name
(Compilation_Unit : Asis.Compilation_Unit)
return Wide_String
is
begin
Check_Validity (Compilation_Unit, Package_Name & "Original_Text_Name");
if not Exists (Compilation_Unit) then
return Nil_Asis_Wide_String;
else
-- Exists resets the Context!
return To_Program_Text (Ref_File (Compilation_Unit));
end if;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Original_Text_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Original_Text_Name",
Ex => Ex,
Arg_CU => Compilation_Unit);
end Original_Text_Name;
-----------------------------
-- Overrides_Type_Operator --
-----------------------------
function Overrides_Type_Operator
(Op_Decl : Asis.Element;
Type_Decl : Asis.Element)
return Boolean
is
pragma Unreferenced (Type_Decl);
Op_Entity : Entity_Id;
Result : Boolean := False;
begin
-- We assume that Is_Type_Operator (Op_Decl, Type_Decl) is True
-- !!! The implementation is incomplete!!!
Op_Entity := Node (Names (Op_Decl) (1));
if Present (Overridden_Operation (Op_Entity)) then
Result := True;
end if;
return Result;
end Overrides_Type_Operator;
---------------------
-- Primitive_Owner --
---------------------
function Primitive_Owner
(Declaration : Asis.Declaration)
return Asis.Type_Definition
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Declaration);
Arg_Node : Node_Id := Empty;
Par_Node : Node_Id := Empty;
Res_Node : Node_Id := Empty;
Result : Element := Nil_Element;
Res_Kind : Internal_Element_Kinds := Not_An_Element;
begin
Check_Validity (Declaration, Package_Name & "Primitive_Owner");
if not (Arg_Kind = A_Procedure_Declaration or else
Arg_Kind = A_Null_Procedure_Declaration or else
Arg_Kind = A_Function_Declaration or else
Arg_Kind = A_Procedure_Renaming_Declaration or else
Arg_Kind = A_Function_Renaming_Declaration or else
Arg_Kind = A_Procedure_Body_Declaration or else
Arg_Kind = A_Function_Body_Declaration or else
Arg_Kind = A_Procedure_Body_Stub or else
Arg_Kind = A_Function_Body_Stub)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Primitive_Owner",
Wrong_Kind => Arg_Kind);
end if;
if not Is_From_Implicit (Declaration) and then
Asis.Declarations.Is_Dispatching_Operation (Declaration)
then
Arg_Node := Specification (Node (Declaration));
if Nkind (Arg_Node) = N_Function_Specification then
if Has_Controlling_Result (Defining_Unit_Name (Arg_Node)) then
Res_Node := Defining_Unit_Name (Arg_Node);
Res_Node := Parent (Res_Node);
Res_Node := Sinfo.Result_Definition (Res_Node);
if Nkind (Res_Node) = N_Access_Definition then
Res_Node := Sinfo.Subtype_Mark (Res_Node);
end if;
Res_Node := Entity (Res_Node);
end if;
end if;
if No (Res_Node) then
-- This means that we do not have a function with controlling
-- result, so we have to go through the formal parameter list,
-- and it can not be No_List or empty
Par_Node := First (Parameter_Specifications (Arg_Node));
while Present (Par_Node) loop
if Is_Controlling_Formal
(Defining_Identifier (Par_Node))
then
if Nkind (Parameter_Type (Par_Node)) =
N_Access_Definition
then
Res_Node :=
Sinfo.Subtype_Mark (Parameter_Type (Par_Node));
else
Res_Node := Defining_Identifier (Par_Node);
end if;
Res_Node := Etype (Res_Node);
exit;
end if;
Par_Node := Next (Par_Node);
end loop;
end if;
pragma Assert (Present (Res_Node));
if Nkind (Parent (Res_Node)) = N_Subtype_Declaration then
Res_Node := Etype (Res_Node);
end if;
Res_Node := Parent (Res_Node);
case Nkind (Res_Node) is
when N_Private_Type_Declaration =>
if Tagged_Present (Res_Node) then
Res_Kind := A_Tagged_Private_Type_Definition;
else
-- It can be non-tagged, if the full view is tagged
Res_Kind := A_Private_Type_Definition;
end if;
when N_Private_Extension_Declaration =>
Res_Kind := A_Private_Extension_Definition;
when N_Full_Type_Declaration =>
Res_Node := Sinfo.Type_Definition (Res_Node);
when others =>
pragma Assert (False);
null;
end case;
Result := Node_To_Element_New (Node => Res_Node,
Internal_Kind => Res_Kind,
Starting_Element => Declaration);
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Declaration,
Outer_Call => Package_Name & "Primitive_Owner");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Primitive_Owner",
Ex => Ex,
Arg_Element => Declaration);
end Primitive_Owner;
------------------------
-- Source_File_Status --
------------------------
function Source_File_Status
(Right : Asis.Compilation_Unit)
return Source_File_Statuses
is
Arg_Kind : constant Unit_Kinds := Kind (Right);
Result : Source_File_Statuses;
begin
Check_Validity (Right, Package_Name & "Source_File_Status");
case Arg_Kind is
when Not_A_Unit |
A_Nonexistent_Declaration |
A_Nonexistent_Body |
An_Unknown_Unit =>
Result := Absent;
when others =>
Result := Source_Status (Right);
end case;
return Result;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Source_File_Status");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Source_File_Status",
Ex => Ex,
Arg_CU => Right);
end Source_File_Status;
-----------------------------------
-- Static_Expression_Value_Image --
-----------------------------------
function Static_Expression_Value_Image
(Expression : Asis.Expression)
return Wide_String
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Expression);
Arg_Node : Node_Id := Empty;
Result : Uint;
Tmp_El : Asis.Element;
begin
Check_Validity
(Expression, Package_Name & "Static_Expression_Value_Image");
if Arg_Kind not in Internal_Expression_Kinds then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Static_Expression_Value_Image",
Wrong_Kind => Arg_Kind);
end if;
if not (Is_True_Expression (Expression) and then
Is_Static (Expression))
then
return "";
end if;
Arg_Node := R_Node (Expression);
if Nkind (Arg_Node) = N_String_Literal then
String_To_Name_Buffer (Strval (Arg_Node));
return To_Wide_String (Name_Buffer (1 .. Name_Len));
-- elsif Nkind (Arg_Node) = N_Real_Literal then
-- begin
-- return Long_Long_Float'Wide_Image
-- (Get_LF_From_Ureal (Realval (Arg_Node)));
-- exception
-- when others => return "";
-- end;
elsif Has_Enumeration_Type (Expression) or else
Has_Integer_Type (Expression)
then
Result := Eval_Scalar_Node (Arg_Node);
UI_Image (Result, Format => Decimal);
return To_Wide_String (UI_Image_Buffer (1 .. UI_Image_Length));
else
if Expression_Kind (Expression) = A_Selected_Component then
Tmp_El := Selector (Expression);
else
Tmp_El := Expression;
end if;
if Expression_Kind (Tmp_El) = An_Identifier then
begin
Tmp_El := Corresponding_Name_Declaration (Tmp_El);
exception
when ASIS_Inappropriate_Element =>
Tmp_El := Nil_Element;
end;
if Declaration_Kind (Tmp_El) = A_Constant_Declaration then
Tmp_El := Initialization_Expression (Tmp_El);
return Static_Expression_Value_Image (Tmp_El);
end if;
end if;
end if;
return "";
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Expression,
Outer_Call => Package_Name & "Static_Expression_Value_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Static_Expression_Value_Image",
Ex => Ex,
Arg_Element => Expression);
end Static_Expression_Value_Image;
-----------------------------------------
-- Static_Range_High_Bound_Value_Image --
-----------------------------------------
function Static_Range_High_Bound_Value_Image
(Range_Element : Asis.Range_Constraint)
return Wide_String
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Range_Element);
Arg_Node : Node_Id := Empty;
Arg_Ekind : Entity_Kind;
Result : Uint;
begin
Check_Validity
(Range_Element, Package_Name & "Static_Range_High_Bound_Value_Image");
if not (Arg_Kind = A_Range_Attribute_Reference or else
Arg_Kind =
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
or else
Arg_Kind = A_Discrete_Range_Attribute_Reference)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Static_Range_High_Bound_Value_Image",
Wrong_Kind => Arg_Kind);
end if;
if not (Is_Static (Range_Element)) then
return "";
end if;
Arg_Node := R_Node (Range_Element);
if Nkind (Arg_Node) = N_Range_Constraint then
Arg_Node := Range_Expression (Arg_Node);
end if;
Arg_Ekind := Ekind (Etype (Arg_Node));
if not (Arg_Ekind in Discrete_Kind) then
-- Implementation limitation!!!
return "";
end if;
Result := Eval_Scalar_Node (High_Bound (Arg_Node));
UI_Image (Result, Format => Decimal);
return To_Wide_String (UI_Image_Buffer (1 .. UI_Image_Length));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Range_Element,
Outer_Call => Package_Name &
"Static_Range_High_Bound_Value_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Static_Range_High_Bound_Value_Image",
Ex => Ex,
Arg_Element => Range_Element);
end Static_Range_High_Bound_Value_Image;
----------------------------------------
-- Static_Range_Low_Bound_Value_Image --
----------------------------------------
function Static_Range_Low_Bound_Value_Image
(Range_Element : Asis.Range_Constraint)
return Wide_String
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Range_Element);
Arg_Node : Node_Id := Empty;
Arg_Ekind : Entity_Kind;
Result : Uint;
begin
Check_Validity
(Range_Element, Package_Name & "Static_Range_Low_Bound_Value_Image");
if not (Arg_Kind = A_Range_Attribute_Reference or else
Arg_Kind =
A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
or else
Arg_Kind = A_Discrete_Range_Attribute_Reference)
then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Static_Range_Low_Bound_Value_Image",
Wrong_Kind => Arg_Kind);
end if;
if not (Is_Static (Range_Element)) then
return "";
end if;
Arg_Node := R_Node (Range_Element);
if Nkind (Arg_Node) = N_Range_Constraint then
Arg_Node := Range_Expression (Arg_Node);
end if;
Arg_Ekind := Ekind (Etype (Arg_Node));
if not (Arg_Ekind in Discrete_Kind) then
-- Implementation limitation!!!
return "";
end if;
Result := Eval_Scalar_Node (Low_Bound (Arg_Node));
UI_Image (Result, Format => Decimal);
return To_Wide_String (UI_Image_Buffer (1 .. UI_Image_Length));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Range_Element,
Outer_Call => Package_Name &
"Static_Range_Low_Bound_Value_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Static_Range_Low_Bound_Value_Image",
Ex => Ex,
Arg_Element => Range_Element);
end Static_Range_Low_Bound_Value_Image;
end Asis.Extensions;
|
-- AOC, Day 3
with Ada.Text_IO; use Ada.Text_IO;
with FMS;
procedure main is
begin
FMS.load_file("day3_input.txt");
put_line("Part 1: " & Positive'Image(FMS.closest_intersection));
put_line("Part 2: " & Positive'Image(FMS.shortest_intersection));
end main;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 - 2019 Joakim Strandberg <joakim@mequinox.se>
--
-- 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 Wayland_XML;
with Aida;
with Ada.Containers.Vectors;
pragma Elaborate_All (Wayland_XML);
pragma Elaborate_All (Aida);
package Xml_Parser_Utils is
function Adaify_Name (Old_Name : String) return String;
function Adaify_Variable_Name (Old_Name : String) return String;
-- If the variable name is "Interface" then it will be recognized as
-- a reserved word in Ada and it will be suffixed with "_V" resulting
-- in "Interface_V"
function Arg_Type_As_String (Arg_Tag : Wayland_XML.Arg_Tag) return String;
function Number_Of_Args
(Request_Tag : aliased Wayland_XML.Request_Tag) return Natural;
function Is_New_Id_Argument_Present
(Request_Tag : aliased Wayland_XML.Request_Tag) return Boolean;
function Is_Interface_Specified
(Request_Tag : aliased Wayland_XML.Request_Tag) return Boolean with
Pre => Is_New_Id_Argument_Present (Request_Tag);
Interface_Not_Found_Exception : exception;
function Find_Specified_Interface
(Request_Tag : aliased Wayland_XML.Request_Tag) return String with
Pre => Is_Interface_Specified (Request_Tag);
-- Will raise Interface_Not_Found_Exception is pre-condition is not met
function Is_Request_Destructor
(Request_Tag : aliased Wayland_XML.Request_Tag) return Boolean;
function Get_Destructor
(Interface_Tag : aliased Wayland_XML.Interface_Tag) return String;
function Exists_Any_Event_Tag
(Interface_Tag : aliased Wayland_XML.Interface_Tag) return Boolean;
function Remove_Tabs (Text : String) return String;
type Interval is record
First : Positive;
Last : Natural;
end record;
package Interval_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Interval,
"=" => "=");
type Intervals_Ref
(Element : not null access constant Interval_Vectors.Vector)
is limited null record with Implicit_Dereference => Element;
type Interval_Identifier is tagged limited private;
function Intervals
(This : aliased Interval_Identifier) return Intervals_Ref with
Global => null;
function Make (Text : String) return Interval_Identifier with
Global => null;
private
type Interval_Identifier is tagged limited record
My_Intervals : aliased Interval_Vectors.Vector;
end record;
function Intervals
(This : aliased Interval_Identifier) return Intervals_Ref
is ((Element => This.My_Intervals'Access));
end Xml_Parser_Utils;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
procedure P(X: in out Integer) is begin X := 0; end;
v: integer;
begin
P(V);
end;
|
package body Tail_Call_P is
function Start_Side (Element : T) return Index is
begin
if Element = 1 then
raise Program_Error;
end if;
if Element = 0 then
return Second;
else
return First;
end if;
end;
function Segment (Element : T) return T is
begin
if Element /= 0 then
raise Program_Error;
end if;
return 1;
end;
procedure Really_Insert (Into : T; Element : T; Value : T) is
begin
if Into /= 0 then
raise Program_Error;
end if;
end;
procedure Insert (Into : A; Element : T; Value : T) is
begin
Really_Insert (Into (Start_Side (Element)), Segment (Element), Value);
end Insert;
end Tail_Call_P;
|
pragma License (Unrestricted);
with Ada.IO_Exceptions;
with System.Storage_Elements;
generic
type Element_Type is private;
package Ada.Storage_IO is
pragma Preelaborate;
Buffer_Size : constant System.Storage_Elements.Storage_Count :=
Element_Type'Max_Size_In_Storage_Elements; -- implementation-defined
subtype Buffer_Type is
System.Storage_Elements.Storage_Array (1 .. Buffer_Size);
-- Input and output operations
procedure Read (Buffer : Buffer_Type; Item : out Element_Type);
pragma Inline (Read);
procedure Write (Buffer : out Buffer_Type; Item : Element_Type);
pragma Inline (Write);
-- Exceptions
Data_Error : exception
renames IO_Exceptions.Data_Error;
end Ada.Storage_IO;
|
--- src/gprbuild-link.adb.orig 2021-05-19 05:22:13 UTC
+++ src/gprbuild-link.adb
@@ -3224,8 +3224,6 @@ package body Gprbuild.Link is
if Opt.Run_Path_Option
and then Main_Proj.Config.Run_Path_Option /= No_Name_List
then
- Add_Rpath_From_Arguments (Rpaths, Arguments, Main_Proj);
- Add_Rpath_From_Arguments (Rpaths, Other_Arguments, Main_Proj);
Add_Run_Path_Options;
end if;
|
generic
type Number is private;
Zero : Number;
One : Number;
Two : Number;
with function "+" (X, Y : Number) return Number 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;
function Decompose (N : Number) return Number_List;
function Is_Prime (N : Number) return Boolean;
end Prime_Numbers;
|
with Ada.Text_IO, Set_Puzzle, Ada.Command_Line;
procedure Puzzle is
package TIO renames Ada.Text_IO;
Card_Count: Positive := Positive'Value(Ada.Command_Line.Argument(1));
Required_Sets: Positive := Positive'Value(Ada.Command_Line.Argument(2));
Cards: Set_Puzzle.Cards(1 .. Card_Count);
function Cnt_Sets(C: Set_Puzzle.Cards) return Natural is
Cnt: Natural := 0;
procedure Count_Sets(C: Set_Puzzle.Cards; S: Set_Puzzle.Set) is
begin
Cnt := Cnt + 1;
end Count_Sets;
procedure CS is new Set_Puzzle.Find_Sets(Count_Sets);
begin
CS(C);
return Cnt;
end Cnt_Sets;
procedure Print_Sets(C: Set_Puzzle.Cards) is
procedure Print_A_Set(C: Set_Puzzle.Cards; S: Set_Puzzle.Set) is
begin
TIO.Put("(" & Integer'Image(S(1)) & "," & Integer'Image(S(2))
& "," & Integer'Image(S(3)) & " ) ");
end Print_A_Set;
procedure PS is new Set_Puzzle.Find_Sets(Print_A_Set);
begin
PS(C);
TIO.New_Line;
end Print_Sets;
begin
loop -- deal random cards
Set_Puzzle.Deal_Cards(Cards);
exit when Cnt_Sets(Cards) = Required_Sets;
end loop; -- until number of sets is as required
for I in Cards'Range loop -- print the cards
if I < 10 then
TIO.Put(" ");
end if;
TIO.Put_Line(Integer'Image(I) & " " & Set_Puzzle.To_String(Cards(I)));
end loop;
Print_Sets(Cards); -- print the sets
end Puzzle;
|
--//////////////////////////////////////////////////////////
-- SFML - Simple and Fast Multimedia Library
-- Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
-- This software is provided 'as-is', without any express or implied warranty.
-- In no event will the authors be held liable for any damages arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it freely,
-- subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented;
-- you must not claim that you wrote the original software.
-- If you use this software in a product, an acknowledgment
-- in the product documentation would be appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such,
-- and must not be misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
with Sf.Network.IpAddress;
with Sf.System.Time;
with Sf.Network.SocketStatus;
with System;
package Sf.Network.TcpSocket is
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--/ @brief Create a new TCP socket
--/
--/ @return A new sfTcpSocket object
--/
--//////////////////////////////////////////////////////////
function create return sfTcpSocket_Ptr;
--//////////////////////////////////////////////////////////
--/ @brief Destroy a TCP socket
--/
--/ @param socket TCP socket to destroy
--/
--//////////////////////////////////////////////////////////
procedure destroy (socket : sfTcpSocket_Ptr);
--//////////////////////////////////////////////////////////
--/ @brief Set the blocking state of a TCP listener
--/
--/ In blocking mode, calls will not return until they have
--/ completed their task. For example, a call to
--/ sfTcpSocket_receive in blocking mode won't return until
--/ new data was actually received.
--/ In non-blocking mode, calls will always return immediately,
--/ using the return code to signal whether there was data
--/ available or not.
--/ By default, all sockets are blocking.
--/
--/ @param socket TCP socket object
--/ @param blocking sfTrue to set the socket as blocking, sfFalse for non-blocking
--/
--//////////////////////////////////////////////////////////
procedure setBlocking (socket : sfTcpSocket_Ptr; blocking : sfBool);
--//////////////////////////////////////////////////////////
--/ @brief Tell whether a TCP socket is in blocking or non-blocking mode
--/
--/ @param socket TCP socket object
--/
--/ @return sfTrue if the socket is blocking, sfFalse otherwise
--/
--//////////////////////////////////////////////////////////
function isBlocking (socket : sfTcpSocket_Ptr) return sfBool;
--//////////////////////////////////////////////////////////
--/ @brief Get the port to which a TCP socket is bound locally
--/
--/ If the socket is not connected, this function returns 0.
--/
--/ @param socket TCP socket object
--/
--/ @return Port to which the socket is bound
--/
--//////////////////////////////////////////////////////////
function getLocalPort (socket : sfTcpSocket_Ptr) return sfUint16;
--//////////////////////////////////////////////////////////
--/ @brief Get the address of the connected peer of a TCP socket
--/
--/ It the socket is not connected, this function returns
--/ sfIpAddress_None.
--/
--/ @param socket TCP socket object
--/
--/ @return Address of the remote peer
--/
--//////////////////////////////////////////////////////////
function getRemoteAddress (socket : sfTcpSocket_Ptr)
return Sf.Network.IpAddress.sfIpAddress;
--//////////////////////////////////////////////////////////
--/ @brief Get the port of the connected peer to which
--/ a TCP socket is connected
--/
--/ If the socket is not connected, this function returns 0.
--/
--/ @param socket TCP socket object
--/
--/ @return Remote port to which the socket is connected
--/
--//////////////////////////////////////////////////////////
function getRemotePort (socket : sfTcpSocket_Ptr) return sfUint16;
--//////////////////////////////////////////////////////////
--/ @brief Connect a TCP socket to a remote peer
--/
--/ In blocking mode, this function may take a while, especially
--/ if the remote peer is not reachable. The last parameter allows
--/ you to stop trying to connect after a given timeout.
--/ If the socket was previously connected, it is first disconnected.
--/
--/ @param socket TCP socket object
--/ @param remoteAddress Address of the remote peer
--/ @param remotePort Port of the remote peer
--/ @param timeout Maximum time to wait
--/
--/ @return Status code
--/
--//////////////////////////////////////////////////////////
function connect
(socket : sfTcpSocket_Ptr;
remoteAddress : Sf.Network.IpAddress.sfIpAddress;
remotePort : sfUint16;
timeout : Sf.System.Time.sfTime) return Sf.Network.SocketStatus.sfSocketStatus;
--//////////////////////////////////////////////////////////
--/ @brief Disconnect a TCP socket from its remote peer
--/
--/ This function gracefully closes the connection. If the
--/ socket is not connected, this function has no effect.
--/
--/ @param socket TCP socket object
--/
--//////////////////////////////////////////////////////////
procedure disconnect (socket : sfTcpSocket_Ptr);
--//////////////////////////////////////////////////////////
--/ @brief Send raw data to the remote peer of a TCP socket
--/
--/ To be able to handle partial sends over non-blocking
--/ sockets, use the sfTcpSocket_sendPartial(sfTcpSocket*, const void*, std::size_t, sfSize_t*)
--/ overload instead.
--/ This function will fail if the socket is not connected.
--/
--/ @param socket TCP socket object
--/ @param data Pointer to the sequence of bytes to send
--/ @param size Number of bytes to send
--/
--/ @return Status code
--/
--//////////////////////////////////////////////////////////
function send
(socket : sfTcpSocket_Ptr;
data : Standard.System.Address;
size : sfSize_t) return Sf.Network.SocketStatus.sfSocketStatus;
--//////////////////////////////////////////////////////////
--/ @brief Send raw data to the remote peer
--/
--/ This function will fail if the socket is not connected.
--/
--/ @param socket TCP socket object
--/ @param data Pointer to the sequence of bytes to send
--/ @param size Number of bytes to send
--/ @param sent The number of bytes sent will be written here
--/
--/ @return Status code
--/
--//////////////////////////////////////////////////////////
function sendPartial
(socket : sfTcpSocket_Ptr;
data : Standard.System.Address;
size : sfSize_t;
sent : access sfSize_t) return Sf.Network.SocketStatus.sfSocketStatus;
--//////////////////////////////////////////////////////////
--/ @brief Receive raw data from the remote peer of a TCP socket
--/
--/ In blocking mode, this function will wait until some
--/ bytes are actually received.
--/ This function will fail if the socket is not connected.
--/
--/ @param socket TCP socket object
--/ @param data Pointer to the array to fill with the received bytes
--/ @param size Maximum number of bytes that can be received
--/ @param received This variable is filled with the actual number of bytes received
--/
--/ @return Status code
--/
--//////////////////////////////////////////////////////////
function receive
(socket : sfTcpSocket_Ptr;
data : Standard.System.Address;
size : sfSize_t;
received : access sfSize_t) return Sf.Network.SocketStatus.sfSocketStatus;
--//////////////////////////////////////////////////////////
--/ @brief Send a formatted packet of data to the remote peer of a TCP socket
--/
--/ In non-blocking mode, if this function returns sfSocketPartial,
--/ you must retry sending the same unmodified packet before sending
--/ anything else in order to guarantee the packet arrives at the remote
--/ peer uncorrupted.
--/ This function will fail if the socket is not connected.
--/
--/ @param socket TCP socket object
--/ @param packet Packet to send
--/
--/ @return Status code
--/
--//////////////////////////////////////////////////////////
function sendPacket (socket : sfTcpSocket_Ptr;
packet : sfPacket_Ptr)
return Sf.Network.SocketStatus.sfSocketStatus;
--//////////////////////////////////////////////////////////
--/ @brief Receive a formatted packet of data from the remote peer
--/
--/ In blocking mode, this function will wait until the whole packet
--/ has been received.
--/ This function will fail if the socket is not connected.
--/
--/ @param socket TCP socket object
--/ @param packet Packet to fill with the received data
--/
--/ @return Status code
--/
--//////////////////////////////////////////////////////////
function receivePacket (socket : sfTcpSocket_Ptr;
packet : sfPacket_Ptr)
return Sf.Network.SocketStatus.sfSocketStatus;
private
pragma Import (C, create, "sfTcpSocket_create");
pragma Import (C, destroy, "sfTcpSocket_destroy");
pragma Import (C, setBlocking, "sfTcpSocket_setBlocking");
pragma Import (C, isBlocking, "sfTcpSocket_isBlocking");
pragma Import (C, getLocalPort, "sfTcpSocket_getLocalPort");
pragma Import (C, getRemoteAddress, "sfTcpSocket_getRemoteAddress");
pragma Import (C, getRemotePort, "sfTcpSocket_getRemotePort");
pragma Import (C, connect, "sfTcpSocket_connect");
pragma Import (C, disconnect, "sfTcpSocket_disconnect");
pragma Import (C, send, "sfTcpSocket_send");
pragma Import (C, sendPartial, "sfTcpSocket_sendPartial");
pragma Import (C, receive, "sfTcpSocket_receive");
pragma Import (C, sendPacket, "sfTcpSocket_sendPacket");
pragma Import (C, receivePacket, "sfTcpSocket_receivePacket");
end Sf.Network.TcpSocket;
|
with Interfaces.C;
with System;
package body Generic_Callback is
function paMinLatCallback
(inputBuffer : System.Address;
outputBuffer : System.Address;
framesPerBuffer : IC.unsigned_long;
timeInfo : access PaStreamCallbackTimeInfo;
statusFlags : PaStreamCallbackFlags;
userData : System.Address)
return PaStreamCallbackResult
with Export => True, Convention => C;
---------------------
-- PAA_Open_Stream --
---------------------
function PAA_Open_Stream
(stream : access PaStream_Ptr;
inputParameters : access PaStreamParameters;
outputParameters : access PaStreamParameters;
sampleRate : Long_Float;
framesPerBuffer : Long_Integer;
streamFlags : PaStreamFlags;
pre : Pre_Callback;
post : Post_Callback;
userData : User_Data)
return PaError
is
begin
end PAA_Open_Stream;
----------------------
-- paMinLatCallback --
----------------------
function paMinLatCallback
(inputBuffer : System.Address;
outputBuffer : System.Address;
framesPerBuffer : Interfaces.C.unsigned_long;
timeInfo : access PaStreamCallbackTimeInfo;
statusFlags : PaStreamCallbackFlags;
userData : System.Address)
return PaStreamCallbackResult
is
begin
for i in 1 .. Integer (framesPerBuffer) loop
null;
end loop;
return paContinue;
end paMinLatCallback;
end Generic_Callback;
|
with Ada.Containers.Vectors;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;
procedure Day_03 is
type Point is record
X, Y: Integer;
end record;
package Wire_Vec is new Ada.Containers.Vectors(
Index_Type => Natural, Element_Type => Point);
procedure Append_Comma_Separated_Wire_Points(W: in out Wire_Vec.Vector) is
Curr: constant Point := W.Last_Element;
Dir: Character;
Distance: Natural;
begin
Ada.Text_IO.Get(Dir);
Ada.Integer_Text_IO.Get(Distance);
case Dir is
when 'U' =>
for I in 1 .. Distance loop
W.Append(Point'(X => Curr.X, Y => Curr.Y + I));
end loop;
when 'D' =>
for I in 1 .. Distance loop
W.Append(Point'(X => Curr.X, Y => Curr.Y - I));
end loop;
when 'R' =>
for I in 1 .. Distance loop
W.Append(Point'(X => Curr.X + I, Y => Curr.Y));
end loop;
when 'L' =>
for I in 1 .. Distance loop
W.Append(Point'(X => Curr.X - I, Y => Curr.Y));
end loop;
when others =>
raise Ada.IO_Exceptions.Data_Error with Character'Image(Dir);
end case;
end Append_Comma_Separated_Wire_Points;
function Read_Wire return Wire_Vec.Vector is
W: Wire_Vec.Vector;
Comma: Character;
begin
W.Append(Point'(0, 0));
loop
Append_Comma_Separated_Wire_Points(W);
exit when Ada.Text_IO.End_Of_Line;
Ada.Text_IO.Get(Comma);
end loop;
return W;
end Read_Wire;
-- only used in part 1
-- function Manhattan(P: Point) return Natural is (abs(P.X) + abs(P.Y));
Wire_1: constant Wire_Vec.Vector := Read_Wire;
Wire_2: constant Wire_Vec.Vector := Read_Wire;
Min_Dist: Natural := Natural'Last;
begin
for I in Wire_1.First_Index .. Wire_1.Last_Index loop
declare
P: constant Point := Wire_1(I);
J: constant Wire_Vec.Extended_Index := Wire_2.Find_Index(P);
Dist: constant Natural := I + J;
begin
if J /= Wire_Vec.No_Index and Dist > 0 then
Min_Dist := Natural'Min(Min_Dist, Dist);
end if;
end;
end loop;
Ada.Integer_Text_IO.Put(Min_Dist);
end Day_03;
|
with Ada.Text_IO; use Ada.Text_IO;
with Interfaces.C;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Ada.Directories; use Ada.Directories;
with System;
with Ada.Calendar;
procedure Main is
type LPCSTR is access constant Interfaces.C.char; -- winnt.h
pragma Convention (C, LPCSTR);
function LoadLibrary (lpLibFileName : LPCSTR) return System.Address;
pragma Import (Stdcall, LoadLibrary, "LoadLibraryA");
-- winbase.h :3619
type PROC is access function return Interfaces.C.int; -- windef.h :175
pragma Convention (Stdcall, PROC);
subtype FARPROC is PROC; -- windef.h :173
function GetProcAddress (hModule : System.Address; lpProcName : LPCSTR) return FARPROC; -- winbase.h :997
pragma Import (Stdcall, GetProcAddress, "GetProcAddress"); -- winbase.h :997
function As_LPCSTR is new Ada.Unchecked_Conversion (Source => System.Address, Target => LPCSTR);
S : Search_Type;
D : Directory_Entry_Type;
Only_Files : constant Filter_Type := (Ordinary_File => True, others => False);
Dll_Name : constant String := "libtest.dll";
C_Name : aliased constant String := Dll_Name & ASCII.nul;
Proc_Name : aliased constant String := "do_stuff" & ASCII.nul;
Waiting : Boolean := True;
begin
while Waiting loop
Start_Search(S, ".", Dll_Name, Only_Files);
if More_Entries(S) then
Get_Next_Entry(S, D);
declare
use Ada.Calendar;
use type System.Address;
Lib_Handle : System.Address := System.Null_Address;
Do_Stuff_Handle : FARPROC;
Ignored : Interfaces.C.int;
begin
-- Plug-in file is older than 5 seconds, we do not want to try
-- loading a plug-in not yet fully compiled.
if Modification_Time (D) < Clock - 5.0 then
Waiting := False;
Lib_Handle := LoadLibrary(As_LPCSTR(C_Name'Address));
if Lib_Handle /= System.Null_Address then
Do_Stuff_Handle := GetProcAddress(Lib_Handle, As_LPCSTR(Proc_Name'Address));
Ignored := Do_Stuff_Handle.all;
end if;
end if;
end;
end if;
end loop;
end Main;
|
-- { dg-do compile }
-- { dg-options "-O2 -gnatp -fdump-tree-optimized" }
pragma Optimize_Alignment (Space);
package body Pack9 is
procedure Copy (X, Y : R2_Ptr) is
T : R2 := Y.all;
begin
if T.I2 /= Y.I2 then
raise Program_Error;
end if;
X.all := T;
end;
end Pack9;
-- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } }
|
package DDS.Request_Reply.Replier is
type Ref is limited interface and DDS.Request_Reply.Ref;
type Ref_Access is access all Ref'class;
procedure Wait_For_Requests
(Self : not null access Ref;
Min_Count : DDS.Integer;
Max_Wait : DDS.Duration_T) is abstract;
end DDS.Request_Reply.Replier;
|
generic
Height : Positive;
Width : Positive;
package Mazes is
type Maze_Grid is private;
procedure Initialize (Maze : in out Maze_Grid);
procedure Put (Item : Maze_Grid);
private
type Directions is (North, South, West, East);
type Cell_Walls is array (Directions) of Boolean;
type Cells is record
Walls : Cell_Walls := (others => True);
Visited : Boolean := False;
end record;
subtype Height_Type is Positive range 1 .. Height;
subtype Width_Type is Positive range 1 .. Width;
type Maze_Grid is array (Height_Type, Width_Type) of Cells;
end Mazes;
|
generic
type Integer_Type is range <>;
type Coordinates is (<>);
package Vectors_xD_I is
pragma Elaborate_Body;
type Vector_xD_I is array (Coordinates) of Integer_Type;
Zero_Vector_xD : constant Vector_xD_I := (others => Integer_Type'First);
function Image (V : Vector_xD_I) return String;
function Norm (V : Vector_xD_I) return Vector_xD_I;
function "*" (Scalar : Float; V : Vector_xD_I) return Vector_xD_I;
function "*" (V : Vector_xD_I; Scalar : Float) return Vector_xD_I;
function "/" (V : Vector_xD_I; Scalar : Float) return Vector_xD_I;
function "*" (V_Left, V_Right : Vector_xD_I) return Float;
function Angle_Between (V_Left, V_Right : Vector_xD_I) return Float;
function "+" (V_Left, V_Right : Vector_xD_I) return Vector_xD_I;
function "-" (V_Left, V_Right : Vector_xD_I) return Vector_xD_I;
function "abs" (V : Vector_xD_I) return Float;
end Vectors_xD_I;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams;
procedure Using_Text_Streams is
Input, Output : File_Type;
Buffer : Character;
begin
Open (File => Input, Mode => In_File, Name => "input.txt");
Create (File => Output, Mode => Out_File, Name => "output.txt");
loop
Buffer := Character'Input (Stream (Input));
Character'Write (Stream (Output), Buffer);
end loop;
Close (Input);
Close (Output);
exception
when End_Error =>
if Is_Open(Input) then
Close (Input);
end if;
if Is_Open(Output) then
Close (Output);
end if;
end Using_Text_Streams;
|
with Asis;
with Asis.Errors;
with Asis.Exceptions;
with Asis.Implementation;
with Asis.Ada_Environments;
with Asis.Compilation_Units;
with Ada.Exceptions;
with Ada.Wide_Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure Asis_Hello_World is
My_Context : Asis.Context;
My_Context_Name : constant Wide_String :=
Asis.Ada_Environments.Default_Name;
My_Context_Parameters : constant Wide_String :=
To_Wide_String (Argument (1));
Initialization_Parameters : constant Wide_String := "";
Finalization_Parameters : constant Wide_String := "";
begin
Asis.Implementation.Initialize (Initialization_Parameters);
Asis.Ada_Environments.Associate
(The_Context => My_Context,
Name => My_Context_Name,
Parameters => My_Context_Parameters);
Asis.Ada_Environments.Open (My_Context);
declare
use Asis.Compilation_Units;
Units : Asis.Compilation_Unit_List := Compilation_Units (My_Context);
begin
for J in Units'Range loop
Ada.Wide_Text_IO.Put_Line
(Text_Name (Units (J)) & " => " & Unit_Full_Name (Units (J)));
end loop;
end;
Asis.Ada_Environments.Close (My_Context);
Asis.Ada_Environments.Dissociate (My_Context);
Asis.Implementation.Finalize (Finalization_Parameters);
Set_Exit_Status (Success);
exception
when E : Asis.Exceptions.ASIS_Inappropriate_Context |
Asis.Exceptions.ASIS_Inappropriate_Container |
Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit |
Asis.Exceptions.ASIS_Inappropriate_Element |
Asis.Exceptions.ASIS_Inappropriate_Line |
Asis.Exceptions.ASIS_Inappropriate_Line_Number |
Asis.Exceptions.ASIS_Failed =>
Ada.Wide_Text_IO.Put_Line
("ASIS exception (" &
To_Wide_String (Ada.Exceptions.Exception_Name (E)) &
") is raised");
Ada.Wide_Text_IO.Put_Line
("ASIS Error Status is " &
Asis.Errors.Error_Kinds'Wide_Image (Asis.Implementation.Status));
Ada.Wide_Text_IO.Put_Line ("ASIS Diagnosis is ");
Ada.Wide_Text_IO.Put_Line (Asis.Implementation.Diagnosis);
Asis.Implementation.Set_Status;
end Asis_Hello_World;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions;
package word_operations_hpp is
-- * File : word_operations.hpp
-- *
-- * File created by : Corentin Gay
-- * File was created at : 06/12/2017
--
subtype uint16_t is unsigned_short; -- ./word_operations.hpp:10
subtype int16_t is short; -- ./word_operations.hpp:11
subtype uint8_t is unsigned_char; -- ./word_operations.hpp:12
subtype int8_t is signed_char; -- ./word_operations.hpp:13
subtype size_t is Extensions.unsigned_long_long; -- ./word_operations.hpp:14
subtype uint is unsigned; -- ./word_operations.hpp:15
function make_word (low : uint8_t; high : uint8_t) return uint16_t; -- ./word_operations.hpp:17
pragma Import (CPP, make_word, "_Z9make_wordhh");
function get_high (word : uint16_t) return uint8_t; -- ./word_operations.hpp:18
pragma Import (CPP, get_high, "_Z8get_hight");
function get_low (word : uint16_t) return uint8_t; -- ./word_operations.hpp:19
pragma Import (CPP, get_low, "_Z7get_lowt");
end word_operations_hpp;
|
with Ada.Streams; use Ada.Streams;
package abstract1 is
type T is abstract tagged limited null record;
function Input (Stream : not null access Root_Stream_Type'Class) return T
is abstract;
function New_T (Stream : not null access Root_Stream_Type'Class)
return T'Class;
type IT is limited new T with record
I : Integer;
end record;
function Input (Stream : not null access Root_Stream_Type'Class) return IT;
type FT is limited new T with record
F : Float;
end record;
function Input (Stream : not null access Root_Stream_Type'Class) return FT;
end abstract1;
|
-- Databases - A simple database library for Ada applications
-- (c) Kristian Klomsten Skordal 2019 <kristian.skordal@wafflemail.net>
-- Report bugs and issues on <https://github.com/skordal/databases/issues>
-- vim:ts=3:sw=3:et:si:sta
package body Databases.Utilities is
function Execute (Database : in Databases.Database_Access; Statement : in String)
return Databases.Statement_Execution_Status
is
Prepared : Databases.Prepared_Statement_Access := Database.Prepare (Statement);
Retval : constant Databases.Statement_Execution_Status := Prepared.Execute;
begin
Databases.Free (Prepared);
return Retval;
end Execute;
end Databases.Utilities;
|
package Noreturn5 is
procedure Proc (Arg_Line : Wide_String; Keep_Going : Boolean);
pragma No_Return (Proc);
end Noreturn5;
|
-- This spec has been automatically generated from FE310.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package FE310_SVD.SPI is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype SCKDIV_SCALE_Field is HAL.UInt12;
-- Serial Clock Divisor Register.
type SCKDIV_Register is record
SCALE : SCKDIV_SCALE_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SCKDIV_Register use record
SCALE at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- Serial Clock Phase
type SCKMODE_CPHA is
(
-- Data is sampled on the leading edge of SCK and shifted on the
-- trailing edge of SCK.
Val_0,
-- Data is shifted on the leading edge of SCK and sampled on the
-- trailing edge of SCK.
Val_1)
with Size => 1;
for SCKMODE_CPHA use
(Val_0 => 0,
Val_1 => 1);
-- Serial Clock Polarity
type SCKMODE_CPOL is
(
-- Inactive state of SCK is logical 0.
Val_0,
-- Inactive state of SCK is logical 1.
Val_1)
with Size => 1;
for SCKMODE_CPOL use
(Val_0 => 0,
Val_1 => 1);
-- Serial Clock Mode Register.
type SCKMODE_Register is record
-- Serial Clock Phase
PHA : SCKMODE_CPHA := FE310_SVD.SPI.Val_0;
-- Serial Clock Polarity
POL : SCKMODE_CPOL := FE310_SVD.SPI.Val_0;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SCKMODE_Register use record
PHA at 0 range 0 .. 0;
POL at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
type CSMODE_Chip_Select_Modes is
(
-- Assert/de-assert CS at the beginning/end of each frame.
Auto,
-- Keep CS continuously asserted after the initial frame.
Hold,
-- Disable hardware control of the CS pin.
Off)
with Size => 2;
for CSMODE_Chip_Select_Modes use
(Auto => 0,
Hold => 2,
Off => 3);
-- Chip Select Mode Register.
type CSMODE_Register is record
MODE : CSMODE_Chip_Select_Modes := FE310_SVD.SPI.Auto;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSMODE_Register use record
MODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype DELAY0_CSSCK_Field is HAL.UInt8;
subtype DELAY0_SCKCS_Field is HAL.UInt8;
-- Delay Control Register 0.
type DELAY0_Register is record
CSSCK : DELAY0_CSSCK_Field := 16#0#;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
SCKCS : DELAY0_SCKCS_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DELAY0_Register use record
CSSCK at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
SCKCS at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype DELAY1_INTERCS_Field is HAL.UInt8;
subtype DELAY1_INTERXFR_Field is HAL.UInt8;
-- Delay Control Register 1.
type DELAY1_Register is record
INTERCS : DELAY1_INTERCS_Field := 16#0#;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
INTERXFR : DELAY1_INTERXFR_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DELAY1_Register use record
INTERCS at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
INTERXFR at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
type FMT_SPI_Protocol is
(
-- Data Pins: DQ0 (MOSI), DQ1 (MISO).
Single,
-- Data Pins: DQ0, DQ1.
Dual,
-- Data Pins: DQ0, DQ1, DQ2, DQ3.
Quad)
with Size => 2;
for FMT_SPI_Protocol use
(Single => 0,
Dual => 1,
Quad => 2);
type FMT_SPI_Endianness is
(
-- Tansmit most-significant bit first.
Msb_First,
-- Transmit least-significant bit first.
Lsb_First)
with Size => 1;
for FMT_SPI_Endianness use
(Msb_First => 0,
Lsb_First => 1);
type FMT_SPI_IO_Direction is
(
-- For dual and quad protocols, the DQ pins are tri-stated. For the
-- single protocol, the DQ0 pin is driven with the transmit data as
-- normal.
Rx,
-- The receive FIFO is not populated.
Tx)
with Size => 1;
for FMT_SPI_IO_Direction use
(Rx => 0,
Tx => 1);
subtype FMT_LEN_Field is HAL.UInt4;
-- Frame Format Register.
type FMT_Register is record
PROTO : FMT_SPI_Protocol := FE310_SVD.SPI.Single;
ENDIAN : FMT_SPI_Endianness := FE310_SVD.SPI.Msb_First;
DIR : FMT_SPI_IO_Direction := FE310_SVD.SPI.Rx;
-- unspecified
Reserved_4_15 : HAL.UInt12 := 16#0#;
LEN : FMT_LEN_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 FMT_Register use record
PROTO at 0 range 0 .. 1;
ENDIAN at 0 range 2 .. 2;
DIR at 0 range 3 .. 3;
Reserved_4_15 at 0 range 4 .. 15;
LEN at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype TXDATA_DATA_Field is HAL.UInt8;
-- Transmit Data Register.
type TXDATA_Register is record
DATA : TXDATA_DATA_Field := 16#0#;
-- unspecified
Reserved_8_30 : HAL.UInt23 := 16#0#;
FULL : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TXDATA_Register use record
DATA at 0 range 0 .. 7;
Reserved_8_30 at 0 range 8 .. 30;
FULL at 0 range 31 .. 31;
end record;
subtype RXDATA_DATA_Field is HAL.UInt8;
-- Receive Data Register.
type RXDATA_Register is record
DATA : RXDATA_DATA_Field := 16#0#;
-- unspecified
Reserved_8_30 : HAL.UInt23 := 16#0#;
EMPTY : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RXDATA_Register use record
DATA at 0 range 0 .. 7;
Reserved_8_30 at 0 range 8 .. 30;
EMPTY at 0 range 31 .. 31;
end record;
subtype TXMARK_TXMARK_Field is HAL.UInt3;
-- Transmit Watermark Register.
type TXMARK_Register is record
TXMARK : TXMARK_TXMARK_Field := 16#0#;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TXMARK_Register use record
TXMARK at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype RXMARK_RXMARK_Field is HAL.UInt3;
-- Receive Watermark Register.
type RXMARK_Register is record
RXMARK : RXMARK_RXMARK_Field := 16#0#;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RXMARK_Register use record
RXMARK at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- SPI Flash Interface Control Register.
type FCTRL_Register is record
ENABLE : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FCTRL_Register use record
ENABLE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
subtype FFMT_ADDR_LEN_Field is HAL.UInt3;
subtype FFMT_PAD_CNT_Field is HAL.UInt4;
subtype FFMT_CMD_PROTO_Field is HAL.UInt2;
subtype FFMT_ADDR_PROTO_Field is HAL.UInt2;
subtype FFMT_DATA_PROTO_Field is HAL.UInt2;
subtype FFMT_CMD_CODE_Field is HAL.UInt8;
subtype FFMT_PAD_CODE_Field is HAL.UInt8;
-- SPI Flash Instruction Format Register.
type FFMT_Register is record
CMD_EN : Boolean := False;
ADDR_LEN : FFMT_ADDR_LEN_Field := 16#0#;
PAD_CNT : FFMT_PAD_CNT_Field := 16#0#;
CMD_PROTO : FFMT_CMD_PROTO_Field := 16#0#;
ADDR_PROTO : FFMT_ADDR_PROTO_Field := 16#0#;
DATA_PROTO : FFMT_DATA_PROTO_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
CMD_CODE : FFMT_CMD_CODE_Field := 16#0#;
PAD_CODE : FFMT_PAD_CODE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FFMT_Register use record
CMD_EN at 0 range 0 .. 0;
ADDR_LEN at 0 range 1 .. 3;
PAD_CNT at 0 range 4 .. 7;
CMD_PROTO at 0 range 8 .. 9;
ADDR_PROTO at 0 range 10 .. 11;
DATA_PROTO at 0 range 12 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
CMD_CODE at 0 range 16 .. 23;
PAD_CODE at 0 range 24 .. 31;
end record;
-- SPI Interrupt Enable Register.
type IE_Register is record
TXWM : Boolean := False;
RXWM : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IE_Register use record
TXWM at 0 range 0 .. 0;
RXWM at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- SPI Interrupt Pending Register.
type IP_Register is record
TXWM : Boolean := False;
RXWM : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IP_Register use record
TXWM at 0 range 0 .. 0;
RXWM at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Serial Peripheral Interface.
type SPI_Peripheral is record
-- Serial Clock Divisor Register.
SCKDIV : aliased SCKDIV_Register;
-- Serial Clock Mode Register.
SCKMODE : aliased SCKMODE_Register;
-- Chip Select ID Register.
CSID : aliased HAL.UInt32;
-- Chip Select Default Register.
CSDEF : aliased HAL.UInt32;
-- Chip Select Mode Register.
CSMODE : aliased CSMODE_Register;
-- Delay Control Register 0.
DELAY0 : aliased DELAY0_Register;
-- Delay Control Register 1.
DELAY1 : aliased DELAY1_Register;
-- Frame Format Register.
FMT : aliased FMT_Register;
-- Transmit Data Register.
TXDATA : aliased TXDATA_Register;
-- Receive Data Register.
RXDATA : aliased RXDATA_Register;
-- Transmit Watermark Register.
TXMARK : aliased TXMARK_Register;
-- Receive Watermark Register.
RXMARK : aliased RXMARK_Register;
-- SPI Flash Interface Control Register.
FCTRL : aliased FCTRL_Register;
-- SPI Flash Instruction Format Register.
FFMT : aliased FFMT_Register;
-- SPI Interrupt Enable Register.
IE : aliased IE_Register;
-- SPI Interrupt Pending Register.
IP : aliased IP_Register;
end record
with Volatile;
for SPI_Peripheral use record
SCKDIV at 16#0# range 0 .. 31;
SCKMODE at 16#4# range 0 .. 31;
CSID at 16#10# range 0 .. 31;
CSDEF at 16#14# range 0 .. 31;
CSMODE at 16#18# range 0 .. 31;
DELAY0 at 16#28# range 0 .. 31;
DELAY1 at 16#2C# range 0 .. 31;
FMT at 16#40# range 0 .. 31;
TXDATA at 16#48# range 0 .. 31;
RXDATA at 16#4C# range 0 .. 31;
TXMARK at 16#50# range 0 .. 31;
RXMARK at 16#54# range 0 .. 31;
FCTRL at 16#60# range 0 .. 31;
FFMT at 16#64# range 0 .. 31;
IE at 16#70# range 0 .. 31;
IP at 16#74# range 0 .. 31;
end record;
-- Serial Peripheral Interface.
QSPI0_Periph : aliased SPI_Peripheral
with Import, Address => System'To_Address (16#10014000#);
-- Serial Peripheral Interface.
QSPI1_Periph : aliased SPI_Peripheral
with Import, Address => System'To_Address (16#10024000#);
-- Serial Peripheral Interface.
QSPI2_Periph : aliased SPI_Peripheral
with Import, Address => System'To_Address (16#10034000#);
end FE310_SVD.SPI;
|
With
Ada.Unchecked_Conversion,
Ada.IO_Exceptions;
Package Body NSO.Types is
Use Ada.Streams;
-------------------
-- INITALIZERS --
-------------------
Function From_String( Text : String ) return String_Stream
with Inline, Pure_Function;
Function Buffer ( Length : Natural ) return String_Stream
with Inline, Pure_Function;
--------------
-- R E A D --
--------------
Procedure Read
(Stream : in out String_Stream;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
Use Ada.IO_Exceptions, Ada.Streams;
Begin
-- When there is a read of zero, do nothing.
-- When there is a read beyond the buffer's bounds, raise an exception.
-- Note: I've used two cases here-
-- 1) when the read is greater than the buffer,
-- 2) when the read would go beyond the buffer.
-- Finally, read the given amount of data and update the position.
if Item'Length = 0 then
null;
elsif Item'Length > Stream.Data'Length then
Raise End_Error with "Request is larger than the buffer's size.";
elsif Stream_Element_Offset'Pred(Stream.Position)+Item'Length > Stream.Data'Length then
Raise End_Error with "Buffer will over-read.";
else
Declare
Subtype Selection is Stream_Element_Offset range
Stream.Position..Stream.Position+Stream_Element_Offset'Pred(Item'Length);
Begin
Item(Item'Range):= Stream.Data(Selection);
Stream.Position:= Stream_Element_Offset'Succ(Selection'Last);
Last:= Selection'Last;--Stream.Position;
End;
end if;
End Read;
-----------------
-- W R I T E --
-----------------
Procedure Write
(Stream : in out String_Stream;
Item : Ada.Streams.Stream_Element_Array) is
Begin
Declare
Subtype Selection is Stream_Element_Offset range
Stream.Position..Stream.Position+Stream_Element_Offset'Pred(Item'Length);
Begin
Stream.Data(Selection):= Item(Item'Range);
Stream.Position:= Stream_Element_Offset'Succ(Selection'Last);
End;
End Write;
----------------------------------
-- INITALIZER IMPLEMENTATIONS --
----------------------------------
-- Create a buffer of the given length, zero-filled.
Function Buffer( Length : Natural ) return String_Stream is
Len : Constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Offset(Length);
Begin
Return Result : Constant String_Stream:=
(Root_Stream_Type with
Position => 1,
Data => (1..Len => 0),
Length => Len
);
End Buffer;
-- Create a buffer from the given string.
Function From_String( Text : String ) return String_Stream is
Use Ada.Streams;
Subtype Element_Range is Stream_Element_Offset range
Stream_Element_Offset(Text'First)..Stream_Element_Offset(Text'Last);
Subtype Constrained_Array is Stream_Element_Array(Element_Range);
Subtype Constrained_String is String(Text'Range);
Function Convert is new Ada.Unchecked_Conversion(
Source => Constrained_String,
Target => Constrained_Array
);
Begin
Return Result : Constant String_Stream:=
(Root_Stream_Type with
Position => Element_Range'First,
Data => Convert( Text ),
Length => Text'Length
);
End From_String;
-- Classwide returning renames, for consistancy/overload.
Function To_Stream( Text : String ) return Root_Stream_Class is
( From_String(Text) ) with Inline, Pure_Function;
Function To_Stream( Length : Natural ) return Root_Stream_Class is
( Buffer(Length) ) with Inline, Pure_Function;
----------------------------
-- CONVERSION OPERATORS --
----------------------------
-- Allocating / access-returning initalizing operations.
Function "+"( Length : Natural ) return not null access Root_Stream_Class is
( New Root_Stream_Class'(To_Stream(Length)) );
Function "+"( Text : String ) return not null access Root_Stream_Class is
( New Root_Stream_Class'(To_Stream(Text)) );
-- Conversion from text or integer to a stream; renaming of the initalizers.
Function "+"( Text : String ) return String_Stream renames From_String;
Function "+"( Length : Natural ) return String_Stream renames Buffer;
-- Convert a given Stream_Element_Array to a String.
Function "-"( Data : Ada.Streams.Stream_Element_Array ) Return String is
Subtype Element_Range is Natural range
Natural(Data'First)..Natural(Data'Last);
Subtype Constrained_Array is Stream_Element_Array(Data'Range);
Subtype Constrained_String is String(Element_Range);
Function Convert is new Ada.Unchecked_Conversion(
Source => Constrained_Array,
Target => Constrained_String
);
Begin
Return Convert( Data );
End "-";
----------------------
-- DATA RETRIEVAL --
----------------------
Function "-"( Stream : String_Stream ) return String is
Begin
Return -Stream.Data(Stream.Position..Stream.Length);
End "-";
Function Data(Stream : String_Stream ) return String is
Begin
Return -Stream.Data;
End Data;
End NSO.Types;
|
with Ada.Text_IO;
with Ada.Strings.Fixed;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A041 is
use Ada.Text_IO;
use Ada.Strings.Fixed;
use Ada.Integer_Text_IO;
-- File Reference: http://www.naturalnumbers.org/primes.html
Digit : constant String (1 .. 9) := "123456789";
FT : File_Type;
Last_Index : Natural;
Prime_Num : String (1 .. 10);
File_Name : constant String := "problems/003/PrimeNumbers_Upto_1000000";
Largest_Pandigital_Prime : Integer := 0;
Is_Pandigital : Boolean;
begin
Open (FT, In_File, File_Name);
while not End_Of_File (FT) loop
Get_Line (FT, Prime_Num, Last_Index);
if Integer'Value (Prime_Num (1 .. Last_Index)) > 7654321 then
exit;
end if;
Is_Pandigital := True;
for I in 1 .. Last_Index loop
if Index (Prime_Num (1 .. Last_Index), Digit (I .. I)) = 0 then
Is_Pandigital := False;
exit;
end if;
end loop;
if Is_Pandigital then
if Integer'Value (Prime_Num (1 .. Last_Index))
> Largest_Pandigital_Prime
then
Largest_Pandigital_Prime := Integer'Value (
Prime_Num (1 .. Last_Index));
end if;
end if;
end loop;
Close (FT);
Put (Largest_Pandigital_Prime, Width => 0);
end A041;
|
-- Abstract :
--
-- Utilities for generating source code from BNF source files
--
-- Copyright (C) 2012, 2013, 2015, 2017, 2018 Free Software Foundation, Inc.
--
-- The WisiToken package is free software; you can redistribute it
-- and/or modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or
-- (at your option) any later version. This library is distributed in
-- the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-- even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-- PARTICULAR PURPOSE.
--
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
package WisiToken.BNF.Utils is
function Strip_Quotes (Item : in String) return String;
-- Remove leading and trailing '"', if any.
function Strip_Parens (Item : in String) return String;
-- Remove leading and trailing '()', if any.
end WisiToken.BNF.Utils;
|
with Ada.Unchecked_Conversion;
with System;
package body Ada.References is
pragma Suppress (All_Checks);
package body Generic_Slicing is
function Constant_Slice (
Item : aliased Array_Type;
First : Index_Type;
Last : Index_Type'Base)
return Constant_Reference_Type is
begin
return Result : Constant_Reference_Type := (
Element => Item'Access, -- dummy, be overwritten
First => First,
Last => Last)
do
declare
type Repr is record
Data : System.Address;
Constraints : System.Address;
end record;
pragma Suppress_Initialization (Repr);
R : Repr;
for R'Address use Result.Element'Address;
begin
R.Data := Item (First)'Address;
R.Constraints := Result.First'Address;
end;
end return;
end Constant_Slice;
function Slice (
Item : aliased in out Array_Type;
First : Index_Type;
Last : Index_Type'Base)
return Reference_Type
is
type Constant_Slice_Type is access function (
Item : aliased Array_Type;
First : Index_Type;
Last : Index_Type'Base)
return Constant_Reference_Type;
type Variable_Slice_Type is access function (
Item : aliased in out Array_Type;
First : Index_Type;
Last : Index_Type'Base)
return Reference_Type;
function Cast is
new Unchecked_Conversion (
Constant_Slice_Type,
Variable_Slice_Type);
begin
return Cast (Constant_Slice'Access) (Item, First, Last);
end Slice;
end Generic_Slicing;
end Ada.References;
|
with Ada.Real_Time; use Ada.Real_Time;
with HIL.GPIO; use HIL.GPIO;
with HIL.Clock; use HIL.Clock;
with Crash;
pragma Unreferenced (Crash);
with Calc;
procedure main with SPARK_Mode is
f1, f2, res : Float;
next : Time := Clock;
PERIOD : constant Time_Span := Milliseconds(500);
led_on : Boolean := False;
begin
HIL.Clock.configure;
HIL.GPIO.configure;
-- For the following tests, we have set system.Denorm (in RTS) to True
-- Test1: Subnormal OUT FROM FPU: OKAY
-- f1 := 0.00429291604;
-- f2 := -2.02303554e-38;
-- 0.00429291604*-2.02303554e-38 = -8.68468736e-41
-- Test2: Subnormal INTO FPU: WORKS.
f1 := 0.00429291604;
f2 := -8.68468736e-41; -- subnormal INTO FPU
-- 0.00429291604*-8.68468736e-41 = -3.72745392e-43.
res := Calc.calc (f1, f2); -- function call to force use of FPU
loop
if led_on then
write (RED_LED, HIGH);
else
write (RED_LED, LOW);
end if;
led_on := not led_on;
next := next + PERIOD;
delay until next;
end loop;
res := 0.0;
end main;
|
with Ada.Containers.Ordered_Sets, Ada.Text_IO;
use Ada.Text_IO;
procedure Duplicate is
package Int_Sets is new Ada.Containers.Ordered_Sets (Integer);
Nums : constant array (Natural range <>) of Integer := (1,2,3,4,5,5,6,7,1);
Unique : Int_Sets.Set;
begin
for n of Nums loop
Unique.Include (n);
end loop;
for e of Unique loop
Put (e'img);
end loop;
end Duplicate;
|
-- CA1108A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A WITH_CLAUSE AND USE_CLAUSE GIVEN FOR A PACKAGE
-- SPECIFICATION APPLIES TO THE BODY AND SUBUNITS OF THE BODY.
-- BHS 7/27/84
-- JBG 5/1/85
PACKAGE OTHER_PKG IS
I : INTEGER := 4;
FUNCTION F (X : INTEGER) RETURN INTEGER;
END OTHER_PKG;
PACKAGE BODY OTHER_PKG IS
FUNCTION F (X : INTEGER) RETURN INTEGER IS
BEGIN
RETURN X + 1;
END F;
END OTHER_PKG;
WITH REPORT, OTHER_PKG;
USE REPORT, OTHER_PKG;
PRAGMA ELABORATE (OTHER_PKG);
PACKAGE CA1108A_PKG IS
J : INTEGER := 2;
PROCEDURE PROC;
PROCEDURE CALL_SUBS (X, Y : IN OUT INTEGER);
END CA1108A_PKG;
PACKAGE BODY CA1108A_PKG IS
PROCEDURE SUB (X, Y : IN OUT INTEGER) IS SEPARATE;
PROCEDURE PROC IS
Y : INTEGER := 2;
BEGIN
Y := OTHER_PKG.I;
IF Y /= 4 THEN
FAILED ("OTHER_PKG VARIABLE NOT VISIBLE " &
"IN PACKAGE BODY PROCEDURE");
END IF;
END PROC;
PROCEDURE CALL_SUBS (X, Y : IN OUT INTEGER) IS
BEGIN
SUB (X, Y);
END CALL_SUBS;
BEGIN
J := F(J); -- J => J + 1.
IF J /= 3 THEN
FAILED ("OTHER_PKG FUNCTION NOT VISIBLE IN " &
"PACKAGE BODY");
END IF;
END CA1108A_PKG;
WITH REPORT, CA1108A_PKG;
USE REPORT, CA1108A_PKG;
PROCEDURE CA1108A IS
VAR1, VAR2 : INTEGER;
BEGIN
TEST ("CA1108A", "WITH_ AND USE_CLAUSES GIVEN FOR A PACKAGE " &
"SPEC APPLY TO THE BODY AND ITS SUBUNITS");
PROC;
VAR1 := 1;
VAR2 := 1;
CALL_SUBS (VAR1, VAR2);
IF VAR1 /= 4 THEN
FAILED ("OTHER_PKG VARIABLE NOT VISIBLE IN SUBUNIT");
END IF;
IF VAR2 /= 6 THEN
FAILED ("OTHER_PKG FUNCTION NOT VISIBLE IN SUBUNIT " &
"OF SUBUNIT");
END IF;
RESULT;
END CA1108A;
SEPARATE (CA1108A_PKG)
PROCEDURE SUB (X, Y : IN OUT INTEGER) IS
PROCEDURE SUB2 (Z : IN OUT INTEGER) IS SEPARATE;
BEGIN
X := I;
SUB2 (Y);
END SUB;
SEPARATE (CA1108A_PKG.SUB)
PROCEDURE SUB2 (Z : IN OUT INTEGER) IS
I : INTEGER := 5;
BEGIN
Z := OTHER_PKG.F(I); -- Z => I + 1.
END SUB2;
|
--Helen: added this file to implement RPC
with Ada.Streams;
package System.RPC is
type Partition_ID is range 0 .. 100;
Communication_Error : exception;
type Params_Stream_Type (
Initial_Size : Ada.Streams.Stream_Element_Count) is new
Ada.Streams.Root_Stream_Type with private;
procedure Read (
Stream : in out Params_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write (
Stream : in out Params_Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
-- Synchronous call
procedure Do_RPC (
Partition : in Partition_ID;
Params : access Params_Stream_Type;
Result : access Params_Stream_Type);
-- Asynchronous call
procedure Do_APC(
Partition : in Partition_ID;
Params : access Params_Stream_Type);
-- The handler for incoming RPSc
type RPC_Receiver is access procedure (
Params : access Params_Stream_Type;
Result : access Params_Stream_Type);
procedure Establish_RPC_Receiver (
Partition : in Partition_ID;
Receiver : in RPC_Receiver);
end System.RPC;
|
with Ada.Text_IO; use Ada.Text_IO;
with I_Am_Ada;
with I_Am_Ada_Too;
procedure Main is
procedure Cpp_Fun;
pragma Import(C, Cpp_Fun, "i_am_adaInterface");
procedure C_Fun;
pragma Import(C, C_Fun, "i_am_c");
begin
Put_Line("Calling external C++ code from Ada main.");
Cpp_Fun;
Put_Line("Calling external C code from Ada main.");
C_Fun;
Put_Line("Calling Ada code from Ada main.");
I_Am_Ada.Ada_Procedure;
I_Am_Ada_Too.Ada_Procedure_Too;
Put_Line("Exiting Ada main.");
end Main;
|
with Ada.Assertions; use Ada.Assertions;
with Ada.Strings; use Ada.Strings;
-- Debug includes:
-- with Ada.Strings.Fixed; use Ada.Strings.Fixed;
-- with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Rejuvenation.File_Utils; use Rejuvenation.File_Utils;
with Rejuvenation.Navigation; use Rejuvenation.Navigation;
package body Rejuvenation.Text_Rewrites is
-- Public: Collect rewrite operation (node) --------
function Prepend
(TR : in out Text_Rewrite; Node : Ada_Node'Class; Text : String;
Before : Node_Location := No_Trivia; Charset : String := "")
return Boolean
is
First : constant Positive := Start_Offset (Node, Before);
WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Text, Charset);
begin
Assert
(Check => TR.Is_Initialized,
Message => "Text Rewrite used uninitialized");
Assert
(Check => Is_Reflexive_Ancestor (TR.Get_Unit.Root, Node),
Message =>
"Text Rewrite does not contain provided Node - " &
Langkit_Support.Text.Image (Node.Text));
Assert
(Check => TR.First <= First,
Message => "Text Rewrite - prepend before part");
return Replace (TR, First, First - 1, WText);
end Prepend;
function Append
(TR : in out Text_Rewrite; Node : Ada_Node'Class; Text : String;
After : Node_Location := No_Trivia; Charset : String := "")
return Boolean
is
Last : constant Positive := End_Offset (Node, After);
WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Text, Charset);
begin
Assert
(Check => TR.Is_Initialized,
Message => "Text Rewrite used uninitialized");
Assert
(Check => Is_Reflexive_Ancestor (TR.Get_Unit.Root, Node),
Message =>
"Text Rewrite Node does not contain provided Node - " &
Langkit_Support.Text.Image (Node.Text));
Assert
(Check => Last <= TR.Last,
Message => "Text Rewrite - append after part");
return Replace (TR, Last + 1, Last, WText);
end Append;
procedure Remove
(TR : in out Text_Rewrite; Node : Ada_Node'Class;
Before : Node_Location := No_Trivia; After : Node_Location := No_Trivia)
is
Dummy : Boolean;
begin
Dummy := TR.Remove (Node, Before, After);
end Remove;
procedure Prepend
(TR : in out Text_Rewrite; Node : Ada_Node'Class; Text : String;
Before : Node_Location := No_Trivia; Charset : String := "")
is
Dummy : Boolean;
begin
Dummy := TR.Prepend (Node, Text, Before, Charset);
end Prepend;
procedure Append
(TR : in out Text_Rewrite; Node : Ada_Node'Class; Text : String;
After : Node_Location := No_Trivia; Charset : String := "")
is
Dummy : Boolean;
begin
Dummy := TR.Append (Node, Text, After, Charset);
end Append;
procedure Replace
(TR : in out Text_Rewrite; Node : Ada_Node'Class; Text : String;
Before, After : Node_Location := No_Trivia; Charset : String := "")
is
Dummy : Boolean;
begin
Dummy := TR.Replace (Node, Text, Before, After, Charset);
end Replace;
procedure Restore (TR : in out Text_Rewrite; Node : Ada_Node'Class) is
Dummy : Boolean;
begin
Dummy := TR.Restore (Node);
end Restore;
procedure ReplaceAround
(TR : in out Text_Rewrite; Node : Ada_Node'Class; Before_Text : String;
Innernode : Ada_Node'Class; After_Text : String;
Before : Node_Location := No_Trivia; After : Node_Location := No_Trivia;
Charset : String := "")
is
NodeStartOffset : constant Positive := Start_Offset (Node, Before);
NodeEndOffset : constant Positive := End_Offset (Node, After);
InnernodeStartOffset : constant Positive :=
Start_Offset (Innernode, Before);
InnernodeEndOffset : constant Positive := End_Offset (Innernode, After);
Before_WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Before_Text, Charset);
After_WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (After_Text, Charset);
Dummy_Before, Dummy_After : Boolean;
begin
Assert
(Check => TR.Is_Initialized,
Message => "Text Rewrite used uninitialized");
Assert
(Check => Is_Reflexive_Ancestor (TR.Get_Unit.Root, Node),
Message =>
"Text Rewrite Node does not contain provided Node - " &
Langkit_Support.Text.Image (Node.Text));
Assert
(Check => TR.First <= NodeStartOffset,
Message => "Text Rewrite - start of node outside part");
Assert
(Check => NodeEndOffset <= TR.Last,
Message => "Text Rewrite - end of node outside part");
Assert
(Check => Is_Reflexive_Ancestor (Node, Innernode),
Message => "Innernode should be contained in node");
Log ("ReplaceAround - Before");
Dummy_Before :=
Replace (TR, NodeStartOffset, InnernodeStartOffset - 1, Before_WText);
Log ("ReplaceAround - After");
Dummy_After :=
Replace (TR, InnernodeEndOffset + 1, NodeEndOffset, After_WText);
Assert
(Check => Dummy_Before = Dummy_After,
Message =>
Langkit_Support.Text.Image (Node.Full_Sloc_Image) &
"How to handle only one of the two is accepted?" & ASCII.LF &
"Before = " & Boolean'Image (Dummy_Before) & ASCII.LF & "After = " &
Boolean'Image (Dummy_After));
end ReplaceAround;
-- Collect rewrite operation (nodes) ---------------
function Replace
(TR : in out Text_Rewrite; First_Node, Last_Node : Ada_Node'Class;
Text : String; Before : Node_Location := No_Trivia;
After : Node_Location := No_Trivia; Charset : String := "")
return Boolean
is
First : constant Positive := Start_Offset (First_Node, Before);
Last : constant Positive := End_Offset (Last_Node, After);
WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Text, Charset);
begin
Assert
(Check => TR.Is_Initialized,
Message => "Text Rewrite used uninitialized");
-- TODO: First and Last node might be the same node
-- How to check it efficiently?
-- Options [at least]
-- * Move Assert upwards (before duplication happens)
-- * add check "First_Node = Last_Node or else .."
Assert
(Check => Is_Reflexive_Ancestor (TR.Get_Unit.Root, First_Node),
Message =>
"Text Rewrite Node does not contain provided First Node - " &
Langkit_Support.Text.Image (First_Node.Text));
Assert
(Check => TR.First <= First,
Message => "Text Rewrite - start of first node outside part");
Assert
(Check => Is_Reflexive_Ancestor (TR.Get_Unit.Root, Last_Node),
Message =>
"Text Rewrite Node does not contain provided Last Node - " &
Langkit_Support.Text.Image (Last_Node.Text));
Assert
(Check => Last <= TR.Last,
Message => "Text Rewrite - end of last node outside part");
return Replace (TR, First, Last, WText);
end Replace;
procedure Remove
(TR : in out Text_Rewrite; First_Node, Last_Node : Ada_Node'Class;
Before : Node_Location := No_Trivia; After : Node_Location := No_Trivia)
is
Dummy : Boolean;
begin
Dummy := Remove (TR, First_Node, Last_Node, Before, After);
end Remove;
procedure Replace
(TR : in out Text_Rewrite; First_Node, Last_Node : Ada_Node'Class;
Text : String; Before : Node_Location := No_Trivia;
After : Node_Location := No_Trivia; Charset : String := "")
is
Dummy : Boolean;
begin
Dummy :=
Replace (TR, First_Node, Last_Node, Text, Before, After, Charset);
end Replace;
-- Public: Collect rewrite operation (token) --------
function Prepend
(TR : in out Text_Rewrite; Token : Token_Reference; Text : String;
Charset : String := "") return Boolean
is
First : constant Integer := Raw_Data (Token).Source_First;
WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Text, Charset);
begin
return Replace (TR, First, First - 1, WText);
end Prepend;
function Append
(TR : in out Text_Rewrite; Token : Token_Reference; Text : String;
Charset : String := "") return Boolean
is
Last : constant Integer := Raw_Data (Token).Source_Last;
WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Text, Charset);
begin
return Replace (TR, Last + 1, Last, WText);
end Append;
function Replace
(TR : in out Text_Rewrite; Token : Token_Reference; Text : String;
Charset : String := "") return Boolean
is
First : constant Integer := Raw_Data (Token).Source_First;
Last : constant Integer := Raw_Data (Token).Source_Last;
WText : constant Wide_Wide_String :=
Langkit_Support.Text.Decode (Text, Charset);
begin
return Replace (TR, First, Last, WText);
end Replace;
procedure Remove (TR : in out Text_Rewrite; Token : Token_Reference) is
Dummy : Boolean;
begin
Dummy := TR.Remove (Token);
end Remove;
procedure Prepend
(TR : in out Text_Rewrite; Token : Token_Reference; Text : String;
Charset : String := "")
is
Dummy : Boolean;
begin
Dummy := TR.Prepend (Token, Text, Charset);
end Prepend;
procedure Append
(TR : in out Text_Rewrite; Token : Token_Reference; Text : String;
Charset : String := "")
is
Dummy : Boolean;
begin
Dummy := TR.Append (Token, Text, Charset);
end Append;
procedure Replace
(TR : in out Text_Rewrite; Token : Token_Reference; Text : String;
Charset : String := "")
is
Dummy : Boolean;
begin
Dummy := TR.Replace (Token, Text, Charset);
end Replace;
-- Public: Inspect rewrite operations --------
function HasReplacements (TR : Text_Rewrite) return Boolean is
begin
return not TR.Entries.Is_Empty;
end HasReplacements;
-- Public: Apply rewrite operations --------
function ApplyToString (TR : Text_Rewrite) return String is
use Replacement_List;
Txt : constant Langkit_Support.Text.Text_Type :=
TR.Get_Unit.Text (TR.First .. TR.Last);
Str : Unbounded_Wide_Wide_String := To_Unbounded_Wide_Wide_String (Txt);
Str_First : constant Positive := 1;
-- lower bound of an Unbounded_Wide_Wide_String is 1
C : Cursor := TR.Entries.Last;
begin
Assert
(Check => TR.Is_Initialized,
Message => "Text Rewrite used uninitialized");
Log ("ApplyToString -" & TR.Entries.Length'Image & " Slices");
while Has_Element (C) loop
declare
RE : constant Replacement_Entry := Element (C);
From : constant Positive := RE.First - TR.First + Str_First;
To : constant Natural := RE.Last - TR.First + Str_First;
Replacement : constant Wide_Wide_String :=
To_Wide_Wide_String (RE.Text);
begin
Log
("Slice #" & To_Index (C)'Image & " [" & From'Image & ":" &
To'Image & " ]");
Replace_Slice (Str, From, To, Replacement);
end;
Previous (C);
end loop;
return
Langkit_Support.Text.Encode
(To_Wide_Wide_String (Str), TR.Get_Unit.Get_Charset);
exception
when others =>
Put_Line ("Error in ApplyToString - " & TR.Get_Unit.Get_Filename);
raise;
end ApplyToString;
function Make_Text_Rewrite_Nodes
(First_Node, Last_Node : Ada_Node'Class;
Before : Node_Location := No_Trivia; After : Node_Location := No_Trivia)
return Text_Rewrite
is
First : constant Positive := Start_Offset (First_Node, Before);
Last : constant Positive := End_Offset (Last_Node, After);
begin
Assert
(Check => First <= Last,
Message => "Make_Text_Rewrite_Nodes - not a sequence");
Assert
(Check => "=" (First_Node.Unit, Last_Node.Unit),
Message => "Make_Text_Rewrite_Nodes - not same unit");
return
(Entries => Replacement_List.Empty_Vector, Unit => First_Node.Unit,
First => First, Last => Last);
end Make_Text_Rewrite_Nodes;
function Make_Text_Rewrite_Unit
(Unit : Analysis_Unit) return Text_Rewrite_Unit
is
begin
return
(Entries => Replacement_List.Empty_Vector, Unit => Unit, First => 1,
Last => Length (To_Unbounded_Wide_Wide_String (Unit.Text)));
end Make_Text_Rewrite_Unit;
procedure Apply (TR : Text_Rewrite_Unit) is
begin
if TR.HasReplacements then
Write_String_To_File (TR.ApplyToString, TR.Get_Unit.Get_Filename);
end if;
end Apply;
procedure Apply_And_Reparse (TR : in out Text_Rewrite_Unit) is
begin
if TR.HasReplacements then
declare
Unit : constant Analysis_Unit := TR.Get_Unit;
begin
Write_String_To_File (TR.ApplyToString, Unit.Get_Filename);
Unit.Reparse;
TR := Make_Text_Rewrite_Unit (Unit);
end;
end if;
end Apply_And_Reparse;
-- Private: Collect rewrite operation --------
function Replace_Inner
(TR : in out Text_Rewrite; First, Last : Natural; Text : Wide_Wide_String)
return Boolean;
-- Return value indicates whether replacement is accepted.
function Replace_Inner
(TR : in out Text_Rewrite; First, Last : Natural; Text : Wide_Wide_String)
return Boolean
is
use Replacement_List;
New_Text : Unbounded_Wide_Wide_String :=
To_Unbounded_Wide_Wide_String (Text);
C : Cursor := TR.Entries.First;
begin
while Has_Element (C) loop
declare
RE : Replacement_Entry := Element (C);
begin
if First = RE.First then
if RE.First - RE.Last = 1 then
Log ("Merge insert/replacement with earlier insertion");
New_Text := RE.Text & New_Text;
-- Might cover multiple earlier inserted replacements
if TR.Entries.Last = C then
Delete (TR.Entries, C);
else
declare
Dummy : Cursor := C;
begin
Delete (TR.Entries, Dummy);
end;
end if;
elsif First - Last = 1 then
Log ("Merge insertion with earlier replacement");
RE.Text := New_Text & RE.Text;
Replace_Element (TR.Entries, C, RE);
return True;
elsif Last < RE.Last then
Log ("Replacements at the same offset; keep the earlier");
return False;
elsif RE.Last < Last then
Log ("Replacements at the same offset; keep the current");
-- Might cover multiple earlier inserted replacements
if TR.Entries.Last = C then
Delete (TR.Entries, C);
else
declare
Dummy : Cursor := C;
begin
Delete (TR.Entries, Dummy);
end;
end if;
else
if RE.Text = New_Text then
Log ("Identical replacements");
return True;
-- TODO: Why return False / True?
-- Both the current is accepted and the old is kept
-- (since both are identical)
else
Log
("Conflicting replacements of equal length; " &
"keep the current");
RE.Text := New_Text;
Replace_Element (TR.Entries, C, RE);
return True;
end if;
end if;
elsif First < RE.First then
if RE.Last = Last then
-- length != 0
if RE.First - RE.Last = 1 then
Log ("Merging of operation with insert operation");
RE.First := First;
RE.Text := New_Text & RE.Text;
Replace_Element (TR.Entries, C, RE);
return True;
else
Log
("Replacements at the same end-offset; " &
"keep the current");
RE.First := First;
RE.Text := New_Text;
Replace_Element (TR.Entries, C, RE);
return True;
end if;
elsif RE.Last < Last then
Log
("Earlier replacement is completely covered " &
"by the current");
-- Might cover multiple earlier inserted replacements
if TR.Entries.Last = C then
Delete (TR.Entries, C);
else
declare
Dummy : Cursor := C;
begin
Delete (TR.Entries, Dummy);
end;
end if;
elsif RE.First - 1 < Last then
Log ("Overlapping edit operations (1)");
return False;
else
Log ("Insert current operation before earlier operation");
exit;
end if;
else
-- RE.First < First
if Last = RE.Last then
-- entry.length != 0
if First - Last = 1 then
Log ("Merging of operation with insert operation");
RE.Text := RE.Text & New_Text;
Replace_Element (TR.Entries, C, RE);
return True;
else
Log
("Replacements at the same end-offset; " &
"keep the earlier");
return False;
end if;
elsif Last < RE.Last then
Log
("Current replacement is completely covered " &
"by the earlier");
return False;
elsif First - 1 < RE.Last then
Log ("Overlapping edit operations (2)");
return False;
else
Next (C);
end if;
end if;
end;
end loop;
-- To have "the largest replacement wins" independent of the order
-- we cannot check for trivial replacements
-- since by removing the replacement,
-- a later smaller replacement can unexpectedly win!
declare
RE : Replacement_Entry;
begin
RE.First := First;
RE.Last := Last;
RE.Text := New_Text;
Log ("Add replacement");
Insert (TR.Entries, C, RE);
end;
return True;
end Replace_Inner;
--
-- Debug functionality to check replace
--
-- Max_Length_Text : constant Integer := 30;
--
-- function Image (TR : Text_Rewrite) return String
-- is
-- Return_Value : Unbounded_String;
-- begin
-- for E of TR.Entries loop
-- Return_Value := Return_Value & E.First'Image & "-"
-- & E.Last'Image & ":"
-- & Head (Image (To_Text (E.Text)), Max_Length_Text)
-- & ASCII.CR & ASCII.LF;
-- end loop;
--
-- return To_String (Return_Value);
-- end Image;
--
-- function Is_Internally_Consistent (TR : Text_Rewrite) return Boolean
-- is
-- Last : Integer := -1;
-- begin
-- for E of TR.Entries loop
-- if Last > E.First then
-- return False;
-- else
-- Last := E.Last;
-- end if;
-- end loop;
-- return True;
-- end Is_Internally_Consistent;
--
-- function Replace (TR : in out Text_Rewrite;
-- First, Last : Natural;
-- Text : Wide_Wide_String)
-- return Boolean
-- is
-- Return_Value : Boolean;
-- begin
-- Log ("Replace " & First'Image & "-" & Last'Image & ":" &
-- Head (Image (To_Text (To_Unbounded_Wide_Wide_String (Text))),
-- Max_Length_Text));
-- Return_Value := Replace_Inner (TR, First, Last, Text);
-- Assert (Check => Is_Internally_Consistent (TR),
-- Message => "Text Rewrite no longer internally consistent" &
-- ASCII.CR & ASCII.LF & Image (TR));
-- return Return_Value;
-- end Replace;
function Replace
(TR : in out Text_Rewrite; First, Last : Natural; Text : Wide_Wide_String)
return Boolean is
(Replace_Inner (TR, First, Last, Text));
-- Proxy to allow easy switching to debug variant
-- Private: Debugging utilities --------
procedure Log (Str : String) is
begin
if DEBUG then
Put_Line (Str);
end if;
end Log;
end Rejuvenation.Text_Rewrites;
|
package constants is
MAX_ARGUMENT_VALUE : constant := 500.0;
MAX_EMPLOYEES : constant := 2;
MAX_CHAIRMEN : constant := 1;
MAX_CLIENTS : constant := 1;
MAX_TASKLIST_SIZE : constant := 40;
MAX_STORAGE_CAPACITY : constant := 40;
EMPLOYEE_SLEEP : constant := 1;
CHAIRMAN_SLEEP : constant := 0.4;
CLIENT_SLEEP : constant := 2;
NUMBER_OF_MACHINES : constant := 2;
MACHINE_SLEEP : constant := 0.8;
IMPATIENT_WAIT : constant := 1.0;
IMPATIENT_PROBABILITY: constant := 0.5;
end constants;
|
-- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with System;
with Ada.Containers.Synchronized_Queue_Interfaces;
generic
with package Queue_Interfaces is new Ada.Containers.Synchronized_Queue_Interfaces (<>);
type Queue_Priority is private;
with function Get_Priority
(Element : Queue_Interfaces.Element_Type) return Queue_Priority is <>;
with function Before
(Left, Right : Queue_Priority) return Boolean is <>;
Default_Ceiling : System.Any_Priority := System.Priority'Last;
package Ada.Containers.Unbounded_Priority_Queues is
pragma Preelaborate(Unbounded_Priority_Queues);
package Implementation is
-- not specified by the language
end Implementation;
protected type Queue
(Ceiling : System.Any_Priority := Default_Ceiling)
with Priority => Ceiling is
new Queue_Interfaces.Queue with
overriding
entry Enqueue (New_Item : in Queue_Interfaces.Element_Type);
overriding
entry Dequeue (Element : out Queue_Interfaces.Element_Type);
not overriding
procedure Dequeue_Only_High_Priority
(At_Least : in Queue_Priority;
Element : in out Queue_Interfaces.Element_Type;
Success : out Boolean);
overriding
function Current_Use return Count_Type;
overriding
function Peak_Use return Count_Type;
private
-- not specified by the language
end Queue;
private
-- not specified by the language
end Ada.Containers.Unbounded_Priority_Queues;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
package AdaBase.Logger.Base.Screen is
type Screen_Logger is new Base_Logger and AIL.iLogger with private;
type Screen_Logger_access is access all Screen_Logger;
overriding
procedure reaction (listener : Screen_Logger);
private
type Screen_Logger is new Base_Logger and AIL.iLogger
with record
null;
end record;
end AdaBase.Logger.Base.Screen;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.USB is
pragma Preelaborate;
---------------
-- Registers --
---------------
-----------------------------------
-- UsbDevice cluster's Registers --
-----------------------------------
-- Operating Mode
type CTRLA_MODESelect is
(-- Device Mode
DEVICE,
-- Host Mode
HOST)
with Size => 1;
for CTRLA_MODESelect use
(DEVICE => 0,
HOST => 1);
-- Control A
type USB_CTRLA_USB_DEVICE_Register is record
-- Software Reset
SWRST : Boolean := False;
-- Enable
ENABLE : Boolean := False;
-- Run in Standby Mode
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Operating Mode
MODE : CTRLA_MODESelect := SAM_SVD.USB.DEVICE;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_CTRLA_USB_DEVICE_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
RUNSTDBY at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
MODE at 0 range 7 .. 7;
end record;
-- Synchronization Busy
type USB_SYNCBUSY_USB_DEVICE_Register is record
-- Read-only. Software Reset Synchronization Busy
SWRST : Boolean;
-- Read-only. Enable Synchronization Busy
ENABLE : Boolean;
-- unspecified
Reserved_2_7 : HAL.UInt6;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_SYNCBUSY_USB_DEVICE_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
subtype USB_QOSCTRL_USB_DEVICE_CQOS_Field is HAL.UInt2;
subtype USB_QOSCTRL_USB_DEVICE_DQOS_Field is HAL.UInt2;
-- USB Quality Of Service
type USB_QOSCTRL_USB_DEVICE_Register is record
-- Configuration Quality of Service
CQOS : USB_QOSCTRL_USB_DEVICE_CQOS_Field := 16#3#;
-- Data Quality of Service
DQOS : USB_QOSCTRL_USB_DEVICE_DQOS_Field := 16#3#;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_QOSCTRL_USB_DEVICE_Register use record
CQOS at 0 range 0 .. 1;
DQOS at 0 range 2 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
-- Speed Configuration
type CTRLB_SPDCONFSelect is
(-- FS : Full Speed
FS,
-- LS : Low Speed
LS,
-- HS : High Speed capable
HS,
-- HSTM: High Speed Test Mode (force high-speed mode for test mode)
HSTM)
with Size => 2;
for CTRLB_SPDCONFSelect use
(FS => 0,
LS => 1,
HS => 2,
HSTM => 3);
-- Link Power Management Handshake
type CTRLB_LPMHDSKSelect is
(-- No handshake. LPM is not supported
NO,
-- ACK
ACK,
-- NYET
NYET,
-- STALL
STALL)
with Size => 2;
for CTRLB_LPMHDSKSelect use
(NO => 0,
ACK => 1,
NYET => 2,
STALL => 3);
-- DEVICE Control B
type USB_CTRLB_USB_DEVICE_Register is record
-- Detach
DETACH : Boolean := True;
-- Upstream Resume
UPRSM : Boolean := False;
-- Speed Configuration
SPDCONF : CTRLB_SPDCONFSelect := SAM_SVD.USB.FS;
-- No Reply
NREPLY : Boolean := False;
-- Test mode J
TSTJ : Boolean := False;
-- Test mode K
TSTK : Boolean := False;
-- Test packet mode
TSTPCKT : Boolean := False;
-- Specific Operational Mode
OPMODE2 : Boolean := False;
-- Global NAK
GNAK : Boolean := False;
-- Link Power Management Handshake
LPMHDSK : CTRLB_LPMHDSKSelect := SAM_SVD.USB.NO;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_CTRLB_USB_DEVICE_Register use record
DETACH at 0 range 0 .. 0;
UPRSM at 0 range 1 .. 1;
SPDCONF at 0 range 2 .. 3;
NREPLY at 0 range 4 .. 4;
TSTJ at 0 range 5 .. 5;
TSTK at 0 range 6 .. 6;
TSTPCKT at 0 range 7 .. 7;
OPMODE2 at 0 range 8 .. 8;
GNAK at 0 range 9 .. 9;
LPMHDSK at 0 range 10 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
end record;
subtype USB_DADD_USB_DEVICE_DADD_Field is HAL.UInt7;
-- DEVICE Device Address
type USB_DADD_USB_DEVICE_Register is record
-- Device Address
DADD : USB_DADD_USB_DEVICE_DADD_Field := 16#0#;
-- Device Address Enable
ADDEN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_DADD_USB_DEVICE_Register use record
DADD at 0 range 0 .. 6;
ADDEN at 0 range 7 .. 7;
end record;
-- Speed Status
type STATUS_SPEEDSelect is
(-- Full-speed mode
FS,
-- Low-speed mode
LS,
-- High-speed mode
HS)
with Size => 2;
for STATUS_SPEEDSelect use
(FS => 0,
LS => 1,
HS => 2);
-- USB Line State Status
type STATUS_LINESTATESelect is
(-- SE0/RESET
Val_0,
-- FS-J or LS-K State
Val_1,
-- FS-K or LS-J State
Val_2)
with Size => 2;
for STATUS_LINESTATESelect use
(Val_0 => 0,
Val_1 => 1,
Val_2 => 2);
-- DEVICE Status
type USB_STATUS_USB_DEVICE_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2;
-- Read-only. Speed Status
SPEED : STATUS_SPEEDSelect;
-- unspecified
Reserved_4_5 : HAL.UInt2;
-- Read-only. USB Line State Status
LINESTATE : STATUS_LINESTATESelect;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_STATUS_USB_DEVICE_Register use record
Reserved_0_1 at 0 range 0 .. 1;
SPEED at 0 range 2 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
LINESTATE at 0 range 6 .. 7;
end record;
-- Fine State Machine Status
type FSMSTATUS_FSMSTATESelect is
(-- OFF (L3). It corresponds to the powered-off, disconnected, and disabled
-- state
OFF,
-- ON (L0). It corresponds to the Idle and Active states
ON,
-- SUSPEND (L2)
SUSPEND,
-- SLEEP (L1)
SLEEP,
-- DNRESUME. Down Stream Resume.
DNRESUME,
-- UPRESUME. Up Stream Resume.
UPRESUME,
-- RESET. USB lines Reset.
RESET)
with Size => 7;
for FSMSTATUS_FSMSTATESelect use
(OFF => 1,
ON => 2,
SUSPEND => 4,
SLEEP => 8,
DNRESUME => 16,
UPRESUME => 32,
RESET => 64);
-- Finite State Machine Status
type USB_FSMSTATUS_USB_DEVICE_Register is record
-- Read-only. Fine State Machine Status
FSMSTATE : FSMSTATUS_FSMSTATESelect;
-- unspecified
Reserved_7_7 : HAL.Bit;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_FSMSTATUS_USB_DEVICE_Register use record
FSMSTATE at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
subtype USB_FNUM_USB_DEVICE_MFNUM_Field is HAL.UInt3;
subtype USB_FNUM_USB_DEVICE_FNUM_Field is HAL.UInt11;
-- DEVICE Device Frame Number
type USB_FNUM_USB_DEVICE_Register is record
-- Read-only. Micro Frame Number
MFNUM : USB_FNUM_USB_DEVICE_MFNUM_Field;
-- Read-only. Frame Number
FNUM : USB_FNUM_USB_DEVICE_FNUM_Field;
-- unspecified
Reserved_14_14 : HAL.Bit;
-- Read-only. Frame Number CRC Error
FNCERR : Boolean;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_FNUM_USB_DEVICE_Register use record
MFNUM at 0 range 0 .. 2;
FNUM at 0 range 3 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
FNCERR at 0 range 15 .. 15;
end record;
-- DEVICE Device Interrupt Enable Clear
type USB_INTENCLR_USB_DEVICE_Register is record
-- Suspend Interrupt Enable
SUSPEND : Boolean := False;
-- Micro Start of Frame Interrupt Enable in High Speed Mode
MSOF : Boolean := False;
-- Start Of Frame Interrupt Enable
SOF : Boolean := False;
-- End of Reset Interrupt Enable
EORST : Boolean := False;
-- Wake Up Interrupt Enable
WAKEUP : Boolean := False;
-- End Of Resume Interrupt Enable
EORSM : Boolean := False;
-- Upstream Resume Interrupt Enable
UPRSM : Boolean := False;
-- Ram Access Interrupt Enable
RAMACER : Boolean := False;
-- Link Power Management Not Yet Interrupt Enable
LPMNYET : Boolean := False;
-- Link Power Management Suspend Interrupt Enable
LPMSUSP : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_INTENCLR_USB_DEVICE_Register use record
SUSPEND at 0 range 0 .. 0;
MSOF at 0 range 1 .. 1;
SOF at 0 range 2 .. 2;
EORST at 0 range 3 .. 3;
WAKEUP at 0 range 4 .. 4;
EORSM at 0 range 5 .. 5;
UPRSM at 0 range 6 .. 6;
RAMACER at 0 range 7 .. 7;
LPMNYET at 0 range 8 .. 8;
LPMSUSP at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- DEVICE Device Interrupt Enable Set
type USB_INTENSET_USB_DEVICE_Register is record
-- Suspend Interrupt Enable
SUSPEND : Boolean := False;
-- Micro Start of Frame Interrupt Enable in High Speed Mode
MSOF : Boolean := False;
-- Start Of Frame Interrupt Enable
SOF : Boolean := False;
-- End of Reset Interrupt Enable
EORST : Boolean := False;
-- Wake Up Interrupt Enable
WAKEUP : Boolean := False;
-- End Of Resume Interrupt Enable
EORSM : Boolean := False;
-- Upstream Resume Interrupt Enable
UPRSM : Boolean := False;
-- Ram Access Interrupt Enable
RAMACER : Boolean := False;
-- Link Power Management Not Yet Interrupt Enable
LPMNYET : Boolean := False;
-- Link Power Management Suspend Interrupt Enable
LPMSUSP : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_INTENSET_USB_DEVICE_Register use record
SUSPEND at 0 range 0 .. 0;
MSOF at 0 range 1 .. 1;
SOF at 0 range 2 .. 2;
EORST at 0 range 3 .. 3;
WAKEUP at 0 range 4 .. 4;
EORSM at 0 range 5 .. 5;
UPRSM at 0 range 6 .. 6;
RAMACER at 0 range 7 .. 7;
LPMNYET at 0 range 8 .. 8;
LPMSUSP at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- DEVICE Device Interrupt Flag
type USB_INTFLAG_USB_DEVICE_Register is record
-- Suspend
SUSPEND : Boolean := False;
-- Micro Start of Frame in High Speed Mode
MSOF : Boolean := False;
-- Start Of Frame
SOF : Boolean := False;
-- End of Reset
EORST : Boolean := False;
-- Wake Up
WAKEUP : Boolean := False;
-- End Of Resume
EORSM : Boolean := False;
-- Upstream Resume
UPRSM : Boolean := False;
-- Ram Access
RAMACER : Boolean := False;
-- Link Power Management Not Yet
LPMNYET : Boolean := False;
-- Link Power Management Suspend
LPMSUSP : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_INTFLAG_USB_DEVICE_Register use record
SUSPEND at 0 range 0 .. 0;
MSOF at 0 range 1 .. 1;
SOF at 0 range 2 .. 2;
EORST at 0 range 3 .. 3;
WAKEUP at 0 range 4 .. 4;
EORSM at 0 range 5 .. 5;
UPRSM at 0 range 6 .. 6;
RAMACER at 0 range 7 .. 7;
LPMNYET at 0 range 8 .. 8;
LPMSUSP at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- USB_EPINTSMRY_USB_DEVICE_EPINT array
type USB_EPINTSMRY_USB_DEVICE_EPINT_Field_Array is array (0 .. 7)
of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for USB_EPINTSMRY_USB_DEVICE_EPINT
type USB_EPINTSMRY_USB_DEVICE_EPINT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EPINT as a value
Val : HAL.UInt8;
when True =>
-- EPINT as an array
Arr : USB_EPINTSMRY_USB_DEVICE_EPINT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for USB_EPINTSMRY_USB_DEVICE_EPINT_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- DEVICE End Point Interrupt Summary
type USB_EPINTSMRY_USB_DEVICE_Register is record
-- Read-only. End Point 0 Interrupt
EPINT : USB_EPINTSMRY_USB_DEVICE_EPINT_Field;
-- unspecified
Reserved_8_15 : HAL.UInt8;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_EPINTSMRY_USB_DEVICE_Register use record
EPINT at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
end record;
subtype USB_PADCAL_USB_DEVICE_TRANSP_Field is HAL.UInt5;
subtype USB_PADCAL_USB_DEVICE_TRANSN_Field is HAL.UInt5;
subtype USB_PADCAL_USB_DEVICE_TRIM_Field is HAL.UInt3;
-- USB PAD Calibration
type USB_PADCAL_USB_DEVICE_Register is record
-- USB Pad Transp calibration
TRANSP : USB_PADCAL_USB_DEVICE_TRANSP_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- USB Pad Transn calibration
TRANSN : USB_PADCAL_USB_DEVICE_TRANSN_Field := 16#0#;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- USB Pad Trim calibration
TRIM : USB_PADCAL_USB_DEVICE_TRIM_Field := 16#0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_PADCAL_USB_DEVICE_Register use record
TRANSP at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TRANSN at 0 range 6 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
TRIM at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
end record;
---------------------------------------------
-- USB_DEVICE_ENDPOINT cluster's Registers --
---------------------------------------------
subtype USB_EPCFG_USB_DEVICE_ENDPOINT_EPTYPE0_Field is HAL.UInt3;
subtype USB_EPCFG_USB_DEVICE_ENDPOINT_EPTYPE1_Field is HAL.UInt3;
-- DEVICE_ENDPOINT End Point Configuration
type USB_EPCFG_USB_DEVICE_ENDPOINT_Register is record
-- End Point Type0
EPTYPE0 : USB_EPCFG_USB_DEVICE_ENDPOINT_EPTYPE0_Field := 16#0#;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- End Point Type1
EPTYPE1 : USB_EPCFG_USB_DEVICE_ENDPOINT_EPTYPE1_Field := 16#0#;
-- NYET Token Disable
NYETDIS : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPCFG_USB_DEVICE_ENDPOINT_Register use record
EPTYPE0 at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
EPTYPE1 at 0 range 4 .. 6;
NYETDIS at 0 range 7 .. 7;
end record;
-- USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ array
type USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ
type USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STALLRQ as a value
Val : HAL.UInt2;
when True =>
-- STALLRQ as an array
Arr : USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DEVICE_ENDPOINT End Point Pipe Status Clear
type USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_Register is record
-- Write-only. Data Toggle OUT Clear
DTGLOUT : Boolean := False;
-- Write-only. Data Toggle IN Clear
DTGLIN : Boolean := False;
-- Write-only. Current Bank Clear
CURBK : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Write-only. Stall 0 Request Clear
STALLRQ : USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_STALLRQ_Field :=
(As_Array => False, Val => 16#0#);
-- Write-only. Bank 0 Ready Clear
BK0RDY : Boolean := False;
-- Write-only. Bank 1 Ready Clear
BK1RDY : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_Register use record
DTGLOUT at 0 range 0 .. 0;
DTGLIN at 0 range 1 .. 1;
CURBK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
STALLRQ at 0 range 4 .. 5;
BK0RDY at 0 range 6 .. 6;
BK1RDY at 0 range 7 .. 7;
end record;
-- USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ array
type USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ
type USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STALLRQ as a value
Val : HAL.UInt2;
when True =>
-- STALLRQ as an array
Arr : USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DEVICE_ENDPOINT End Point Pipe Status Set
type USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_Register is record
-- Write-only. Data Toggle OUT Set
DTGLOUT : Boolean := False;
-- Write-only. Data Toggle IN Set
DTGLIN : Boolean := False;
-- Write-only. Current Bank Set
CURBK : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Write-only. Stall 0 Request Set
STALLRQ : USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_STALLRQ_Field :=
(As_Array => False, Val => 16#0#);
-- Write-only. Bank 0 Ready Set
BK0RDY : Boolean := False;
-- Write-only. Bank 1 Ready Set
BK1RDY : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_Register use record
DTGLOUT at 0 range 0 .. 0;
DTGLIN at 0 range 1 .. 1;
CURBK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
STALLRQ at 0 range 4 .. 5;
BK0RDY at 0 range 6 .. 6;
BK1RDY at 0 range 7 .. 7;
end record;
-- USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ array
type USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ
type USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STALLRQ as a value
Val : HAL.UInt2;
when True =>
-- STALLRQ as an array
Arr : USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DEVICE_ENDPOINT End Point Pipe Status
type USB_EPSTATUS_USB_DEVICE_ENDPOINT_Register is record
-- Read-only. Data Toggle Out
DTGLOUT : Boolean;
-- Read-only. Data Toggle In
DTGLIN : Boolean;
-- Read-only. Current Bank
CURBK : Boolean;
-- unspecified
Reserved_3_3 : HAL.Bit;
-- Read-only. Stall 0 Request
STALLRQ : USB_EPSTATUS_USB_DEVICE_ENDPOINT_STALLRQ_Field;
-- Read-only. Bank 0 ready
BK0RDY : Boolean;
-- Read-only. Bank 1 ready
BK1RDY : Boolean;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPSTATUS_USB_DEVICE_ENDPOINT_Register use record
DTGLOUT at 0 range 0 .. 0;
DTGLIN at 0 range 1 .. 1;
CURBK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
STALLRQ at 0 range 4 .. 5;
BK0RDY at 0 range 6 .. 6;
BK1RDY at 0 range 7 .. 7;
end record;
-- USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT array
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRCPT as a value
Val : HAL.UInt2;
when True =>
-- TRCPT as an array
Arr : USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL array
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRFAIL as a value
Val : HAL.UInt2;
when True =>
-- TRFAIL as an array
Arr : USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL array
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STALL as a value
Val : HAL.UInt2;
when True =>
-- STALL as an array
Arr : USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DEVICE_ENDPOINT End Point Interrupt Flag
type USB_EPINTFLAG_USB_DEVICE_ENDPOINT_Register is record
-- Transfer Complete 0
TRCPT : USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRCPT_Field :=
(As_Array => False, Val => 16#0#);
-- Error Flow 0
TRFAIL : USB_EPINTFLAG_USB_DEVICE_ENDPOINT_TRFAIL_Field :=
(As_Array => False, Val => 16#0#);
-- Received Setup
RXSTP : Boolean := False;
-- Stall 0 In/out
STALL : USB_EPINTFLAG_USB_DEVICE_ENDPOINT_STALL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPINTFLAG_USB_DEVICE_ENDPOINT_Register use record
TRCPT at 0 range 0 .. 1;
TRFAIL at 0 range 2 .. 3;
RXSTP at 0 range 4 .. 4;
STALL at 0 range 5 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
-- USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT array
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRCPT as a value
Val : HAL.UInt2;
when True =>
-- TRCPT as an array
Arr : USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL array
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRFAIL as a value
Val : HAL.UInt2;
when True =>
-- TRFAIL as an array
Arr : USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL array
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STALL as a value
Val : HAL.UInt2;
when True =>
-- STALL as an array
Arr : USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DEVICE_ENDPOINT End Point Interrupt Clear Flag
type USB_EPINTENCLR_USB_DEVICE_ENDPOINT_Register is record
-- Transfer Complete 0 Interrupt Disable
TRCPT : USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRCPT_Field :=
(As_Array => False, Val => 16#0#);
-- Error Flow 0 Interrupt Disable
TRFAIL : USB_EPINTENCLR_USB_DEVICE_ENDPOINT_TRFAIL_Field :=
(As_Array => False, Val => 16#0#);
-- Received Setup Interrupt Disable
RXSTP : Boolean := False;
-- Stall 0 In/Out Interrupt Disable
STALL : USB_EPINTENCLR_USB_DEVICE_ENDPOINT_STALL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPINTENCLR_USB_DEVICE_ENDPOINT_Register use record
TRCPT at 0 range 0 .. 1;
TRFAIL at 0 range 2 .. 3;
RXSTP at 0 range 4 .. 4;
STALL at 0 range 5 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
-- USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT array
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRCPT as a value
Val : HAL.UInt2;
when True =>
-- TRCPT as an array
Arr : USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL array
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRFAIL as a value
Val : HAL.UInt2;
when True =>
-- TRFAIL as an array
Arr : USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL array
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STALL as a value
Val : HAL.UInt2;
when True =>
-- STALL as an array
Arr : USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DEVICE_ENDPOINT End Point Interrupt Set Flag
type USB_EPINTENSET_USB_DEVICE_ENDPOINT_Register is record
-- Transfer Complete 0 Interrupt Enable
TRCPT : USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRCPT_Field :=
(As_Array => False, Val => 16#0#);
-- Error Flow 0 Interrupt Enable
TRFAIL : USB_EPINTENSET_USB_DEVICE_ENDPOINT_TRFAIL_Field :=
(As_Array => False, Val => 16#0#);
-- Received Setup Interrupt Enable
RXSTP : Boolean := False;
-- Stall 0 In/out Interrupt enable
STALL : USB_EPINTENSET_USB_DEVICE_ENDPOINT_STALL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_EPINTENSET_USB_DEVICE_ENDPOINT_Register use record
TRCPT at 0 range 0 .. 1;
TRFAIL at 0 range 2 .. 3;
RXSTP at 0 range 4 .. 4;
STALL at 0 range 5 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
type USB_DEVICE_ENDPOINT_Cluster is record
-- DEVICE_ENDPOINT End Point Configuration
EPCFG : aliased USB_EPCFG_USB_DEVICE_ENDPOINT_Register;
-- DEVICE_ENDPOINT End Point Pipe Status Clear
EPSTATUSCLR : aliased USB_EPSTATUSCLR_USB_DEVICE_ENDPOINT_Register;
-- DEVICE_ENDPOINT End Point Pipe Status Set
EPSTATUSSET : aliased USB_EPSTATUSSET_USB_DEVICE_ENDPOINT_Register;
-- DEVICE_ENDPOINT End Point Pipe Status
EPSTATUS : aliased USB_EPSTATUS_USB_DEVICE_ENDPOINT_Register;
-- DEVICE_ENDPOINT End Point Interrupt Flag
EPINTFLAG : aliased USB_EPINTFLAG_USB_DEVICE_ENDPOINT_Register;
-- DEVICE_ENDPOINT End Point Interrupt Clear Flag
EPINTENCLR : aliased USB_EPINTENCLR_USB_DEVICE_ENDPOINT_Register;
-- DEVICE_ENDPOINT End Point Interrupt Set Flag
EPINTENSET : aliased USB_EPINTENSET_USB_DEVICE_ENDPOINT_Register;
end record
with Size => 256;
for USB_DEVICE_ENDPOINT_Cluster use record
EPCFG at 16#0# range 0 .. 7;
EPSTATUSCLR at 16#4# range 0 .. 7;
EPSTATUSSET at 16#5# range 0 .. 7;
EPSTATUS at 16#6# range 0 .. 7;
EPINTFLAG at 16#7# range 0 .. 7;
EPINTENCLR at 16#8# range 0 .. 7;
EPINTENSET at 16#9# range 0 .. 7;
end record;
type USB_DEVICE_ENDPOINT_Clusters is array (0 .. 7)
of USB_DEVICE_ENDPOINT_Cluster;
-- USB is Device
type UsbDevice_Cluster is record
-- Control A
CTRLA : aliased USB_CTRLA_USB_DEVICE_Register;
-- Synchronization Busy
SYNCBUSY : aliased USB_SYNCBUSY_USB_DEVICE_Register;
-- USB Quality Of Service
QOSCTRL : aliased USB_QOSCTRL_USB_DEVICE_Register;
-- DEVICE Control B
CTRLB : aliased USB_CTRLB_USB_DEVICE_Register;
-- DEVICE Device Address
DADD : aliased USB_DADD_USB_DEVICE_Register;
-- DEVICE Status
STATUS : aliased USB_STATUS_USB_DEVICE_Register;
-- Finite State Machine Status
FSMSTATUS : aliased USB_FSMSTATUS_USB_DEVICE_Register;
-- DEVICE Device Frame Number
FNUM : aliased USB_FNUM_USB_DEVICE_Register;
-- DEVICE Device Interrupt Enable Clear
INTENCLR : aliased USB_INTENCLR_USB_DEVICE_Register;
-- DEVICE Device Interrupt Enable Set
INTENSET : aliased USB_INTENSET_USB_DEVICE_Register;
-- DEVICE Device Interrupt Flag
INTFLAG : aliased USB_INTFLAG_USB_DEVICE_Register;
-- DEVICE End Point Interrupt Summary
EPINTSMRY : aliased USB_EPINTSMRY_USB_DEVICE_Register;
-- Descriptor Address
DESCADD : aliased HAL.UInt32;
-- USB PAD Calibration
PADCAL : aliased USB_PADCAL_USB_DEVICE_Register;
USB_DEVICE_ENDPOINT : aliased USB_DEVICE_ENDPOINT_Clusters;
end record
with Size => 2304;
for UsbDevice_Cluster use record
CTRLA at 16#0# range 0 .. 7;
SYNCBUSY at 16#2# range 0 .. 7;
QOSCTRL at 16#3# range 0 .. 7;
CTRLB at 16#8# range 0 .. 15;
DADD at 16#A# range 0 .. 7;
STATUS at 16#C# range 0 .. 7;
FSMSTATUS at 16#D# range 0 .. 7;
FNUM at 16#10# range 0 .. 15;
INTENCLR at 16#14# range 0 .. 15;
INTENSET at 16#18# range 0 .. 15;
INTFLAG at 16#1C# range 0 .. 15;
EPINTSMRY at 16#20# range 0 .. 15;
DESCADD at 16#24# range 0 .. 31;
PADCAL at 16#28# range 0 .. 15;
USB_DEVICE_ENDPOINT at 16#100# range 0 .. 2047;
end record;
---------------------------------
-- UsbHost cluster's Registers --
---------------------------------
-- Control A
type USB_CTRLA_USB_HOST_Register is record
-- Software Reset
SWRST : Boolean := False;
-- Enable
ENABLE : Boolean := False;
-- Run in Standby Mode
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Operating Mode
MODE : CTRLA_MODESelect := SAM_SVD.USB.DEVICE;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_CTRLA_USB_HOST_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
RUNSTDBY at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
MODE at 0 range 7 .. 7;
end record;
-- Synchronization Busy
type USB_SYNCBUSY_USB_HOST_Register is record
-- Read-only. Software Reset Synchronization Busy
SWRST : Boolean;
-- Read-only. Enable Synchronization Busy
ENABLE : Boolean;
-- unspecified
Reserved_2_7 : HAL.UInt6;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_SYNCBUSY_USB_HOST_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
subtype USB_QOSCTRL_USB_HOST_CQOS_Field is HAL.UInt2;
subtype USB_QOSCTRL_USB_HOST_DQOS_Field is HAL.UInt2;
-- USB Quality Of Service
type USB_QOSCTRL_USB_HOST_Register is record
-- Configuration Quality of Service
CQOS : USB_QOSCTRL_USB_HOST_CQOS_Field := 16#3#;
-- Data Quality of Service
DQOS : USB_QOSCTRL_USB_HOST_DQOS_Field := 16#3#;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_QOSCTRL_USB_HOST_Register use record
CQOS at 0 range 0 .. 1;
DQOS at 0 range 2 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
-- Speed Configuration for Host
type CTRLB_SPDCONFSelect_1 is
(-- Normal mode: the host starts in full-speed mode and performs a high-speed
-- reset to switch to the high speed mode if the downstream peripheral is
-- high-speed capable.
NORMAL,
-- Full-speed: the host remains in full-speed mode whatever is the peripheral
-- speed capability. Relevant in UTMI mode only.
FS)
with Size => 2;
for CTRLB_SPDCONFSelect_1 use
(NORMAL => 0,
FS => 3);
-- HOST Control B
type USB_CTRLB_USB_HOST_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Send USB Resume
RESUME : Boolean := False;
-- Speed Configuration for Host
SPDCONF : CTRLB_SPDCONFSelect_1 := SAM_SVD.USB.NORMAL;
-- Auto Resume Enable
AUTORESUME : Boolean := False;
-- Test mode J
TSTJ : Boolean := False;
-- Test mode K
TSTK : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Start of Frame Generation Enable
SOFE : Boolean := False;
-- Send USB Reset
BUSRESET : Boolean := False;
-- VBUS is OK
VBUSOK : Boolean := False;
-- Send L1 Resume
L1RESUME : Boolean := False;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_CTRLB_USB_HOST_Register use record
Reserved_0_0 at 0 range 0 .. 0;
RESUME at 0 range 1 .. 1;
SPDCONF at 0 range 2 .. 3;
AUTORESUME at 0 range 4 .. 4;
TSTJ at 0 range 5 .. 5;
TSTK at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
SOFE at 0 range 8 .. 8;
BUSRESET at 0 range 9 .. 9;
VBUSOK at 0 range 10 .. 10;
L1RESUME at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
end record;
subtype USB_HSOFC_USB_HOST_FLENC_Field is HAL.UInt4;
-- HOST Host Start Of Frame Control
type USB_HSOFC_USB_HOST_Register is record
-- Frame Length Control
FLENC : USB_HSOFC_USB_HOST_FLENC_Field := 16#0#;
-- unspecified
Reserved_4_6 : HAL.UInt3 := 16#0#;
-- Frame Length Control Enable
FLENCE : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_HSOFC_USB_HOST_Register use record
FLENC at 0 range 0 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
FLENCE at 0 range 7 .. 7;
end record;
subtype USB_STATUS_USB_HOST_SPEED_Field is HAL.UInt2;
subtype USB_STATUS_USB_HOST_LINESTATE_Field is HAL.UInt2;
-- HOST Status
type USB_STATUS_USB_HOST_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Speed Status
SPEED : USB_STATUS_USB_HOST_SPEED_Field := 16#0#;
-- unspecified
Reserved_4_5 : HAL.UInt2 := 16#0#;
-- USB Line State Status
LINESTATE : USB_STATUS_USB_HOST_LINESTATE_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_STATUS_USB_HOST_Register use record
Reserved_0_1 at 0 range 0 .. 1;
SPEED at 0 range 2 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
LINESTATE at 0 range 6 .. 7;
end record;
-- Finite State Machine Status
type USB_FSMSTATUS_USB_HOST_Register is record
-- Read-only. Fine State Machine Status
FSMSTATE : FSMSTATUS_FSMSTATESelect;
-- unspecified
Reserved_7_7 : HAL.Bit;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_FSMSTATUS_USB_HOST_Register use record
FSMSTATE at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
subtype USB_FNUM_USB_HOST_MFNUM_Field is HAL.UInt3;
subtype USB_FNUM_USB_HOST_FNUM_Field is HAL.UInt11;
-- HOST Host Frame Number
type USB_FNUM_USB_HOST_Register is record
-- Micro Frame Number
MFNUM : USB_FNUM_USB_HOST_MFNUM_Field := 16#0#;
-- Frame Number
FNUM : USB_FNUM_USB_HOST_FNUM_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_FNUM_USB_HOST_Register use record
MFNUM at 0 range 0 .. 2;
FNUM at 0 range 3 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
end record;
-- HOST Host Interrupt Enable Clear
type USB_INTENCLR_USB_HOST_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Host Start Of Frame Interrupt Disable
HSOF : Boolean := False;
-- BUS Reset Interrupt Disable
RST : Boolean := False;
-- Wake Up Interrupt Disable
WAKEUP : Boolean := False;
-- DownStream to Device Interrupt Disable
DNRSM : Boolean := False;
-- Upstream Resume from Device Interrupt Disable
UPRSM : Boolean := False;
-- Ram Access Interrupt Disable
RAMACER : Boolean := False;
-- Device Connection Interrupt Disable
DCONN : Boolean := False;
-- Device Disconnection Interrupt Disable
DDISC : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_INTENCLR_USB_HOST_Register use record
Reserved_0_1 at 0 range 0 .. 1;
HSOF at 0 range 2 .. 2;
RST at 0 range 3 .. 3;
WAKEUP at 0 range 4 .. 4;
DNRSM at 0 range 5 .. 5;
UPRSM at 0 range 6 .. 6;
RAMACER at 0 range 7 .. 7;
DCONN at 0 range 8 .. 8;
DDISC at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- HOST Host Interrupt Enable Set
type USB_INTENSET_USB_HOST_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Host Start Of Frame Interrupt Enable
HSOF : Boolean := False;
-- Bus Reset Interrupt Enable
RST : Boolean := False;
-- Wake Up Interrupt Enable
WAKEUP : Boolean := False;
-- DownStream to the Device Interrupt Enable
DNRSM : Boolean := False;
-- Upstream Resume fromthe device Interrupt Enable
UPRSM : Boolean := False;
-- Ram Access Interrupt Enable
RAMACER : Boolean := False;
-- Link Power Management Interrupt Enable
DCONN : Boolean := False;
-- Device Disconnection Interrupt Enable
DDISC : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_INTENSET_USB_HOST_Register use record
Reserved_0_1 at 0 range 0 .. 1;
HSOF at 0 range 2 .. 2;
RST at 0 range 3 .. 3;
WAKEUP at 0 range 4 .. 4;
DNRSM at 0 range 5 .. 5;
UPRSM at 0 range 6 .. 6;
RAMACER at 0 range 7 .. 7;
DCONN at 0 range 8 .. 8;
DDISC at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- HOST Host Interrupt Flag
type USB_INTFLAG_USB_HOST_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Host Start Of Frame
HSOF : Boolean := False;
-- Bus Reset
RST : Boolean := False;
-- Wake Up
WAKEUP : Boolean := False;
-- Downstream
DNRSM : Boolean := False;
-- Upstream Resume from the Device
UPRSM : Boolean := False;
-- Ram Access
RAMACER : Boolean := False;
-- Device Connection
DCONN : Boolean := False;
-- Device Disconnection
DDISC : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_INTFLAG_USB_HOST_Register use record
Reserved_0_1 at 0 range 0 .. 1;
HSOF at 0 range 2 .. 2;
RST at 0 range 3 .. 3;
WAKEUP at 0 range 4 .. 4;
DNRSM at 0 range 5 .. 5;
UPRSM at 0 range 6 .. 6;
RAMACER at 0 range 7 .. 7;
DCONN at 0 range 8 .. 8;
DDISC at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- USB_PINTSMRY_USB_HOST_EPINT array
type USB_PINTSMRY_USB_HOST_EPINT_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for USB_PINTSMRY_USB_HOST_EPINT
type USB_PINTSMRY_USB_HOST_EPINT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EPINT as a value
Val : HAL.UInt8;
when True =>
-- EPINT as an array
Arr : USB_PINTSMRY_USB_HOST_EPINT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for USB_PINTSMRY_USB_HOST_EPINT_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- HOST Pipe Interrupt Summary
type USB_PINTSMRY_USB_HOST_Register is record
-- Read-only. Pipe 0 Interrupt
EPINT : USB_PINTSMRY_USB_HOST_EPINT_Field;
-- unspecified
Reserved_8_15 : HAL.UInt8;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_PINTSMRY_USB_HOST_Register use record
EPINT at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
end record;
subtype USB_PADCAL_USB_HOST_TRANSP_Field is HAL.UInt5;
subtype USB_PADCAL_USB_HOST_TRANSN_Field is HAL.UInt5;
subtype USB_PADCAL_USB_HOST_TRIM_Field is HAL.UInt3;
-- USB PAD Calibration
type USB_PADCAL_USB_HOST_Register is record
-- USB Pad Transp calibration
TRANSP : USB_PADCAL_USB_HOST_TRANSP_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- USB Pad Transn calibration
TRANSN : USB_PADCAL_USB_HOST_TRANSN_Field := 16#0#;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- USB Pad Trim calibration
TRIM : USB_PADCAL_USB_HOST_TRIM_Field := 16#0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for USB_PADCAL_USB_HOST_Register use record
TRANSP at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TRANSN at 0 range 6 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
TRIM at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
end record;
---------------------------------------
-- USB_HOST_PIPE cluster's Registers --
---------------------------------------
subtype USB_PCFG_USB_HOST_PIPE_PTOKEN_Field is HAL.UInt2;
subtype USB_PCFG_USB_HOST_PIPE_PTYPE_Field is HAL.UInt3;
-- HOST_PIPE End Point Configuration
type USB_PCFG_USB_HOST_PIPE_Register is record
-- Pipe Token
PTOKEN : USB_PCFG_USB_HOST_PIPE_PTOKEN_Field := 16#0#;
-- Pipe Bank
BK : Boolean := False;
-- Pipe Type
PTYPE : USB_PCFG_USB_HOST_PIPE_PTYPE_Field := 16#0#;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PCFG_USB_HOST_PIPE_Register use record
PTOKEN at 0 range 0 .. 1;
BK at 0 range 2 .. 2;
PTYPE at 0 range 3 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- HOST_PIPE End Point Pipe Status Clear
type USB_PSTATUSCLR_USB_HOST_PIPE_Register is record
-- Write-only. Data Toggle clear
DTGL : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Write-only. Curren Bank clear
CURBK : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Write-only. Pipe Freeze Clear
PFREEZE : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Write-only. Bank 0 Ready Clear
BK0RDY : Boolean := False;
-- Write-only. Bank 1 Ready Clear
BK1RDY : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PSTATUSCLR_USB_HOST_PIPE_Register use record
DTGL at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CURBK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
PFREEZE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
BK0RDY at 0 range 6 .. 6;
BK1RDY at 0 range 7 .. 7;
end record;
-- HOST_PIPE End Point Pipe Status Set
type USB_PSTATUSSET_USB_HOST_PIPE_Register is record
-- Write-only. Data Toggle Set
DTGL : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Write-only. Current Bank Set
CURBK : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Write-only. Pipe Freeze Set
PFREEZE : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Write-only. Bank 0 Ready Set
BK0RDY : Boolean := False;
-- Write-only. Bank 1 Ready Set
BK1RDY : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PSTATUSSET_USB_HOST_PIPE_Register use record
DTGL at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CURBK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
PFREEZE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
BK0RDY at 0 range 6 .. 6;
BK1RDY at 0 range 7 .. 7;
end record;
-- HOST_PIPE End Point Pipe Status
type USB_PSTATUS_USB_HOST_PIPE_Register is record
-- Read-only. Data Toggle
DTGL : Boolean;
-- unspecified
Reserved_1_1 : HAL.Bit;
-- Read-only. Current Bank
CURBK : Boolean;
-- unspecified
Reserved_3_3 : HAL.Bit;
-- Read-only. Pipe Freeze
PFREEZE : Boolean;
-- unspecified
Reserved_5_5 : HAL.Bit;
-- Read-only. Bank 0 ready
BK0RDY : Boolean;
-- Read-only. Bank 1 ready
BK1RDY : Boolean;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PSTATUS_USB_HOST_PIPE_Register use record
DTGL at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CURBK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
PFREEZE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
BK0RDY at 0 range 6 .. 6;
BK1RDY at 0 range 7 .. 7;
end record;
-- USB_PINTFLAG_USB_HOST_PIPE_TRCPT array
type USB_PINTFLAG_USB_HOST_PIPE_TRCPT_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_PINTFLAG_USB_HOST_PIPE_TRCPT
type USB_PINTFLAG_USB_HOST_PIPE_TRCPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRCPT as a value
Val : HAL.UInt2;
when True =>
-- TRCPT as an array
Arr : USB_PINTFLAG_USB_HOST_PIPE_TRCPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_PINTFLAG_USB_HOST_PIPE_TRCPT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- HOST_PIPE Pipe Interrupt Flag
type USB_PINTFLAG_USB_HOST_PIPE_Register is record
-- Transfer Complete 0 Interrupt Flag
TRCPT : USB_PINTFLAG_USB_HOST_PIPE_TRCPT_Field :=
(As_Array => False, Val => 16#0#);
-- Error Flow Interrupt Flag
TRFAIL : Boolean := False;
-- Pipe Error Interrupt Flag
PERR : Boolean := False;
-- Transmit Setup Interrupt Flag
TXSTP : Boolean := False;
-- Stall Interrupt Flag
STALL : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PINTFLAG_USB_HOST_PIPE_Register use record
TRCPT at 0 range 0 .. 1;
TRFAIL at 0 range 2 .. 2;
PERR at 0 range 3 .. 3;
TXSTP at 0 range 4 .. 4;
STALL at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- USB_PINTENCLR_USB_HOST_PIPE_TRCPT array
type USB_PINTENCLR_USB_HOST_PIPE_TRCPT_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_PINTENCLR_USB_HOST_PIPE_TRCPT
type USB_PINTENCLR_USB_HOST_PIPE_TRCPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRCPT as a value
Val : HAL.UInt2;
when True =>
-- TRCPT as an array
Arr : USB_PINTENCLR_USB_HOST_PIPE_TRCPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_PINTENCLR_USB_HOST_PIPE_TRCPT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- HOST_PIPE Pipe Interrupt Flag Clear
type USB_PINTENCLR_USB_HOST_PIPE_Register is record
-- Transfer Complete 0 Disable
TRCPT : USB_PINTENCLR_USB_HOST_PIPE_TRCPT_Field :=
(As_Array => False, Val => 16#0#);
-- Error Flow Interrupt Disable
TRFAIL : Boolean := False;
-- Pipe Error Interrupt Disable
PERR : Boolean := False;
-- Transmit Setup Interrupt Disable
TXSTP : Boolean := False;
-- Stall Inetrrupt Disable
STALL : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PINTENCLR_USB_HOST_PIPE_Register use record
TRCPT at 0 range 0 .. 1;
TRFAIL at 0 range 2 .. 2;
PERR at 0 range 3 .. 3;
TXSTP at 0 range 4 .. 4;
STALL at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- USB_PINTENSET_USB_HOST_PIPE_TRCPT array
type USB_PINTENSET_USB_HOST_PIPE_TRCPT_Field_Array is array (0 .. 1)
of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for USB_PINTENSET_USB_HOST_PIPE_TRCPT
type USB_PINTENSET_USB_HOST_PIPE_TRCPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TRCPT as a value
Val : HAL.UInt2;
when True =>
-- TRCPT as an array
Arr : USB_PINTENSET_USB_HOST_PIPE_TRCPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for USB_PINTENSET_USB_HOST_PIPE_TRCPT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- HOST_PIPE Pipe Interrupt Flag Set
type USB_PINTENSET_USB_HOST_PIPE_Register is record
-- Transfer Complete 0 Interrupt Enable
TRCPT : USB_PINTENSET_USB_HOST_PIPE_TRCPT_Field :=
(As_Array => False, Val => 16#0#);
-- Error Flow Interrupt Enable
TRFAIL : Boolean := False;
-- Pipe Error Interrupt Enable
PERR : Boolean := False;
-- Transmit Setup Interrupt Enable
TXSTP : Boolean := False;
-- Stall Interrupt Enable
STALL : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for USB_PINTENSET_USB_HOST_PIPE_Register use record
TRCPT at 0 range 0 .. 1;
TRFAIL at 0 range 2 .. 2;
PERR at 0 range 3 .. 3;
TXSTP at 0 range 4 .. 4;
STALL at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
type USB_HOST_PIPE_Cluster is record
-- HOST_PIPE End Point Configuration
PCFG : aliased USB_PCFG_USB_HOST_PIPE_Register;
-- HOST_PIPE Bus Access Period of Pipe
BINTERVAL : aliased HAL.UInt8;
-- HOST_PIPE End Point Pipe Status Clear
PSTATUSCLR : aliased USB_PSTATUSCLR_USB_HOST_PIPE_Register;
-- HOST_PIPE End Point Pipe Status Set
PSTATUSSET : aliased USB_PSTATUSSET_USB_HOST_PIPE_Register;
-- HOST_PIPE End Point Pipe Status
PSTATUS : aliased USB_PSTATUS_USB_HOST_PIPE_Register;
-- HOST_PIPE Pipe Interrupt Flag
PINTFLAG : aliased USB_PINTFLAG_USB_HOST_PIPE_Register;
-- HOST_PIPE Pipe Interrupt Flag Clear
PINTENCLR : aliased USB_PINTENCLR_USB_HOST_PIPE_Register;
-- HOST_PIPE Pipe Interrupt Flag Set
PINTENSET : aliased USB_PINTENSET_USB_HOST_PIPE_Register;
end record
with Size => 256;
for USB_HOST_PIPE_Cluster use record
PCFG at 16#0# range 0 .. 7;
BINTERVAL at 16#3# range 0 .. 7;
PSTATUSCLR at 16#4# range 0 .. 7;
PSTATUSSET at 16#5# range 0 .. 7;
PSTATUS at 16#6# range 0 .. 7;
PINTFLAG at 16#7# range 0 .. 7;
PINTENCLR at 16#8# range 0 .. 7;
PINTENSET at 16#9# range 0 .. 7;
end record;
type USB_HOST_PIPE_Clusters is array (0 .. 7) of USB_HOST_PIPE_Cluster;
-- USB is Host
type UsbHost_Cluster is record
-- Control A
CTRLA : aliased USB_CTRLA_USB_HOST_Register;
-- Synchronization Busy
SYNCBUSY : aliased USB_SYNCBUSY_USB_HOST_Register;
-- USB Quality Of Service
QOSCTRL : aliased USB_QOSCTRL_USB_HOST_Register;
-- HOST Control B
CTRLB : aliased USB_CTRLB_USB_HOST_Register;
-- HOST Host Start Of Frame Control
HSOFC : aliased USB_HSOFC_USB_HOST_Register;
-- HOST Status
STATUS : aliased USB_STATUS_USB_HOST_Register;
-- Finite State Machine Status
FSMSTATUS : aliased USB_FSMSTATUS_USB_HOST_Register;
-- HOST Host Frame Number
FNUM : aliased USB_FNUM_USB_HOST_Register;
-- HOST Host Frame Length
FLENHIGH : aliased HAL.UInt8;
-- HOST Host Interrupt Enable Clear
INTENCLR : aliased USB_INTENCLR_USB_HOST_Register;
-- HOST Host Interrupt Enable Set
INTENSET : aliased USB_INTENSET_USB_HOST_Register;
-- HOST Host Interrupt Flag
INTFLAG : aliased USB_INTFLAG_USB_HOST_Register;
-- HOST Pipe Interrupt Summary
PINTSMRY : aliased USB_PINTSMRY_USB_HOST_Register;
-- Descriptor Address
DESCADD : aliased HAL.UInt32;
-- USB PAD Calibration
PADCAL : aliased USB_PADCAL_USB_HOST_Register;
USB_HOST_PIPE : aliased USB_HOST_PIPE_Clusters;
end record
with Size => 2304;
for UsbHost_Cluster use record
CTRLA at 16#0# range 0 .. 7;
SYNCBUSY at 16#2# range 0 .. 7;
QOSCTRL at 16#3# range 0 .. 7;
CTRLB at 16#8# range 0 .. 15;
HSOFC at 16#A# range 0 .. 7;
STATUS at 16#C# range 0 .. 7;
FSMSTATUS at 16#D# range 0 .. 7;
FNUM at 16#10# range 0 .. 15;
FLENHIGH at 16#12# range 0 .. 7;
INTENCLR at 16#14# range 0 .. 15;
INTENSET at 16#18# range 0 .. 15;
INTFLAG at 16#1C# range 0 .. 15;
PINTSMRY at 16#20# range 0 .. 15;
DESCADD at 16#24# range 0 .. 31;
PADCAL at 16#28# range 0 .. 15;
USB_HOST_PIPE at 16#100# range 0 .. 2047;
end record;
-----------------
-- Peripherals --
-----------------
type USB_Disc is
(DEVICE,
HOST);
-- Universal Serial Bus
type USB_Peripheral
(Discriminent : USB_Disc := DEVICE)
is record
case Discriminent is
when DEVICE =>
-- USB is Device
USB_DEVICE : aliased UsbDevice_Cluster;
when HOST =>
-- USB is Host
USB_HOST : aliased UsbHost_Cluster;
end case;
end record
with Unchecked_Union, Volatile;
for USB_Peripheral use record
USB_DEVICE at 0 range 0 .. 2303;
USB_HOST at 0 range 0 .. 2303;
end record;
-- Universal Serial Bus
USB_Periph : aliased USB_Peripheral
with Import, Address => USB_Base;
end SAM_SVD.USB;
|
with System;
with Interfaces; use Interfaces;
with System.Machine_Code; use System.Machine_Code;
package body Startup is
WDTCTL : Unsigned_16 with Import, Address => System'To_Address (16#0120#);
procedure Ada_Init with Import => True, Convention => C, External_Name => "adainit";
procedure Ada_Main with Import => True, Convention => C, External_Name => "_ada_main";
procedure Reset_Handler is
begin
Asm ("mov #__stack_end, sp", Volatile => True);
WDTCTL := 16#5A80#;
Ada_Init;
Ada_Main;
end Reset_Handler;
Vectors : constant array (0 .. 15) of System.Address := (
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
System'To_Address (16#FFFF#),
Reset_Handler'Address)
with Export => True;
pragma Linker_Section (Vectors, ".vectors");
end Startup;
|
with
GL,
system.storage_Elements;
package openGL.Attribute
--
-- Models an openGL shader attribute.
--
is
type Item is tagged private;
type View is access all Item'Class;
type Views is array (Positive range <>) of View;
type data_Kind is (GL_BYTE, GL_UNSIGNED_BYTE,
GL_SHORT, GL_UNSIGNED_SHORT,
GL_INT, GL_UNSIGNED_INT,
GL_FLOAT, GL_FIXED);
---------
--- Forge
--
procedure define (Self : in out Item);
procedure destroy (Self : in out Item);
package Forge
is
use system.storage_Elements;
function to_Attribute (Name : in String;
gl_Location : in gl.GLuint;
Size : in gl.GLint;
data_Kind : in Attribute.data_Kind;
Stride : in Natural;
Offset : in storage_Offset;
Normalized : in Boolean) return Item;
function new_Attribute (Name : in String;
gl_Location : in gl.GLuint;
Size : in gl.GLint;
data_Kind : in Attribute.data_Kind;
Stride : in Natural;
Offset : in storage_Offset;
Normalized : in Boolean) return View;
end Forge;
--------------
--- Attributes
--
function Name (Self : in Item'Class) return String;
function gl_Location (Self : in Item'Class) return gl.GLuint;
--------------
--- Operations
--
procedure enable (Self : in Item);
private
type Item is tagged
record
Name : access String;
Location : gl.GLuint;
Size : gl.GLint;
data_Kind : Attribute.data_Kind;
vertex_Stride : gl.GLint;
Offset : system.storage_Elements.storage_Offset;
Normalized : gl.GLboolean;
end record;
for data_Kind use (GL_BYTE => 16#1400#,
GL_UNSIGNED_BYTE => 16#1401#,
GL_SHORT => 16#1402#,
GL_UNSIGNED_SHORT => 16#1403#,
GL_INT => 16#1404#,
GL_UNSIGNED_INT => 16#1405#,
GL_FLOAT => 16#1406#,
GL_FIXED => 16#140c#);
end openGL.Attribute;
|
With
NSO.Helpers,
Ada.Strings.Fixed,
Ada.Calendar.Formatting,
Ada.Characters.Latin_1,
Ada.Tags,
Gnoga.Types.Colors,
Gnoga.Gui.View,
Ada.Text_IO
;
WITH
Ada.Tags,
Ada.Text_IO;
with
Gnoga.Gui.Base;
Package Body NSO.Types.Report_Objects.Weather_Report is
Use NSO.Helpers;
DEBUGGING : Constant Boolean := False;
Package Naming is new Name_Binder("Weather", Weather_Report);
Function Get_Name(Self: Weather_Report) return String
renames Naming.Get_Name;
Report_Name : String renames Naming.Report_Name;
---------------------------
-- Characters & Strings --
---------------------------
Package Latin_1 renames Ada.Characters.Latin_1;
Left_Bracket : Character renames Latin_1.Left_Square_Bracket; -- [
Right_Bracket : Character renames Latin_1.Right_Square_Bracket; -- ]
Bracket_Divide : Constant String := Right_Bracket & Left_Bracket; -- ][
New_Line : Constant String := (Latin_1.CR, Latin_1.LF);
---------------------------
-- DISPLAY REPORT DATA --
---------------------------
Function Report_Header return String is
Date_Time : String renames HTML_Tag("th", "Time / Date");
Wind_Speed : String renames HTML_Tag("th", "Wind Speed");
Temperature : String renames HTML_Tag("th", "Temperature");
Seeing : String renames HTML_Tag("th", "Seeing");
Conditions : String renames HTML_Tag("th", "Conditions");
Wind_Direction : String renames HTML_Tag("th", "Wind Direction");
Begin
Return New_Line & HTML_Tag("thead", HTML_Tag("tr",
Date_Time & Wind_Speed & Wind_Direction &
Temperature & Seeing & Conditions)
) & New_Line;
End Report_Header;
Function Report( Cursor : Report_Map.Cursor ) return String is
Use Report_Map, Ada.Calendar, Ada.Calendar.Formatting;
Begin
if not Has_Element(Cursor) then
Return "";
else
Declare
Function "+"(Input : Sky) return string is
( Sky'Image(Input) );
Function "+"(Input : Direction) return string is
( Direction'Image(Input) );
Date : Time renames Key(Cursor);
Data : Report_Data renames Element(Cursor);
Date_Time : String renames HTML_Tag("th", Image(Date));
Wind_Speed : String renames HTML_Tag("td",+Data.Wind_Speed);
Temperature : String renames HTML_Tag("td",+Data.Temperature);
Seeing : String renames HTML_Tag("td",+Data.Seeing);
Conditions : String renames HTML_Tag("td",+Data.Conditions);
Wind_Direction : String renames HTML_Tag("td",+Data.Wind_Direction);
Begin
return New_Line & HTML_Tag("tr",
Date_Time & Wind_Speed & Wind_Direction &
Temperature & Seeing & Conditions
) & New_Line;
End;
End if;
End Report;
Function Report( Object : Report_Map.Map ) return String is
Use NSO.Helpers;
Function Report_Data( Cursor : Report_Map.Cursor:= Object.First ) return String is
Next : Report_Map.Cursor renames Report_Map.Next(Cursor);
Has_Next : Boolean renames Report_Map.Has_Element( Next );
Begin
Return Report(Cursor) &
(if not Has_Next then "" else Report_Data( Next ));
End Report_Data;
Caption : Constant String := HTML_Tag("Caption", Report_Name&" Report");
Begin
return HTML_Tag("Table", Caption & Report_Header &
HTML_Tag("tbody", Report_Data) );
End Report;
--------------------------
-- CREATE REPORT DATA --
--------------------------
Function Report(Data : in NSO.JSON.Instance'Class) return Report_Map.Map is
Use NSO.Types, NSO.JSON, Ada.Strings.Fixed;
Package Fixed renames Ada.Strings.Fixed;
Function Filter_Object is new Object_Filter( Report_Name );
Function Filter Return JSON.Instance'Class is ( Filter_Object(Data) );
-- The result to return.
Working : Report_Map.Map;
Current : Report_Map.Cursor;
Procedure Process_Records(Name : String; Value : Instance'Class);
Function Process_Parameters is new Process_Date_Time(
Result => Working,
Current => Current,
Element => Report_Data,
Date_Time_Map => Report_Map,
Default => Report_Data'(others => <>),
Report_Name => Report_Name,
On_Object => Process_Records
);
Procedure Process_Records(Name : String; Value : Instance'Class) is
Data : Report_Data renames Working( Report_Map.Key(Current) );
Procedure Process_Value(Value : String) is
Function "-"(Object: String) return Sky is
(Sky'Value(Object));
Function "-"(Object: String) return Direction is
(Direction'Value(Object));
Begin
declare
Field_Item : Field renames "+"(Name);
Field_Pos : Constant Natural := Field'Pos(Field_Item);
begin
Case Field_Item is
When Wind_Speed => Data.Wind_Speed := -Value;
When Temperature => Data.Temperature := -Value;
When Seeing => Data.Seeing := -Value;
When Conditions => Data.Conditions := -Value;
When Wind_Direction => Data.Wind_Direction := -Value;
End Case;
Data.Initalized(Field_Pos):= True;
end;
End Process_Value;
Procedure Do_Process is new Apply(On_String => Process_Value);
Begin
Do_Process( Value );
End Process_Records;
Begin
Return Result : Report_Map.Map := Process_Parameters(Data) do
-- Ensure all fields are initalized.
for Cursor in reverse Result.Iterate loop
declare
K : Ada.Calendar.Time renames Report_Map.Key(Cursor);
E : Report_Data renames Report_Map.Element( Cursor );
I : Bit_Vector renames E.Initalized;
begin
if not (for all X in I'Range => I(X)) then
Result.Delete( K );
end if;
end;
end loop;
End return;
End Report;
procedure Add_Self(
Self : in Weather_Report;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class
) is
Use Gnoga.Gui.Element.Common, Gnoga.Gui.Element.Form;
Package Form_Entry is new Generic_Form_Entry(
Report_Type => Weather_Report,
Report => Self'Access,
Form => Form,
Label => Self.Date.Value & ' ' & Self.Time.Value
);
Package Items is new Form_Entry.Components(Text_Type, Text_Access, 5);
Wind_Speed : Text_Type renames Items.Tuple(1).All;
Wind_Dir : Text_Type renames Items.Tuple(2).All;
Temperature : Text_Type renames Items.Tuple(3).All;
Seeing : Text_Type renames Items.Tuple(4).All;
Conditions : Text_Type renames Items.Tuple(5).All;
Function Name is new Form_Entry.Name(
Indices =>
Form_Entry.Index(Self.Date.Value) &
Form_Entry.Index(Self.Time.Value)
);
Begin
Wind_Speed.Create (Form, Value => Self.Wind_Speed.Value,
Name => Name("Wind_Speed"));
Temperature.Create(Form, Value => Self.Temperature.Value,
Name => Name("Temperature"));
Seeing.Create (Form, Value => Self.Seeing.Value,
Name => Name("Seeing"));
Conditions.Create (Form, Value => Self.Conditions.Value,
Name => Name("Conditions"));
Wind_Dir.Create (Form, Value => Self.Wind_Direction.value,
Name => Name("Wind_Direction"));
Items.Set_Attributes;
Items.Place_Items;
End Add_Self;
Procedure Weather_Div(Object : in out Weather_Report;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class ) is
Use Gnoga.Gui.Element.Form;
Date : Date_Type renames Object.Date;
Time : Time_Type renames Object.Time;
Wind_Speed : Number_Type renames Object.Wind_Speed;
Temperature : Number_Type renames Object.Temperature;
Seeing : Number_Type renames Object.Seeing;
Conditions : Selection_Type renames Object.Conditions;
Wind_Direction : Selection_Type renames Object.Wind_Direction;
Labels : Array(1..7) of Gnoga.Gui.Element.Form.Label_Type;
Procedure Add_Directions is new Add_Discrete( NSO.Types.Direction );
Procedure Add_Conditions is new Add_Discrete( NSO.Types.Sky );
Procedure Add_Label(
Label : in out Gnoga.Gui.Element.Form.Label_Type'Class;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class;
Item : in out Gnoga.Gui.Element.Element_Type'Class;
Text : String
) is
Begin
Label.Create(Form, Item, Text, Auto_Place => False);
Item.Place_Inside_Bottom_Of(Label);
End Add_Label;
Use Ada.Calendar.Formatting;
Function Time_String return String is
Use Ada.Strings.Fixed, Ada.Strings;
Time_Image : String renames Image( Ada.Calendar.Clock );
Space : Natural renames Index(Time_Image, " ", Time_Image'First);
Colon : Natural renames Index(Time_Image, ":", Time_Image'Last, Going => Backward);
Begin
Return Result : Constant String :=
Time_Image( Positive'Succ(Space)..Positive'Pred(Colon) );
End;
Function Date_String return String is
Use Ada.Strings.Fixed, Ada.Strings;
Time_Image : String renames Image( Ada.Calendar.Clock );
Space : Natural renames Index(Time_Image, " ", Time_Image'First);
Begin
Return Result : Constant String :=
Time_Image( Time_Image'First..Positive'Pred(Space) );
End;
Begin
if DEBUGGING then
Object.Background_Color( Gnoga.Types.Colors.Yellow );
end if;
-----------------------
-- CREATE COMPONENTS --
-----------------------
Date.Create(Form => Form, ID => "Weather.Date", Value => Date_String);
Time.Create(Form => Form, ID => "Weather.Time", Value => Time_String);
Conditions.Create( Form, ID => "Weather.Condition" );
Wind_Direction.Create (Form, ID => "Weather.Wind_Direction");
Wind_Speed.Create( Form, ID => "Weather.Wind_Speed", Value => "0");
Wind_Speed.Maximum( 100 ); Wind_Speed.Minimum( 0 ); Wind_Speed.Step( 1 );
Temperature.Create( Form, ID => "Weather.Temperature", Value => "70");
Temperature.Maximum(120); Temperature.Minimum(-40); Temperature.Step(1);
Seeing.Create( Form, ID => "Weather.Seeing", Value => "5");
Seeing.Maximum(8); Seeing.Minimum(1); Seeing.Step(1);
-----------------
-- ADD OPTIONS --
-----------------
Add_Directions(Form, Wind_Direction);
Add_Conditions(Form, Conditions);
--------------------
-- CREATE LABELS --
--------------------
Add_Label( Labels(1), Form, Date, "Date:");
Add_Label( Labels(2), Form, Time, "Time:");
Add_Label( Labels(3), Form, Conditions, "Conditions:");
Add_Label( Labels(4), Form, Wind_Direction, "Wind Direction:");
Add_Label( Labels(5), Form, Wind_Speed, "Wind Speed:");
Add_Label( Labels(6), Form, Temperature, "Temperature:");
Add_Label( Labels(7), Form, Seeing, "Seeing:");
-------------------
-- PLACE OBJECTS --
-------------------
Labels(1).Place_Inside_Top_Of( Object );
For X in Positive'Succ(Labels'First)..Labels'Last loop
Labels(X).Place_After( Labels( Positive'Pred(X) ) );
end loop;
Object.Place_Inside_Bottom_Of( Form );
End Weather_Div;
procedure Make --(Report : in out Weather_Report;
-- Parent : in out Gnoga.Gui.Base.Base_Type'Class;
-- Content : in String := "";
-- ID : in String := "" ) is
is new Generic_Create(
UI_Report_Div => Weather_Report,
Populate_Div => Weather_Div,
Name => Report_Name
);
procedure Create (Report : in out Weather_Report;
Parent : in out Gnoga.Gui.Base.Base_Type'Class;
Content : in String := "";
ID : in String := ""
) renames Make;
End NSO.Types.Report_Objects.Weather_Report;
|
package Memory.Dup is
type Dup_Type is new Memory_Type with private;
type Dup_Pointer is access all Dup_Type'Class;
function Create_Dup return Dup_Pointer;
overriding
function Clone(mem : Dup_Type) return Memory_Pointer;
procedure Add_Memory(mem : in out Dup_Type;
other : access Memory_Type'Class);
overriding
procedure Reset(mem : in out Dup_Type;
context : in Natural);
overriding
procedure Read(mem : in out Dup_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Write(mem : in out Dup_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Idle(mem : in out Dup_Type;
cycles : in Time_Type);
overriding
procedure Show_Stats(mem : in out Dup_Type);
overriding
function To_String(mem : Dup_Type) return Unbounded_String;
overriding
function Get_Cost(mem : Dup_Type) return Cost_Type;
overriding
function Get_Writes(mem : Dup_Type) return Long_Integer;
overriding
function Get_Word_Size(mem : Dup_Type) return Positive;
overriding
procedure Generate(mem : in Dup_Type;
sigs : in out Unbounded_String;
code : in out Unbounded_String);
overriding
function Get_Ports(mem : Dup_Type) return Port_Vector_Type;
overriding
procedure Adjust(mem : in out Dup_Type);
overriding
procedure Finalize(mem : in out Dup_Type);
private
package Memory_Vectors is new Vectors(Natural, Memory_Pointer);
type Dup_Type is new Memory_Type with record
memories : Memory_Vectors.Vector;
end record;
end Memory.Dup;
|
package Buffer_Package is
NONE : Integer := Integer'Size - 1;
type Pos is record
L : Integer;
C : Integer;
end record;
type Tag is record
P1 : Pos;
P2 : Pos;
V : Integer;
end record;
type Tag_Type is (
VIRTCURS,
HIGHLIGHT,
BLOCK,
TAG_MAX);
type Tags_Array is array (0 .. 2) of Tag;
type Buffer is record
N : Integer;
Can_Undo : Boolean;
Dirty : Boolean;
Tags : Tags_Array;
end record;
procedure Enable_Undo (B : in out Buffer);
procedure Clear_Tag (B : in out Buffer; T : Tag_Type);
procedure Set_Tag
(B : out Buffer;
T : Tag_Type;
P1 : Pos;
P2 : Pos;
V : Integer);
end Buffer_Package;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Interrupts.Names;
with Ada.Real_Time; use Ada.Real_Time;
with STM32F4; use STM32F4;
with STM32F4.GPIO; use STM32F4.GPIO;
with STM32F4.RCC; use STM32F4.RCC;
with STM32F4.SYSCFG; use STM32F4.SYSCFG;
with STM32F429_Discovery; use STM32F429_Discovery;
package body Button is
protected Button is
pragma Interrupt_Priority;
function Current_Direction return Directions;
private
procedure Interrupt_Handler;
pragma Attach_Handler
(Interrupt_Handler,
Ada.Interrupts.Names.EXTI0_Interrupt);
Direction : Directions := Clockwise; -- arbitrary
Last_Time : Time := Clock;
end Button;
Debounce_Time : constant Time_Span := Milliseconds (500);
protected body Button is
function Current_Direction return Directions is
begin
return Direction;
end Current_Direction;
procedure Interrupt_Handler is
Now : constant Time := Clock;
begin
Clear_External_Interrupt (Pin_0);
-- Debouncing
if Now - Last_Time >= Debounce_Time then
if Direction = Counterclockwise then
Direction := Clockwise;
else
Direction := Counterclockwise;
end if;
Last_Time := Now;
end if;
end Interrupt_Handler;
end Button;
function Current_Direction return Directions is
begin
return Button.Current_Direction;
end Current_Direction;
procedure Initialize is
Configuration : GPIO_Port_Configuration;
begin
Enable_Clock (GPIO_A);
Configuration.Mode := Mode_In;
Configuration.Resistors := Floating;
Configure_IO (Port => GPIO_A,
Pin => Pin_0,
Config => Configuration);
Connect_External_Interrupt (GPIO_A, Pin_0);
Configure_Trigger (GPIO_A, Pin_0, Interrupt_Rising_Edge);
end Initialize;
begin
Initialize;
end Button;
|
with Ada.Containers.Indefinite_Hashed_Maps;
-- with Ada.Containers.Indefinite_Holders;
with Ada.Containers.Indefinite_Vectors;
with Ada.Containers.Vectors;
with Ada.Finalization;
use Ada;
--
-- ## What is this?
--
-- This package implements a generic "symbol table," that is a structure that
-- maps symbol "names" (a string) to symbol values.
--
-- The peculiarity that differentiate the symbol tables defined in this
-- package from an ordirary `Hashed_Maps.Map` is the possibility of
-- having different namespaces, possibly nested.
--
-- ### Data model
--
-- The abstract model is as follows.
-- * The symbol table contains one or more _namespace_
-- * A newly created table has only one namespace: the _root namespace_
-- that contains all the globally visible symbols
-- * At any time there is a _current_ namespace
-- * New namespaces can be created as _children_ of an existing namespace.
-- Two common choices for the parent namespace are
-- * The current namespace (like using a `declare .. begin .. end` in Ada)
-- * The root namespace (like when a new procedure is defined)
-- * When a symbol is searched for, first it is searched the current
--- namespace. If the symbol is not found, it is searched in the parent,
-- grand-parent and so on... until the root namespace is reached.
-- * When a new namespace is created it becomes the current one;
-- when the namespace is closed, the previous current namespace is selected.
--
-- It turns out that namespaces are organized in two structures
--
-- * They are organized as a tree (having the global namspace as root)
-- according to the child-parent relationship
-- * They are organized as a stack whose top is the current namespace.
-- New namespaces are pushed to the top and they are popped when
-- they are closed.
--
-- ### Cursors
--
-- When the table is queried it returns a `Cursor` that "points to" the
-- found element (or it assumes the special value `No_Element`). This
-- is similar to the behaviour of standard Ada containers.
--
-- The main difference with the usual `Cursor` is that the cursor of
-- this structure is "stable" with respect to tampering; that is, it
-- remains valid even if new elements and/or new namespaces are added
-- (I do not think this is guaranteed with the standard containers).
-- Only removing the namespace that contains the entry pointed by the cursors
-- invalidates the cursor (obviously).
--
generic
type Symbol_Name is new String;
type Symbol_Value (<>) is private;
with function Hash (Key : Symbol_Name) return Ada.Containers.Hash_Type;
with function Equivalent_Names (X, Y : Symbol_Name) return Boolean;
package Symbol_Tables.Generic_Symbol_Table is
type Symbol_Table is
new Finalization.Limited_Controlled
with
private;
type Cursor is private;
No_Element : constant Cursor;
function Image (X : Cursor) return String;
-- Return a printable representation of a cursor. Useful
-- mostly for debugging
type Table_Namespace is private;
No_Namespace : constant Table_Namespace;
function Copy_Globals (T : Symbol_Table) return Symbol_Table;
function Root (T : Symbol_Table) return Table_Namespace;
-- Return the global namespace of the table
function Current_Namespace (T : Symbol_Table) return Table_Namespace;
-- Return the current namespace
function Parent_Of (T : Symbol_Table;
Block : Table_Namespace) return Table_Namespace
with Post => (if Block = T.Root then Parent_Of'Result = No_Namespace);
-- Return the parent of a given namespace
procedure Open_Namespace (Table : in out Symbol_Table;
Parent : Table_Namespace)
with
Pre => Parent /= No_Namespace,
Post => Parent_Of (Table, Table.Current_Namespace) = Parent;
-- Create a new namespace with the given parent
procedure Open_Internal_Namespace (Table : in out Symbol_Table);
-- Syntactic sugar: Parent defaults to Table.Current_Block
procedure Open_External_Namespace (Table : in out Symbol_Table);
-- Syntactic sugar: Parent defaults to Table.Root
procedure Close_Namespace (Table : in out Symbol_Table)
with
Pre => Table.Current_Namespace /= Table.Root;
function Find (Table : Symbol_Table;
Name : Symbol_Name)
return Cursor;
function Contains (Table : Symbol_Table;
Name : Symbol_Name)
return Boolean
is (Table.Find (Name) /= No_Element);
function Has_Value (Pos : Cursor) return Boolean
with Pre => Pos /= No_Element;
function Value (Pos : Cursor) return Symbol_Value
with Pre => Has_Value (Pos);
function Name (Pos : Cursor) return Symbol_Name
with Pre => Pos /= No_Element;
function Contains (Block : Table_Namespace;
Name : Symbol_Name)
return Boolean;
procedure Create (Table : in out Symbol_Table;
Name : Symbol_Name;
Initial_Value : Symbol_Value)
with
Pre =>
not Contains (Table.Current_Namespace, Name),
Post =>
Contains (Table.Current_Namespace, Name)
and
Table.Current_Namespace = Table.Current_Namespace'Old;
procedure Create (Table : in out Symbol_Table;
Name : Symbol_Name;
Initial_Value : Symbol_Value;
Position : out Cursor)
with
Pre =>
not Contains (Table.Current_Namespace, Name),
Post =>
Contains (Table.Current_Namespace, Name)
and
Table.Current_Namespace = Table.Current_Namespace'Old
and
Table.Find (Name) = Position
and
Has_Value (Position)
and
Value (Position) = Initial_Value;
-- procedure Create (Table : in out Symbol_Table;
-- Name : Symbol_Name;
-- Position : out Cursor)
-- with
-- Pre =>
-- not Contains (Table.Current_Block, Name),
-- Post =>
-- Contains (Table.Current_Block, Name)
-- and
-- Table.Current_Block = Table.Current_Block'Old
-- and
-- Table.Find (Name) = Position
-- and
-- not Has_Value (Position);
procedure Update (Pos : Cursor;
New_Value : Symbol_Value)
with
Pre => Pos /= No_Element;
Uninitialized_Value : exception;
type Value_Printer is access function (X : Symbol_Value) return String;
procedure Set_Printer (Callback : Value_Printer);
-- Useful for debugging. Setup a function that converts symbol values
-- to string. This function will be used in generating debug prints.
-- Why specifying the converter in this way and not as a parameter
-- to package? Because it is a feature that it is not always
-- required.
Stale_Cursor : exception;
private
--
-- The structure of the symbol table is as follows: we have a stacks
-- of Namespaces. When a new namespace is open, it is pushed on the
-- stack, when it is closed it is popped out. The top of the stack
-- is always the current block. The stack can never be empty, the
-- bottom of the stack is the global namespace.
--
-- Blocks can have a "parent" that is searched when the symbol is not
-- found. The parent list goes from the block to the root.
--
-- Every namespace has an ID that is monotonically increased. Two
-- namespaces will never have the same ID.
--
-- Every namespace has two structure: a vector of Symbol_Value and
-- a Map mapping symbol_names to vector indexes. Why this involuted
-- structure? Why not just a map sending names to values? Because
-- in this way we can have a stable Cursor given by
-- * The namespace index in the stack
-- * The namespace ID
-- * The index of the entry in the value vector
--
-- This Cursor is stable against new additions to the table, a feature
-- that is sometimes required and that maybe is not guaranteed with
-- the usual library structures. The ID is not stricly necessary,
-- but it is useful to check for stale Cursors that refer to past
-- namespaces.
--
type Value_Index is range 1 .. Positive'Last;
type Namespace_Index is range 1 .. Positive'Last;
type Namespace_ID is range 0 .. Positive'Last;
Root_ID : constant Namespace_ID := Namespace_ID'First;
Root_Namespace : constant Namespace_Index := Namespace_Index'First;
package Name_Maps is
new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => Symbol_Name,
Element_Type => Value_Index,
Hash => Hash,
Equivalent_Keys => Equivalent_Names);
package Value_Vectors is
new Ada.Containers.Indefinite_Vectors (Index_Type => Value_Index,
Element_Type => Symbol_Value);
package Name_Vectors is
new Ada.Containers.Indefinite_Vectors (Index_Type => Value_Index,
Element_Type => Symbol_Name);
type Basic_Table;
type Basic_Table_Access is access Basic_Table;
type Table_Namespace is
record
Table : Basic_Table_Access;
Index : Namespace_Index;
ID : Namespace_ID;
end record;
No_Namespace : constant Table_Namespace := (Table => null,
Index => Namespace_Index'Last,
ID => Namespace_ID'Last);
type Namespace_Block is
record
Name_Map : Name_Maps.Map;
Values : Value_Vectors.Vector;
Names : Name_Vectors.Vector;
ID : Namespace_ID;
Parent : Table_Namespace;
end record;
-- with Dynamic_Predicate =>
-- (for all Idx in Namespace_Block.Names.First_Index .. Namespace_Block.Names.Last_Index
-- => Namespace_Block.Name_Map (Namespace_Block.Names (Idx)) = Idx)
-- and Names.First_Index = Values.First_Index
-- and Names.Last_Index = Values.Last_Index;
type Cursor is
record
Namespace : Table_Namespace;
Idx : Value_Index;
end record;
No_Element : constant Cursor := Cursor'(Namespace => No_Namespace,
Idx => Value_Index'Last);
function Image (X : Cursor) return String
is (if Has_Value (X) then
"["
& X.Idx'Image
& "@"
& X.Namespace.Index'Image
& ","
& X.Namespace.ID'Image
& "]"
else
"NO_ELEMENT");
package Namespace_Stacks is
new Ada.Containers.Vectors (Index_Type => Namespace_Index,
Element_Type => Namespace_Block);
-- package Value_Holders is
-- new Ada.Containers.Indefinite_Holders (Symbol_Value);
--
-- use type Value_Holders.Holder;
--
-- subtype Map_Entry is Value_Holders.Holder;
subtype Namespace_Stack is Namespace_Stacks.Vector;
procedure Push (Stack : in out Namespace_Stack;
Item : Namespace_Block);
procedure Pop (Stack : in out Namespace_Stack);
type Basic_Table is
record
Stack : Namespace_Stacks.Vector;
end record;
type Symbol_Table is
new Finalization.Limited_Controlled
with
record
Counter : Namespace_ID := Root_ID;
T : Basic_Table_Access;
end record;
overriding procedure Initialize (Object : in out Symbol_Table);
function Root (T : Symbol_Table) return Table_Namespace
is (Table_Namespace'(Table => T.T,
Index => Root_Namespace,
ID => Root_ID));
function Current_Namespace (T : Symbol_Table) return Table_Namespace
is (Table_Namespace'(Table => T.T,
Index => T.T.Stack.Last_Index,
Id => T.T.Stack.Last_Element.ID));
function Parent_Of (Block : Table_Namespace) return Table_Namespace
is (Block.Table.Stack.Element (Block.Index).Parent);
function Contains (Block : Table_Namespace;
Name : Symbol_Name)
return Boolean
is (Block.Table.Stack (Block.Index).Name_Map.Contains (Name));
function Is_Stale (Pos : Cursor) return Boolean
is (Pos.Namespace /= No_Namespace and then
(Pos.Namespace.Table.Stack (Pos.Namespace.Index).Id /= Pos.Namespace.Id));
function Value (Pos : Cursor) return Symbol_Value
is (if not Is_Stale (Pos) then
(if Has_Value (Pos) then
Pos.Namespace.Table.Stack (Pos.Namespace.Index).Values (Pos.Idx)
else
raise Uninitialized_Value with String (Name (Pos)))
else
raise Stale_Cursor);
function Has_Value (Pos : Cursor) return Boolean
is (Pos.Namespace /= No_Namespace);
function Name (Pos : Cursor) return Symbol_Name
is (Pos.Namespace.Table.Stack (Pos.Namespace.Index).Names (Pos.Idx));
function Parent_Of (T : Symbol_Table;
Block : Table_Namespace) return Table_Namespace
is (Table_Namespace'(Table => Block.Table,
Index => Block.Table.Stack (Block.Index).Parent.Index,
ID => Block.Table.Stack (Block.Index).Parent.ID));
end Symbol_Tables.Generic_Symbol_Table;
|
----------------------------------------
-- Copyright (C) 2019 Dmitriy Shadrin --
-- All rights reserved. --
----------------------------------------
with Unchecked_Deallocation;
with Ada.Text_IO; use Ada.Text_IO;
with ConfigTree.SaxParser;
--------------------------------------------------------------------------------
package body ConfigTree is
procedure Free is new Unchecked_Deallocation (Node, NodePtr);
-----------------------------------------------------------------------------
procedure Initialize (Object : in out Node) is
begin
Object.parent := null;
Object.next := null;
Object.previous := null;
Object.childFirst := null;
Object.childLast := null;
Object.name := Ada.Strings.Unbounded.To_Unbounded_String ("");
Object.data := Ada.Strings.Unbounded.To_Unbounded_String ("");
end Initialize;
-----------------------------------------------------------------------------
procedure Finalize (Object : in out Node) is
begin
if Object.next /= null then
Free (Object.next);
end if;
if Object.childFirst /= null then
Free (Object.childFirst);
end if;
end Finalize;
-----------------------------------------------------------------------------
function GetChild (Object : in out Node; path : String) return NodePtr is
use type Ada.Strings.Unbounded.Unbounded_String;
str : Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.To_Unbounded_String (path);
pos : Natural := Ada.Strings.Unbounded.Index (str, ".", 1);
first : Ada.Strings.Unbounded.Unbounded_String;
last : Ada.Strings.Unbounded.Unbounded_String;
node : NodePtr := Object.childFirst;
begin
if pos = 0 then
first := str;
else
if pos > 1 then
first := Ada.Strings.Unbounded.To_Unbounded_String (Ada.Strings.Unbounded.Slice (str, 1, pos - 1));
end if;
last := str;
Ada.Strings.Unbounded.Delete (last, 1, pos);
end if;
if Ada.Strings.Unbounded.Length (first) > 0 then
while node /= null loop
exit when first = node.name;
node := node.next;
end loop;
end if;
if Ada.Strings.Unbounded.Length (last) > 0 then
node := node.GetChild (Ada.Strings.Unbounded.To_String (last));
end if;
return node;
end GetChild;
-----------------------------------------------------------------------------
function GetFirst (Object : in out Node) return NodePtr is
begin
return Object.childFirst;
end GetFirst;
-----------------------------------------------------------------------------
function GetNext (Object : in out Node) return NodePtr is
begin
return Object.next;
end GetNext;
-----------------------------------------------------------------------------
function GetValue (Object : in out Node; path : in String; default : in String := "") return String is
node : NodePtr := Object.GetChild (path);
begin
if not IsNull (node) then
return Ada.Strings.Unbounded.To_String (node.data);
end if;
return default;
end GetValue;
-----------------------------------------------------------------------------
function GetValue (Object : in out Node) return String is
begin
return Ada.Strings.Unbounded.To_String (Object.data);
end GetValue;
-----------------------------------------------------------------------------
function GetName (Object : in out Node) return String is
begin
return Ada.Strings.Unbounded.To_String (Object.name);
end GetName;
-----------------------------------------------------------------------------
procedure Finalize (Object : in out Tree) is
begin
if Object.root /= null then
Free (Object.root);
end if;
end Finalize;
-----------------------------------------------------------------------------
procedure Initialize (Object : in out Tree) is
begin
Object.root := new Node;
Object.root.name := Ada.Strings.Unbounded.To_Unbounded_String ("root");
SaxParser.Parse (Object.root);
end Initialize;
-----------------------------------------------------------------------------
function GetChild (Object : in out Tree; path : in String) return NodePtr is
begin
return Object.root.GetChild (path);
end GetChild;
-----------------------------------------------------------------------------
function GetValue (Object : in out Tree; path : in String; default : in String := "") return String is
begin
return Object.root.GetValue (path, default);
end GetValue;
end ConfigTree;
|
Package Body Config is
-- Return the slice (1..Item.LENGTH).
Function "+"( Item : Pascal_String ) return String is
Begin
Return Result : Constant String := (Item.Text(1..Natural(Item.Length)));
End "+";
-- Return Item concatenated with the padding to make the result-length 255.
Function "+"( Item : String ) return Pascal_String is
Subtype Tail is Natural range
Natural'Succ(Item'Length)..Max_String_255'Last;
Begin
Return Result : Constant Pascal_String :=
(Text => Item &
(Tail => ASCII.NUL),
Length => Item'Length);
End "+";
---------
-- GET --
---------
function Host return Pascal_String is (mailhost);
function User return Pascal_String is (mailuser);
function Password return Pascal_String is (mailpassword);
---------
-- SET --
---------
procedure Host( Item : String ) is
Begin
mailhost:= +Item;
End;
procedure User( Item : String ) is
Begin
mailuser:= +Item;
End;
procedure Password(Item : String) is
Begin
mailpassword:= +Item;
End;
End Config;
|
-----------------------------------------------------------------------
-- security-openid-servlets - Servlets for OpenID 2.0 Authentication
-- Copyright (C) 2010, 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Servlets;
with ASF.Requests;
with ASF.Responses;
with ASF.Principals;
with Security.Auth; use Security;
-- The <b>Security.Openid.Servlets</b> package defines two servlets that can be used
-- to implement an OpenID 2.0 authentication with an OpenID provider such as Google,
-- Yahoo!, Verisign, Orange, ...
--
-- The process to use these servlets is the following:
-- <ul>
-- <li>Declare and register a <b>Request_Auth_Servlet</b> servlet.</li>
-- <li>Map that servlet to an authenticate URL. To authenticate, a user will have
-- to click on a link mapped to that servlet. To identify the OpenID provider,
-- the URL must contain the name of the provider. Example:
--
-- http://localhost:8080/app/openid/auth/google
--
-- <li>Declare and register a <b>Verify_Auth_Servlet</b> servlet.
-- <li>Map that servlet to the verification URL. This is the URL that the user
-- will return to when authentication is done by the OpenID provider. Example:
--
-- http://localhost:8080/app/openid/verify
--
-- <li>Declare in the application properties a set of configurations:
-- <ul>
-- <li>The <b>openid.realm</b> must indicate the URL that identifies the
-- application the end user will trust. Example:
--
-- openid.realm=http://localhost:8080/app
--
-- <li>The <b>openid.callback_url</b> must indicate the callback URL to
-- which the OpenID provider will redirect the user when authentication
-- is finished (successfully or not). The callback URL must match
-- the realm.
--
-- openid.callback_url=http://localhost:8080/app/openid/verify
--
-- <li>For each OpenID provider, a URL to the Yadis entry point of the
-- OpenID provider is necessary. This URL is used to get the XRDS
-- stream giving endoint of the OpenID provider. Example:
--
-- openid.provider.google=https://www.google.com/accounts/o8/id
-- </ul>
--
-- </ul>
--
package ASF.Security.Servlets is
-- ------------------------------
-- OpenID Servlet
-- ------------------------------
-- The <b>Openid_Servlet</b> is the OpenID root servlet for OpenID 2.0 authentication.
-- It is defined to provide a common basis for the authentication and verification servlets.
type Openid_Servlet is abstract new ASF.Servlets.Servlet and Auth.Parameters with private;
-- Called by the servlet container to indicate to a servlet that the servlet
-- is being placed into service.
overriding
procedure Initialize (Server : in out Openid_Servlet;
Context : in ASF.Servlets.Servlet_Registry'Class);
-- Get a configuration parameter from the servlet context for the security Auth provider.
overriding
function Get_Parameter (Server : in Openid_Servlet;
Name : in String) return String;
-- ------------------------------
-- OpenID Request Servlet
-- ------------------------------
-- The <b>Request_Auth_Servlet</b> servlet implements the first steps of an OpenID
-- authentication.
type Request_Auth_Servlet is new Openid_Servlet with private;
-- Proceed to the OpenID authentication with an OpenID provider.
-- Find the OpenID provider URL and starts the discovery, association phases
-- during which a private key is obtained from the OpenID provider.
-- After OpenID discovery and association, the user will be redirected to
-- the OpenID provider.
overriding
procedure Do_Get (Server : in Request_Auth_Servlet;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class);
-- ------------------------------
-- OpenID Verification Servlet
-- ------------------------------
-- The <b>Verify_Auth_Servlet</b> verifies the authentication result and
-- extract authentication from the callback URL.
type Verify_Auth_Servlet is new Openid_Servlet with private;
-- Verify the authentication result that was returned by the OpenID provider.
-- If the authentication succeeded and the signature was correct, sets a
-- user principals on the session.
overriding
procedure Do_Get (Server : in Verify_Auth_Servlet;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class);
-- Create a principal object that correspond to the authenticated user identified
-- by the <b>Credential</b> information. The principal will be attached to the session
-- and will be destroyed when the session is closed.
procedure Create_Principal (Server : in Verify_Auth_Servlet;
Credential : in Auth.Authentication;
Result : out ASF.Principals.Principal_Access);
private
function Get_Provider_URL (Server : in Request_Auth_Servlet;
Request : in ASF.Requests.Request'Class) return String;
procedure Initialize (Server : in Openid_Servlet;
Provider : in String;
Manager : in out Auth.Manager);
type Openid_Servlet is new ASF.Servlets.Servlet and Auth.Parameters with null record;
type Request_Auth_Servlet is new Openid_Servlet with null record;
type Verify_Auth_Servlet is new Openid_Servlet with null record;
end ASF.Security.Servlets;
|
-- {{Ada/Sourceforge|to_lower_1.adb}}
pragma License (Gpl);
pragma Ada_95;
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Characters.Handling;
procedure To_Lower_1 is
package CL renames Ada.Command_Line;
package T_IO renames Ada.Text_IO;
function To_Lower (Str : String) return String;
Value : constant String := CL.Argument (1);
function To_Lower (C : Character) return Character renames
Ada.Characters.Handling.To_Lower;
-- tolower - translates all alphabetic, uppercase characters
-- in str to lowercase
function To_Lower (Str : String) return String is
Result : String (Str'Range) := (others => ' ');
begin
for C in Str'Range loop
Result (C) := To_Lower (Str (C));
end loop;
return Result;
end To_Lower;
begin
T_IO.Put ("The lower case of ");
T_IO.Put (Value);
T_IO.Put (" is ");
T_IO.Put (To_Lower (Value));
return;
end To_Lower_1;
----------------------------------------------------------------------------
-- $Author: krischik $
--
-- $Revision: 226 $
-- $Date: 2007-12-02 15:11:44 +0000 (Sun, 02 Dec 2007) $
--
-- $Id: to_lower_1.adb 226 2007-12-02 15:11:44Z krischik $
-- $HeadURL: file:///svn/p/wikibook-ada/code/trunk/demos/Source/to_lower_1.adb $
----------------------------------------------------------------------------
-- vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab
-- vim: filetype=ada encoding=utf-8 fileformat=unix foldmethod=indent
|
with ACO.Messages;
with ACO.OD_Types;
with ACO.Configuration;
private with ACO.Utils.DS.Generic_Queue;
package ACO.SDO_Sessions is
type Session_Manager is tagged limited private;
type Services is
(None,
Download,
Upload,
Block_Download,
Block_Upload);
subtype Endpoint_Nr is Integer range -1 .. Integer'Last;
No_Endpoint_Id : constant Endpoint_Nr := Endpoint_Nr'First;
subtype Valid_Endpoint_Nr is Endpoint_Nr range
No_Endpoint_Id + 1 .. ACO.Configuration.Max_Nof_Simultaneous_SDO_Sessions;
type SDO_Parameters is record
CAN_Id_C2S : ACO.Messages.Id_Type := 0;
CAN_Id_S2C : ACO.Messages.Id_Type := 0;
Node : ACO.Messages.Node_Nr := ACO.Messages.Not_A_Slave;
end record;
No_SDO_Parameters : constant SDO_Parameters :=
(CAN_Id_C2S => 0,
CAN_Id_S2C => 0,
Node => ACO.Messages.Not_A_Slave);
type SDO_Parameter_Array is array (Natural range <>) of SDO_Parameters;
type Endpoint_Type is record
Id : Endpoint_Nr := No_Endpoint_Id;
Parameters : SDO_Parameters;
end record;
No_Endpoint : constant Endpoint_Type :=
(Id => No_Endpoint_Id,
Parameters => No_SDO_Parameters);
function Image (Endpoint : Endpoint_Type) return String;
type SDO_Status is
(Pending,
Complete,
Error);
Is_Complete : constant array (SDO_Status) of Boolean :=
(Pending | Error => False,
Complete => True);
subtype SDO_Result is SDO_Status range Complete .. Error;
type SDO_Session (Service : Services := None) is record
Endpoint : Endpoint_Type := No_Endpoint;
Index : ACO.OD_Types.Entry_Index := (0, 0);
Toggle : Boolean := False;
end record;
function Create_Download
(Endpoint : Endpoint_Type;
Index : ACO.OD_Types.Entry_Index)
return SDO_Session;
function Create_Upload
(Endpoint : Endpoint_Type;
Index : ACO.OD_Types.Entry_Index)
return SDO_Session;
function Get
(This : Session_Manager;
Id : Valid_Endpoint_Nr)
return SDO_Session;
procedure Put
(This : in out Session_Manager;
Session : in SDO_Session);
function Service
(This : Session_Manager;
Id : Valid_Endpoint_Nr)
return Services;
procedure Clear
(This : in out Session_Manager;
Id : in Valid_Endpoint_Nr);
procedure Clear_Buffer
(This : in out Session_Manager;
Id : in Valid_Endpoint_Nr);
procedure Put_Buffer
(This : in out Session_Manager;
Id : in Valid_Endpoint_Nr;
Data : in ACO.Messages.Data_Array);
function Length_Buffer
(This : Session_Manager;
Id : Valid_Endpoint_Nr)
return Natural;
procedure Get_Buffer
(This : in out Session_Manager;
Id : in Valid_Endpoint_Nr;
Data : out ACO.Messages.Data_Array)
with Pre => Data'Length <= This.Length_Buffer (Id);
function Peek_Buffer
(This : Session_Manager;
Id : Valid_Endpoint_Nr)
return ACO.Messages.Data_Array;
private
package Q is new ACO.Utils.DS.Generic_Queue
(Item_Type => ACO.Messages.Data_Type);
type Session_Array is array (Endpoint_Nr range <>) of SDO_Session;
type Buffer_Array is array (Endpoint_Nr range <>) of
Q.Queue (Max_Nof_Items => ACO.Configuration.Max_SDO_Transfer_Size);
type Session_Manager is tagged limited record
List : Session_Array (Valid_Endpoint_Nr'Range);
Buffers : Buffer_Array (Valid_Endpoint_Nr'Range);
end record;
end ACO.SDO_Sessions;
|
------------------------------------------------------------------------------
-- --
-- GBIND BINDER COMPONENTS --
-- --
-- B I N D U S G --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Osint; use Osint;
with Output; use Output;
procedure Bindusg is
procedure Write_Switch_Char;
-- Write two spaces followed by appropriate switch character
procedure Write_Switch_Char is
begin
Write_Str (" ");
Write_Char (Switch_Character);
end Write_Switch_Char;
-- Start of processing for Bindusg
begin
-- Usage line
Write_Str ("Usage: ");
Write_Program_Name;
Write_Char (' ');
Write_Str ("switches lfile");
Write_Eol;
Write_Eol;
-- Line for -aO switch
Write_Switch_Char;
Write_Str ("aOdir Specify library files search path");
Write_Eol;
-- Line for -aI switch
Write_Switch_Char;
Write_Str ("aIdir Specify source files search path");
Write_Eol;
-- Line for A switch
Write_Switch_Char;
Write_Str ("A Generate binder program in Ada (default)");
Write_Eol;
-- Line for -b switch
Write_Switch_Char;
Write_Str ("b Generate brief messages to std");
Write_Str ("err even if verbose mode set");
Write_Eol;
-- Line for -c switch
Write_Switch_Char;
Write_Str ("c Check only, no generation of b");
Write_Str ("inder output file");
Write_Eol;
-- Line for C switch
Write_Switch_Char;
Write_Str ("C Generate binder program in C");
Write_Eol;
-- Line for -e switch
Write_Switch_Char;
Write_Str ("e Output complete list of elabor");
Write_Str ("ation order dependencies");
Write_Eol;
-- Line for -E switch
Write_Switch_Char;
Write_Str ("E Store tracebacks in Exception occurrences");
Write_Eol;
-- Line for -h switch
Write_Switch_Char;
Write_Str ("h Output this usage (help) infor");
Write_Str ("mation");
Write_Eol;
-- Lines for -I switch
Write_Switch_Char;
Write_Str ("Idir Specify library and source files search path");
Write_Eol;
Write_Switch_Char;
Write_Str ("I- Don't look for sources & library files");
Write_Str (" in default directory");
Write_Eol;
-- Line for -K switch
Write_Switch_Char;
Write_Str ("K Give list of linker options specified for link");
Write_Eol;
-- Line for -l switch
Write_Switch_Char;
Write_Str ("l Output chosen elaboration order");
Write_Eol;
-- Line of -L switch
Write_Switch_Char;
Write_Str ("Lxyz Library build: adainit/final ");
Write_Str ("renamed to xyzinit/final, implies -n");
Write_Eol;
-- Line for -M switch
Write_Switch_Char;
Write_Str ("Mxyz Rename generated main program from main to xyz");
Write_Eol;
-- Line for -m switch
Write_Switch_Char;
Write_Str ("mnnn Limit number of detected error");
Write_Str ("s to nnn (1-999)");
Write_Eol;
-- Line for -n switch
Write_Switch_Char;
Write_Str ("n No Ada main program (foreign main routine)");
Write_Eol;
-- Line for -nostdinc
Write_Switch_Char;
Write_Str ("nostdinc Don't look for source files");
Write_Str (" in the system default directory");
Write_Eol;
-- Line for -nostdlib
Write_Switch_Char;
Write_Str ("nostdlib Don't look for library files");
Write_Str (" in the system default directory");
Write_Eol;
-- Line for -o switch
Write_Switch_Char;
Write_Str ("o file Give the output file name (default is b~xxx.adb) ");
Write_Eol;
-- Line for -O switch
Write_Switch_Char;
Write_Str ("O Give list of objects required for link");
Write_Eol;
-- Line for -p switch
Write_Switch_Char;
Write_Str ("p Pessimistic (worst-case) elaborat");
Write_Str ("ion order");
Write_Eol;
-- Line for -s switch
Write_Switch_Char;
Write_Str ("s Require all source files to be");
Write_Str (" present");
Write_Eol;
-- Line for -Sxx switch
Write_Switch_Char;
Write_Str ("S?? Sin/lo/hi/xx for Initialize_Scalars");
Write_Str (" invalid/low/high/hex");
Write_Eol;
-- Line for -static
Write_Switch_Char;
Write_Str ("static Link against a static GNAT run time");
Write_Eol;
-- Line for -shared
Write_Switch_Char;
Write_Str ("shared Link against a shared GNAT run time");
Write_Eol;
-- Line for -t switch
Write_Switch_Char;
Write_Str ("t Tolerate time stamp and other consistency errors");
Write_Eol;
-- Line for -T switch
Write_Switch_Char;
Write_Str ("Tn Set time slice value to n microseconds (n >= 0)");
Write_Eol;
-- Line for -v switch
Write_Switch_Char;
Write_Str ("v Verbose mode. Error messages, ");
Write_Str ("header, summary output to stdout");
Write_Eol;
-- Lines for -w switch
Write_Switch_Char;
Write_Str ("wx Warning mode. (x=s/e for supp");
Write_Str ("ress/treat as error)");
Write_Eol;
-- Line for -x switch
Write_Switch_Char;
Write_Str ("x Exclude source files (check ob");
Write_Str ("ject consistency only)");
Write_Eol;
-- Line for -z switch
Write_Switch_Char;
Write_Str ("z No main subprogram (zero main)");
Write_Eol;
-- Line for sfile
Write_Str (" lfile Library file names");
Write_Eol;
end Bindusg;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Program.Elements.Declarations is
pragma Pure (Program.Elements.Declarations);
type Declaration is limited interface and Program.Elements.Element;
type Declaration_Access is access all Declaration'Class
with Storage_Size => 0;
end Program.Elements.Declarations;
|
limited
with
openGL.Program;
package openGL.Variable.uniform
--
-- Models a uniform variable for shaders.
--
is
type Item is abstract new Variable.item with private;
---------
-- Forge
--
procedure define (Self : in out Item; Program : access openGL.Program.item'class;
Name : in String);
overriding
procedure destroy (Self : in out Item);
-----------
-- Actuals
--
type bool is new Variable.uniform.item with private;
type int is new Variable.uniform.item with private;
type float is new Variable.uniform.item with private;
type vec3 is new Variable.uniform.item with private;
type vec4 is new Variable.uniform.item with private;
type mat3 is new Variable.uniform.item with private;
type mat4 is new Variable.uniform.item with private;
procedure Value_is (Self : in bool; Now : in Boolean);
procedure Value_is (Self : in int; Now : in Integer);
procedure Value_is (Self : in float; Now : in Real);
procedure Value_is (Self : in vec3; Now : in Vector_3);
procedure Value_is (Self : in vec4; Now : in Vector_4);
procedure Value_is (Self : in mat3; Now : in Matrix_3x3);
procedure Value_is (Self : in mat4; Now : in Matrix_4x4);
private
type Item is abstract new openGL.Variable.item with null record;
type bool is new Variable.uniform.item with null record;
type int is new Variable.uniform.item with null record;
type float is new Variable.uniform.item with null record;
type vec3 is new Variable.uniform.item with null record;
type vec4 is new Variable.uniform.item with null record;
type mat3 is new Variable.uniform.item with null record;
type mat4 is new Variable.uniform.item with null record;
end openGL.Variable.uniform;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . S P E L L I N G _ C H E C K E R _ G E N E R I C --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2020, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Compiler_Unit_Warning;
package body GNAT.Spelling_Checker_Generic is
------------------------
-- Is_Bad_Spelling_Of --
------------------------
function Is_Bad_Spelling_Of
(Found : String_Type;
Expect : String_Type) return Boolean
is
FN : constant Natural := Found'Length;
FF : constant Natural := Found'First;
FL : constant Natural := Found'Last;
EN : constant Natural := Expect'Length;
EF : constant Natural := Expect'First;
EL : constant Natural := Expect'Last;
Letter_o : constant Char_Type := Char_Type'Val (Character'Pos ('o'));
Digit_0 : constant Char_Type := Char_Type'Val (Character'Pos ('0'));
Digit_9 : constant Char_Type := Char_Type'Val (Character'Pos ('9'));
begin
-- If both strings null, then we consider this a match, but if one
-- is null and the other is not, then we definitely do not match
if FN = 0 then
return (EN = 0);
elsif EN = 0 then
return False;
-- If first character does not match, then we consider that this is
-- definitely not a misspelling. An exception is when we expect a
-- letter O and found a zero.
elsif Found (FF) /= Expect (EF)
and then (Found (FF) /= Digit_0 or else Expect (EF) /= Letter_o)
then
return False;
-- Not a bad spelling if both strings are 1-2 characters long
elsif FN < 3 and then EN < 3 then
return False;
-- Lengths match. Execute loop to check for a single error, single
-- transposition or exact match (we only fall through this loop if
-- one of these three conditions is found).
elsif FN = EN then
for J in 1 .. FN - 2 loop
if Expect (EF + J) /= Found (FF + J) then
-- If both mismatched characters are digits, then we do
-- not consider it a misspelling (e.g. B345 is not a
-- misspelling of B346, it is something quite different)
if Expect (EF + J) in Digit_0 .. Digit_9
and then Found (FF + J) in Digit_0 .. Digit_9
then
return False;
elsif Expect (EF + J + 1) = Found (FF + J + 1)
and then Expect (EF + J + 2 .. EL) = Found (FF + J + 2 .. FL)
then
return True;
elsif Expect (EF + J) = Found (FF + J + 1)
and then Expect (EF + J + 1) = Found (FF + J)
and then Expect (EF + J + 2 .. EL) = Found (FF + J + 2 .. FL)
then
return True;
else
return False;
end if;
end if;
end loop;
-- At last character. Test digit case as above, otherwise we
-- have a match since at most this last character fails to match.
if Expect (EL) in Digit_0 .. Digit_9
and then Found (FL) in Digit_0 .. Digit_9
and then Expect (EL) /= Found (FL)
then
return False;
else
return True;
end if;
-- Length is 1 too short. Execute loop to check for single deletion
elsif FN = EN - 1 then
for J in 1 .. FN - 1 loop
if Found (FF + J) /= Expect (EF + J) then
return Found (FF + J .. FL) = Expect (EF + J + 1 .. EL);
end if;
end loop;
-- If we fall through then the last character was missing, which
-- we consider to be a match (e.g. found xyz, expected xyza).
return True;
-- Length is 1 too long. Execute loop to check for single insertion
elsif FN = EN + 1 then
for J in 1 .. EN - 1 loop
if Found (FF + J) /= Expect (EF + J) then
return Found (FF + J + 1 .. FL) = Expect (EF + J .. EL);
end if;
end loop;
-- If we fall through then the last character was an additional
-- character, which is a match (e.g. found xyza, expected xyz).
return True;
-- Length is completely wrong
else
return False;
end if;
end Is_Bad_Spelling_Of;
end GNAT.Spelling_Checker_Generic;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
package AMF.Internals.Tables.CMOF_Metamodel.Links is
procedure Initialize;
private
procedure Initialize_1;
procedure Initialize_2;
procedure Initialize_3;
procedure Initialize_4;
procedure Initialize_5;
procedure Initialize_6;
procedure Initialize_7;
procedure Initialize_8;
procedure Initialize_9;
procedure Initialize_10;
procedure Initialize_11;
procedure Initialize_12;
procedure Initialize_13;
procedure Initialize_14;
procedure Initialize_15;
procedure Initialize_16;
procedure Initialize_17;
procedure Initialize_18;
procedure Initialize_19;
procedure Initialize_20;
procedure Initialize_21;
procedure Initialize_22;
procedure Initialize_23;
procedure Initialize_24;
procedure Initialize_25;
procedure Initialize_26;
procedure Initialize_27;
procedure Initialize_28;
procedure Initialize_29;
procedure Initialize_30;
procedure Initialize_31;
procedure Initialize_32;
procedure Initialize_33;
procedure Initialize_34;
procedure Initialize_35;
procedure Initialize_36;
procedure Initialize_37;
procedure Initialize_38;
procedure Initialize_39;
procedure Initialize_40;
procedure Initialize_41;
procedure Initialize_42;
procedure Initialize_43;
procedure Initialize_44;
procedure Initialize_45;
procedure Initialize_46;
procedure Initialize_47;
procedure Initialize_48;
procedure Initialize_49;
procedure Initialize_50;
procedure Initialize_51;
procedure Initialize_52;
procedure Initialize_53;
procedure Initialize_54;
procedure Initialize_55;
procedure Initialize_56;
procedure Initialize_57;
procedure Initialize_58;
procedure Initialize_59;
procedure Initialize_60;
procedure Initialize_61;
procedure Initialize_62;
procedure Initialize_63;
procedure Initialize_64;
procedure Initialize_65;
procedure Initialize_66;
procedure Initialize_67;
procedure Initialize_68;
procedure Initialize_69;
procedure Initialize_70;
procedure Initialize_71;
procedure Initialize_72;
procedure Initialize_73;
procedure Initialize_74;
procedure Initialize_75;
procedure Initialize_76;
procedure Initialize_77;
procedure Initialize_78;
procedure Initialize_79;
procedure Initialize_80;
procedure Initialize_81;
procedure Initialize_82;
procedure Initialize_83;
procedure Initialize_84;
procedure Initialize_85;
procedure Initialize_86;
procedure Initialize_87;
procedure Initialize_88;
procedure Initialize_89;
procedure Initialize_90;
procedure Initialize_91;
procedure Initialize_92;
procedure Initialize_93;
procedure Initialize_94;
procedure Initialize_95;
procedure Initialize_96;
procedure Initialize_97;
procedure Initialize_98;
procedure Initialize_99;
procedure Initialize_100;
procedure Initialize_101;
procedure Initialize_102;
procedure Initialize_103;
procedure Initialize_104;
procedure Initialize_105;
procedure Initialize_106;
procedure Initialize_107;
procedure Initialize_108;
procedure Initialize_109;
procedure Initialize_110;
procedure Initialize_111;
procedure Initialize_112;
procedure Initialize_113;
procedure Initialize_114;
procedure Initialize_115;
procedure Initialize_116;
procedure Initialize_117;
procedure Initialize_118;
procedure Initialize_119;
procedure Initialize_120;
procedure Initialize_121;
procedure Initialize_122;
procedure Initialize_123;
procedure Initialize_124;
procedure Initialize_125;
procedure Initialize_126;
procedure Initialize_127;
procedure Initialize_128;
procedure Initialize_129;
procedure Initialize_130;
procedure Initialize_131;
procedure Initialize_132;
procedure Initialize_133;
procedure Initialize_134;
procedure Initialize_135;
procedure Initialize_136;
procedure Initialize_137;
procedure Initialize_138;
procedure Initialize_139;
procedure Initialize_140;
procedure Initialize_141;
procedure Initialize_142;
procedure Initialize_143;
procedure Initialize_144;
procedure Initialize_145;
procedure Initialize_146;
procedure Initialize_147;
procedure Initialize_148;
procedure Initialize_149;
procedure Initialize_150;
procedure Initialize_151;
procedure Initialize_152;
procedure Initialize_153;
procedure Initialize_154;
procedure Initialize_155;
procedure Initialize_156;
procedure Initialize_157;
procedure Initialize_158;
procedure Initialize_159;
procedure Initialize_160;
procedure Initialize_161;
procedure Initialize_162;
procedure Initialize_163;
procedure Initialize_164;
procedure Initialize_165;
procedure Initialize_166;
procedure Initialize_167;
procedure Initialize_168;
procedure Initialize_169;
procedure Initialize_170;
procedure Initialize_171;
procedure Initialize_172;
procedure Initialize_173;
procedure Initialize_174;
procedure Initialize_175;
procedure Initialize_176;
procedure Initialize_177;
procedure Initialize_178;
procedure Initialize_179;
procedure Initialize_180;
procedure Initialize_181;
procedure Initialize_182;
procedure Initialize_183;
procedure Initialize_184;
procedure Initialize_185;
procedure Initialize_186;
procedure Initialize_187;
procedure Initialize_188;
procedure Initialize_189;
procedure Initialize_190;
procedure Initialize_191;
procedure Initialize_192;
procedure Initialize_193;
procedure Initialize_194;
procedure Initialize_195;
procedure Initialize_196;
procedure Initialize_197;
procedure Initialize_198;
procedure Initialize_199;
procedure Initialize_200;
procedure Initialize_201;
procedure Initialize_202;
procedure Initialize_203;
procedure Initialize_204;
procedure Initialize_205;
procedure Initialize_206;
procedure Initialize_207;
procedure Initialize_208;
procedure Initialize_209;
procedure Initialize_210;
procedure Initialize_211;
procedure Initialize_212;
procedure Initialize_213;
procedure Initialize_214;
procedure Initialize_215;
procedure Initialize_216;
procedure Initialize_217;
procedure Initialize_218;
procedure Initialize_219;
procedure Initialize_220;
procedure Initialize_221;
procedure Initialize_222;
procedure Initialize_223;
procedure Initialize_224;
procedure Initialize_225;
procedure Initialize_226;
procedure Initialize_227;
procedure Initialize_228;
procedure Initialize_229;
procedure Initialize_230;
procedure Initialize_231;
procedure Initialize_232;
procedure Initialize_233;
procedure Initialize_234;
procedure Initialize_235;
procedure Initialize_236;
procedure Initialize_237;
procedure Initialize_238;
procedure Initialize_239;
procedure Initialize_240;
procedure Initialize_241;
procedure Initialize_242;
procedure Initialize_243;
procedure Initialize_244;
procedure Initialize_245;
procedure Initialize_246;
procedure Initialize_247;
procedure Initialize_248;
procedure Initialize_249;
procedure Initialize_250;
procedure Initialize_251;
procedure Initialize_252;
procedure Initialize_253;
procedure Initialize_254;
procedure Initialize_255;
procedure Initialize_256;
procedure Initialize_257;
procedure Initialize_258;
procedure Initialize_259;
procedure Initialize_260;
procedure Initialize_261;
procedure Initialize_262;
procedure Initialize_263;
procedure Initialize_264;
procedure Initialize_265;
procedure Initialize_266;
procedure Initialize_267;
procedure Initialize_268;
procedure Initialize_269;
procedure Initialize_270;
procedure Initialize_271;
procedure Initialize_272;
procedure Initialize_273;
procedure Initialize_274;
procedure Initialize_275;
procedure Initialize_276;
procedure Initialize_277;
procedure Initialize_278;
procedure Initialize_279;
procedure Initialize_280;
procedure Initialize_281;
procedure Initialize_282;
procedure Initialize_283;
procedure Initialize_284;
procedure Initialize_285;
procedure Initialize_286;
procedure Initialize_287;
procedure Initialize_288;
procedure Initialize_289;
procedure Initialize_290;
procedure Initialize_291;
procedure Initialize_292;
procedure Initialize_293;
procedure Initialize_294;
procedure Initialize_295;
procedure Initialize_296;
procedure Initialize_297;
procedure Initialize_298;
procedure Initialize_299;
procedure Initialize_300;
procedure Initialize_301;
procedure Initialize_302;
procedure Initialize_303;
procedure Initialize_304;
procedure Initialize_305;
procedure Initialize_306;
procedure Initialize_307;
procedure Initialize_308;
procedure Initialize_309;
procedure Initialize_310;
procedure Initialize_311;
procedure Initialize_312;
procedure Initialize_313;
procedure Initialize_314;
procedure Initialize_315;
procedure Initialize_316;
procedure Initialize_317;
procedure Initialize_318;
procedure Initialize_319;
procedure Initialize_320;
procedure Initialize_321;
procedure Initialize_322;
procedure Initialize_323;
procedure Initialize_324;
procedure Initialize_325;
procedure Initialize_326;
procedure Initialize_327;
procedure Initialize_328;
procedure Initialize_329;
procedure Initialize_330;
procedure Initialize_331;
procedure Initialize_332;
procedure Initialize_333;
procedure Initialize_334;
procedure Initialize_335;
procedure Initialize_336;
procedure Initialize_337;
procedure Initialize_338;
procedure Initialize_339;
procedure Initialize_340;
procedure Initialize_341;
procedure Initialize_342;
procedure Initialize_343;
procedure Initialize_344;
procedure Initialize_345;
procedure Initialize_346;
procedure Initialize_347;
procedure Initialize_348;
procedure Initialize_349;
procedure Initialize_350;
procedure Initialize_351;
procedure Initialize_352;
procedure Initialize_353;
procedure Initialize_354;
procedure Initialize_355;
procedure Initialize_356;
procedure Initialize_357;
procedure Initialize_358;
procedure Initialize_359;
procedure Initialize_360;
procedure Initialize_361;
procedure Initialize_362;
procedure Initialize_363;
procedure Initialize_364;
procedure Initialize_365;
procedure Initialize_366;
procedure Initialize_367;
procedure Initialize_368;
procedure Initialize_369;
procedure Initialize_370;
procedure Initialize_371;
procedure Initialize_372;
procedure Initialize_373;
procedure Initialize_374;
procedure Initialize_375;
procedure Initialize_376;
procedure Initialize_377;
procedure Initialize_378;
procedure Initialize_379;
procedure Initialize_380;
procedure Initialize_381;
procedure Initialize_382;
procedure Initialize_383;
procedure Initialize_384;
procedure Initialize_385;
procedure Initialize_386;
procedure Initialize_387;
procedure Initialize_388;
procedure Initialize_389;
procedure Initialize_390;
procedure Initialize_391;
procedure Initialize_392;
procedure Initialize_393;
procedure Initialize_394;
procedure Initialize_395;
procedure Initialize_396;
procedure Initialize_397;
procedure Initialize_398;
procedure Initialize_399;
procedure Initialize_400;
procedure Initialize_401;
procedure Initialize_402;
procedure Initialize_403;
procedure Initialize_404;
procedure Initialize_405;
procedure Initialize_406;
procedure Initialize_407;
procedure Initialize_408;
procedure Initialize_409;
procedure Initialize_410;
procedure Initialize_411;
procedure Initialize_412;
procedure Initialize_413;
procedure Initialize_414;
procedure Initialize_415;
procedure Initialize_416;
procedure Initialize_417;
procedure Initialize_418;
procedure Initialize_419;
procedure Initialize_420;
procedure Initialize_421;
procedure Initialize_422;
procedure Initialize_423;
procedure Initialize_424;
procedure Initialize_425;
procedure Initialize_426;
procedure Initialize_427;
procedure Initialize_428;
procedure Initialize_429;
procedure Initialize_430;
procedure Initialize_431;
procedure Initialize_432;
procedure Initialize_433;
procedure Initialize_434;
procedure Initialize_435;
procedure Initialize_436;
procedure Initialize_437;
procedure Initialize_438;
procedure Initialize_439;
procedure Initialize_440;
procedure Initialize_441;
procedure Initialize_442;
procedure Initialize_443;
procedure Initialize_444;
procedure Initialize_445;
procedure Initialize_446;
procedure Initialize_447;
procedure Initialize_448;
procedure Initialize_449;
procedure Initialize_450;
procedure Initialize_451;
procedure Initialize_452;
procedure Initialize_453;
procedure Initialize_454;
procedure Initialize_455;
procedure Initialize_456;
procedure Initialize_457;
procedure Initialize_458;
procedure Initialize_459;
procedure Initialize_460;
procedure Initialize_461;
procedure Initialize_462;
procedure Initialize_463;
procedure Initialize_464;
procedure Initialize_465;
procedure Initialize_466;
procedure Initialize_467;
procedure Initialize_468;
procedure Initialize_469;
procedure Initialize_470;
procedure Initialize_471;
procedure Initialize_472;
procedure Initialize_473;
procedure Initialize_474;
procedure Initialize_475;
procedure Initialize_476;
procedure Initialize_477;
procedure Initialize_478;
procedure Initialize_479;
procedure Initialize_480;
procedure Initialize_481;
procedure Initialize_482;
procedure Initialize_483;
procedure Initialize_484;
procedure Initialize_485;
procedure Initialize_486;
procedure Initialize_487;
procedure Initialize_488;
procedure Initialize_489;
procedure Initialize_490;
procedure Initialize_491;
procedure Initialize_492;
procedure Initialize_493;
procedure Initialize_494;
procedure Initialize_495;
procedure Initialize_496;
procedure Initialize_497;
procedure Initialize_498;
procedure Initialize_499;
procedure Initialize_500;
procedure Initialize_501;
procedure Initialize_502;
procedure Initialize_503;
procedure Initialize_504;
procedure Initialize_505;
procedure Initialize_506;
procedure Initialize_507;
procedure Initialize_508;
procedure Initialize_509;
procedure Initialize_510;
procedure Initialize_511;
procedure Initialize_512;
procedure Initialize_513;
procedure Initialize_514;
procedure Initialize_515;
procedure Initialize_516;
procedure Initialize_517;
procedure Initialize_518;
procedure Initialize_519;
procedure Initialize_520;
procedure Initialize_521;
procedure Initialize_522;
procedure Initialize_523;
procedure Initialize_524;
procedure Initialize_525;
procedure Initialize_526;
procedure Initialize_527;
procedure Initialize_528;
procedure Initialize_529;
procedure Initialize_530;
procedure Initialize_531;
procedure Initialize_532;
procedure Initialize_533;
procedure Initialize_534;
procedure Initialize_535;
procedure Initialize_536;
procedure Initialize_537;
procedure Initialize_538;
procedure Initialize_539;
procedure Initialize_540;
procedure Initialize_541;
procedure Initialize_542;
procedure Initialize_543;
procedure Initialize_544;
procedure Initialize_545;
procedure Initialize_546;
procedure Initialize_547;
procedure Initialize_548;
procedure Initialize_549;
procedure Initialize_550;
procedure Initialize_551;
procedure Initialize_552;
procedure Initialize_553;
procedure Initialize_554;
procedure Initialize_555;
procedure Initialize_556;
procedure Initialize_557;
procedure Initialize_558;
procedure Initialize_559;
procedure Initialize_560;
procedure Initialize_561;
procedure Initialize_562;
procedure Initialize_563;
procedure Initialize_564;
procedure Initialize_565;
procedure Initialize_566;
procedure Initialize_567;
procedure Initialize_568;
procedure Initialize_569;
procedure Initialize_570;
procedure Initialize_571;
procedure Initialize_572;
procedure Initialize_573;
procedure Initialize_574;
procedure Initialize_575;
procedure Initialize_576;
procedure Initialize_577;
procedure Initialize_578;
procedure Initialize_579;
procedure Initialize_580;
procedure Initialize_581;
procedure Initialize_582;
procedure Initialize_583;
procedure Initialize_584;
procedure Initialize_585;
procedure Initialize_586;
procedure Initialize_587;
procedure Initialize_588;
procedure Initialize_589;
procedure Initialize_590;
procedure Initialize_591;
procedure Initialize_592;
procedure Initialize_593;
procedure Initialize_594;
procedure Initialize_595;
procedure Initialize_596;
procedure Initialize_597;
procedure Initialize_598;
procedure Initialize_599;
procedure Initialize_600;
procedure Initialize_601;
procedure Initialize_602;
procedure Initialize_603;
procedure Initialize_604;
procedure Initialize_605;
procedure Initialize_606;
procedure Initialize_607;
procedure Initialize_608;
procedure Initialize_609;
procedure Initialize_610;
procedure Initialize_611;
procedure Initialize_612;
procedure Initialize_613;
procedure Initialize_614;
procedure Initialize_615;
procedure Initialize_616;
procedure Initialize_617;
procedure Initialize_618;
procedure Initialize_619;
procedure Initialize_620;
procedure Initialize_621;
procedure Initialize_622;
procedure Initialize_623;
procedure Initialize_624;
procedure Initialize_625;
procedure Initialize_626;
procedure Initialize_627;
procedure Initialize_628;
procedure Initialize_629;
procedure Initialize_630;
procedure Initialize_631;
procedure Initialize_632;
procedure Initialize_633;
procedure Initialize_634;
procedure Initialize_635;
procedure Initialize_636;
procedure Initialize_637;
procedure Initialize_638;
procedure Initialize_639;
procedure Initialize_640;
procedure Initialize_641;
procedure Initialize_642;
procedure Initialize_643;
procedure Initialize_644;
procedure Initialize_645;
procedure Initialize_646;
procedure Initialize_647;
procedure Initialize_648;
procedure Initialize_649;
procedure Initialize_650;
procedure Initialize_651;
procedure Initialize_652;
procedure Initialize_653;
procedure Initialize_654;
procedure Initialize_655;
procedure Initialize_656;
procedure Initialize_657;
procedure Initialize_658;
procedure Initialize_659;
procedure Initialize_660;
procedure Initialize_661;
procedure Initialize_662;
procedure Initialize_663;
procedure Initialize_664;
procedure Initialize_665;
procedure Initialize_666;
procedure Initialize_667;
procedure Initialize_668;
procedure Initialize_669;
procedure Initialize_670;
procedure Initialize_671;
procedure Initialize_672;
procedure Initialize_673;
procedure Initialize_674;
procedure Initialize_675;
procedure Initialize_676;
procedure Initialize_677;
procedure Initialize_678;
procedure Initialize_679;
procedure Initialize_680;
procedure Initialize_681;
procedure Initialize_682;
procedure Initialize_683;
procedure Initialize_684;
procedure Initialize_685;
procedure Initialize_686;
procedure Initialize_687;
procedure Initialize_688;
procedure Initialize_689;
procedure Initialize_690;
procedure Initialize_691;
procedure Initialize_692;
procedure Initialize_693;
procedure Initialize_694;
procedure Initialize_695;
procedure Initialize_696;
procedure Initialize_697;
procedure Initialize_698;
procedure Initialize_699;
procedure Initialize_700;
procedure Initialize_701;
procedure Initialize_702;
procedure Initialize_703;
procedure Initialize_704;
procedure Initialize_705;
procedure Initialize_706;
procedure Initialize_707;
procedure Initialize_708;
procedure Initialize_709;
procedure Initialize_710;
procedure Initialize_711;
procedure Initialize_712;
procedure Initialize_713;
procedure Initialize_714;
procedure Initialize_715;
procedure Initialize_716;
procedure Initialize_717;
procedure Initialize_718;
procedure Initialize_719;
procedure Initialize_720;
procedure Initialize_721;
procedure Initialize_722;
procedure Initialize_723;
procedure Initialize_724;
procedure Initialize_725;
procedure Initialize_726;
procedure Initialize_727;
procedure Initialize_728;
procedure Initialize_729;
procedure Initialize_730;
procedure Initialize_731;
procedure Initialize_732;
procedure Initialize_733;
procedure Initialize_734;
procedure Initialize_735;
procedure Initialize_736;
procedure Initialize_737;
procedure Initialize_738;
procedure Initialize_739;
procedure Initialize_740;
procedure Initialize_741;
procedure Initialize_742;
procedure Initialize_743;
procedure Initialize_744;
procedure Initialize_745;
procedure Initialize_746;
procedure Initialize_747;
procedure Initialize_748;
procedure Initialize_749;
procedure Initialize_750;
procedure Initialize_751;
procedure Initialize_752;
procedure Initialize_753;
procedure Initialize_754;
procedure Initialize_755;
procedure Initialize_756;
procedure Initialize_757;
procedure Initialize_758;
procedure Initialize_759;
procedure Initialize_760;
procedure Initialize_761;
procedure Initialize_762;
procedure Initialize_763;
procedure Initialize_764;
procedure Initialize_765;
procedure Initialize_766;
procedure Initialize_767;
procedure Initialize_768;
procedure Initialize_769;
procedure Initialize_770;
procedure Initialize_771;
procedure Initialize_772;
procedure Initialize_773;
procedure Initialize_774;
procedure Initialize_775;
procedure Initialize_776;
procedure Initialize_777;
procedure Initialize_778;
procedure Initialize_779;
procedure Initialize_780;
procedure Initialize_781;
procedure Initialize_782;
procedure Initialize_783;
procedure Initialize_784;
procedure Initialize_785;
procedure Initialize_786;
procedure Initialize_787;
procedure Initialize_788;
procedure Initialize_789;
procedure Initialize_790;
procedure Initialize_791;
procedure Initialize_792;
procedure Initialize_793;
procedure Initialize_794;
procedure Initialize_795;
procedure Initialize_796;
procedure Initialize_797;
procedure Initialize_798;
procedure Initialize_799;
procedure Initialize_800;
end AMF.Internals.Tables.CMOF_Metamodel.Links;
|
with Ada.Containers.Ordered_Maps;
use Ada.Containers;
with Memory.Container; use Memory.Container;
generic
type Value_Type is range <>;
with function Get_Value(mem : access Memory_Type'Class) return Value_Type;
package Memory.Super is
type Super_Type is new Container_Type with private;
type Super_Pointer is access all Super_Type'Class;
function Create_Super(mem : not null access Memory_Type'Class;
max_cost : Cost_Type;
seed : Integer;
max_iterations : Long_Integer;
permute_only : Boolean)
return Super_Pointer;
overriding
function Done(mem : Super_Type) return Boolean;
overriding
function Clone(mem : Super_Type) return Memory_Pointer;
overriding
procedure Reset(mem : in out Super_Type;
context : in Natural);
overriding
procedure Read(mem : in out Super_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Write(mem : in out Super_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Idle(mem : in out Super_Type;
cycles : in Time_Type);
overriding
procedure Show_Stats(mem : in out Super_Type);
overriding
procedure Show_Access_Stats(mem : in out Super_Type);
overriding
procedure Adjust(mem : in out Super_Type);
overriding
procedure Finalize(mem : in out Super_Type);
private
package Value_Vectors is new Vectors(Natural, Value_Type);
type Result_Type is record
value : Value_Type;
context_values : Value_Vectors.Vector;
end record;
package Value_Maps is new Ordered_Maps(Unbounded_String, Result_Type);
type Context_Type is record
index : Natural := 0;
value : Value_Type := Value_Type'Last;
last_value : Value_Type := Value_Type'Last;
total_length : Long_Integer := 0;
end record;
type Context_Pointer is access all Context_Type;
package Context_Vectors is new Vectors(Natural, Context_Pointer);
type Super_Type is new Container_Type with record
max_cost : Cost_Type := 1e6;
permute_only : Boolean := False;
generator : Distribution_Pointer := null;
current_length : Long_Integer := 0;
best_name : Unbounded_String := Null_Unbounded_String;
best_cost : Cost_Type := Cost_Type'Last;
best_value : Value_Type := Value_Type'Last;
last : Memory_Pointer := null;
current : Memory_Pointer := null;
contexts : Context_Vectors.Vector;
context : Context_Pointer := null;
last_value : Value_Type := Value_Type'Last;
table : Value_Maps.Map;
total : Long_Integer := 0;
max_iterations : Long_Integer := 1000;
steps : Long_Integer := 0;
iteration : Long_Integer := 0;
improvement : Value_Type := 0;
threshold : Long_Integer := 0;
has_idle : Boolean := False;
age : Long_Integer := 0;
end record;
end Memory.Super;
|
generic
type Real is digits <>;
package pc_2_coeff_18 is
subtype PC_Rule_Range is Integer range 0..31;
type Integration_Rule is array(PC_Rule_Range) of Real;
Starting_Id_of_First_Deriv_of_Y : constant PC_Rule_Range := 15;
-- Center_Integration Rule, applied to (d/dt)**2 Y, takes a dY/dt here, and
-- Integrates it one indice forward.
Extrap_Factor: constant Real := 1.0 / 15.5;
-- bst val unkown
Corrector_33_18 : constant Integration_Rule :=
(
-1.35951861799309381059455538426319930E-3,
1.39069403769245073144165593536988958E-2,
-5.83205346578877942952080408672201944E-2,
1.21290301174823107677707609652576441E-1,
-1.03815142756802743183588371166416289E-1,
-4.27802041635694502134496267996755801E-2,
1.17126983342484528927697815213303907E-1,
3.68322889302523002238108271688083306E-2,
-1.15800654486395812696752995479150700E-1,
-7.37839951350917231438965017337920689E-2,
9.38463970073461607542198031787119609E-2,
1.31051664970486218723153354971299777E-1,
-2.90086445263299000413187326241752033E-2,
-1.80292630197441416214923219988739258E-1,
-9.56253701553319675154872566782690037E-2,
2.27775332905438320998277548107118823E-1,
5.94380042428699500158468776730385484E-1,
8.33175208629989653492248737298748037E-1,
9.44044382044241577544618992186682566E-1,
1.02177197582947154009036351482437911E+0,
1.08857915576829483296832744769464273E+0,
1.06986153060073770155201800351931421E+0,
9.50876301815938789122007035674209926E-1,
8.78111582425428946745489478120962881E-1,
9.88815710821029335916106998357035867E-1,
1.14604737781767946383245911604088728E+0,
1.05698942635864164658554335004650286E+0,
8.17374447049483441764980683646452406E-1,
9.56301707643009727387335727526781325E-1,
1.28329933268294760931160183469879052E+0,
7.31956749168108562717815358210066410E-1,
1.03680730728164797463273160529279989E+0
);
Final_Step_Corrector_33_18 : constant Real
:= 6.05645476237384526738191232075418243E-2 ;
Predictor_31_18 : constant Integration_Rule :=
(
0.0,
3.56361383829876663908202663432523049E-2,
-3.90115431830533838249464551057563900E-1,
1.78974996633552556955863257920310828E+0,
-4.26256658077616969563823580036343224E+0,
4.90043667525590088833459699341871099E+0,
-4.70862296148502239830195705149125177E-1,
-4.49357603117391363006679359459962841E+0,
1.50171715249090140377590236828470534E+0,
4.43155537264151183660434474594022823E+0,
-9.33868987092458594566878453840375056E-1,
-4.72180738311164007903894635956852030E+0,
-6.40576136789559223193020310311596967E-1,
4.58752246905007629974206802968938497E+0,
2.75185638998815803105061749908133753E+0,
-3.34956538433427805768986116098092101E+0,
-4.28530998366928727977551363779637932E+0,
2.03383834159954888789260942603367790E+0,
6.81893831992471129792141844118907659E+0,
2.77963176186441467985847677876483811E+0,
-4.45945614820928833160857583092101435E+0,
-3.38930729033696435644315609998667567E+0,
5.38471129781688911689742385002121398E+0,
7.34172110019758723768537641534571270E+0,
-2.76023902746570191689933141843508085E+0,
-6.72460159833145499564694539832600231E+0,
6.60545490512954816152653426962027766E+0,
8.43435599437051781540338217837694035E+0,
-1.25883146789052319624260902981072823E+1,
1.05691950461243463885599769995546878E+1,
-2.73317076827908445236706307884373467E+0,
1.73701679528144337223789085742017981E+0
);
Center_Integration_32_19 : constant Integration_Rule :=
(
-1.41501156931067545191501312733094102E-4,
1.69441133195312502336968604787743340E-3,
-8.61544295798328561307030279365738855E-3,
2.32522477143118426176052393367656539E-2,
-3.20373760649639632990583205373993766E-2,
9.68311879655490404918829221544626281E-3,
2.98405558251770724450545901773275631E-2,
-2.11932635560042163342688677276285795E-2,
-3.40139641520665797927076418961388228E-2,
2.39929365151054090972351826201286669E-2,
5.03980165053735885315830844386504085E-2,
-1.67572033593255648996289991156556072E-2,
-8.55143893368475698891050162052229503E-2,
-1.68019530527635752538536469121305871E-2,
1.93391342763102570230011006236692833E-1,
3.82822464185307310632837215427677584E-1,
3.82822464185307310632837215427677584E-1,
1.93391342763102570230011006236692833E-1,
-1.68019530527635752538536469121305871E-2,
-8.55143893368475698891050162052229503E-2,
-1.67572033593255648996289991156556072E-2,
5.03980165053735885315830844386504085E-2,
2.39929365151054090972351826201286669E-2,
-3.40139641520665797927076418961388228E-2,
-2.11932635560042163342688677276285795E-2,
2.98405558251770724450545901773275631E-2,
9.68311879655490404918829221544626281E-3,
-3.20373760649639632990583205373993766E-2,
2.32522477143118426176052393367656539E-2,
-8.61544295798328561307030279365738855E-3,
1.69441133195312502336968604787743340E-3,
-1.41501156931067545191501312733094102E-4
);
Center_to_End_Integration_32_18 : constant Integration_Rule :=
(
-3.81770184777346623380110569542835949E-3,
4.05600481305225100431771731724661383E-2,
-1.78960644404925372155519107371264318E-1,
4.02508354852081736538337070981740472E-1,
-4.12245799146607050239645603322640102E-1,
-4.06676030795254271581852584036984669E-2,
4.20151487442417894541575652148503997E-1,
-2.63013726968328025656416239579759775E-2,
-4.25619930761715939528547616857059305E-1,
-5.66802595575916095145500076613340765E-2,
4.25527513387221442576512226976097047E-1,
2.31262001614811935088168103429958614E-1,
-3.54671787412183713725830087525134388E-1,
-4.44275799650857522124612780257402912E-1,
2.15801588255155647477266607274874694E-1,
9.44639451210398769642450115072372853E-1,
1.04980974043523524722608788434861985E+0,
7.05326515239133104060285019090603847E-1,
6.53898395033922918460650307229914001E-1,
1.13547472673928814316237387397538743E+0,
1.49277644993555361140496691744320562E+0,
1.10847506246039448251194288375408286E+0,
4.76138798599908430383423645923217131E-1,
6.67671928363033884979230291153735253E-1,
1.53139154452707130637511206372170441E+0,
1.47871903260463646091317780357858152E+0,
3.05010171092012642651902250995572496E-1,
6.02890153641317548216223444193499566E-1,
2.26479708327785878199402453266040609E+0,
-1.53010632749539244412148010944865189E-1,
1.66734269407645484183803198957998877E+0,
2.76078790389120807573561345292270384E-1
);
Predictor_Rule : Integration_Rule renames Predictor_31_18;
Corrector_Rule : Integration_Rule renames Corrector_33_18;
Center_Integration : Integration_Rule renames Center_Integration_32_19;
Center_to_End_Integration
: Integration_Rule renames Center_to_End_Integration_32_18;
Final_Step_Corrector : Real renames Final_Step_Corrector_33_18;
end pc_2_coeff_18;
|
-----------------------------------------------------------------------
-- Faces Context Tests - Unit tests for ASF.Contexts.Faces
-- Copyright (C) 2010, 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Ada.Calendar.Formatting;
with Util.Beans.Objects.Time;
with Util.Test_Caller;
with ASF.Tests;
with ASF.Components.Html.Text;
with ASF.Converters.Dates;
package body ASF.Converters.Tests is
use Util.Tests;
use ASF.Converters.Dates;
package Caller is new Util.Test_Caller (Test, "Converters");
procedure Test_Date_Conversion (T : in out Test;
Date_Style : in Dates.Style_Type;
Time_Style : in Dates.Style_Type;
Expect : in String);
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 ASF.Converters.Dates.To_String (Date, Short)",
Test_Date_Short_Converter'Access);
Caller.Add_Test (Suite, "Test ASF.Converters.Dates.To_String (Date, Medium)",
Test_Date_Medium_Converter'Access);
Caller.Add_Test (Suite, "Test ASF.Converters.Dates.To_String (Date, Long)",
Test_Date_Long_Converter'Access);
Caller.Add_Test (Suite, "Test ASF.Converters.Dates.To_String (Date, Full)",
Test_Date_Full_Converter'Access);
Caller.Add_Test (Suite, "Test ASF.Converters.Dates.To_String (Time, Short)",
Test_Time_Short_Converter'Access);
Caller.Add_Test (Suite, "Test ASF.Converters.Dates.To_String (Time, Medium)",
Test_Time_Medium_Converter'Access);
Caller.Add_Test (Suite, "Test ASF.Converters.Dates.To_String (Time, Long)",
Test_Time_Long_Converter'Access);
end Add_Tests;
-- ------------------------------
-- Test getting an attribute from the faces context.
-- ------------------------------
procedure Test_Date_Conversion (T : in out Test;
Date_Style : in Dates.Style_Type;
Time_Style : in Dates.Style_Type;
Expect : in String) is
Ctx : aliased ASF.Contexts.Faces.Faces_Context;
UI : ASF.Components.Html.Text.UIOutput;
C : ASF.Converters.Dates.Date_Converter_Access;
D : constant Ada.Calendar.Time := Ada.Calendar.Formatting.Time_Of (2011, 11, 19,
3, 4, 5);
begin
T.Setup (Ctx);
ASF.Contexts.Faces.Set_Current (Ctx'Unchecked_Access, ASF.Tests.Get_Application.all'Access);
if Date_Style = Dates.DEFAULT then
C := ASF.Converters.Dates.Create_Date_Converter (Date => Date_Style,
Time => Time_Style,
Format => ASF.Converters.Dates.TIME,
Locale => "en",
Pattern => "");
elsif Time_Style = Dates.DEFAULT then
C := ASF.Converters.Dates.Create_Date_Converter (Date => Date_Style,
Time => Time_Style,
Format => ASF.Converters.Dates.DATE,
Locale => "en",
Pattern => "");
else
C := ASF.Converters.Dates.Create_Date_Converter (Date => Date_Style,
Time => Time_Style,
Format => ASF.Converters.Dates.BOTH,
Locale => "en",
Pattern => "");
end if;
UI.Set_Converter (C.all'Access);
declare
R : constant String := C.To_String (Ctx, UI, Util.Beans.Objects.Time.To_Object (D));
begin
Util.Tests.Assert_Equals (T, Expect, R, "Invalid date conversion");
end;
end Test_Date_Conversion;
-- ------------------------------
-- Test the date short converter.
-- ------------------------------
procedure Test_Date_Short_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.SHORT, ASF.Converters.Dates.DEFAULT,
"19/11/2011");
end Test_Date_Short_Converter;
-- ------------------------------
-- Test the date medium converter.
-- ------------------------------
procedure Test_Date_Medium_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.MEDIUM, ASF.Converters.Dates.DEFAULT,
"Nov 19, 2011");
end Test_Date_Medium_Converter;
-- ------------------------------
-- Test the date long converter.
-- ------------------------------
procedure Test_Date_Long_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.LONG, ASF.Converters.Dates.DEFAULT,
"November 19, 2011");
end Test_Date_Long_Converter;
-- ------------------------------
-- Test the date full converter.
-- ------------------------------
procedure Test_Date_Full_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.FULL, ASF.Converters.Dates.DEFAULT,
"Saturday, November 19, 2011");
end Test_Date_Full_Converter;
-- ------------------------------
-- Test the time short converter.
-- ------------------------------
procedure Test_Time_Short_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.DEFAULT, ASF.Converters.Dates.SHORT,
"03:04");
end Test_Time_Short_Converter;
-- ------------------------------
-- Test the time short converter.
-- ------------------------------
procedure Test_Time_Medium_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.DEFAULT, ASF.Converters.Dates.MEDIUM,
"03:04");
end Test_Time_Medium_Converter;
-- ------------------------------
-- Test the time long converter.
-- ------------------------------
procedure Test_Time_Long_Converter (T : in out Test) is
begin
Test_Date_Conversion (T, ASF.Converters.Dates.DEFAULT, ASF.Converters.Dates.LONG,
"03:04:05");
end Test_Time_Long_Converter;
end ASF.Converters.Tests;
|
-- TITLE external_file_manager
-- AUTHOR: John Self (UCI)
-- DESCRIPTION opens external files for other functions
-- NOTES This package opens external files, and thus may be system dependent
-- because of limitations on file names.
-- This version is for the VADS 5.5 Ada development system.
-- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/file_managerS.a,v 1.4 90/01/12 15:20:00 self Exp Locker: self $
--***************************************************************************
-- This file is subject to the Arcadia License Agreement.
--
-- (see notice in aflex.a)
--
--***************************************************************************
with TEXT_IO; use TEXT_IO;
package EXTERNAL_FILE_MANAGER is
STANDARD_ERROR:FILE_TYPE;
procedure GET_IO_FILE(F : in out FILE_TYPE);
procedure GET_DFA_FILE(F : in out FILE_TYPE);
procedure GET_SCANNER_FILE(F : in out FILE_TYPE);
procedure GET_BACKTRACK_FILE(F : in out FILE_TYPE);
procedure INITIALIZE_FILES;
end EXTERNAL_FILE_MANAGER;
|
--*****************************************************************************
--*
--* PROJECT: BINGADA
--*
--* FILE: q_bingo-q_bombo.ads
--*
--* AUTHOR: Javier Fuica Fernandez
--*
--*****************************************************************************
package Q_Bingo.Q_Bombo is
procedure P_Init;
procedure P_Spin (V_Number : out Positive;
V_Current_Index : out T_Number;
V_Last_Number : out Boolean);
function F_Get_Number (V_Index : T_Number) return T_Number;
function F_Get_Current_Index return T_Number;
end Q_Bingo.Q_Bombo;
|
package body ACO.Utils.DS.Generic_Protected_Queue is
procedure Put_Blocking
(This : in out Protected_Queue;
Item : in Item_Type)
is
Success : Boolean;
begin
This.Buffer.Put (Item, Success);
if not Success then
Ada.Synchronous_Task_Control.Suspend_Until_True (This.Non_Full);
This.Buffer.Put (Item, Success);
end if;
Ada.Synchronous_Task_Control.Set_True (This.Non_Empty);
end Put_Blocking;
procedure Put
(This : in out Protected_Queue;
Item : in Item_Type;
Success : out Boolean)
is
begin
This.Buffer.Put (Item, Success);
end Put;
procedure Get_Blocking
(This : in out Protected_Queue;
Item : out Item_Type)
is
Success : Boolean;
begin
This.Buffer.Get (Item, Success);
if not Success then
Ada.Synchronous_Task_Control.Suspend_Until_True (This.Non_Empty);
This.Buffer.Get (Item, Success);
end if;
Ada.Synchronous_Task_Control.Set_True (This.Non_Full);
end Get_Blocking;
procedure Get
(This : in out Protected_Queue;
Item : out Item_Type)
is
Success : Boolean;
begin
This.Buffer.Get (Item, Success);
Ada.Synchronous_Task_Control.Set_True (This.Non_Full);
end Get;
function Count
(This : Protected_Queue)
return Natural
is
begin
return This.Buffer.Nof_Items;
end Count;
function Is_Empty
(This : Protected_Queue)
return Boolean
is
begin
return This.Buffer.Nof_Items = 0;
end Is_Empty;
function Is_Full
(This : Protected_Queue)
return Boolean
is
begin
return This.Buffer.Nof_Items >= Maximum_Nof_Items;
end Is_Full;
protected body Buffer_Type is
procedure Put
(Item : in Item_Type;
Success : out Boolean)
is
begin
if Queue.Is_Full then
Success := False;
else
Success := True;
Queue.Put (Item);
end if;
end Put;
procedure Get
(Item : out Item_Type;
Success : out Boolean)
is
begin
if Queue.Is_Empty then
Success := False;
else
Success := True;
Queue.Get (Item);
end if;
end Get;
function Nof_Items return Natural
is
begin
return Queue.Length;
end Nof_Items;
end Buffer_Type;
end ACO.Utils.DS.Generic_Protected_Queue;
|
-- Score PIXAL le 07/10/2020 à 14:33 : 100%
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
-- Tri par insertion
procedure Tri_Insertion is
Capacite: constant Integer := 10; -- Cette taille est arbitraire
type T_TableauBrut is array (1..Capacite) of Integer;
type T_Tableau is
record
Elements: T_TableauBrut;
Taille: Integer;
-- Invariant: 0 <= Taille and Taille <= Capacite;
end record;
-- Initialiser un tableau Tab à partir d'éléments lus au clavier.
-- La nombre d'éléments est d'abord demandée, suivi des éléments.
-- Les éléments en surnombre par rapport à la capacité du tableau
-- sont ignorés et le message "Données tronquées" est affiché.
procedure Lire (Tab: out T_Tableau) is
Taille_Souhaitee: Integer;
Nb_Elements: Integer; -- Nombre d'éléments à lire
begin
-- Demander la taille
Put ("Nombre d'éléments ? ");
Get (Taille_Souhaitee);
if Taille_Souhaitee > Capacite then
Nb_Elements := Capacite;
elsif Taille_Souhaitee < 0 then
Nb_Elements := 0;
else
Nb_Elements := Taille_Souhaitee;
end if;
-- Demander les éléments du tableau
for N in 1..Nb_Elements loop
Put ("Element ");
Put (N, 1);
Put (" ? ");
Get (Tab.Elements (N));
end loop;
Tab.Taille := Nb_Elements;
if Nb_Elements < Taille_Souhaitee then
Put_Line ("Données tronquées");
else
null;
end if;
end Lire;
-- Afficher le tableau. Les éléments sont affichés entre crochets, séparés
-- par des virgules.
procedure Ecrire(Tab: in T_Tableau) is
begin
Put ('[');
if Tab.Taille > 0 then
-- Écrire le premier élément
Put (Tab.Elements (1), 1);
-- Écrire les autres éléments précédés d'une virgule
for I in 2..Tab.Taille loop
Put (", ");
Put (Tab.Elements (I), 1);
end loop;
else
null;
end if;
Put (']');
end Ecrire;
--------------------[ Ne pas changer le code qui précède ]---------------------
procedure Trier (Tableau: in out T_Tableau);
procedure Swap (Tableau: in out T_Tableau; Indice1: in Integer; Indice2: in Integer) is
Temp: Integer;
begin
Temp := Tableau.Elements(Indice1);
Tableau.Elements(Indice1) := Tableau.Elements(Indice2);
Tableau.Elements(Indice2) := Temp;
end Swap;
procedure Inserer (Tableau: in out T_Tableau; Ancien: in Integer; Nouveau: in Integer) is
begin
for J in reverse Nouveau..(Ancien-1) loop
Swap(Tableau, J, J+1);
end loop;
end Inserer;
procedure Etape_Insertion (Tableau: in out T_Tableau; Etape: in Integer) is
Indice_Insertion: Integer;
begin
Indice_Insertion := 1;
-- Chercher l'indice d'insertion de l'élément d'indice Etape.
while Tableau.Elements(Indice_Insertion) <= Tableau.Elements(Etape) and Indice_Insertion < Etape loop
Indice_Insertion := Indice_Insertion + 1;
end loop;
-- Inserer l'élément d'indice Etape à sa place pour avoir un sous tableau trié jusqu'à étape.
Inserer(Tableau, Etape, Indice_Insertion);
-- Ecrire le tableau pour répondre aux contraintes
Ecrire(Tableau);
New_Line;
end Etape_Insertion;
procedure Trier (Tableau: in out T_Tableau) is
begin
for J in 2..Tableau.Taille loop
Etape_Insertion(Tableau, J); -- Inserer l'element d'indice J à sa propre position
end loop;
end Trier;
----[ Ne pas changer le code qui suit, sauf pour la question optionnelle ]----
Tab1: T_Tableau; -- Un tableau
begin
Lire (Tab1);
-- Afficher le tableau lu
Put ("Tableau lu : ");
Ecrire (Tab1);
New_Line;
Trier (Tab1);
-- Afficher le tableau trié
Put ("Tableau trié : ");
Ecrire (Tab1);
New_Line;
end Tri_Insertion;
|
with Ada.Text_IO;
procedure Letter_Frequency is
Counters: array (Character) of Natural := (others => 0); -- initialize all Counters to 0
C: Character;
File: Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Open(File, Mode => Ada.Text_IO.In_File, Name => "letter_frequency.adb");
while not Ada.Text_IO.End_Of_File(File) loop
Ada.Text_IO.Get(File, C);
Counters(C) := Counters(C) + 1;
end loop;
for I in Counters'Range loop
if Counters(I) > 0 then
Ada.Text_IO.Put_Line("'" & I & "':" & Integer'Image(Counters(I)));
end if;
end loop;
end Letter_Frequency;
|
with physics.Rigid;
with Math;
package physics.Motor.spring is
-- a motor which acts as a spring to bring a target solid to a desired site or attitude.
type Item is abstract new physics.Motor.item with
record
Rigid : physics.Rigid.pointer; -- access to the Solid affected by this Motor.
end record;
procedure update (Self : in out Item) is abstract;
private
procedure dummy;
end physics.Motor.spring;
|
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package bits_types_u_mbstate_t_h is
-- Integral type unchanged by default argument promotions that can
-- hold any value corresponding to members of the extended character
-- set, as well as at least one value that does not correspond to any
-- member of the extended character set.
-- Conversion state information.
-- skipped anonymous struct anon_2
subtype uu_mbstate_t_array853 is Interfaces.C.char_array (0 .. 3);
type anon_3 (discr : unsigned := 0) is record
case discr is
when 0 =>
uu_wch : aliased unsigned; -- /usr/include/bits/types/__mbstate_t.h:18
when others =>
uu_wchb : aliased uu_mbstate_t_array853; -- /usr/include/bits/types/__mbstate_t.h:19
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True;
type uu_mbstate_t is record
uu_count : aliased int; -- /usr/include/bits/types/__mbstate_t.h:15
uu_value : aliased anon_3; -- /usr/include/bits/types/__mbstate_t.h:20
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/types/__mbstate_t.h:21
-- Value so far.
end bits_types_u_mbstate_t_h;
|
package STM32GD.Power is
subtype Millivolts is Natural range 0..4095;
procedure Enable_Sleep;
procedure Enable_Stop;
procedure Enable_Standby;
function Supply_Voltage return Millivolts;
end STM32GD.Power;
|
Package numeros_racionales is
type Racional is private;
function "/" (A,B:integer)return racional;
--{Crea un numero racional donde A numerador y B denominador}
--{Pre:Ninguna}
--{Post:Numerador(Crear(A,B))=A,Denominador(Crear(A,B))=B}
function "+"(X,Y:Racional)return Racional;
--{Pre:Ninguna}
--{Post:Devuelve la esp.(a/b) + (c/d) = (a*d+b*c)/(b*d)}
function "-"(X,Y:Racional)return Racional;
--{Pre:Ninguna}
--{Post:Devuelve la esp. (a/b) - (c/d) = (a*d-b*c)/(b*d)}
Function "*"(x,Y:Racional) return Racional;
--{Pre:Ninguna}
--{Post:Devuelve la esp.(a/b) * (c/d) = (a*c)/(b*d)}
Function "/"(X,Y:Racional) return Racional;
--{Pre:Ninguna}
--{Post:Devuelve la esp.(a/b) / (c/d) = (a*d)/(b*c) }
function Numerador(X:racional) return Integer;
--{Pre:Ninguna}
--{Post:Devuelve la esp. Numerador(x)= entero}
function Denominador(X:racional) return Integer;
--{Pre:Ninguna}
--{Post:Devuelve la esp. Denominador(x)= entero}
Function "=" (X,Y:Racional) return Boolean;
--{Pre:Ninguna}
--{Post:Determina si dos racionales son iguales}
Denominador_cero:exception;
--{excepcion para cuando el denominador es cero}
Private
function Max(X,Y:integer)return Integer;
Type Racional is record
Num,Dem:integer;
end record;
--{Tipo privado que es una estructura para guardar el numero racional}
end Numeros_racionales;
|
with Interfaces; use Interfaces;
-- @summary
-- dummy file replacing hil.ads (because we don't want
-- its additional dependencies here)
package HIL with
SPARK_Mode
is
pragma Preelaborate;
-- procedure configure_Hardware;
type Byte is mod 2**8 with Size => 8;
-- Arrays
type Byte_Array is array (Natural range <>) of Byte;
end HIL;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- I N D E P S W --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- GNATLINK platform-independent switches
-- Used to convert GNAT switches to their platform-dependent switch
-- equivalent for the underlying linker.
with GNAT.OS_Lib; use GNAT.OS_Lib;
package Indepsw is
type Switch_Kind is
-- Independent switches currently supported
(Map_File);
-- Produce a map file. The path name of the map file to produce
-- is given as an argument.
procedure Convert
(Switch : Switch_Kind;
Argument : String;
To : out String_List_Access);
-- Convert Switch to the platform-dependent linker switch (with or without
-- additional arguments) To. Issue a warning if Switch is not supported
-- for the platform; in this case, To is set to null.
function Is_Supported (Switch : Switch_Kind) return Boolean;
-- Return True for each independent switch supported by the platform
private
-- Default warning messages when the switches are not supported by the
-- implementation. These are in the spec so that the platform specific
-- bodies do not need to redefine them.
Map_File_Not_Supported : aliased String :=
"the underlying linker does not allow the output of a map file";
No_Support_For : constant array (Switch_Kind) of String_Access :=
(Map_File => Map_File_Not_Supported'Access);
-- All implementations of procedure Convert should include a case
-- statements with a "when others =>" choice that output the default
-- warning message:
-- case Switch is
-- when ... =>
-- ...
-- when others =>
-- Write_Str ("warning: ");
-- Write_Line (No_Support_For (Switch).all);
-- To := null;
-- end case;
end Indepsw;
|
-- C4A011A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT NONSTATIC UNIVERSAL REAL EXPRESSIONS ARE EVALUATED WITH
-- THE ACCURACY OF THE MOST PRECISE PREDEFINED FLOATING POINT TYPE
-- (I. E., THE TYPE FOR WHICH 'DIGITS EQUALS SYSTEM.MAX_DIGITS).
-- RJW 8/4/86
WITH SYSTEM; USE SYSTEM;
WITH REPORT; USE REPORT;
PROCEDURE C4A011A IS
TYPE MAX_FLOAT IS DIGITS MAX_DIGITS;
C5L : CONSTANT := 16#0.AAAA8#;
C5U : CONSTANT := 16#0.AAAAC#;
C6L : CONSTANT := 16#0.AAAAA8#;
C6U : CONSTANT := 16#0.AAAAB0#;
C7L : CONSTANT := 16#0.AAAAAA8#;
C7U : CONSTANT := 16#0.AAAAAB0#;
C8L : CONSTANT := 16#0.AAAAAAA#;
C8U : CONSTANT := 16#0.AAAAAAB#;
C9L : CONSTANT := 16#0.AAAAAAAA#;
C9U : CONSTANT := 16#0.AAAAAAAC#;
C10L : CONSTANT := 16#0.AAAAAAAAA#;
C10U : CONSTANT := 16#0.AAAAAAAAC#;
C11L : CONSTANT := 16#0.AAAAAAAAA8#;
C11U : CONSTANT := 16#0.AAAAAAAAAC#;
C12L : CONSTANT := 16#0.AAAAAAAAAA8#;
C12U : CONSTANT := 16#0.AAAAAAAAAB0#;
C13L : CONSTANT := 16#0.AAAAAAAAAAA8#;
C13U : CONSTANT := 16#0.AAAAAAAAAAB0#;
C14L : CONSTANT := 16#0.AAAAAAAAAAAA#;
C14U : CONSTANT := 16#0.AAAAAAAAAAAB#;
C15L : CONSTANT := 16#0.AAAAAAAAAAAAA#;
C15U : CONSTANT := 16#0.AAAAAAAAAAAAC#;
C16L : CONSTANT := 16#0.AAAAAAAAAAAAAA#;
C16U : CONSTANT := 16#0.AAAAAAAAAAAAAC#;
C17L : CONSTANT := 16#0.AAAAAAAAAAAAAA8#;
C17U : CONSTANT := 16#0.AAAAAAAAAAAAAAC#;
C18L : CONSTANT := 16#0.AAAAAAAAAAAAAAA8#;
C18U : CONSTANT := 16#0.AAAAAAAAAAAAAAB0#;
C19L : CONSTANT := 16#0.AAAAAAAAAAAAAAAA8#;
C19U : CONSTANT := 16#0.AAAAAAAAAAAAAAAB0#;
C20L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAA#;
C20U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAB#;
C21L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAA#;
C21U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAC#;
C22L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAA#;
C22U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAC#;
C23L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAA8#;
C23U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAC#;
C24L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAA8#;
C24U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAB0#;
C25L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAA8#;
C25U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAB0#;
C26L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAA#;
C26U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAB#;
C27L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAA#;
C27U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAC#;
C28L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAA#;
C28U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAC#;
C29L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAA8#;
C29U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAC#;
C30L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAA8#;
C30U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAB0#;
C31L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAA#;
C31U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAB#;
C32L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAA#;
C32U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAB#;
C33L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAAA#;
C33U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAAC#;
C34L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAAA8#;
C34U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAAAC#;
C35L : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8#;
C35U : CONSTANT := 16#0.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAC#;
BEGIN
TEST ( "C4A011A", "CHECK THAT NONSTATIC UNIVERSAL REAL " &
"EXPRESSIONS ARE EVALUATED WITH THE " &
"ACCURACY OF THE MOST PRECISE PREDEFINED " &
"FLOATING POINT TYPE (I. E., THE TYPE FOR " &
"WHICH 'DIGITS EQUALS SYSTEM.MAX_DIGITS" );
CASE MAX_DIGITS IS
WHEN 5 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C5L .. C5U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 5" );
END IF;
WHEN 6 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C6L .. C6U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 6" );
END IF;
WHEN 7 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C7L .. C7U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 7" );
END IF;
WHEN 8 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C8L .. C8U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 8" );
END IF;
WHEN 9 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C9L .. C9U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 9" );
END IF;
WHEN 10 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C10L .. C10U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 10" );
END IF;
WHEN 11 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C11L .. C11U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 11" );
END IF;
WHEN 12 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C12L .. C12U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 12" );
END IF;
WHEN 13 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C13L .. C13U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 13" );
END IF;
WHEN 14 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C14L .. C14U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 14" );
END IF;
WHEN 15 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C15L .. C15U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 15" );
END IF;
WHEN 16 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C16L .. C16U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 16" );
END IF;
WHEN 17 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C17L .. C17U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 17" );
END IF;
WHEN 18 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C18L .. C18U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 18" );
END IF;
WHEN 19 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C19L .. C19U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 19" );
END IF;
WHEN 20 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C20L .. C20U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 20" );
END IF;
WHEN 21 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C21L .. C21U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 21" );
END IF;
WHEN 22 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C22L .. C22U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 22" );
END IF;
WHEN 23 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C23L .. C23U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 23" );
END IF;
WHEN 24 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C24L .. C24U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 24" );
END IF;
WHEN 25 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C25L .. C25U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 25" );
END IF;
WHEN 26 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C26L .. C26U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 26" );
END IF;
WHEN 27 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C27L .. C27U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 27" );
END IF;
WHEN 28 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C28L .. C28U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 28" );
END IF;
WHEN 29 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C29L .. C29U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 29" );
END IF;
WHEN 30 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C30L .. C30U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 30" );
END IF;
WHEN 31 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C31L .. C31U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 31" );
END IF;
WHEN 32 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C32L .. C32U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 32" );
END IF;
WHEN 33 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C33L .. C33U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 33" );
END IF;
WHEN 34 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C34L .. C34U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 34" );
END IF;
WHEN 35 =>
IF (2.0 * INTEGER'POS (IDENT_INT (1))) / 3.0 NOT IN
C35L .. C35U THEN
FAILED ( "INCORRECT ACCURACY FOR A MAX_DIGITS " &
"VALUE OF 35" );
END IF;
WHEN OTHERS =>
NOT_APPLICABLE ( "MAX_DIGITS OUT OF RANGE OF TEST. " &
"MAX_DIGITS = " &
INTEGER'IMAGE (MAX_DIGITS));
END CASE;
RESULT;
END C4A011A;
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2018 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY 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.
pragma License (Modified_GPL);
package body WisiToken.Generate.Packrat is
function Potential_Direct_Right_Recursive
(Grammar : in WisiToken.Productions.Prod_Arrays.Vector;
Empty : in Token_ID_Set)
return Token_ID_Set
is
subtype Nonterminal is Token_ID range Grammar.First_Index .. Grammar.Last_Index;
begin
return Result : Token_ID_Set (Nonterminal) := (others => False) do
for Prod of Grammar loop
RHS_Loop :
for RHS of Prod.RHSs loop
ID_Loop :
for I in reverse RHS.Tokens.First_Index + 1 .. RHS.Tokens.Last_Index loop
declare
ID : constant Token_ID := RHS.Tokens (I);
begin
if ID = Prod.LHS then
Result (ID) := True;
exit RHS_Loop;
elsif not (ID in Nonterminal) then
exit ID_Loop;
elsif not Empty (ID) then
exit ID_Loop;
end if;
end;
end loop ID_Loop;
end loop RHS_Loop;
end loop;
end return;
end Potential_Direct_Right_Recursive;
procedure Indirect_Left_Recursive (Data : in out Packrat.Data)
is
begin
for Prod_I of Data.Grammar loop
for Prod_J of Data.Grammar loop
Data.Involved (Prod_I.LHS, Prod_J.LHS) :=
Data.First (Prod_I.LHS, Prod_J.LHS) and
Data.First (Prod_J.LHS, Prod_I.LHS);
end loop;
end loop;
end Indirect_Left_Recursive;
----------
-- Public subprograms
function Initialize
(Source_File_Name : in String;
Grammar : in WisiToken.Productions.Prod_Arrays.Vector;
Source_Line_Map : in Productions.Source_Line_Maps.Vector;
First_Terminal : in Token_ID)
return Packrat.Data
is
Empty : constant Token_ID_Set := WisiToken.Generate.Has_Empty_Production (Grammar);
begin
return Result : Packrat.Data :=
(First_Terminal => First_Terminal,
First_Nonterminal => Grammar.First_Index,
Last_Nonterminal => Grammar.Last_Index,
Source_File_Name => +Source_File_Name,
Grammar => Grammar,
Source_Line_Map => Source_Line_Map,
Empty => Empty,
Direct_Left_Recursive => Potential_Direct_Left_Recursive (Grammar, Empty),
First => WisiToken.Generate.First (Grammar, Empty, First_Terminal => First_Terminal),
Involved => (others => (others => False)))
do
Indirect_Left_Recursive (Result);
end return;
end Initialize;
procedure Check_Recursion (Data : in Packrat.Data; Descriptor : in WisiToken.Descriptor)
is
Right_Recursive : constant Token_ID_Set := Potential_Direct_Right_Recursive (Data.Grammar, Data.Empty);
begin
for Prod of Data.Grammar loop
if Data.Direct_Left_Recursive (Prod.LHS) and Right_Recursive (Prod.LHS) then
-- We only implement the simplest left recursion solution ([warth
-- 2008] figure 3); [tratt 2010] section 6.3 gives this condition for
-- that to be valid.
-- FIXME: not quite? definite direct right recursive ok?
-- FIXME: for indirect left recursion, need potential indirect right recursive check?
Put_Error
(Error_Message
(-Data.Source_File_Name, Data.Source_Line_Map (Prod.LHS).Line, "'" & Image (Prod.LHS, Descriptor) &
"' is both left and right recursive; not supported."));
end if;
for I in Data.Involved'Range (2) loop
if Prod.LHS /= I and then Data.Involved (Prod.LHS, I) then
Put_Error
(Error_Message
(-Data.Source_File_Name, Data.Source_Line_Map (Prod.LHS).Line, "'" & Image (Prod.LHS, Descriptor) &
"' is indirect recursive with " & Image (I, Descriptor) & ", not supported"));
end if;
end loop;
end loop;
end Check_Recursion;
procedure Check_RHS_Order (Data : in Packrat.Data; Descriptor : in WisiToken.Descriptor)
is
use all type Ada.Containers.Count_Type;
begin
for Prod of Data.Grammar loop
-- Empty must be last
for I in Prod.RHSs.First_Index .. Prod.RHSs.Last_Index - 1 loop
if Prod.RHSs (I).Tokens.Length = 0 then
Put_Error
(Error_Message
(-Data.Source_File_Name, Data.Source_Line_Map (Prod.LHS).RHS_Map (I),
"right hand side" & Integer'Image (I) & " in " & Image (Prod.LHS, Descriptor) &
" is empty, but not last; no later right hand side will match."));
WisiToken.Generate.Error := True;
end if;
end loop;
for I in Prod.RHSs.First_Index + 1 .. Prod.RHSs.Last_Index loop
declare
Cur : Token_ID_Arrays.Vector renames Prod.RHSs (I).Tokens;
begin
-- Shared prefix; longer must be first
for J in Prod.RHSs.First_Index .. I - 1 loop
declare
Prev : Token_ID_Arrays.Vector renames Prod.RHSs (J).Tokens;
K : constant Natural := Shared_Prefix (Prev, Cur);
begin
if K > 0 and Prev.Length < Cur.Length then
Put_Error
(Error_Message
(-Data.Source_File_Name, Data.Source_Line_Map (Prod.LHS).RHS_Map (I),
"right hand side" & Integer'Image (I) & " in " & Image (Prod.LHS, Descriptor) &
" may never match; it shares a prefix with a shorter previous rhs" &
Integer'Image (J) & "."));
end if;
end;
end loop;
-- recursion; typical LALR list is written:
--
-- statement_list
-- : statement
-- | statement_list statement
-- ;
-- association_list
-- : association
-- | association_list COMMA association
-- ;
--
-- a different recursive definition:
--
-- name
-- : IDENTIFIER
-- | name LEFT_PAREN range_list RIGHT_PAREN
-- | name actual_parameter_part
-- ...
-- ;
--
-- For packrat, the recursive RHSs must come before others:
--
-- statement_list
-- : statement_list statement
-- | statement
-- ;
-- association_list
-- : association_list COMMA association
-- | association
-- ;
-- name
-- : name LEFT_PAREN range_list RIGHT_PAREN
-- | name actual_parameter_part
-- | IDENTIFIER
-- ...
-- ;
declare
Prev : Token_ID_Arrays.Vector renames Prod.RHSs (I - 1).Tokens;
begin
if Cur.Length > 0 and then Prev.Length > 0 and then
Cur (1) = Prod.LHS and then Prev (1) /= Prod.LHS
then
Put_Error
(Error_Message
(-Data.Source_File_Name, Data.Source_Line_Map (Prod.LHS).Line,
"recursive right hand sides must be before others."));
end if;
end;
end;
end loop;
end loop;
end Check_RHS_Order;
procedure Check_All (Data : in Packrat.Data; Descriptor : in WisiToken.Descriptor)
is begin
Check_Recursion (Data, Descriptor);
Check_RHS_Order (Data, Descriptor);
end Check_All;
function Potential_Direct_Left_Recursive
(Grammar : in WisiToken.Productions.Prod_Arrays.Vector;
Empty : in Token_ID_Set)
return Token_ID_Set
is
subtype Nonterminal is Token_ID range Grammar.First_Index .. Grammar.Last_Index;
begin
-- FIXME: this duplicates the computation of First; if keep First,
-- change this to use it.
return Result : Token_ID_Set (Nonterminal) := (others => False) do
for Prod of Grammar loop
RHS_Loop :
for RHS of Prod.RHSs loop
ID_Loop :
for ID of RHS.Tokens loop
if ID = Prod.LHS then
Result (ID) := True;
exit RHS_Loop;
elsif not (ID in Nonterminal) then
exit ID_Loop;
elsif not Empty (ID) then
exit ID_Loop;
end if;
end loop ID_Loop;
end loop RHS_Loop;
end loop;
end return;
end Potential_Direct_Left_Recursive;
end WisiToken.Generate.Packrat;
|
package body Tests is
---------------
-- Get_Suite --
---------------
function Get_Suite return AUnit.Test_Suites.Access_Test_Suite
is (Suite'Access);
end Tests;
|
-- SPDX-FileCopyrightText: 2019-2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Program.Lexical_Elements is
pragma Pure;
type Lexical_Element is limited interface;
type Lexical_Element_Access is
access all Lexical_Element'Class with Storage_Size => 0;
function Assigned (Self : access Lexical_Element'Class) return Boolean
is (Self /= null);
not overriding function Image (Self : Lexical_Element) return Text
is abstract;
-- Return text of the lexical element.
type Lexical_Element_Kind is
(Less, Equal, Greater, Hyphen, Slash,
Star, Ampersand, Plus,
Less_Or_Equal, Greater_Or_Equal, Inequality,
Double_Star,
Or_Keyword, And_Keyword, Xor_Keyword, Mod_Keyword, Rem_Keyword,
Abs_Keyword, Not_Keyword,
Right_Label,
Box, Left_Label,
Assignment, Arrow,
Double_Dot,
Apostrophe, Left_Parenthesis,
Right_Parenthesis,
Comma, Dot,
Colon, Semicolon,
Vertical_Line,
Abort_Keyword,
Abstract_Keyword, Accept_Keyword,
Access_Keyword, Aliased_Keyword, All_Keyword,
Array_Keyword, At_Keyword,
Begin_Keyword, Body_Keyword, Case_Keyword,
Constant_Keyword, Declare_Keyword, Delay_Keyword,
Delta_Keyword, Digits_Keyword, Do_Keyword,
Else_Keyword, Elsif_Keyword, End_Keyword,
Entry_Keyword, Exception_Keyword, Exit_Keyword,
For_Keyword, Function_Keyword, Generic_Keyword,
Goto_Keyword, If_Keyword, In_Keyword,
Interface_Keyword, Is_Keyword, Limited_Keyword,
Loop_Keyword, New_Keyword,
Null_Keyword, Of_Keyword,
Others_Keyword, Out_Keyword,
Overriding_Keyword, Package_Keyword, Pragma_Keyword,
Private_Keyword, Procedure_Keyword, Protected_Keyword,
Raise_Keyword, Range_Keyword, Record_Keyword,
Renames_Keyword, Requeue_Keyword,
Return_Keyword, Reverse_Keyword, Select_Keyword,
Separate_Keyword, Some_Keyword, Subtype_Keyword, Synchronized_Keyword,
Tagged_Keyword, Task_Keyword, Terminate_Keyword,
Then_Keyword, Type_Keyword, Until_Keyword,
Use_Keyword, When_Keyword, While_Keyword,
With_Keyword,
Comment, Identifier, Numeric_Literal,
Character_Literal, String_Literal,
Error, End_Of_Input);
subtype Operator_Kind is Lexical_Element_Kind range Less .. Not_Keyword;
subtype Keyword_Operator_Kind is Lexical_Element_Kind
range Or_Keyword .. Not_Keyword;
subtype Keyword_Kind is Lexical_Element_Kind
range Abort_Keyword .. With_Keyword;
not overriding function Kind (Self : Lexical_Element)
return Lexical_Element_Kind is abstract;
type Location is record
Line : Positive;
Column : Positive;
end record;
function "<" (Left, Right : Location) return Boolean with Inline;
function ">" (Left, Right : Location) return Boolean with Inline;
function "<=" (Left, Right : Location) return Boolean with Inline;
function ">=" (Left, Right : Location) return Boolean with Inline;
not overriding function From (Self : Lexical_Element) return Location
is abstract;
-- Line and column where the lexical element is located.
function From_Image (Self : Lexical_Element'Class) return Program.Text;
-- Line:column where the lexical element is located as a string.
type Lexical_Element_Vector is limited interface;
-- Vector of lexical elements.
type Lexical_Element_Vector_Access is
access all Lexical_Element_Vector'Class
with Storage_Size => 0;
not overriding function First_Index (Self : Lexical_Element_Vector)
return Positive is abstract;
not overriding function Last_Index (Self : Lexical_Element_Vector)
return Positive is abstract;
-- The vector always has at least one element.
function Length (Self : Lexical_Element_Vector'Class)
return Positive is (Self.Last_Index - Self.First_Index + 1);
-- Return number of elements in the vector
not overriding function Element
(Self : Lexical_Element_Vector;
Index : Positive)
return not null Lexical_Element_Access
is abstract
with Pre'Class => Index in Self.First_Index .. Self.Last_Index;
-- Return an element of the vector
function First
(Self : Lexical_Element_Vector'Class)
return not null Program.Lexical_Elements.Lexical_Element_Access
with Inline;
-- Get the first element of the vector
function Last
(Self : Lexical_Element_Vector'Class)
return not null Program.Lexical_Elements.Lexical_Element_Access
with Inline;
-- Get the last element of the vector
end Program.Lexical_Elements;
|
package Debug13 is
procedure Compile (P : Natural);
end Debug13;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.