text
stringlengths 4
1.04M
|
|---|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 3 0 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 30
package System.Pack_30 is
pragma Preelaborate;
Bits : constant := 30;
type Bits_30 is mod 2 ** Bits;
for Bits_30'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_30
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_30 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_30
(Arr : System.Address;
N : Natural;
E : Bits_30;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
function GetU_30
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_30 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned. This version
-- is used when Arr may represent an unaligned address.
procedure SetU_30
(Arr : System.Address;
N : Natural;
E : Bits_30;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value. This version
-- is used when Arr may represent an unaligned address
end System.Pack_30;
|
-- Copyright 2015,2016,2017 Steven Stewart-Gallus
--
-- 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 Linted.Controls;
with Linted.Errors;
with Linted.KOs;
with Linted.Triggers;
package Linted.Controls_Reader is
pragma Elaborate_Body;
type Event is record
Data : Controls.Packet;
Err : Errors.Error := 0;
end record;
type Future is limited private with
Preelaborable_Initialization;
function Is_Live (F : Future) return Boolean;
procedure Read
(Object : KOs.KO;
Signaller : Triggers.Signaller;
F : out Future) with
Post => Is_Live (F);
procedure Read_Wait (F : in out Future; E : out Event) with
Pre => Is_Live (F),
Post => not Is_Live (F);
procedure Read_Poll
(F : in out Future;
E : out Event;
Init : out Boolean) with
Pre => Is_Live (F),
Post => (if Init then not Is_Live (F) else Is_Live (F));
private
Max_Nodes : constant := 2;
type Future is range 0 .. Max_Nodes + 1 with
Default_Value => 0;
end Linted.Controls_Reader;
|
-- Mojang Authentication API
-- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-- ------------ EDIT NOTE ------------
-- This file was generated with openapi-generator. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .openapi-generator-ignore file:
--
-- src/com-github-asyncmc-mojang-authentication-ada-server-model.ads
--
-- Then, you can drop this edit note comment.
-- ------------ EDIT NOTE ------------
package com.github is
end com.github;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . O S _ I N T E R F A C E --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1998-2001, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the SGI Pthreads version of this package.
-- This package encapsulates all direct interfaces to OS services
-- that are needed by children of System.
-- PLEASE DO NOT add any with-clauses to this package
-- or remove the pragma Elaborate_Body.
-- It is designed to be a bottom-level (leaf) package.
with Interfaces.C;
package System.OS_Interface is
pragma Preelaborate;
pragma Linker_Options ("-lpthread");
subtype int is Interfaces.C.int;
subtype short is Interfaces.C.short;
subtype long is Interfaces.C.long;
subtype unsigned is Interfaces.C.unsigned;
subtype unsigned_short is Interfaces.C.unsigned_short;
subtype unsigned_long is Interfaces.C.unsigned_long;
subtype unsigned_char is Interfaces.C.unsigned_char;
subtype plain_char is Interfaces.C.plain_char;
subtype size_t is Interfaces.C.size_t;
-----------
-- Errno --
-----------
function errno return int;
pragma Import (C, errno, "__get_errno");
EINTR : constant := 4; -- interrupted system call
EAGAIN : constant := 11; -- No more processes
ENOMEM : constant := 12; -- Not enough core
EINVAL : constant := 22; -- Invalid argument
ETIMEDOUT : constant := 145; -- Connection timed out
-------------
-- Signals --
-------------
Max_Interrupt : constant := 64;
type Signal is new int range 0 .. Max_Interrupt;
for Signal'Size use int'Size;
SIGHUP : constant := 1; -- hangup
SIGINT : constant := 2; -- interrupt (rubout)
SIGQUIT : constant := 3; -- quit (ASCD FS)
SIGILL : constant := 4; -- illegal instruction (not reset)
SIGTRAP : constant := 5; -- trace trap (not reset)
SIGIOT : constant := 6; -- IOT instruction
SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the
-- future
SIGEMT : constant := 7; -- EMT instruction
SIGFPE : constant := 8; -- floating point exception
SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
SIGBUS : constant := 10; -- bus error
SIGSEGV : constant := 11; -- segmentation violation
SIGSYS : constant := 12; -- bad argument to system call
SIGPIPE : constant := 13; -- write on a pipe with no one to read it
SIGALRM : constant := 14; -- alarm clock
SIGTERM : constant := 15; -- software termination signal from kill
SIGUSR1 : constant := 16; -- user defined signal 1
SIGUSR2 : constant := 17; -- user defined signal 2
SIGCLD : constant := 18; -- alias for SIGCHLD
SIGCHLD : constant := 18; -- child status change
SIGPWR : constant := 19; -- power-fail restart
SIGWINCH : constant := 20; -- window size change
SIGURG : constant := 21; -- urgent condition on IO channel
SIGPOLL : constant := 22; -- pollable event occurred
SIGIO : constant := 22; -- I/O possible (Solaris SIGPOLL alias)
SIGSTOP : constant := 23; -- stop (cannot be caught or ignored)
SIGTSTP : constant := 24; -- user stop requested from tty
SIGCONT : constant := 25; -- stopped process has been continued
SIGTTIN : constant := 26; -- background tty read attempted
SIGTTOU : constant := 27; -- background tty write attempted
SIGVTALRM : constant := 28; -- virtual timer expired
SIGPROF : constant := 29; -- profiling timer expired
SIGXCPU : constant := 30; -- CPU time limit exceeded
SIGXFSZ : constant := 31; -- filesize limit exceeded
SIGK32 : constant := 32; -- reserved for kernel (IRIX)
SIGCKPT : constant := 33; -- Checkpoint warning
SIGRESTART : constant := 34; -- Restart warning
SIGUME : constant := 35; -- Uncorrectable memory error
-- Signals defined for Posix 1003.1c.
SIGPTINTR : constant := 47;
SIGPTRESCHED : constant := 48;
-- Posix 1003.1b signals
SIGRTMIN : constant := 49; -- Posix 1003.1b signals
SIGRTMAX : constant := 64; -- Posix 1003.1b signals
type sigset_t is private;
type sigset_t_ptr is access all sigset_t;
function sigaddset (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigaddset, "sigaddset");
function sigdelset (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigdelset, "sigdelset");
function sigfillset (set : access sigset_t) return int;
pragma Import (C, sigfillset, "sigfillset");
function sigismember (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigismember, "sigismember");
function sigemptyset (set : access sigset_t) return int;
pragma Import (C, sigemptyset, "sigemptyset");
type array_type_2 is array (Integer range 0 .. 1) of int;
type struct_sigaction is record
sa_flags : int;
sa_handler : System.Address;
sa_mask : sigset_t;
sa_resv : array_type_2;
end record;
pragma Convention (C, struct_sigaction);
type struct_sigaction_ptr is access all struct_sigaction;
SIG_BLOCK : constant := 1;
SIG_UNBLOCK : constant := 2;
SIG_SETMASK : constant := 3;
SIG_DFL : constant := 0;
SIG_IGN : constant := 1;
function sigaction
(sig : Signal;
act : struct_sigaction_ptr;
oact : struct_sigaction_ptr := null) return int;
pragma Import (C, sigaction, "sigaction");
----------
-- Time --
----------
type timespec is private;
type timespec_ptr is access all timespec;
type clockid_t is private;
CLOCK_REALTIME : constant clockid_t;
CLOCK_SGI_FAST : constant clockid_t;
CLOCK_SGI_CYCLE : constant clockid_t;
SGI_CYCLECNTR_SIZE : constant := 165;
function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
pragma Import (C, syssgi, "syssgi");
function clock_gettime
(clock_id : clockid_t;
tp : access timespec) return int;
pragma Import (C, clock_gettime, "clock_gettime");
function clock_getres
(clock_id : clockid_t;
tp : access timespec) return int;
pragma Import (C, clock_getres, "clock_getres");
function To_Duration (TS : timespec) return Duration;
pragma Inline (To_Duration);
function To_Timespec (D : Duration) return timespec;
pragma Inline (To_Timespec);
type struct_timeval is private;
function To_Duration (TV : struct_timeval) return Duration;
pragma Inline (To_Duration);
function To_Timeval (D : Duration) return struct_timeval;
pragma Inline (To_Timeval);
-------------------------
-- Priority Scheduling --
-------------------------
SCHED_FIFO : constant := 1;
SCHED_RR : constant := 2;
SCHED_TS : constant := 3;
SCHED_OTHER : constant := 3;
SCHED_NP : constant := 4;
function sched_get_priority_min (Policy : int) return int;
pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
function sched_get_priority_max (Policy : int) return int;
pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
-------------
-- Process --
-------------
type pid_t is private;
function kill (pid : pid_t; sig : Signal) return int;
pragma Import (C, kill, "kill");
function getpid return pid_t;
pragma Import (C, getpid, "getpid");
-------------
-- Threads --
-------------
type Thread_Body is access
function (arg : System.Address) return System.Address;
type pthread_t is private;
subtype Thread_Id is pthread_t;
type pthread_mutex_t is limited private;
type pthread_cond_t is limited private;
type pthread_attr_t is limited private;
type pthread_mutexattr_t is limited private;
type pthread_condattr_t is limited private;
type pthread_key_t is private;
PTHREAD_CREATE_DETACHED : constant := 1;
---------------------------------------
-- Nonstandard Thread Initialization --
---------------------------------------
procedure pthread_init;
pragma Inline (pthread_init);
-- This is a dummy procedure to share some GNULLI files
-------------------------
-- POSIX.1c Section 3 --
-------------------------
function sigwait
(set : access sigset_t;
sig : access Signal) return int;
pragma Import (C, sigwait, "sigwait");
function pthread_kill
(thread : pthread_t;
sig : Signal) return int;
pragma Import (C, pthread_kill, "pthread_kill");
function pthread_sigmask
(how : int;
set : sigset_t_ptr;
oset : sigset_t_ptr) return int;
pragma Import (C, pthread_sigmask, "pthread_sigmask");
--------------------------
-- POSIX.1c Section 11 --
--------------------------
function pthread_mutexattr_init
(attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
function pthread_mutexattr_destroy
(attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
function pthread_mutex_init
(mutex : access pthread_mutex_t;
attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
function pthread_condattr_init
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
function pthread_condattr_destroy
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
function pthread_cond_init
(cond : access pthread_cond_t;
attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_cond_init, "pthread_cond_init");
function pthread_cond_destroy (cond : access pthread_cond_t) return int;
pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
function pthread_cond_signal (cond : access pthread_cond_t) return int;
pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
function pthread_cond_wait
(cond : access pthread_cond_t;
mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
function pthread_cond_timedwait
(cond : access pthread_cond_t;
mutex : access pthread_mutex_t;
abstime : access timespec) return int;
pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
--------------------------
-- POSIX.1c Section 13 --
--------------------------
PTHREAD_PRIO_NONE : constant := 0;
PTHREAD_PRIO_PROTECT : constant := 2;
PTHREAD_PRIO_INHERIT : constant := 1;
function pthread_mutexattr_setprotocol
(attr : access pthread_mutexattr_t;
protocol : int) return int;
pragma Import (C, pthread_mutexattr_setprotocol);
function pthread_mutexattr_setprioceiling
(attr : access pthread_mutexattr_t;
prioceiling : int) return int;
pragma Import (C, pthread_mutexattr_setprioceiling);
type struct_sched_param is record
sched_priority : int;
end record;
pragma Convention (C, struct_sched_param);
function pthread_setschedparam
(thread : pthread_t;
policy : int;
param : access struct_sched_param)
return int;
pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
function pthread_attr_setscope
(attr : access pthread_attr_t;
contentionscope : int) return int;
pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
function pthread_attr_setinheritsched
(attr : access pthread_attr_t;
inheritsched : int) return int;
pragma Import
(C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
function pthread_attr_setschedpolicy
(attr : access pthread_attr_t;
policy : int) return int;
pragma Import (C, pthread_attr_setschedpolicy);
function pthread_attr_setschedparam
(attr : access pthread_attr_t;
sched_param : access struct_sched_param)
return int;
pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
function sched_yield return int;
pragma Import (C, sched_yield, "sched_yield");
---------------------------
-- P1003.1c - Section 16 --
---------------------------
function pthread_attr_init (attributes : access pthread_attr_t) return int;
pragma Import (C, pthread_attr_init, "pthread_attr_init");
function pthread_attr_destroy
(attributes : access pthread_attr_t) return int;
pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
function pthread_attr_setdetachstate
(attr : access pthread_attr_t;
detachstate : int) return int;
pragma Import (C, pthread_attr_setdetachstate);
function pthread_attr_setstacksize
(attr : access pthread_attr_t;
stacksize : size_t) return int;
pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
function pthread_create
(thread : access pthread_t;
attributes : access pthread_attr_t;
start_routine : Thread_Body;
arg : System.Address) return int;
pragma Import (C, pthread_create, "pthread_create");
procedure pthread_exit (status : System.Address);
pragma Import (C, pthread_exit, "pthread_exit");
function pthread_self return pthread_t;
pragma Import (C, pthread_self, "pthread_self");
--------------------------
-- POSIX.1c Section 17 --
--------------------------
function pthread_setspecific
(key : pthread_key_t;
value : System.Address) return int;
pragma Import (C, pthread_setspecific, "pthread_setspecific");
function pthread_getspecific (key : pthread_key_t) return System.Address;
pragma Import (C, pthread_getspecific, "pthread_getspecific");
type destructor_pointer is access procedure (arg : System.Address);
function pthread_key_create
(key : access pthread_key_t;
destructor : destructor_pointer) return int;
pragma Import (C, pthread_key_create, "pthread_key_create");
---------------------------------------------------------------
-- Non portable SGI 6.5 additions to the pthread interface --
-- must be executed from within the context of a system --
-- scope task --
---------------------------------------------------------------
function pthread_setrunon_np (cpu : int) return int;
pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
private
type array_type_1 is array (Integer range 0 .. 3) of unsigned;
type sigset_t is record
X_X_sigbits : array_type_1;
end record;
pragma Convention (C, sigset_t);
type pid_t is new long;
type time_t is new long;
type timespec is record
tv_sec : time_t;
tv_nsec : long;
end record;
pragma Convention (C, timespec);
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 1;
CLOCK_SGI_CYCLE : constant clockid_t := 2;
CLOCK_SGI_FAST : constant clockid_t := 3;
type struct_timeval is record
tv_sec : time_t;
tv_usec : time_t;
end record;
pragma Convention (C, struct_timeval);
type array_type_9 is array (Integer range 0 .. 4) of long;
type pthread_attr_t is record
X_X_D : array_type_9;
end record;
pragma Convention (C, pthread_attr_t);
type array_type_8 is array (Integer range 0 .. 1) of long;
type pthread_condattr_t is record
X_X_D : array_type_8;
end record;
pragma Convention (C, pthread_condattr_t);
type array_type_7 is array (Integer range 0 .. 1) of long;
type pthread_mutexattr_t is record
X_X_D : array_type_7;
end record;
pragma Convention (C, pthread_mutexattr_t);
type pthread_t is new unsigned;
type array_type_10 is array (Integer range 0 .. 7) of long;
type pthread_mutex_t is record
X_X_D : array_type_10;
end record;
pragma Convention (C, pthread_mutex_t);
type array_type_11 is array (Integer range 0 .. 7) of long;
type pthread_cond_t is record
X_X_D : array_type_11;
end record;
pragma Convention (C, pthread_cond_t);
type pthread_key_t is new int;
end System.OS_Interface;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . A D D R E S S _ I M A G E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2003 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. --
-- --
------------------------------------------------------------------------------
-- This is a GNAT specific addition which provides a useful debugging
-- procedure that gives an (implementation dependent) string which
-- identifies an address.
-- This unit may be used directly from an application program by providing
-- an appropriate WITH, and the interface can be expected to remain stable.
function System.Address_Image (A : Address) return String;
pragma Pure (System.Address_Image);
-- Returns string (hexadecimal digits with upper case letters) representing
-- the address (string is 8/16 bytes for 32/64-bit machines).
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Exception_Handlers.Collections;
with AMF.UML.Input_Pins.Collections;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Output_Pins.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Ports;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Start_Object_Behavior_Actions;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.Visitors;
package AMF.Internals.UML_Start_Object_Behavior_Actions is
type UML_Start_Object_Behavior_Action_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Start_Object_Behavior_Actions.UML_Start_Object_Behavior_Action with null record;
overriding function Get_Object
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Input_Pins.UML_Input_Pin_Access;
-- Getter of StartObjectBehaviorAction::object.
--
-- Holds the object which is either a behavior to be started or has a
-- classifier behavior to be started.
overriding procedure Set_Object
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access);
-- Setter of StartObjectBehaviorAction::object.
--
-- Holds the object which is either a behavior to be started or has a
-- classifier behavior to be started.
overriding function Get_Is_Synchronous
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return Boolean;
-- Getter of CallAction::isSynchronous.
--
-- If true, the call is synchronous and the caller waits for completion of
-- the invoked behavior. If false, the call is asynchronous and the caller
-- proceeds immediately and does not expect a return values.
overriding procedure Set_Is_Synchronous
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : Boolean);
-- Setter of CallAction::isSynchronous.
--
-- If true, the call is synchronous and the caller waits for completion of
-- the invoked behavior. If false, the call is asynchronous and the caller
-- proceeds immediately and does not expect a return values.
overriding function Get_Result
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin;
-- Getter of CallAction::result.
--
-- A list of output pins where the results of performing the invocation
-- are placed.
overriding function Get_Argument
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin;
-- Getter of InvocationAction::argument.
--
-- Specification of the ordered set of argument values that appears during
-- execution.
overriding function Get_On_Port
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Ports.UML_Port_Access;
-- Getter of InvocationAction::onPort.
--
-- A optional port of the receiver object on which the behavioral feature
-- is invoked.
overriding procedure Set_On_Port
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : AMF.UML.Ports.UML_Port_Access);
-- Setter of InvocationAction::onPort.
--
-- A optional port of the receiver object on which the behavioral feature
-- is invoked.
overriding function Get_Context
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access;
-- Getter of Action::context.
--
-- The classifier that owns the behavior of which this action is a part.
overriding function Get_Input
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin;
-- Getter of Action::input.
--
-- The ordered set of input pins connected to the Action. These are among
-- the total set of inputs.
overriding function Get_Is_Locally_Reentrant
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return Boolean;
-- Getter of Action::isLocallyReentrant.
--
-- If true, the action can begin a new, concurrent execution, even if
-- there is already another execution of the action ongoing. If false, the
-- action cannot begin a new execution until any previous execution has
-- completed.
overriding procedure Set_Is_Locally_Reentrant
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : Boolean);
-- Setter of Action::isLocallyReentrant.
--
-- If true, the action can begin a new, concurrent execution, even if
-- there is already another execution of the action ongoing. If false, the
-- action cannot begin a new execution until any previous execution has
-- completed.
overriding function Get_Local_Postcondition
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Action::localPostcondition.
--
-- Constraint that must be satisfied when executed is completed.
overriding function Get_Local_Precondition
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Action::localPrecondition.
--
-- Constraint that must be satisfied when execution is started.
overriding function Get_Output
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin;
-- Getter of Action::output.
--
-- The ordered set of output pins connected to the Action. The action
-- places its results onto pins in this set.
overriding function Get_Handler
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler;
-- Getter of ExecutableNode::handler.
--
-- A set of exception handlers that are examined if an uncaught exception
-- propagates to the outer level of the executable node.
overriding function Get_Activity
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Start_Object_Behavior_Action_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Context
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access;
-- Operation Action::context.
--
-- Missing derivation for Action::/context : Classifier
overriding function Is_Consistent_With
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Start_Object_Behavior_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Start_Object_Behavior_Actions;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . B U B B L E _ S O R T _ G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-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. --
-- --
------------------------------------------------------------------------------
-- Bubblesort generic package using formal procedures
-- This package provides a generic bubble sort routine that can be used with
-- different types of data.
-- See also GNAT.Bubble_Sort, a version that works with subprogram access
-- parameters, allowing code sharing. The generic version is slightly more
-- efficient but does not allow code sharing and has an interface that is
-- more awkward to use.
-- There is also GNAT.Bubble_Sort_A, which is now considered obsolete, but
-- was an older version working with subprogram parameters. This version
-- is retained for backwards compatibility with old versions of GNAT.
generic
-- The data to be sorted is assumed to be indexed by integer values from
-- 1 to N, where N is the number of items to be sorted. In addition, the
-- index value zero is used for a temporary location used during the sort.
with procedure Move (From : Natural; To : Natural);
-- A procedure that moves the data item with index value From to the data
-- item with index value To (the old value in To being lost). An index
-- value of zero is used for moves from and to a single temporary location
-- used by the sort.
with function Lt (Op1, Op2 : Natural) return Boolean;
-- A function that compares two items and returns True if the item with
-- index Op1 is less than the item with Index Op2, and False if the Op2
-- item is greater than or equal to the Op1 item.
package GNAT.Bubble_Sort_G is
pragma Pure;
procedure Sort (N : Natural);
-- This procedures sorts items in the range from 1 to N into ascending
-- order making calls to Lt to do required comparisons, and Move to move
-- items around. Note that, as described above, both Move and Lt use a
-- single temporary location with index value zero. This sort is stable,
-- that is the order of equal elements in the input is preserved.
end GNAT.Bubble_Sort_G;
|
-- Suggestions for packages which might be useful:
with Ada.Real_Time; use Ada.Real_Time;
with Vectors_3D; use Vectors_3D;
with Swarm_Structures_Base; use Swarm_Structures_Base;
with Vehicle_Task_Type; use Vehicle_Task_Type;
-- Author : Wenjun Yang
-- u_id : u6251843
package Vehicle_Message_Type is
-- Replace this record definition by what your vehicles need to communicate.
type Inter_Vehicle_Messages is
record
-- Vehicle_ID in the message, for recognizing the source of message
ID : Positive;
-- The message sent time
Message_Send_Time : Time;
-- Record whether the drone finds the globe or not
Energy_Globe_Find : Boolean;
-- Record the position of energy globe
Energy_Globe_Pos : Vector_3D;
-- Record the current energy level of corresponding drone
My_Energy : Vehicle_Charges;
-- Message of all the live drones' vehicle_No
Exist_Neighbours_No : No_Set;
-- Message of all the dead drones' vehicle_No
Delete_Neighbours_No : No_Set;
end record;
end Vehicle_Message_Type;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . U T F _ E N C O D I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body Ada.Strings.UTF_Encoding is
use Interfaces;
--------------
-- Encoding --
--------------
function Encoding
(Item : UTF_String;
Default : Encoding_Scheme := UTF_8) return Encoding_Scheme
is
begin
if Item'Length >= 2 then
if Item (Item'First .. Item'First + 1) = BOM_16BE then
return UTF_16BE;
elsif Item (Item'First .. Item'First + 1) = BOM_16LE then
return UTF_16LE;
elsif Item'Length >= 3
and then Item (Item'First .. Item'First + 2) = BOM_8
then
return UTF_8;
end if;
end if;
return Default;
end Encoding;
-----------------
-- From_UTF_16 --
-----------------
function From_UTF_16
(Item : UTF_16_Wide_String;
Output_Scheme : UTF_XE_Encoding;
Output_BOM : Boolean := False) return UTF_String
is
BSpace : constant Natural := 2 * Boolean'Pos (Output_BOM);
Result : UTF_String (1 .. 2 * Item'Length + BSpace);
Len : Natural;
C : Unsigned_16;
Iptr : Natural;
begin
if Output_BOM then
Result (1 .. 2) :=
(if Output_Scheme = UTF_16BE then BOM_16BE else BOM_16LE);
Len := 2;
else
Len := 0;
end if;
-- Skip input BOM
Iptr := Item'First;
if Iptr <= Item'Last and then Item (Iptr) = BOM_16 (1) then
Iptr := Iptr + 1;
end if;
-- UTF-16BE case
if Output_Scheme = UTF_16BE then
while Iptr <= Item'Last loop
C := To_Unsigned_16 (Item (Iptr));
Result (Len + 1) := Character'Val (Shift_Right (C, 8));
Result (Len + 2) := Character'Val (C and 16#00_FF#);
Len := Len + 2;
Iptr := Iptr + 1;
end loop;
-- UTF-16LE case
else
while Iptr <= Item'Last loop
C := To_Unsigned_16 (Item (Iptr));
Result (Len + 1) := Character'Val (C and 16#00_FF#);
Result (Len + 2) := Character'Val (Shift_Right (C, 8));
Len := Len + 2;
Iptr := Iptr + 1;
end loop;
end if;
return Result (1 .. Len);
end From_UTF_16;
--------------------------
-- Raise_Encoding_Error --
--------------------------
procedure Raise_Encoding_Error (Index : Natural) is
Val : constant String := Index'Img;
begin
raise Encoding_Error with
"bad input at Item (" & Val (Val'First + 1 .. Val'Last) & ')';
end Raise_Encoding_Error;
---------------
-- To_UTF_16 --
---------------
function To_UTF_16
(Item : UTF_String;
Input_Scheme : UTF_XE_Encoding;
Output_BOM : Boolean := False) return UTF_16_Wide_String
is
Result : UTF_16_Wide_String (1 .. Item'Length / 2 + 1);
Len : Natural;
Iptr : Natural;
begin
if Item'Length mod 2 /= 0 then
raise Encoding_Error with "UTF-16BE/LE string has odd length";
end if;
-- Deal with input BOM, skip if OK, error if bad BOM
Iptr := Item'First;
if Item'Length >= 2 then
if Item (Iptr .. Iptr + 1) = BOM_16BE then
if Input_Scheme = UTF_16BE then
Iptr := Iptr + 2;
else
Raise_Encoding_Error (Iptr);
end if;
elsif Item (Iptr .. Iptr + 1) = BOM_16LE then
if Input_Scheme = UTF_16LE then
Iptr := Iptr + 2;
else
Raise_Encoding_Error (Iptr);
end if;
elsif Item'Length >= 3 and then Item (Iptr .. Iptr + 2) = BOM_8 then
Raise_Encoding_Error (Iptr);
end if;
end if;
-- Output BOM if specified
if Output_BOM then
Result (1) := BOM_16 (1);
Len := 1;
else
Len := 0;
end if;
-- UTF-16BE case
if Input_Scheme = UTF_16BE then
while Iptr < Item'Last loop
Len := Len + 1;
Result (Len) :=
Wide_Character'Val
(Character'Pos (Item (Iptr)) * 256 +
Character'Pos (Item (Iptr + 1)));
Iptr := Iptr + 2;
end loop;
-- UTF-16LE case
else
while Iptr < Item'Last loop
Len := Len + 1;
Result (Len) :=
Wide_Character'Val
(Character'Pos (Item (Iptr)) +
Character'Pos (Item (Iptr + 1)) * 256);
Iptr := Iptr + 2;
end loop;
end if;
return Result (1 .. Len);
end To_UTF_16;
end Ada.Strings.UTF_Encoding;
|
with Metric.Kasner; use Metric.Kasner;
with ADMBase.Coords; use ADMBase.Coords;
package body ADMBase.Initial is
procedure create_data is
t, x, y, z : Real;
begin
t := beg_time;
for i in 1..num_x loop
for j in 1..num_y loop
for k in 1..num_z loop
x := x_coord (i);
y := y_coord (j);
z := z_coord (k);
N (i,j,k) := set_3d_lapse (t,x,y,z);
gab (i,j,k) := set_3d_metric (t,x,y,z);
Kab (i,j,k) := set_3d_extcurv (t,x,y,z);
end loop;
end loop;
end loop;
end create_data;
procedure create_grid is
a, b, c : Integer := 0;
p, q, r, s, u, v : Integer := 0;
x, y, z : Real;
begin
for i in 1..num_x loop
for j in 1..num_y loop
for k in 1..num_z loop
x := x_coord (i);
y := y_coord (j);
z := z_coord (k);
a := a + 1;
grid_point_list (a) := (i,j,k,x,y,z);
if (i>1) and (i<num_x) and
(j>1) and (j<num_y) and
(k>1) and (k<num_z)
then
b := b+1;
interior (b) := a;
else
c := c+1;
boundary (c) := a;
if k = num_z then
p := p + 1;
north_bndry (p) := a;
else
if k = 1 then
q := q + 1;
south_bndry (q) := a;
else
if j = num_y then
r := r + 1;
east_bndry (r) := a;
else
if j = 1 then
s := s + 1;
west_bndry (s) := a;
else
if i = num_x then
u := u + 1;
front_bndry (u) := a;
else
if i = 1 then
v := v + 1;
back_bndry (v) := a;
end if;
end if;
end if;
end if;
end if;
end if;
end if;
end loop;
end loop;
end loop;
interior_num := b;
boundary_num := c;
north_bndry_num := p;
south_bndry_num := q;
east_bndry_num := r;
west_bndry_num := s;
front_bndry_num := u;
back_bndry_num := v;
if boundary_num /= (north_bndry_num + south_bndry_num + east_bndry_num + west_bndry_num + front_bndry_num + back_bndry_num) then
put_line ("> Error in create_grid: boundary not equal sum of parts");
halt (1);
end if;
if grid_point_num /= interior_num + boundary_num then
put_line ("> Error in create_grid: boundary + interior not equal to whole");
halt (1);
end if;
if a /= grid_point_num then
put_line ("> Error in create_grid: incorrect number of grid points");
halt (1);
end if;
end create_grid;
end ADMBase.Initial;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T A G S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System;
with System.Storage_Elements;
package Ada.Tags is
pragma Elaborate_Body;
type Tag is private;
function Expanded_Name (T : Tag) return String;
function External_Tag (T : Tag) return String;
function Internal_Tag (External : String) return Tag;
Tag_Error : exception;
private
----------------------------------------------------------------
-- Abstract procedural interface for the GNAT dispatch table --
----------------------------------------------------------------
-- GNAT's Dispatch Table format is customizable in order to match the
-- format used in another language. GNAT supports programs that use
-- two different dispatch table format at the same time: the native
-- format that supports Ada 95 tagged types and which is described in
-- Ada.Tags and a foreign format for types that are imported from some
-- other language (typically C++) which is described in interfaces.cpp.
-- The runtime information kept for each tagged type is separated into
-- two objects: the Dispatch Table and the Type Specific Data record.
-- These two objects are allocated statically using the constants:
-- DT Size = DT_Prologue_Size + Nb_Prim * DT_Entry_Size
-- TSD Size = TSD_Prologue_Size + (1 + Idepth) * TSD_Entry_Size
-- where Nb_prim is the number of primitive operations of the given
-- type and Idepth its inheritance depth.
-- The compiler generates calls to the following SET routines to
-- initialize those structures and uses the GET functions to
-- retreive the information when needed
package S renames System;
package SSE renames System.Storage_Elements;
function CW_Membership (Obj_Tag : Tag; Typ_Tag : Tag) return Boolean;
-- Given the tag of an object and the tag associated to a type, return
-- true if Obj is in Typ'Class.
function Get_Expanded_Name (T : Tag) return S.Address;
-- Retrieve the address of a null terminated string containing
-- the expanded name
function Get_External_Tag (T : Tag) return S.Address;
-- Retrieve the address of a null terminated string containing
-- the external name
function Get_Prim_Op_Address
(T : Tag;
Position : Positive)
return S.Address;
-- Given a pointer to a dispatch Table (T) and a position in the DT
-- this function returns the address of the virtual function stored
-- in it (used for dispatching calls)
function Get_Inheritance_Depth (T : Tag) return Natural;
-- Given a pointer to a dispatch Table, retrieves the value representing
-- the depth in the inheritance tree (used for membership).
function Get_RC_Offset (T : Tag) return SSE.Storage_Offset;
-- Return the Offset of the implicit record controller when the object
-- has controlled components. O otherwise.
pragma Export (Ada, Get_RC_Offset, "ada__tags__get_rc_offset");
-- This procedure is used in s-finimp to compute the deep routines
-- it is exported manually in order to avoid changing completely the
-- organization of the run time.
function Get_Remotely_Callable (T : Tag) return Boolean;
-- Return the value previously set by Set_Remotely_Callable
function Get_TSD (T : Tag) return S.Address;
-- Given a pointer T to a dispatch Table, retreives the address of the
-- record containing the Type Specific Data generated by GNAT
procedure Inherit_DT
(Old_T : Tag;
New_T : Tag;
Entry_Count : Natural);
-- Entry point used to initialize the DT of a type knowing the tag
-- of the direct ancestor and the number of primitive ops that are
-- inherited (Entry_Count).
procedure Inherit_TSD (Old_TSD : S.Address; New_Tag : Tag);
-- Entry point used to initialize the TSD of a type knowing the
-- TSD of the direct ancestor.
function Parent_Size (Obj : S.Address) return SSE.Storage_Count;
-- Computes the size of field _Parent of a tagged extension object
-- whose address is 'obj' by calling the indirectly _size function of
-- the parent. This function assumes that _size is always in slot 1 of
-- the dispatch table.
pragma Export (Ada, Parent_Size, "ada__tags__parent_size");
-- This procedure is used in s-finimp and is thus exported manually
procedure Register_Tag (T : Tag);
-- Insert the Tag and its associated external_tag in a table for the
-- sake of Internal_Tag
procedure Set_Inheritance_Depth
(T : Tag;
Value : Natural);
-- Given a pointer to a dispatch Table, stores the value representing
-- the depth in the inheritance tree (the second parameter). Used during
-- elaboration of the tagged type.
procedure Set_Prim_Op_Address
(T : Tag;
Position : Positive;
Value : S.Address);
-- Given a pointer to a dispatch Table (T) and a position in the
-- dispatch Table put the address of the virtual function in it
-- (used for overriding)
procedure Set_TSD (T : Tag; Value : S.Address);
-- Given a pointer T to a dispatch Table, stores the address of the record
-- containing the Type Specific Data generated by GNAT
procedure Set_Expanded_Name (T : Tag; Value : S.Address);
-- Set the address of the string containing the expanded name
-- in the Dispatch table
procedure Set_External_Tag (T : Tag; Value : S.Address);
-- Set the address of the string containing the external tag
-- in the Dispatch table
procedure Set_RC_Offset (T : Tag; Value : SSE.Storage_Offset);
-- Sets the Offset of the implicit record controller when the object
-- has controlled components. Set to O otherwise.
procedure Set_Remotely_Callable (T : Tag; Value : Boolean);
-- Set to true if the type has been declared in a context described
-- in E.4 (18)
DT_Prologue_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(Standard'Address_Size / S.Storage_Unit);
-- Size of the first part of the dispatch table
DT_Entry_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(Standard'Address_Size / S.Storage_Unit);
-- Size of each primitive operation entry in the Dispatch Table.
TSD_Prologue_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(6 * Standard'Address_Size / S.Storage_Unit);
-- Size of the first part of the type specific data
TSD_Entry_Size : constant SSE.Storage_Count :=
SSE.Storage_Count (Standard'Address_Size / S.Storage_Unit);
-- Size of each ancestor tag entry in the TSD
type Address_Array is array (Natural range <>) of S.Address;
type Dispatch_Table;
type Tag is access all Dispatch_Table;
type Type_Specific_Data;
type Type_Specific_Data_Ptr is access all Type_Specific_Data;
pragma Inline_Always (CW_Membership);
pragma Inline_Always (Get_Expanded_Name);
pragma Inline_Always (Get_Inheritance_Depth);
pragma Inline_Always (Get_Prim_Op_Address);
pragma Inline_Always (Get_RC_Offset);
pragma Inline_Always (Get_Remotely_Callable);
pragma Inline_Always (Get_TSD);
pragma Inline_Always (Inherit_DT);
pragma Inline_Always (Inherit_TSD);
pragma Inline_Always (Register_Tag);
pragma Inline_Always (Set_Expanded_Name);
pragma Inline_Always (Set_External_Tag);
pragma Inline_Always (Set_Inheritance_Depth);
pragma Inline_Always (Set_Prim_Op_Address);
pragma Inline_Always (Set_RC_Offset);
pragma Inline_Always (Set_Remotely_Callable);
pragma Inline_Always (Set_TSD);
end Ada.Tags;
|
package Debug2_Pkg is
type String_Ptr is access all String;
function To_Heap return String_Ptr;
type String_List(Chars_Length: Positive) is private;
type String_List_Ptr is access constant String_List;
function Singleton return String_List;
private
type String_List(Chars_Length: Positive) is record
Chars: String(1..Chars_Length);
end record;
end Debug2_Pkg;
|
-----------------------------------------------------------------------
-- mat-readers-tests -- Unit tests for MAT readers
-- Copyright (C) 2014, 2015, 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with MAT.Readers.Streams.Files;
package body MAT.Targets.Tests is
package Caller is new Util.Test_Caller (Test, "Files");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test MAT.Targets.Read_File",
Test_Read_File'Access);
Caller.Add_Test (Suite, "Test MAT.Types.Tick_Value",
Test_Conversions'Access);
end Add_Tests;
-- ------------------------------
-- Test reading a file into a string
-- Reads this ada source file and checks we have read it correctly
-- ------------------------------
procedure Test_Read_File (T : in out Test) is
pragma Unreferenced (T);
Path : constant String := Util.Tests.Get_Path ("regtests/files/file-v1.dat");
Target : MAT.Targets.Target_Type;
Reader : MAT.Readers.Streams.Files.File_Reader_Type;
begin
Target.Initialize (Reader);
Reader.Open (Path);
Reader.Read_All;
end Test_Read_File;
-- ------------------------------
-- Test various type conversions.
-- ------------------------------
procedure Test_Conversions (T : in out Test) is
use MAT.Types;
Time : MAT.Types.Target_Tick_Ref;
begin
Time := MAT.Types.Tick_Value ("1.1");
Util.Tests.Assert_Equals (T, 1, Natural (Time / 1_000000), "Invalid Tick_Value conversion");
Util.Tests.Assert_Equals (T, 100_000, Natural (Time mod 1_000000),
"Invalid Tick_Value conversion");
Time := MAT.Types.Tick_Value ("12.001234");
Util.Tests.Assert_Equals (T, 12, Natural (Time / 1_000000), "Invalid Tick_Value conversion");
Util.Tests.Assert_Equals (T, 1_234, Natural (Time mod 1_000000),
"Invalid Tick_Value conversion");
end Test_Conversions;
end MAT.Targets.Tests;
|
-----------------------------------------------------------------------
-- are-generator-c-tests -- Tests for C generator
-- 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.Directories;
with Util.Test_Caller;
package body Are.Generator.C.Tests is
Expect_Dir : constant String := "regtests/expect/c/";
function Tool return String;
package Caller is new Util.Test_Caller (Test, "Are.Generator.C");
function Tool return String is
begin
return "bin/are" & Are.Testsuite.EXE;
end Tool;
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Are.Generate_C1",
Test_Generate_C1'Access);
Caller.Add_Test (Suite, "Test Are.Generate_C2",
Test_Generate_C2'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Lines",
Test_Generate_Lines'Access);
end Add_Tests;
procedure Test_Generate_C1 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-c-1/web";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " --lang=c -o " & Dir & " --name-access "
& "--resource=Resources1 --fileset '**/*' "
& Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources1.h")),
"Resource file 'resources1.h' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources1.c")),
"Resource file 'resources1.c' not generated");
-- Build the test program.
T.Execute ("make -C regtests/files/test-c-1", Result);
T.Assert (Ada.Directories.Exists ("bin/test-c-1" & Are.Testsuite.EXE),
"Binary file 'bin/test-c-1' not created");
T.Execute ("bin/test-c-1" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: body { background: #eee; }p"
& " { color: #2a2a2a; }", Result,
"Invalid generation");
end Test_Generate_C1;
procedure Test_Generate_C2 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-c-2/web";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " --lang=c -o " & Dir
& " --name-access --var-prefix Id_ --resource=Resources2 --fileset '**/*' "
& Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources2.h")),
"Resource file 'resources2.h' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources2.c")),
"Resource file 'resources2.c' not generated");
-- Build the test program.
T.Execute ("make -C regtests/files/test-c-2", Result);
T.Assert (Ada.Directories.Exists ("bin/test-c-2" & Are.Testsuite.EXE),
"Binary file 'bin/test-c-2' not created");
T.Execute ("bin/test-c-2" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: body { background: #eee; }p"
& " { color: #2a2a2a; }", Result,
"Invalid generation");
end Test_Generate_C2;
procedure Test_Generate_Lines (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Rule : constant String := "regtests/files/package-lines.xml";
Files : constant String := "regtests/files";
Lines_H : constant String := Ada.Directories.Compose (Dir, "lines.h");
Lines_C : constant String := Ada.Directories.Compose (Dir, "lines.c");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the lines.ads files
T.Execute (Tool & " -o " & Dir & " --lang=c --content-only --var-prefix Id_ --rule="
& Rule & " " & Files & "/lines-empty", Result);
T.Assert (Ada.Directories.Exists (Lines_H),
"Resource file 'lines.h' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-empty.h"),
Test => Lines_H,
Message => "Invalid lines-empty.h generation");
T.Assert (Ada.Directories.Exists (Lines_C),
"Resource file 'lines.c' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-empty.c"),
Test => Lines_C,
Message => "Invalid lines-empty.c generation");
Ada.Directories.Delete_File (Lines_H);
Ada.Directories.Delete_File (Lines_C);
T.Execute (Tool & " -o " & Dir & " --lang=c --content-only --var-prefix Id_ --rule="
& Rule & " " & Files & "/lines-single", Result);
T.Assert (Ada.Directories.Exists (Lines_H),
"Resource file 'lines.h' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-single.h"),
Test => Lines_H,
Message => "Invalid lines-single.h generation");
T.Assert (Ada.Directories.Exists (Lines_C),
"Resource file 'lines.c' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-single.c"),
Test => Lines_C,
Message => "Invalid lines-single.c generation");
Ada.Directories.Delete_File (Lines_H);
Ada.Directories.Delete_File (Lines_C);
T.Execute (Tool & " -o " & Dir & " --lang=c --content-only --var-prefix Id_ --rule="
& Rule & " " & Files & "/lines-multiple", Result);
T.Assert (Ada.Directories.Exists (Lines_H),
"Resource file 'lines.h' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-multiple.h"),
Test => Lines_H,
Message => "Invalid lines-multiple.h generation");
T.Assert (Ada.Directories.Exists (Lines_C),
"Resource file 'lines.c' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-multiple.c"),
Test => Lines_C,
Message => "Invalid lines-multiple.c generation");
end Test_Generate_Lines;
end Are.Generator.C.Tests;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- G N A T . H E A P _ S O R T _ G --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1995-2000 Ada Core Technologies, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- Heapsort generic package using formal procedures
-- This package provides a generic heapsort routine that can be used with
-- different types of data. See also GNAT.Heap_Sort_A, a version that works
-- with subprogram parameters, allowing code sharing. The generic version
-- is slightly more efficient but does not allow code sharing. The generic
-- version is also Pure, while the access version can only be Preelaborate.
generic
-- The data to be sorted is assumed to be indexed by integer values from
-- 1 to N, where N is the number of items to be sorted. In addition, the
-- index value zero is used for a temporary location used during the sort.
with procedure Move (From : Natural; To : Natural);
-- A procedure that moves the data item with index From to the data item
-- with Index To. An index value of zero is used for moves from and to a
-- single temporary location used by the sort.
with function Lt (Op1, Op2 : Natural) return Boolean;
-- A function that compares two items and returns True if the item with
-- index Op1 is less than the item with Index Op2, and False if the Op1
-- item is greater than or equal to the Op2 item.
package GNAT.Heap_Sort_G is
pragma Pure (Heap_Sort_G);
procedure Sort (N : Natural);
-- This procedures sorts items in the range from 1 to N into ascending
-- order making calls to Lt to do required comparisons, and Move to move
-- items around. Note that, as described above, both Move and Lt use a
-- single temporary location with index value zero. This sort is not
-- stable, i.e. the order of equal elements in the input is not preserved.
end GNAT.Heap_Sort_G;
|
pragma License (Unrestricted);
-- generalized unit of Ada.Strings.UTF_Encoding.Strings
generic
type Character_Type is (<>);
type String_Type is array (Positive range <>) of Character_Type;
Expanding_From_8 : Positive;
Expanding_From_16 : Positive;
Expanding_From_32 : Positive;
Expanding_To_8 : Positive;
Expanding_To_16 : Positive;
Expanding_To_32 : Positive;
with procedure Get (
Item : String_Type;
Last : out Natural;
Value : out Wide_Wide_Character;
Is_Illegal_Sequence : out Boolean);
with procedure Put (
Value : Wide_Wide_Character;
Item : out String_Type;
Last : out Natural);
package Ada.Strings.UTF_Encoding.Generic_Strings is
pragma Pure;
-- Encoding / decoding between String_Type and various encoding schemes
function Encode (
Item : String_Type;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False)
return UTF_String;
function Encode (Item : String_Type; Output_BOM : Boolean := False)
return UTF_8_String;
function Encode (Item : String_Type; Output_BOM : Boolean := False)
return UTF_16_Wide_String;
-- extended
function Encode (Item : String_Type; Output_BOM : Boolean := False)
return UTF_32_Wide_Wide_String;
function Decode (Item : UTF_String; Input_Scheme : Encoding_Scheme)
return String_Type;
function Decode (Item : UTF_8_String) return String_Type;
function Decode (Item : UTF_16_Wide_String) return String_Type;
-- extended
function Decode (Item : UTF_32_Wide_Wide_String) return String_Type;
end Ada.Strings.UTF_Encoding.Generic_Strings;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- I N T E R F A C E S . V X W O R K S . I O --
-- --
-- S p e c --
-- --
-- Copyright (C) 2002-2020, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides a binding to the functions fileno and ioctl
-- in VxWorks, providing a set of definitions of ioctl function codes
-- and options for the use of these functions.
-- A particular use of this interface is to enable use of Get_Immediate
-- in Ada.Text_IO. There is no way in VxWorks to provide the desired
-- functionality of Get_Immediate (no buffering and no waiting for a
-- line return) without flushing the buffer, which violates the Ada
-- semantic requirements for Ada.Text_IO.
with Interfaces.C_Streams;
package Interfaces.VxWorks.IO is
-------------------------
-- The ioctl Interface --
--------------------------
type FUNCODE is new int;
-- Type of the function codes in ioctl
type IOOPT is mod 2 ** int'Size;
-- Type of the option codes in ioctl
-- ioctl function codes (for more information see ioLib.h)
-- These values could be generated automatically in System.OS_Constants???
FIONREAD : constant FUNCODE := 1;
FIOFLUSH : constant FUNCODE := 2;
FIOOPTIONS : constant FUNCODE := 3;
FIOBAUDRATE : constant FUNCODE := 4;
FIODISKFORMAT : constant FUNCODE := 5;
FIODISKINIT : constant FUNCODE := 6;
FIOSEEK : constant FUNCODE := 7;
FIOWHERE : constant FUNCODE := 8;
FIODIRENTRY : constant FUNCODE := 9;
FIORENAME : constant FUNCODE := 10;
FIOREADYCHANGE : constant FUNCODE := 11;
FIONWRITE : constant FUNCODE := 12;
FIODISKCHANGE : constant FUNCODE := 13;
FIOCANCEL : constant FUNCODE := 14;
FIOSQUEEZE : constant FUNCODE := 15;
FIONBIO : constant FUNCODE := 16;
FIONMSGS : constant FUNCODE := 17;
FIOGETNAME : constant FUNCODE := 18;
FIOGETOPTIONS : constant FUNCODE := 19;
FIOSETOPTIONS : constant FUNCODE := FIOOPTIONS;
FIOISATTY : constant FUNCODE := 20;
FIOSYNC : constant FUNCODE := 21;
FIOPROTOHOOK : constant FUNCODE := 22;
FIOPROTOARG : constant FUNCODE := 23;
FIORBUFSET : constant FUNCODE := 24;
FIOWBUFSET : constant FUNCODE := 25;
FIORFLUSH : constant FUNCODE := 26;
FIOWFLUSH : constant FUNCODE := 27;
FIOSELECT : constant FUNCODE := 28;
FIOUNSELECT : constant FUNCODE := 29;
FIONFREE : constant FUNCODE := 30;
FIOMKDIR : constant FUNCODE := 31;
FIORMDIR : constant FUNCODE := 32;
FIOLABELGET : constant FUNCODE := 33;
FIOLABELSET : constant FUNCODE := 34;
FIOATTRIBSE : constant FUNCODE := 35;
FIOCONTIG : constant FUNCODE := 36;
FIOREADDIR : constant FUNCODE := 37;
FIOFSTATGET : constant FUNCODE := 38;
FIOUNMOUNT : constant FUNCODE := 39;
FIOSCSICOMMAND : constant FUNCODE := 40;
FIONCONTIG : constant FUNCODE := 41;
FIOTRUNC : constant FUNCODE := 42;
FIOGETFL : constant FUNCODE := 43;
FIOTIMESET : constant FUNCODE := 44;
FIOINODETONAM : constant FUNCODE := 45;
FIOFSTATFSGE : constant FUNCODE := 46;
-- ioctl option values
OPT_ECHO : constant IOOPT := 16#0001#;
OPT_CRMOD : constant IOOPT := 16#0002#;
OPT_TANDEM : constant IOOPT := 16#0004#;
OPT_7_BIT : constant IOOPT := 16#0008#;
OPT_MON_TRAP : constant IOOPT := 16#0010#;
OPT_ABORT : constant IOOPT := 16#0020#;
OPT_LINE : constant IOOPT := 16#0040#;
OPT_RAW : constant IOOPT := 16#0000#;
OPT_TERMINAL : constant IOOPT := OPT_ECHO or
OPT_CRMOD or
OPT_TANDEM or
OPT_MON_TRAP or
OPT_7_BIT or
OPT_ABORT or
OPT_LINE;
function fileno (Fp : Interfaces.C_Streams.FILEs) return int;
pragma Import (C, fileno, "fileno");
-- Binding to the C routine fileno
function ioctl (Fd : int; Function_Code : FUNCODE; Arg : IOOPT) return int;
pragma Import (C, ioctl, "ioctl");
-- Binding to the C routine ioctl
--
-- Note: we are taking advantage of the fact that on currently supported
-- VxWorks targets, it is fine to directly bind to a variadic C function.
------------------------------
-- Control of Get_Immediate --
------------------------------
-- The procedures in this section make use of the interface to ioctl
-- and fileno to provide a mechanism for enabling unbuffered behavior
-- for Get_Immediate in VxWorks.
-- The situation is that the RM requires that the use of Get_Immediate
-- be identical to Get except that it is desirable (not required) that
-- there be no buffering or line editing.
-- Unfortunately, in VxWorks, the only way to enable this desired
-- unbuffered behavior involves changing into raw mode. But this
-- transition into raw mode flushes the input buffer, a behavior
-- not permitted by the RM semantics for Get_Immediate.
-- Given that Get_Immediate cannot be accurately implemented in
-- raw mode, it seems best not to enable it by default, and instead
-- to require specific programmer action, with the programmer being
-- aware that input may be lost.
-- The following is an example of the use of the two procedures
-- in this section (Enable_Get_Immediate and Disable_Get_Immediate)
-- with Ada.Text_IO; use Ada.Text_IO;
-- with Ada.Text_IO.C_Streams; use Ada.Text_IO.C_Streams;
-- with Interfaces.VxWorks.IO; use Interfaces.VxWorks.IO;
-- procedure Example_IO is
-- Input : Character;
-- Available : Boolean;
-- Success : Boolean;
-- begin
-- Enable_Get_Immediate (C_Stream (Current_Input), Success);
-- if Success = False then
-- raise Device_Error;
-- end if;
-- -- Example with the first type of Get_Immediate
-- -- Waits for an entry on the input. Immediately returns
-- -- after having received an character on the input
-- Put ("Input -> ");
-- Get_Immediate (Input);
-- New_Line;
-- Put_Line ("Character read: " & Input);
-- -- Example with the second type of Get_Immediate
-- -- This is equivalent to a non blocking read
-- for J in 1 .. 10 loop
-- Put ("Input -> ");
-- Get_Immediate (Input, Available);
-- New_Line;
-- if Available = True then
-- Put_Line ("Character read: " & Input);
-- end if;
-- delay 1.0;
-- end loop;
-- Disable_Get_Immediate (C_Stream (Current_Input), Success);
-- if Success = False then
-- raise Device_Error;
-- end if;
-- exception
-- when Device_Error =>
-- Put_Line ("Device Error. Check your configuration");
-- end Example_IO;
procedure Enable_Get_Immediate
(File : Interfaces.C_Streams.FILEs;
Success : out Boolean);
-- On VxWorks, a call to this procedure is required before subsequent calls
-- to Get_Immediate have the desired effect of not waiting for a line
-- return. The reason that this call is not automatic on this target is
-- that the call flushes the input buffer, discarding any previous input.
-- Note: Following a call to Enable_Get_Immediate, the only permitted
-- operations on the relevant file are Get_Immediate operations. Any
-- other operations have undefined behavior.
procedure Disable_Get_Immediate
(File : Interfaces.C_Streams.FILEs;
Success : out Boolean);
-- This procedure resets File to standard mode, and permits subsequent
-- use of the full range of Ada.Text_IO functions
end Interfaces.VxWorks.IO;
|
M:part4a
F:G$putchar$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$getchar$0$0({2}DF,SC:S),Z,0,0,0,0,0
F:G$main$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$SYSCLK_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PORT_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$UART0_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$ADC_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$DAC_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$INTERRUPT_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$TIMER_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$MAC_INIT$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:G$start_conversion$0$0({1}SC:S),E,0,0
S:G$dig_val$0$0({2}SI:U),E,0,0
S:Lpart4a.main$adcValH$1$29({5}DA5d,SC:U),E,0,0
S:Lpart4a.main$adcValL$1$29({5}DA5d,SC:U),E,0,0
S:Lpart4a.main$result$1$29({2}SI:U),R,0,0,[r6,r7]
S:Lpart4a.main$results$1$29({4}DA2d,SI:U),E,0,0
S:Lpart4a.main$analogval$1$29({2}SI:U),R,0,0,[]
S:Lpart4a.main$analoghi$1$29({1}SC:U),R,0,0,[r4]
S:Lpart4a.main$analoglow$1$29({1}SC:U),R,0,0,[r5]
S:Lpart4a.main$VREF$1$29({4}SF:S),R,0,0,[]
S:G$P0$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$SFRPAGE$0$0({1}SC:U),I,0,0
S:G$SFRNEXT$0$0({1}SC:U),I,0,0
S:G$SFRLAST$0$0({1}SC:U),I,0,0
S:G$PCON$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$PSBANK$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$CKCON$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$SSTA0$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SCON$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SBUF$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$EMI0TC$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$EMI0CF$0$0({1}SC:U),I,0,0
S:G$SADDR0$0$0({1}SC:U),I,0,0
S:G$FLSCL$0$0({1}SC:U),I,0,0
S:G$SADEN0$0$0({1}SC:U),I,0,0
S:G$AMX0CF$0$0({1}SC:U),I,0,0
S:G$AMX0SL$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$SMB0CN$0$0({1}SC:U),I,0,0
S:G$SMB0STA$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$TMR2CN$0$0({1}SC:U),I,0,0
S:G$TMR2CF$0$0({1}SC:U),I,0,0
S:G$RCAP2L$0$0({1}SC:U),I,0,0
S:G$RCAP2H$0$0({1}SC:U),I,0,0
S:G$TMR2L$0$0({1}SC:U),I,0,0
S:G$TL2$0$0({1}SC:U),I,0,0
S:G$TMR2H$0$0({1}SC:U),I,0,0
S:G$TH2$0$0({1}SC:U),I,0,0
S:G$SMB0CR$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$DAC0L$0$0({1}SC:U),I,0,0
S:G$DAC0H$0$0({1}SC:U),I,0,0
S:G$DAC0CN$0$0({1}SC:U),I,0,0
S:G$PCA0CN$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM3$0$0({1}SC:U),I,0,0
S:G$PCA0CPM4$0$0({1}SC:U),I,0,0
S:G$PCA0CPM5$0$0({1}SC:U),I,0,0
S:G$PCA0CPL5$0$0({1}SC:U),I,0,0
S:G$PCA0CPH5$0$0({1}SC:U),I,0,0
S:G$ADC0CN$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL3$0$0({1}SC:U),I,0,0
S:G$PCA0CPH3$0$0({1}SC:U),I,0,0
S:G$PCA0CPL4$0$0({1}SC:U),I,0,0
S:G$PCA0CPH4$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$SPI0CN$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$CPT0CN$0$0({1}SC:U),I,0,0
S:G$CPT0MD$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$TMR3CN$0$0({1}SC:U),I,0,0
S:G$TMR3CF$0$0({1}SC:U),I,0,0
S:G$RCAP3L$0$0({1}SC:U),I,0,0
S:G$RCAP3H$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$DAC1L$0$0({1}SC:U),I,0,0
S:G$DAC1H$0$0({1}SC:U),I,0,0
S:G$DAC1CN$0$0({1}SC:U),I,0,0
S:G$CPT1CN$0$0({1}SC:U),I,0,0
S:G$CPT1MD$0$0({1}SC:U),I,0,0
S:G$AMX2CF$0$0({1}SC:U),I,0,0
S:G$AMX2SL$0$0({1}SC:U),I,0,0
S:G$ADC2CF$0$0({1}SC:U),I,0,0
S:G$ADC2$0$0({1}SC:U),I,0,0
S:G$ADC2GT$0$0({1}SC:U),I,0,0
S:G$ADC2LT$0$0({1}SC:U),I,0,0
S:G$TMR4CN$0$0({1}SC:U),I,0,0
S:G$TMR4CF$0$0({1}SC:U),I,0,0
S:G$RCAP4L$0$0({1}SC:U),I,0,0
S:G$RCAP4H$0$0({1}SC:U),I,0,0
S:G$TMR4L$0$0({1}SC:U),I,0,0
S:G$TMR4H$0$0({1}SC:U),I,0,0
S:G$ADC2CN$0$0({1}SC:U),I,0,0
S:G$MAC0BL$0$0({1}SC:U),I,0,0
S:G$MAC0BH$0$0({1}SC:U),I,0,0
S:G$MAC0ACC0$0$0({1}SC:U),I,0,0
S:G$MAC0ACC1$0$0({1}SC:U),I,0,0
S:G$MAC0ACC2$0$0({1}SC:U),I,0,0
S:G$MAC0ACC3$0$0({1}SC:U),I,0,0
S:G$MAC0OVR$0$0({1}SC:U),I,0,0
S:G$MAC0STA$0$0({1}SC:U),I,0,0
S:G$MAC0AL$0$0({1}SC:U),I,0,0
S:G$MAC0AH$0$0({1}SC:U),I,0,0
S:G$MAC0CF$0$0({1}SC:U),I,0,0
S:G$MAC0RNDL$0$0({1}SC:U),I,0,0
S:G$MAC0RNDH$0$0({1}SC:U),I,0,0
S:G$FLSTAT$0$0({1}SC:U),I,0,0
S:G$PLL0CN$0$0({1}SC:U),I,0,0
S:G$OSCICN$0$0({1}SC:U),I,0,0
S:G$OSCICL$0$0({1}SC:U),I,0,0
S:G$OSCXCN$0$0({1}SC:U),I,0,0
S:G$PLL0DIV$0$0({1}SC:U),I,0,0
S:G$PLL0MUL$0$0({1}SC:U),I,0,0
S:G$PLL0FLT$0$0({1}SC:U),I,0,0
S:G$SFRPGCN$0$0({1}SC:U),I,0,0
S:G$CLKSEL$0$0({1}SC:U),I,0,0
S:G$CCH0MA$0$0({1}SC:U),I,0,0
S:G$P4MDOUT$0$0({1}SC:U),I,0,0
S:G$P5MDOUT$0$0({1}SC:U),I,0,0
S:G$P6MDOUT$0$0({1}SC:U),I,0,0
S:G$P7MDOUT$0$0({1}SC:U),I,0,0
S:G$CCH0CN$0$0({1}SC:U),I,0,0
S:G$CCH0TN$0$0({1}SC:U),I,0,0
S:G$CCH0LC$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$FLACL$0$0({1}SC:U),I,0,0
S:G$P4$0$0({1}SC:U),I,0,0
S:G$P5$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$P6$0$0({1}SC:U),I,0,0
S:G$P7$0$0({1}SC:U),I,0,0
S:G$TMR0$0$0({2}SI:U),I,0,0
S:G$TMR1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$RCAP2$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DAC0$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0CP3$0$0({2}SI:U),I,0,0
S:G$PCA0CP4$0$0({2}SI:U),I,0,0
S:G$PCA0CP5$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$RCAP3$0$0({2}SI:U),I,0,0
S:G$DAC1$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$RCAP4$0$0({2}SI:U),I,0,0
S:G$MAC0A$0$0({2}SI:U),I,0,0
S:G$MAC0ACC$0$0({4}SL:U),I,0,0
S:G$MAC0RND$0$0({2}SI:U),I,0,0
S:G$P0_0$0$0({1}SX:U),J,0,0
S:G$P0_1$0$0({1}SX:U),J,0,0
S:G$P0_2$0$0({1}SX:U),J,0,0
S:G$P0_3$0$0({1}SX:U),J,0,0
S:G$P0_4$0$0({1}SX:U),J,0,0
S:G$P0_5$0$0({1}SX:U),J,0,0
S:G$P0_6$0$0({1}SX:U),J,0,0
S:G$P0_7$0$0({1}SX:U),J,0,0
S:G$IT0$0$0({1}SX:U),J,0,0
S:G$IE0$0$0({1}SX:U),J,0,0
S:G$IT1$0$0({1}SX:U),J,0,0
S:G$IE1$0$0({1}SX:U),J,0,0
S:G$TR0$0$0({1}SX:U),J,0,0
S:G$TF0$0$0({1}SX:U),J,0,0
S:G$TR1$0$0({1}SX:U),J,0,0
S:G$TF1$0$0({1}SX:U),J,0,0
S:G$CP0HYN0$0$0({1}SX:U),J,0,0
S:G$CP0HYN1$0$0({1}SX:U),J,0,0
S:G$CP0HYP0$0$0({1}SX:U),J,0,0
S:G$CP0HYP1$0$0({1}SX:U),J,0,0
S:G$CP0FIF$0$0({1}SX:U),J,0,0
S:G$CP0RIF$0$0({1}SX:U),J,0,0
S:G$CP0OUT$0$0({1}SX:U),J,0,0
S:G$CP0EN$0$0({1}SX:U),J,0,0
S:G$CP1HYN0$0$0({1}SX:U),J,0,0
S:G$CP1HYN1$0$0({1}SX:U),J,0,0
S:G$CP1HYP0$0$0({1}SX:U),J,0,0
S:G$CP1HYP1$0$0({1}SX:U),J,0,0
S:G$CP1FIF$0$0({1}SX:U),J,0,0
S:G$CP1RIF$0$0({1}SX:U),J,0,0
S:G$CP1OUT$0$0({1}SX:U),J,0,0
S:G$CP1EN$0$0({1}SX:U),J,0,0
S:G$FLHBUSY$0$0({1}SX:U),J,0,0
S:G$P1_0$0$0({1}SX:U),J,0,0
S:G$P1_1$0$0({1}SX:U),J,0,0
S:G$P1_2$0$0({1}SX:U),J,0,0
S:G$P1_3$0$0({1}SX:U),J,0,0
S:G$P1_4$0$0({1}SX:U),J,0,0
S:G$P1_5$0$0({1}SX:U),J,0,0
S:G$P1_6$0$0({1}SX:U),J,0,0
S:G$P1_7$0$0({1}SX:U),J,0,0
S:G$RI0$0$0({1}SX:U),J,0,0
S:G$RI$0$0({1}SX:U),J,0,0
S:G$TI0$0$0({1}SX:U),J,0,0
S:G$TI$0$0({1}SX:U),J,0,0
S:G$RB80$0$0({1}SX:U),J,0,0
S:G$TB80$0$0({1}SX:U),J,0,0
S:G$REN0$0$0({1}SX:U),J,0,0
S:G$REN$0$0({1}SX:U),J,0,0
S:G$SM20$0$0({1}SX:U),J,0,0
S:G$SM10$0$0({1}SX:U),J,0,0
S:G$SM00$0$0({1}SX:U),J,0,0
S:G$RI1$0$0({1}SX:U),J,0,0
S:G$TI1$0$0({1}SX:U),J,0,0
S:G$RB81$0$0({1}SX:U),J,0,0
S:G$TB81$0$0({1}SX:U),J,0,0
S:G$REN1$0$0({1}SX:U),J,0,0
S:G$MCE1$0$0({1}SX:U),J,0,0
S:G$S1MODE$0$0({1}SX:U),J,0,0
S:G$P2_0$0$0({1}SX:U),J,0,0
S:G$P2_1$0$0({1}SX:U),J,0,0
S:G$P2_2$0$0({1}SX:U),J,0,0
S:G$P2_3$0$0({1}SX:U),J,0,0
S:G$P2_4$0$0({1}SX:U),J,0,0
S:G$P2_5$0$0({1}SX:U),J,0,0
S:G$P2_6$0$0({1}SX:U),J,0,0
S:G$P2_7$0$0({1}SX:U),J,0,0
S:G$EX0$0$0({1}SX:U),J,0,0
S:G$ET0$0$0({1}SX:U),J,0,0
S:G$EX1$0$0({1}SX:U),J,0,0
S:G$ET1$0$0({1}SX:U),J,0,0
S:G$ES0$0$0({1}SX:U),J,0,0
S:G$ES$0$0({1}SX:U),J,0,0
S:G$ET2$0$0({1}SX:U),J,0,0
S:G$EA$0$0({1}SX:U),J,0,0
S:G$P3_0$0$0({1}SX:U),J,0,0
S:G$P3_1$0$0({1}SX:U),J,0,0
S:G$P3_2$0$0({1}SX:U),J,0,0
S:G$P3_3$0$0({1}SX:U),J,0,0
S:G$P3_4$0$0({1}SX:U),J,0,0
S:G$P3_5$0$0({1}SX:U),J,0,0
S:G$P3_6$0$0({1}SX:U),J,0,0
S:G$P3_7$0$0({1}SX:U),J,0,0
S:G$PX0$0$0({1}SX:U),J,0,0
S:G$PT0$0$0({1}SX:U),J,0,0
S:G$PX1$0$0({1}SX:U),J,0,0
S:G$PT1$0$0({1}SX:U),J,0,0
S:G$PS0$0$0({1}SX:U),J,0,0
S:G$PS$0$0({1}SX:U),J,0,0
S:G$PT2$0$0({1}SX:U),J,0,0
S:G$SMBTOE$0$0({1}SX:U),J,0,0
S:G$SMBFTE$0$0({1}SX:U),J,0,0
S:G$AA$0$0({1}SX:U),J,0,0
S:G$SI$0$0({1}SX:U),J,0,0
S:G$STO$0$0({1}SX:U),J,0,0
S:G$STA$0$0({1}SX:U),J,0,0
S:G$ENSMB$0$0({1}SX:U),J,0,0
S:G$BUSY$0$0({1}SX:U),J,0,0
S:G$MAC0N$0$0({1}SX:U),J,0,0
S:G$MAC0SO$0$0({1}SX:U),J,0,0
S:G$MAC0Z$0$0({1}SX:U),J,0,0
S:G$MAC0HO$0$0({1}SX:U),J,0,0
S:G$CPRL2$0$0({1}SX:U),J,0,0
S:G$CT2$0$0({1}SX:U),J,0,0
S:G$TR2$0$0({1}SX:U),J,0,0
S:G$EXEN2$0$0({1}SX:U),J,0,0
S:G$EXF2$0$0({1}SX:U),J,0,0
S:G$TF2$0$0({1}SX:U),J,0,0
S:G$CPRL3$0$0({1}SX:U),J,0,0
S:G$CT3$0$0({1}SX:U),J,0,0
S:G$TR3$0$0({1}SX:U),J,0,0
S:G$EXEN3$0$0({1}SX:U),J,0,0
S:G$EXF3$0$0({1}SX:U),J,0,0
S:G$TF3$0$0({1}SX:U),J,0,0
S:G$CPRL4$0$0({1}SX:U),J,0,0
S:G$CT4$0$0({1}SX:U),J,0,0
S:G$TR4$0$0({1}SX:U),J,0,0
S:G$EXEN4$0$0({1}SX:U),J,0,0
S:G$EXF4$0$0({1}SX:U),J,0,0
S:G$TF4$0$0({1}SX:U),J,0,0
S:G$P4_0$0$0({1}SX:U),J,0,0
S:G$P4_1$0$0({1}SX:U),J,0,0
S:G$P4_2$0$0({1}SX:U),J,0,0
S:G$P4_3$0$0({1}SX:U),J,0,0
S:G$P4_4$0$0({1}SX:U),J,0,0
S:G$P4_5$0$0({1}SX:U),J,0,0
S:G$P4_6$0$0({1}SX:U),J,0,0
S:G$P4_7$0$0({1}SX:U),J,0,0
S:G$P$0$0({1}SX:U),J,0,0
S:G$F1$0$0({1}SX:U),J,0,0
S:G$OV$0$0({1}SX:U),J,0,0
S:G$RS0$0$0({1}SX:U),J,0,0
S:G$RS1$0$0({1}SX:U),J,0,0
S:G$F0$0$0({1}SX:U),J,0,0
S:G$AC$0$0({1}SX:U),J,0,0
S:G$CY$0$0({1}SX:U),J,0,0
S:G$CCF0$0$0({1}SX:U),J,0,0
S:G$CCF1$0$0({1}SX:U),J,0,0
S:G$CCF2$0$0({1}SX:U),J,0,0
S:G$CCF3$0$0({1}SX:U),J,0,0
S:G$CCF4$0$0({1}SX:U),J,0,0
S:G$CCF5$0$0({1}SX:U),J,0,0
S:G$CR$0$0({1}SX:U),J,0,0
S:G$CF$0$0({1}SX:U),J,0,0
S:G$P5_0$0$0({1}SX:U),J,0,0
S:G$P5_1$0$0({1}SX:U),J,0,0
S:G$P5_2$0$0({1}SX:U),J,0,0
S:G$P5_3$0$0({1}SX:U),J,0,0
S:G$P5_4$0$0({1}SX:U),J,0,0
S:G$P5_5$0$0({1}SX:U),J,0,0
S:G$P5_6$0$0({1}SX:U),J,0,0
S:G$P5_7$0$0({1}SX:U),J,0,0
S:G$AD0LJST$0$0({1}SX:U),J,0,0
S:G$AD0WINT$0$0({1}SX:U),J,0,0
S:G$AD0CM0$0$0({1}SX:U),J,0,0
S:G$AD0CM1$0$0({1}SX:U),J,0,0
S:G$AD0BUSY$0$0({1}SX:U),J,0,0
S:G$AD0INT$0$0({1}SX:U),J,0,0
S:G$AD0TM$0$0({1}SX:U),J,0,0
S:G$AD0EN$0$0({1}SX:U),J,0,0
S:G$AD2WINT$0$0({1}SX:U),J,0,0
S:G$AD2CM0$0$0({1}SX:U),J,0,0
S:G$AD2CM1$0$0({1}SX:U),J,0,0
S:G$AD2CM2$0$0({1}SX:U),J,0,0
S:G$AD2BUSY$0$0({1}SX:U),J,0,0
S:G$AD2INT$0$0({1}SX:U),J,0,0
S:G$AD2TM$0$0({1}SX:U),J,0,0
S:G$AD2EN$0$0({1}SX:U),J,0,0
S:G$P6_0$0$0({1}SX:U),J,0,0
S:G$P6_1$0$0({1}SX:U),J,0,0
S:G$P6_2$0$0({1}SX:U),J,0,0
S:G$P6_3$0$0({1}SX:U),J,0,0
S:G$P6_4$0$0({1}SX:U),J,0,0
S:G$P6_5$0$0({1}SX:U),J,0,0
S:G$P6_6$0$0({1}SX:U),J,0,0
S:G$P6_7$0$0({1}SX:U),J,0,0
S:G$SPIEN$0$0({1}SX:U),J,0,0
S:G$TXBMT$0$0({1}SX:U),J,0,0
S:G$NSSMD0$0$0({1}SX:U),J,0,0
S:G$NSSMD1$0$0({1}SX:U),J,0,0
S:G$RXOVRN$0$0({1}SX:U),J,0,0
S:G$MODF$0$0({1}SX:U),J,0,0
S:G$WCOL$0$0({1}SX:U),J,0,0
S:G$SPIF$0$0({1}SX:U),J,0,0
S:G$P7_0$0$0({1}SX:U),J,0,0
S:G$P7_1$0$0({1}SX:U),J,0,0
S:G$P7_2$0$0({1}SX:U),J,0,0
S:G$P7_3$0$0({1}SX:U),J,0,0
S:G$P7_4$0$0({1}SX:U),J,0,0
S:G$P7_5$0$0({1}SX:U),J,0,0
S:G$P7_6$0$0({1}SX:U),J,0,0
S:G$P7_7$0$0({1}SX:U),J,0,0
S:G$_print_format$0$0({2}DF,SI:S),C,0,0
S:G$printf_small$0$0({2}DF,SV:S),C,0,0
S:G$printf$0$0({2}DF,SI:S),C,0,0
S:G$vprintf$0$0({2}DF,SI:S),C,0,0
S:G$sprintf$0$0({2}DF,SI:S),C,0,0
S:G$vsprintf$0$0({2}DF,SI:S),C,0,0
S:G$puts$0$0({2}DF,SI:S),C,0,0
S:G$gets$0$0({2}DF,DG,SC:S),C,0,0
S:G$printf_fast$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast_f$0$0({2}DF,SV:S),C,0,0
S:G$printf_tiny$0$0({2}DF,SV:S),C,0,0
|
--
-- Copyright (C) 2017 secunet Security Networks AG
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with HW.GFX.GMA.DP_Info;
private package HW.GFX.GMA.DDI_Phy is
type T is (BC, A);
procedure Power_On (Phy : T);
procedure Power_Off (Phy : T);
subtype DDI_Phy_Port is GPU_Port range DIGI_A .. DIGI_C;
procedure Pre_PLL (Port_Cfg : Port_Config);
Max_V_Swing : constant DP_Info.DP_Voltage_Swing := DP_Info.VS_Level_3;
type Emph_Array is array (DP_Info.DP_Voltage_Swing) of DP_Info.DP_Pre_Emph;
Max_Pre_Emph : constant Emph_Array :=
(DP_Info.VS_Level_0 => DP_Info.Emph_Level_3,
DP_Info.VS_Level_1 => DP_Info.Emph_Level_2,
DP_Info.VS_Level_2 => DP_Info.Emph_Level_1,
others => DP_Info.Emph_Level_0);
procedure Set_DP_Signal_Levels
(Port : Digital_Port;
Train_Set : DP_Info.Train_Set);
subtype HDMI_Buf_Trans_Range is DDI_HDMI_Buf_Trans_Range range 0 .. 9;
procedure Set_HDMI_Signal_Levels
(Port : DDI_Phy_Port;
Level : HDMI_Buf_Trans_Range);
end HW.GFX.GMA.DDI_Phy;
|
with Some_Package;
procedure main with SPARK_Mode is
begin
Some_Package.bar;
end main;
|
generic
Lower_Bound, Upper_Bound : Integer; -- bounds in which random numbers are generated
-- { Lower_Bound <= Upper_Bound }
package Alea is
-- Compute a random number in the range Lower_Bound..Upper_Bound.
--
-- Notice that Ada advocates the definition of a range type in such a case
-- to ensure that the type reflects the real possible values.
procedure Get_Random_Number (Resultat : out Integer);
end Alea;
|
package body Littlefs is
------------
-- C_Type --
------------
function Kind (Info : Entry_Info) return File_Kind
is (File_Kind'Enum_Val (Info.c_type));
----------
-- Size --
----------
function Size (Info : Entry_Info) return LFS_Size
is (Info.size);
----------
-- Name --
----------
function Name (Info : Entry_Info) return String is
Count : Natural;
From : Positive := Info.name'First;
begin
while Info.name (From) /= ASCII.NUL loop
From := From + 1;
end loop;
Count := Natural (From) - Natural (Info.name'First);
return Info.name (Info.name'First .. Info.name'First + Count - 1);
end Name;
------------
-- Format --
------------
function Format
(LFS : aliased in out LFS_T;
Config : aliased LFS_Config)
return int
is
function Format (lfs : access LFS_T;
config : access constant LFS_Config)
return int
with Import => True, Convention => C, External_Name => "lfs_format";
begin
return Format (LFS'Access, Config'Access);
end Format;
-----------
-- Mount --
-----------
function Mount
(LFS : aliased in out LFS_T; Config : aliased LFS_Config) return int
is
function Mount (lfs : access LFS_T;
config : access constant LFS_Config)
return int
with Import => True, Convention => C, External_Name => "lfs_mount";
begin
return Mount (LFS'Access, Config'Access);
end Mount;
-------------
-- Unmount --
-------------
function Unmount (LFS : aliased in out LFS_T) return int is
function Unmount (lfs : access LFS_T) return int -- lfs.h:443
with Import => True, Convention => C, External_Name => "lfs_unmount";
begin
return Unmount (LFS'Access);
end Unmount;
------------
-- Remove --
------------
function Remove (LFS : aliased in out LFS_T; Path : String) return int is
function Remove (lfs : access LFS_T;
path : System.Address)
return int -- lfs.h:452
with Import => True, Convention => C, External_Name => "lfs_remove";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Remove (LFS'Access, C_Path'Address);
end Remove;
------------
-- Rename --
------------
function Rename
(LFS : aliased in out LFS_T; Oldpath : String; Newpath : String)
return int
is
function Rename (lfs : access LFS_T;
oldpath : System.Address;
newpath : System.Address)
return int
with Import => True, Convention => C, External_Name => "lfs_rename";
C_Oldpath : constant String (1 .. Oldpath'Length + 1) :=
Oldpath & ASCII.NUL;
C_Newpath : constant String (1 .. Newpath'Length + 1) :=
Newpath & ASCII.NUL;
begin
return Rename (LFS'Access, C_Oldpath'Address, C_Newpath'Address);
end Rename;
----------
-- Stat --
----------
function Stat
(LFS : aliased in out LFS_T; Path : String; Info : aliased out Entry_Info)
return int
is
function Stat (lfs : access LFS_T;
path : System.Address;
info : access Entry_Info)
return int -- lfs.h:469
with Import => True, Convention => C, External_Name => "lfs_stat";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Stat (LFS'Access, C_Path'Address, Info'Access);
end Stat;
-------------
-- Setattr --
-------------
function Setattr (LFS : aliased in out LFS_T;
Path : String;
Id : Interfaces.Unsigned_8;
Buffer : System.Address;
Size : LFS_Size)
return int
is
function Setattr (lfs : access LFS_T;
path : System.Address;
c_type : Interfaces.Unsigned_8;
buffer : System.Address;
size : LFS_Size)
return int -- lfs.h:494
with Import => True, Convention => C, External_Name => "lfs_setattr";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Setattr (LFS'Access, C_Path'Address, Id, Buffer, Size);
end Setattr;
----------------
-- Removeattr --
----------------
function Removeattr (LFS : aliased in out LFS_T;
Path : String;
Id : Interfaces.Unsigned_8)
return int
is
function Removeattr (lfs : access LFS_T;
path : System.Address;
c_type : Interfaces.Unsigned_8)
return int -- lfs.h:504
with Import => True, Convention => C,
External_Name => "lfs_removeattr";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Removeattr (LFS'Access, C_Path'Address, Id);
end Removeattr;
----------
-- Open --
----------
function Open (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Path : String;
Flags : LFS_Open_Flags)
return int
is
function Open (lfs : access LFS_T;
file : access LFS_File;
path : System.Address;
flags : int)
return int -- lfs.h:516
with Import => True, Convention => C, External_Name => "lfs_file_open";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Open (LFS'Access, File'Access, C_Path'Address, int (Flags));
end Open;
-------------
-- Opencfg --
-------------
function Opencfg (LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Path : String;
Flags : LFS_Open_Flags;
Config : aliased lfs_file_config)
return int
is
function Opencfg (lfs : access LFS_T;
file : access LFS_File;
path : System.Address;
flags : int;
config : access constant lfs_file_config)
return int
with Import => True,
Convention => C,
External_Name => "lfs_file_opencfg";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Opencfg (LFS'Access, File'Access, C_Path'Address, int (Flags),
Config'Access);
end Opencfg;
-----------
-- Close --
-----------
function Close (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return int
is
function Close (lfs : access LFS_T;
file : access LFS_File)
return int -- lfs.h:539
with Import => True, Convention => C,
External_Name => "lfs_file_close";
begin
return Close (LFS'Access, File'Access);
end Close;
----------
-- Sync --
----------
function Sync
(LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return int
is
function Sync (lfs : access LFS_T;
file : access LFS_File)
return int
with Import => True, Convention => C, External_Name => "lfs_file_sync";
begin
return Sync (LFS'Access, File'Access);
end Sync;
----------
-- Read --
----------
function Read
(LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Buffer : System.Address;
Size : LFS_Size)
return LFS_Signed_Size
is
function Read (lfs : access LFS_T;
file : access LFS_File;
buffer : System.Address;
size : LFS_Size)
return LFS_Signed_Size
with Import => True, Convention => C, External_Name => "lfs_file_read";
begin
return Read (LFS'Access, File'Access, Buffer, Size);
end Read;
-----------
-- Write --
-----------
function Write
(LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Buffer : System.Address;
Size : LFS_Size)
return LFS_Signed_Size
is
function Write (lfs : access LFS_T;
file : access LFS_File;
buffer : System.Address;
size : LFS_Size)
return LFS_Signed_Size -- lfs.h:561
with Import => True, Convention => C,
External_Name => "lfs_file_write";
begin
return Write (LFS'Access, File'Access, Buffer, Size);
end Write;
----------
-- Seek --
----------
function Seek
(LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Off : LFS_Signed_Offset;
Whence : int)
return LFS_Signed_Offset
is
function Seek (lfs : access LFS_T;
file : access LFS_File;
off : LFS_Signed_Offset;
whence : int)
return LFS_Signed_Offset -- lfs.h:569
with Import => True, Convention => C, External_Name => "lfs_file_seek";
begin
return Seek (LFS'Access, File'Access, Off, Whence);
end Seek;
--------------
-- Truncate --
--------------
function Truncate
(LFS : aliased in out LFS_T;
File : aliased in out LFS_File;
Size : LFS_Offset)
return int
is
function Truncate
(lfs : access LFS_T;
file : access LFS_File;
size : LFS_Offset) return int -- lfs.h:576
with Import => True,
Convention => C,
External_Name => "lfs_file_truncate";
begin
return Truncate (LFS'Access, File'Access, Size);
end Truncate;
----------
-- Tell --
----------
function Tell (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return LFS_Signed_Offset
is
function Tell (lfs : access LFS_T;
file : access LFS_File)
return LFS_Signed_Offset
with Import => True, Convention => C, External_Name => "lfs_file_tell";
begin
return Tell (LFS'Access, File'Access);
end Tell;
------------
-- Rewind --
------------
function Rewind
(LFS : aliased in out LFS_T; File : aliased in out LFS_File) return int
is
function Rewind (lfs : access LFS_T;
file : access LFS_File)
return int
with Import => True,
Convention => C,
External_Name => "lfs_file_rewind";
begin
return Rewind (LFS'Access, File'Access);
end Rewind;
----------
-- Size --
----------
function Size (LFS : aliased in out LFS_T;
File : aliased in out LFS_File)
return LFS_Signed_Offset
is
function Size (lfs : access LFS_T;
file : access LFS_File)
return LFS_Signed_Offset
with Import => True, Convention => C, External_Name => "lfs_file_tell";
begin
return Size (LFS'Access, File'Access);
end Size;
-----------
-- Mkdir --
-----------
function Mkdir (LFS : aliased in out LFS_T; Path : String) return int is
function Mkdir (lfs : access LFS_T;
path : System.Address)
return int
with Import => True, Convention => C, External_Name => "lfs_mkdir";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Mkdir (LFS'Access, C_Path'Address);
end Mkdir;
----------
-- Open --
----------
function Open (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir;
Path : String)
return int
is
function Open
(lfs : access LFS_T;
dir : access LFS_Dir;
path : System.Address) return int -- lfs.h:611
with Import => True, Convention => C, External_Name => "lfs_dir_open";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Open (LFS'Access, Dir'Access, C_Path'Address);
end Open;
-----------
-- Close --
-----------
function Close (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir)
return int
is
function Close (lfs : access LFS_T; dir : access LFS_Dir) return int
with Import => True, Convention => C, External_Name => "lfs_dir_close";
begin
return Close (LFS'Access, Dir'Access);
end Close;
----------
-- Read --
----------
function Read
(LFS : aliased in out LFS_T; Dir : aliased in out LFS_Dir;
Info : aliased out Entry_Info) return int
is
function Read
(lfs : access LFS_T;
dir : access LFS_Dir;
info : access Entry_Info) return int -- lfs.h:624
with Import => True, Convention => C, External_Name => "lfs_dir_read";
begin
return Read (LFS'Access, Dir'Access, Info'Access);
end Read;
----------
-- Seek --
----------
function Seek (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir;
Off : LFS_Offset)
return int
is
function Seek
(lfs : access LFS_T;
dir : access LFS_Dir;
off : LFS_Offset) return int -- lfs.h:632
with Import => True, Convention => C, External_Name => "lfs_dir_seek";
begin
return Seek (LFS'Access, Dir'Access, Off);
end Seek;
----------
-- Tell --
----------
function Tell (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir)
return LFS_Signed_Offset
is
function Tell (lfs : access LFS_T;
dir : access LFS_Dir)
return LFS_Signed_Offset
with Import => True, Convention => C, External_Name => "lfs_dir_tell";
begin
return Tell (LFS'Access, Dir'Access);
end Tell;
------------
-- Rewind --
------------
function Rewind (LFS : aliased in out LFS_T;
Dir : aliased in out LFS_Dir)
return int
is
function Rewind (lfs : access LFS_T;
dir : access LFS_Dir)
return int
with Import => True, Convention => C,
External_Name => "lfs_dir_rewind";
begin
return Rewind (LFS'Access, Dir'Access);
end Rewind;
----------
-- Size --
----------
function Size (LFS : aliased in out LFS_T) return LFS_Signed_Size is
function Size (lfs : access LFS_T)
return LFS_Signed_Size
with Import => True, Convention => C, External_Name => "lfs_fs_size";
begin
return Size (LFS'Access);
end Size;
--------------
-- Traverse --
--------------
function Traverse
(LFS : aliased in out LFS_T;
CB : access function
(arg1 : System.Address; arg2 : LFS_Block) return int;
Data : System.Address) return int
is
function Traverse
(lfs : access LFS_T;
cb : access function (arg1 : System.Address; arg2 : LFS_Block)
return int;
data : System.Address) return int
with Import => True,
Convention => C,
External_Name => "lfs_fs_traverse";
begin
return Traverse (LFS'Access, CB, Data);
end Traverse;
-- -------------
-- -- Migrate --
-- -------------
--
-- function Migrate (LFS : aliased in out LFS_T;
-- Config : aliased in out LFS_Config)
-- return int
-- is
-- function Migrate (lfs : access LFS_T;
-- config : access constant LFS_Config) return int
-- with Import => True,
-- Convention => C,
-- External_Name => "lfs_migrate";
--
-- begin
-- return Migrate (LFS'Access, Config'Access);
-- end Migrate;
--
-------------
-- Getattr --
-------------
function Getattr (LFS : aliased in out LFS_T;
Path : String;
Id : Interfaces.Unsigned_8;
Buffer : System.Address;
Size : LFS_Size)
return LFS_Signed_Size
is
function Getattr (lfs : access LFS_T;
path : System.Address;
c_type : Interfaces.Unsigned_8;
buffer : System.Address;
size : LFS_Size)
return LFS_Signed_Size -- lfs.h:483
with Import => True, Convention => C, External_Name => "lfs_getattr";
C_Path : constant String (1 .. Path'Length + 1) :=
Path & ASCII.NUL;
begin
return Getattr (LFS'Access, C_Path'Address, Id, Buffer, Size);
end Getattr;
end Littlefs;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_User_Data --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2014,2018 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.16 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
-- |
-- |=====================================================================
-- | man page form_field_userptr.3x
-- |=====================================================================
-- |
package body Terminal_Interface.Curses.Forms.Field_User_Data is
-- |
-- |
-- |
procedure Set_User_Data (Fld : Field;
Data : User_Access)
is
function Set_Field_Userptr (Fld : Field;
Usr : User_Access) return Eti_Error;
pragma Import (C, Set_Field_Userptr, "set_field_userptr");
begin
Eti_Exception (Set_Field_Userptr (Fld, Data));
end Set_User_Data;
-- |
-- |
-- |
function Get_User_Data (Fld : Field) return User_Access
is
function Field_Userptr (Fld : Field) return User_Access;
pragma Import (C, Field_Userptr, "field_userptr");
begin
return Field_Userptr (Fld);
end Get_User_Data;
procedure Get_User_Data (Fld : Field;
Data : out User_Access)
is
begin
Data := Get_User_Data (Fld);
end Get_User_Data;
end Terminal_Interface.Curses.Forms.Field_User_Data;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . A D D R E S S _ O P E R A T I O N S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2019, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides arithmetic and logical operations on type Address.
-- It is intended for use by other packages in the System hierarchy. For
-- applications requiring this capability, see System.Storage_Elements or
-- the operations introduced in System.Aux_DEC;
-- The reason we need this package is that arithmetic operations may not
-- be available in the case where type Address is non-private and the
-- operations have been made abstract in the spec of System (to avoid
-- inappropriate use by applications programs). In addition, the logical
-- operations may not be available if type Address is a signed integer.
pragma Compiler_Unit_Warning;
package System.Address_Operations is
pragma Pure;
-- The semantics of the arithmetic operations are those that apply to
-- a modular type with the same length as Address, i.e. they provide
-- twos complement wrap around arithmetic treating the address value
-- as an unsigned value, with no overflow checking.
-- Note that we do not use the infix names for these operations to
-- avoid problems with ambiguities coming from declarations in package
-- Standard (which may or may not be visible depending on the exact
-- form of the declaration of type System.Address).
-- For addition, subtraction, and multiplication, the effect of overflow
-- is 2's complement wrapping (as though the type Address were unsigned).
-- For division and modulus operations, the caller is responsible for
-- ensuring that the Right argument is non-zero, and the effect of the
-- call is not specified if a zero argument is passed.
function AddA (Left, Right : Address) return Address;
function SubA (Left, Right : Address) return Address;
function MulA (Left, Right : Address) return Address;
function DivA (Left, Right : Address) return Address;
function ModA (Left, Right : Address) return Address;
-- The semantics of the logical operations are those that apply to
-- a modular type with the same length as Address, i.e. they provide
-- bit-wise operations on all bits of the value (including the sign
-- bit if Address is a signed integer type).
function AndA (Left, Right : Address) return Address;
function OrA (Left, Right : Address) return Address;
pragma Inline_Always (AddA);
pragma Inline_Always (SubA);
pragma Inline_Always (MulA);
pragma Inline_Always (DivA);
pragma Inline_Always (ModA);
pragma Inline_Always (AndA);
pragma Inline_Always (OrA);
end System.Address_Operations;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with System; use System;
pragma Warnings (Off, "* is an internal GNAT unit");
with System.BB.Parameters;
pragma Warnings (On, "* is an internal GNAT unit");
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32.Device is
------------------
-- Enable_Clock --
------------------
Secure_Code : UInt32;
pragma Import (C, Secure_Code, "secure_code");
RCC : aliased RCC_Peripheral
with Import, Address => S_NS_Periph (RCC_Base);
procedure Enable_Clock (This : aliased in out Digital_To_Analog_Converter)
is
begin
RCC_Periph.APB1ENR1.DAC1EN := True;
end Enable_Clock;
procedure Reset (This : aliased in out Digital_To_Analog_Converter)
is
begin
RCC_Periph.APB1RSTR1.DAC1RST := True;
RCC_Periph.APB1RSTR1.DAC1RST := False;
end Reset;
procedure Enable_Clock (This : aliased in out GPIO_Port) is
begin
if This'Address = S_NS_Periph (GPIOA_Base) then
RCC.AHB2ENR.GPIOAEN := True;
elsif This'Address = S_NS_Periph (GPIOB_Base) then
RCC.AHB2ENR.GPIOBEN := True;
elsif This'Address = S_NS_Periph (GPIOC_Base) then
RCC.AHB2ENR.GPIOCEN := True;
elsif This'Address = S_NS_Periph (GPIOD_Base) then
RCC.AHB2ENR.GPIODEN := True;
elsif This'Address = S_NS_Periph (GPIOE_Base) then
RCC.AHB2ENR.GPIOEEN := True;
elsif This'Address = S_NS_Periph (GPIOF_Base) then
RCC.AHB2ENR.GPIOFEN := True;
elsif This'Address = S_NS_Periph (GPIOG_Base) then
RCC.AHB2ENR.GPIOGEN := True;
elsif This'Address = S_NS_Periph (GPIOH_Base) then
RCC.AHB2ENR.GPIOHEN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
procedure Disable_Clock (This : aliased in out GPIO_Port) is
begin
if This'Address = S_NS_Periph (GPIOA_Base) then
RCC.AHB2ENR.GPIOAEN := False;
elsif This'Address = S_NS_Periph (GPIOB_Base) then
RCC.AHB2ENR.GPIOBEN := False;
elsif This'Address = S_NS_Periph (GPIOC_Base) then
RCC.AHB2ENR.GPIOCEN := False;
elsif This'Address = S_NS_Periph (GPIOD_Base) then
RCC.AHB2ENR.GPIODEN := False;
elsif This'Address = S_NS_Periph (GPIOE_Base) then
RCC.AHB2ENR.GPIOEEN := False;
elsif This'Address = S_NS_Periph (GPIOF_Base) then
RCC.AHB2ENR.GPIOFEN := False;
elsif This'Address = S_NS_Periph (GPIOG_Base) then
RCC.AHB2ENR.GPIOGEN := False;
elsif This'Address = S_NS_Periph (GPIOH_Base) then
RCC.AHB2ENR.GPIOHEN := False;
else
raise Unknown_Device;
end if;
end Disable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (Point : GPIO_Point)
is
begin
Enable_Clock (Point.Periph.all);
end Enable_Clock;
procedure Disable_Clock (Point : GPIO_Point)
is
begin
Disable_Clock (Point.Periph.all);
end Disable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (Points : GPIO_Points)
is
begin
for Point of Points loop
Enable_Clock (Point.Periph.all);
end loop;
end Enable_Clock;
procedure Disable_Clock (Points : GPIO_Points)
is
begin
for Point of Points loop
Disable_Clock (Point.Periph.all);
end loop;
end Disable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : aliased in out GPIO_Port) is
begin
if This'Address = S_NS_Periph (GPIOA_Base) then
RCC.AHB2RSTR.GPIOARST := True;
RCC.AHB2RSTR.GPIOARST := False;
elsif This'Address = S_NS_Periph (GPIOB_Base) then
RCC.AHB2RSTR.GPIOBRST := True;
RCC.AHB2RSTR.GPIOBRST := False;
elsif This'Address = S_NS_Periph (GPIOC_Base) then
RCC.AHB2RSTR.GPIOCRST := True;
RCC.AHB2RSTR.GPIOCRST := False;
elsif This'Address = S_NS_Periph (GPIOD_Base) then
RCC.AHB2RSTR.GPIODRST := True;
RCC.AHB2RSTR.GPIODRST := False;
elsif This'Address = S_NS_Periph (GPIOE_Base) then
RCC.AHB2RSTR.GPIOERST := True;
RCC.AHB2RSTR.GPIOERST := False;
else
raise Unknown_Device;
end if;
end Reset;
-----------
-- Reset --
-----------
procedure Reset (Point : GPIO_Point) is
begin
Reset (Point.Periph.all);
end Reset;
-----------
-- Reset --
-----------
procedure Reset (Points : GPIO_Points)
is
Do_Reset : Boolean;
begin
for J in Points'Range loop
Do_Reset := True;
for K in Points'First .. J - 1 loop
if Points (K).Periph = Points (J).Periph then
Do_Reset := False;
exit;
end if;
end loop;
if Do_Reset then
Reset (Points (J).Periph.all);
end if;
end loop;
end Reset;
------------------------------
-- GPIO_Port_Representation --
------------------------------
function GPIO_Port_Representation (Port : GPIO_Port) return UInt4 is
begin
-- TODO: rather ugly to have this board-specific range here
if Port'Address = S_NS_Periph (GPIOA_Base) then
return 0;
elsif Port'Address = S_NS_Periph (GPIOB_Base) then
return 1;
elsif Port'Address = S_NS_Periph (GPIOC_Base) then
return 2;
elsif Port'Address = S_NS_Periph (GPIOD_Base) then
return 3;
elsif Port'Address = S_NS_Periph (GPIOE_Base) then
return 4;
else
raise Program_Error;
end if;
end GPIO_Port_Representation;
----------------
-- As_Port_Id --
----------------
function As_Port_Id (Port : I2C_Port) return I2C_Port_Id is
begin
if Port.Periph.all'Address = S_NS_Periph (I2C1_Base) then
return I2C_Id_1;
elsif Port.Periph.all'Address = S_NS_Periph (I2C2_Base) then
return I2C_Id_2;
elsif Port.Periph.all'Address = S_NS_Periph (I2C3_Base) then
return I2C_Id_3;
else
raise Unknown_Device;
end if;
end As_Port_Id;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : I2C_Port) is
begin
Enable_Clock (As_Port_Id (This));
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : I2C_Port_Id) is
begin
case This is
when I2C_Id_1 =>
RCC_Periph.APB1ENR1.I2C1EN := True;
when I2C_Id_2 =>
RCC_Periph.APB1ENR1.I2C2EN := True;
when I2C_Id_3 =>
RCC_Periph.APB1ENR1.I2C3EN := True;
end case;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : I2C_Port) is
begin
Reset (As_Port_Id (This));
end Reset;
-----------
-- Reset --
-----------
procedure Reset (This : I2C_Port_Id) is
begin
case This is
when I2C_Id_1 =>
RCC_Periph.APB1RSTR1.I2C1RST := True;
RCC_Periph.APB1RSTR1.I2C1RST := False;
when I2C_Id_2 =>
RCC_Periph.APB1RSTR1.I2C2RST := True;
RCC_Periph.APB1RSTR1.I2C2RST := False;
when I2C_Id_3 =>
RCC_Periph.APB1RSTR1.I2C3RST := True;
RCC_Periph.APB1RSTR1.I2C3RST := False;
end case;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : SPI_Port) is
begin
if This.Periph.all'Address = S_NS_Periph (SPI1_Base) then
RCC.APB2ENR.SPI1EN := True;
elsif This.Periph.all'Address = S_NS_Periph (SPI2_Base) then
RCC.APB1ENR1.SPI2EN := True;
elsif This.Periph.all'Address = S_NS_Periph (SPI3_Base) then
RCC.APB1ENR1.SPI3EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out SPI_Port) is
begin
if This.Periph.all'Address = S_NS_Periph (SPI1_Base) then
RCC.APB2RSTR.SPI1RST := True;
RCC.APB2RSTR.SPI1RST := False;
elsif This.Periph.all'Address = S_NS_Periph (SPI2_Base) then
RCC.APB1RSTR1.SPI2RST := True;
RCC.APB1RSTR1.SPI2RST := False;
elsif This.Periph.all'Address = S_NS_Periph (SPI3_Base) then
RCC.APB1RSTR1.SPI3RST := True;
RCC.APB1RSTR1.SPI3RST := False;
else
raise Unknown_Device;
end if;
end Reset;
function S_NS_Periph (Addr : System.Address) return System.Address
is
X : UInt32;
LAddr : System.Address;
for X'Address use LAddr'Address;
begin
LAddr := Addr;
if Secure_Code > 0 then
X := X + 16#1000_0000#;
end if;
return LAddr;
end S_NS_Periph;
end STM32.Device;
|
-- Copyright (C) 2008-2011 Maciej Sobczak
-- Distributed under the Boost Software License, Version 1.0.
-- (See accompanying file LICENSE_1_0.txt or copy at
-- http://www.boost.org/LICENSE_1_0.txt)
package SOCI.PostgreSQL is
--
-- Registers the PostgreSQL backend so that it is ready for use
-- by the dynamic backend loader.
--
procedure Register_Factory_PostgreSQL;
pragma Import (C, Register_Factory_PostgreSQL,
"register_factory_postgresql");
end SOCI.PostgreSQL;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Registers; use Registers;
with STM32F4.GPIO; use STM32F4.GPIO;
package body LEDs is
function As_Word is new Ada.Unchecked_Conversion
(Source => User_LED, Target => Word);
procedure On (This : User_LED) is
begin
GPIOD.BSRR := As_Word (This);
end On;
procedure Off (This : User_LED) is
begin
GPIOD.BSRR := Shift_Left (As_Word (This), 16);
end Off;
All_LEDs_On : constant Word := Green'Enum_Rep or Red'Enum_Rep or
Blue'Enum_Rep or Orange'Enum_Rep;
pragma Compile_Time_Error
(All_LEDs_On /= 16#F000#,
"Invalid representation for All_LEDs_On");
All_LEDs_Off : constant Word := Shift_Left (All_LEDs_On, 16);
procedure All_Off is
begin
GPIOD.BSRR := All_LEDs_Off;
end All_Off;
procedure All_On is
begin
GPIOD.BSRR := All_LEDs_On;
end All_On;
procedure Initialize is
RCC_AHB1ENR_GPIOD : constant Word := 16#08#;
begin
-- Enable clock for GPIO-D
RCC.AHB1ENR := RCC.AHB1ENR or RCC_AHB1ENR_GPIOD;
-- Configure PD12-15
GPIOD.MODER (12 .. 15) := (others => Mode_OUT);
GPIOD.OTYPER (12 .. 15) := (others => Type_PP);
GPIOD.OSPEEDR (12 .. 15) := (others => Speed_100MHz);
GPIOD.PUPDR (12 .. 15) := (others => No_Pull);
end Initialize;
begin
Initialize;
end LEDs;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S E C U R E _ H A S H E S . M D 5 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2002-2009, 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 provides supporting code for implementation of the MD5
-- Message-Digest Algorithm as described in RFC 1321. The complete text of
-- RFC 1321 can be found at:
-- http://www.ietf.org/rfc/rfc1321.txt
-- This is an internal unit and should not be used directly in applications.
-- Use GNAT.MD5 instead.
with GNAT.Byte_Swapping;
with Interfaces;
package GNAT.Secure_Hashes.MD5 is
package Hash_State is
new GNAT.Secure_Hashes.Hash_Function_State
(Word => Interfaces.Unsigned_32,
Swap => GNAT.Byte_Swapping.Swap4,
Hash_Bit_Order => System.Low_Order_First);
-- MD5 operates on 32-bit little endian words
Block_Words : constant := 16;
-- Messages are processed in chunks of 16 words
procedure Transform
(H : in out Hash_State.State;
M : in out Message_State);
-- Transformation function applied for each block
Initial_State : constant Hash_State.State;
-- Initialization vector
private
Initial_A : constant := 16#67452301#;
Initial_B : constant := 16#EFCDAB89#;
Initial_C : constant := 16#98BADCFE#;
Initial_D : constant := 16#10325476#;
Initial_State : constant Hash_State.State :=
(Initial_A, Initial_B, Initial_C, Initial_D);
-- Initialization vector from RFC 1321
end GNAT.Secure_Hashes.MD5;
|
-------------------------------------------------------------------------------
-- package Disorderly.Basic_Rand.Deviates, Floating point random deviates.
-- Copyright (C) 1995-2018 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 Disorderly.Basic_Rand.Deviates
--
-- Generates floating point streams of Random deviates (variates) from
-- the following distributions:
--
-- Uniform, Normal (Gaussian), Exponential, Lorentzian (Cauchy),
-- Poissonian, Binomial, Negative Binomial, Weibull, Rayleigh,
-- Student_t, Beta, Gamma, Chi_Squared, Log_Normal, Multivariate_Normal
--
-- The more complicated deviates are accompanied by routines that
-- calculate their respective probability densities. The test routine,
-- (basic_deviates_demo_1), verifies that the random variables are
-- drawn from these probability distributions, as advertized.
--
-- So basic_deviates_demo_1.adb is a useful demonstration of the
-- random variable generators in this package, as well as the exact
-- distributions they are drawn from.
--
-- The package is pure.
--
-- Most routines would grind to a halt if they had to recalculate
-- certain quantities each call. So these quantities are calculated
-- on the first call, and then placed into a record that's passed
-- as in/out parameter to keep the package pure.
--
-- Uses 53 bits of the 61-bit generator Disorderly.Basic_Rand.
--
-- For most of the routines, the time_per_call is not constant. Most
-- routines call the random number generator an unpredictable number
-- of times each time the routine is called.
--
-- Wikipedia gives extended descriptions of each distribution. The
-- probability density functions generated by the functions declared
-- below are taken directly from the Wikipedia articles on the same,
-- to ensure that the Wikipedia discussions are exactly relevant.
--
-- Uses the integer valued Disorderly.Basic_Rand in the parent package to
-- create a floating point generator (Uniform).
-- Is generic in the floating point type (as long as its 15 digits!).
--
-- Like the other routines in this collection, Deviates is designed
-- to exploit the newer 64-bit CPU's. All of the routines use
-- 15 digit floats, which means 53 bit mantissas in practice.
-- Poisson should be thought of as single precision though.
--
-- References:
--
-- Chandrasekaran and Sheppard,
-- Journal of Pascal, Ada, and Modula2, Vol 5, Num 4, (1986).
--
-- Kemp, C.D. (1986). 'A modal method for generating binomial
-- variables', Commun. Statist. - Theor. Meth. 15(3), 805-813.
--
-- see also Fortran 77 code from the book:
-- Dagpunar, J. 'Principles of random variate generation'
-- Clarendon Press, Oxford, 1988. ISBN 0-19-852202-9
--
-- Many thanks are due to Allan Miller - most routines are based on
-- his Fortran 90 versions of the Dagpunar code.
--
-- Notes on the Distributions:
--
-- The functions approximate in a statistical manner certain continuous
-- probability distributions or densities (except Poisson and the Binomials,
-- which are integer valued here, not continuous). More precisely, if
-- you ran the program a long time, added up the number of points output
-- in each interval (X,X+dX), and plotted the resulting histogram,
-- you would get a function f(X), where f(X) is given as follows.
-- The functions are given in Normalized form.
--
-- The easy ones:
--
-- Random_Real (X, State_Val) samples from a uniform distribution:
-- = 1 for 0.0 <= X < 1.0
-- = 0 otherwise.
--
-- Exponential (Mean) = Exp (-X / Mean) / Mean for X > 0; 0 otherwise.
--
-- Normal (Mean, Sigma) =
-- = Exp (-(X - Mean)**2 / (2*Sigma**2)) / (Sigma*Sqrt(2*Pi))
--
-- Sometimes Normal is called Gaussian if Mean /=0 and Std Dev /= 1.
-- Sometimes Normal is called Std Normal if Mean =0 and Std Dev = 1.
--
-- Poisson (Mean) = Mean**k * Exp (-Mean) / k!
--
-- Output of Poisson is integer valued; Output includes 0.
--
-- The Cauchy probability density has a Lorentzian shape: (a/pi) / (a^2 + X^2).
--
-- The more complicated distribution are described well in their
-- respective Wikipedia articles.
generic
type Real is digits <>;
-- 15 digits required. This is checked.
package Disorderly.Basic_Rand.Deviates is
pragma Pure (Deviates);
procedure Get_Random_Real
(Random_Real : out Real;
Stream : in out State);
--
-- Uniform on [0.0, 1.0).
-- (X starts out on 0..2**53-1; then squeezed onto [0,1) by
-- multiplying X by 2.0**(-53).)
type Normal_Initializer is private;
procedure Get_Normal
(Mean : in Real;
Sigma : in Real;
N_Init : in out Normal_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Normal_Initializer and pass it in.
-- The procedure Get_Normal does everything else for you.
--
-- The Gaussian distribution probability density:
--
-- f(X) = A * Exp (-(X-Mean)**2 / (2*Sigma**2))
--
-- Sigma = Standard_Deviation
-- A = 1.0 / (Sigma*Sqrt(2*Pi)) (normalization constant)
--
-- If Sigma=1, and Mean=0 then its usually called the
-- Standard Normal distribution.
function Normal_Probability
(Mean : in Real; -- Mean of random variable X
Sigma : in Real; -- Std Dev of random variable X
X : in Real)
return Real;
subtype Log_Normal_Initializer is Normal_Initializer;
procedure Get_Log_Normal -- outputs random variable X
(Mean_Z : in Real; -- Mean of random variable Z = Log (X)
Sigma_Z : in Real; -- Std Dev of random variable Z = Log (X)
LN_Init : in out Log_Normal_Initializer;
Stream : in out State;
Result : out Real); -- X
--
-- 1. Must declare variable of type Log_Normal_Initializer and pass it in.
-- The procedure Get_Log_Normal does everything else for you.
--
-- The Log_Normal distribution probability density for X:
--
-- f(X) = A * Exp (-(Log(X) - Mean_Z)**2 / (2*Sigma_Z**2)) / X
--
-- f(X) = 0 (for X <= 0)
--
-- Sigma_Z = Standard_Deviation of Z = Log (X)
-- A = 1.0 / (Sigma_Z * Sqrt (2*Pi))
--
-- If Z is a normally distributed Random Variable with (Mean_Z, Sigma_Z)
-- then X = Exp (Z) is Log_Normal distributed with the distribution given
-- above. In terms of Z's Average and Std Deviation, (Mean_Z, Sigma_Z):
-- Mean_X = Exp (Mean_Z + Sigma_Z**2 / 2)
-- Sigma_X**2 = Mean_X**2 * (Exp (Sigma_Z**2) - 1))
--
-- Suppose you have (Mean_X, Sigma_X) and you want (Mean_Z, Sigma_Z) of
-- Z = Log(X), (the latter is the pair you plug into Get_Log_Normal above).
-- The formula is
-- Sigma_Z**2 = Log (1 + Sigma_X**2 / Mean_X**2))
-- Mean_Z = Log (Mean_X) - 0.5 * Sigma_Z**2
--
function Log_Normal_Probability
(Mean_Z : in Real; -- Mean of random variable Z = Log (X)
Sigma_Z : in Real; -- Std Dev of random variable Z = Log (X)
X : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- The Log_Normal probability density:
--
-- f(X) = A * Exp (-(Log(X) - Mean_Z)**2 / (2*Sigma_Z**2)) / X
--
-- f(X) = 0 (for X <= 0)
--
-- Sigma_Z = Standard_Deviation of Z, (where Z = Log (X)).
-- A = 1.0 / (Sigma_Z * Sqrt (2*Pi))
procedure Get_Cauchy
(A : in Real;
Stream : in out State;
Result : out Real);
--
-- The Cauchy (Lorentzian) distribution probability density:
--
-- f(X) = A / [(A*A + X*X) * Pi] -- normalized and scaled
--
-- Generates random deviates X in range (-inf, inf).
procedure Get_Exponential
(Mean : in Real;
Stream : in out State;
Result : out Real);
--
-- 1. Must have Mean > 0.0.
-- Raises contraint_Error if Mean is <= 0.0.
--
-- The Exponential distribution probability density:
--
-- f(X) = Exp (-X / Mean) / Mean for X > 0; 0 otherwise.
--
-- Generates a random deviate X in [0,inf).
procedure Get_Weibull
(a : in Real;
Stream : in out State;
Result : out Real);
--
-- The Weibull distribution probability density function:
--
-- f(X) = a * X**(a-1) * Exp (-X**a) if X > 0; f(X) = 0 otherwise.
--
-- If a=1 its Get_Exponential with Mean=1. Use Get_Exponential; much faster.
-- If a=2 its Rayleigh distribution. Use Get_Rayleigh; its faster.
-- If a=0, raises contraint_Error.
-- If a is too near 0, (or far from 1 in general) get Nan's or nonsense.
procedure Get_Rayleigh
(Stream : in out State;
Result : out Real);
--
-- The Rayleigh distribution probability density:
--
-- f(X) = 2 * X * Exp (-X**2) if X > 0; f(X) = 0 otherwise.
--
type Binomial_Initializer is private;
procedure Get_Binomial
(n : in Positive;
p : in Real;
B_Init : in out Binomial_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Binomial_Initializer and pass it in.
-- The procedure Get_Binomial does everything else for you.
--
-- 2. Must have: 0 < p < 1. (p = Bernoulli success probability.)
--
-- The Binomial distribution probability density:
--
-- f(X) = (n!/([X]!(n-[X])!)) * p^[X] * (1-p)^(n-[X])
-- if 0 <= X <= n; f(X) = 0 otherwise.
--
-- Result is output as a float, but is always Integer valued.
function Binomial_Probability
(n : in Positive;
k : in Integer;
p : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- Uses Log_Gamma to get:
--
-- [n!/(k!(n-k)!)] * p^k * (1-p)^(n-k)
-- if 0 <= k <= n;
-- returns 0 otherwise.
--
-- k < 0 returns 0
-- k > n returns 0
--
-- p <= 0.0 raises Constraint_Error
-- p >= 1.0 raises Constraint_Error
type Neg_Binomial_Initializer is private;
procedure Get_Neg_Binomial
(r : in Real;
p : in Real;
NB_Init : in out Neg_Binomial_Initializer;
Stream : in out State;
Result : out Real);
--
-- Result is a random deviate from distribution f_r(k) where f_r(k) is
-- the probability of r successes and k failures in n = k+r Bernoulli trials.
-- Assumes that the final trial is a success, and p = success probability.
-- (r is not retricted to integer values; output Result is. Result is k-like.)
--
-- Slow for large r, (r >> 10).
-- Slow for small p, (p < 0.1).
--
-- Must have: r > 0.0
-- r = the number of successes when r integer.
-- The random deviate output (Result) is sampled
-- from a distribution f_r(k) where f_r(k) is the
-- probability that k failures and r successes
-- are observed in a series of uncorrelated Bernoulli trials
-- (with the final trial being a success).
-- Must have: 0 < p < 1
-- p = Bernoulli success probability
--
-- Result is output as a float, but is always Integer valued.
function Neg_Binomial_Probability
(r : in Real;
k : in Integer;
p : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- Uses Log_Gamma to get:
--
-- [Gamma(r + k)/[(Gamma(r)*k!] * p^r * (1-p)^k
--
-- Must have: r > 0.0
-- Must have: 0 < p < 1
-- p = Bernoulli success probability
--
-- Probability of r successes and k failures in n = k+r Bernoulli trials.
-- Assumes that the final trial is a success, and p = success probability.
--
-- If r = 1, the distribution is the probability of success on the (k+1)th
-- trial with k previous failures: geometric distribution, p*(1-p)^k.
-- As r -> inf, keeping the Mean = r*(1-p)/p constant, you get the
-- Poissonian distribution. So its a large p limit, opposite of Binomial.
subtype Poisson_Initializer is Binomial_Initializer;
p_Shift : constant := -20;
-- binomial is used to get Poisson, by setting p~2**(-20) and p*Mean = n.
-- p is the binomial (Bernoulli) success probability: p = 2.0**p_Shift.
-- p = -20 is stnd. If p=-20, then Max allowed Mean is < 2048, and you can
-- sample for 2 days at least without detecting difference between Poisson
-- and binomial. If you set p=-23, then you can sample for 2 wks without
-- problem, but then the maximum allowed Mean is < 256.
procedure Get_Poisson
(Mean : in Real;
P_Init : in out Poisson_Initializer;
Stream : in out State;
Result : out Real);
--
-- The Poisson distribution probability mass function:
--
-- f(k) = Mean^k * Exp (-Mean) / k!
--
-- Output of Poisson is integer valued, but floating point type.
-- Output includes 0.
--
-- Must have Mean > 0
-- Must have Mean < 2047.0 (if p_Shift = -20; ie p = 2**(-20))
-- Must have Mean < 256.0 (if p_Shift = -23; ie p = 2**(-23))
--
-- If mean > 8 then routine uses Binomial with p = 2**(-20) (with large
-- n so that Mean=n*p). The binomial distribution agrees with Poisson
-- with err ~ 5.0e-7 here. This discrepency is hard to
-- measure, but the routine should be thought of as single-precision.
-- This discrepency can be reduced by a factor of 8 by reducing p
-- by a factor of 8, (but max allowed Mean falls by a factor of 8).
function Poisson_Probability
(Mean : in Real;
k : in Integer)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- The Poisson distribution (probability mass function):
--
-- f(k) = Mean^k * Exp (-Mean) / k!
--
-- Negative k input is allowed (for convenience).
-- Output is 0 for k < 0.
type Student_t_Initializer is private;
procedure Get_Student_t
(m : in Positive;
Student_t_Init : in out Student_t_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Student_t_Initializer and pass it in.
-- The procedure Get_Student_t does everything else for you.
--
-- 2. Must have m >= 1. (m = degrees of freedom of distribution.)
--
-- The Student_t distribution probability density:
--
-- f(X) = (1 + X*X/m)^(-(m+1)/2) *
-- Gamma((m+1)/2) / [Sqrt (m*Pi) * Gamma(m/2)]
--
-- generates a random deviate from a t distribution
-- using Kinderman and Monahan's ratio method.
function Student_t_Probability
(m : in Positive;
x : in Real)
return Real;
--
-- A Probability density function.
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- Uses Log_Gamma to get:
--
-- f(X) = Gamma((m+1)/2) * (1 + X*X/m)^(-(m+1)/2) / [Sqrt (m*Pi) * Gamma(m/2)]
type Beta_Initializer is private;
procedure Get_Beta
(aa : in Real;
bb : in Real;
Beta_Init : in out Beta_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Beta_Initializer and pass it in.
-- The procedure Get_Beta does everything else for you.
--
-- 2. Must have aa > 0, bb > 0.
--
-- Get_Beta generates a random deviate in [0,1] from a beta distribution.
-- Uses Cheng's log logistic method.
--
-- The Beta distribution probability density:
--
-- f(X) = X**(aa-1) * (1-X)**(bb-1) *
-- Gamma (aa + bb) / (Gamma (bb)*Gamma (aa))
--
function Beta_Probability
(aa, bb : in Real;
x : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- f(x) = x**(aa-1) * (1-x)**(bb-1) *
-- Gamma (aa + bb) / (Gamma (bb)*Gamma (aa))
--
-- x must be in range (0, 1)
type Gamma_Initializer is private;
procedure Get_Gamma
(s : in Real;
Gamma_Init : in out Gamma_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Gamma_Initializer and pass it in.
-- The procedure Get_Gamma does everything else for you.
--
-- 2. Must have s > 0.
-- s = Shape parameter of Gamma distribution.
--
-- Generates a random deviate in [0,infinity) from a gamma distribution.
function Gamma_Probability
(s : in Real;
x : in Real)
return Real;
--
-- f(x) = x**(s-1) * Exp (-x) / Gamma (s)
-- = 0 if x < 0.
--
-- (where s = Gamma shape parameter).
-- Must have s > 0.
-- NOT a random deviate. (Used for testing mostly.)
subtype Chi_Initializer is Gamma_Initializer;
procedure Get_Chi_Squared
(Degrees_of_Freedom : in Real;
Chi_Init : in out Chi_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Chi_Initializer and pass it in.
-- The procedure Get_Chi_Squared does everything else for you.
--
-- 2. Must have Degrees_of_Freedom > 0.
--
-- Generates a random deviate in [0,infinity) from a Chi-Sq distribution.
function Chi_Squared_Probability
(Degrees_of_Freedom : in Real;
x : in Real)
return Real;
--
-- f(x) = (1 / 2) * (x / 2)**(s-1) * Exp (-x / 2) / Gamma (s)
-- = 0 if x < 0.
--
-- (where s = 0.5 * Degrees_of_Freedom).
-- NOT a random deviate. (Used for testing mostly.)
-- USING Get_Multivariate_Normal:
--
-- procedure Get_Multivariate_Normal is harder to use than the 1-dimensional
-- routines. You have to remember the following:
-- 1. You need a positive definite Covariance matrix.
-- 2. Declare it type Matrix (a..b, a..b) where a and b are type Positive.
-- 3. Declare Means : Vector(a..b), same range as Matrix, and initialize Means.
-- 4. Use procedure Choleski_Decompose to get the LU decomp. of Covariance.
subtype MV_Normal_Initializer is Normal_Initializer;
type Vector is array (Positive range <>) of Real;
type Matrix is array (Positive range <>, Positive range <>) of Real;
procedure Choleski_Decompose
(Covariance : in Matrix;
LU_of_Covariance : out Matrix); -- Choleski Decomp of Covariance matrix.
procedure Get_Multivariate_Normal
(Mean : in Vector;
LU_of_Covariance : in Matrix;
MV_Init : in out MV_Normal_Initializer;
Stream : in out State;
Result : out Vector);
--
-- To use Get_Multivariate_Normal:
-- put a Positive Definite Covariance matrix into
-- Choleski_Decompose to get Sqrt_Covariance.
--
-- Must have
-- Mean'First = Covariance'First(1) = Covariance'First(2)
-- Mean'Last = Covariance'Last(1) = Covariance'Last(2)
-- Mean'Length > 1
-- So use:
-- Mean : Vector (1..n);
-- Covariance : Matrix (1..n, 1..n);
--
-- Must initialize: Mean.
function Multivariate_Normal_Probability
(Mean : in Vector; -- Mean of random variables X
LU_of_Covariance : in Matrix; -- L of LU decomp of Covariance matrix
X : in Vector)
return Real;
procedure Test_Choleski;
private
Half : constant Real := +0.5;
Zero : constant Real := +0.0;
One : constant Real := +1.0;
Two : constant Real := +2.0;
Three : constant Real := +3.0;
Four : constant Real := +4.0;
Five : constant Real := +5.0;
Eight : constant Real := +8.0;
Sixteen : constant Real := +16.0;
Quarter : constant Real := +0.25;
Two_to_the_Ninth : constant Real := +512.0;
type Binomial_Initializer is
record
n : Positive := Positive'First;
r0 : Integer := 0;
p : Real := Half;
p_r : Real := Zero;
odds_ratio : Real := Zero;
Uninitialized : Boolean := True;
end record;
type Student_t_Initializer is
record
m : Positive := Positive'First;
a, f, g : Real := Zero;
Uninitialized : Boolean := True;
end record;
type Beta_Initializer is
record
Alpha, Beta : Real := Zero;
d, f, h, t, c : Real := Zero;
Swap : Boolean := False;
Uninitialized : Boolean := True;
end record;
type Gamma_Initializer is
record
s, p, c, uf, vr, d : Real := Zero;
Uninitialized : Boolean := True;
end record;
type Neg_Binomial_Initializer is
record
Reciprocal_Log_p1 : Real := Zero;
Reciprocal_Log_q1 : Real := Zero;
p : Real := Half;
Uninitialized : Boolean := True;
end record;
type Normal_Initializer is
record
Mean : Real := Zero;
Sigma : Real := Zero;
X2 : Real := Zero;
Uninitialized : Boolean := True;
end record;
Max_Allowed_Real : constant Real := Two**(Real'Machine_Emax-32);
Min_Allowed_Real : constant Real := Two**(Real'Machine_Emin+32);
end Disorderly.Basic_Rand.Deviates;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . M A C H I N E _ C O D E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides machine code support, both for intrinsic machine
-- operations, and also for machine code statements. See GNAT documentation
-- for full details.
package System.Machine_Code is
pragma No_Elaboration_Code_All;
pragma Pure;
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
type Asm_Input_Operand is private;
type Asm_Output_Operand is private;
-- These types are never used directly, they are declared only so that
-- the calls to Asm are type correct according to Ada semantic rules.
No_Input_Operands : constant Asm_Input_Operand;
No_Output_Operands : constant Asm_Output_Operand;
type Asm_Input_Operand_List is
array (Integer range <>) of Asm_Input_Operand;
type Asm_Output_Operand_List is
array (Integer range <>) of Asm_Output_Operand;
type Asm_Insn is private;
-- This type is not used directly. It is declared only so that the
-- aggregates used in code statements are type correct by Ada rules.
procedure Asm (
Template : String;
Outputs : Asm_Output_Operand_List;
Inputs : Asm_Input_Operand_List;
Clobber : String := "";
Volatile : Boolean := False);
procedure Asm (
Template : String;
Outputs : Asm_Output_Operand := No_Output_Operands;
Inputs : Asm_Input_Operand_List;
Clobber : String := "";
Volatile : Boolean := False);
procedure Asm (
Template : String;
Outputs : Asm_Output_Operand_List;
Inputs : Asm_Input_Operand := No_Input_Operands;
Clobber : String := "";
Volatile : Boolean := False);
procedure Asm (
Template : String;
Outputs : Asm_Output_Operand := No_Output_Operands;
Inputs : Asm_Input_Operand := No_Input_Operands;
Clobber : String := "";
Volatile : Boolean := False);
function Asm (
Template : String;
Outputs : Asm_Output_Operand_List;
Inputs : Asm_Input_Operand_List;
Clobber : String := "";
Volatile : Boolean := False) return Asm_Insn;
function Asm (
Template : String;
Outputs : Asm_Output_Operand := No_Output_Operands;
Inputs : Asm_Input_Operand_List;
Clobber : String := "";
Volatile : Boolean := False) return Asm_Insn;
function Asm (
Template : String;
Outputs : Asm_Output_Operand_List;
Inputs : Asm_Input_Operand := No_Input_Operands;
Clobber : String := "";
Volatile : Boolean := False) return Asm_Insn;
function Asm (
Template : String;
Outputs : Asm_Output_Operand := No_Output_Operands;
Inputs : Asm_Input_Operand := No_Input_Operands;
Clobber : String := "";
Volatile : Boolean := False) return Asm_Insn;
pragma Import (Intrinsic, Asm);
private
type Asm_Input_Operand is new Integer;
type Asm_Output_Operand is new Integer;
type Asm_Insn is new Integer;
-- All three of these types are dummy types, to meet the requirements of
-- type consistency. No values of these types are ever referenced.
No_Input_Operands : constant Asm_Input_Operand := 0;
No_Output_Operands : constant Asm_Output_Operand := 0;
end System.Machine_Code;
|
-- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_tex_gendv_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
pad1 : aliased swig.int8_t_Array (0 .. 3);
n : aliased Interfaces.Unsigned_32;
datum : aliased xcb.xcb_glx_float64_t;
pad2 : aliased swig.int8_t_Array (0 .. 7);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_get_tex_gendv_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_tex_gendv_reply_t.Item,
Element_Array => xcb.xcb_glx_get_tex_gendv_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_get_tex_gendv_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_tex_gendv_reply_t.Pointer,
Element_Array => xcb.xcb_glx_get_tex_gendv_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_tex_gendv_reply_t;
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="15">
<syndb class_id="0" tracking_level="0" version="0">
<userIPLatency>-1</userIPLatency>
<userIPName></userIPName>
<cdfg class_id="1" tracking_level="1" version="0" object_id="_0">
<name>Block_ZN2xf2cv3MatILi9ELi2160ELi3840ELi1ELi2EEC2Eii_exit1_proc</name>
<ret_bitwidth>0</ret_bitwidth>
<ports class_id="2" tracking_level="0" version="0">
<count>16</count>
<item_version>0</item_version>
<item class_id="3" tracking_level="1" version="0" object_id="_1">
<Value class_id="4" tracking_level="0" version="0">
<Obj class_id="5" tracking_level="0" version="0">
<type>1</type>
<id>1</id>
<name>rows</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo class_id="6" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs class_id="7" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_2">
<Value>
<Obj>
<type>1</type>
<id>2</id>
<name>cols</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>129</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_3">
<Value>
<Obj>
<type>1</type>
<id>3</id>
<name>imgInput_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>160</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item class_id="8" tracking_level="0" version="0">
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second class_id="9" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="10" tracking_level="0" version="0">
<first class_id="11" tracking_level="0" version="0">
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>160</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgInput.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_4">
<Value>
<Obj>
<type>1</type>
<id>4</id>
<name>imgInput_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>160</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>160</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgInput.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_5">
<Value>
<Obj>
<type>1</type>
<id>5</id>
<name>rgb2hsv_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>161</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>161</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>rgb2hsv.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>177</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_6">
<Value>
<Obj>
<type>1</type>
<id>6</id>
<name>rgb2hsv_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>161</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>161</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>rgb2hsv.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_7">
<Value>
<Obj>
<type>1</type>
<id>7</id>
<name>imgHelper1_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>163</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>163</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper1.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>3039962777</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_8">
<Value>
<Obj>
<type>1</type>
<id>8</id>
<name>imgHelper1_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>163</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>163</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper1.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_9">
<Value>
<Obj>
<type>1</type>
<id>9</id>
<name>imgHelper2_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>164</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>164</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper2.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>52</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_10">
<Value>
<Obj>
<type>1</type>
<id>10</id>
<name>imgHelper2_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>164</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>164</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper2.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>3040496640</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_11">
<Value>
<Obj>
<type>1</type>
<id>11</id>
<name>imgHelper3_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>165</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>165</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper3.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>3040493776</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_12">
<Value>
<Obj>
<type>1</type>
<id>12</id>
<name>imgHelper3_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>165</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>165</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper3.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_13">
<Value>
<Obj>
<type>1</type>
<id>13</id>
<name>imgHelper4_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>166</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>166</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper4.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>3040709856</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_14">
<Value>
<Obj>
<type>1</type>
<id>14</id>
<name>imgHelper4_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>166</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>166</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgHelper4.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>3040714904</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_15">
<Value>
<Obj>
<type>1</type>
<id>15</id>
<name>imgOutput_rows_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>167</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>167</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgOutput.rows</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_16">
<Value>
<Obj>
<type>1</type>
<id>16</id>
<name>imgOutput_cols_out</name>
<fileName>src/xf_colordetect_accel_stream.cpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>167</lineNumber>
<contextFuncName>colordetect_accel</contextFuncName>
<contextNormFuncName>colordetect_accel</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>src/xf_colordetect_accel_stream.cpp</first>
<second>colordetect_accel</second>
</first>
<second>167</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>imgOutput.cols</originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>3</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
</ports>
<nodes class_id="12" tracking_level="0" version="0">
<count>17</count>
<item_version>0</item_version>
<item class_id="13" tracking_level="1" version="0" object_id="_17">
<Value>
<Obj>
<type>0</type>
<id>17</id>
<name>cols_read</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<oprand_edges>
<count>2</count>
<item_version>0</item_version>
<item>50</item>
<item>51</item>
</oprand_edges>
<opcode>read</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>0.00</m_delay>
<m_topoIndex>1</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_18">
<Value>
<Obj>
<type>0</type>
<id>18</id>
<name>rows_read</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<oprand_edges>
<count>2</count>
<item_version>0</item_version>
<item>52</item>
<item>53</item>
</oprand_edges>
<opcode>read</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>0.00</m_delay>
<m_topoIndex>2</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_19">
<Value>
<Obj>
<type>0</type>
<id>33</id>
<name>imgInput_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>4034666248</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>55</item>
<item>56</item>
<item>57</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.40</m_delay>
<m_topoIndex>3</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_20">
<Value>
<Obj>
<type>0</type>
<id>34</id>
<name>imgInput_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>58</item>
<item>59</item>
<item>60</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.40</m_delay>
<m_topoIndex>4</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_21">
<Value>
<Obj>
<type>0</type>
<id>35</id>
<name>rgb2hsv_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>4228300630</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>61</item>
<item>62</item>
<item>63</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.40</m_delay>
<m_topoIndex>5</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_22">
<Value>
<Obj>
<type>0</type>
<id>36</id>
<name>rgb2hsv_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>4294967295</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>64</item>
<item>65</item>
<item>66</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.40</m_delay>
<m_topoIndex>6</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_23">
<Value>
<Obj>
<type>0</type>
<id>37</id>
<name>imgHelper1_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>67</item>
<item>68</item>
<item>69</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.36</m_delay>
<m_topoIndex>7</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_24">
<Value>
<Obj>
<type>0</type>
<id>38</id>
<name>imgHelper1_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>70</item>
<item>71</item>
<item>72</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.36</m_delay>
<m_topoIndex>8</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_25">
<Value>
<Obj>
<type>0</type>
<id>39</id>
<name>imgHelper2_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>913</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>73</item>
<item>74</item>
<item>75</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.32</m_delay>
<m_topoIndex>9</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_26">
<Value>
<Obj>
<type>0</type>
<id>40</id>
<name>imgHelper2_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>76</item>
<item>77</item>
<item>78</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.32</m_delay>
<m_topoIndex>10</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_27">
<Value>
<Obj>
<type>0</type>
<id>41</id>
<name>imgHelper3_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>79</item>
<item>80</item>
<item>81</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.28</m_delay>
<m_topoIndex>11</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_28">
<Value>
<Obj>
<type>0</type>
<id>42</id>
<name>imgHelper3_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>82</item>
<item>83</item>
<item>84</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.28</m_delay>
<m_topoIndex>12</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_29">
<Value>
<Obj>
<type>0</type>
<id>43</id>
<name>imgHelper4_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>913</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>85</item>
<item>86</item>
<item>87</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.24</m_delay>
<m_topoIndex>13</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_30">
<Value>
<Obj>
<type>0</type>
<id>44</id>
<name>imgHelper4_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>88</item>
<item>89</item>
<item>90</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.24</m_delay>
<m_topoIndex>14</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_31">
<Value>
<Obj>
<type>0</type>
<id>45</id>
<name>imgOutput_rows_out_write_ln614</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>614</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>614</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>0</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>91</item>
<item>92</item>
<item>93</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.26</m_delay>
<m_topoIndex>15</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_32">
<Value>
<Obj>
<type>0</type>
<id>46</id>
<name>imgOutput_cols_out_write_ln615</name>
<fileName>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</fileName>
<fileDirectory>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</fileDirectory>
<lineNumber>615</lineNumber>
<contextFuncName>init</contextFuncName>
<contextNormFuncName>init</contextNormFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>/home/willychiang/Desktop/PYNQ-HelloWorld/boards/ip/vitis_lib/vision/L1/include/common/xf_structs.hpp</first>
<second>init</second>
</first>
<second>615</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>49</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>3</count>
<item_version>0</item_version>
<item>94</item>
<item>95</item>
<item>96</item>
</oprand_edges>
<opcode>write</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>3.26</m_delay>
<m_topoIndex>16</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
<item class_id_reference="13" object_id="_33">
<Value>
<Obj>
<type>0</type>
<id>47</id>
<name>_ln0</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>132</coreId>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>0</count>
<item_version>0</item_version>
</oprand_edges>
<opcode>ret</opcode>
<m_Display>0</m_Display>
<m_isOnCriticalPath>0</m_isOnCriticalPath>
<m_isLCDNode>0</m_isLCDNode>
<m_isStartOfPath>0</m_isStartOfPath>
<m_delay>0.00</m_delay>
<m_topoIndex>17</m_topoIndex>
<m_clusterGroupNumber>-1</m_clusterGroupNumber>
</item>
</nodes>
<consts class_id="15" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</consts>
<blocks class_id="16" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="17" tracking_level="1" version="0" object_id="_34">
<Obj>
<type>3</type>
<id>48</id>
<name>Block__ZN2xf2cv3MatILi9ELi2160ELi3840ELi1ELi2EEC2Eii.exit1_proc</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<contextNormFuncName></contextNormFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<control></control>
<opType></opType>
<implIndex></implIndex>
<coreName></coreName>
<coreId>1768189039</coreId>
</Obj>
<node_objs>
<count>17</count>
<item_version>0</item_version>
<item>17</item>
<item>18</item>
<item>33</item>
<item>34</item>
<item>35</item>
<item>36</item>
<item>37</item>
<item>38</item>
<item>39</item>
<item>40</item>
<item>41</item>
<item>42</item>
<item>43</item>
<item>44</item>
<item>45</item>
<item>46</item>
<item>47</item>
</node_objs>
</item>
</blocks>
<edges class_id="18" tracking_level="0" version="0">
<count>30</count>
<item_version>0</item_version>
<item class_id="19" tracking_level="1" version="0" object_id="_35">
<id>51</id>
<edge_type>1</edge_type>
<source_obj>2</source_obj>
<sink_obj>17</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_36">
<id>53</id>
<edge_type>1</edge_type>
<source_obj>1</source_obj>
<sink_obj>18</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_37">
<id>56</id>
<edge_type>1</edge_type>
<source_obj>3</source_obj>
<sink_obj>33</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_38">
<id>57</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>33</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_39">
<id>59</id>
<edge_type>1</edge_type>
<source_obj>4</source_obj>
<sink_obj>34</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_40">
<id>60</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>34</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_41">
<id>62</id>
<edge_type>1</edge_type>
<source_obj>5</source_obj>
<sink_obj>35</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_42">
<id>63</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>35</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_43">
<id>65</id>
<edge_type>1</edge_type>
<source_obj>6</source_obj>
<sink_obj>36</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_44">
<id>66</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>36</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_45">
<id>68</id>
<edge_type>1</edge_type>
<source_obj>7</source_obj>
<sink_obj>37</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_46">
<id>69</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>37</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_47">
<id>71</id>
<edge_type>1</edge_type>
<source_obj>8</source_obj>
<sink_obj>38</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_48">
<id>72</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>38</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_49">
<id>74</id>
<edge_type>1</edge_type>
<source_obj>9</source_obj>
<sink_obj>39</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_50">
<id>75</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>39</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_51">
<id>77</id>
<edge_type>1</edge_type>
<source_obj>10</source_obj>
<sink_obj>40</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_52">
<id>78</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>40</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_53">
<id>80</id>
<edge_type>1</edge_type>
<source_obj>11</source_obj>
<sink_obj>41</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_54">
<id>81</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>41</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_55">
<id>83</id>
<edge_type>1</edge_type>
<source_obj>12</source_obj>
<sink_obj>42</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_56">
<id>84</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>42</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_57">
<id>86</id>
<edge_type>1</edge_type>
<source_obj>13</source_obj>
<sink_obj>43</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_58">
<id>87</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>43</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_59">
<id>89</id>
<edge_type>1</edge_type>
<source_obj>14</source_obj>
<sink_obj>44</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_60">
<id>90</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>44</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_61">
<id>92</id>
<edge_type>1</edge_type>
<source_obj>15</source_obj>
<sink_obj>45</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_62">
<id>93</id>
<edge_type>1</edge_type>
<source_obj>18</source_obj>
<sink_obj>45</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_63">
<id>95</id>
<edge_type>1</edge_type>
<source_obj>16</source_obj>
<sink_obj>46</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
<item class_id_reference="19" object_id="_64">
<id>96</id>
<edge_type>1</edge_type>
<source_obj>17</source_obj>
<sink_obj>46</sink_obj>
<is_back_edge>0</is_back_edge>
</item>
</edges>
</cdfg>
<cdfg_regions class_id="20" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="21" tracking_level="1" version="0" object_id="_65">
<mId>1</mId>
<mTag>Block__ZN2xf2cv3MatILi9ELi2160ELi3840ELi1ELi2EEC2Eii.exit1_proc</mTag>
<mNormTag>Block_ZN2xf2cv3MatILi9ELi2160ELi3840ELi1ELi2EEC2Eii_exit1_proc</mNormTag>
<mType>0</mType>
<sub_regions>
<count>0</count>
<item_version>0</item_version>
</sub_regions>
<basic_blocks>
<count>1</count>
<item_version>0</item_version>
<item>48</item>
</basic_blocks>
<mII>-1</mII>
<mDepth>-1</mDepth>
<mMinTripCount>-1</mMinTripCount>
<mMaxTripCount>-1</mMaxTripCount>
<mMinLatency>0</mMinLatency>
<mMaxLatency>0</mMaxLatency>
<mIsDfPipe>0</mIsDfPipe>
<mDfPipe class_id="-1"></mDfPipe>
</item>
</cdfg_regions>
<fsm class_id="-1"></fsm>
<res class_id="-1"></res>
<node_label_latency class_id="25" tracking_level="0" version="0">
<count>17</count>
<item_version>0</item_version>
<item class_id="26" tracking_level="0" version="0">
<first>17</first>
<second class_id="27" tracking_level="0" version="0">
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>18</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>33</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>34</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>35</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>36</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>37</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>38</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>39</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>40</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>41</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>42</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>43</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>44</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>45</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>46</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>47</first>
<second>
<first>0</first>
<second>0</second>
</second>
</item>
</node_label_latency>
<bblk_ent_exit class_id="28" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="29" tracking_level="0" version="0">
<first>48</first>
<second class_id="30" tracking_level="0" version="0">
<first>0</first>
<second>0</second>
</second>
</item>
</bblk_ent_exit>
<regions class_id="31" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</regions>
<dp_fu_nodes class_id="32" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes>
<dp_fu_nodes_expression class_id="33" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_expression>
<dp_fu_nodes_module>
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_module>
<dp_fu_nodes_io>
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_io>
<return_ports>
<count>0</count>
<item_version>0</item_version>
</return_ports>
<dp_mem_port_nodes class_id="34" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_mem_port_nodes>
<dp_reg_nodes>
<count>0</count>
<item_version>0</item_version>
</dp_reg_nodes>
<dp_regname_nodes>
<count>0</count>
<item_version>0</item_version>
</dp_regname_nodes>
<dp_reg_phi>
<count>0</count>
<item_version>0</item_version>
</dp_reg_phi>
<dp_regname_phi>
<count>0</count>
<item_version>0</item_version>
</dp_regname_phi>
<dp_port_io_nodes class_id="35" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_port_io_nodes>
<port2core>
<count>0</count>
<item_version>0</item_version>
</port2core>
<node2core>
<count>0</count>
<item_version>0</item_version>
</node2core>
</syndb>
</boost_serialization>
|
--------------------------------------------------------------------------------
-- --
-- B B . I D E A L --
-- Ball on Beam Simulator - Ideal interface --
-- --
-- Spec --
-- --
-- Ideal interface to the Ball on Beam system. --
-- --
-- Author: Jorge Real --
-- Universitat Politecnica de Valencia --
-- July, 2020 - Version 1 --
-- February, 2021 - Version 2 --
-- --
-- This is free software in the ample sense: you can use it freely, --
-- provided you preserve this comment at the header of source files and --
-- you clearly indicate the changes made to the original file, if any. --
-- --
--------------------------------------------------------------------------------
package BB.Ideal is
procedure Set_Beam_Angle (Inclination : Angle);
-- Set the beam inclination angle, in degrees.
function Ball_Position return Position;
-- Returns the simulated ball position, in mm.
end BB.Ideal;
|
with Ahven.Framework;
package math_Tests.linear_Algebra_2d
is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
end math_Tests.linear_Algebra_2d;
|
-- Copyright 2017-2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local url = require("url")
name = "Yahoo"
type = "scrape"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
for i=1,201,10 do
local ok = scrape(ctx, {['url']=buildurl(domain, i)})
if not ok then
break
end
end
end
function buildurl(domain, pagenum)
local query = "site:" .. domain .. " -domain:www." .. domain
local params = {
p=query,
b=pagenum,
pz="10",
bct="0",
xargs="0",
}
return "https://search.yahoo.com/search?" .. url.build_query_string(params)
end
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A W K --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2019, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is an AWK-like unit. It provides an easy interface for parsing one
-- or more files containing formatted data. The file can be viewed seen as
-- a database where each record is a line and a field is a data element in
-- this line. In this implementation an AWK record is a line. This means
-- that a record cannot span multiple lines. The operating procedure is to
-- read files line by line, with each line being presented to the user of
-- the package. The interface provides services to access specific fields
-- in the line. Thus it is possible to control actions taken on a line based
-- on values of some fields. This can be achieved directly or by registering
-- callbacks triggered on programmed conditions.
--
-- The state of an AWK run is recorded in an object of type session.
-- The following is the procedure for using a session to control an
-- AWK run:
--
-- 1) Specify which session is to be used. It is possible to use the
-- default session or to create a new one by declaring an object of
-- type Session_Type. For example:
--
-- Computers : Session_Type;
--
-- 2) Specify how to cut a line into fields. There are two modes: using
-- character fields separators or column width. This is done by using
-- Set_Fields_Separators or Set_Fields_Width. For example by:
--
-- AWK.Set_Field_Separators (";,", Computers);
--
-- or by using iterators' Separators parameter.
--
-- 3) Specify which files to parse. This is done with Add_File/Add_Files
-- services, or by using the iterators' Filename parameter. For
-- example:
--
-- AWK.Add_File ("myfile.db", Computers);
--
-- 4) Run the AWK session using one of the provided iterators.
--
-- Parse
-- This is the most automated iterator. You can gain control on
-- the session only by registering one or more callbacks (see
-- Register).
--
-- Get_Line/End_Of_Data
-- This is a manual iterator to be used with a loop. You have
-- complete control on the session. You can use callbacks but
-- this is not required.
--
-- For_Every_Line
-- This provides a mixture of manual/automated iterator action.
--
-- Examples of these three approaches appear below
--
-- There are many ways to use this package. The following discussion shows
-- three approaches to using this package, using the three iterator forms.
-- All examples will use the following file (computer.db):
--
-- Pluton;Windows-NT;Pentium III
-- Mars;Linux;Pentium Pro
-- Venus;Solaris;Sparc
-- Saturn;OS/2;i486
-- Jupiter;MacOS;PPC
--
-- 1) Using Parse iterator
--
-- Here the first step is to register some action associated to a pattern
-- and then to call the Parse iterator (this is the simplest way to use
-- this unit). The default session is used here. For example to output the
-- second field (the OS) of computer "Saturn".
--
-- procedure Action is
-- begin
-- Put_Line (AWK.Field (2));
-- end Action;
--
-- begin
-- AWK.Register (1, "Saturn", Action'Access);
-- AWK.Parse (";", "computer.db");
--
--
-- 2) Using the Get_Line/End_Of_Data iterator
--
-- Here you have full control. For example to do the same as
-- above but using a specific session, you could write:
--
-- Computer_File : Session_Type;
--
-- begin
-- AWK.Set_Current (Computer_File);
-- AWK.Open (Separators => ";",
-- Filename => "computer.db");
--
-- -- Display Saturn OS
--
-- while not AWK.End_Of_File loop
-- AWK.Get_Line;
--
-- if AWK.Field (1) = "Saturn" then
-- Put_Line (AWK.Field (2));
-- end if;
-- end loop;
--
-- AWK.Close (Computer_File);
--
--
-- 3) Using For_Every_Line iterator
--
-- In this case you use a provided iterator and you pass the procedure
-- that must be called for each record. You could code the previous
-- example could be coded as follows (using the iterator quick interface
-- but without using the current session):
--
-- Computer_File : Session_Type;
--
-- procedure Action (Quit : in out Boolean) is
-- begin
-- if AWK.Field (1, Computer_File) = "Saturn" then
-- Put_Line (AWK.Field (2, Computer_File));
-- end if;
-- end Action;
--
-- procedure Look_For_Saturn is
-- new AWK.For_Every_Line (Action);
--
-- begin
-- Look_For_Saturn (Separators => ";",
-- Filename => "computer.db",
-- Session => Computer_File);
--
-- Integer_Text_IO.Put
-- (Integer (AWK.NR (Session => Computer_File)));
-- Put_Line (" line(s) have been processed.");
--
-- You can also use a regular expression for the pattern. Let us output
-- the computer name for all computer for which the OS has a character
-- O in its name.
--
-- Regexp : String := ".*O.*";
--
-- Matcher : Regpat.Pattern_Matcher := Regpat.Compile (Regexp);
--
-- procedure Action is
-- begin
-- Text_IO.Put_Line (AWK.Field (2));
-- end Action;
--
-- begin
-- AWK.Register (2, Matcher, Action'Unrestricted_Access);
-- AWK.Parse (";", "computer.db");
--
with Ada.Finalization;
with GNAT.Regpat;
package GNAT.AWK is
Session_Error : exception;
-- Raised when a Session is reused but is not closed
File_Error : exception;
-- Raised when there is a file problem (see below)
End_Error : exception;
-- Raised when an attempt is made to read beyond the end of the last
-- file of a session.
Field_Error : exception;
-- Raised when accessing a field value which does not exist
Data_Error : exception;
-- Raised when it is impossible to convert a field value to a specific type
type Count is new Natural;
type Widths_Set is array (Positive range <>) of Positive;
-- Used to store a set of columns widths
Default_Separators : constant String := " " & ASCII.HT;
Use_Current : constant String := "";
-- Value used when no separator or filename is specified in iterators
type Session_Type is limited private;
-- This is the main exported type. A session is used to keep the state of
-- a full AWK run. The state comprises a list of files, the current file,
-- the number of line processed, the current line, the number of fields in
-- the current line... A default session is provided (see Set_Current,
-- Current_Session and Default_Session below).
----------------------------
-- Package initialization --
----------------------------
-- To be thread safe it is not possible to use the default provided
-- session. Each task must used a specific session and specify it
-- explicitly for every services.
procedure Set_Current (Session : Session_Type);
-- Set the session to be used by default. This file will be used when the
-- Session parameter in following services is not specified.
function Current_Session return not null access Session_Type;
-- Returns the session used by default by all services. This is the
-- latest session specified by Set_Current service or the session
-- provided by default with this implementation.
function Default_Session return not null access Session_Type;
-- Returns the default session provided by this package. Note that this is
-- the session return by Current_Session if Set_Current has not been used.
procedure Set_Field_Separators
(Separators : String := Default_Separators;
Session : Session_Type);
procedure Set_Field_Separators
(Separators : String := Default_Separators);
-- Set the field separators. Each character in the string is a field
-- separator. When a line is read it will be split by field using the
-- separators set here. Separators can be changed at any point and in this
-- case the current line is split according to the new separators. In the
-- special case that Separators is a space and a tabulation
-- (Default_Separators), fields are separated by runs of spaces and/or
-- tabs.
procedure Set_FS
(Separators : String := Default_Separators;
Session : Session_Type)
renames Set_Field_Separators;
procedure Set_FS
(Separators : String := Default_Separators)
renames Set_Field_Separators;
-- FS is the AWK abbreviation for above service
procedure Set_Field_Widths
(Field_Widths : Widths_Set;
Session : Session_Type);
procedure Set_Field_Widths
(Field_Widths : Widths_Set);
-- This is another way to split a line by giving the length (in number of
-- characters) of each field in a line. Field widths can be changed at any
-- point and in this case the current line is split according to the new
-- field lengths. A line split with this method must have a length equal or
-- greater to the total of the field widths. All characters remaining on
-- the line after the latest field are added to a new automatically
-- created field.
procedure Add_File
(Filename : String;
Session : Session_Type);
procedure Add_File
(Filename : String);
-- Add Filename to the list of file to be processed. There is no limit on
-- the number of files that can be added. Files are processed in the order
-- they have been added (i.e. the filename list is FIFO). If Filename does
-- not exist or if it is not readable, File_Error is raised.
procedure Add_Files
(Directory : String;
Filenames : String;
Number_Of_Files_Added : out Natural;
Session : Session_Type);
procedure Add_Files
(Directory : String;
Filenames : String;
Number_Of_Files_Added : out Natural);
-- Add all files matching the regular expression Filenames in the specified
-- directory to the list of file to be processed. There is no limit on
-- the number of files that can be added. Each file is processed in
-- the same order they have been added (i.e. the filename list is FIFO).
-- The number of files (possibly 0) added is returned in
-- Number_Of_Files_Added.
-------------------------------------
-- Information about current state --
-------------------------------------
function Number_Of_Fields
(Session : Session_Type) return Count;
function Number_Of_Fields
return Count;
pragma Inline (Number_Of_Fields);
-- Returns the number of fields in the current record. It returns 0 when
-- no file is being processed.
function NF
(Session : Session_Type) return Count
renames Number_Of_Fields;
function NF
return Count
renames Number_Of_Fields;
-- AWK abbreviation for above service
function Number_Of_File_Lines
(Session : Session_Type) return Count;
function Number_Of_File_Lines
return Count;
pragma Inline (Number_Of_File_Lines);
-- Returns the current line number in the processed file. It returns 0 when
-- no file is being processed.
function FNR (Session : Session_Type) return Count
renames Number_Of_File_Lines;
function FNR return Count
renames Number_Of_File_Lines;
-- AWK abbreviation for above service
function Number_Of_Lines
(Session : Session_Type) return Count;
function Number_Of_Lines
return Count;
pragma Inline (Number_Of_Lines);
-- Returns the number of line processed until now. This is equal to number
-- of line in each already processed file plus FNR. It returns 0 when
-- no file is being processed.
function NR (Session : Session_Type) return Count
renames Number_Of_Lines;
function NR return Count
renames Number_Of_Lines;
-- AWK abbreviation for above service
function Number_Of_Files
(Session : Session_Type) return Natural;
function Number_Of_Files
return Natural;
pragma Inline (Number_Of_Files);
-- Returns the number of files associated with Session. This is the total
-- number of files added with Add_File and Add_Files services.
function File (Session : Session_Type) return String;
function File return String;
-- Returns the name of the file being processed. It returns the empty
-- string when no file is being processed.
---------------------
-- Field accessors --
---------------------
function Field
(Rank : Count;
Session : Session_Type) return String;
function Field
(Rank : Count) return String;
-- Returns field number Rank value of the current record. If Rank = 0 it
-- returns the current record (i.e. the line as read in the file). It
-- raises Field_Error if Rank > NF or if Session is not open.
function Field
(Rank : Count;
Session : Session_Type) return Integer;
function Field
(Rank : Count) return Integer;
-- Returns field number Rank value of the current record as an integer. It
-- raises Field_Error if Rank > NF or if Session is not open. It
-- raises Data_Error if the field value cannot be converted to an integer.
function Field
(Rank : Count;
Session : Session_Type) return Float;
function Field
(Rank : Count) return Float;
-- Returns field number Rank value of the current record as a float. It
-- raises Field_Error if Rank > NF or if Session is not open. It
-- raises Data_Error if the field value cannot be converted to a float.
generic
type Discrete is (<>);
function Discrete_Field
(Rank : Count;
Session : Session_Type) return Discrete;
generic
type Discrete is (<>);
function Discrete_Field_Current_Session
(Rank : Count) return Discrete;
-- Returns field number Rank value of the current record as a type
-- Discrete. It raises Field_Error if Rank > NF. It raises Data_Error if
-- the field value cannot be converted to type Discrete.
--------------------
-- Pattern/Action --
--------------------
-- AWK defines rules like "PATTERN { ACTION }". Which means that ACTION
-- will be executed if PATTERN match. A pattern in this implementation can
-- be a simple string (match function is equality), a regular expression,
-- a function returning a boolean. An action is associated to a pattern
-- using the Register services.
--
-- Each procedure Register will add a rule to the set of rules for the
-- session. Rules are examined in the order they have been added.
type Pattern_Callback is access function return Boolean;
-- This is a pattern function pointer. When it returns True the associated
-- action will be called.
type Action_Callback is access procedure;
-- A simple action pointer
type Match_Action_Callback is
access procedure (Matches : GNAT.Regpat.Match_Array);
-- An advanced action pointer used with a regular expression pattern. It
-- returns an array of all the matches. See GNAT.Regpat for further
-- information.
procedure Register
(Field : Count;
Pattern : String;
Action : Action_Callback;
Session : Session_Type);
procedure Register
(Field : Count;
Pattern : String;
Action : Action_Callback);
-- Register an Action associated with a Pattern. The pattern here is a
-- simple string that must match exactly the field number specified.
procedure Register
(Field : Count;
Pattern : GNAT.Regpat.Pattern_Matcher;
Action : Action_Callback;
Session : Session_Type);
procedure Register
(Field : Count;
Pattern : GNAT.Regpat.Pattern_Matcher;
Action : Action_Callback);
-- Register an Action associated with a Pattern. The pattern here is a
-- simple regular expression which must match the field number specified.
procedure Register
(Field : Count;
Pattern : GNAT.Regpat.Pattern_Matcher;
Action : Match_Action_Callback;
Session : Session_Type);
procedure Register
(Field : Count;
Pattern : GNAT.Regpat.Pattern_Matcher;
Action : Match_Action_Callback);
-- Same as above but it pass the set of matches to the action
-- procedure. This is useful to analyze further why and where a regular
-- expression did match.
procedure Register
(Pattern : Pattern_Callback;
Action : Action_Callback;
Session : Session_Type);
procedure Register
(Pattern : Pattern_Callback;
Action : Action_Callback);
-- Register an Action associated with a Pattern. The pattern here is a
-- function that must return a boolean. Action callback will be called if
-- the pattern callback returns True and nothing will happen if it is
-- False. This version is more general, the two other register services
-- trigger an action based on the value of a single field only.
procedure Register
(Action : Action_Callback;
Session : Session_Type);
procedure Register
(Action : Action_Callback);
-- Register an Action that will be called for every line. This is
-- equivalent to a Pattern_Callback function always returning True.
--------------------
-- Parse iterator --
--------------------
procedure Parse
(Separators : String := Use_Current;
Filename : String := Use_Current;
Session : Session_Type);
procedure Parse
(Separators : String := Use_Current;
Filename : String := Use_Current);
-- Launch the iterator, it will read every line in all specified
-- session's files. Registered callbacks are then called if the associated
-- pattern match. It is possible to specify a filename and a set of
-- separators directly. This offer a quick way to parse a single
-- file. These parameters will override those specified by Set_FS and
-- Add_File. The Session will be opened and closed automatically.
-- File_Error is raised if there is no file associated with Session, or if
-- a file associated with Session is not longer readable. It raises
-- Session_Error is Session is already open.
-----------------------------------
-- Get_Line/End_Of_Data Iterator --
-----------------------------------
type Callback_Mode is (None, Only, Pass_Through);
-- These mode are used for Get_Line/End_Of_Data and For_Every_Line
-- iterators. The associated semantic is:
--
-- None
-- callbacks are not active. This is the default mode for
-- Get_Line/End_Of_Data and For_Every_Line iterators.
--
-- Only
-- callbacks are active, if at least one pattern match, the associated
-- action is called and this line will not be passed to the user. In
-- the Get_Line case the next line will be read (if there is some
-- line remaining), in the For_Every_Line case Action will
-- not be called for this line.
--
-- Pass_Through
-- callbacks are active, for patterns which match the associated
-- action is called. Then the line is passed to the user. It means
-- that Action procedure is called in the For_Every_Line case and
-- that Get_Line returns with the current line active.
--
procedure Open
(Separators : String := Use_Current;
Filename : String := Use_Current;
Session : Session_Type);
procedure Open
(Separators : String := Use_Current;
Filename : String := Use_Current);
-- Open the first file and initialize the unit. This must be called once
-- before using Get_Line. It is possible to specify a filename and a set of
-- separators directly. This offer a quick way to parse a single file.
-- These parameters will override those specified by Set_FS and Add_File.
-- File_Error is raised if there is no file associated with Session, or if
-- the first file associated with Session is no longer readable. It raises
-- Session_Error is Session is already open.
procedure Get_Line
(Callbacks : Callback_Mode := None;
Session : Session_Type);
procedure Get_Line
(Callbacks : Callback_Mode := None);
-- Read a line from the current input file. If the file index is at the
-- end of the current input file (i.e. End_Of_File is True) then the
-- following file is opened. If there is no more file to be processed,
-- exception End_Error will be raised. File_Error will be raised if Open
-- has not been called. Next call to Get_Line will return the following
-- line in the file. By default the registered callbacks are not called by
-- Get_Line, this can activated by setting Callbacks (see Callback_Mode
-- description above). File_Error may be raised if a file associated with
-- Session is not readable.
--
-- When Callbacks is not None, it is possible to exhaust all the lines
-- of all the files associated with Session. In this case, File_Error
-- is not raised.
--
-- This procedure can be used from a subprogram called by procedure Parse
-- or by an instantiation of For_Every_Line (see below).
function End_Of_Data
(Session : Session_Type) return Boolean;
function End_Of_Data
return Boolean;
pragma Inline (End_Of_Data);
-- Returns True if there is no more data to be processed in Session. It
-- means that the latest session's file is being processed and that
-- there is no more data to be read in this file (End_Of_File is True).
function End_Of_File
(Session : Session_Type) return Boolean;
function End_Of_File
return Boolean;
pragma Inline (End_Of_File);
-- Returns True when there is no more data to be processed on the current
-- session's file.
procedure Close (Session : Session_Type);
-- Release all associated data with Session. All memory allocated will
-- be freed, the current file will be closed if needed, the callbacks
-- will be unregistered. Close is convenient in reestablishing a session
-- for new use. Get_Line is no longer usable (will raise File_Error)
-- except after a successful call to Open, Parse or an instantiation
-- of For_Every_Line.
-----------------------------
-- For_Every_Line iterator --
-----------------------------
generic
with procedure Action (Quit : in out Boolean);
procedure For_Every_Line
(Separators : String := Use_Current;
Filename : String := Use_Current;
Callbacks : Callback_Mode := None;
Session : Session_Type);
generic
with procedure Action (Quit : in out Boolean);
procedure For_Every_Line_Current_Session
(Separators : String := Use_Current;
Filename : String := Use_Current;
Callbacks : Callback_Mode := None);
-- This is another iterator. Action will be called for each new
-- record. The iterator's termination can be controlled by setting Quit
-- to True. It is by default set to False. It is possible to specify a
-- filename and a set of separators directly. This offer a quick way to
-- parse a single file. These parameters will override those specified by
-- Set_FS and Add_File. By default the registered callbacks are not called
-- by For_Every_Line, this can activated by setting Callbacks (see
-- Callback_Mode description above). The Session will be opened and
-- closed automatically. File_Error is raised if there is no file
-- associated with Session. It raises Session_Error is Session is already
-- open.
private
type Session_Data;
type Session_Data_Access is access Session_Data;
type Session_Type is new Ada.Finalization.Limited_Controlled with record
Data : Session_Data_Access;
Self : not null access Session_Type := Session_Type'Unchecked_Access;
end record;
procedure Initialize (Session : in out Session_Type);
procedure Finalize (Session : in out Session_Type);
end GNAT.AWK;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . C O N T T . S D --
-- --
-- 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.Exceptions;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.GNAT_Int;
with A4G.A_Output; use A4G.A_Output;
with A4G.Contt.TT; use A4G.Contt.TT;
with A4G.Contt.UT; use A4G.Contt.UT;
with A4G.CU_Info2; use A4G.CU_Info2;
with A4G.Defaults; use A4G.Defaults;
with A4G.Vcheck; use A4G.Vcheck;
with Atree;
with Lib;
with Output; use Output;
with Sinfo; use Sinfo;
package body A4G.Contt.SD is
------------------------------------
-- Local Subprograms (new stuff) --
------------------------------------
-- Do we need some of these local subprograms as the interface
-- subprograms of this package?
-- Is this package the right location for these subprograms?
procedure Scan_Search_Path (C : Context_Id);
-- Scans the tree search path and stores the names of the tree file
-- candidates in the context tree table.
procedure Scan_Tree_List (C : Context_Id);
-- This procedure is supposed to be called for One_tree and N_Trees
-- Context processing modes, therefore the Parameters string associated
-- with C should contain at least one tree name. It scans the list of tree
-- file names which have been extracted from the Parameters string when
-- making the association for C. For each tree file name checks if the
-- file exists and stores existing files in the context tree table. In case
-- if this check fails, raises ASIS_Failed if C was defined as "-C1"
-- ("one tree") context, or generates Asis Warning for "-CN" Context.
-- This procedure does not reset a context.
procedure Read_and_Check_New
(C : Context_Id;
Tree : Tree_Id;
Success : out Boolean);
-- Tries to read in Tree and to check if this tree is compile-only.
-- if both of these attempts are successful, sets Success ON and
-- sets Current_Tree as Tree. If either of these actions fails, then
-- depending on the Context operation mode, either raises ASIS_Failed
-- and forms the Diagnosis string on behalf on Asis.Ada_Environments.Open,
-- or only sets Success OFF, in both cases Current_Context and Current_Tree
-- are set to nil values.
procedure Process_Unit_New (U : Unit_Number_Type);
-- Does the general unit processing in one-pass Context opening. If this
-- unit is "new", it creates the new entry in the unit table and checks,
-- if the unit in the tree is consistent with the unit source (if needed).
-- If U corresponds to a "known" unit, it makes the consistency check.
-- If this procedure raises ASIS_Failed, it forms the Diagnosis string
-- on behalf on Asis.Ada_Environments.Open
-- ????????
procedure Investigate_Unit_New
(C : Context_Id;
U : Unit_Id;
U_N : Unit_Number_Type);
-- Computes the basic unit attributes for U_N and stores them for the
-- ASIS unit U in the ASIS Context C.
procedure Store_Tree (Path : String);
-- Stores the full name of the tree file in the Context Tree table for
-- the current Context. It supposes, that when it is called,
-- Namet.Name_Table contains the name of the tree file to be stored,
-- but without any directory information, and Path contains the path to
-- the tree search directory (followed by directory separator) where this
-- file was found.
---------------------------
-- Investigate_Trees_New --
---------------------------
procedure Investigate_Trees_New (C : Context_Id) is
Success : Boolean := False;
-- flag indicating if the next tree file has been successfully read in
Current_Dir : constant Dir_Name_Str := Get_Current_Dir;
begin
-- here we have all the names of tree files stored in the tree table
-- for C
for T in First_Tree_Id .. Last_Tree (C) loop
Read_and_Check_New (C, T, Success);
if Success then
Get_Name_String (C, T);
Change_Dir (Dir_Name (A_Name_Buffer (1 .. A_Name_Len)));
Register_Units;
Scan_Units_New;
Change_Dir (Current_Dir);
end if;
end loop;
end Investigate_Trees_New;
--------------------------
-- Investigate_Unit_New --
--------------------------
procedure Investigate_Unit_New
(C : Context_Id;
U : Unit_Id;
U_N : Unit_Number_Type)
is
Top : constant Node_Id := Lib.Cunit (U_N);
-- pointer to the N_Compilation_Unit node for U in the currently
-- accessed tree
begin
Set_S_F_Name_and_Origin (C, U, Top);
Check_Source_Consistency (C, U);
Set_Kind_and_Class (C, U, Top);
Get_Ada_Name (Top);
Set_Ada_Name (U);
Set_Is_Main_Unit (C, U, Is_Main (Top, Kind (C, U)));
Set_Is_Body_Required (C, U, Sinfo.Body_Required (Top));
Set_Dependencies (C, U, Top);
end Investigate_Unit_New;
----------------------
-- Process_Unit_New --
----------------------
procedure Process_Unit_New (U : Unit_Number_Type) is
Cont : constant Context_Id := Get_Current_Cont;
Include_Unit : Boolean := False;
Current_Unit : Unit_Id;
begin
Namet.Get_Decoded_Name_String (Lib.Unit_Name (U));
Set_Norm_Ada_Name_String_With_Check (U, Include_Unit);
if not Include_Unit then
return;
end if;
Current_Unit := Name_Find (Cont);
-- all the units in the current tree are already registered, therefore
-- Current_Unit should not be Nil_Unit
if Already_Processed (Cont, Current_Unit) then
Check_Consistency (Cont, Current_Unit, U);
-- Append_Tree_To_Unit (Cont, Current_Unit);
else
Investigate_Unit_New (Cont, Current_Unit, U);
end if;
end Process_Unit_New;
------------------------
-- Read_and_Check_New --
------------------------
procedure Read_and_Check_New
(C : Context_Id;
Tree : Tree_Id;
Success : out Boolean)
is
Tree_File_D : File_Descriptor;
begin
-- Special processing for GNSA mode:
if Tree_Processing_Mode (C) = GNSA then
if Context_Processing_Mode (C) = One_Tree then
Set_Current_Cont (C);
Set_Current_Tree (Tree);
Success := True;
return;
else
-- Other possibilites are not implemented now, so
pragma Assert (False);
null;
end if;
end if;
Get_Name_String (C, Tree);
A_Name_Buffer (A_Name_Len + 1) := ASCII.NUL;
Tree_File_D := Open_Read (A_Name_Buffer'Address, Binary);
A4G.GNAT_Int.Tree_In_With_Version_Check (Tree_File_D, C, Success);
Set_Current_Cont (C);
Set_Current_Tree (Tree);
exception
when Program_Error |
ASIS_Failed =>
Set_Current_Cont (Nil_Context_Id);
Set_Current_Tree (Nil_Tree);
raise;
when Ex : others =>
-- If we are here, we are definitely having a serious problem:
-- we have a tree file which is version-compartible with ASIS,
-- and we can not read it because of some unknown reason.
Set_Current_Cont (Nil_Context_Id);
Set_Current_Tree (Nil_Tree);
-- debug stuff...
if Debug_Flag_O or else
Debug_Lib_Model or else
Debug_Mode
then
Write_Str ("The tree file ");
Write_Str (A_Name_Buffer (1 .. A_Name_Len));
Write_Str (" was not read in and checked successfully");
Write_Eol;
Write_Str (Ada.Exceptions.Exception_Name (Ex));
Write_Str (" was raised");
Write_Eol;
Write_Str ("Exception message: ");
Write_Str (Ada.Exceptions.Exception_Message (Ex));
Write_Eol;
end if;
Report_ASIS_Bug
(Query_Name => "A4G.Contt.SD.Read_and_Check_New" &
" (tree file " &
A_Name_Buffer (1 .. A_Name_Len) & ")",
Ex => Ex);
end Read_and_Check_New;
--------------------
-- Scan_Tree_List --
--------------------
procedure Scan_Tree_List (C : Context_Id) is
Cont_Mode : constant Context_Mode := Context_Processing_Mode (C);
Tree_List : Tree_File_List_Ptr renames
Contexts.Table (C).Context_Tree_Files;
GNSA_Tree_Name : constant String := "GNSA-created tree";
-- Can be used for -C1 COntext only.
-- Success : Boolean;
begin
-- Special processing for GNSA mode:
if Tree_Processing_Mode (C) = GNSA then
if Context_Processing_Mode (C) = One_Tree then
Name_Len := GNSA_Tree_Name'Length;
Name_Buffer (1 .. Name_Len) := GNSA_Tree_Name;
Store_Tree ("");
return;
else
-- Other possibilites are not implemented now, so
pragma Assert (False);
null;
end if;
end if;
for I in Tree_List'Range loop
exit when Tree_List (I) = null;
if not Is_Regular_File (Tree_List (I).all) then
-- -- A loop needed to deal with possible raise conditions
-- Success := False;
-- for J in 1 .. 100 loop
-- if Is_Regular_File (Tree_List (I).all) then
-- Success := True;
-- exit;
-- end if;
-- delay 0.05;
-- end loop;
-- if not Success then
if Cont_Mode = One_Tree then
Set_Error_Status
(Status => Asis.Errors.Use_Error,
Diagnosis => "Asis.Ada_Environments.Open:"
& ASIS_Line_Terminator
& "tree file "
& Tree_List (I).all
& " does not exist");
raise ASIS_Failed;
elsif Cont_Mode = N_Trees then
ASIS_Warning
(Message => "Asis.Ada_Environments.Open: "
& ASIS_Line_Terminator
& "tree file "
& Tree_List (I).all
& " does not exist",
Error => Use_Error);
end if;
-- end if;
else
Name_Len := Tree_List (I)'Length;
Name_Buffer (1 .. Name_Len) := Tree_List (I).all;
Store_Tree ("");
end if;
end loop;
end Scan_Tree_List;
----------------------
-- Scan_Search_Path --
----------------------
procedure Scan_Search_Path (C : Context_Id) is
Curr_Dir : GNAT.Directory_Operations.Dir_Type;
Search_Path : constant Directory_List_Ptr :=
Contexts.Table (C).Tree_Path;
procedure Scan_Dir (Path : String);
-- scans tree files in Curr_Dir. Puts in the Name Table all
-- the files having names of the form *.at?, which have not been
-- scanned before. Sets the global variable Last_Tree_File equal to
-- the Name_Id of the last scanned tree file. The names of the tree
-- files stores in the Name Table are also stored in the ASIS tree
-- table with the directory information passed as the actual for Path
-- parameter
procedure Read_Tree_File
(Dir : in out GNAT.Directory_Operations.Dir_Type;
Str : out String;
Last : out Natural);
-- This procedure is the modification of GNAT.Directory_Operations.Read
-- which reads only tree file entries from the directory. A Tree file
-- is any file having the extension '.[aA][dD][tT]' (We are
-- considering upper case letters because of "semi-case-sensitiveness"
-- of Windows 95/98/NT.)
procedure Read_Tree_File
(Dir : in out GNAT.Directory_Operations.Dir_Type;
Str : out String;
Last : out Natural)
is
function Is_Tree_File return Boolean;
-- Checks if the file name stored in Str is the name of some tree
-- file. This function assumes that Str'First is 1, and that
-- Last > 0
function Is_Tree_File return Boolean is
Result : Boolean := False;
begin
if Last >= 5 and then
Str (Last - 3) = '.' and then
(Str (Last) = 't' or else
Str (Last) = 'T') and then
(Str (Last - 1) = 'd' or else
Str (Last - 1) = 'D') and then
(Str (Last - 2) = 'a' or else
Str (Last - 2) = 'A')
then
Result := True;
end if;
return Result;
end Is_Tree_File;
begin
GNAT.Directory_Operations.Read (Dir, Str, Last);
while Last > 0 loop
exit when Is_Tree_File;
GNAT.Directory_Operations.Read (Dir, Str, Last);
end loop;
end Read_Tree_File;
procedure Scan_Dir (Path : String) is
T_File : Name_Id;
Is_First_Tree : Boolean := True;
begin
-- looking for the first tree file in this directory
Read_Tree_File
(Dir => Curr_Dir,
Str => Namet.Name_Buffer,
Last => Namet.Name_Len);
while Namet.Name_Len > 0 loop
T_File := Name_Find;
if Is_First_Tree then
Is_First_Tree := False;
First_Tree_File := T_File;
end if;
if T_File > Last_Tree_File then
Last_Tree_File := T_File;
Store_Tree (Path);
end if;
Read_Tree_File
(Dir => Curr_Dir,
Str => Namet.Name_Buffer,
Last => Namet.Name_Len);
end loop;
end Scan_Dir;
begin -- Scan_Search_Path
if Search_Path = null then
GNAT.Directory_Operations.Open (Curr_Dir, "." & Directory_Separator);
Scan_Dir ("");
GNAT.Directory_Operations.Close (Curr_Dir);
else
for I in 1 .. Search_Path'Last loop
GNAT.Directory_Operations.Open (Curr_Dir, Search_Path (I).all);
Scan_Dir (Search_Path (I).all);
GNAT.Directory_Operations.Close (Curr_Dir);
end loop;
end if;
if Use_Default_Trees (C) then
for J in First_Dir_Id .. ASIS_Tree_Search_Directories.Last loop
GNAT.Directory_Operations.Open
(Curr_Dir,
ASIS_Tree_Search_Directories.Table (J).all);
Scan_Dir (ASIS_Tree_Search_Directories.Table (J).all);
GNAT.Directory_Operations.Close (Curr_Dir);
end loop;
end if;
end Scan_Search_Path;
-------------------------
-- Scan_Tree_Files_New --
-------------------------
procedure Scan_Tree_Files_New (C : Context_Id) is
C_Mode : constant Context_Mode := Context_Processing_Mode (C);
GNSA_Tree_Name : constant String := "GNSA-created tree";
-- Can be used for -C1 Context only
begin
-- Special processing for GNSA mode:
if Tree_Processing_Mode (C) = GNSA then
if Context_Processing_Mode (C) = One_Tree then
Name_Len := GNSA_Tree_Name'Length;
Name_Buffer (1 .. Name_Len) := GNSA_Tree_Name;
Store_Tree ("");
return;
-- to avoid GNAT Name Table corruption
else
-- Other possibilites are not implemented now, so
pragma Assert (False);
null;
end if;
end if;
-- first, initialization which is (may be?) common for all context
-- modes:
First_Tree_File := First_Name_Id;
Last_Tree_File := First_Name_Id - 1;
Namet.Initialize;
-- now for different context modes we call individual scan procedures.
-- all of them first put names of tree files into the GNAT Name table
-- and then transfer them into Context tree table, but we cannot
-- factor this out because of the differences in processing a search
-- path (if any) and forming the full names of the tree files
case C_Mode is
when All_Trees =>
Scan_Search_Path (C);
when One_Tree | N_Trees =>
Scan_Tree_List (C);
-- all the tree file names have already been stored in the
-- context tree table when association parameters were processed
null;
when Partition =>
Not_Implemented_Yet ("Scan_Tree_Files_New (Partition)");
end case;
-- debug output:...
if Debug_Flag_O or else
Debug_Lib_Model or else
Debug_Mode
then
Write_Str ("Scanning tree files for Context ");
Write_Int (Int (C));
Write_Eol;
if Context_Processing_Mode (C) = All_Trees then
if Last_Tree_File < First_Tree_File then
Write_Str (" no tree file has been found");
Write_Eol;
else
Write_Str (" the content of the Name Table is:");
Write_Eol;
for I in First_Tree_File .. Last_Tree_File loop
Get_Name_String (I);
Write_Str (" ");
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Eol;
end loop;
end if;
else
Write_Str ("Trees already stored in the tree table:");
Write_Eol;
for Tr in First_Tree_Id .. Last_Tree (C) loop
Get_Name_String (C, Tr);
Write_Str (" " & A_Name_Buffer (1 .. A_Name_Len));
Write_Eol;
end loop;
end if;
end if;
end Scan_Tree_Files_New;
--------------------
-- Scan_Units_New --
--------------------
procedure Scan_Units_New is
Main_Unit_Id : Unit_Id;
Next_Unit_Id : Unit_Id;
Include_Unit : Boolean := False;
begin
for N_Unit in Main_Unit .. Lib.Last_Unit loop
if Atree.Present (Lib.Cunit (N_Unit)) then
Process_Unit_New (N_Unit);
end if;
end loop;
-- And here we collect compilation dependencies for the main unit in
-- the tree:
Namet.Get_Decoded_Name_String (Lib.Unit_Name (Main_Unit));
Set_Norm_Ada_Name_String_With_Check (Main_Unit, Include_Unit);
if not Include_Unit then
return;
end if;
Main_Unit_Id := Name_Find (Current_Context);
for N_Unit in Main_Unit .. Lib.Last_Unit loop
if Atree.Present (Lib.Cunit (N_Unit)) then
Namet.Get_Decoded_Name_String (Lib.Unit_Name (N_Unit));
Set_Norm_Ada_Name_String_With_Check (N_Unit, Include_Unit);
if Include_Unit then
Next_Unit_Id := Name_Find (Current_Context);
Add_To_Elmt_List
(Unit => Next_Unit_Id,
List =>
Unit_Table.Table (Main_Unit_Id).Compilation_Dependencies);
end if;
end if;
end loop;
Unit_Table.Table (Main_Unit_Id).Main_Tree := Current_Tree;
Set_Main_Unit_Id (Main_Unit_Id);
end Scan_Units_New;
----------------
-- Store_Tree --
----------------
procedure Store_Tree (Path : String) is
New_Tree : Tree_Id;
-- we do not need it, but Allocate_Tree_Entry is a function...
pragma Warnings (Off, New_Tree);
begin
if Path = "" then
Set_Name_String (Normalize_Pathname (Name_Buffer (1 .. Name_Len)));
else
Set_Name_String
(Normalize_Pathname
(Path & Directory_Separator & Name_Buffer (1 .. Name_Len)));
end if;
New_Tree := Allocate_Tree_Entry;
end Store_Tree;
end A4G.Contt.SD;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . I M G _ L L F --
-- --
-- S p e c --
-- --
-- Copyright (C) 2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains routines for the Image attribute of floating point
-- types based on Long_Long_Float, also used for Float_IO output.
with System.Img_LLU;
with System.Image_R;
with System.Powten_LLF;
with System.Unsigned_Types;
package System.Img_LLF is
pragma Pure;
-- Note that the following instantiation is really for a 32-bit target,
-- where 128-bit integer types are not available. For a 64-bit targaet,
-- it is possible to use Long_Long_Unsigned and Long_Long_Long_Unsigned
-- instead of Unsigned and Long_Long_Unsigned, in order to double the
-- number of significant digits. But we do not do it by default to avoid
-- dragging 128-bit integer types for the sake of backward compatibility.
package Impl is new Image_R
(Long_Long_Float,
System.Powten_LLF.Maxpow,
System.Powten_LLF.Powten'Address,
Unsigned_Types.Long_Long_Unsigned,
System.Img_LLU.Set_Image_Long_Long_Unsigned);
procedure Image_Long_Long_Float
(V : Long_Long_Float;
S : in out String;
P : out Natural;
Digs : Natural)
renames Impl.Image_Floating_Point;
procedure Set_Image_Long_Long_Float
(V : Long_Long_Float;
S : in out String;
P : in out Natural;
Fore : Natural;
Aft : Natural;
Exp : Natural)
renames Impl.Set_Image_Real;
end System.Img_LLF;
|
procedure launch_mouse_Motion
--
-- Todo
--
is
begin
null;
end launch_mouse_Motion;
|
-- C95085A.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 CONSTRAINT_ERROR IS RAISED FOR OUT OF RANGE SCALAR
-- ARGUMENTS. SUBTESTS ARE:
-- (A) STATIC IN ARGUMENT.
-- (B) DYNAMIC IN ARGUMENT.
-- (C) IN OUT, OUT OF RANGE ON CALL.
-- (D) OUT, OUT OF RANGE ON RETURN.
-- (E) IN OUT, OUT OF RANGE ON RETURN.
-- GLH 7/15/85
-- JRK 8/23/85
-- JWC 11/15/85 ADDED VARIABLE "CALLED" TO ENSURE THAT THE ENTRY
-- CALL WAS MADE FOR THOSE CASES THAT ARE APPLICABLE.
WITH REPORT; USE REPORT;
PROCEDURE C95085A IS
SUBTYPE DIGIT IS INTEGER RANGE 0..9;
D : DIGIT;
I : INTEGER;
M1 : CONSTANT INTEGER := IDENT_INT (-1);
COUNT : INTEGER := 0;
CALLED : BOOLEAN;
SUBTYPE SI IS INTEGER RANGE M1 .. 10;
TASK T1 IS
ENTRY E1 (PIN : IN DIGIT; WHO : STRING); -- (A), (B).
END T1;
TASK BODY T1 IS
BEGIN
LOOP
BEGIN
SELECT
ACCEPT E1 (PIN : IN DIGIT;
WHO : STRING) DO -- (A), (B).
FAILED ("EXCEPTION NOT RAISED BEFORE " &
"CALL - E1 " & WHO);
END E1;
OR
TERMINATE;
END SELECT;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN E1");
END;
END LOOP;
END T1;
TASK T2 IS
ENTRY E2 (PINOUT : IN OUT DIGIT; WHO : STRING); -- (C).
END T2;
TASK BODY T2 IS
BEGIN
LOOP
BEGIN
SELECT
ACCEPT E2 (PINOUT : IN OUT DIGIT;
WHO : STRING) DO -- (C).
FAILED ("EXCEPTION NOT RAISED BEFORE " &
"CALL - E2 " & WHO);
END E2;
OR
TERMINATE;
END SELECT;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN E2");
END;
END LOOP;
END T2;
TASK T3 IS
ENTRY E3 (POUT : OUT SI; WHO : STRING); -- (D).
END T3;
TASK BODY T3 IS
BEGIN
LOOP
BEGIN
SELECT
ACCEPT E3 (POUT : OUT SI;
WHO : STRING) DO -- (D).
CALLED := TRUE;
IF WHO = "10" THEN
POUT := IDENT_INT (10); -- 10 IS NOT
-- A DIGIT.
ELSE
POUT := -1;
END IF;
END E3;
OR
TERMINATE;
END SELECT;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN E3");
END;
END LOOP;
END T3;
TASK T4 IS
ENTRY E4 (PINOUT : IN OUT INTEGER; WHO : STRING); -- (E).
END T4;
TASK BODY T4 IS
BEGIN
LOOP
BEGIN
SELECT
ACCEPT E4 (PINOUT : IN OUT INTEGER;
WHO : STRING) DO -- (E).
CALLED := TRUE;
IF WHO = "10" THEN
PINOUT := 10; -- 10 IS NOT A DIGIT.
ELSE
PINOUT := IDENT_INT (-1);
END IF;
END E4;
OR
TERMINATE;
END SELECT;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN E4");
END;
END LOOP;
END T4;
BEGIN
TEST ("C95085A", "CHECK THAT CONSTRAINT_ERROR IS RAISED " &
"FOR OUT OF RANGE SCALAR ARGUMENTS");
BEGIN -- (A)
T1.E1 (10, "10");
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR E1 (10)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E1 (10)");
END; -- (A)
BEGIN -- (B)
T1.E1 (IDENT_INT (-1), "-1");
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR E1 (" &
"IDENT_INT (-1))");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E1 (" &
"IDENT_INT (-1))");
END; -- (B)
BEGIN -- (C)
I := IDENT_INT (10);
T2.E2 (I, "10");
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR E2 (10)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E2 (10)");
END; -- (C)
BEGIN -- (C1)
I := IDENT_INT (-1);
T2.E2 (I, "-1");
FAILED ("CONSTRAINT_ERROR NOT RAISED FOR E2 (-1)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E2 (-1)");
END; -- (C1)
BEGIN -- (D)
CALLED := FALSE;
D := IDENT_INT (1);
T3.E3 (D, "10");
FAILED ("CONSTRAINT_ERROR NOT RAISED ON RETURN FROM " &
"E3 (10)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
IF NOT CALLED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL " &
"E3 (10)");
END IF;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E3 (10)");
END; -- (D)
BEGIN -- (D1)
CALLED := FALSE;
D := IDENT_INT (1);
T3.E3 (D, "-1");
FAILED ("CONSTRAINT_ERROR NOT RAISED ON RETURN FROM " &
"E3 (-1)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
IF NOT CALLED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL " &
"E3 (-1)");
END IF;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E3 (-1)");
END; -- (D1)
BEGIN -- (E)
CALLED := FALSE;
D := 9;
T4.E4 (D, "10");
FAILED ("CONSTRAINT_ERROR NOT RAISED ON RETURN FROM " &
"E4 (10)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
IF NOT CALLED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL " &
"E4 (10)");
END IF;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E4 (10)");
END; -- (E)
BEGIN -- (E1)
CALLED := FALSE;
D := 0;
T4.E4 (D, "-1");
FAILED ("CONSTRAINT_ERROR NOT RAISED ON RETURN FROM " &
"E4 (-1)");
EXCEPTION
WHEN CONSTRAINT_ERROR =>
COUNT := COUNT + 1;
IF NOT CALLED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL " &
"E4 (-1)");
END IF;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED FOR E4 (-1)");
END; -- (E1)
IF COUNT /= 8 THEN
FAILED ("INCORRECT NUMBER OF CONSTRAINT_ERRORS RAISED");
END IF;
RESULT;
END C95085A;
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
package body Vectors_3D is
function "*" (V_Left, V_Right : Vector_3D) return Vector_3D is
(x => (V_Left (y) * V_Right (z) - V_Left (z) * V_Right (y)),
y => (V_Left (z) * V_Right (x) - V_Left (x) * V_Right (z)),
z => (V_Left (x) * V_Right (y) - V_Left (y) * V_Right (x)));
end Vectors_3D;
|
------------------------------------------------------------------------------
-- --
-- Giza --
-- --
-- Copyright (C) 2016 Fabien Chouteau (chouteau@adacore.com) --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
limited with Giza.Context;
package Giza.Font is
type Instance is interface;
subtype Class is Instance'Class;
type Ref is access all Class;
type Ref_Const is access constant Class;
procedure Glyph_Box (This : Instance;
C : Character;
Width, Height, X_Advance : out Natural;
X_Offset, Y_Offset : out Integer) is abstract;
procedure Print_Glyph (This : Instance;
Ctx : in out Giza.Context.Instance'Class;
C : Character) is abstract;
function Y_Advance (This : Instance) return Integer is abstract;
end Giza.Font;
|
-- Copyright 2014-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with System;
package Pck is
type Element is abstract tagged null record;
type GADataType is interface;
type Data_Type is new Element and GADataType with record
I : Integer := 42;
end record;
procedure Do_Nothing (A : System.Address);
end Pck;
|
------------------------------------------------------------------------------
-- --
-- A SIGMANIFICIENT PROGRAM --
-- --
-- PRIME CALCULATOR --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO, Ada.Integer_Text_IO ;
use Ada.Text_IO, Ada.Integer_Text_IO ;
procedure Main is
count_prime : Integer ;
counter : Integer ;
wanted : Integer ;
iteration : Integer ;
testing : Integer ;
is_prime : Boolean ;
answer : Character ;
begin
loop
Put("Calculateur de nombre premiers") ;
New_line(2) ;
Put("Entrez 'p' pour calculer des premiers") ;
New_Line(1);
Put("Entrez 'q' pour quitter") ;
New_Line(2) ;
Put(">> ") ;
Get(answer) ;
Skip_line ;
if answer = 'p' then
Put("Entrez le nombre de premiers voulu : ");
Get(wanted) ;
Skip_line ;
iteration := 0 ;
count_prime := 0 ;
counter := 1 ;
if wanted > 0 then
Put("2");
New_Line(1);
if wanted > 1 then
Put("3");
New_Line(1);
end if ;
if wanted > 2 then
count_prime := 2;
loop
if counter = 1 then
counter := 0 ;
iteration := iteration + 1 ;
testing := ( 6 * iteration ) - 1 ;
else
counter := 1 ;
testing := ( 6 * iteration ) + 1 ;
end if ;
is_prime := True ;
for i in 2..(testing-1) loop
if (testing rem i = 0) then
is_prime := False ;
end if ;
end loop;
if is_prime = True then
Put(testing);
New_Line(1);
count_prime := count_prime + 1 ;
end if ;
exit when count_prime = wanted;
end loop ;
end if;
Put("Ended") ;
else
Put("Vous devez mettre un nombre positif ._.");
end if ;
end if ;
New_Line(3);
exit when answer = 'q' ;
end loop ;
end Main ;
-- Long life to prime ! --
|
-- Abstract:
--
-- see spec
--
-- Copyright (C) 1998, 2003, 2009, 2015, 2017 - 2019 Free Software Foundation, Inc.
--
-- SAL 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. SAL is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- See the GNU General Public License for more details. You should
-- have received a copy of the GNU General Public License distributed
-- with SAL; see file COPYING. If not, write to the Free Software
-- Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-- USA.
--
-- As a special exception, if other files instantiate generics from
-- SAL, or you link SAL object files with other files to produce an
-- executable, that 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.
pragma License (Modified_GPL);
package body SAL.Gen_Bounded_Definite_Stacks
with Spark_Mode
is
pragma Suppress (All_Checks);
procedure Clear (Stack : in out Sgbds.Stack)
is begin
Stack.Top := 0;
end Clear;
function Depth (Stack : in Sgbds.Stack) return Size_Type
is (Stack.Top);
function Is_Empty (Stack : in Sgbds.Stack) return Boolean
is begin
return Stack.Top = 0;
end Is_Empty;
function Is_Full (Stack : in Sgbds.Stack) return Boolean
is begin
return Stack.Top = Stack.Size;
end Is_Full;
function Peek
(Stack : in Sgbds.Stack;
Index : in Peek_Type := 1)
return Element_Type
is (Stack.Data (Stack.Top - Index + 1));
procedure Pop (Stack : in out Sgbds.Stack; Count : in Base_Peek_Type := 1)
is begin
Stack.Top := Stack.Top - Count;
end Pop;
procedure Pop (Stack : in out Sgbds.Stack; Item : out Element_Type)
is begin
Item := Stack.Peek (1);
Stack.Top := Stack.Top - 1;
end Pop;
function Pop (Stack : in out Sgbds.Stack) return Element_Type with
Spark_Mode => Off
is begin
return Result : Element_Type do
Pop (Stack, Result);
end return;
end Pop;
procedure Push (Stack : in out Sgbds.Stack; Item : in Element_Type)
is begin
Stack.Top := Stack.Top + 1;
Stack.Data (Stack.Top) := Item;
end Push;
end SAL.Gen_Bounded_Definite_Stacks;
|
with Matrices;
pragma Elaborate_All (Matrices);
package Matrices_3D is new Matrices (3);
|
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.RNG; use STM32_SVD.RNG;
package body STM32.RNG is
----------------------
-- Enable_RNG_Clock --
----------------------
procedure Enable_RNG_Clock is
begin
RCC_Periph.AHB2ENR.RNGEN := True;
end Enable_RNG_Clock;
----------------
-- Enable_RNG --
----------------
procedure Enable_RNG is
begin
RNG_Periph.CR.RNGEN := True;
end Enable_RNG;
-----------------
-- Disable_RNG --
-----------------
procedure Disable_RNG is
begin
RNG_Periph.CR.RNGEN := False;
end Disable_RNG;
---------------
-- Reset_RNG --
---------------
procedure Reset_RNG
is
begin
RCC_Periph.AHB2RSTR.RNGRST := True;
RCC_Periph.AHB2RSTR.RNGRST := False;
end Reset_RNG;
-----------------
-- RNG_Enabled --
-----------------
function RNG_Enabled return Boolean is
(RNG_Periph.CR.RNGEN);
--------------------------
-- Enable_RNG_Interrupt --
--------------------------
procedure Enable_RNG_Interrupt is
begin
RNG_Periph.CR.IE := True;
end Enable_RNG_Interrupt;
---------------------------
-- Disable_RNG_Interrupt --
---------------------------
procedure Disable_RNG_Interrupt is
begin
RNG_Periph.CR.IE := False;
end Disable_RNG_Interrupt;
---------------------------
-- RNG_Interrupt_Enabled --
---------------------------
function RNG_Interrupt_Enabled return Boolean is
(RNG_Periph.CR.IE);
--------------
-- RNG_Data --
--------------
function RNG_Data return UInt32
is (RNG_Periph.DR);
--------------------
-- RNG_Data_Ready --
--------------------
function RNG_Data_Ready return Boolean
is (RNG_Periph.SR.DRDY);
---------------------------
-- RNG_Seed_Error_Status --
---------------------------
function RNG_Seed_Error_Status return Boolean is
(RNG_Periph.SR.SECS);
----------------------------
-- RNG_Clock_Error_Status --
----------------------------
function RNG_Clock_Error_Status return Boolean is
(RNG_Periph.SR.CECS);
---------------------------------
-- Clear_RNG_Seed_Error_Status --
---------------------------------
procedure Clear_RNG_Seed_Error_Status
is
begin
RNG_Periph.SR.SECS := False;
end Clear_RNG_Seed_Error_Status;
----------------------------------
-- Clear_RNG_Clock_Error_Status --
----------------------------------
procedure Clear_RNG_Clock_Error_Status
is
begin
RNG_Periph.SR.CECS := False;
end Clear_RNG_Clock_Error_Status;
end STM32.RNG;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Menus --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2014,2018 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.33 $
-- $Date: 2018/07/07 23:36:44 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Interfaces.C.Pointers;
package body Terminal_Interface.Curses.Menus is
type C_Item_Array is array (Natural range <>) of aliased Item;
package I_Array is new
Interfaces.C.Pointers (Natural, Item, C_Item_Array, Null_Item);
subtype chars_ptr is Interfaces.C.Strings.chars_ptr;
------------------------------------------------------------------------------
procedure Request_Name (Key : Menu_Request_Code;
Name : out String)
is
function Request_Name (Key : C_Int) return chars_ptr;
pragma Import (C, Request_Name, "menu_request_name");
begin
Fill_String (Request_Name (C_Int (Key)), Name);
end Request_Name;
function Request_Name (Key : Menu_Request_Code) return String
is
function Request_Name (Key : C_Int) return chars_ptr;
pragma Import (C, Request_Name, "menu_request_name");
begin
return Fill_String (Request_Name (C_Int (Key)));
end Request_Name;
function Create (Name : String;
Description : String := "") return Item
is
type Char_Ptr is access all Interfaces.C.char;
function Newitem (Name, Desc : Char_Ptr) return Item;
pragma Import (C, Newitem, "new_item");
type Name_String is new char_array (0 .. Name'Length);
type Name_String_Ptr is access Name_String;
pragma Controlled (Name_String_Ptr);
type Desc_String is new char_array (0 .. Description'Length);
type Desc_String_Ptr is access Desc_String;
pragma Controlled (Desc_String_Ptr);
Name_Str : constant Name_String_Ptr := new Name_String;
Desc_Str : constant Desc_String_Ptr := new Desc_String;
Name_Len, Desc_Len : size_t;
Result : Item;
begin
To_C (Name, Name_Str.all, Name_Len);
To_C (Description, Desc_Str.all, Desc_Len);
Result := Newitem (Name_Str.all (Name_Str.all'First)'Access,
Desc_Str.all (Desc_Str.all'First)'Access);
if Result = Null_Item then
raise Eti_System_Error;
end if;
return Result;
end Create;
procedure Delete (Itm : in out Item)
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
function Freeitem (Itm : Item) return Eti_Error;
pragma Import (C, Freeitem, "free_item");
Ptr : chars_ptr;
begin
Ptr := Descname (Itm);
if Ptr /= Null_Ptr then
Interfaces.C.Strings.Free (Ptr);
end if;
Ptr := Itemname (Itm);
if Ptr /= Null_Ptr then
Interfaces.C.Strings.Free (Ptr);
end if;
Eti_Exception (Freeitem (Itm));
Itm := Null_Item;
end Delete;
-------------------------------------------------------------------------------
procedure Set_Value (Itm : Item;
Value : Boolean := True)
is
function Set_Item_Val (Itm : Item;
Val : C_Int) return Eti_Error;
pragma Import (C, Set_Item_Val, "set_item_value");
begin
Eti_Exception (Set_Item_Val (Itm, Boolean'Pos (Value)));
end Set_Value;
function Value (Itm : Item) return Boolean
is
function Item_Val (Itm : Item) return C_Int;
pragma Import (C, Item_Val, "item_value");
begin
if Item_Val (Itm) = Curses_False then
return False;
else
return True;
end if;
end Value;
-------------------------------------------------------------------------------
function Visible (Itm : Item) return Boolean
is
function Item_Vis (Itm : Item) return C_Int;
pragma Import (C, Item_Vis, "item_visible");
begin
if Item_Vis (Itm) = Curses_False then
return False;
else
return True;
end if;
end Visible;
-------------------------------------------------------------------------------
procedure Set_Options (Itm : Item;
Options : Item_Option_Set)
is
function Set_Item_Opts (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Set_Item_Opts, "set_item_opts");
begin
Eti_Exception (Set_Item_Opts (Itm, Options));
end Set_Options;
procedure Switch_Options (Itm : Item;
Options : Item_Option_Set;
On : Boolean := True)
is
function Item_Opts_On (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Item_Opts_On, "item_opts_on");
function Item_Opts_Off (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Item_Opts_Off, "item_opts_off");
begin
if On then
Eti_Exception (Item_Opts_On (Itm, Options));
else
Eti_Exception (Item_Opts_Off (Itm, Options));
end if;
end Switch_Options;
procedure Get_Options (Itm : Item;
Options : out Item_Option_Set)
is
function Item_Opts (Itm : Item) return Item_Option_Set;
pragma Import (C, Item_Opts, "item_opts");
begin
Options := Item_Opts (Itm);
end Get_Options;
function Get_Options (Itm : Item := Null_Item) return Item_Option_Set
is
Ios : Item_Option_Set;
begin
Get_Options (Itm, Ios);
return Ios;
end Get_Options;
-------------------------------------------------------------------------------
procedure Name (Itm : Item;
Name : out String)
is
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
begin
Fill_String (Itemname (Itm), Name);
end Name;
function Name (Itm : Item) return String
is
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
begin
return Fill_String (Itemname (Itm));
end Name;
procedure Description (Itm : Item;
Description : out String)
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
begin
Fill_String (Descname (Itm), Description);
end Description;
function Description (Itm : Item) return String
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
begin
return Fill_String (Descname (Itm));
end Description;
-------------------------------------------------------------------------------
procedure Set_Current (Men : Menu;
Itm : Item)
is
function Set_Curr_Item (Men : Menu;
Itm : Item) return Eti_Error;
pragma Import (C, Set_Curr_Item, "set_current_item");
begin
Eti_Exception (Set_Curr_Item (Men, Itm));
end Set_Current;
function Current (Men : Menu) return Item
is
function Curr_Item (Men : Menu) return Item;
pragma Import (C, Curr_Item, "current_item");
Res : constant Item := Curr_Item (Men);
begin
if Res = Null_Item then
raise Menu_Exception;
end if;
return Res;
end Current;
procedure Set_Top_Row (Men : Menu;
Line : Line_Position)
is
function Set_Toprow (Men : Menu;
Line : C_Int) return Eti_Error;
pragma Import (C, Set_Toprow, "set_top_row");
begin
Eti_Exception (Set_Toprow (Men, C_Int (Line)));
end Set_Top_Row;
function Top_Row (Men : Menu) return Line_Position
is
function Toprow (Men : Menu) return C_Int;
pragma Import (C, Toprow, "top_row");
Res : constant C_Int := Toprow (Men);
begin
if Res = Curses_Err then
raise Menu_Exception;
end if;
return Line_Position (Res);
end Top_Row;
function Get_Index (Itm : Item) return Positive
is
function Get_Itemindex (Itm : Item) return C_Int;
pragma Import (C, Get_Itemindex, "item_index");
Res : constant C_Int := Get_Itemindex (Itm);
begin
if Res = Curses_Err then
raise Menu_Exception;
end if;
return Positive (Natural (Res) + Positive'First);
end Get_Index;
-------------------------------------------------------------------------------
procedure Post (Men : Menu;
Post : Boolean := True)
is
function M_Post (Men : Menu) return Eti_Error;
pragma Import (C, M_Post, "post_menu");
function M_Unpost (Men : Menu) return Eti_Error;
pragma Import (C, M_Unpost, "unpost_menu");
begin
if Post then
Eti_Exception (M_Post (Men));
else
Eti_Exception (M_Unpost (Men));
end if;
end Post;
-------------------------------------------------------------------------------
procedure Set_Options (Men : Menu;
Options : Menu_Option_Set)
is
function Set_Menu_Opts (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Set_Menu_Opts, "set_menu_opts");
begin
Eti_Exception (Set_Menu_Opts (Men, Options));
end Set_Options;
procedure Switch_Options (Men : Menu;
Options : Menu_Option_Set;
On : Boolean := True)
is
function Menu_Opts_On (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Menu_Opts_On, "menu_opts_on");
function Menu_Opts_Off (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Menu_Opts_Off, "menu_opts_off");
begin
if On then
Eti_Exception (Menu_Opts_On (Men, Options));
else
Eti_Exception (Menu_Opts_Off (Men, Options));
end if;
end Switch_Options;
procedure Get_Options (Men : Menu;
Options : out Menu_Option_Set)
is
function Menu_Opts (Men : Menu) return Menu_Option_Set;
pragma Import (C, Menu_Opts, "menu_opts");
begin
Options := Menu_Opts (Men);
end Get_Options;
function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set
is
Mos : Menu_Option_Set;
begin
Get_Options (Men, Mos);
return Mos;
end Get_Options;
-------------------------------------------------------------------------------
procedure Set_Window (Men : Menu;
Win : Window)
is
function Set_Menu_Win (Men : Menu;
Win : Window) return Eti_Error;
pragma Import (C, Set_Menu_Win, "set_menu_win");
begin
Eti_Exception (Set_Menu_Win (Men, Win));
end Set_Window;
function Get_Window (Men : Menu) return Window
is
function Menu_Win (Men : Menu) return Window;
pragma Import (C, Menu_Win, "menu_win");
W : constant Window := Menu_Win (Men);
begin
return W;
end Get_Window;
procedure Set_Sub_Window (Men : Menu;
Win : Window)
is
function Set_Menu_Sub (Men : Menu;
Win : Window) return Eti_Error;
pragma Import (C, Set_Menu_Sub, "set_menu_sub");
begin
Eti_Exception (Set_Menu_Sub (Men, Win));
end Set_Sub_Window;
function Get_Sub_Window (Men : Menu) return Window
is
function Menu_Sub (Men : Menu) return Window;
pragma Import (C, Menu_Sub, "menu_sub");
W : constant Window := Menu_Sub (Men);
begin
return W;
end Get_Sub_Window;
procedure Scale (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count)
is
type C_Int_Access is access all C_Int;
function M_Scale (Men : Menu;
Yp, Xp : C_Int_Access) return Eti_Error;
pragma Import (C, M_Scale, "scale_menu");
X, Y : aliased C_Int;
begin
Eti_Exception (M_Scale (Men, Y'Access, X'Access));
Lines := Line_Count (Y);
Columns := Column_Count (X);
end Scale;
-------------------------------------------------------------------------------
procedure Position_Cursor (Men : Menu)
is
function Pos_Menu_Cursor (Men : Menu) return Eti_Error;
pragma Import (C, Pos_Menu_Cursor, "pos_menu_cursor");
begin
Eti_Exception (Pos_Menu_Cursor (Men));
end Position_Cursor;
-------------------------------------------------------------------------------
procedure Set_Mark (Men : Menu;
Mark : String)
is
type Char_Ptr is access all Interfaces.C.char;
function Set_Mark (Men : Menu;
Mark : Char_Ptr) return Eti_Error;
pragma Import (C, Set_Mark, "set_menu_mark");
Txt : char_array (0 .. Mark'Length);
Len : size_t;
begin
To_C (Mark, Txt, Len);
Eti_Exception (Set_Mark (Men, Txt (Txt'First)'Access));
end Set_Mark;
procedure Mark (Men : Menu;
Mark : out String)
is
function Get_Menu_Mark (Men : Menu) return chars_ptr;
pragma Import (C, Get_Menu_Mark, "menu_mark");
begin
Fill_String (Get_Menu_Mark (Men), Mark);
end Mark;
function Mark (Men : Menu) return String
is
function Get_Menu_Mark (Men : Menu) return chars_ptr;
pragma Import (C, Get_Menu_Mark, "menu_mark");
begin
return Fill_String (Get_Menu_Mark (Men));
end Mark;
-------------------------------------------------------------------------------
procedure Set_Foreground
(Men : Menu;
Fore : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Fore (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Fore, "set_menu_fore");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Fore);
begin
Eti_Exception (Set_Menu_Fore (Men, Ch));
end Set_Foreground;
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set)
is
function Menu_Fore (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Fore, "menu_fore");
begin
Fore := Menu_Fore (Men).Attr;
end Foreground;
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Fore (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Fore, "menu_fore");
begin
Fore := Menu_Fore (Men).Attr;
Color := Menu_Fore (Men).Color;
end Foreground;
procedure Set_Background
(Men : Menu;
Back : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Back (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Back, "set_menu_back");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Back);
begin
Eti_Exception (Set_Menu_Back (Men, Ch));
end Set_Background;
procedure Background (Men : Menu;
Back : out Character_Attribute_Set)
is
function Menu_Back (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Back, "menu_back");
begin
Back := Menu_Back (Men).Attr;
end Background;
procedure Background (Men : Menu;
Back : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Back (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Back, "menu_back");
begin
Back := Menu_Back (Men).Attr;
Color := Menu_Back (Men).Color;
end Background;
procedure Set_Grey (Men : Menu;
Grey : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Grey (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Grey, "set_menu_grey");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Grey);
begin
Eti_Exception (Set_Menu_Grey (Men, Ch));
end Set_Grey;
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set)
is
function Menu_Grey (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Grey, "menu_grey");
begin
Grey := Menu_Grey (Men).Attr;
end Grey;
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Grey (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Grey, "menu_grey");
begin
Grey := Menu_Grey (Men).Attr;
Color := Menu_Grey (Men).Color;
end Grey;
procedure Set_Pad_Character (Men : Menu;
Pad : Character := Space)
is
function Set_Menu_Pad (Men : Menu;
Ch : C_Int) return Eti_Error;
pragma Import (C, Set_Menu_Pad, "set_menu_pad");
begin
Eti_Exception (Set_Menu_Pad (Men, C_Int (Character'Pos (Pad))));
end Set_Pad_Character;
procedure Pad_Character (Men : Menu;
Pad : out Character)
is
function Menu_Pad (Men : Menu) return C_Int;
pragma Import (C, Menu_Pad, "menu_pad");
begin
Pad := Character'Val (Menu_Pad (Men));
end Pad_Character;
-------------------------------------------------------------------------------
procedure Set_Spacing (Men : Menu;
Descr : Column_Position := 0;
Row : Line_Position := 0;
Col : Column_Position := 0)
is
function Set_Spacing (Men : Menu;
D, R, C : C_Int) return Eti_Error;
pragma Import (C, Set_Spacing, "set_menu_spacing");
begin
Eti_Exception (Set_Spacing (Men,
C_Int (Descr),
C_Int (Row),
C_Int (Col)));
end Set_Spacing;
procedure Spacing (Men : Menu;
Descr : out Column_Position;
Row : out Line_Position;
Col : out Column_Position)
is
type C_Int_Access is access all C_Int;
function Get_Spacing (Men : Menu;
D, R, C : C_Int_Access) return Eti_Error;
pragma Import (C, Get_Spacing, "menu_spacing");
D, R, C : aliased C_Int;
begin
Eti_Exception (Get_Spacing (Men,
D'Access,
R'Access,
C'Access));
Descr := Column_Position (D);
Row := Line_Position (R);
Col := Column_Position (C);
end Spacing;
-------------------------------------------------------------------------------
function Set_Pattern (Men : Menu;
Text : String) return Boolean
is
type Char_Ptr is access all Interfaces.C.char;
function Set_Pattern (Men : Menu;
Pattern : Char_Ptr) return Eti_Error;
pragma Import (C, Set_Pattern, "set_menu_pattern");
S : char_array (0 .. Text'Length);
L : size_t;
Res : Eti_Error;
begin
To_C (Text, S, L);
Res := Set_Pattern (Men, S (S'First)'Access);
case Res is
when E_No_Match =>
return False;
when others =>
Eti_Exception (Res);
return True;
end case;
end Set_Pattern;
procedure Pattern (Men : Menu;
Text : out String)
is
function Get_Pattern (Men : Menu) return chars_ptr;
pragma Import (C, Get_Pattern, "menu_pattern");
begin
Fill_String (Get_Pattern (Men), Text);
end Pattern;
-------------------------------------------------------------------------------
procedure Set_Format (Men : Menu;
Lines : Line_Count;
Columns : Column_Count)
is
function Set_Menu_Fmt (Men : Menu;
Lin : C_Int;
Col : C_Int) return Eti_Error;
pragma Import (C, Set_Menu_Fmt, "set_menu_format");
begin
Eti_Exception (Set_Menu_Fmt (Men,
C_Int (Lines),
C_Int (Columns)));
end Set_Format;
procedure Format (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count)
is
type C_Int_Access is access all C_Int;
function Menu_Fmt (Men : Menu;
Y, X : C_Int_Access) return Eti_Error;
pragma Import (C, Menu_Fmt, "menu_format");
L, C : aliased C_Int;
begin
Eti_Exception (Menu_Fmt (Men, L'Access, C'Access));
Lines := Line_Count (L);
Columns := Column_Count (C);
end Format;
-------------------------------------------------------------------------------
procedure Set_Item_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Item_Init (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Item_Init, "set_item_init");
begin
Eti_Exception (Set_Item_Init (Men, Proc));
end Set_Item_Init_Hook;
procedure Set_Item_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Item_Term (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Item_Term, "set_item_term");
begin
Eti_Exception (Set_Item_Term (Men, Proc));
end Set_Item_Term_Hook;
procedure Set_Menu_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Menu_Init (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Menu_Init, "set_menu_init");
begin
Eti_Exception (Set_Menu_Init (Men, Proc));
end Set_Menu_Init_Hook;
procedure Set_Menu_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Menu_Term (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Menu_Term, "set_menu_term");
begin
Eti_Exception (Set_Menu_Term (Men, Proc));
end Set_Menu_Term_Hook;
function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function
is
function Item_Init (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Item_Init, "item_init");
begin
return Item_Init (Men);
end Get_Item_Init_Hook;
function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function
is
function Item_Term (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Item_Term, "item_term");
begin
return Item_Term (Men);
end Get_Item_Term_Hook;
function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function
is
function Menu_Init (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Menu_Init, "menu_init");
begin
return Menu_Init (Men);
end Get_Menu_Init_Hook;
function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function
is
function Menu_Term (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Menu_Term, "menu_term");
begin
return Menu_Term (Men);
end Get_Menu_Term_Hook;
-------------------------------------------------------------------------------
procedure Redefine (Men : Menu;
Items : Item_Array_Access)
is
function Set_Items (Men : Menu;
Items : System.Address) return Eti_Error;
pragma Import (C, Set_Items, "set_menu_items");
begin
pragma Assert (Items.all (Items'Last) = Null_Item);
if Items.all (Items'Last) /= Null_Item then
raise Menu_Exception;
else
Eti_Exception (Set_Items (Men, Items.all'Address));
end if;
end Redefine;
function Item_Count (Men : Menu) return Natural
is
function Count (Men : Menu) return C_Int;
pragma Import (C, Count, "item_count");
begin
return Natural (Count (Men));
end Item_Count;
function Items (Men : Menu;
Index : Positive) return Item
is
use I_Array;
function C_Mitems (Men : Menu) return Pointer;
pragma Import (C, C_Mitems, "menu_items");
P : Pointer := C_Mitems (Men);
begin
if P = null or else Index > Item_Count (Men) then
raise Menu_Exception;
else
P := P + ptrdiff_t (C_Int (Index) - 1);
return P.all;
end if;
end Items;
-------------------------------------------------------------------------------
function Create (Items : Item_Array_Access) return Menu
is
function Newmenu (Items : System.Address) return Menu;
pragma Import (C, Newmenu, "new_menu");
M : Menu;
begin
pragma Assert (Items.all (Items'Last) = Null_Item);
if Items.all (Items'Last) /= Null_Item then
raise Menu_Exception;
else
M := Newmenu (Items.all'Address);
if M = Null_Menu then
raise Menu_Exception;
end if;
return M;
end if;
end Create;
procedure Delete (Men : in out Menu)
is
function Free (Men : Menu) return Eti_Error;
pragma Import (C, Free, "free_menu");
begin
Eti_Exception (Free (Men));
Men := Null_Menu;
end Delete;
------------------------------------------------------------------------------
function Driver (Men : Menu;
Key : Key_Code) return Driver_Result
is
function Driver (Men : Menu;
Key : C_Int) return Eti_Error;
pragma Import (C, Driver, "menu_driver");
R : constant Eti_Error := Driver (Men, C_Int (Key));
begin
case R is
when E_Unknown_Command =>
return Unknown_Request;
when E_No_Match =>
return No_Match;
when E_Request_Denied | E_Not_Selectable =>
return Request_Denied;
when others =>
Eti_Exception (R);
return Menu_Ok;
end case;
end Driver;
procedure Free (IA : in out Item_Array_Access;
Free_Items : Boolean := False)
is
procedure Release is new Ada.Unchecked_Deallocation
(Item_Array, Item_Array_Access);
begin
if IA /= null and then Free_Items then
for I in IA'First .. (IA'Last - 1) loop
if IA.all (I) /= Null_Item then
Delete (IA.all (I));
end if;
end loop;
end if;
Release (IA);
end Free;
-------------------------------------------------------------------------------
function Default_Menu_Options return Menu_Option_Set
is
begin
return Get_Options (Null_Menu);
end Default_Menu_Options;
function Default_Item_Options return Item_Option_Set
is
begin
return Get_Options (Null_Item);
end Default_Item_Options;
-------------------------------------------------------------------------------
end Terminal_Interface.Curses.Menus;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 5 9 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2009, 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. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 59
package System.Pack_59 is
pragma Preelaborate;
Bits : constant := 59;
type Bits_59 is mod 2 ** Bits;
for Bits_59'Size use Bits;
function Get_59 (Arr : System.Address; N : Natural) return Bits_59;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_59 (Arr : System.Address; N : Natural; E : Bits_59);
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_59;
|
package LR.Synchro.Fifo is
function Nom_Strategie return String;
procedure Demander_Lecture;
procedure Demander_Ecriture;
procedure Terminer_Lecture;
procedure Terminer_Ecriture;
end LR.Synchro.Fifo;
|
with AAA.Strings;
with CLIC.Subcommand;
package CLIC_Ex.Commands.Subsub is
type Instance
is new CLIC.Subcommand.Command
with private;
overriding
function Name (Cmd : Instance) return CLIC.Subcommand.Identifier
is ("subsub");
overriding
function Switch_Parsing (This : Instance)
return CLIC.Subcommand.Switch_Parsing_Kind
is (CLIC.Subcommand.Parse_All);
overriding
procedure Execute (Cmd : in out Instance;
Args : AAA.Strings.Vector);
overriding
function Long_Description (Cmd : Instance) return AAA.Strings.Vector
is (AAA.Strings.Empty_Vector);
overriding
procedure Setup_Switches
(Cmd : in out Instance;
Config : in out CLIC.Subcommand.Switches_Configuration)
is null;
overriding
function Short_Description (Cmd : Instance) return String
is ("Subcommands in a subcommand");
overriding
function Usage_Custom_Parameters (Cmd : Instance) return String
is ("");
private
type Instance
is new CLIC.Subcommand.Command
with null record;
end CLIC_Ex.Commands.Subsub;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O S I N T - B --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the low level, operating system routines used only
-- in the GNAT binder for command line processing and file input output.
package Osint.B is
function More_Lib_Files return Boolean;
-- Indicates whether more library information files remain to be processed.
-- Returns False right away if no source files, or if all source files
-- have been processed.
function Next_Main_Lib_File return File_Name_Type;
-- This function returns the name of the next library info file specified
-- on the command line. It is an error to call Next_Main_Lib_File if no
-- more library information files exist (i.e. Next_Main_Lib_File may be
-- called only if a previous call to More_Lib_Files returned True). This
-- name is the simple name, excluding any directory information.
-------------------
-- Binder Output --
-------------------
-- These routines are used by the binder to generate the Ada source files
-- containing the binder output. The format of these files is described in
-- package Bindgen.
procedure Create_Binder_Output
(Output_File_Name : String;
Typ : Character;
Bfile : out Name_Id);
-- Creates the binder output file. Typ is one of
-- 'b' create body file for case of generating Ada
-- 's' create spec file for case of generating Ada
--
-- If Output_File_Name is null, then a default name is used based on
-- the name of the most recently accessed main source file name. If
-- Output_File_Name is non-null then it is the full path name of the
-- file to be output (in the case of Ada, it must have an extension
-- of adb, and the spec file is created by changing the last character
-- from b to s. On return, Bfile also contains the Name_Id for the
-- generated file name.
procedure Write_Binder_Info (Info : String);
-- Writes the contents of the referenced string to the binder output file
-- created by a previous call to Create_Binder_Output. Info represents a
-- single line in the file, but does not contain any line termination
-- characters. The implementation of Write_Binder_Info is responsible
-- for adding necessary end of line and end of file control characters
-- as required by the operating system.
procedure Close_Binder_Output;
-- Closes the file created by Create_Binder_Output, flushing any
-- buffers etc. from writes by Write_Binder_Info.
procedure Set_Current_File_Name_Index (To : Int);
-- Set value of Current_File_Name_Index (in private part of Osint) to To
----------------------------------
-- Other binder-generated files --
----------------------------------
procedure Set_List_File (Filename : String);
-- Create Filename as a text output file and set it as the current output
-- (see Output.Set_Output).
procedure Close_List_File;
-- If a specific output file was created by Set_List_File, close it and
-- reset the current output file to standard output.
end Osint.B;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R . C H 1 3 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram body ordering check. Subprograms are in order
-- by RM section rather than alphabetical
separate (Par)
package body Ch13 is
-- Local functions, used only in this chapter
function P_Component_Clause return Node_Id;
function P_Mod_Clause return Node_Id;
-----------------------------------
-- Aspect_Specifications_Present --
-----------------------------------
function Aspect_Specifications_Present
(Strict : Boolean := Ada_Version < Ada_2012) return Boolean
is
Scan_State : Saved_Scan_State;
Result : Boolean;
function Possible_Misspelled_Aspect return Boolean;
-- Returns True, if Token_Name is a misspelling of some aspect name
function With_Present return Boolean;
-- Returns True if WITH is present, indicating presence of aspect
-- specifications. Also allows incorrect use of WHEN in place of WITH.
--------------------------------
-- Possible_Misspelled_Aspect --
--------------------------------
function Possible_Misspelled_Aspect return Boolean is
begin
for J in Aspect_Id_Exclude_No_Aspect loop
if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then
return True;
end if;
end loop;
return False;
end Possible_Misspelled_Aspect;
------------------
-- With_Present --
------------------
function With_Present return Boolean is
begin
if Token = Tok_With then
return True;
-- Check for WHEN used in place of WITH
elsif Token = Tok_When then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past WHEN
if Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
Error_Msg_SC ("WHEN should be WITH");
Restore_Scan_State (Scan_State);
return True;
else
Restore_Scan_State (Scan_State);
return False;
end if;
end;
else
return False;
end if;
end With_Present;
-- Start of processing for Aspect_Specifications_Present
begin
-- Definitely must have WITH to consider aspect specs to be present
-- Note that this means that if we have a semicolon, we immediately
-- return False. There is a case in which this is not optimal, namely
-- something like
-- type R is new Integer;
-- with bla bla;
-- where the semicolon is redundant, but scanning forward for it would
-- be too expensive. Instead we pick up the aspect specifications later
-- as a bogus declaration, and diagnose the semicolon at that point.
if not With_Present then
return False;
end if;
-- Have a WITH or some token that we accept as a legitimate bad attempt
-- at writing WITH. See if it looks like an aspect specification
Save_Scan_State (Scan_State);
Scan; -- past WITH (or WHEN or other bad keyword)
-- If no identifier, then consider that we definitely do not have an
-- aspect specification.
if Token /= Tok_Identifier then
Result := False;
-- This is where we pay attention to the Strict mode. Normally when
-- we are in Ada 2012 mode, Strict is False, and we consider that we
-- have an aspect specification if the identifier is an aspect name
-- or a likely misspelling of one (even if not followed by =>) or
-- the identifier is not an aspect name but is followed by =>, by
-- a comma, or by a semicolon. The last two cases correspond to
-- (misspelled) Boolean aspects with a defaulted value of True.
-- P_Aspect_Specifications will generate messages if the aspect
-- specification is ill-formed.
elsif not Strict then
if Get_Aspect_Id (Token_Name) /= No_Aspect
or else Possible_Misspelled_Aspect
then
Result := True;
else
Scan; -- past identifier
Result := Token = Tok_Arrow or else
Token = Tok_Comma or else
Token = Tok_Semicolon;
end if;
-- If earlier than Ada 2012, check for valid aspect identifier (possibly
-- completed with 'CLASS) followed by an arrow, and consider that this
-- is still an aspect specification so we give an appropriate message.
else
if Get_Aspect_Id (Token_Name) = No_Aspect then
Result := False;
else
Scan; -- past aspect name
Result := False;
if Token = Tok_Arrow then
Result := True;
-- The identifier may be the name of a boolean aspect with a
-- defaulted True value. Further checks when analyzing aspect
-- specification, which may include further aspects.
elsif Token = Tok_Comma or else Token = Tok_Semicolon then
Result := True;
elsif Token = Tok_Apostrophe then
Scan; -- past apostrophe
if Token = Tok_Identifier
and then Token_Name = Name_Class
then
Scan; -- past CLASS
if Token = Tok_Arrow then
Result := True;
end if;
end if;
end if;
if Result then
Restore_Scan_State (Scan_State);
Error_Msg_Ada_2012_Feature ("|aspect specification", Token_Ptr);
return True;
end if;
end if;
end if;
Restore_Scan_State (Scan_State);
return Result;
end Aspect_Specifications_Present;
-------------------------------
-- Get_Aspect_Specifications --
-------------------------------
function Get_Aspect_Specifications
(Semicolon : Boolean := True) return List_Id
is
A_Id : Aspect_Id;
Aspect : Node_Id;
Aspects : List_Id;
OK : Boolean;
Opt : Boolean;
-- True if current aspect takes an optional argument
begin
Aspects := Empty_List;
-- Check if aspect specification present
if not Aspect_Specifications_Present then
if Semicolon then
TF_Semicolon;
end if;
return Aspects;
end if;
Scan; -- past WITH (or possible WHEN after error)
Aspects := Empty_List;
-- Loop to scan aspects
loop
OK := True;
-- The aspect mark is not an identifier
if Token /= Tok_Identifier then
Error_Msg_SC ("aspect identifier expected");
-- Skip the whole aspect specification list
if Semicolon then
Resync_Past_Semicolon;
end if;
return Aspects;
end if;
A_Id := Get_Aspect_Id (Token_Name);
Aspect :=
Make_Aspect_Specification (Token_Ptr,
Identifier => Token_Node);
-- The aspect mark is not recognized
if A_Id = No_Aspect then
Error_Msg_N ("& is not a valid aspect identifier", Token_Node);
OK := False;
-- Check bad spelling
for J in Aspect_Id_Exclude_No_Aspect loop
if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then
Error_Msg_Name_1 := Aspect_Names (J);
Error_Msg_N -- CODEFIX
("\possible misspelling of%", Token_Node);
exit;
end if;
end loop;
Scan; -- past incorrect identifier
if Token = Tok_Apostrophe then
Scan; -- past apostrophe
Scan; -- past presumably CLASS
end if;
-- Attempt to parse the aspect definition by assuming it is an
-- expression.
if Token = Tok_Arrow then
Scan; -- past arrow
Set_Expression (Aspect, P_Expression);
-- If we have a correct terminator (comma or semicolon, or a
-- reasonable likely missing comma), then just proceed.
elsif Token = Tok_Comma or else
Token = Tok_Semicolon or else
Token = Tok_Identifier
then
null;
-- Otherwise the aspect contains a junk definition
else
if Semicolon then
Resync_Past_Semicolon;
end if;
return Aspects;
end if;
-- Aspect mark is OK
else
Scan; -- past identifier
Opt := Aspect_Argument (A_Id) = Optional_Expression
or else
Aspect_Argument (A_Id) = Optional_Name;
-- Check for 'Class present
if Token = Tok_Apostrophe then
if Class_Aspect_OK (A_Id) then
Scan; -- past apostrophe
if Token = Tok_Identifier
and then Token_Name = Name_Class
then
Scan; -- past CLASS
Set_Class_Present (Aspect);
else
Error_Msg_SC ("Class attribute expected here");
OK := False;
if Token = Tok_Identifier then
Scan; -- past identifier not CLASS
end if;
end if;
-- The aspect does not allow 'Class
else
Error_Msg_Node_1 := Identifier (Aspect);
Error_Msg_SC ("aspect& does not permit attribute here");
OK := False;
Scan; -- past apostrophe
Scan; -- past presumably CLASS
end if;
end if;
-- Check for a missing aspect definition. Aspects with optional
-- definitions are not considered.
if Token = Tok_Comma or else Token = Tok_Semicolon then
if not Opt then
Error_Msg_Node_1 := Identifier (Aspect);
Error_Msg_AP ("aspect& requires an aspect definition");
OK := False;
end if;
-- Here we do not have a comma or a semicolon, we are done if we
-- do not have an arrow and the aspect does not need an argument
elsif Opt and then Token /= Tok_Arrow then
null;
-- Here we have either an arrow, or an aspect that definitely
-- needs an aspect definition, and we will look for one even if
-- no arrow is preseant.
-- Otherwise we have an aspect definition
else
if Token = Tok_Arrow then
Scan; -- past arrow
else
T_Arrow;
OK := False;
end if;
-- Detect a common error where the non-null definition of
-- aspect Depends, Global, Refined_Depends, Refined_Global
-- or Refined_State lacks enclosing parentheses.
if Token /= Tok_Left_Paren and then Token /= Tok_Null then
-- [Refined_]Depends
if A_Id = Aspect_Depends
or else
A_Id = Aspect_Refined_Depends
then
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last in the list
-- of specifications and the list applies to a body.
if Token = Tok_Is then
return Aspects;
end if;
-- [Refined_]Global
elsif A_Id = Aspect_Global
or else
A_Id = Aspect_Refined_Global
then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past item or mode_selector
-- Emit an error when the aspect has a mode_selector
-- as the moded_global_list must be parenthesized:
-- with Global => Output => Item
if Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last in
-- the list of specifications and the list applies
-- to a body.
if Token = Tok_Is then
return Aspects;
end if;
elsif Token = Tok_Comma then
Scan; -- past comma
-- An item followed by a comma does not need to
-- be parenthesized if the next token is a valid
-- aspect name:
-- with Global => Item,
-- Aspect => ...
if Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
Restore_Scan_State (Scan_State);
-- Otherwise this is a list of items in which case
-- the list must be parenthesized.
else
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last
-- in the list of specifications and the list
-- applies to a body.
if Token = Tok_Is then
return Aspects;
end if;
end if;
-- The definition of [Refined_]Global does not need to
-- be parenthesized.
else
Restore_Scan_State (Scan_State);
end if;
end;
-- Refined_State
elsif A_Id = Aspect_Refined_State then
if Token = Tok_Identifier then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past state
-- The refinement contains a constituent, the whole
-- argument of Refined_State must be parenthesized.
-- with Refined_State => State => Constit
if Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last
-- in the list of specifications and the list
-- applies to a body.
if Token = Tok_Is then
return Aspects;
end if;
-- The refinement lacks constituents. Do not flag
-- this case as the error would be misleading. The
-- diagnostic is left to the analysis.
-- with Refined_State => State
else
Restore_Scan_State (Scan_State);
end if;
end;
end if;
end if;
end if;
-- Note if inside Depends aspect
if A_Id = Aspect_Depends then
Inside_Depends := True;
end if;
-- Parse the aspect definition depening on the expected
-- argument kind.
if Aspect_Argument (A_Id) = Name
or else Aspect_Argument (A_Id) = Optional_Name
then
Set_Expression (Aspect, P_Name);
else
pragma Assert
(Aspect_Argument (A_Id) = Expression
or else
Aspect_Argument (A_Id) = Optional_Expression);
Set_Expression (Aspect, P_Expression);
end if;
-- Unconditionally reset flag for Inside_Depends
Inside_Depends := False;
end if;
-- Add the aspect to the resulting list only when it was properly
-- parsed.
if OK then
Append (Aspect, Aspects);
end if;
end if;
-- Merge here after good or bad aspect (we should be at a comma
-- or a semicolon, but there might be other possible errors).
-- The aspect specification list contains more than one aspect
if Token = Tok_Comma then
Scan; -- past comma
goto Continue;
-- Check for a missing comma between two aspects. Emit an error
-- and proceed to the next aspect.
elsif Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past identifier
-- Attempt to detect ' or => following a potential aspect
-- mark.
if Token = Tok_Apostrophe or else Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_AP -- CODEFIX
("|missing "",""");
goto Continue;
-- The construct following the current aspect is not an
-- aspect.
else
Restore_Scan_State (Scan_State);
end if;
end;
-- Check for a mistyped semicolon in place of a comma between two
-- aspects. Emit an error and proceed to the next aspect.
elsif Token = Tok_Semicolon then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past semicolon
if Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
Scan; -- past identifier
-- Attempt to detect ' or => following potential aspect mark
if Token = Tok_Apostrophe or else Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("|"";"" should be "",""");
Scan; -- past semicolon
goto Continue;
end if;
end if;
-- Construct following the current aspect is not an aspect
Restore_Scan_State (Scan_State);
end;
end if;
-- Require semicolon if caller expects to scan this out
if Semicolon then
T_Semicolon;
end if;
exit;
<<Continue>>
null;
end loop;
return Aspects;
end Get_Aspect_Specifications;
--------------------------------------------
-- 13.1 Representation Clause (also I.7) --
--------------------------------------------
-- REPRESENTATION_CLAUSE ::=
-- ATTRIBUTE_DEFINITION_CLAUSE
-- | ENUMERATION_REPRESENTATION_CLAUSE
-- | RECORD_REPRESENTATION_CLAUSE
-- | AT_CLAUSE
-- ATTRIBUTE_DEFINITION_CLAUSE ::=
-- for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use EXPRESSION;
-- | for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use NAME;
-- Note: in Ada 83, the expression must be a simple expression
-- AT_CLAUSE ::= for DIRECT_NAME use at EXPRESSION;
-- Note: in Ada 83, the expression must be a simple expression
-- ENUMERATION_REPRESENTATION_CLAUSE ::=
-- for first_subtype_LOCAL_NAME use ENUMERATION_AGGREGATE;
-- ENUMERATION_AGGREGATE ::= ARRAY_AGGREGATE
-- RECORD_REPRESENTATION_CLAUSE ::=
-- for first_subtype_LOCAL_NAME use
-- record [MOD_CLAUSE]
-- {COMPONENT_CLAUSE}
-- end record;
-- Note: for now we allow only a direct name as the local name in the
-- above constructs. This probably needs changing later on ???
-- The caller has checked that the initial token is FOR
-- Error recovery: cannot raise Error_Resync, if an error occurs,
-- the scan is repositioned past the next semicolon.
function P_Representation_Clause return Node_Id is
For_Loc : Source_Ptr;
Name_Node : Node_Id;
Prefix_Node : Node_Id;
Attr_Name : Name_Id;
Identifier_Node : Node_Id;
Rep_Clause_Node : Node_Id;
Expr_Node : Node_Id;
Record_Items : List_Id;
begin
For_Loc := Token_Ptr;
Scan; -- past FOR
-- Note that the name in a representation clause is always a simple
-- name, even in the attribute case, see AI-300 which made this so.
Identifier_Node := P_Identifier (C_Use);
-- Check case of qualified name to give good error message
if Token = Tok_Dot then
Error_Msg_SC
("representation clause requires simple name!");
loop
exit when Token /= Tok_Dot;
Scan; -- past dot
Discard_Junk_Node (P_Identifier);
end loop;
end if;
-- Attribute Definition Clause
if Token = Tok_Apostrophe then
-- Allow local names of the form a'b'.... This enables
-- us to parse class-wide streams attributes correctly.
Name_Node := Identifier_Node;
while Token = Tok_Apostrophe loop
Scan; -- past apostrophe
Identifier_Node := Token_Node;
Attr_Name := No_Name;
if Token = Tok_Identifier then
Attr_Name := Token_Name;
-- Note that the parser must complain in case of an internal
-- attribute name that comes from source since internal names
-- are meant to be used only by the compiler.
if not Is_Attribute_Name (Attr_Name)
and then (not Is_Internal_Attribute_Name (Attr_Name)
or else Comes_From_Source (Token_Node))
then
Signal_Bad_Attribute;
end if;
if Style_Check then
Style.Check_Attribute_Name (False);
end if;
-- Here for case of attribute designator is not an identifier
else
if Token = Tok_Delta then
Attr_Name := Name_Delta;
elsif Token = Tok_Digits then
Attr_Name := Name_Digits;
elsif Token = Tok_Access then
Attr_Name := Name_Access;
else
Error_Msg_AP ("attribute designator expected");
raise Error_Resync;
end if;
if Style_Check then
Style.Check_Attribute_Name (True);
end if;
end if;
-- Here we have an OK attribute scanned, and the corresponding
-- Attribute identifier node is stored in Ident_Node.
Prefix_Node := Name_Node;
Name_Node := New_Node (N_Attribute_Reference, Prev_Token_Ptr);
Set_Prefix (Name_Node, Prefix_Node);
Set_Attribute_Name (Name_Node, Attr_Name);
Scan;
-- Check for Address clause which needs to be marked for use in
-- optimizing performance of Exp_Util.Following_Address_Clause.
if Attr_Name = Name_Address
and then Nkind (Prefix_Node) = N_Identifier
then
Set_Name_Table_Boolean1 (Chars (Prefix_Node), True);
end if;
end loop;
Rep_Clause_Node := New_Node (N_Attribute_Definition_Clause, For_Loc);
Set_Name (Rep_Clause_Node, Prefix_Node);
Set_Chars (Rep_Clause_Node, Attr_Name);
T_Use;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Expression (Rep_Clause_Node, Expr_Node);
else
TF_Use;
Rep_Clause_Node := Empty;
-- AT follows USE (At Clause)
if Token = Tok_At then
Scan; -- past AT
Rep_Clause_Node := New_Node (N_At_Clause, For_Loc);
Set_Identifier (Rep_Clause_Node, Identifier_Node);
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Expression (Rep_Clause_Node, Expr_Node);
-- Mark occurrence of address clause (used to optimize performance
-- of Exp_Util.Following_Address_Clause).
Set_Name_Table_Boolean1 (Chars (Identifier_Node), True);
-- RECORD follows USE (Record Representation Clause)
elsif Token = Tok_Record then
Record_Items := P_Pragmas_Opt;
Rep_Clause_Node :=
New_Node (N_Record_Representation_Clause, For_Loc);
Set_Identifier (Rep_Clause_Node, Identifier_Node);
Push_Scope_Stack;
Scope.Table (Scope.Last).Etyp := E_Record;
Scope.Table (Scope.Last).Ecol := Start_Column;
Scope.Table (Scope.Last).Sloc := Token_Ptr;
Scan; -- past RECORD
Record_Items := P_Pragmas_Opt;
-- Possible Mod Clause
if Token = Tok_At then
Set_Mod_Clause (Rep_Clause_Node, P_Mod_Clause);
Set_Pragmas_Before (Mod_Clause (Rep_Clause_Node), Record_Items);
Record_Items := P_Pragmas_Opt;
end if;
if No (Record_Items) then
Record_Items := New_List;
end if;
Set_Component_Clauses (Rep_Clause_Node, Record_Items);
-- Loop through component clauses
loop
if Token not in Token_Class_Name then
exit when Check_End;
end if;
Append (P_Component_Clause, Record_Items);
P_Pragmas_Opt (Record_Items);
end loop;
-- Left paren follows USE (Enumeration Representation Clause)
elsif Token = Tok_Left_Paren then
Rep_Clause_Node :=
New_Node (N_Enumeration_Representation_Clause, For_Loc);
Set_Identifier (Rep_Clause_Node, Identifier_Node);
Set_Array_Aggregate (Rep_Clause_Node, P_Aggregate);
-- Some other token follows FOR (invalid representation clause)
else
Error_Msg_SC ("invalid representation clause");
raise Error_Resync;
end if;
end if;
TF_Semicolon;
return Rep_Clause_Node;
exception
when Error_Resync =>
Resync_Past_Semicolon;
return Error;
end P_Representation_Clause;
----------------------
-- 13.1 Local Name --
----------------------
-- Local name is always parsed by its parent. In the case of its use in
-- pragmas, the check for a local name is handled in Par.Prag and allows
-- all the possible forms of local name. For the uses in chapter 13, we
-- currently only allow a direct name, but this should probably change???
---------------------------
-- 13.1 At Clause (I.7) --
---------------------------
-- Parsed by P_Representation_Clause (13.1)
---------------------------------------
-- 13.3 Attribute Definition Clause --
---------------------------------------
-- Parsed by P_Representation_Clause (13.1)
--------------------------------
-- 13.1 Aspect Specification --
--------------------------------
-- ASPECT_SPECIFICATION ::=
-- with ASPECT_MARK [=> ASPECT_DEFINITION] {,
-- ASPECT_MARK [=> ASPECT_DEFINITION] }
-- ASPECT_MARK ::= aspect_IDENTIFIER['Class]
-- ASPECT_DEFINITION ::= NAME | EXPRESSION
-- Error recovery: cannot raise Error_Resync
procedure P_Aspect_Specifications
(Decl : Node_Id;
Semicolon : Boolean := True)
is
Aspects : List_Id;
Ptr : Source_Ptr;
begin
-- Aspect Specification is present
Ptr := Token_Ptr;
-- Here we have an aspect specification to scan, note that we don't
-- set the flag till later, because it may turn out that we have no
-- valid aspects in the list.
Aspects := Get_Aspect_Specifications (Semicolon);
-- Here if aspects present
if Is_Non_Empty_List (Aspects) then
-- If Decl is Empty, we just ignore the aspects (the caller in this
-- case has always issued an appropriate error message).
if Decl = Empty then
null;
-- If Decl is Error, we ignore the aspects, and issue a message
elsif Decl = Error then
Error_Msg ("aspect specifications not allowed here", Ptr);
-- Here aspects are allowed, and we store them
else
Set_Parent (Aspects, Decl);
Set_Aspect_Specifications (Decl, Aspects);
end if;
end if;
end P_Aspect_Specifications;
---------------------------------------------
-- 13.4 Enumeration Representation Clause --
---------------------------------------------
-- Parsed by P_Representation_Clause (13.1)
---------------------------------
-- 13.4 Enumeration Aggregate --
---------------------------------
-- Parsed by P_Representation_Clause (13.1)
------------------------------------------
-- 13.5.1 Record Representation Clause --
------------------------------------------
-- Parsed by P_Representation_Clause (13.1)
------------------------------
-- 13.5.1 Mod Clause (I.8) --
------------------------------
-- MOD_CLAUSE ::= at mod static_EXPRESSION;
-- Note: in Ada 83, the expression must be a simple expression
-- The caller has checked that the initial Token is AT
-- Error recovery: cannot raise Error_Resync
-- Note: the caller is responsible for setting the Pragmas_Before field
function P_Mod_Clause return Node_Id is
Mod_Node : Node_Id;
Expr_Node : Node_Id;
begin
Mod_Node := New_Node (N_Mod_Clause, Token_Ptr);
Scan; -- past AT
T_Mod;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Expression (Mod_Node, Expr_Node);
TF_Semicolon;
return Mod_Node;
end P_Mod_Clause;
------------------------------
-- 13.5.1 Component Clause --
------------------------------
-- COMPONENT_CLAUSE ::=
-- COMPONENT_CLAUSE_COMPONENT_NAME at POSITION
-- range FIRST_BIT .. LAST_BIT;
-- COMPONENT_CLAUSE_COMPONENT_NAME ::=
-- component_DIRECT_NAME
-- | component_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
-- | FIRST_SUBTYPE_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
-- POSITION ::= static_EXPRESSION
-- Note: in Ada 83, the expression must be a simple expression
-- FIRST_BIT ::= static_SIMPLE_EXPRESSION
-- LAST_BIT ::= static_SIMPLE_EXPRESSION
-- Note: the AARM V2.0 grammar has an error at this point, it uses
-- EXPRESSION instead of SIMPLE_EXPRESSION for FIRST_BIT and LAST_BIT
-- Error recovery: cannot raise Error_Resync
function P_Component_Clause return Node_Id is
Component_Node : Node_Id;
Comp_Name : Node_Id;
Expr_Node : Node_Id;
begin
Component_Node := New_Node (N_Component_Clause, Token_Ptr);
Comp_Name := P_Name;
if Nkind (Comp_Name) = N_Identifier
or else Nkind (Comp_Name) = N_Attribute_Reference
then
Set_Component_Name (Component_Node, Comp_Name);
else
Error_Msg_N
("component name must be direct name or attribute", Comp_Name);
Set_Component_Name (Component_Node, Error);
end if;
Set_Sloc (Component_Node, Token_Ptr);
T_At;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Position (Component_Node, Expr_Node);
T_Range;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_First_Bit (Component_Node, Expr_Node);
T_Dot_Dot;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Last_Bit (Component_Node, Expr_Node);
TF_Semicolon;
return Component_Node;
end P_Component_Clause;
----------------------
-- 13.5.1 Position --
----------------------
-- Parsed by P_Component_Clause (13.5.1)
-----------------------
-- 13.5.1 First Bit --
-----------------------
-- Parsed by P_Component_Clause (13.5.1)
----------------------
-- 13.5.1 Last Bit --
----------------------
-- Parsed by P_Component_Clause (13.5.1)
--------------------------
-- 13.8 Code Statement --
--------------------------
-- CODE_STATEMENT ::= QUALIFIED_EXPRESSION
-- On entry the caller has scanned the SUBTYPE_MARK (passed in as the
-- single argument, and the scan points to the apostrophe.
-- Error recovery: can raise Error_Resync
function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id is
Node1 : Node_Id;
begin
Scan; -- past apostrophe
-- If left paren, then we have a possible code statement
if Token = Tok_Left_Paren then
Node1 := New_Node (N_Code_Statement, Sloc (Subtype_Mark));
Set_Expression (Node1, P_Qualified_Expression (Subtype_Mark));
TF_Semicolon;
return Node1;
-- Otherwise we have an illegal range attribute. Note that P_Name
-- ensures that Token = Tok_Range is the only possibility left here.
else
Error_Msg_SC ("RANGE attribute illegal here!");
raise Error_Resync;
end if;
end P_Code_Statement;
end Ch13;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S I N F O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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 Style_Checks (All_Checks);
-- No subprogram ordering check, due to logical grouping
with Atree; use Atree;
package body Sinfo is
use Atree.Unchecked_Access;
-- This package is one of the few packages which is allowed to make direct
-- references to tree nodes (since it is in the business of providing a
-- higher level of tree access which other clients are expected to use and
-- which implements checks).
use Atree_Private_Part;
-- The only reason that we ask for direct access to the private part of
-- the tree package is so that we can directly reference the Nkind field
-- of nodes table entries. We do this since it helps the efficiency of
-- the Sinfo debugging checks considerably (note that when we are checking
-- Nkind values, we don't need to check for a valid node reference, because
-- we will check that anyway when we reference the field).
NT : Nodes.Table_Ptr renames Nodes.Table;
-- A short hand abbreviation, useful for the debugging checks
----------------------------
-- Field Access Functions --
----------------------------
-- Note: The use of Assert (False or else ...) is just a device to allow
-- uniform format of the conditions following this. Note that csinfo
-- expects this uniform format.
function ABE_Is_Certain
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Procedure_Call_Statement
or else NT (N).Nkind = N_Procedure_Instantiation);
return Flag18 (N);
end ABE_Is_Certain;
function Abort_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Requeue_Statement);
return Flag15 (N);
end Abort_Present;
function Abortable_Part
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Asynchronous_Select);
return Node2 (N);
end Abortable_Part;
function Abstract_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Record_Definition);
return Flag4 (N);
end Abstract_Present;
function Accept_Handler_Records
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative);
return List5 (N);
end Accept_Handler_Records;
function Accept_Statement
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative);
return Node2 (N);
end Accept_Statement;
function Access_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration);
return Node3 (N);
end Access_Definition;
function Access_To_Subprogram_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition);
return Node3 (N);
end Access_To_Subprogram_Definition;
function Access_Types_To_Process
(N : Node_Id) return Elist_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Freeze_Entity);
return Elist2 (N);
end Access_Types_To_Process;
function Actions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Compilation_Unit_Aux
or else NT (N).Nkind = N_Compound_Statement
or else NT (N).Nkind = N_Expression_With_Actions
or else NT (N).Nkind = N_Freeze_Entity
or else NT (N).Nkind = N_Or_Else);
return List1 (N);
end Actions;
function Activation_Chain_Entity
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
return Node3 (N);
end Activation_Chain_Entity;
function Acts_As_Spec
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit
or else NT (N).Nkind = N_Subprogram_Body);
return Flag4 (N);
end Acts_As_Spec;
function Actual_Designated_Subtype
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Explicit_Dereference
or else NT (N).Nkind = N_Free_Statement);
return Node4 (N);
end Actual_Designated_Subtype;
function Address_Warning_Posted
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause);
return Flag18 (N);
end Address_Warning_Posted;
function Aggregate_Bounds
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate);
return Node3 (N);
end Aggregate_Bounds;
function Aliased_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
return Flag4 (N);
end Aliased_Present;
function All_Others
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Others_Choice);
return Flag11 (N);
end All_Others;
function All_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Quantified_Expression
or else NT (N).Nkind = N_Use_Type_Clause);
return Flag15 (N);
end All_Present;
function Alternatives
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Expression
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In);
return List4 (N);
end Alternatives;
function Ancestor_Part
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extension_Aggregate);
return Node3 (N);
end Ancestor_Part;
function Atomic_Sync_Required
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Explicit_Dereference
or else NT (N).Nkind = N_Identifier
or else NT (N).Nkind = N_Indexed_Component
or else NT (N).Nkind = N_Selected_Component);
return Flag14 (N);
end Atomic_Sync_Required;
function Array_Aggregate
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Enumeration_Representation_Clause);
return Node3 (N);
end Array_Aggregate;
function Aspect_Rep_Item
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
return Node2 (N);
end Aspect_Rep_Item;
function Assignment_OK
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind in N_Subexpr);
return Flag15 (N);
end Assignment_OK;
function Associated_Node
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Entity
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate
or else NT (N).Nkind = N_Selected_Component);
return Node4 (N);
end Associated_Node;
function At_End_Proc
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements);
return Node1 (N);
end At_End_Proc;
function Attribute_Name
(N : Node_Id) return Name_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
return Name2 (N);
end Attribute_Name;
function Aux_Decls_Node
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Node5 (N);
end Aux_Decls_Node;
function Backwards_OK
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
return Flag6 (N);
end Backwards_OK;
function Bad_Is_Detected
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body);
return Flag15 (N);
end Bad_Is_Detected;
function Body_Required
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Flag13 (N);
end Body_Required;
function Body_To_Inline
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Declaration);
return Node3 (N);
end Body_To_Inline;
function Box_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Formal_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Generic_Association
or else NT (N).Nkind = N_Iterated_Component_Association);
return Flag15 (N);
end Box_Present;
function By_Ref
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
return Flag5 (N);
end By_Ref;
function Char_Literal_Value
(N : Node_Id) return Uint is
begin
pragma Assert (False
or else NT (N).Nkind = N_Character_Literal);
return Uint2 (N);
end Char_Literal_Value;
function Chars
(N : Node_Id) return Name_Id is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Chars);
return Name1 (N);
end Chars;
function Check_Address_Alignment
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause);
return Flag11 (N);
end Check_Address_Alignment;
function Choice_Parameter
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
return Node2 (N);
end Choice_Parameter;
function Choices
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association);
return List1 (N);
end Choices;
function Class_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
return Flag6 (N);
end Class_Present;
function Classifications
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
return Node3 (N);
end Classifications;
function Cleanup_Actions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
return List5 (N);
end Cleanup_Actions;
function Comes_From_Extended_Return_Statement
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Simple_Return_Statement);
return Flag18 (N);
end Comes_From_Extended_Return_Statement;
function Compile_Time_Known_Aggregate
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate);
return Flag18 (N);
end Compile_Time_Known_Aggregate;
function Component_Associations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Delta_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
return List2 (N);
end Component_Associations;
function Component_Clauses
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Record_Representation_Clause);
return List3 (N);
end Component_Clauses;
function Component_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Constrained_Array_Definition
or else NT (N).Nkind = N_Unconstrained_Array_Definition);
return Node4 (N);
end Component_Definition;
function Component_Items
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_List);
return List3 (N);
end Component_Items;
function Component_List
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_Variant);
return Node1 (N);
end Component_List;
function Component_Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
return Node1 (N);
end Component_Name;
function Componentwise_Assignment
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
return Flag14 (N);
end Componentwise_Assignment;
function Condition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative
or else NT (N).Nkind = N_Delay_Alternative
or else NT (N).Nkind = N_Elsif_Part
or else NT (N).Nkind = N_Entry_Body_Formal_Part
or else NT (N).Nkind = N_Exit_Statement
or else NT (N).Nkind = N_If_Statement
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression
or else NT (N).Nkind = N_Raise_Constraint_Error
or else NT (N).Nkind = N_Raise_Program_Error
or else NT (N).Nkind = N_Raise_Storage_Error
or else NT (N).Nkind = N_Terminate_Alternative);
return Node1 (N);
end Condition;
function Condition_Actions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Elsif_Part
or else NT (N).Nkind = N_Iteration_Scheme);
return List3 (N);
end Condition_Actions;
function Config_Pragmas
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit_Aux);
return List4 (N);
end Config_Pragmas;
function Constant_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Object_Declaration);
return Flag17 (N);
end Constant_Present;
function Constraint
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Indication);
return Node3 (N);
end Constraint;
function Constraints
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Index_Or_Discriminant_Constraint);
return List1 (N);
end Constraints;
function Context_Installed
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag13 (N);
end Context_Installed;
function Context_Items
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return List1 (N);
end Context_Items;
function Context_Pending
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Flag16 (N);
end Context_Pending;
function Contract_Test_Cases
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
return Node2 (N);
end Contract_Test_Cases;
function Controlling_Argument
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
return Node1 (N);
end Controlling_Argument;
function Conversion_OK
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Type_Conversion);
return Flag14 (N);
end Conversion_OK;
function Convert_To_Return_False
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Raise_Expression);
return Flag13 (N);
end Convert_To_Return_False;
function Corresponding_Aspect
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Node3 (N);
end Corresponding_Aspect;
function Corresponding_Body
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Subprogram_Declaration
or else NT (N).Nkind = N_Task_Body_Stub
or else NT (N).Nkind = N_Task_Type_Declaration);
return Node5 (N);
end Corresponding_Body;
function Corresponding_Formal_Spec
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
return Node3 (N);
end Corresponding_Formal_Spec;
function Corresponding_Generic_Association
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration);
return Node5 (N);
end Corresponding_Generic_Association;
function Corresponding_Integer_Value
(N : Node_Id) return Uint is
begin
pragma Assert (False
or else NT (N).Nkind = N_Real_Literal);
return Uint4 (N);
end Corresponding_Integer_Value;
function Corresponding_Spec
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Expression_Function
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration
or else NT (N).Nkind = N_Task_Body
or else NT (N).Nkind = N_With_Clause);
return Node5 (N);
end Corresponding_Spec;
function Corresponding_Spec_Of_Stub
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Task_Body_Stub);
return Node2 (N);
end Corresponding_Spec_Of_Stub;
function Corresponding_Stub
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subunit);
return Node3 (N);
end Corresponding_Stub;
function Dcheck_Function
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant);
return Node5 (N);
end Dcheck_Function;
function Declarations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Compilation_Unit_Aux
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
return List2 (N);
end Declarations;
function Default_Expression
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
return Node5 (N);
end Default_Expression;
function Default_Storage_Pool
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit_Aux);
return Node3 (N);
end Default_Storage_Pool;
function Default_Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration);
return Node2 (N);
end Default_Name;
function Defining_Identifier
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Defining_Program_Unit_Name
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Entry_Index_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Exception_Renaming_Declaration
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Formal_Type_Declaration
or else NT (N).Nkind = N_Full_Type_Declaration
or else NT (N).Nkind = N_Implicit_Label_Declaration
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Loop_Parameter_Specification
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Parameter_Specification
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Single_Protected_Declaration
or else NT (N).Nkind = N_Single_Task_Declaration
or else NT (N).Nkind = N_Subtype_Declaration
or else NT (N).Nkind = N_Task_Body
or else NT (N).Nkind = N_Task_Body_Stub
or else NT (N).Nkind = N_Task_Type_Declaration);
return Node1 (N);
end Defining_Identifier;
function Defining_Unit_Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Generic_Function_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Package_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Procedure_Renaming_Declaration
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Package_Renaming_Declaration
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Procedure_Specification);
return Node1 (N);
end Defining_Unit_Name;
function Delay_Alternative
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Timed_Entry_Call);
return Node4 (N);
end Delay_Alternative;
function Delay_Statement
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Delay_Alternative);
return Node2 (N);
end Delay_Statement;
function Delta_Expression
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Decimal_Fixed_Point_Definition
or else NT (N).Nkind = N_Delta_Constraint
or else NT (N).Nkind = N_Ordinary_Fixed_Point_Definition);
return Node3 (N);
end Delta_Expression;
function Digits_Expression
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Decimal_Fixed_Point_Definition
or else NT (N).Nkind = N_Digits_Constraint
or else NT (N).Nkind = N_Floating_Point_Definition);
return Node2 (N);
end Digits_Expression;
function Discr_Check_Funcs_Built
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Full_Type_Declaration);
return Flag11 (N);
end Discr_Check_Funcs_Built;
function Discrete_Choices
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Case_Statement_Alternative
or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Variant);
return List4 (N);
end Discrete_Choices;
function Discrete_Range
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Slice);
return Node4 (N);
end Discrete_Range;
function Discrete_Subtype_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Entry_Index_Specification
or else NT (N).Nkind = N_Loop_Parameter_Specification);
return Node4 (N);
end Discrete_Subtype_Definition;
function Discrete_Subtype_Definitions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Constrained_Array_Definition);
return List2 (N);
end Discrete_Subtype_Definitions;
function Discriminant_Specifications
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Type_Declaration
or else NT (N).Nkind = N_Full_Type_Declaration
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Task_Type_Declaration);
return List4 (N);
end Discriminant_Specifications;
function Discriminant_Type
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Discriminant_Specification);
return Node5 (N);
end Discriminant_Type;
function Do_Accessibility_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Specification);
return Flag13 (N);
end Do_Accessibility_Check;
function Do_Discriminant_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Selected_Component
or else NT (N).Nkind = N_Type_Conversion);
return Flag1 (N);
end Do_Discriminant_Check;
function Do_Division_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Divide
or else NT (N).Nkind = N_Op_Mod
or else NT (N).Nkind = N_Op_Rem);
return Flag13 (N);
end Do_Division_Check;
function Do_Length_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Op_And
or else NT (N).Nkind = N_Op_Or
or else NT (N).Nkind = N_Op_Xor
or else NT (N).Nkind = N_Type_Conversion);
return Flag4 (N);
end Do_Length_Check;
function Do_Overflow_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Op
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Case_Expression
or else NT (N).Nkind = N_If_Expression
or else NT (N).Nkind = N_Type_Conversion);
return Flag17 (N);
end Do_Overflow_Check;
function Do_Range_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
return Flag9 (N);
end Do_Range_Check;
function Do_Storage_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Subprogram_Body);
return Flag17 (N);
end Do_Storage_Check;
function Do_Tag_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement
or else NT (N).Nkind = N_Simple_Return_Statement
or else NT (N).Nkind = N_Type_Conversion);
return Flag13 (N);
end Do_Tag_Check;
function Elaborate_All_Desirable
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag9 (N);
end Elaborate_All_Desirable;
function Elaborate_All_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag14 (N);
end Elaborate_All_Present;
function Elaborate_Desirable
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag11 (N);
end Elaborate_Desirable;
function Elaborate_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag4 (N);
end Elaborate_Present;
function Else_Actions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Expression);
return List3 (N);
end Else_Actions;
function Else_Statements
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Conditional_Entry_Call
or else NT (N).Nkind = N_If_Statement
or else NT (N).Nkind = N_Selective_Accept);
return List4 (N);
end Else_Statements;
function Elsif_Parts
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Statement);
return List3 (N);
end Elsif_Parts;
function Enclosing_Variant
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant);
return Node2 (N);
end Enclosing_Variant;
function End_Label
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Enumeration_Type_Definition
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements
or else NT (N).Nkind = N_Loop_Statement
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Protected_Definition
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_Task_Definition);
return Node4 (N);
end End_Label;
function End_Span
(N : Node_Id) return Uint is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_If_Statement);
return Uint5 (N);
end End_Span;
function Entity
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Entity
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Freeze_Entity
or else NT (N).Nkind = N_Freeze_Generic_Entity);
return Node4 (N);
end Entity;
function Entity_Or_Associated_Node
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Entity
or else NT (N).Nkind = N_Freeze_Entity);
return Node4 (N);
end Entity_Or_Associated_Node;
function Entry_Body_Formal_Part
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Body);
return Node5 (N);
end Entry_Body_Formal_Part;
function Entry_Call_Alternative
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Conditional_Entry_Call
or else NT (N).Nkind = N_Timed_Entry_Call);
return Node1 (N);
end Entry_Call_Alternative;
function Entry_Call_Statement
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Call_Alternative);
return Node1 (N);
end Entry_Call_Statement;
function Entry_Direct_Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement);
return Node1 (N);
end Entry_Direct_Name;
function Entry_Index
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement);
return Node5 (N);
end Entry_Index;
function Entry_Index_Specification
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Body_Formal_Part);
return Node4 (N);
end Entry_Index_Specification;
function Etype
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Etype);
return Node5 (N);
end Etype;
function Exception_Choices
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
return List4 (N);
end Exception_Choices;
function Exception_Handlers
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements);
return List5 (N);
end Exception_Handlers;
function Exception_Junk
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Goto_Statement
or else NT (N).Nkind = N_Label
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Subtype_Declaration);
return Flag8 (N);
end Exception_Junk;
function Exception_Label
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler
or else NT (N).Nkind = N_Push_Constraint_Error_Label
or else NT (N).Nkind = N_Push_Program_Error_Label
or else NT (N).Nkind = N_Push_Storage_Error_Label);
return Node5 (N);
end Exception_Label;
function Expansion_Delayed
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
return Flag11 (N);
end Expansion_Delayed;
function Explicit_Actual_Parameter
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Association);
return Node3 (N);
end Explicit_Actual_Parameter;
function Explicit_Generic_Actual_Parameter
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Generic_Association);
return Node1 (N);
end Explicit_Generic_Actual_Parameter;
function Expression
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_At_Clause
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Case_Expression
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_Code_Statement
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Delay_Relative_Statement
or else NT (N).Nkind = N_Delay_Until_Statement
or else NT (N).Nkind = N_Delta_Aggregate
or else NT (N).Nkind = N_Discriminant_Association
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Expression_Function
or else NT (N).Nkind = N_Expression_With_Actions
or else NT (N).Nkind = N_Free_Statement
or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Mod_Clause
or else NT (N).Nkind = N_Modular_Type_Definition
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification
or else NT (N).Nkind = N_Pragma_Argument_Association
or else NT (N).Nkind = N_Qualified_Expression
or else NT (N).Nkind = N_Raise_Expression
or else NT (N).Nkind = N_Raise_Statement
or else NT (N).Nkind = N_Simple_Return_Statement
or else NT (N).Nkind = N_Type_Conversion
or else NT (N).Nkind = N_Unchecked_Expression
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
return Node3 (N);
end Expression;
function Expression_Copy
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma_Argument_Association);
return Node2 (N);
end Expression_Copy;
function Expressions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Extension_Aggregate
or else NT (N).Nkind = N_If_Expression
or else NT (N).Nkind = N_Indexed_Component);
return List1 (N);
end Expressions;
function First_Bit
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
return Node3 (N);
end First_Bit;
function First_Inlined_Subprogram
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Node3 (N);
end First_Inlined_Subprogram;
function First_Name
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag5 (N);
end First_Name;
function First_Named_Actual
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Call_Statement
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
return Node4 (N);
end First_Named_Actual;
function First_Real_Statement
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements);
return Node2 (N);
end First_Real_Statement;
function First_Subtype_Link
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Freeze_Entity);
return Node5 (N);
end First_Subtype_Link;
function Float_Truncate
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Type_Conversion);
return Flag11 (N);
end Float_Truncate;
function Formal_Type_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Type_Declaration);
return Node3 (N);
end Formal_Type_Definition;
function Forwards_OK
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
return Flag5 (N);
end Forwards_OK;
function From_Aspect_Specification
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Pragma);
return Flag13 (N);
end From_Aspect_Specification;
function From_At_End
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Raise_Statement);
return Flag4 (N);
end From_At_End;
function From_At_Mod
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause);
return Flag4 (N);
end From_At_Mod;
function From_Conditional_Expression
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_If_Statement);
return Flag1 (N);
end From_Conditional_Expression;
function From_Default
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
return Flag6 (N);
end From_Default;
function Generalized_Indexing
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Indexed_Component);
return Node4 (N);
end Generalized_Indexing;
function Generic_Associations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Procedure_Instantiation);
return List3 (N);
end Generic_Associations;
function Generic_Formal_Declarations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration);
return List2 (N);
end Generic_Formal_Declarations;
function Generic_Parent
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Procedure_Specification);
return Node5 (N);
end Generic_Parent;
function Generic_Parent_Type
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Declaration);
return Node4 (N);
end Generic_Parent_Type;
function Handled_Statement_Sequence
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
return Node4 (N);
end Handled_Statement_Sequence;
function Handler_List_Entry
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
return Node2 (N);
end Handler_List_Entry;
function Has_Created_Identifier
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Loop_Statement);
return Flag15 (N);
end Has_Created_Identifier;
function Has_Dereference_Action
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Explicit_Dereference);
return Flag13 (N);
end Has_Dereference_Action;
function Has_Dynamic_Length_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
return Flag10 (N);
end Has_Dynamic_Length_Check;
function Has_Dynamic_Range_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Declaration
or else NT (N).Nkind in N_Subexpr);
return Flag12 (N);
end Has_Dynamic_Range_Check;
function Has_Init_Expression
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
return Flag14 (N);
end Has_Init_Expression;
function Has_Local_Raise
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
return Flag8 (N);
end Has_Local_Raise;
function Has_No_Elaboration_Code
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Flag17 (N);
end Has_No_Elaboration_Code;
function Has_Pragma_Suppress_All
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Flag14 (N);
end Has_Pragma_Suppress_All;
function Has_Private_View
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Op
or else NT (N).Nkind = N_Character_Literal
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Identifier
or else NT (N).Nkind = N_Operator_Symbol);
return Flag11 (N);
end Has_Private_View;
function Has_Relative_Deadline_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Definition);
return Flag9 (N);
end Has_Relative_Deadline_Pragma;
function Has_Self_Reference
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
return Flag13 (N);
end Has_Self_Reference;
function Has_SP_Choice
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Case_Statement_Alternative
or else NT (N).Nkind = N_Variant);
return Flag15 (N);
end Has_SP_Choice;
function Has_Storage_Size_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Task_Definition);
return Flag5 (N);
end Has_Storage_Size_Pragma;
function Has_Target_Names
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
return Flag8 (N);
end Has_Target_Names;
function Has_Wide_Character
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_String_Literal);
return Flag11 (N);
end Has_Wide_Character;
function Has_Wide_Wide_Character
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_String_Literal);
return Flag13 (N);
end Has_Wide_Wide_Character;
function Header_Size_Added
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
return Flag11 (N);
end Header_Size_Added;
function Hidden_By_Use_Clause
(N : Node_Id) return Elist_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Use_Package_Clause
or else NT (N).Nkind = N_Use_Type_Clause);
return Elist4 (N);
end Hidden_By_Use_Clause;
function High_Bound
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range
or else NT (N).Nkind = N_Real_Range_Specification
or else NT (N).Nkind = N_Signed_Integer_Type_Definition);
return Node2 (N);
end High_Bound;
function Identifier
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_At_Clause
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Designator
or else NT (N).Nkind = N_Enumeration_Representation_Clause
or else NT (N).Nkind = N_Label
or else NT (N).Nkind = N_Loop_Statement
or else NT (N).Nkind = N_Record_Representation_Clause);
return Node1 (N);
end Identifier;
function Implicit_With
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag16 (N);
end Implicit_With;
function Implicit_With_From_Instantiation
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag12 (N);
end Implicit_With_From_Instantiation;
function Interface_List
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_Single_Protected_Declaration
or else NT (N).Nkind = N_Single_Task_Declaration
or else NT (N).Nkind = N_Task_Type_Declaration);
return List2 (N);
end Interface_List;
function Interface_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Record_Definition);
return Flag16 (N);
end Interface_Present;
function Import_Interface_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag16 (N);
end Import_Interface_Present;
function In_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
return Flag15 (N);
end In_Present;
function Includes_Infinities
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range);
return Flag11 (N);
end Includes_Infinities;
function Incomplete_View
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Full_Type_Declaration);
return Node2 (N);
end Incomplete_View;
function Inherited_Discriminant
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association);
return Flag13 (N);
end Inherited_Discriminant;
function Instance_Spec
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Procedure_Instantiation);
return Node5 (N);
end Instance_Spec;
function Intval
(N : Node_Id) return Uint is
begin
pragma Assert (False
or else NT (N).Nkind = N_Integer_Literal);
return Uint3 (N);
end Intval;
function Is_Abort_Block
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
return Flag4 (N);
end Is_Abort_Block;
function Is_Accessibility_Actual
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Association);
return Flag13 (N);
end Is_Accessibility_Actual;
function Is_Analyzed_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag5 (N);
end Is_Analyzed_Pragma;
function Is_Asynchronous_Call_Block
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
return Flag7 (N);
end Is_Asynchronous_Call_Block;
function Is_Boolean_Aspect
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
return Flag16 (N);
end Is_Boolean_Aspect;
function Is_Checked
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
return Flag11 (N);
end Is_Checked;
function Is_Checked_Ghost_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag3 (N);
end Is_Checked_Ghost_Pragma;
function Is_Component_Left_Opnd
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Concat);
return Flag13 (N);
end Is_Component_Left_Opnd;
function Is_Component_Right_Opnd
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Concat);
return Flag14 (N);
end Is_Component_Right_Opnd;
function Is_Controlling_Actual
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
return Flag16 (N);
end Is_Controlling_Actual;
function Is_Disabled
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
return Flag15 (N);
end Is_Disabled;
function Is_Delayed_Aspect
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Pragma);
return Flag14 (N);
end Is_Delayed_Aspect;
function Is_Dynamic_Coextension
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator);
return Flag18 (N);
end Is_Dynamic_Coextension;
function Is_Elsif
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Expression);
return Flag13 (N);
end Is_Elsif;
function Is_Entry_Barrier_Function
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Declaration);
return Flag8 (N);
end Is_Entry_Barrier_Function;
function Is_Expanded_Build_In_Place_Call
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call);
return Flag11 (N);
end Is_Expanded_Build_In_Place_Call;
function Is_Expanded_Contract
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
return Flag1 (N);
end Is_Expanded_Contract;
function Is_Finalization_Wrapper
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
return Flag9 (N);
end Is_Finalization_Wrapper;
function Is_Folded_In_Parser
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_String_Literal);
return Flag4 (N);
end Is_Folded_In_Parser;
function Is_Generic_Contract_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag2 (N);
end Is_Generic_Contract_Pragma;
function Is_Ignored
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
return Flag9 (N);
end Is_Ignored;
function Is_Ignored_Ghost_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag8 (N);
end Is_Ignored_Ghost_Pragma;
function Is_In_Discriminant_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Selected_Component);
return Flag11 (N);
end Is_In_Discriminant_Check;
function Is_Inherited_Pragma
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag4 (N);
end Is_Inherited_Pragma;
function Is_Machine_Number
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Real_Literal);
return Flag11 (N);
end Is_Machine_Number;
function Is_Null_Loop
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Loop_Statement);
return Flag16 (N);
end Is_Null_Loop;
function Is_Overloaded
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
return Flag5 (N);
end Is_Overloaded;
function Is_Power_Of_2_For_Shift
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Expon);
return Flag13 (N);
end Is_Power_Of_2_For_Shift;
function Is_Prefixed_Call
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Selected_Component);
return Flag17 (N);
end Is_Prefixed_Call;
function Is_Protected_Subprogram_Body
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body);
return Flag7 (N);
end Is_Protected_Subprogram_Body;
function Is_Qualified_Universal_Literal
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Qualified_Expression);
return Flag4 (N);
end Is_Qualified_Universal_Literal;
function Is_Static_Coextension
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator);
return Flag14 (N);
end Is_Static_Coextension;
function Is_Static_Expression
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
return Flag6 (N);
end Is_Static_Expression;
function Is_Subprogram_Descriptor
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
return Flag16 (N);
end Is_Subprogram_Descriptor;
function Is_Task_Allocation_Block
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
return Flag6 (N);
end Is_Task_Allocation_Block;
function Is_Task_Body_Procedure
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Declaration);
return Flag1 (N);
end Is_Task_Body_Procedure;
function Is_Task_Master
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
return Flag5 (N);
end Is_Task_Master;
function Iteration_Scheme
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Loop_Statement);
return Node2 (N);
end Iteration_Scheme;
function Iterator_Specification
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression);
return Node2 (N);
end Iterator_Specification;
function Itype
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Itype_Reference);
return Node1 (N);
end Itype;
function Kill_Range_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
return Flag11 (N);
end Kill_Range_Check;
function Label_Construct
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Implicit_Label_Declaration);
return Node2 (N);
end Label_Construct;
function Last_Bit
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
return Node4 (N);
end Last_Bit;
function Last_Name
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag6 (N);
end Last_Name;
function Left_Opnd
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In
or else NT (N).Nkind = N_Or_Else
or else NT (N).Nkind in N_Binary_Op);
return Node2 (N);
end Left_Opnd;
function Library_Unit
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Task_Body_Stub
or else NT (N).Nkind = N_With_Clause);
return Node4 (N);
end Library_Unit;
function Limited_View_Installed
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_With_Clause);
return Flag18 (N);
end Limited_View_Installed;
function Limited_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_With_Clause);
return Flag17 (N);
end Limited_Present;
function Literals
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Enumeration_Type_Definition);
return List1 (N);
end Literals;
function Local_Raise_Not_OK
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
return Flag7 (N);
end Local_Raise_Not_OK;
function Local_Raise_Statements
(N : Node_Id) return Elist_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
return Elist1 (N);
end Local_Raise_Statements;
function Loop_Actions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Iterated_Component_Association);
return List2 (N);
end Loop_Actions;
function Loop_Parameter_Specification
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression);
return Node4 (N);
end Loop_Parameter_Specification;
function Low_Bound
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range
or else NT (N).Nkind = N_Real_Range_Specification
or else NT (N).Nkind = N_Signed_Integer_Type_Definition);
return Node1 (N);
end Low_Bound;
function Mod_Clause
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Record_Representation_Clause);
return Node2 (N);
end Mod_Clause;
function More_Ids
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
return Flag5 (N);
end More_Ids;
function Must_Be_Byte_Aligned
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
return Flag14 (N);
end Must_Be_Byte_Aligned;
function Must_Not_Freeze
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Indication
or else NT (N).Nkind in N_Subexpr);
return Flag8 (N);
end Must_Not_Freeze;
function Must_Not_Override
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Procedure_Specification);
return Flag15 (N);
end Must_Not_Override;
function Must_Override
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Procedure_Specification);
return Flag14 (N);
end Must_Override;
function Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Defining_Program_Unit_Name
or else NT (N).Nkind = N_Designator
or else NT (N).Nkind = N_Entry_Call_Statement
or else NT (N).Nkind = N_Exception_Renaming_Declaration
or else NT (N).Nkind = N_Exit_Statement
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Generic_Function_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Package_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Procedure_Renaming_Declaration
or else NT (N).Nkind = N_Goto_Statement
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Package_Renaming_Declaration
or else NT (N).Nkind = N_Procedure_Call_Statement
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Raise_Expression
or else NT (N).Nkind = N_Raise_Statement
or else NT (N).Nkind = N_Requeue_Statement
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration
or else NT (N).Nkind = N_Subunit
or else NT (N).Nkind = N_Variant_Part
or else NT (N).Nkind = N_With_Clause);
return Node2 (N);
end Name;
function Names
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Abort_Statement
or else NT (N).Nkind = N_Use_Package_Clause);
return List2 (N);
end Names;
function Next_Entity
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Defining_Character_Literal
or else NT (N).Nkind = N_Defining_Identifier
or else NT (N).Nkind = N_Defining_Operator_Symbol);
return Node2 (N);
end Next_Entity;
function Next_Exit_Statement
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exit_Statement);
return Node3 (N);
end Next_Exit_Statement;
function Next_Implicit_With
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Node3 (N);
end Next_Implicit_With;
function Next_Named_Actual
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Association);
return Node4 (N);
end Next_Named_Actual;
function Next_Pragma
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Node1 (N);
end Next_Pragma;
function Next_Rep_Item
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Enumeration_Representation_Clause
or else NT (N).Nkind = N_Pragma
or else NT (N).Nkind = N_Record_Representation_Clause);
return Node5 (N);
end Next_Rep_Item;
function Next_Use_Clause
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Use_Package_Clause
or else NT (N).Nkind = N_Use_Type_Clause);
return Node3 (N);
end Next_Use_Clause;
function No_Ctrl_Actions
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
return Flag7 (N);
end No_Ctrl_Actions;
function No_Elaboration_Check
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
return Flag14 (N);
end No_Elaboration_Check;
function No_Entities_Ref_In_Spec
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag8 (N);
end No_Entities_Ref_In_Spec;
function No_Initialization
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Object_Declaration);
return Flag13 (N);
end No_Initialization;
function No_Minimize_Eliminate
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In);
return Flag17 (N);
end No_Minimize_Eliminate;
function No_Side_Effect_Removal
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call);
return Flag1 (N);
end No_Side_Effect_Removal;
function No_Truncation
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
return Flag17 (N);
end No_Truncation;
function Non_Aliased_Prefix
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
return Flag18 (N);
end Non_Aliased_Prefix;
function Null_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_List
or else NT (N).Nkind = N_Procedure_Specification
or else NT (N).Nkind = N_Record_Definition);
return Flag13 (N);
end Null_Present;
function Null_Excluding_Subtype
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_To_Object_Definition);
return Flag16 (N);
end Null_Excluding_Subtype;
function Null_Exclusion_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Access_Procedure_Definition
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Parameter_Specification
or else NT (N).Nkind = N_Subtype_Declaration);
return Flag11 (N);
end Null_Exclusion_Present;
function Null_Exclusion_In_Return_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Function_Definition);
return Flag14 (N);
end Null_Exclusion_In_Return_Present;
function Null_Record_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
return Flag17 (N);
end Null_Record_Present;
function Object_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
return Node4 (N);
end Object_Definition;
function Of_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iterator_Specification);
return Flag16 (N);
end Of_Present;
function Original_Discriminant
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Identifier);
return Node2 (N);
end Original_Discriminant;
function Original_Entity
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Integer_Literal
or else NT (N).Nkind = N_Real_Literal);
return Node2 (N);
end Original_Entity;
function Others_Discrete_Choices
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Others_Choice);
return List1 (N);
end Others_Discrete_Choices;
function Out_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
return Flag17 (N);
end Out_Present;
function Parameter_Associations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Call_Statement
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
return List3 (N);
end Parameter_Associations;
function Parameter_Specifications
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Access_Procedure_Definition
or else NT (N).Nkind = N_Entry_Body_Formal_Part
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Procedure_Specification);
return List3 (N);
end Parameter_Specifications;
function Parameter_Type
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Specification);
return Node2 (N);
end Parameter_Type;
function Parent_Spec
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Generic_Function_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Package_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Procedure_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Package_Renaming_Declaration
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Subprogram_Declaration
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
return Node4 (N);
end Parent_Spec;
function Position
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
return Node2 (N);
end Position;
function Pragma_Argument_Associations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return List2 (N);
end Pragma_Argument_Associations;
function Pragma_Identifier
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Node4 (N);
end Pragma_Identifier;
function Pragmas_After
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit_Aux
or else NT (N).Nkind = N_Terminate_Alternative);
return List5 (N);
end Pragmas_After;
function Pragmas_Before
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative
or else NT (N).Nkind = N_Delay_Alternative
or else NT (N).Nkind = N_Entry_Call_Alternative
or else NT (N).Nkind = N_Mod_Clause
or else NT (N).Nkind = N_Terminate_Alternative
or else NT (N).Nkind = N_Triggering_Alternative);
return List4 (N);
end Pragmas_Before;
function Pre_Post_Conditions
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
return Node1 (N);
end Pre_Post_Conditions;
function Prefix
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Explicit_Dereference
or else NT (N).Nkind = N_Indexed_Component
or else NT (N).Nkind = N_Reference
or else NT (N).Nkind = N_Selected_Component
or else NT (N).Nkind = N_Slice);
return Node3 (N);
end Prefix;
function Premature_Use
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Incomplete_Type_Declaration);
return Node5 (N);
end Premature_Use;
function Present_Expr
(N : Node_Id) return Uint is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant);
return Uint3 (N);
end Present_Expr;
function Prev_Ids
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
return Flag6 (N);
end Prev_Ids;
function Print_In_Hex
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Integer_Literal);
return Flag13 (N);
end Print_In_Hex;
function Private_Declarations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Protected_Definition
or else NT (N).Nkind = N_Task_Definition);
return List3 (N);
end Private_Declarations;
function Private_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_With_Clause);
return Flag15 (N);
end Private_Present;
function Procedure_To_Call
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Free_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
return Node2 (N);
end Procedure_To_Call;
function Proper_Body
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subunit);
return Node1 (N);
end Proper_Body;
function Protected_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Single_Protected_Declaration);
return Node3 (N);
end Protected_Definition;
function Protected_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Access_Procedure_Definition
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Record_Definition);
return Flag6 (N);
end Protected_Present;
function Raises_Constraint_Error
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
return Flag7 (N);
end Raises_Constraint_Error;
function Range_Constraint
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Delta_Constraint
or else NT (N).Nkind = N_Digits_Constraint);
return Node4 (N);
end Range_Constraint;
function Range_Expression
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range_Constraint);
return Node4 (N);
end Range_Expression;
function Real_Range_Specification
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Decimal_Fixed_Point_Definition
or else NT (N).Nkind = N_Floating_Point_Definition
or else NT (N).Nkind = N_Ordinary_Fixed_Point_Definition);
return Node4 (N);
end Real_Range_Specification;
function Realval
(N : Node_Id) return Ureal is
begin
pragma Assert (False
or else NT (N).Nkind = N_Real_Literal);
return Ureal3 (N);
end Realval;
function Reason
(N : Node_Id) return Uint is
begin
pragma Assert (False
or else NT (N).Nkind = N_Raise_Constraint_Error
or else NT (N).Nkind = N_Raise_Program_Error
or else NT (N).Nkind = N_Raise_Storage_Error);
return Uint3 (N);
end Reason;
function Record_Extension_Part
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition);
return Node3 (N);
end Record_Extension_Part;
function Redundant_Use
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Identifier);
return Flag13 (N);
end Redundant_Use;
function Renaming_Exception
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Declaration);
return Node2 (N);
end Renaming_Exception;
function Result_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Function_Specification);
return Node4 (N);
end Result_Definition;
function Return_Object_Declarations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extended_Return_Statement);
return List3 (N);
end Return_Object_Declarations;
function Return_Statement_Entity
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
return Node5 (N);
end Return_Statement_Entity;
function Reverse_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Loop_Parameter_Specification);
return Flag15 (N);
end Reverse_Present;
function Right_Opnd
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind in N_Op
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In
or else NT (N).Nkind = N_Or_Else);
return Node3 (N);
end Right_Opnd;
function Rounded_Result
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Divide
or else NT (N).Nkind = N_Op_Multiply
or else NT (N).Nkind = N_Type_Conversion);
return Flag18 (N);
end Rounded_Result;
function SCIL_Controlling_Tag
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Dispatching_Call);
return Node5 (N);
end SCIL_Controlling_Tag;
function SCIL_Entity
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Dispatch_Table_Tag_Init
or else NT (N).Nkind = N_SCIL_Dispatching_Call
or else NT (N).Nkind = N_SCIL_Membership_Test);
return Node4 (N);
end SCIL_Entity;
function SCIL_Tag_Value
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Membership_Test);
return Node5 (N);
end SCIL_Tag_Value;
function SCIL_Target_Prim
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Dispatching_Call);
return Node2 (N);
end SCIL_Target_Prim;
function Scope
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Defining_Character_Literal
or else NT (N).Nkind = N_Defining_Identifier
or else NT (N).Nkind = N_Defining_Operator_Symbol);
return Node3 (N);
end Scope;
function Select_Alternatives
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Selective_Accept);
return List1 (N);
end Select_Alternatives;
function Selector_Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Generic_Association
or else NT (N).Nkind = N_Parameter_Association
or else NT (N).Nkind = N_Selected_Component);
return Node2 (N);
end Selector_Name;
function Selector_Names
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Discriminant_Association);
return List1 (N);
end Selector_Names;
function Shift_Count_OK
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Rotate_Left
or else NT (N).Nkind = N_Op_Rotate_Right
or else NT (N).Nkind = N_Op_Shift_Left
or else NT (N).Nkind = N_Op_Shift_Right
or else NT (N).Nkind = N_Op_Shift_Right_Arithmetic);
return Flag4 (N);
end Shift_Count_OK;
function Source_Type
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Validate_Unchecked_Conversion);
return Node1 (N);
end Source_Type;
function Specification
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Expression_Function
or else NT (N).Nkind = N_Formal_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Subprogram_Declaration
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
return Node1 (N);
end Specification;
function Split_PPC
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
return Flag17 (N);
end Split_PPC;
function Statements
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Abortable_Part
or else NT (N).Nkind = N_Accept_Alternative
or else NT (N).Nkind = N_Case_Statement_Alternative
or else NT (N).Nkind = N_Delay_Alternative
or else NT (N).Nkind = N_Entry_Call_Alternative
or else NT (N).Nkind = N_Exception_Handler
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements
or else NT (N).Nkind = N_Loop_Statement
or else NT (N).Nkind = N_Triggering_Alternative);
return List3 (N);
end Statements;
function Storage_Pool
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Free_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
return Node1 (N);
end Storage_Pool;
function Subpool_Handle_Name
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator);
return Node4 (N);
end Subpool_Handle_Name;
function Strval
(N : Node_Id) return String_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Operator_Symbol
or else NT (N).Nkind = N_String_Literal);
return Str3 (N);
end Strval;
function Subtype_Indication
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Subtype_Declaration);
return Node5 (N);
end Subtype_Indication;
function Suppress_Assignment_Checks
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Object_Declaration);
return Flag18 (N);
end Suppress_Assignment_Checks;
function Suppress_Loop_Warnings
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Loop_Statement);
return Flag17 (N);
end Suppress_Loop_Warnings;
function Subtype_Mark
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Qualified_Expression
or else NT (N).Nkind = N_Subtype_Indication
or else NT (N).Nkind = N_Type_Conversion
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
return Node4 (N);
end Subtype_Mark;
function Subtype_Marks
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Unconstrained_Array_Definition
or else NT (N).Nkind = N_Use_Type_Clause);
return List2 (N);
end Subtype_Marks;
function Synchronized_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Record_Definition);
return Flag7 (N);
end Synchronized_Present;
function Tagged_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Incomplete_Type_Definition
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Record_Definition);
return Flag15 (N);
end Tagged_Present;
function Target_Type
(N : Node_Id) return Entity_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Validate_Unchecked_Conversion);
return Node2 (N);
end Target_Type;
function Task_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Single_Task_Declaration
or else NT (N).Nkind = N_Task_Type_Declaration);
return Node3 (N);
end Task_Definition;
function Task_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Record_Definition);
return Flag5 (N);
end Task_Present;
function Then_Actions
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Expression);
return List2 (N);
end Then_Actions;
function Then_Statements
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Elsif_Part
or else NT (N).Nkind = N_If_Statement);
return List2 (N);
end Then_Statements;
function Treat_Fixed_As_Integer
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Divide
or else NT (N).Nkind = N_Op_Mod
or else NT (N).Nkind = N_Op_Multiply
or else NT (N).Nkind = N_Op_Rem);
return Flag14 (N);
end Treat_Fixed_As_Integer;
function Triggering_Alternative
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Asynchronous_Select);
return Node1 (N);
end Triggering_Alternative;
function Triggering_Statement
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Triggering_Alternative);
return Node1 (N);
end Triggering_Statement;
function TSS_Elist
(N : Node_Id) return Elist_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Freeze_Entity);
return Elist3 (N);
end TSS_Elist;
function Type_Definition
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Full_Type_Declaration);
return Node3 (N);
end Type_Definition;
function Uneval_Old_Accept
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag7 (N);
end Uneval_Old_Accept;
function Uneval_Old_Warn
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag18 (N);
end Uneval_Old_Warn;
function Unit
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
return Node2 (N);
end Unit;
function Unknown_Discriminants_Present
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Type_Declaration
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration);
return Flag13 (N);
end Unknown_Discriminants_Present;
function Unreferenced_In_Spec
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Flag7 (N);
end Unreferenced_In_Spec;
function Variant_Part
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_List);
return Node4 (N);
end Variant_Part;
function Variants
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant_Part);
return List1 (N);
end Variants;
function Visible_Declarations
(N : Node_Id) return List_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Protected_Definition
or else NT (N).Nkind = N_Task_Definition);
return List2 (N);
end Visible_Declarations;
function Uninitialized_Variable
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration);
return Node3 (N);
end Uninitialized_Variable;
function Used_Operations
(N : Node_Id) return Elist_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_Use_Type_Clause);
return Elist5 (N);
end Used_Operations;
function Was_Expression_Function
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body);
return Flag18 (N);
end Was_Expression_Function;
function Was_Originally_Stub
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
return Flag13 (N);
end Was_Originally_Stub;
function Withed_Body
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
return Node1 (N);
end Withed_Body;
--------------------------
-- Field Set Procedures --
--------------------------
procedure Set_ABE_Is_Certain
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Procedure_Call_Statement
or else NT (N).Nkind = N_Procedure_Instantiation);
Set_Flag18 (N, Val);
end Set_ABE_Is_Certain;
procedure Set_Abort_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Requeue_Statement);
Set_Flag15 (N, Val);
end Set_Abort_Present;
procedure Set_Abortable_Part
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Asynchronous_Select);
Set_Node2_With_Parent (N, Val);
end Set_Abortable_Part;
procedure Set_Abstract_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Record_Definition);
Set_Flag4 (N, Val);
end Set_Abstract_Present;
procedure Set_Accept_Handler_Records
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative);
Set_List5 (N, Val); -- semantic field, no parent set
end Set_Accept_Handler_Records;
procedure Set_Accept_Statement
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative);
Set_Node2_With_Parent (N, Val);
end Set_Accept_Statement;
procedure Set_Access_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration);
Set_Node3_With_Parent (N, Val);
end Set_Access_Definition;
procedure Set_Access_To_Subprogram_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition);
Set_Node3_With_Parent (N, Val);
end Set_Access_To_Subprogram_Definition;
procedure Set_Access_Types_To_Process
(N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Freeze_Entity);
Set_Elist2 (N, Val); -- semantic field, no parent set
end Set_Access_Types_To_Process;
procedure Set_Actions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Compilation_Unit_Aux
or else NT (N).Nkind = N_Compound_Statement
or else NT (N).Nkind = N_Expression_With_Actions
or else NT (N).Nkind = N_Freeze_Entity
or else NT (N).Nkind = N_Or_Else);
Set_List1_With_Parent (N, Val);
end Set_Actions;
procedure Set_Activation_Chain_Entity
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Activation_Chain_Entity;
procedure Set_Acts_As_Spec
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit
or else NT (N).Nkind = N_Subprogram_Body);
Set_Flag4 (N, Val);
end Set_Acts_As_Spec;
procedure Set_Actual_Designated_Subtype
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Explicit_Dereference
or else NT (N).Nkind = N_Free_Statement);
Set_Node4 (N, Val);
end Set_Actual_Designated_Subtype;
procedure Set_Address_Warning_Posted
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause);
Set_Flag18 (N, Val);
end Set_Address_Warning_Posted;
procedure Set_Aggregate_Bounds
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Aggregate_Bounds;
procedure Set_Aliased_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
Set_Flag4 (N, Val);
end Set_Aliased_Present;
procedure Set_All_Others
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Others_Choice);
Set_Flag11 (N, Val);
end Set_All_Others;
procedure Set_All_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Quantified_Expression
or else NT (N).Nkind = N_Use_Type_Clause);
Set_Flag15 (N, Val);
end Set_All_Present;
procedure Set_Alternatives
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Expression
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In);
Set_List4_With_Parent (N, Val);
end Set_Alternatives;
procedure Set_Ancestor_Part
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extension_Aggregate);
Set_Node3_With_Parent (N, Val);
end Set_Ancestor_Part;
procedure Set_Atomic_Sync_Required
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Explicit_Dereference
or else NT (N).Nkind = N_Identifier
or else NT (N).Nkind = N_Indexed_Component
or else NT (N).Nkind = N_Selected_Component);
Set_Flag14 (N, Val);
end Set_Atomic_Sync_Required;
procedure Set_Array_Aggregate
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Enumeration_Representation_Clause);
Set_Node3_With_Parent (N, Val);
end Set_Array_Aggregate;
procedure Set_Aspect_Rep_Item
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
Set_Node2 (N, Val);
end Set_Aspect_Rep_Item;
procedure Set_Assignment_OK
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind in N_Subexpr);
Set_Flag15 (N, Val);
end Set_Assignment_OK;
procedure Set_Associated_Node
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Entity
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate
or else NT (N).Nkind = N_Selected_Component);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_Associated_Node;
procedure Set_At_End_Proc
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements);
Set_Node1 (N, Val);
end Set_At_End_Proc;
procedure Set_Attribute_Name
(N : Node_Id; Val : Name_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
Set_Name2 (N, Val);
end Set_Attribute_Name;
procedure Set_Aux_Decls_Node
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Node5_With_Parent (N, Val);
end Set_Aux_Decls_Node;
procedure Set_Backwards_OK
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
Set_Flag6 (N, Val);
end Set_Backwards_OK;
procedure Set_Bad_Is_Detected
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body);
Set_Flag15 (N, Val);
end Set_Bad_Is_Detected;
procedure Set_Body_Required
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Flag13 (N, Val);
end Set_Body_Required;
procedure Set_Body_To_Inline
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Declaration);
Set_Node3 (N, Val);
end Set_Body_To_Inline;
procedure Set_Box_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Formal_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Generic_Association
or else NT (N).Nkind = N_Iterated_Component_Association);
Set_Flag15 (N, Val);
end Set_Box_Present;
procedure Set_By_Ref
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
Set_Flag5 (N, Val);
end Set_By_Ref;
procedure Set_Char_Literal_Value
(N : Node_Id; Val : Uint) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Character_Literal);
Set_Uint2 (N, Val);
end Set_Char_Literal_Value;
procedure Set_Chars
(N : Node_Id; Val : Name_Id) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Chars);
Set_Name1 (N, Val);
end Set_Chars;
procedure Set_Check_Address_Alignment
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause);
Set_Flag11 (N, Val);
end Set_Check_Address_Alignment;
procedure Set_Choice_Parameter
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
Set_Node2_With_Parent (N, Val);
end Set_Choice_Parameter;
procedure Set_Choices
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association);
Set_List1_With_Parent (N, Val);
end Set_Choices;
procedure Set_Class_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
Set_Flag6 (N, Val);
end Set_Class_Present;
procedure Set_Classifications
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Classifications;
procedure Set_Cleanup_Actions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
Set_List5 (N, Val); -- semantic field, no parent set
end Set_Cleanup_Actions;
procedure Set_Comes_From_Extended_Return_Statement
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Simple_Return_Statement);
Set_Flag18 (N, Val);
end Set_Comes_From_Extended_Return_Statement;
procedure Set_Compile_Time_Known_Aggregate
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate);
Set_Flag18 (N, Val);
end Set_Compile_Time_Known_Aggregate;
procedure Set_Component_Associations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Delta_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
Set_List2_With_Parent (N, Val);
end Set_Component_Associations;
procedure Set_Component_Clauses
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Record_Representation_Clause);
Set_List3_With_Parent (N, Val);
end Set_Component_Clauses;
procedure Set_Component_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Constrained_Array_Definition
or else NT (N).Nkind = N_Unconstrained_Array_Definition);
Set_Node4_With_Parent (N, Val);
end Set_Component_Definition;
procedure Set_Component_Items
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_List);
Set_List3_With_Parent (N, Val);
end Set_Component_Items;
procedure Set_Component_List
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_Variant);
Set_Node1_With_Parent (N, Val);
end Set_Component_List;
procedure Set_Component_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
Set_Node1_With_Parent (N, Val);
end Set_Component_Name;
procedure Set_Componentwise_Assignment
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
Set_Flag14 (N, Val);
end Set_Componentwise_Assignment;
procedure Set_Condition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative
or else NT (N).Nkind = N_Delay_Alternative
or else NT (N).Nkind = N_Elsif_Part
or else NT (N).Nkind = N_Entry_Body_Formal_Part
or else NT (N).Nkind = N_Exit_Statement
or else NT (N).Nkind = N_If_Statement
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression
or else NT (N).Nkind = N_Raise_Constraint_Error
or else NT (N).Nkind = N_Raise_Program_Error
or else NT (N).Nkind = N_Raise_Storage_Error
or else NT (N).Nkind = N_Terminate_Alternative);
Set_Node1_With_Parent (N, Val);
end Set_Condition;
procedure Set_Condition_Actions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Elsif_Part
or else NT (N).Nkind = N_Iteration_Scheme);
Set_List3 (N, Val); -- semantic field, no parent set
end Set_Condition_Actions;
procedure Set_Config_Pragmas
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit_Aux);
Set_List4_With_Parent (N, Val);
end Set_Config_Pragmas;
procedure Set_Constant_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Object_Declaration);
Set_Flag17 (N, Val);
end Set_Constant_Present;
procedure Set_Constraint
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Indication);
Set_Node3_With_Parent (N, Val);
end Set_Constraint;
procedure Set_Constraints
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Index_Or_Discriminant_Constraint);
Set_List1_With_Parent (N, Val);
end Set_Constraints;
procedure Set_Context_Installed
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag13 (N, Val);
end Set_Context_Installed;
procedure Set_Context_Items
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_List1_With_Parent (N, Val);
end Set_Context_Items;
procedure Set_Context_Pending
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Flag16 (N, Val);
end Set_Context_Pending;
procedure Set_Contract_Test_Cases
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Contract_Test_Cases;
procedure Set_Controlling_Argument
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
Set_Node1 (N, Val); -- semantic field, no parent set
end Set_Controlling_Argument;
procedure Set_Conversion_OK
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag14 (N, Val);
end Set_Conversion_OK;
procedure Set_Convert_To_Return_False
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Raise_Expression);
Set_Flag13 (N, Val);
end Set_Convert_To_Return_False;
procedure Set_Corresponding_Aspect
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Node3 (N, Val);
end Set_Corresponding_Aspect;
procedure Set_Corresponding_Body
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Subprogram_Declaration
or else NT (N).Nkind = N_Task_Body_Stub
or else NT (N).Nkind = N_Task_Type_Declaration);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Corresponding_Body;
procedure Set_Corresponding_Formal_Spec
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Corresponding_Formal_Spec;
procedure Set_Corresponding_Generic_Association
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Corresponding_Generic_Association;
procedure Set_Corresponding_Integer_Value
(N : Node_Id; Val : Uint) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Real_Literal);
Set_Uint4 (N, Val); -- semantic field, no parent set
end Set_Corresponding_Integer_Value;
procedure Set_Corresponding_Spec
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Expression_Function
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration
or else NT (N).Nkind = N_Task_Body
or else NT (N).Nkind = N_With_Clause);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Corresponding_Spec;
procedure Set_Corresponding_Spec_Of_Stub
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Task_Body_Stub);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Corresponding_Spec_Of_Stub;
procedure Set_Corresponding_Stub
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subunit);
Set_Node3 (N, Val);
end Set_Corresponding_Stub;
procedure Set_Dcheck_Function
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Dcheck_Function;
procedure Set_Declarations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Compilation_Unit_Aux
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
Set_List2_With_Parent (N, Val);
end Set_Declarations;
procedure Set_Default_Expression
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Default_Expression;
procedure Set_Default_Storage_Pool
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit_Aux);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Default_Storage_Pool;
procedure Set_Default_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration);
Set_Node2_With_Parent (N, Val);
end Set_Default_Name;
procedure Set_Defining_Identifier
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Defining_Program_Unit_Name
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Entry_Index_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Exception_Renaming_Declaration
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Formal_Type_Declaration
or else NT (N).Nkind = N_Full_Type_Declaration
or else NT (N).Nkind = N_Implicit_Label_Declaration
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Loop_Parameter_Specification
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Parameter_Specification
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Single_Protected_Declaration
or else NT (N).Nkind = N_Single_Task_Declaration
or else NT (N).Nkind = N_Subtype_Declaration
or else NT (N).Nkind = N_Task_Body
or else NT (N).Nkind = N_Task_Body_Stub
or else NT (N).Nkind = N_Task_Type_Declaration);
Set_Node1_With_Parent (N, Val);
end Set_Defining_Identifier;
procedure Set_Defining_Unit_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Generic_Function_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Package_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Procedure_Renaming_Declaration
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Package_Renaming_Declaration
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Procedure_Specification);
Set_Node1_With_Parent (N, Val);
end Set_Defining_Unit_Name;
procedure Set_Delay_Alternative
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Timed_Entry_Call);
Set_Node4_With_Parent (N, Val);
end Set_Delay_Alternative;
procedure Set_Delay_Statement
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Delay_Alternative);
Set_Node2_With_Parent (N, Val);
end Set_Delay_Statement;
procedure Set_Delta_Expression
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Decimal_Fixed_Point_Definition
or else NT (N).Nkind = N_Delta_Constraint
or else NT (N).Nkind = N_Ordinary_Fixed_Point_Definition);
Set_Node3_With_Parent (N, Val);
end Set_Delta_Expression;
procedure Set_Digits_Expression
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Decimal_Fixed_Point_Definition
or else NT (N).Nkind = N_Digits_Constraint
or else NT (N).Nkind = N_Floating_Point_Definition);
Set_Node2_With_Parent (N, Val);
end Set_Digits_Expression;
procedure Set_Discr_Check_Funcs_Built
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Full_Type_Declaration);
Set_Flag11 (N, Val);
end Set_Discr_Check_Funcs_Built;
procedure Set_Discrete_Choices
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Case_Statement_Alternative
or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Variant);
Set_List4_With_Parent (N, Val);
end Set_Discrete_Choices;
procedure Set_Discrete_Range
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Slice);
Set_Node4_With_Parent (N, Val);
end Set_Discrete_Range;
procedure Set_Discrete_Subtype_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Entry_Index_Specification
or else NT (N).Nkind = N_Loop_Parameter_Specification);
Set_Node4_With_Parent (N, Val);
end Set_Discrete_Subtype_Definition;
procedure Set_Discrete_Subtype_Definitions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Constrained_Array_Definition);
Set_List2_With_Parent (N, Val);
end Set_Discrete_Subtype_Definitions;
procedure Set_Discriminant_Specifications
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Type_Declaration
or else NT (N).Nkind = N_Full_Type_Declaration
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Task_Type_Declaration);
Set_List4_With_Parent (N, Val);
end Set_Discriminant_Specifications;
procedure Set_Discriminant_Type
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Discriminant_Specification);
Set_Node5_With_Parent (N, Val);
end Set_Discriminant_Type;
procedure Set_Do_Accessibility_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Specification);
Set_Flag13 (N, Val);
end Set_Do_Accessibility_Check;
procedure Set_Do_Discriminant_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Selected_Component
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag1 (N, Val);
end Set_Do_Discriminant_Check;
procedure Set_Do_Division_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Divide
or else NT (N).Nkind = N_Op_Mod
or else NT (N).Nkind = N_Op_Rem);
Set_Flag13 (N, Val);
end Set_Do_Division_Check;
procedure Set_Do_Length_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Op_And
or else NT (N).Nkind = N_Op_Or
or else NT (N).Nkind = N_Op_Xor
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag4 (N, Val);
end Set_Do_Length_Check;
procedure Set_Do_Overflow_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Op
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Case_Expression
or else NT (N).Nkind = N_If_Expression
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag17 (N, Val);
end Set_Do_Overflow_Check;
procedure Set_Do_Range_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
Set_Flag9 (N, Val);
end Set_Do_Range_Check;
procedure Set_Do_Storage_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Subprogram_Body);
Set_Flag17 (N, Val);
end Set_Do_Storage_Check;
procedure Set_Do_Tag_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement
or else NT (N).Nkind = N_Simple_Return_Statement
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag13 (N, Val);
end Set_Do_Tag_Check;
procedure Set_Elaborate_All_Desirable
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag9 (N, Val);
end Set_Elaborate_All_Desirable;
procedure Set_Elaborate_All_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag14 (N, Val);
end Set_Elaborate_All_Present;
procedure Set_Elaborate_Desirable
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag11 (N, Val);
end Set_Elaborate_Desirable;
procedure Set_Elaborate_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag4 (N, Val);
end Set_Elaborate_Present;
procedure Set_Else_Actions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Expression);
Set_List3_With_Parent (N, Val); -- semantic field, but needs parents
end Set_Else_Actions;
procedure Set_Else_Statements
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Conditional_Entry_Call
or else NT (N).Nkind = N_If_Statement
or else NT (N).Nkind = N_Selective_Accept);
Set_List4_With_Parent (N, Val);
end Set_Else_Statements;
procedure Set_Elsif_Parts
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Statement);
Set_List3_With_Parent (N, Val);
end Set_Elsif_Parts;
procedure Set_Enclosing_Variant
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Enclosing_Variant;
procedure Set_End_Label
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Enumeration_Type_Definition
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements
or else NT (N).Nkind = N_Loop_Statement
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Protected_Definition
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_Task_Definition);
Set_Node4_With_Parent (N, Val);
end Set_End_Label;
procedure Set_End_Span
(N : Node_Id; Val : Uint) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_If_Statement);
Set_Uint5 (N, Val);
end Set_End_Span;
procedure Set_Entity
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Entity
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Freeze_Entity
or else NT (N).Nkind = N_Freeze_Generic_Entity);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_Entity;
procedure Set_Entry_Body_Formal_Part
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Body);
Set_Node5_With_Parent (N, Val);
end Set_Entry_Body_Formal_Part;
procedure Set_Entry_Call_Alternative
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Conditional_Entry_Call
or else NT (N).Nkind = N_Timed_Entry_Call);
Set_Node1_With_Parent (N, Val);
end Set_Entry_Call_Alternative;
procedure Set_Entry_Call_Statement
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Call_Alternative);
Set_Node1_With_Parent (N, Val);
end Set_Entry_Call_Statement;
procedure Set_Entry_Direct_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement);
Set_Node1_With_Parent (N, Val);
end Set_Entry_Direct_Name;
procedure Set_Entry_Index
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement);
Set_Node5_With_Parent (N, Val);
end Set_Entry_Index;
procedure Set_Entry_Index_Specification
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Body_Formal_Part);
Set_Node4_With_Parent (N, Val);
end Set_Entry_Index_Specification;
procedure Set_Etype
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Has_Etype);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Etype;
procedure Set_Exception_Choices
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
Set_List4_With_Parent (N, Val);
end Set_Exception_Choices;
procedure Set_Exception_Handlers
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements);
Set_List5_With_Parent (N, Val);
end Set_Exception_Handlers;
procedure Set_Exception_Junk
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Goto_Statement
or else NT (N).Nkind = N_Label
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Subtype_Declaration);
Set_Flag8 (N, Val);
end Set_Exception_Junk;
procedure Set_Exception_Label
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler
or else NT (N).Nkind = N_Push_Constraint_Error_Label
or else NT (N).Nkind = N_Push_Program_Error_Label
or else NT (N).Nkind = N_Push_Storage_Error_Label);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Exception_Label;
procedure Set_Expansion_Delayed
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
Set_Flag11 (N, Val);
end Set_Expansion_Delayed;
procedure Set_Explicit_Actual_Parameter
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Association);
Set_Node3_With_Parent (N, Val);
end Set_Explicit_Actual_Parameter;
procedure Set_Explicit_Generic_Actual_Parameter
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Generic_Association);
Set_Node1_With_Parent (N, Val);
end Set_Explicit_Generic_Actual_Parameter;
procedure Set_Expression
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_At_Clause
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Case_Expression
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_Code_Statement
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Delay_Relative_Statement
or else NT (N).Nkind = N_Delay_Until_Statement
or else NT (N).Nkind = N_Delta_Aggregate
or else NT (N).Nkind = N_Discriminant_Association
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Expression_Function
or else NT (N).Nkind = N_Expression_With_Actions
or else NT (N).Nkind = N_Free_Statement
or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Mod_Clause
or else NT (N).Nkind = N_Modular_Type_Definition
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification
or else NT (N).Nkind = N_Pragma_Argument_Association
or else NT (N).Nkind = N_Qualified_Expression
or else NT (N).Nkind = N_Raise_Expression
or else NT (N).Nkind = N_Raise_Statement
or else NT (N).Nkind = N_Simple_Return_Statement
or else NT (N).Nkind = N_Type_Conversion
or else NT (N).Nkind = N_Unchecked_Expression
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
Set_Node3_With_Parent (N, Val);
end Set_Expression;
procedure Set_Expression_Copy
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma_Argument_Association);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Expression_Copy;
procedure Set_Expressions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Extension_Aggregate
or else NT (N).Nkind = N_If_Expression
or else NT (N).Nkind = N_Indexed_Component);
Set_List1_With_Parent (N, Val);
end Set_Expressions;
procedure Set_First_Bit
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
Set_Node3_With_Parent (N, Val);
end Set_First_Bit;
procedure Set_First_Inlined_Subprogram
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_First_Inlined_Subprogram;
procedure Set_First_Name
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag5 (N, Val);
end Set_First_Name;
procedure Set_First_Named_Actual
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Call_Statement
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_First_Named_Actual;
procedure Set_First_Real_Statement
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_First_Real_Statement;
procedure Set_First_Subtype_Link
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Freeze_Entity);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_First_Subtype_Link;
procedure Set_Float_Truncate
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag11 (N, Val);
end Set_Float_Truncate;
procedure Set_Formal_Type_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Type_Declaration);
Set_Node3_With_Parent (N, Val);
end Set_Formal_Type_Definition;
procedure Set_Forwards_OK
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
Set_Flag5 (N, Val);
end Set_Forwards_OK;
procedure Set_From_Aspect_Specification
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Pragma);
Set_Flag13 (N, Val);
end Set_From_Aspect_Specification;
procedure Set_From_At_End
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Raise_Statement);
Set_Flag4 (N, Val);
end Set_From_At_End;
procedure Set_From_At_Mod
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause);
Set_Flag4 (N, Val);
end Set_From_At_Mod;
procedure Set_From_Conditional_Expression
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Statement
or else NT (N).Nkind = N_If_Statement);
Set_Flag1 (N, Val);
end Set_From_Conditional_Expression;
procedure Set_From_Default
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
Set_Flag6 (N, Val);
end Set_From_Default;
procedure Set_Generalized_Indexing
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Indexed_Component);
Set_Node4 (N, Val);
end Set_Generalized_Indexing;
procedure Set_Generic_Associations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Procedure_Instantiation);
Set_List3_With_Parent (N, Val);
end Set_Generic_Associations;
procedure Set_Generic_Formal_Declarations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration);
Set_List2_With_Parent (N, Val);
end Set_Generic_Formal_Declarations;
procedure Set_Generic_Parent
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Procedure_Specification);
Set_Node5 (N, Val);
end Set_Generic_Parent;
procedure Set_Generic_Parent_Type
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Declaration);
Set_Node4 (N, Val);
end Set_Generic_Parent_Type;
procedure Set_Handled_Statement_Sequence
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Entry_Body
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
Set_Node4_With_Parent (N, Val);
end Set_Handled_Statement_Sequence;
procedure Set_Handler_List_Entry
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
Set_Node2 (N, Val);
end Set_Handler_List_Entry;
procedure Set_Has_Created_Identifier
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Loop_Statement);
Set_Flag15 (N, Val);
end Set_Has_Created_Identifier;
procedure Set_Has_Dereference_Action
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Explicit_Dereference);
Set_Flag13 (N, Val);
end Set_Has_Dereference_Action;
procedure Set_Has_Dynamic_Length_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
Set_Flag10 (N, Val);
end Set_Has_Dynamic_Length_Check;
procedure Set_Has_Dynamic_Range_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Declaration
or else NT (N).Nkind in N_Subexpr);
Set_Flag12 (N, Val);
end Set_Has_Dynamic_Range_Check;
procedure Set_Has_Init_Expression
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
Set_Flag14 (N, Val);
end Set_Has_Init_Expression;
procedure Set_Has_Local_Raise
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
Set_Flag8 (N, Val);
end Set_Has_Local_Raise;
procedure Set_Has_No_Elaboration_Code
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Flag17 (N, Val);
end Set_Has_No_Elaboration_Code;
procedure Set_Has_Pragma_Suppress_All
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Flag14 (N, Val);
end Set_Has_Pragma_Suppress_All;
procedure Set_Has_Private_View
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Op
or else NT (N).Nkind = N_Character_Literal
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Identifier
or else NT (N).Nkind = N_Operator_Symbol);
Set_Flag11 (N, Val);
end Set_Has_Private_View;
procedure Set_Has_Relative_Deadline_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Definition);
Set_Flag9 (N, Val);
end Set_Has_Relative_Deadline_Pragma;
procedure Set_Has_Self_Reference
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
Set_Flag13 (N, Val);
end Set_Has_Self_Reference;
procedure Set_Has_SP_Choice
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Case_Statement_Alternative
or else NT (N).Nkind = N_Variant);
Set_Flag15 (N, Val);
end Set_Has_SP_Choice;
procedure Set_Has_Storage_Size_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Task_Definition);
Set_Flag5 (N, Val);
end Set_Has_Storage_Size_Pragma;
procedure Set_Has_Target_Names
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
Set_Flag8 (N, Val);
end Set_Has_Target_Names;
procedure Set_Has_Wide_Character
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_String_Literal);
Set_Flag11 (N, Val);
end Set_Has_Wide_Character;
procedure Set_Has_Wide_Wide_Character
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_String_Literal);
Set_Flag13 (N, Val);
end Set_Has_Wide_Wide_Character;
procedure Set_Header_Size_Added
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
Set_Flag11 (N, Val);
end Set_Header_Size_Added;
procedure Set_Hidden_By_Use_Clause
(N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Use_Package_Clause
or else NT (N).Nkind = N_Use_Type_Clause);
Set_Elist4 (N, Val);
end Set_Hidden_By_Use_Clause;
procedure Set_High_Bound
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range
or else NT (N).Nkind = N_Real_Range_Specification
or else NT (N).Nkind = N_Signed_Integer_Type_Definition);
Set_Node2_With_Parent (N, Val);
end Set_High_Bound;
procedure Set_Identifier
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_At_Clause
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Designator
or else NT (N).Nkind = N_Enumeration_Representation_Clause
or else NT (N).Nkind = N_Label
or else NT (N).Nkind = N_Loop_Statement
or else NT (N).Nkind = N_Record_Representation_Clause);
Set_Node1_With_Parent (N, Val);
end Set_Identifier;
procedure Set_Implicit_With
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag16 (N, Val);
end Set_Implicit_With;
procedure Set_Implicit_With_From_Instantiation
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag12 (N, Val);
end Set_Implicit_With_From_Instantiation;
procedure Set_Interface_List
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_Single_Protected_Declaration
or else NT (N).Nkind = N_Single_Task_Declaration
or else NT (N).Nkind = N_Task_Type_Declaration);
Set_List2_With_Parent (N, Val);
end Set_Interface_List;
procedure Set_Interface_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Record_Definition);
Set_Flag16 (N, Val);
end Set_Interface_Present;
procedure Set_Import_Interface_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag16 (N, Val);
end Set_Import_Interface_Present;
procedure Set_In_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
Set_Flag15 (N, Val);
end Set_In_Present;
procedure Set_Includes_Infinities
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range);
Set_Flag11 (N, Val);
end Set_Includes_Infinities;
procedure Set_Incomplete_View
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Full_Type_Declaration);
Set_Node2 (N, Val); -- semantic field, no Parent set
end Set_Incomplete_View;
procedure Set_Inherited_Discriminant
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association);
Set_Flag13 (N, Val);
end Set_Inherited_Discriminant;
procedure Set_Instance_Spec
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Procedure_Instantiation);
Set_Node5 (N, Val); -- semantic field, no Parent set
end Set_Instance_Spec;
procedure Set_Intval
(N : Node_Id; Val : Uint) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Integer_Literal);
Set_Uint3 (N, Val);
end Set_Intval;
procedure Set_Is_Abort_Block
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
Set_Flag4 (N, Val);
end Set_Is_Abort_Block;
procedure Set_Is_Accessibility_Actual
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Association);
Set_Flag13 (N, Val);
end Set_Is_Accessibility_Actual;
procedure Set_Is_Analyzed_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag5 (N, Val);
end Set_Is_Analyzed_Pragma;
procedure Set_Is_Asynchronous_Call_Block
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
Set_Flag7 (N, Val);
end Set_Is_Asynchronous_Call_Block;
procedure Set_Is_Boolean_Aspect
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
Set_Flag16 (N, Val);
end Set_Is_Boolean_Aspect;
procedure Set_Is_Checked
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
Set_Flag11 (N, Val);
end Set_Is_Checked;
procedure Set_Is_Checked_Ghost_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag3 (N, Val);
end Set_Is_Checked_Ghost_Pragma;
procedure Set_Is_Component_Left_Opnd
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Concat);
Set_Flag13 (N, Val);
end Set_Is_Component_Left_Opnd;
procedure Set_Is_Component_Right_Opnd
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Concat);
Set_Flag14 (N, Val);
end Set_Is_Component_Right_Opnd;
procedure Set_Is_Controlling_Actual
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
Set_Flag16 (N, Val);
end Set_Is_Controlling_Actual;
procedure Set_Is_Delayed_Aspect
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Pragma);
Set_Flag14 (N, Val);
end Set_Is_Delayed_Aspect;
procedure Set_Is_Disabled
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
Set_Flag15 (N, Val);
end Set_Is_Disabled;
procedure Set_Is_Dynamic_Coextension
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator);
Set_Flag18 (N, Val);
end Set_Is_Dynamic_Coextension;
procedure Set_Is_Elsif
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Expression);
Set_Flag13 (N, Val);
end Set_Is_Elsif;
procedure Set_Is_Entry_Barrier_Function
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Declaration);
Set_Flag8 (N, Val);
end Set_Is_Entry_Barrier_Function;
procedure Set_Is_Expanded_Build_In_Place_Call
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call);
Set_Flag11 (N, Val);
end Set_Is_Expanded_Build_In_Place_Call;
procedure Set_Is_Expanded_Contract
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
Set_Flag1 (N, Val);
end Set_Is_Expanded_Contract;
procedure Set_Is_Finalization_Wrapper
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
Set_Flag9 (N, Val);
end Set_Is_Finalization_Wrapper;
procedure Set_Is_Folded_In_Parser
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_String_Literal);
Set_Flag4 (N, Val);
end Set_Is_Folded_In_Parser;
procedure Set_Is_Generic_Contract_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag2 (N, Val);
end Set_Is_Generic_Contract_Pragma;
procedure Set_Is_Ignored
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
Set_Flag9 (N, Val);
end Set_Is_Ignored;
procedure Set_Is_Ignored_Ghost_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag8 (N, Val);
end Set_Is_Ignored_Ghost_Pragma;
procedure Set_Is_In_Discriminant_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Selected_Component);
Set_Flag11 (N, Val);
end Set_Is_In_Discriminant_Check;
procedure Set_Is_Inherited_Pragma
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag4 (N, Val);
end Set_Is_Inherited_Pragma;
procedure Set_Is_Machine_Number
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Real_Literal);
Set_Flag11 (N, Val);
end Set_Is_Machine_Number;
procedure Set_Is_Null_Loop
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Loop_Statement);
Set_Flag16 (N, Val);
end Set_Is_Null_Loop;
procedure Set_Is_Overloaded
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
Set_Flag5 (N, Val);
end Set_Is_Overloaded;
procedure Set_Is_Power_Of_2_For_Shift
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Expon);
Set_Flag13 (N, Val);
end Set_Is_Power_Of_2_For_Shift;
procedure Set_Is_Prefixed_Call
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Selected_Component);
Set_Flag17 (N, Val);
end Set_Is_Prefixed_Call;
procedure Set_Is_Protected_Subprogram_Body
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body);
Set_Flag7 (N, Val);
end Set_Is_Protected_Subprogram_Body;
procedure Set_Is_Qualified_Universal_Literal
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Qualified_Expression);
Set_Flag4 (N, Val);
end Set_Is_Qualified_Universal_Literal;
procedure Set_Is_Static_Coextension
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator);
Set_Flag14 (N, Val);
end Set_Is_Static_Coextension;
procedure Set_Is_Static_Expression
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
Set_Flag6 (N, Val);
end Set_Is_Static_Expression;
procedure Set_Is_Subprogram_Descriptor
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
Set_Flag16 (N, Val);
end Set_Is_Subprogram_Descriptor;
procedure Set_Is_Task_Allocation_Block
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement);
Set_Flag6 (N, Val);
end Set_Is_Task_Allocation_Block;
procedure Set_Is_Task_Body_Procedure
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Declaration);
Set_Flag1 (N, Val);
end Set_Is_Task_Body_Procedure;
procedure Set_Is_Task_Master
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Block_Statement
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
Set_Flag5 (N, Val);
end Set_Is_Task_Master;
procedure Set_Iteration_Scheme
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Loop_Statement);
Set_Node2_With_Parent (N, Val);
end Set_Iteration_Scheme;
procedure Set_Iterator_Specification
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression);
Set_Node2_With_Parent (N, Val);
end Set_Iterator_Specification;
procedure Set_Itype
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Itype_Reference);
Set_Node1 (N, Val); -- no parent, semantic field
end Set_Itype;
procedure Set_Kill_Range_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
Set_Flag11 (N, Val);
end Set_Kill_Range_Check;
procedure Set_Label_Construct
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Implicit_Label_Declaration);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Label_Construct;
procedure Set_Last_Bit
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
Set_Node4_With_Parent (N, Val);
end Set_Last_Bit;
procedure Set_Last_Name
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag6 (N, Val);
end Set_Last_Name;
procedure Set_Left_Opnd
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In
or else NT (N).Nkind = N_Or_Else
or else NT (N).Nkind in N_Binary_Op);
Set_Node2_With_Parent (N, Val);
end Set_Left_Opnd;
procedure Set_Library_Unit
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit
or else NT (N).Nkind = N_Package_Body_Stub
or else NT (N).Nkind = N_Protected_Body_Stub
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Task_Body_Stub
or else NT (N).Nkind = N_With_Clause);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_Library_Unit;
procedure Set_Limited_View_Installed
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_With_Clause);
Set_Flag18 (N, Val);
end Set_Limited_View_Installed;
procedure Set_Limited_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Record_Definition
or else NT (N).Nkind = N_With_Clause);
Set_Flag17 (N, Val);
end Set_Limited_Present;
procedure Set_Literals
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Enumeration_Type_Definition);
Set_List1_With_Parent (N, Val);
end Set_Literals;
procedure Set_Local_Raise_Not_OK
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
Set_Flag7 (N, Val);
end Set_Local_Raise_Not_OK;
procedure Set_Local_Raise_Statements
(N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Handler);
Set_Elist1 (N, Val);
end Set_Local_Raise_Statements;
procedure Set_Loop_Actions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Iterated_Component_Association);
Set_List2 (N, Val); -- semantic field, no parent set
end Set_Loop_Actions;
procedure Set_Loop_Parameter_Specification
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression);
Set_Node4_With_Parent (N, Val);
end Set_Loop_Parameter_Specification;
procedure Set_Low_Bound
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range
or else NT (N).Nkind = N_Real_Range_Specification
or else NT (N).Nkind = N_Signed_Integer_Type_Definition);
Set_Node1_With_Parent (N, Val);
end Set_Low_Bound;
procedure Set_Mod_Clause
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Record_Representation_Clause);
Set_Node2_With_Parent (N, Val);
end Set_Mod_Clause;
procedure Set_More_Ids
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
Set_Flag5 (N, Val);
end Set_More_Ids;
procedure Set_Must_Be_Byte_Aligned
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
Set_Flag14 (N, Val);
end Set_Must_Be_Byte_Aligned;
procedure Set_Must_Not_Freeze
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subtype_Indication
or else NT (N).Nkind in N_Subexpr);
Set_Flag8 (N, Val);
end Set_Must_Not_Freeze;
procedure Set_Must_Not_Override
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Procedure_Specification);
Set_Flag15 (N, Val);
end Set_Must_Not_Override;
procedure Set_Must_Override
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Procedure_Specification);
Set_Flag14 (N, Val);
end Set_Must_Override;
procedure Set_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Defining_Program_Unit_Name
or else NT (N).Nkind = N_Designator
or else NT (N).Nkind = N_Entry_Call_Statement
or else NT (N).Nkind = N_Exception_Renaming_Declaration
or else NT (N).Nkind = N_Exit_Statement
or else NT (N).Nkind = N_Formal_Package_Declaration
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Generic_Function_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Package_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Procedure_Renaming_Declaration
or else NT (N).Nkind = N_Goto_Statement
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Package_Renaming_Declaration
or else NT (N).Nkind = N_Procedure_Call_Statement
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Raise_Expression
or else NT (N).Nkind = N_Raise_Statement
or else NT (N).Nkind = N_Requeue_Statement
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration
or else NT (N).Nkind = N_Subunit
or else NT (N).Nkind = N_Variant_Part
or else NT (N).Nkind = N_With_Clause);
Set_Node2_With_Parent (N, Val);
end Set_Name;
procedure Set_Names
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Abort_Statement
or else NT (N).Nkind = N_Use_Package_Clause);
Set_List2_With_Parent (N, Val);
end Set_Names;
procedure Set_Next_Entity
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Defining_Character_Literal
or else NT (N).Nkind = N_Defining_Identifier
or else NT (N).Nkind = N_Defining_Operator_Symbol);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Next_Entity;
procedure Set_Next_Exit_Statement
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exit_Statement);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Next_Exit_Statement;
procedure Set_Next_Implicit_With
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Next_Implicit_With;
procedure Set_Next_Named_Actual
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Association);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_Next_Named_Actual;
procedure Set_Next_Pragma
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Node1 (N, Val); -- semantic field, no parent set
end Set_Next_Pragma;
procedure Set_Next_Rep_Item
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Enumeration_Representation_Clause
or else NT (N).Nkind = N_Pragma
or else NT (N).Nkind = N_Record_Representation_Clause);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Next_Rep_Item;
procedure Set_Next_Use_Clause
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Use_Package_Clause
or else NT (N).Nkind = N_Use_Type_Clause);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Next_Use_Clause;
procedure Set_No_Ctrl_Actions
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement);
Set_Flag7 (N, Val);
end Set_No_Ctrl_Actions;
procedure Set_No_Elaboration_Check
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
Set_Flag14 (N, Val);
end Set_No_Elaboration_Check;
procedure Set_No_Entities_Ref_In_Spec
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag8 (N, Val);
end Set_No_Entities_Ref_In_Spec;
procedure Set_No_Initialization
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Object_Declaration);
Set_Flag13 (N, Val);
end Set_No_Initialization;
procedure Set_No_Minimize_Eliminate
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In);
Set_Flag17 (N, Val);
end Set_No_Minimize_Eliminate;
procedure Set_No_Side_Effect_Removal
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Call);
Set_Flag1 (N, Val);
end Set_No_Side_Effect_Removal;
procedure Set_No_Truncation
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
Set_Flag17 (N, Val);
end Set_No_Truncation;
procedure Set_Non_Aliased_Prefix
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference);
Set_Flag18 (N, Val);
end Set_Non_Aliased_Prefix;
procedure Set_Null_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_List
or else NT (N).Nkind = N_Procedure_Specification
or else NT (N).Nkind = N_Record_Definition);
Set_Flag13 (N, Val);
end Set_Null_Present;
procedure Set_Null_Excluding_Subtype
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_To_Object_Definition);
Set_Flag16 (N, Val);
end Set_Null_Excluding_Subtype;
procedure Set_Null_Exclusion_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Access_Procedure_Definition
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Parameter_Specification
or else NT (N).Nkind = N_Subtype_Declaration);
Set_Flag11 (N, Val);
end Set_Null_Exclusion_Present;
procedure Set_Null_Exclusion_In_Return_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Function_Definition);
Set_Flag14 (N, Val);
end Set_Null_Exclusion_In_Return_Present;
procedure Set_Null_Record_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aggregate
or else NT (N).Nkind = N_Extension_Aggregate);
Set_Flag17 (N, Val);
end Set_Null_Record_Present;
procedure Set_Object_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Object_Declaration);
Set_Node4_With_Parent (N, Val);
end Set_Object_Definition;
procedure Set_Of_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iterator_Specification);
Set_Flag16 (N, Val);
end Set_Of_Present;
procedure Set_Original_Discriminant
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Identifier);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Original_Discriminant;
procedure Set_Original_Entity
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Integer_Literal
or else NT (N).Nkind = N_Real_Literal);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Original_Entity;
procedure Set_Others_Discrete_Choices
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Others_Choice);
Set_List1_With_Parent (N, Val);
end Set_Others_Discrete_Choices;
procedure Set_Out_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
Set_Flag17 (N, Val);
end Set_Out_Present;
procedure Set_Parameter_Associations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Entry_Call_Statement
or else NT (N).Nkind = N_Function_Call
or else NT (N).Nkind = N_Procedure_Call_Statement);
Set_List3_With_Parent (N, Val);
end Set_Parameter_Associations;
procedure Set_Parameter_Specifications
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Statement
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Access_Procedure_Definition
or else NT (N).Nkind = N_Entry_Body_Formal_Part
or else NT (N).Nkind = N_Entry_Declaration
or else NT (N).Nkind = N_Function_Specification
or else NT (N).Nkind = N_Procedure_Specification);
Set_List3_With_Parent (N, Val);
end Set_Parameter_Specifications;
procedure Set_Parameter_Type
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Parameter_Specification);
Set_Node2_With_Parent (N, Val);
end Set_Parameter_Type;
procedure Set_Parent_Spec
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Function_Instantiation
or else NT (N).Nkind = N_Generic_Function_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Package_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Procedure_Renaming_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Package_Instantiation
or else NT (N).Nkind = N_Package_Renaming_Declaration
or else NT (N).Nkind = N_Procedure_Instantiation
or else NT (N).Nkind = N_Subprogram_Declaration
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_Parent_Spec;
procedure Set_Position
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Clause);
Set_Node2_With_Parent (N, Val);
end Set_Position;
procedure Set_Pragma_Argument_Associations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_List2_With_Parent (N, Val);
end Set_Pragma_Argument_Associations;
procedure Set_Pragma_Identifier
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Node4_With_Parent (N, Val);
end Set_Pragma_Identifier;
procedure Set_Pragmas_After
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit_Aux
or else NT (N).Nkind = N_Terminate_Alternative);
Set_List5_With_Parent (N, Val);
end Set_Pragmas_After;
procedure Set_Pragmas_Before
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Accept_Alternative
or else NT (N).Nkind = N_Delay_Alternative
or else NT (N).Nkind = N_Entry_Call_Alternative
or else NT (N).Nkind = N_Mod_Clause
or else NT (N).Nkind = N_Terminate_Alternative
or else NT (N).Nkind = N_Triggering_Alternative);
Set_List4_With_Parent (N, Val);
end Set_Pragmas_Before;
procedure Set_Pre_Post_Conditions
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
Set_Node1 (N, Val); -- semantic field, no parent set
end Set_Pre_Post_Conditions;
procedure Set_Prefix
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Explicit_Dereference
or else NT (N).Nkind = N_Indexed_Component
or else NT (N).Nkind = N_Reference
or else NT (N).Nkind = N_Selected_Component
or else NT (N).Nkind = N_Slice);
Set_Node3_With_Parent (N, Val);
end Set_Prefix;
procedure Set_Premature_Use
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Incomplete_Type_Declaration);
Set_Node5 (N, Val);
end Set_Premature_Use;
procedure Set_Present_Expr
(N : Node_Id; Val : Uint) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant);
Set_Uint3 (N, Val);
end Set_Present_Expr;
procedure Set_Prev_Ids
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_Declaration
or else NT (N).Nkind = N_Discriminant_Specification
or else NT (N).Nkind = N_Exception_Declaration
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Number_Declaration
or else NT (N).Nkind = N_Object_Declaration
or else NT (N).Nkind = N_Parameter_Specification);
Set_Flag6 (N, Val);
end Set_Prev_Ids;
procedure Set_Print_In_Hex
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Integer_Literal);
Set_Flag13 (N, Val);
end Set_Print_In_Hex;
procedure Set_Private_Declarations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Protected_Definition
or else NT (N).Nkind = N_Task_Definition);
Set_List3_With_Parent (N, Val);
end Set_Private_Declarations;
procedure Set_Private_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_With_Clause);
Set_Flag15 (N, Val);
end Set_Private_Present;
procedure Set_Procedure_To_Call
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Free_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Procedure_To_Call;
procedure Set_Proper_Body
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subunit);
Set_Node1_With_Parent (N, Val);
end Set_Proper_Body;
procedure Set_Protected_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Protected_Type_Declaration
or else NT (N).Nkind = N_Single_Protected_Declaration);
Set_Node3_With_Parent (N, Val);
end Set_Protected_Definition;
procedure Set_Protected_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Access_Procedure_Definition
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Record_Definition);
Set_Flag6 (N, Val);
end Set_Protected_Present;
procedure Set_Raises_Constraint_Error
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Subexpr);
Set_Flag7 (N, Val);
end Set_Raises_Constraint_Error;
procedure Set_Range_Constraint
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Delta_Constraint
or else NT (N).Nkind = N_Digits_Constraint);
Set_Node4_With_Parent (N, Val);
end Set_Range_Constraint;
procedure Set_Range_Expression
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Range_Constraint);
Set_Node4_With_Parent (N, Val);
end Set_Range_Expression;
procedure Set_Real_Range_Specification
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Decimal_Fixed_Point_Definition
or else NT (N).Nkind = N_Floating_Point_Definition
or else NT (N).Nkind = N_Ordinary_Fixed_Point_Definition);
Set_Node4_With_Parent (N, Val);
end Set_Real_Range_Specification;
procedure Set_Realval
(N : Node_Id; Val : Ureal) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Real_Literal);
Set_Ureal3 (N, Val);
end Set_Realval;
procedure Set_Reason
(N : Node_Id; Val : Uint) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Raise_Constraint_Error
or else NT (N).Nkind = N_Raise_Program_Error
or else NT (N).Nkind = N_Raise_Storage_Error);
Set_Uint3 (N, Val);
end Set_Reason;
procedure Set_Record_Extension_Part
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition);
Set_Node3_With_Parent (N, Val);
end Set_Record_Extension_Part;
procedure Set_Redundant_Use
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Reference
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Identifier);
Set_Flag13 (N, Val);
end Set_Redundant_Use;
procedure Set_Renaming_Exception
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Exception_Declaration);
Set_Node2 (N, Val);
end Set_Renaming_Exception;
procedure Set_Result_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Function_Definition
or else NT (N).Nkind = N_Function_Specification);
Set_Node4_With_Parent (N, Val);
end Set_Result_Definition;
procedure Set_Return_Object_Declarations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extended_Return_Statement);
Set_List3_With_Parent (N, Val);
end Set_Return_Object_Declarations;
procedure Set_Return_Statement_Entity
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_Return_Statement_Entity;
procedure Set_Reverse_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Loop_Parameter_Specification);
Set_Flag15 (N, Val);
end Set_Reverse_Present;
procedure Set_Right_Opnd
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind in N_Op
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_In
or else NT (N).Nkind = N_Not_In
or else NT (N).Nkind = N_Or_Else);
Set_Node3_With_Parent (N, Val);
end Set_Right_Opnd;
procedure Set_Rounded_Result
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Divide
or else NT (N).Nkind = N_Op_Multiply
or else NT (N).Nkind = N_Type_Conversion);
Set_Flag18 (N, Val);
end Set_Rounded_Result;
procedure Set_SCIL_Controlling_Tag
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Dispatching_Call);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_SCIL_Controlling_Tag;
procedure Set_SCIL_Entity
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Dispatch_Table_Tag_Init
or else NT (N).Nkind = N_SCIL_Dispatching_Call
or else NT (N).Nkind = N_SCIL_Membership_Test);
Set_Node4 (N, Val); -- semantic field, no parent set
end Set_SCIL_Entity;
procedure Set_SCIL_Tag_Value
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Membership_Test);
Set_Node5 (N, Val); -- semantic field, no parent set
end Set_SCIL_Tag_Value;
procedure Set_SCIL_Target_Prim
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_SCIL_Dispatching_Call);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_SCIL_Target_Prim;
procedure Set_Scope
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Defining_Character_Literal
or else NT (N).Nkind = N_Defining_Identifier
or else NT (N).Nkind = N_Defining_Operator_Symbol);
Set_Node3 (N, Val); -- semantic field, no parent set
end Set_Scope;
procedure Set_Select_Alternatives
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Selective_Accept);
Set_List1_With_Parent (N, Val);
end Set_Select_Alternatives;
procedure Set_Selector_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Expanded_Name
or else NT (N).Nkind = N_Generic_Association
or else NT (N).Nkind = N_Parameter_Association
or else NT (N).Nkind = N_Selected_Component);
Set_Node2_With_Parent (N, Val);
end Set_Selector_Name;
procedure Set_Selector_Names
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Discriminant_Association);
Set_List1_With_Parent (N, Val);
end Set_Selector_Names;
procedure Set_Shift_Count_OK
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Rotate_Left
or else NT (N).Nkind = N_Op_Rotate_Right
or else NT (N).Nkind = N_Op_Shift_Left
or else NT (N).Nkind = N_Op_Shift_Right
or else NT (N).Nkind = N_Op_Shift_Right_Arithmetic);
Set_Flag4 (N, Val);
end Set_Shift_Count_OK;
procedure Set_Source_Type
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Validate_Unchecked_Conversion);
Set_Node1 (N, Val); -- semantic field, no parent set
end Set_Source_Type;
procedure Set_Specification
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Expression_Function
or else NT (N).Nkind = N_Formal_Abstract_Subprogram_Declaration
or else NT (N).Nkind = N_Formal_Concrete_Subprogram_Declaration
or else NT (N).Nkind = N_Generic_Package_Declaration
or else NT (N).Nkind = N_Generic_Subprogram_Declaration
or else NT (N).Nkind = N_Package_Declaration
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Subprogram_Body_Stub
or else NT (N).Nkind = N_Subprogram_Declaration
or else NT (N).Nkind = N_Subprogram_Renaming_Declaration);
Set_Node1_With_Parent (N, Val);
end Set_Specification;
procedure Set_Split_PPC
(N : Node_Id; Val : Boolean) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification
or else NT (N).Nkind = N_Pragma);
Set_Flag17 (N, Val);
end Set_Split_PPC;
procedure Set_Statements
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Abortable_Part
or else NT (N).Nkind = N_Accept_Alternative
or else NT (N).Nkind = N_Case_Statement_Alternative
or else NT (N).Nkind = N_Delay_Alternative
or else NT (N).Nkind = N_Entry_Call_Alternative
or else NT (N).Nkind = N_Exception_Handler
or else NT (N).Nkind = N_Handled_Sequence_Of_Statements
or else NT (N).Nkind = N_Loop_Statement
or else NT (N).Nkind = N_Triggering_Alternative);
Set_List3_With_Parent (N, Val);
end Set_Statements;
procedure Set_Storage_Pool
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator
or else NT (N).Nkind = N_Extended_Return_Statement
or else NT (N).Nkind = N_Free_Statement
or else NT (N).Nkind = N_Simple_Return_Statement);
Set_Node1 (N, Val); -- semantic field, no parent set
end Set_Storage_Pool;
procedure Set_Subpool_Handle_Name
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Allocator);
Set_Node4_With_Parent (N, Val);
end Set_Subpool_Handle_Name;
procedure Set_Strval
(N : Node_Id; Val : String_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Operator_Symbol
or else NT (N).Nkind = N_String_Literal);
Set_Str3 (N, Val);
end Set_Strval;
procedure Set_Subtype_Indication
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_To_Object_Definition
or else NT (N).Nkind = N_Component_Definition
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Iterator_Specification
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Subtype_Declaration);
Set_Node5_With_Parent (N, Val);
end Set_Subtype_Indication;
procedure Set_Subtype_Mark
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Access_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Object_Declaration
or else NT (N).Nkind = N_Object_Renaming_Declaration
or else NT (N).Nkind = N_Qualified_Expression
or else NT (N).Nkind = N_Subtype_Indication
or else NT (N).Nkind = N_Type_Conversion
or else NT (N).Nkind = N_Unchecked_Type_Conversion);
Set_Node4_With_Parent (N, Val);
end Set_Subtype_Mark;
procedure Set_Subtype_Marks
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Unconstrained_Array_Definition
or else NT (N).Nkind = N_Use_Type_Clause);
Set_List2_With_Parent (N, Val);
end Set_Subtype_Marks;
procedure Set_Suppress_Assignment_Checks
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Assignment_Statement
or else NT (N).Nkind = N_Object_Declaration);
Set_Flag18 (N, Val);
end Set_Suppress_Assignment_Checks;
procedure Set_Suppress_Loop_Warnings
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Loop_Statement);
Set_Flag17 (N, Val);
end Set_Suppress_Loop_Warnings;
procedure Set_Synchronized_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Formal_Derived_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Record_Definition);
Set_Flag7 (N, Val);
end Set_Synchronized_Present;
procedure Set_Tagged_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Incomplete_Type_Definition
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration
or else NT (N).Nkind = N_Record_Definition);
Set_Flag15 (N, Val);
end Set_Tagged_Present;
procedure Set_Target_Type
(N : Node_Id; Val : Entity_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Validate_Unchecked_Conversion);
Set_Node2 (N, Val); -- semantic field, no parent set
end Set_Target_Type;
procedure Set_Task_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Single_Task_Declaration
or else NT (N).Nkind = N_Task_Type_Declaration);
Set_Node3_With_Parent (N, Val);
end Set_Task_Definition;
procedure Set_Task_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Derived_Type_Definition
or else NT (N).Nkind = N_Record_Definition);
Set_Flag5 (N, Val);
end Set_Task_Present;
procedure Set_Then_Actions
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_If_Expression);
Set_List2_With_Parent (N, Val); -- semantic field, but needs parents
end Set_Then_Actions;
procedure Set_Then_Statements
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Elsif_Part
or else NT (N).Nkind = N_If_Statement);
Set_List2_With_Parent (N, Val);
end Set_Then_Statements;
procedure Set_Treat_Fixed_As_Integer
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Op_Divide
or else NT (N).Nkind = N_Op_Mod
or else NT (N).Nkind = N_Op_Multiply
or else NT (N).Nkind = N_Op_Rem);
Set_Flag14 (N, Val);
end Set_Treat_Fixed_As_Integer;
procedure Set_Triggering_Alternative
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Asynchronous_Select);
Set_Node1_With_Parent (N, Val);
end Set_Triggering_Alternative;
procedure Set_Triggering_Statement
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Triggering_Alternative);
Set_Node1_With_Parent (N, Val);
end Set_Triggering_Statement;
procedure Set_TSS_Elist
(N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Freeze_Entity);
Set_Elist3 (N, Val); -- semantic field, no parent set
end Set_TSS_Elist;
procedure Set_Uneval_Old_Accept
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag7 (N, Val);
end Set_Uneval_Old_Accept;
procedure Set_Uneval_Old_Warn
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag18 (N, Val);
end Set_Uneval_Old_Warn;
procedure Set_Type_Definition
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Full_Type_Declaration);
Set_Node3_With_Parent (N, Val);
end Set_Type_Definition;
procedure Set_Unit
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Compilation_Unit);
Set_Node2_With_Parent (N, Val);
end Set_Unit;
procedure Set_Unknown_Discriminants_Present
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Type_Declaration
or else NT (N).Nkind = N_Incomplete_Type_Declaration
or else NT (N).Nkind = N_Private_Extension_Declaration
or else NT (N).Nkind = N_Private_Type_Declaration);
Set_Flag13 (N, Val);
end Set_Unknown_Discriminants_Present;
procedure Set_Unreferenced_In_Spec
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Flag7 (N, Val);
end Set_Unreferenced_In_Spec;
procedure Set_Variant_Part
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Component_List);
Set_Node4_With_Parent (N, Val);
end Set_Variant_Part;
procedure Set_Variants
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Variant_Part);
Set_List1_With_Parent (N, Val);
end Set_Variants;
procedure Set_Visible_Declarations
(N : Node_Id; Val : List_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Specification
or else NT (N).Nkind = N_Protected_Definition
or else NT (N).Nkind = N_Task_Definition);
Set_List2_With_Parent (N, Val);
end Set_Visible_Declarations;
procedure Set_Uninitialized_Variable
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Formal_Private_Type_Definition
or else NT (N).Nkind = N_Private_Extension_Declaration);
Set_Node3 (N, Val);
end Set_Uninitialized_Variable;
procedure Set_Used_Operations
(N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Use_Type_Clause);
Set_Elist5 (N, Val);
end Set_Used_Operations;
procedure Set_Was_Expression_Function
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Subprogram_Body);
Set_Flag18 (N, Val);
end Set_Was_Expression_Function;
procedure Set_Was_Originally_Stub
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Package_Body
or else NT (N).Nkind = N_Protected_Body
or else NT (N).Nkind = N_Subprogram_Body
or else NT (N).Nkind = N_Task_Body);
Set_Flag13 (N, Val);
end Set_Was_Originally_Stub;
procedure Set_Withed_Body
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
or else NT (N).Nkind = N_With_Clause);
Set_Node1 (N, Val);
end Set_Withed_Body;
-------------------------
-- Iterator Procedures --
-------------------------
procedure Next_Entity (N : in out Node_Id) is
begin
N := Next_Entity (N);
end Next_Entity;
procedure Next_Named_Actual (N : in out Node_Id) is
begin
N := Next_Named_Actual (N);
end Next_Named_Actual;
procedure Next_Rep_Item (N : in out Node_Id) is
begin
N := Next_Rep_Item (N);
end Next_Rep_Item;
procedure Next_Use_Clause (N : in out Node_Id) is
begin
N := Next_Use_Clause (N);
end Next_Use_Clause;
------------------
-- End_Location --
------------------
function End_Location (N : Node_Id) return Source_Ptr is
L : constant Uint := End_Span (N);
begin
if L = No_Uint then
return No_Location;
else
return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L));
end if;
end End_Location;
--------------------
-- Get_Pragma_Arg --
--------------------
function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
begin
if Nkind (Arg) = N_Pragma_Argument_Association then
return Expression (Arg);
else
return Arg;
end if;
end Get_Pragma_Arg;
----------------------
-- Set_End_Location --
----------------------
procedure Set_End_Location (N : Node_Id; S : Source_Ptr) is
begin
Set_End_Span (N,
UI_From_Int (Int (S) - Int (Sloc (N))));
end Set_End_Location;
--------------
-- Nkind_In --
--------------
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3 or else
T = V4;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3 or else
T = V4 or else
T = V5;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3 or else
T = V4 or else
T = V5 or else
T = V6;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind;
V7 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3 or else
T = V4 or else
T = V5 or else
T = V6 or else
T = V7;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind;
V7 : Node_Kind;
V8 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3 or else
T = V4 or else
T = V5 or else
T = V6 or else
T = V7 or else
T = V8;
end Nkind_In;
function Nkind_In
(T : Node_Kind;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind;
V7 : Node_Kind;
V8 : Node_Kind;
V9 : Node_Kind) return Boolean
is
begin
return T = V1 or else
T = V2 or else
T = V3 or else
T = V4 or else
T = V5 or else
T = V6 or else
T = V7 or else
T = V8 or else
T = V9;
end Nkind_In;
-----------------
-- Pragma_Name --
-----------------
function Pragma_Name_Unmapped (N : Node_Id) return Name_Id is
begin
return Chars (Pragma_Identifier (N));
end Pragma_Name_Unmapped;
---------------------
-- Map_Pragma_Name --
---------------------
-- We don't want to introduce a dependence on some hash table package or
-- similar, so we use a simple array of Key => Value pairs, and do a linear
-- search. Linear search is plenty efficient, given that we don't expect
-- more than a couple of entries in the mapping.
type Name_Pair is record
Key : Name_Id;
Value : Name_Id;
end record;
type Pragma_Map_Index is range 1 .. 100;
Pragma_Map : array (Pragma_Map_Index) of Name_Pair;
Last_Pair : Pragma_Map_Index'Base range 0 .. Pragma_Map_Index'Last := 0;
procedure Map_Pragma_Name (From, To : Name_Id) is
begin
if Last_Pair = Pragma_Map'Last then
raise Too_Many_Pragma_Mappings;
end if;
Last_Pair := Last_Pair + 1;
Pragma_Map (Last_Pair) := (Key => From, Value => To);
end Map_Pragma_Name;
-----------------
-- Pragma_Name --
-----------------
function Pragma_Name (N : Node_Id) return Name_Id is
Result : constant Name_Id := Pragma_Name_Unmapped (N);
begin
for J in Pragma_Map'First .. Last_Pair loop
if Result = Pragma_Map (J).Key then
return Pragma_Map (J).Value;
end if;
end loop;
return Result;
end Pragma_Name;
end Sinfo;
|
------------------------------------------------------------------------------
-- --
-- Unicode Utilities --
-- UTF-8 Stream Decoder --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, 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. --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Conversions;
with Unicode.UTF8_Stream_Decoder.Codec;
package body Unicode.UTF8_Stream_Decoder is
--
-- Stream Decoders
--
-----------------
-- Decode_Next -- (Wide_Wide_Character)
-----------------
function Decode_Next (UTF8_Stream : not null access Root_Stream_Type'Class)
return Wide_Wide_Character
is
use Codec;
Buffer: Sequence_Array (1 .. 4) := (others => 0);
Last, Continuation: Stream_Element_Offset;
Status: Decode_Status;
begin
return Result: Wide_Wide_Character do
-- Load next octet (hoping for a valid starting octet)
Stream_Element'Read (UTF8_Stream, Buffer(1));
-- Phase 1, check for sync and then mult-byte sequence
Try_Decode (Sequence => Buffer(1 .. 1),
Last => Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
-- See if we have an indicated multi-byte condition
if Status = Short_Load then
-- Load the expected number of octets and re-run
declare
-- The (verified) postcondition of Try_Decode promises that
-- Continuation will be 1 .. 3. Therefore we know that the
-- above range will never be larger than 2 .. 3 + 1 = 4
pragma Suppress (Index_Check);
pragma Suppress (Length_Check);
pragma Suppress (Overflow_Check);
pragma Suppress (Range_Check);
-- 2 .. 2, 2 .. 3, 2 .. 4 - all ok
-- Also note that the components of Sequence_Array is
-- a modular type - and therefore Overflow_Check and
-- Range_Check do not apply to those (the return values)
-- anyways.
begin
Sequence_Array'Read
(UTF8_Stream, Buffer(2 .. Continuation + 1));
end;
-- Run Try_Decode again for the final Result
Try_Decode (Sequence => Buffer(1 .. Continuation + 1),
Last => Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
end if;
-- Note that the postcondition of Try_Decode promises that if Status
-- is not "Success", then Result will always be
-- Unicode_Replacement_Character
end return;
end Decode_Next;
-----------------
-- Decode_Next -- (Wide_Character)
-----------------
function Decode_Next (UTF8_Stream : not null access Root_Stream_Type'Class)
return Wide_Character
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character
:= Decode_Next (UTF8_Stream);
begin
if not Is_Wide_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Wide_Character";
else
return To_Wide_Character (Full_Char);
end if;
end Decode_Next;
-----------------
-- Decode_Next -- (Character)
-----------------
function Decode_Next (UTF8_Stream : not null access Root_Stream_Type'Class)
return Character
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character
:= Decode_Next (UTF8_Stream);
begin
if not Is_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Character";
else
return To_Character (Full_Char);
end if;
end Decode_Next;
-- Buffer Decoders ---------------------------------------------------------
-----------------
-- Decode_Next -- (Wide_Wide_Character)
-----------------
procedure Decode_Next (Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Result : out Wide_Wide_Character)
is
use Codec;
Start : Stream_Element_Offset := Buffer'First;
Continuation: Stream_Element_Offset;
Status : Decode_Status;
Sequence_Last: Sequence_Index;
begin
if Buffer'Length = 0 then
raise Short_Buffer with "Buffer is empty.";
end if;
Last := Buffer'First;
-- Phase 1, check for sync and then mult-byte sequence
Try_Decode
(Sequence => Sequence_Array'(1 => Buffer(Buffer'First)),
Last => Sequence_Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
-- See if we have an indicated multi-byte condition
if Status = Short_Load then
-- Check that we can actually provide the required number of
-- continuation bytes.
if Buffer'First + Continuation > Buffer'Last then
raise Short_Buffer;
end if;
-- Re-run with the Load the expected number of octets
declare
-- The (verified) postcondition of Try_Decode promises that
-- Continuation will be 1 .. 3. Therefore we know that the
-- above range will never be larger than 2 .. 3 + 1 = 4
pragma Suppress (Index_Check);
pragma Suppress (Length_Check);
pragma Suppress (Overflow_Check);
pragma Suppress (Range_Check);
-- 2 .. 2, 2 .. 3, 2 .. 4 - all ok
-- Also note that the components of Sequence_Array is
-- a modular type - and therefore Overflow_Check and
-- Range_Check do not apply to those (the return values)
-- anyways.
Sequence: constant Sequence_Array(1 .. 1 + Continuation)
:= Sequence_Array
(Buffer(Buffer'First .. Buffer'First + Continuation));
-- 1 + Continuation must be: 2, 3, 4
-- Buffer'First + Continuation must be <= Buffer'Last, due
-- to the if statement above
begin
-- Run Try_Decode again for the final Result
Try_Decode (Sequence => Sequence,
Last => Sequence_Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
end;
end if;
Last := Buffer'First + Continuation;
if Status /= Success then
Result := Unicode_Replacement_Character;
end if;
end Decode_Next;
-----------------
-- Decode_Next -- (Wide_Character)
-----------------
procedure Decode_Next (Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Result : out Wide_Character)
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character;
Temp_Last: Stream_Element_Offset;
begin
Decode_Next (Buffer => Buffer,
Last => Temp_Last,
Result => Full_Char);
if not Is_Wide_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Wide_Character";
else
Result := To_Wide_Character (Full_Char);
Last := Temp_Last;
end if;
end Decode_Next;
-----------------
-- Decode_Next -- (Character)
-----------------
procedure Decode_Next (Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Result : out Character)
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character;
Temp_Last: Stream_Element_Offset;
begin
Decode_Next (Buffer => Buffer,
Last => Temp_Last,
Result => Full_Char);
if not Is_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Character";
else
Result := To_Character (Full_Char);
Last := Temp_Last;
end if;
end Decode_Next;
end Unicode.UTF8_Stream_Decoder;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.INDEFINITE_HASHED_MAPS --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2021, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 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/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Iterator_Interfaces;
private with Ada.Containers.Hash_Tables;
private with Ada.Finalization;
private with Ada.Streams;
private with Ada.Strings.Text_Buffers;
generic
type Key_Type (<>) is private;
type Element_Type (<>) is private;
with function Hash (Key : Key_Type) return Hash_Type;
with function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Indefinite_Hashed_Maps with
SPARK_Mode => Off
is
pragma Annotate (CodePeer, Skip_Analysis);
pragma Preelaborate;
pragma Remote_Types;
type Map is tagged private with
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type,
Aggregate => (Empty => Empty,
Add_Named => Insert);
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_Map : constant Map;
-- Map objects declared without an initialization expression are
-- initialized to the value Empty_Map.
function Empty (Capacity : Count_Type := 1000) return Map;
No_Element : constant Cursor;
-- Cursor objects declared without an initialization expression are
-- initialized to the value No_Element.
function Has_Element (Position : Cursor) return Boolean;
-- Equivalent to Position /= No_Element
package Map_Iterator_Interfaces is new
Ada.Iterator_Interfaces (Cursor, Has_Element);
overriding function "=" (Left, Right : Map) return Boolean;
-- For each key/element pair in Left, equality attempts to find the key in
-- Right; if a search fails the equality returns False. The search works by
-- calling Hash to find the bucket in the Right map that corresponds to the
-- Left key. If bucket is non-empty, then equality calls Equivalent_Keys
-- to compare the key (in Left) to the key of each node in the bucket (in
-- Right); if the keys are equivalent, then the equality test for this
-- key/element pair (in Left) completes by calling the element equality
-- operator to compare the element (in Left) to the element of the node
-- (in Right) whose key matched.
function Capacity (Container : Map) return Count_Type;
-- Returns the current capacity of the map. Capacity is the maximum length
-- before which rehashing in guaranteed not to occur.
procedure Reserve_Capacity (Container : in out Map; Capacity : Count_Type);
-- Adjusts the current capacity, by allocating a new buckets array. If the
-- requested capacity is less than the current capacity, then the capacity
-- is contracted (to a value not less than the current length). If the
-- requested capacity is greater than the current capacity, then the
-- capacity is expanded (to a value not less than what is requested). In
-- either case, the nodes are rehashed from the old buckets array onto the
-- new buckets array (Hash is called once for each existing key in order to
-- compute the new index), and then the old buckets array is deallocated.
function Length (Container : Map) return Count_Type;
-- Returns the number of items in the map
function Is_Empty (Container : Map) return Boolean;
-- Equivalent to Length (Container) = 0
procedure Clear (Container : in out Map);
-- Removes all of the items from the map
function Key (Position : Cursor) return Key_Type;
-- Returns the key of the node designated by the cursor
function Element (Position : Cursor) return Element_Type;
-- Returns the element of the node designated by the cursor
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type);
-- Assigns the value New_Item to the element designated by the cursor
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : Element_Type));
-- Calls Process with the key and element (both having only a constant
-- view) of the node designed by the cursor.
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type));
-- Calls Process with the key (with only a constant view) and element (with
-- a variable view) of the node designed by the cursor.
type Constant_Reference_Type
(Element : not null access constant Element_Type) is private
with
Implicit_Dereference => Element;
type Reference_Type (Element : not null access Element_Type) is private
with
Implicit_Dereference => Element;
function Constant_Reference
(Container : aliased Map;
Position : Cursor) return Constant_Reference_Type;
pragma Inline (Constant_Reference);
function Reference
(Container : aliased in out Map;
Position : Cursor) return Reference_Type;
pragma Inline (Reference);
function Constant_Reference
(Container : aliased Map;
Key : Key_Type) return Constant_Reference_Type;
pragma Inline (Constant_Reference);
function Reference
(Container : aliased in out Map;
Key : Key_Type) return Reference_Type;
pragma Inline (Reference);
procedure Assign (Target : in out Map; Source : Map);
function Copy (Source : Map; Capacity : Count_Type := 0) return Map;
procedure Move (Target : in out Map; Source : in out Map);
-- Clears Target (if it's not empty), and then moves (not copies) the
-- buckets array and nodes from Source to Target.
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean);
-- Conditionally inserts New_Item into the map. If Key is already in the
-- map, then Inserted returns False and Position designates the node
-- containing the existing key/element pair (neither of which is modified).
-- If Key is not already in the map, the Inserted returns True and Position
-- designates the newly-inserted node container Key and New_Item. The
-- search for the key works as follows. Hash is called to determine Key's
-- bucket; if the bucket is non-empty, then Equivalent_Keys is called to
-- compare Key to each node in that bucket. If the bucket is empty, or
-- there were no matching keys in the bucket, the search "fails" and the
-- key/item pair is inserted in the map (and Inserted returns True);
-- otherwise, the search "succeeds" (and Inserted returns False).
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
-- Attempts to insert Key into the map, performing the usual search (which
-- involves calling both Hash and Equivalent_Keys); if the search succeeds
-- (because Key is already in the map), then it raises Constraint_Error.
-- (This version of Insert is similar to Replace, but having the opposite
-- exception behavior. It is intended for use when you want to assert that
-- Key is not already in the map.)
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
-- Attempts to insert Key into the map. If Key is already in the map, then
-- both the existing key and element are assigned the values of Key and
-- New_Item, respectively. (This version of Insert only raises an exception
-- if cursor tampering occurs. It is intended for use when you want to
-- insert the key/element pair in the map, and you don't care whether Key
-- is already present.)
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
-- Searches for Key in the map; if the search fails (because Key was not in
-- the map), then it raises Constraint_Error. Otherwise, both the existing
-- key and element are assigned the values of Key and New_Item rsp. (This
-- is similar to Insert, but with the opposite exception behavior. It is
-- intended for use when you want to assert that Key is already in the
-- map.)
procedure Exclude (Container : in out Map; Key : Key_Type);
-- Searches for Key in the map, and if found, removes its node from the map
-- and then deallocates it. The search works as follows. The operation
-- calls Hash to determine the key's bucket; if the bucket is not empty, it
-- calls Equivalent_Keys to compare Key to each key in the bucket. (This is
-- the deletion analog of Include. It is intended for use when you want to
-- remove the item from the map, but don't care whether the key is already
-- in the map.)
procedure Delete (Container : in out Map; Key : Key_Type);
-- Searches for Key in the map (which involves calling both Hash and
-- Equivalent_Keys). If the search fails, then the operation raises
-- Constraint_Error. Otherwise it removes the node from the map and then
-- deallocates it. (This is the deletion analog of non-conditional
-- Insert. It is intended for use when you want to assert that the item is
-- already in the map.)
procedure Delete (Container : in out Map; Position : in out Cursor);
-- Removes the node designated by Position from the map, and then
-- deallocates the node. The operation calls Hash to determine the bucket,
-- and then compares Position to each node in the bucket until there's a
-- match (it does not call Equivalent_Keys).
function First (Container : Map) return Cursor;
-- Returns a cursor that designates the first non-empty bucket, by
-- searching from the beginning of the buckets array.
function Next (Position : Cursor) return Cursor;
-- Returns a cursor that designates the node that follows the current one
-- designated by Position. If Position designates the last node in its
-- bucket, the operation calls Hash to compute the index of this bucket,
-- and searches the buckets array for the first non-empty bucket, starting
-- from that index; otherwise, it simply follows the link to the next node
-- in the same bucket.
procedure Next (Position : in out Cursor);
-- Equivalent to Position := Next (Position)
function Find (Container : Map; Key : Key_Type) return Cursor;
-- Searches for Key in the map. Find calls Hash to determine the key's
-- bucket; if the bucket is not empty, it calls Equivalent_Keys to compare
-- Key to each key in the bucket. If the search succeeds, Find returns a
-- cursor designating the matching node; otherwise, it returns No_Element.
function Contains (Container : Map; Key : Key_Type) return Boolean;
-- Equivalent to Find (Container, Key) /= No_Element
function Element (Container : Map; Key : Key_Type) return Element_Type;
-- Equivalent to Element (Find (Container, Key))
function Equivalent_Keys (Left, Right : Cursor) return Boolean;
-- Returns the result of calling Equivalent_Keys with the keys of the nodes
-- designated by cursors Left and Right.
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean;
-- Returns the result of calling Equivalent_Keys with key of the node
-- designated by Left and key Right.
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean;
-- Returns the result of calling Equivalent_Keys with key Left and the node
-- designated by Right.
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor));
-- Calls Process for each node in the map
function Iterate (Container : Map)
return Map_Iterator_Interfaces.Forward_Iterator'class;
private
pragma Inline ("=");
pragma Inline (Length);
pragma Inline (Is_Empty);
pragma Inline (Clear);
pragma Inline (Key);
pragma Inline (Element);
pragma Inline (Move);
pragma Inline (Contains);
pragma Inline (Capacity);
pragma Inline (Reserve_Capacity);
pragma Inline (Has_Element);
pragma Inline (Equivalent_Keys);
pragma Inline (Next);
type Node_Type;
type Node_Access is access Node_Type;
type Key_Access is access Key_Type;
type Element_Access is access all Element_Type;
type Node_Type is limited record
Key : Key_Access;
Element : Element_Access;
Next : Node_Access;
end record;
package HT_Types is
new Hash_Tables.Generic_Hash_Table_Types (Node_Type, Node_Access);
type Map is new Ada.Finalization.Controlled with record
HT : HT_Types.Hash_Table_Type;
end record with Put_Image => Put_Image;
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Map);
overriding procedure Adjust (Container : in out Map);
overriding procedure Finalize (Container : in out Map);
use HT_Types, HT_Types.Implementation;
use Ada.Finalization;
use Ada.Streams;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Map);
for Map'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Map);
for Map'Read use Read;
type Map_Access is access all Map;
for Map_Access'Storage_Size use 0;
type Cursor is record
Container : Map_Access;
-- Access to this cursor's container
Node : Node_Access;
-- Access to the node pointed to by this cursor
Position : Hash_Type := Hash_Type'Last;
-- Position of the node in the buckets of the container. If this is
-- equal to Hash_Type'Last, then it will not be used. Position is
-- not requried by the implementation, but improves the efficiency
-- of various operations.
--
-- However, this value must be maintained so that the predefined
-- equality operation acts as required by RM A.18.4-18/2, which
-- states: "The predefined "=" operator for type Cursor returns True
-- if both cursors are No_Element, or designate the same element
-- in the same container."
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
subtype Reference_Control_Type is Implementation.Reference_Control_Type;
-- It is necessary to rename this here, so that the compiler can find it
type Constant_Reference_Type
(Element : not null access constant Element_Type) is
record
Control : Reference_Control_Type :=
raise Program_Error with "uninitialized reference";
-- The RM says, "The default initialization of an object of
-- type Constant_Reference_Type or Reference_Type propagates
-- Program_Error."
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type);
for Constant_Reference_Type'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type);
for Constant_Reference_Type'Read use Read;
type Reference_Type
(Element : not null access Element_Type) is
record
Control : Reference_Control_Type :=
raise Program_Error with "uninitialized reference";
-- The RM says, "The default initialization of an object of
-- type Constant_Reference_Type or Reference_Type propagates
-- Program_Error."
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type);
for Reference_Type'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type);
for Reference_Type'Read use Read;
-- Three operations are used to optimize in the expansion of "for ... of"
-- loops: the Next(Cursor) procedure in the visible part, and the following
-- Pseudo_Reference and Get_Element_Access functions. See Sem_Ch5 for
-- details.
function Pseudo_Reference
(Container : aliased Map'Class) return Reference_Control_Type;
pragma Inline (Pseudo_Reference);
-- Creates an object of type Reference_Control_Type pointing to the
-- container, and increments the Lock. Finalization of this object will
-- decrement the Lock.
function Get_Element_Access
(Position : Cursor) return not null Element_Access;
-- Returns a pointer to the element designated by Position.
Empty_Map : constant Map := (Controlled with others => <>);
No_Element : constant Cursor :=
(Container => null, Node => null, Position => Hash_Type'Last);
type Iterator is new Limited_Controlled and
Map_Iterator_Interfaces.Forward_Iterator with
record
Container : Map_Access;
end record
with Disable_Controlled => not T_Check;
overriding procedure Finalize (Object : in out Iterator);
overriding function First (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
Position : Cursor) return Cursor;
end Ada.Containers.Indefinite_Hashed_Maps;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-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. --
-- --
------------------------------------------------------------------------------
-- This package provides target dependent definitions of constant for use
-- by the GNAT.Sockets package (g-socket.ads). This package should not be
-- directly with'ed by an applications program.
-- This is the version for ia64-hp-linux-gnu
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to gen-soccon.c and re-run it on each target.
package GNAT.Sockets.Constants is
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 10; -- IPv6 address family
-----------
-- Modes --
-----------
SOCK_STREAM : constant := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
-------------------
-- Socket errors --
-------------------
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 98; -- Address already in use
EADDRNOTAVAIL : constant := 99; -- Cannot assign address
EAFNOSUPPORT : constant := 97; -- Addr family not supported
EALREADY : constant := 114; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 103; -- Connection aborted
ECONNREFUSED : constant := 111; -- Connection refused
ECONNRESET : constant := 104; -- Connection reset by peer
EDESTADDRREQ : constant := 89; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 112; -- Host is down
EHOSTUNREACH : constant := 113; -- No route to host
EINPROGRESS : constant := 115; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 106; -- Socket already connected
ELOOP : constant := 40; -- Too many symbolic lynks
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 90; -- Message too long
ENAMETOOLONG : constant := 36; -- Name too long
ENETDOWN : constant := 100; -- Network is down
ENETRESET : constant := 102; -- Disconn. on network reset
ENETUNREACH : constant := 101; -- Network is unreachable
ENOBUFS : constant := 105; -- No buffer space available
ENOPROTOOPT : constant := 92; -- Protocol not available
ENOTCONN : constant := 107; -- Socket not connected
ENOTSOCK : constant := 88; -- Operation on non socket
EOPNOTSUPP : constant := 95; -- Operation not supported
EPFNOSUPPORT : constant := 96; -- Unknown protocol family
EPROTONOSUPPORT : constant := 93; -- Unknown protocol
EPROTOTYPE : constant := 91; -- Unknown protocol type
ESHUTDOWN : constant := 108; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 94; -- Socket type not supported
ETIMEDOUT : constant := 110; -- Connection timed out
ETOOMANYREFS : constant := 109; -- Too many references
EWOULDBLOCK : constant := 11; -- Operation would block
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 1; -- Unknown host
TRY_AGAIN : constant := 2; -- Host name lookup failure
NO_DATA : constant := 4; -- No data record for name
NO_RECOVERY : constant := 3; -- Non recoverable errors
-------------------
-- Control flags --
-------------------
FIONBIO : constant := 21537; -- Set/clear non-blocking io
FIONREAD : constant := 21531; -- How many bytes to read
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 1; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := 128; -- Send end of record
MSG_WAITALL : constant := 256; -- Wait for full reception
MSG_NOSIGNAL : constant := 16384; -- No SIGPIPE on send
MSG_Forced_Flags : constant := MSG_NOSIGNAL;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 2; -- Bind reuse local address
SO_KEEPALIVE : constant := 9; -- Enable keep-alive msgs
SO_LINGER : constant := 13; -- Defer close to flush data
SO_BROADCAST : constant := 6; -- Can send broadcast msgs
SO_SNDBUF : constant := 7; -- Set/get send buffer size
SO_RCVBUF : constant := 8; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 21; -- Emission timeout
SO_RCVTIMEO : constant := 20; -- Reception timeout
SO_ERROR : constant := 4; -- Get/clear error status
IP_MULTICAST_IF : constant := 32; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 33; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 34; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 35; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 36; -- Leave a multicast group
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 8; -- tv_sec
SIZEOF_tv_usec : constant := 8; -- tv_usec
end GNAT.Sockets.Constants;
|
-- Copyright 2010-2021 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
Last_Node_Id : Node_Id := Node_Id'First;
function Pn (N : Node_Id) return Node_Id is
begin
Last_Node_Id := N;
return N;
end Pn;
end Pck;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
generic
type Enum is (<>);
package League.Holders.Generic_Enumerations is
pragma Preelaborate;
Value_Tag : constant Tag;
function Element (Self : Holder) return Enum;
-- Returns internal value.
procedure Replace_Element (Self : in out Holder; To : Enum);
-- Set value. Tag of the value must be set before this call.
function To_Holder (Item : Enum) return Holder;
-- Creates new Value from specified value.
private
type Enumeration_Container is new Abstract_Container with record
Value : Enum;
end record;
overriding function Constructor
(Is_Empty : not null access Boolean) return Enumeration_Container;
Value_Tag : constant Tag := Tag (Enumeration_Container'Tag);
end League.Holders.Generic_Enumerations;
|
-- Copyright 2018-2021 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
function Ident (S : String) return String is
begin
return S;
end Ident;
end Pck;
|
-- The MIT License (MIT)
-- Copyright (c) 2015 Pavel Zhukov <landgraf@fedoraproject.org>
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Nanomsg.Domains;
with Nanomsg.Pubsub;
with Aunit.Assertions;
with Nanomsg.Messages;
package body Nanomsg.Test_Pub_Sub is
procedure Run_Test (T : in out TC) is
use Aunit.Assertions;
Address : constant String := "tcp://127.0.0.1:5555";
Subscribe : constant String := "HELPME" ;
Publish : constant String := "HELPME: Hello world";
Not_Publish : constant String := "XHELPME: You shouldn't see that";
Publish_Message : Nanomsg.Messages.Message_T;
Not_Publish_Message : Nanomsg.Messages.Message_T;
Finished : Boolean := False with Volatile;
task Sender is
entry Start;
end Sender;
task body Sender is
begin
accept Start;
while not Finished loop
Nanomsg.Socket.Send (T.Server, Publish_Message);
Nanomsg.Socket.Send (T.Server, Not_Publish_Message);
delay 0.1;
end loop;
end Sender;
begin
Nanomsg.Messages.From_String (Publish_Message, Publish);
Nanomsg.Messages.From_String (Not_Publish_Message, Not_Publish);
Nanomsg.Socket.Init (T.Server, Nanomsg.Domains.Af_Sp, Nanomsg.Pubsub.Nn_PUB);
Nanomsg.Socket.Init (T.Client, Nanomsg.Domains.Af_Sp, Nanomsg.Pubsub.Nn_SUB);
Assert (Condition => not T.Server.Is_Null, Message => "Failed to initialize socket1");
Assert (Condition => not T.Client.Is_Null, Message => "Failed to initialize socket2");
Assert (Condition => T.Server.Get_Fd /= T.Client.Get_Fd,
Message => "Descriptors collision!");
Nanomsg.Socket.Bind (T.Server, "tcp://*:5555");
Sender.Start;
Nanomsg.Pubsub.Subscribe (T.Client, Subscribe);
Nanomsg.Socket.Connect (T.Client, Address);
declare
Msg : Nanomsg.Messages.Message_T;
begin
for X in 1 .. 100 loop
select
delay 2.0;
Assert (False, "Aborted by timeout");
Finished := True;
then abort
T.Client.Receive (Msg);
declare
Text : constant String := Msg.Text;
begin
Assert (Text (Text'First .. Subscribe'Length) = Subscribe, "Received not subscribed!");
end;
end select;
end loop;
Finished := True;
end;
end Run_Test;
function Name (T : TC) return Message_String is
begin
return Aunit.Format ("Test case name : Publisher/Subsriber test");
end Name;
procedure Tear_Down (T : in out Tc) is
begin
if T.Server.Get_Fd >= 0 then
T.Server.Close;
end if;
if T.Client.Get_Fd >= 0 then
T.Client.Close;
end if;
end Tear_Down;
end Nanomsg.Test_Pub_Sub;
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Fixed;
with Ada.Text_IO;
with Ada.Streams.Stream_IO;
with Ada.Assertions;
with Ada.Directories;
with Ada.Environment_Variables;
with Platform_Info;
with Registrar.Queries;
with Registrar.Registration;
with Registrar.Subsystems;
with Registrar.Library_Units;
with Workers, Workers.Reporting;
with Child_Processes.Path_Searching;
package body Build.Linking is
New_Line: Character renames Workers.Reporting.New_Line;
procedure Assert (Check: Boolean; Message: in String)
renames Ada.Assertions.Assert;
package Program_Paths renames Child_Processes.Path_Searching;
Binder_Program: aliased constant String
:= (Platform_Info.Toolchain_Prefix & "gnatbind");
Binder: constant Program_Paths.Elaboration_Path_Search
:= Program_Paths.Initialize (Binder_Program);
Linker_Program: aliased constant String
:= Platform_Info.Toolchain_Prefix & "gcc";
Linker: constant Program_Paths.Elaboration_Path_Search
:= Program_Paths.Initialize (Linker_Program);
Archiver_Program: aliased constant String
:= Platform_Info.Toolchain_Prefix & "ar";
Archiver: constant Program_Paths.Elaboration_Path_Search
:= Program_Paths.Initialize (Archiver_Program);
--
-- Scan_ALI_Order
--
type Scan_ALI_Order is new Workers.Work_Order with
record
Target: Registrar.Library_Units.Library_Unit;
end record;
overriding function Image (Order: Scan_ALI_Order) return String;
overriding procedure Execute (Order: in out Scan_ALI_Order);
-----------
-- Image --
-----------
function Image (Order: Scan_ALI_Order) return String is
("[Scan_ALI_Order] (Build.Scan_Linker_Options)" & New_Line
& "Target: " & Order.Target.Name.To_UTF8_String);
-------------
-- Execute --
-------------
procedure Execute (Order: in out Scan_ALI_Order) is
use Ada.Text_IO;
use Registrar.Library_Units;
-- Avoid using the secondary stack, for efficincy
Buffer: String (1 .. 1920);
Last : Natural;
ALI_File: File_Type;
begin
pragma Assert (Order.Target.State = Compiled);
-- Skip units that are not Ada Library Units
if Order.Target.Kind not in Package_Unit | Subprogram_Unit then
return;
end if;
Open (File => ALI_File,
Mode => In_File,
Name => ALI_File_Name (Order.Target));
-- Fairly simple operation. We'll keep going until we hit the end of the
-- file, scanning each line. Linker option lines start with 'L', and then
-- a space, and then a quote-enclosed string. We simply take those strings,
-- strip the quotes, and slap them onto the queue
while not End_Of_File (ALI_File) loop
Get_Line (File => ALI_File,
Item => Buffer,
Last => Last);
if Last > Buffer'First
-- if Last = Item'First, we definately don't want it anyways
and then Buffer(1) = 'L'
then
pragma Assert (Buffer(3) = '"');
pragma Assert (Buffer(Last) = '"');
Linker_Options.Enqueue
(UBS.To_Unbounded_String (Buffer(4 .. Last - 1)));
-- L "option"
-- ^....^
-- 1234.....Last
end if;
end loop;
Close (ALI_File);
exception
when others =>
if Is_Open (ALI_File) then Close (ALI_File); end if;
raise;
end Execute;
-------------------------
-- Scan_Linker_Options --
-------------------------
procedure Scan_Linker_Options
(Unit_Set: in Registrar.Library_Units.Library_Unit_Sets.Set)
is
use Registrar.Library_Units;
New_Order: Scan_ALI_Order := (Tracker => Scan_Progress'Access,
others => <>);
begin
Scan_Progress.Increase_Total_Items_By (Natural (Unit_Set.Length));
for Unit of Unit_Set loop
New_Order.Target := Unit;
Workers.Enqueue_Order (New_Order);
end loop;
end Scan_Linker_Options;
----------
-- Bind --
----------
procedure Bind
(Unit_Set : in Registrar.Library_Units.Library_Unit_Sets.Set;
Configuration: in Build_Configuration;
Errors : out UBS.Unbounded_String)
is
use UBS;
use Registrar.Library_Units;
use type Ada.Containers.Count_Type;
Need_GNARL: Boolean := False;
-- GNAT-specific. GNARL is the tasting part of the Ada runtime. Not
-- all programs need this, and those that do also need pthreads
Args: Unbounded_String;
Bind_Output: Unbounded_String;
begin
pragma Assert (Configuration.Mode in Library | Image);
pragma Assert
(if Unit_Set.Length = 1 then
Configuration.Mode = Image
and then Unit_Set(Unit_Set.First).Kind = Subprogram_Unit);
pragma Assert (for all Unit of Unit_Set =>
Unit.Kind in Package_Unit | Subprogram_Unit);
-- Verify that we have a binder
if not Program_Paths.Found (Binder) then
raise Program_Error with
"Bind failed: Could not find the binder program ("
& Binder_Program & ").";
end if;
-- Generate the binder file
-- Switches first
Set_Unbounded_String (Args, "-x -o ada_main.adb");
if Configuration.Mode = Library then
Append (Args, " -n");
elsif Unit_Set.Length > 1 then
Append (Args, " -z");
end if;
if Configuration.Linking in Static | Static_RT then
Append (Args, " -static");
else
Append (Args, " -shared");
end if;
-- Now add the unit ALI file names
for Unit of Unit_Set loop
Append (Args, ' ' & ALI_File_Name (Unit));
end loop;
-- Keep a record of our command
declare
use Ada.Text_IO;
Path: constant String := Build_Output_Root & "/ada_main.binder.cmd";
CMD_OUT: File_Type;
begin
if Ada.Directories.Exists (Path) then
Open (File => CMD_OUT,
Mode => Out_File,
Name => Path);
else
Create (File => CMD_OUT,
Name => Path);
end if;
Put_Line (CMD_OUT, "Binder used:");
Put_Line (CMD_OUT, Program_Paths.Image_Path (Binder));
Put_Line (CMD_OUT, "Arguments used:");
Put_Line (CMD_OUT, To_String (Args));
Close (CMD_OUT);
end;
-- Execute
declare
use Child_Processes;
Bind_Process: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Binder),
Arguments => To_String (Args),
Working_Directory => Build_Root);
Timed_Out: Boolean;
Status : Exit_Status;
Output : Unbounded_String;
begin
Output := Null_Unbounded_String;
Wait_And_Buffer (Process => Bind_Process,
Poll_Rate => 0.1,
Timeout => 300.0,
Output => Output,
Error => Errors,
Timed_Out => Timed_Out,
Status => Status);
if Timed_Out then
Bind_Process.Kill;
Append (Errors, " [TIMED OUT]");
elsif Status = Failure or else Length (Errors) > 0 then
if Length (Errors) = 0 then
Append (Errors, "[No error output]");
end if;
return;
end if;
end;
-- Successful. Errors is empty.
-- Complete by entering the outputed binder unit
declare
use Ada.Directories;
Search : Search_Type;
Unit_Source: Directory_Entry_Type;
begin
Start_Search (Search => Search,
Directory => Build_Root,
Pattern => "ada_main.ad*");
-- We are expecting exactly two entries
for I in 1 .. 2 loop
if not More_Entries (Search) then
Set_Unbounded_String
(Errors, "Could not find the expected binder output.");
return;
end if;
Get_Next_Entry (Search => Search,
Directory_Entry => Unit_Source);
Registrar.Registration.Enter_Unit (Unit_Source);
end loop;
if More_Entries (Search) then
Set_Unbounded_String (Errors, "Unexpected binder artifacts.");
return;
end if;
End_Search (Search);
end;
end Bind;
--
-- Link Operations
--
------------------
-- Find_Ada_RTS --
------------------
-- Path to the Ada RTS
function Find_Ada_RTS return String is
-- This function is very GCC-specific. We want to find the directory
-- that contains the actual Ada Run-Time libraries (libgnat and libgnarl)
-- These always reside in the location of libgcc, within the directory
-- adalib.
use UBS;
use Ada.Directories;
use Child_Processes;
GCC_Info: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Linker),
Arguments => "-print-libgcc-file-name",
Working_Directory => Current_Directory);
Output, Error: Unbounded_String;
Timed_Out : Boolean;
Status : Exit_Status;
begin
Wait_And_Buffer (Process => GCC_Info,
Poll_Rate => 0.01, -- Expected to be quick
Timeout => 1.0, -- Generous
Output => Output,
Error => Error,
Timed_Out => Timed_Out,
Status => Status);
Assert (Check => not Timed_Out,
Message => "gcc timed out unexpectedly.");
Assert (Check => Status = Success and then Length (Error) = 0,
Message => "gcc failed unexpectedly.");
-- Output now consists of a "full name" to 'libgcc.a'. The containing
-- directory of that file contains a directory "adalib", which is what
-- we need to return
return Containing_Directory (To_String (Output)) & "/adalib";
end Find_Ada_RTS;
-----------------
-- Needs_GNARL --
-----------------
-- GNAT-specific. Scans the binder body file looking for the presence of
-- "-lgnarl"
function Needs_GNARL return Boolean is
use Ada.Text_IO;
File: File_Type;
Test: Character;
In_Section : Boolean := False;
Section_Test : constant String := "-- BEGIN Object file/option list";
Section_Test_Depth: Positive := Section_Test'First;
GNARL_Test : constant String := "-lgnarl";
GNARL_Test_Depth: Positive := GNARL_Test'First;
begin
Open (File => File,
Mode => In_File,
Name => Build_Root & "/ada_main.adb");
while not End_Of_File (File) loop
Get (File, Test);
if not In_Section then
if Test = Section_Test(Section_Test_Depth) then
if Section_Test_Depth = Section_Test'Last then
In_Section := True;
else
Section_Test_Depth := Section_Test_Depth + 1;
end if;
else
Section_Test_Depth := Section_Test'First;
end if;
else
if Test = GNARL_Test(GNARL_Test_Depth) then
if GNARL_Test_Depth = GNARL_Test'Last then
Close (File);
return True;
else
GNARL_Test_Depth := GNARL_Test_Depth + 1;
end if;
else
GNARL_Test_Depth := GNARL_Test'First;
end if;
end if;
end loop;
-- End of file and we didn't find any -lgnarl
Close (File);
Assert (In_Section, "Could not find option list in binder source.");
return False;
exception
when Name_Error =>
raise Name_Error with "Binder source was not found";
end Needs_GNARL;
------------------------
-- Add_Linker_Options --
------------------------
-- A generalized procedure for adding all the various linker options that
-- would be shared between image and library linking
procedure Add_Linker_Options (Configuration: in Build_Configuration;
Args : in out UBS.Unbounded_String)
is
use UBS;
begin
-- Debug options
if Configuration.Debug_Enabled then
Append (Args, " -g");
end if;
-- User-defined linker options
declare
Option: UBS.Unbounded_String;
begin
loop
select
Linker_Options.Dequeue (Option);
else
exit;
end select;
Append (Args, ' ' & UBS.To_String (Option));
end loop;
end;
-- The following options really only apply when we are linking some kind
-- of final elf "image" - either an executable or a shared library.
--
-- For archives (static libraries), we don't want to include these
-- options in "linker options" output provided along-side the archive
if Configuration.Mode in Image | Systemize
or else (Configuration.Mode = Library
and then Configuration.Linking = Static)
then
-- Initial set-up depending on the linking mode
case Configuration.Linking is
when Shared =>
Append (Args, " -shared-libgcc -shared");
-- Only if we are actually creating an executable (image),
-- should we add the pie/no-pie flags
if Configuration.Mode = Image then
if Configuration.Position_Independent then
Append (Args, " -pie");
else
Append (Args, " -no-pie");
end if;
end if;
when Static_RT =>
Append (Args, " -static-libgcc");
when Static =>
Append (Args, " -static-libgcc");
if Configuration.Position_Independent then
Append (Args, " -static-pie");
else
Append (Args, " -static");
end if;
end case;
-- If we are building a shared library, we will add in the
-- initialization and finalization symbols to cause elaboration of the
-- Ada code via the binder program.
if Configuration.Mode = Library
and then Configuration.Linking = Shared
then
Append (Args, " -Wl,-init=adainit,-fini=adafinal");
end if;
end if;
-- Now all the user libraries
for Subsys of Registrar.Queries.Available_Subsystems loop
for Lib_Pair of Subsys.Configuration.External_Libraries loop
Append (Args, " -l" & To_String (Lib_Pair.Value));
end loop;
end loop;
end Add_Linker_Options;
-----------------
-- Add_Runtime --
-----------------
-- Adds the appropriate libraries or archives for the Ada runtime. This
-- must come after the object list in the case of a static rt
--
-- For_Archive is set true when building the linker option outbut for
-- static archive library builds. This causes only the libgnat and
-- libgnarl objects to be rolled into the archive
procedure Add_Static_Runtime_Archives
(Configuration: in Build_Configuration;
Args : in out UBS.Unbounded_String;
GNARL : in Boolean := Needs_GNARL;
RTS_Dir : in String := Find_Ada_RTS)
is
-- Add_Static_Runtime_Archives specifically adds the actual archives
-- for the static version of the Ada runtime. This subprogram is used
-- both by Add_Runtime and Archive.
--
-- Add_Runtime uses it to pass to the linker, while Archive uses it
-- to include the static runtime archives in the final archive object
begin
if GNARL then
UBS.Append (Args, ' ' & RTS_Dir
& (if Configuration.Position_Independent then
"/libgnarl_pic.a"
else
"/libgnarl.a"));
end if;
UBS.Append (Args, ' ' & RTS_DIR
& (if Configuration.Position_Independent then
"/libgnat_pic.a"
else
"/libgnat.a"));
end;
----------------------------------------------------------------------
procedure Add_Runtime (Configuration: in Build_Configuration;
Args : in out UBS.Unbounded_String)
is
use UBS;
RTS_Dir: constant String := Find_Ada_RTS;
GNARL : constant Boolean := Needs_GNARL;
-- Note in theory, there should be only one link per run of AURA, so it
-- is perfectly fine to elaborate these locally, since it will only
-- happen once anyways.
begin
if GNARL and then Platform_Info.Platform_Family = "unix" then
Append (Args, " -pthread");
end if;
case Configuration.Linking is
when Shared =>
Append (Args, " -L" & RTS_Dir);
Append (Args, " -lgnat");
if GNARL then
Append (Args, " -lgnarl");
end if;
when Static_RT | Static =>
Add_Static_Runtime_Archives (Configuration, Args, GNARL, RTS_Dir);
end case;
end Add_Runtime;
----------------
-- Link_Image --
----------------
procedure Link_Image
(Image_Path : in String;
Unit_Set : in Registrar.Library_Units.Library_Unit_Sets.Set;
Configuration: in Build_Configuration;
Errors : out UBS.Unbounded_String)
is
use UBS;
use Child_Processes;
Args: Unbounded_String;
begin
-- Verify that we can find the Linker
if not Program_Paths.Found (Binder) then
raise Program_Error with
"Link failed: Could not find the linker program ("
& Linker_Program & ").";
end if;
if Image_Path'Length = 0 then
raise Constraint_Error with "Attempt to link without an image path";
end if;
Set_Unbounded_String (Args, "-o " & Image_Path);
Add_Linker_Options (Configuration, Args);
-- Add linker options
-- Then the objects
declare
use Ada.Directories;
use Registrar.Library_Units;
begin
for Unit of Unit_Set loop
if Unit.Kind not in Unknown | Subunit then
Append (Args, ' ' & Simple_Name (Object_File_Name (Unit)));
-- We use Simple_Name and then execute the linker from the
-- aura-build subdirectory to avoid any problems with
-- overwhelming the arguments of the linker with long path-names
-- for each object. It's also a bit nicer to look at when
-- debugging
end if;
end loop;
end;
-- Finally the Ada Runtime
Add_Runtime (Configuration, Args);
-- Record the command
declare
use Ada.Text_IO;
Path: constant String := Build_Output_Root & "/ada_main.linker.cmd";
CMD_OUT: File_Type;
begin
if Ada.Directories.Exists (Path) then
Open (File => CMD_OUT,
Mode => Out_File,
Name => Path);
else
Create (File => CMD_OUT,
Name => Path);
end if;
Put_Line (CMD_OUT, "Linker used:");
Put_Line (CMD_OUT, Program_Paths.Image_Path (Linker));
Put_Line (CMD_OUT, "Arguments used:");
Put_Line (CMD_OUT, To_String (Args));
Close (CMD_OUT);
end;
-- Execute
declare
use Child_Processes;
Link_Process: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Linker),
Arguments => To_String (Args),
Working_Directory => Build_Root);
Discard : Unbounded_String;
Timed_Out: Boolean;
Status : Exit_Status;
begin
Wait_And_Buffer (Process => Link_Process,
Poll_Rate => 0.1,
Timeout => 300.0,
Output => Discard,
Error => Errors,
Timed_Out => Timed_Out,
Status => Status);
if Timed_Out then
Link_Process.Kill;
Append (Errors, " [TIMED OUT]");
elsif Status = Failure and then Length (Errors) = 0 then
Set_Unbounded_String (Errors, "[No error output]");
end if;
end;
end Link_Image;
-------------
-- Archive --
-------------
procedure Archive
(Archive_Path : in String;
Unit_Set : in Registrar.Library_Units.Library_Unit_Sets.Set;
Configuration: in Build_Configuration;
Errors : out UBS.Unbounded_String)
is
Args: UBS.Unbounded_String := UBS.To_Unbounded_String
("-rc " & Archive_Path & ' ');
GNARL : constant Boolean := Needs_GNARL;
RTS_Dir: constant String := Find_Ada_RTS;
procedure Output_Linker_Options is
use Ada.Strings.Fixed;
use Ada.Text_IO;
use all type Ada.Strings.Direction;
Linker_Options: UBS.Unbounded_String;
LO_File: File_Type;
Extension_Start: constant Natural := Index (Source => Archive_Path,
Pattern => ".",
Going => Backward);
Path: constant String
:= Archive_Path (Archive_Path'First .. Extension_Start)
& "linkopt";
begin
if Extension_Start < Archive_Path'First then
-- This will likely be checked by the command processor,
-- but this is such a cheap check to make, why not
raise Constraint_Error with
"Library archive path shall have an extension.";
end if;
if GNARL and then Platform_Info.Platform_Family = "unix" then
UBS.Append (Linker_Options, " -pthread");
end if;
Add_Linker_Options (Configuration, Linker_Options);
if Ada.Directories.Exists (Path) then
Open (File => LO_File,
Mode => Out_File,
Name => Path);
else
Create (File => LO_File,
Mode => Out_File,
Name => Path);
end if;
Put_Line (File => LO_File, Item => UBS.To_String (Linker_Options));
Close (LO_File);
end;
begin
pragma Assert (Configuration.Mode = Library);
-- Verify that we can find the Archiver
if not Program_Paths.Found (Archiver) then
raise Program_Error with
"Archive failed: Could not find the archiver program ("
& Archiver_Program & ").";
end if;
declare
use Ada.Directories;
use Registrar.Library_Units;
begin
for Unit of Unit_Set loop
if Unit.Kind not in Unknown | Subunit then
UBS.Append (Args, ' ' & Simple_Name (Object_File_Name (Unit)));
-- We use Simple_Name and then execute the linker from the
-- aura-build subdirectory to avoid any problems with
-- overwhelming the arguments of the linker with long path-names
-- for each object. It's also a bit nicer to look at when
-- debugging
end if;
end loop;
end;
-- Add the Ada runtime archives
Add_Static_Runtime_Archives (Configuration, Args, GNARL, RTS_Dir);
-- Record the command
declare
use Ada.Text_IO;
Path: constant String := Build_Output_Root & "/ada_main.archiver.cmd";
CMD_OUT: File_Type;
begin
if Ada.Directories.Exists (Path) then
Open (File => CMD_OUT,
Mode => Out_File,
Name => Path);
else
Create (File => CMD_OUT,
Name => Path);
end if;
Put_Line (CMD_OUT, "Archiver used:");
Put_Line (CMD_OUT, Program_Paths.Image_Path (Archiver));
Put_Line (CMD_OUT, "Arguments used:");
Put_Line (CMD_OUT, UBS.To_String (Args));
Close (CMD_OUT);
end;
-- Execute
declare
use Child_Processes;
Archive_Process: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Archiver),
Arguments => UBS.To_String (Args),
Working_Directory => Build_Root);
Discard : UBS.Unbounded_String;
Timed_Out: Boolean;
Status : Exit_Status;
begin
Wait_And_Buffer (Process => Archive_Process,
Poll_Rate => 0.1,
Timeout => 60.0,
Output => Discard,
Error => Errors,
Timed_Out => Timed_Out,
Status => Status);
if Timed_Out then
Archive_Process.Kill;
UBS.Append (Errors, " [TIMED OUT]");
elsif Status = Success then
Output_Linker_Options;
elsif Status = Failure and then UBS.Length (Errors) = 0 then
UBS.Set_Unbounded_String (Errors, "[No error output]");
end if;
end;
end Archive;
---------------------
-- Link_Subsystems --
---------------------
procedure Link_Subsystems is
begin
-- TODO
raise Program_Error with "Not implemented";
end Link_Subsystems;
end Build.Linking;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . C O N C A T _ 9 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2008-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains a procedure for runtime concatenation of eight string
-- operands. It is used when we want to save space in the generated code.
pragma Compiler_Unit_Warning;
package System.Concat_9 is
procedure Str_Concat_9
(R : out String;
S1, S2, S3, S4, S5, S6, S7, S8, S9 : String);
-- Performs the operation R := S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9.
-- The bounds of R are known to be correct (usually set by a call to the
-- Str_Concat_Bounds_9 procedure below), so no bounds checks are required,
-- and it is known that none of the input operands overlaps R. No
-- assumptions can be made about the lower bounds of any of the operands.
procedure Str_Concat_Bounds_9
(Lo, Hi : out Natural;
S1, S2, S3, S4, S5, S6, S7, S8, S9 : String);
-- Assigns to Lo..Hi the bounds of the result of concatenating the nine
-- given strings, following the rules in the RM regarding null operands.
end System.Concat_9;
|
-- Concurrency can be offered by the OS, the language, or a combination
-- Link to some papers that say that threading can't be a library.
-- Ousterhout has an interesting paper here that shows that you can't guarantee pthreads correctness.
-- Processes offer protection but are too heavy-weight.
-- Compiler must take care of low-level thread management, as opposed to RTOS
with Ada.Text_IO;
procedure Tasking is
-- Specification of nested task
task HelloTask;
task body HelloTask is
begin
-- Task body begins executing as soon as Tasking starts
for idx in 1 .. 5 loop
Ada.Text_IO.Put_Line("The task says hello.");
delay 1.0;
end loop;
end HelloTask;
begin
Ada.Text_IO.Put_Line("Starting Program!");
-- Tasking ends when both the body and task have ended
-- Task must terminate
end Tasking;
|
-----------------------------------------------------------------------
-- keystore-passwords -- Password provider
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Keystore.Passwords is
type Provider is limited interface;
type Provider_Access is access all Provider'Class;
-- Get the password through the Getter operation.
procedure Get_Password (From : in Provider;
Getter : not null
access procedure (Password : in Secret_Key)) is abstract;
subtype Tag_Type is Interfaces.Unsigned_32;
type Slot_Provider is limited interface and Provider;
function Get_Tag (From : in Slot_Provider) return Tag_Type is abstract;
function Has_Password (From : in Slot_Provider) return Boolean is abstract;
procedure Next (From : in out Slot_Provider) is abstract;
-- Get the key and IV through the Getter operation.
procedure Get_Key (From : in Slot_Provider;
Getter : not null access procedure (Key : in Secret_Key;
IV : in Secret_Key)) is abstract;
procedure To_Provider (Secret : in Secret_Key;
Process : not null access procedure (P : in out Provider'Class));
private
type Internal_Key_Provider is limited interface;
procedure Save_Key (Provider : in Internal_Key_Provider;
Data : out Ada.Streams.Stream_Element_Array) is abstract;
type Default_Provider (Len : Key_Length) is limited new Provider with record
Password : Keystore.Secret_Key (Len);
end record;
type Default_Provider_Access is access all Default_Provider'Class;
-- Get the password through the Getter operation.
overriding
procedure Get_Password (From : in Default_Provider;
Getter : not null access procedure (Password : in Secret_Key));
-- Create a password provider.
function Create (Password : in out Ada.Streams.Stream_Element_Array) return Provider_Access;
end Keystore.Passwords;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_20.Main is
begin
Put_Line ("Day-20");
end Adventofcode.Day_20.Main;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- S Y S T E M . A S S E R T I O N S --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions;
package body System.Assertions is
--------------------------
-- Raise_Assert_Failure --
--------------------------
procedure Raise_Assert_Failure (Msg : String) is
begin
Ada.Exceptions.Raise_Exception (Assert_Failure'Identity, Msg);
end Raise_Assert_Failure;
end System.Assertions;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (VxWorks e500 AE653 vThreads) --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This version is for the AE653/e500v2 vThreads full run-time
package System is
pragma Pure;
-- Note that we take advantage of the implementation permission to make
-- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
-- 2005, this is Pure in any case (AI-362).
pragma No_Elaboration_Code_All;
-- Allow the use of that restriction in units that WITH this unit
type Name is (SYSTEM_NAME_GNAT);
System_Name : constant Name := SYSTEM_NAME_GNAT;
-- System-Dependent Named Numbers
Min_Int : constant := -2 ** (Standard'Max_Integer_Size - 1);
Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1;
Max_Binary_Modulus : constant := 2 ** Standard'Max_Integer_Size;
Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
Max_Base_Digits : constant := Long_Long_Float'Digits;
Max_Digits : constant := Long_Long_Float'Digits;
Max_Mantissa : constant := 63;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 1.0 / 60.0;
-- Storage-related Declarations
type Address is private;
pragma Preelaborable_Initialization (Address);
Null_Address : constant Address;
Storage_Unit : constant := 8;
Word_Size : constant := 32;
Memory_Size : constant := 2 ** 32;
-- Address comparison
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
-- Other System-Dependent Declarations
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := High_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
-- Ada priorities are mapped to VxWorks priorities using the following
-- transformation: 255 - Ada Priority
-- Ada priorities are used as follows:
-- 256 is reserved for the VxWorks kernel
-- 248 - 255 correspond to hardware interrupt levels 0 .. 7
-- 247 is a catchall default "interrupt" priority for signals,
-- allowing higher priority than normal tasks, but lower than
-- hardware priority levels. Protected Object ceilings can
-- override these values.
-- 246 is used by the Interrupt_Manager task
Max_Priority : constant Positive := 245;
Max_Interrupt_Priority : constant Positive := 255;
subtype Any_Priority is Integer range 0 .. 255;
subtype Priority is Any_Priority range 0 .. 245;
subtype Interrupt_Priority is Any_Priority range 246 .. 255;
Default_Priority : constant Priority := 122;
private
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
--------------------------------------
-- System Implementation Parameters --
--------------------------------------
-- These parameters provide information about the target that is used
-- by the compiler. They are in the private part of System, where they
-- can be accessed using the special circuitry in the Targparm unit
-- whose source should be consulted for more detailed descriptions
-- of the individual switch values.
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := False;
Configurable_Run_Time : constant Boolean := False;
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := False;
Exit_Status_Supported : constant Boolean := True;
Fractional_Fixed_Ops : constant Boolean := False;
Frontend_Layout : constant Boolean := False;
Machine_Overflows : constant Boolean := False;
Machine_Rounds : constant Boolean := True;
Preallocated_Stacks : constant Boolean := False;
Signed_Zeros : constant Boolean := True;
Stack_Check_Default : constant Boolean := False;
Stack_Check_Probes : constant Boolean := True;
Stack_Check_Limits : constant Boolean := False;
Support_Aggregates : constant Boolean := True;
Support_Composite_Assign : constant Boolean := True;
Support_Composite_Compare : constant Boolean := True;
Support_Long_Shifts : constant Boolean := True;
Always_Compatible_Rep : constant Boolean := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := True;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := False;
Executable_Extension : constant String := ".out";
end System;
|
type Kernel_3x3 is array (-1..1, -1..1) of Float_Luminance;
procedure Filter (Picture : in out Image; K : Kernel_3x3) is
function Get (I, J : Integer) return Float_Pixel is
pragma Inline (Get);
begin
if I in Picture'Range (1) and then J in Picture'Range (2) then
declare
Color : Pixel := Picture (I, J);
begin
return (Float_Luminance (Color.R), Float_Luminance (Color.G), Float_Luminance (Color.B));
end;
else
return (others => 0.0);
end if;
end Get;
W11, W12, W13 : Float_Pixel; -- The image window
W21, W22, W23 : Float_Pixel;
W31, W32, W33 : Float_Pixel;
Above : array (Picture'First (2) - 1..Picture'Last (2) + 1) of Float_Pixel;
This : Float_Pixel;
begin
for I in Picture'Range (1) loop
W11 := Above (Picture'First (2) - 1); -- The upper row is taken from the cache
W12 := Above (Picture'First (2) );
W13 := Above (Picture'First (2) + 1);
W21 := (others => 0.0); -- The middle row
W22 := Get (I, Picture'First (2) );
W23 := Get (I, Picture'First (2) + 1);
W31 := (others => 0.0); -- The bottom row
W32 := Get (I+1, Picture'First (2) );
W33 := Get (I+1, Picture'First (2) + 1);
for J in Picture'Range (2) loop
This :=
W11 * K (-1, -1) + W12 * K (-1, 0) + W13 * K (-1, 1) +
W21 * K ( 0, -1) + W22 * K ( 0, 0) + W23 * K ( 0, 1) +
W31 * K ( 1, -1) + W32 * K ( 1, 0) + W33 * K ( 1, 1);
Above (J-1) := W21;
W11 := W12; W12 := W13; W13 := Above (J+1); -- Shift the window
W21 := W22; W22 := W23; W23 := Get (I, J+1);
W31 := W32; W32 := W23; W33 := Get (I+1, J+1);
Picture (I, J) := To_Pixel (This);
end loop;
Above (Picture'Last (2)) := W21;
end loop;
end Filter;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY COMPONENTS --
-- --
-- S Y S T E M . C O M P A R E _ A R R A Y _ S I G N E D _ 8 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2002-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains functions for runtime comparisons on arrays whose
-- elements are 8-bit discrete type values to be treated as signed.
package System.Compare_Array_Signed_8 is
-- Note: although the functions in this package are in a sense Pure, the
-- package cannot be declared as Pure, since the arguments are addresses,
-- not the data, and the result is not pure wrt the address values.
function Compare_Array_S8
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer;
-- Compare the array starting at address Left of length Left_Len
-- with the array starting at address Right of length Right_Len.
-- The comparison is in the normal Ada semantic sense of array
-- comparison. The result is -1,0,+1 for Left<Right, Left=Right,
-- Left>Right respectively. This function works with 4 byte words
-- if the operands are aligned on 4-byte boundaries and long enough.
function Compare_Array_S8_Unaligned
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer;
-- Same functionality as Compare_Array_S8 but always proceeds by
-- bytes. Used when the caller knows that the operands are unaligned,
-- or short enough that it makes no sense to go by words.
end System.Compare_Array_Signed_8;
|
package FLTK.Widgets.Valuators is
type Valuator is new Widget with private;
type Valuator_Reference (Data : not null access Valuator'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Valuator;
end Forge;
function Clamp
(This : in Valuator;
Input : in Long_Float)
return Long_Float;
function Round
(This : in Valuator;
Input : in Long_Float)
return Long_Float;
function Increment
(This : in Valuator;
Input : in Long_Float;
Step : in Integer)
return Long_Float;
function Get_Minimum
(This : in Valuator)
return Long_Float;
procedure Set_Minimum
(This : in out Valuator;
To : in Long_Float);
function Get_Maximum
(This : in Valuator)
return Long_Float;
procedure Set_Maximum
(This : in out Valuator;
To : in Long_Float);
function Get_Step
(This : in Valuator)
return Long_Float;
procedure Set_Step
(This : in out Valuator;
To : in Long_Float);
function Get_Value
(This : in Valuator)
return Long_Float;
procedure Set_Value
(This : in out Valuator;
To : in Long_Float);
procedure Set_Bounds
(This : in out Valuator;
Min, Max : in Long_Float);
procedure Set_Precision
(This : in out Valuator;
To : in Integer);
procedure Set_Range
(This : in out Valuator;
Min, Max : in Long_Float);
function Handle
(This : in out Valuator;
Event : in Event_Kind)
return Event_Outcome;
private
type Valuator is new Widget with null record;
overriding procedure Finalize
(This : in out Valuator);
pragma Inline (Clamp);
pragma Inline (Round);
pragma Inline (Increment);
pragma Inline (Get_Minimum);
pragma Inline (Set_Minimum);
pragma Inline (Get_Maximum);
pragma Inline (Set_Maximum);
pragma Inline (Get_Step);
pragma Inline (Set_Step);
pragma Inline (Get_Value);
pragma Inline (Set_Value);
pragma Inline (Set_Bounds);
pragma Inline (Set_Precision);
pragma Inline (Set_Range);
pragma Inline (Handle);
end FLTK.Widgets.Valuators;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, Fabien Chouteau --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with AGATE;
package Test_Dynamic_Tasks is
procedure Create;
function Dyamic_Semaphore return AGATE.Semaphore_ID;
end Test_Dynamic_Tasks;
|
-- Copyright 2008-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Proc (I : Integer) is
Not_In_Scope : Integer := 77;
begin
Inner.Inside_Variable := Not_In_Scope + I;
end Proc;
procedure Ambiguous_Func is
begin
null;
end Ambiguous_Func;
end Pck;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S H A 2 2 4 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2009-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package implements the SHA-224 secure hash function as described in
-- FIPS PUB 180-3. The complete text of FIPS PUB 180-3 can be found at:
-- http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf
-- See the declaration of GNAT.Secure_Hashes.H in g-sechas.ads for complete
-- documentation.
with GNAT.Secure_Hashes.SHA2_Common;
with GNAT.Secure_Hashes.SHA2_32;
with System;
package GNAT.SHA224 is new GNAT.Secure_Hashes.H
(Block_Words => GNAT.Secure_Hashes.SHA2_Common.Block_Words,
State_Words => 8,
Hash_Words => 7,
Hash_Bit_Order => System.High_Order_First,
Hash_State => GNAT.Secure_Hashes.SHA2_32.Hash_State,
Initial_State => GNAT.Secure_Hashes.SHA2_32.SHA224_Init_State,
Transform => GNAT.Secure_Hashes.SHA2_32.Transform);
|
------------------------------------------------------------------------------
-- --
-- Modular Hash Infrastructure --
-- --
-- xxHash32 --
-- --
-- Pedantic Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2021, 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 implementation follows the official xxHash algorithm specification as
-- described at https://github.com/Cyan4973/xxHash (v 0.8.0).
--
-- The specification contains the following copyright notice:
--
-- Copyright (c) Yann Collet
--
-- Permission is granted to copy and distribute this document for any purpose
-- and without charge, including translations into other languages and
-- incorporation into compilations, provided that the copyright notice and this
-- notice are preserved, and that any substantive changes or deletions from the
-- original are clearly marked. Distribution of this document is unlimited.
package body Modular_Hashing.xxHash32 is
--
-- XXH32_Hash
--
function "<" (Left, Right : XXH32_Hash) return Boolean is
(Left.Digest < Right.Digest);
function ">" (Left, Right : XXH32_Hash) return Boolean is
(Left.Digest > Right.Digest);
function "=" (Left, Right : XXH32_Hash) return Boolean is
(Left.Digest = Right.Digest);
------------
-- Binary --
------------
function Binary (Value: XXH32_Hash) return Hash_Binary_Value is
V: Accumulator_Type := Value.Digest;
begin
return Bin: Hash_Binary_Value (1 .. XXH32_Hash_Bytes) do
for Byte of Bin loop
Byte := Unsigned_8 (V and 16#FF#);
V := Shift_Right (V, 8);
end loop;
end return;
end Binary;
--
-- XXH32_Engine
--
------------------
-- Stripe_Round -- "Step 2"
------------------
-- Stripe_Round executes one full strip round (16-bytes) on the engine.
-- This consumes the entire 16-byte Buffer (which must be full)
procedure Stripe_Round (Engine: in out XXH32_Engine) with
Inline,
Pre => Engine.Last_Element = Engine.Buffer'Last
is
Lanes : Accumulator_Array;
Accumulators: Accumulator_Array renames Engine.Accumulators;
begin
-- For each lane, load the value and then run the round on the
-- accumulator. This is designed for simd, and we'll try to structure
-- this to give the compiler as much of a chance as possible to see the
-- obvious simd conditions
-- Load lanes
declare
I: Stream_Element_Offset := Engine.Buffer'First;
begin
for Lane of Lanes loop
for Byte of reverse Engine.Buffer(I .. I + 3) loop
Lane := Shift_Left (Lane, 8);
Lane := Lane + Accumulator_Type (Byte);
end loop;
I := I + 4;
end loop;
end;
for I in Lanes'Range loop
-- The actual rounds
Accumulators(I) := Accumulators(I) + (Lanes(I) * PRIME32_2);
Accumulators(I) := Rotate_Left (Accumulators(I), 13);
Accumulators(I) := Accumulators(I) * PRIME32_1;
end loop;
Engine.Last_Element := Engine.Buffer'First - 1;
end Stripe_Round;
-----------
-- Write --
-----------
procedure Write (Engine : in out XXH32_Engine;
Item : in Stream_Element_Array)
is
Last_Load: Stream_Element_Offset := Item'First - 1;
procedure Load_Round with Inline, Pre => Last_Load < Item'Last is
Buffer_Space: Stream_Element_Offset
:= Engine.Buffer'Last - Engine.Last_Element;
Load_First: constant Stream_Element_Offset := Last_Load + 1;
Load_Last : Stream_Element_Offset;
Load_Size : Stream_Element_Offset := Buffer_Space;
New_Last_Element: Stream_Element_Offset;
begin
pragma Assert (Buffer_Space > 0);
-- Load in as many bytes as we can into the buffer. If we hit 16
-- bytes, we call a Stripe_Round.
Load_Last := Load_First + Buffer_Space - 1;
if Load_Last > Item'Last then
Load_Last := Item'Last;
Load_Size := Load_Last - Load_First + 1;
end if;
New_Last_Element := Engine.Last_Element + Load_Size;
Engine.Buffer (Engine.Last_Element + 1 .. New_Last_Element)
:= Item (Load_First .. Load_Last);
Last_Load := Load_Last;
Engine.Last_Element := New_Last_Element;
if New_Last_Element = Engine.Buffer'Last then
Stripe_Round (Engine);
end if;
end;
begin
if Item'Length = 0 then return; end if;
while Last_Load < Item'Last loop
Load_Round;
end loop;
Engine.Input_Total := Engine.Input_Total + Item'Length;
end Write;
-----------
-- Reset --
-----------
procedure Reset (Engine : in out XXH32_Engine) is
begin
Engine.Last_Element := Engine.Buffer'First - 1;
Engine.Input_Total := 0;
Engine.Accumulators := Accumulators_Initial;
end Reset;
------------
-- Digest --
------------
function Digest (Engine : in out XXH32_Engine) return Hash'Class is
Lane_Accumulators: Accumulator_Array renames Engine.Accumulators;
Hash_Accumulator : Accumulator_Type;
-- Steps as per the xxHash spec
procedure Step_1_Short with Inline; -- Step 1 with < 16 byte total input
-- Step 2. Process Stripes is done in Write
procedure Step_3 with Inline; -- Accumulator Convergence
procedure Step_4 with Inline; -- Add input length
procedure Step_5 with Inline; -- Consume remaining input
procedure Step_6 with Inline; -- Final mix (avalanche)
-- Step 1 Short
procedure Step_1_Short is
-- This is invoked when Digest is called before 16 or more bytes have
-- been written to the engine
begin
Hash_Accumulator := PRIME32_5;
end;
-- Step 3: Accumulator Convergence
procedure Step_3 is begin
Hash_Accumulator
:= Rotate_Left (Lane_Accumulators(1), 1)
+ Rotate_Left (Lane_Accumulators(2), 7)
+ Rotate_Left (Lane_Accumulators(3), 12)
+ Rotate_Left (Lane_Accumulators(4), 18);
end;
-- Step 4: Add input length
procedure Step_4 is begin
Hash_Accumulator := Hash_Accumulator + Engine.Input_Total;
end;
-- Step 5: Consume remaining input
procedure Step_5 is
Lane: Accumulator_Type := 0;
Mark: Stream_Element_Offset := Engine.Buffer'First;
begin
pragma Assert (Engine.Last_Element < Engine.Buffer'Last);
while (Engine.Last_Element - Mark) >= 3 loop
-- Note that since we are shifting the lane 4 x 8bits,
-- the initial value of Lane does not matter at all,
-- so we don't need to clear it every time
for Byte of reverse Engine.Buffer (Mark .. Mark + 3) loop
Lane := Shift_Left (Lane, 8);
Lane := Lane + Accumulator_Type (Byte);
end loop;
Mark := Mark + 4;
Hash_Accumulator := Hash_Accumulator + Lane * PRIME32_3;
Hash_Accumulator := Rotate_Left (Hash_Accumulator, 17);
Hash_Accumulator := Hash_Accumulator * PRIME32_4;
end loop;
while Mark <= Engine.Last_Element loop
Lane := Accumulator_Type (Engine.Buffer(Mark));
Hash_Accumulator := Hash_Accumulator + Lane * PRIME32_5;
Hash_Accumulator := Rotate_Left (Hash_Accumulator, 11);
Hash_Accumulator := Hash_Accumulator * PRIME32_1;
Mark := Mark + 1;
end loop;
end;
-- Step 6: Final mix (avalanche)
procedure Step_6 is
Acc: Accumulator_Type renames Hash_Accumulator;
begin
Acc := Acc xor Shift_Right (Acc, 15);
Acc := Acc * PRIME32_2;
Acc := Acc xor Shift_Right (Acc, 13);
Acc := Acc * PRIME32_3;
Acc := Acc xor Shift_Right (Acc, 16);
end Step_6;
begin
if Engine.Input_Total < 16 then
-- If the total input is less than 16, we need to "manually"
-- initialize the accumulator. If we have done any rounds ("Step 2")
-- to process 16-byte "stripes", then we would use "Step 3" to
-- initialize Hash_Accumulator from the Engine's accumulators.
Hash_Accumulator := PRIME32_5;
else
-- Normal completion (Converge the engine accumulators into the hash
-- accumulator)
Step_3;
end if;
Step_4;
Step_5;
Step_6;
return XXH32_Hash'(Digest => Hash_Accumulator);
end Digest;
end Modular_Hashing.xxHash32;
|
-- Copyright 2013-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
Thread: Integer;
begin
Thread := 0;
for I in 1 .. 100 loop
Thread := Thread + I; -- STOP_HERE
end loop;
Put(Integer'Image(Thread));
end Foo;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- Based on ft5336.h from MCD Application Team
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Unchecked_Conversion;
with HAL.Touch_Panel; use HAL.Touch_Panel;
with STM32.Board; use STM32.Board;
with STM32.Device; use STM32.Device;
with FT5336; use FT5336;
package body Touch_Panel_FT5336 is
----------------
-- Initialize --
----------------
function Initialize
(This : in out Touch_Panel;
Orientation : HAL.Framebuffer.Display_Orientation :=
HAL.Framebuffer.Default)
return Boolean
is
begin
Initialize_I2C_GPIO (TP_I2C);
-- Wait at least 200ms after power up before accessing the TP registers
delay until Clock + Milliseconds (200);
Configure_I2C (TP_I2C);
This.TP_Set_Use_Interrupts (False);
This.Set_Orientation (Orientation);
return This.Check_Id;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize (This : in out Touch_Panel;
Orientation : HAL.Framebuffer.Display_Orientation :=
HAL.Framebuffer.Default) is
begin
if not This.Initialize (Orientation) then
raise Constraint_Error with "Cannot initialize the touch panel";
end if;
end Initialize;
---------------------
-- Set_Orientation --
---------------------
procedure Set_Orientation
(This : in out Touch_Panel;
Orientation : HAL.Framebuffer.Display_Orientation)
is
begin
case Orientation is
when HAL.Framebuffer.Default | HAL.Framebuffer.Landscape =>
This.Set_Bounds (LCD_Natural_Width,
LCD_Natural_Height,
0);
when HAL.Framebuffer.Portrait =>
This.Set_Bounds (LCD_Natural_Width,
LCD_Natural_Height,
Invert_Y or Swap_XY);
end case;
end Set_Orientation;
end Touch_Panel_FT5336;
|
-- { dg-do compile }
package body itypes is
Size : constant := 10;
type Arr is array (1 .. size) of Integer;
type Rec is record
Field1 : Arr := (others => 0);
Field2 : Arr := (others => 0);
Field3 : Arr := (others => 0);
Field4 : Arr := (others => 0);
Field5 : Arr := (others => 0);
Field6 : Arr := (others => 0);
Field7 : Arr := (others => 0);
end record;
procedure Proc is
Temp1 : Rec;
begin
null;
end;
end;
|
-- Copyright 2015-2020 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pack is
type Table_Type is
array (Natural range <>) of Integer;
type Table_Ptr_Type is access all Table_Type;
Table : Table_Type := (1 => 10, 2 => 20);
Table_Ptr : aliased Table_Ptr_Type := new Table_Type'(3 => 30, 4 => 40);
end Pack;
|
-------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
package body LSE.Model.Grammar.Symbol.OtherSymbol is
procedure Initialize (This : out Instance)
is
begin
This := Instance '(Representation => ' ');
end Initialize;
procedure Initialize (This : out Instance; Representation : Character)
is
begin
This := Instance '(Representation => Representation);
end Initialize;
procedure Interpret (This : in out Instance;
T : in out Holder)
is
begin
-- Nothing to do
null;
end Interpret;
end LSE.Model.Grammar.Symbol.OtherSymbol;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Utp_Elements;
with AMF.UML.Call_Operation_Actions;
with AMF.Utp.Stop_Timer_Actions;
with AMF.Visitors;
package AMF.Internals.Utp_Stop_Timer_Actions is
type Utp_Stop_Timer_Action_Proxy is
limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy
and AMF.Utp.Stop_Timer_Actions.Utp_Stop_Timer_Action with null record;
overriding function Get_Base_Call_Operation_Action
(Self : not null access constant Utp_Stop_Timer_Action_Proxy)
return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access;
-- Getter of StopTimerAction::base_CallOperationAction.
--
overriding procedure Set_Base_Call_Operation_Action
(Self : not null access Utp_Stop_Timer_Action_Proxy;
To : AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access);
-- Setter of StopTimerAction::base_CallOperationAction.
--
overriding procedure Enter_Element
(Self : not null access constant Utp_Stop_Timer_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Utp_Stop_Timer_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Utp_Stop_Timer_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Utp_Stop_Timer_Actions;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Generic_Stack;
procedure RPN_to_Infix is
-- The code above
begin
Put_Line ("3 4 2 * 1 5 - 2 3 ^ ^ / + = ");
Put_Line (Convert ("3 4 2 * 1 5 - 2 3 ^ ^ / +"));
Put_Line ("1 2 + 3 4 + ^ 5 6 + ^ = ");
Put_Line (Convert ("1 2 + 3 4 + ^ 5 6 + ^"));
end RPN_to_Infix;
|
with Ada.Unchecked_Conversion;
with Ada.Command_Line;
with Ada.Finalization;
package body GLUT is
-- finalization - free Argv strings
--
-- RK 23 - Oct - 2006, to remove the memory leak in question.
--
type Argvz is array (0 .. 500) of aliased Interfaces.C.Strings.chars_ptr;
type Arg_Type is new Ada.Finalization.Controlled with record
v : Argvz := (others => Interfaces.C.Strings.Null_Ptr);
v_Count : Natural := 0;
end record;
overriding procedure Finalize (Self : in out Arg_Type)
is
use Interfaces.C.Strings;
begin
if Self.v (0) /= Interfaces.C.Strings.Null_Ptr then
Free (Self.v (0));
end if;
for I in 1 .. Self.v_Count loop
Free (Self.v (I));
end loop;
end Finalize;
Arg : Arg_Type;
procedure Glutinit (Argcp : access Integer;
Argv : access Interfaces.C.Strings.chars_ptr);
-- pragma Import (C, Glutinit, "glutInit", "glutInit"); -- APEX
pragma Import (StdCall, Glutinit, "glutInit"); -- GNAT/OA
-- Pure Ada method, from IBM / Rational Apex support:
-- "This procedure may be a useful replacement when porting an
-- Ada program written for Gnat, which imports argc and argv like this:
-- argc : aliased integer;
-- pragma Import (C, argc, "gnat_argc");
--
-- argv : chars_ptr_ptr;
-- pragma Import (C, argv, "gnat_argv");
-- "
-- http://www - 1.ibm.com/support/docview.wss?uid=swg21125019
procedure Init is
use Ada.Command_Line;
use Interfaces.C.Strings;
Argc : aliased Integer := Argument_Count + 1;
begin
Arg.v_Count := Argument_Count;
Arg.v (0) := New_String (Command_Name);
for I in 1 .. Arg.v_Count loop
Arg.v (I) := New_String (Argument (I));
end loop;
Glutinit (Argc'Access, Arg.v (0)'Access);
end Init;
function CreateWindow (Title : String) return Integer is
Result : Integer;
C_Title : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Title);
begin
Result := CreateWindow (C_Title);
Interfaces.C.Strings.Free (C_Title);
return Result;
end CreateWindow;
procedure InitDisplayString (Name : String) is
C_Name : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Name);
begin
InitDisplayString (C_Name);
Interfaces.C.Strings.Free (C_Name);
pragma Unreferenced (C_Name);
end InitDisplayString;
procedure SetWindowTitle (Title : String) is
C_Title : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Title);
begin
SetWindowTitle (C_Title);
Interfaces.C.Strings.Free (C_Title);
pragma Unreferenced (C_Title);
end SetWindowTitle;
procedure SetIconTitle (Title : String) is
C_Title : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Title);
begin
SetIconTitle (C_Title);
Interfaces.C.Strings.Free (C_Title);
pragma Unreferenced (C_Title);
end SetIconTitle;
procedure AddMenuEntry (Label : String; Value : Integer) is
C_Label : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Label);
begin
AddMenuEntry (C_Label, Value);
Interfaces.C.Strings.Free (C_Label);
pragma Unreferenced (C_Label);
end AddMenuEntry;
procedure AddSubMenu (Label : String; Submenu : Integer) is
C_Label : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Label);
begin
AddSubMenu (C_Label, Submenu);
Interfaces.C.Strings.Free (C_Label);
pragma Unreferenced (C_Label);
end AddSubMenu;
procedure ChangeToMenuEntry
(Item : Integer;
Label : String;
Value : Integer)
is
C_Label : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Label);
begin
ChangeToMenuEntry (Item, C_Label, Value);
Interfaces.C.Strings.Free (C_Label);
pragma Unreferenced (C_Label);
end ChangeToMenuEntry;
procedure ChangeToSubMenu
(Item : Integer;
Label : String;
Submenu : Integer)
is
C_Label : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Label);
begin
ChangeToSubMenu (Item, C_Label, Submenu);
Interfaces.C.Strings.Free (C_Label);
pragma Unreferenced (C_Label);
end ChangeToSubMenu;
function ExtensionSupported (Name : String) return Integer is
Result : Integer;
C_Name : Interfaces.C.Strings.chars_ptr
:= Interfaces.C.Strings.New_String (Name);
begin
Result := ExtensionSupported (C_Name);
Interfaces.C.Strings.Free (C_Name);
return Result;
end ExtensionSupported;
-----------------------------------------------------
-- GdM 2005 : callbacks with the 'Address attribute --
-----------------------------------------------------
-- This method is functionally identical as GNAT's Unrestricted_Access
-- but has no type safety (cf GNAT Docs)
function CreateMenu (P1 : System.Address) return Integer is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_1);
begin
return CreateMenu (Cvt (P1));
end CreateMenu;
procedure DisplayFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_2);
begin
DisplayFunc (Cvt (P1));
end DisplayFunc;
procedure ReshapeFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_3);
begin
ReshapeFunc (Cvt (P1));
end ReshapeFunc;
procedure KeyboardFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_4);
begin
KeyboardFunc (Cvt (P1));
end KeyboardFunc;
procedure KeyboardUpFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_KeyUpFunc);
begin
KeyboardUpFunc (Cvt (P1));
end KeyboardUpFunc;
procedure MouseFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_5);
begin
MouseFunc (Cvt (P1));
end MouseFunc;
procedure MotionFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_6);
begin
MotionFunc (Cvt (P1));
end MotionFunc;
procedure PassiveMotionFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_7);
begin
PassiveMotionFunc (Cvt (P1));
end PassiveMotionFunc;
procedure IdleFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_10);
begin
IdleFunc (Cvt (P1));
end IdleFunc;
procedure SpecialFunc (P1 : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_Proc_13);
begin
SpecialFunc (Cvt (P1));
end SpecialFunc;
procedure SpecialUpFunc (Func : System.Address) is
function Cvt is new Ada.Unchecked_Conversion (System.Address, Glut_SpecialUp);
begin
SpecialUpFunc (Cvt (Func));
end SpecialUpFunc;
end GLUT;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.Standard_Profile_L2.Traces.Hash is
new AMF.Elements.Generic_Hash (Standard_Profile_L2_Trace, Standard_Profile_L2_Trace_Access);
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . F L O A T _ C O N T R O L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2011, 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. --
-- --
------------------------------------------------------------------------------
-- Control functions for floating-point unit
package System.Float_Control is
pragma Pure;
-- This is not fully correct, but this unit is with-ed by pure units
-- (eg s-imgrea).
procedure Reset;
pragma Inline (Reset);
-- Reset the floating-point processor to the default state needed to get
-- correct Ada semantics for the target. Some third party tools change
-- the settings for the floating-point processor. Reset can be called
-- to reset the floating-point processor into the mode required by GNAT
-- for correct operation. Use this call after a call to foreign code if
-- you suspect incorrect floating-point operation after the call.
--
-- For example under Windows NT some system DLL calls change the default
-- FPU arithmetic to 64 bit precision mode. However, since in Ada 95 it
-- is required to provide full access to the floating-point types of the
-- architecture, GNAT requires full 80-bit precision mode, and Reset makes
-- sure this mode is established.
--
-- Similarly on the PPC processor, it is important that overflow and
-- underflow exceptions be disabled.
--
-- The call to Reset simply has no effect if the target environment
-- does not give rise to such concerns.
end System.Float_Control;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . O S _ C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2019, 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. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks ("M32766");
-- Allow long lines
-- This package provides target dependent definitions of constant for use
-- by the GNAT runtime library. This package should not be directly with'd
-- by an application program.
-- This file is generated automatically, do not modify it by hand! Instead,
-- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library.
-- This is the version for i686-pc-mingw32
with Interfaces.C;
package System.OS_Constants is
pragma Pure;
---------------------------------
-- General platform parameters --
---------------------------------
type OS_Type is (Windows, Other_OS);
Target_OS : constant OS_Type := Windows;
pragma Warnings (Off, Target_OS);
-- Suppress warnings on Target_OS since it is in general tested for
-- equality with a constant value to implement conditional compilation,
-- which normally generates a constant condition warning.
Target_Name : constant String := "i686-pc-mingw32";
SIZEOF_unsigned_int : constant := 4; -- Size of unsigned int
-------------------
-- System limits --
-------------------
IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt
NAME_MAX : constant := 260; -- Maximum file name length
---------------------
-- File open modes --
---------------------
O_RDWR : constant := 2; -- Read/write
O_NOCTTY : constant := -1; -- Don't change ctrl tty
O_NDELAY : constant := -1; -- Nonblocking
----------------------
-- Fcntl operations --
----------------------
F_GETFL : constant := -1; -- Get flags
F_SETFL : constant := -1; -- Set flags
-----------------
-- Fcntl flags --
-----------------
FNDELAY : constant := -1; -- Nonblocking
----------------------
-- Ioctl operations --
----------------------
subtype IOCTL_Req_T is Interfaces.C.int;
FIONBIO : constant := -2147195266; -- Set/clear non-blocking io
FIONREAD : constant := 1074030207; -- How many bytes to read
------------------
-- Errno values --
------------------
-- The following constants are defined from <errno.h>
EAGAIN : constant := 11; -- Try again
ENOENT : constant := 2; -- File not found
ENOMEM : constant := 12; -- Out of memory
-- The following constants are defined from <winsock2.h> (WSA*)
EACCES : constant := 13; -- Permission denied
EADDRINUSE : constant := 10048; -- Address already in use
EADDRNOTAVAIL : constant := 10049; -- Cannot assign address
EAFNOSUPPORT : constant := 10047; -- Addr family not supported
EALREADY : constant := 10037; -- Operation in progress
EBADF : constant := 9; -- Bad file descriptor
ECONNABORTED : constant := 10053; -- Connection aborted
ECONNREFUSED : constant := 10061; -- Connection refused
ECONNRESET : constant := 10054; -- Connection reset by peer
EDESTADDRREQ : constant := 10039; -- Destination addr required
EFAULT : constant := 14; -- Bad address
EHOSTDOWN : constant := 10064; -- Host is down
EHOSTUNREACH : constant := 10065; -- No route to host
EINPROGRESS : constant := 10036; -- Operation now in progress
EINTR : constant := 4; -- Interrupted system call
EINVAL : constant := 22; -- Invalid argument
EIO : constant := 5; -- Input output error
EISCONN : constant := 10056; -- Socket already connected
ELOOP : constant := 10062; -- Too many symbolic links
EMFILE : constant := 24; -- Too many open files
EMSGSIZE : constant := 10040; -- Message too long
ENAMETOOLONG : constant := 38; -- Name too long
ENETDOWN : constant := 10050; -- Network is down
ENETRESET : constant := 10052; -- Disconn. on network reset
ENETUNREACH : constant := 10051; -- Network is unreachable
ENOBUFS : constant := 10055; -- No buffer space available
ENOPROTOOPT : constant := 10042; -- Protocol not available
ENOTCONN : constant := 10057; -- Socket not connected
ENOTSOCK : constant := 10038; -- Operation on non socket
EOPNOTSUPP : constant := 10045; -- Operation not supported
EPIPE : constant := 32; -- Broken pipe
EPFNOSUPPORT : constant := 10046; -- Unknown protocol family
EPROTONOSUPPORT : constant := 10043; -- Unknown protocol
EPROTOTYPE : constant := 10041; -- Unknown protocol type
ERANGE : constant := 34; -- Result too large
ESHUTDOWN : constant := 10058; -- Cannot send once shutdown
ESOCKTNOSUPPORT : constant := 10044; -- Socket type not supported
ETIMEDOUT : constant := 10060; -- Connection timed out
ETOOMANYREFS : constant := 10059; -- Too many references
EWOULDBLOCK : constant := 10035; -- Operation would block
E2BIG : constant := 7; -- Argument list too long
EILSEQ : constant := 42; -- Illegal byte sequence
----------------------
-- Terminal control --
----------------------
DTR_CONTROL_ENABLE : constant := 1; -- Enable DTR flow ctrl
RTS_CONTROL_ENABLE : constant := 1; -- Enable RTS flow ctrl
-----------------------------
-- Pseudo terminal library --
-----------------------------
PTY_Library : constant String := ""; -- for g-exptty
--------------
-- Families --
--------------
AF_INET : constant := 2; -- IPv4 address family
AF_INET6 : constant := 23; -- IPv6 address family
AF_UNSPEC : constant := 0; -- Unspecified address family
-----------------------------
-- addrinfo fields offsets --
-----------------------------
AI_FLAGS_OFFSET : constant := 0; -- Offset of ai_flags in addrinfo
AI_FAMILY_OFFSET : constant := 4; -- Offset of ai_family in addrinfo
AI_SOCKTYPE_OFFSET : constant := 8; -- Offset of ai_socktype in addrinfo
AI_PROTOCOL_OFFSET : constant := 12; -- Offset of ai_protocol in addrinfo
AI_ADDRLEN_OFFSET : constant := 16; -- Offset of ai_addrlen in addrinfo
AI_ADDR_OFFSET : constant := 24; -- Offset of ai_addr in addrinfo
AI_CANONNAME_OFFSET : constant := 20; -- Offset of ai_canonname in addrinfo
AI_NEXT_OFFSET : constant := 28; -- Offset of ai_next in addrinfo
---------------------------------------
-- getaddrinfo getnameinfo constants --
---------------------------------------
AI_PASSIVE : constant := 1; -- NULL nodename for accepting
AI_CANONNAME : constant := 2; -- Get the host official name
AI_NUMERICSERV : constant := -1; -- Service is a numeric string
AI_NUMERICHOST : constant := 4; -- Node is a numeric IP address
AI_ADDRCONFIG : constant := -1; -- Returns addresses for only locally configured families
AI_V4MAPPED : constant := -1; -- Returns IPv4 mapped to IPv6
AI_ALL : constant := -1; -- Change AI_V4MAPPED behavior for unavailavle IPv6 addresses
NI_NAMEREQD : constant := 4; -- Error if the hostname cannot be determined
NI_DGRAM : constant := 16; -- Service is datagram
NI_NOFQDN : constant := 1; -- Return only the hostname part for local hosts
NI_NUMERICSERV : constant := 8; -- Numeric form of the service
NI_NUMERICHOST : constant := 2; -- Numeric form of the hostname
NI_MAXHOST : constant := 1025; -- Maximum size of hostname
NI_MAXSERV : constant := 32; -- Maximum size of service name
EAI_SYSTEM : constant := 10107; -- Check errno for details
------------------
-- Socket modes --
------------------
SOCK_STREAM : constant := 1; -- Stream socket
SOCK_DGRAM : constant := 2; -- Datagram socket
SOCK_RAW : constant := 3; -- Raw socket
-----------------
-- Host errors --
-----------------
HOST_NOT_FOUND : constant := 11001; -- Unknown host
TRY_AGAIN : constant := 11002; -- Host name lookup failure
NO_DATA : constant := 11004; -- No data record for name
NO_RECOVERY : constant := 11003; -- Non recoverable errors
--------------------
-- Shutdown modes --
--------------------
SHUT_RD : constant := 0; -- No more recv
SHUT_WR : constant := 1; -- No more send
SHUT_RDWR : constant := 2; -- No more recv/send
---------------------
-- Protocol levels --
---------------------
SOL_SOCKET : constant := 65535; -- Options for socket level
IPPROTO_IP : constant := 0; -- Dummy protocol for IP
IPPROTO_IPV6 : constant := 41; -- IPv6 socket option level
IPPROTO_UDP : constant := 17; -- UDP
IPPROTO_TCP : constant := 6; -- TCP
-------------------
-- Request flags --
-------------------
MSG_OOB : constant := 1; -- Process out-of-band data
MSG_PEEK : constant := 2; -- Peek at incoming data
MSG_EOR : constant := -1; -- Send end of record
MSG_WAITALL : constant := -1; -- Wait for full reception
MSG_NOSIGNAL : constant := -1; -- No SIGPIPE on send
MSG_Forced_Flags : constant := 0;
-- Flags set on all send(2) calls
--------------------
-- Socket options --
--------------------
TCP_NODELAY : constant := 1; -- Do not coalesce packets
SO_REUSEADDR : constant := 4; -- Bind reuse local address
SO_REUSEPORT : constant := -1; -- Bind reuse port number
SO_KEEPALIVE : constant := 8; -- Enable keep-alive msgs
SO_LINGER : constant := 128; -- Defer close to flush data
SO_BROADCAST : constant := 32; -- Can send broadcast msgs
SO_SNDBUF : constant := 4097; -- Set/get send buffer size
SO_RCVBUF : constant := 4098; -- Set/get recv buffer size
SO_SNDTIMEO : constant := 4101; -- Emission timeout
SO_RCVTIMEO : constant := 4102; -- Reception timeout
SO_ERROR : constant := 4103; -- Get/clear error status
SO_BUSY_POLL : constant := -1; -- Busy polling
IP_MULTICAST_IF : constant := 9; -- Set/get mcast interface
IP_MULTICAST_TTL : constant := 10; -- Set/get multicast TTL
IP_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback
IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group
IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group
IP_PKTINFO : constant := 19; -- Get datagram info
IP_RECVERR : constant := -1; -- Extended reliable error message passing
IPV6_ADDRFORM : constant := -1; -- Turn IPv6 socket into different address family
IPV6_ADD_MEMBERSHIP : constant := 12; -- Join IPv6 multicast group
IPV6_DROP_MEMBERSHIP : constant := 13; -- Leave IPv6 multicast group
IPV6_MTU : constant := -1; -- Set/get MTU used for the socket
IPV6_MTU_DISCOVER : constant := -1; -- Control path-MTU discovery on the socket
IPV6_MULTICAST_HOPS : constant := 10; -- Set the multicast hop limit for the socket
IPV6_MULTICAST_IF : constant := 9; -- Set/get IPv6 mcast interface
IPV6_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback
IPV6_RECVPKTINFO : constant := -1; -- Set delivery of the IPV6_PKTINFO
IPV6_PKTINFO : constant := 19; -- Get IPv6datagram info
IPV6_RTHDR : constant := -1; -- Set the routing header delivery
IPV6_AUTHHDR : constant := -1; -- Set the authentication header delivery
IPV6_DSTOPTS : constant := -1; -- Set the destination options delivery
IPV6_HOPOPTS : constant := -1; -- Set the hop options delivery
IPV6_FLOWINFO : constant := -1; -- Set the flow ID delivery
IPV6_HOPLIMIT : constant := -1; -- Set the hop count of the packet delivery
IPV6_RECVERR : constant := -1; -- Extended reliable error message passing
IPV6_ROUTER_ALERT : constant := -1; -- Pass forwarded router alert hop-by-hop option
IPV6_UNICAST_HOPS : constant := 4; -- Set the unicast hop limit
IPV6_V6ONLY : constant := -1; -- Restricted to IPv6 communications only
----------------------
-- Type definitions --
----------------------
-- Sizes (in bytes) of the components of struct timeval
SIZEOF_tv_sec : constant := 4; -- tv_sec
SIZEOF_tv_usec : constant := 4; -- tv_usec
-- Maximum allowed value for tv_sec
MAX_tv_sec : constant := 2 ** (SIZEOF_tv_sec * 8 - 1) - 1;
-- Sizes of various data types
SIZEOF_sockaddr_in : constant := 16; -- struct sockaddr_in
SIZEOF_sockaddr_in6 : constant := 28; -- struct sockaddr_in6
SIZEOF_fd_set : constant := 4100; -- fd_set
FD_SETSIZE : constant := 1024; -- Max fd value
SIZEOF_struct_hostent : constant := 16; -- struct hostent
SIZEOF_struct_servent : constant := 16; -- struct servent
SIZEOF_socklen_t : constant := 4; -- Size of socklen_t
IF_NAMESIZE : constant := -1; -- Max size of interface name with 0 terminator
-- Fields of struct msghdr
subtype Msg_Iovlen_T is Interfaces.C.size_t;
----------------------------------------
-- Properties of supported interfaces --
----------------------------------------
Need_Netdb_Buffer : constant := 0; -- Need buffer for Netdb ops
Need_Netdb_Lock : constant := 0; -- Need lock for Netdb ops
Has_Sockaddr_Len : constant := 0; -- Sockaddr has sa_len field
Thread_Blocking_IO : constant Boolean := True;
-- Set False for contexts where socket i/o are process blocking
Inet_Pton_Linkname : constant String := "__gnat_inet_pton";
Inet_Ntop_Linkname : constant String := "__gnat_inet_ntop";
---------------------
-- Threads support --
---------------------
-- Clock identifier definitions
CLOCK_REALTIME : constant := 1; -- System realtime clock
CLOCK_MONOTONIC : constant := 3; -- System monotonic clock
CLOCK_THREAD_CPUTIME_ID : constant := -1; -- Thread CPU clock
CLOCK_RT_Ada : constant := CLOCK_REALTIME;
--------------------------------
-- File and directory support --
--------------------------------
SIZEOF_struct_file_attributes : constant := 24; -- struct file_attributes
SIZEOF_struct_dirent_alloc : constant := 273; -- struct dirent allocation
------------------------------
-- MinGW-specific constants --
------------------------------
-- These constants may be used only within the MinGW version of
-- GNAT.Sockets.Thin.
WSASYSNOTREADY : constant := 10091; -- System not ready
WSAVERNOTSUPPORTED : constant := 10092; -- Version not supported
WSANOTINITIALISED : constant := 10093; -- Winsock not initialized
WSAEDISCON : constant := 10101; -- Disconnected
end System.OS_Constants;
|
------------------------------------------------------------------------------
-- --
-- tiled-code-gen --
-- --
-- Copyright (C) 2018 Fabien Chouteau --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Directories; use Ada.Directories;
with GNAT.OS_Lib;
with DOM.Core; use DOM.Core;
with TCG.Utils; use TCG.Utils;
with TCG.Tile_Layers; use TCG.Tile_Layers;
with TCG.Object_Groups; use TCG.Object_Groups;
with Input_Sources.File; use Input_Sources.File;
with Sax.Readers; use Sax.Readers;
with DOM.Readers; use DOM.Readers;
with DOM.Core.Documents; use DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
package body TCG.Maps is
function Create (N : Node; Name : String) return Map;
function Load_Tileset (N : Node; Base_Dir : String) return Map_Tileset;
------------
-- Create --
------------
function Create (N : Node; Name : String) return Map is
Tile_Width : constant Natural := Item_As_Natural (N, "tilewidth");
Tile_Height : constant Natural := Item_As_Natural (N, "tileheight");
Width : constant Natural := Item_As_Natural (N, "width");
Height : constant Natural := Item_As_Natural (N, "height");
M : constant Map := new Map_Data;
begin
M.Width := Width;
M.Height := Height;
M.Tile_Width := Tile_Width;
M.Tile_Height := Tile_Height;
M.Name := new String'(Name);
return M;
end Create;
------------------
-- Load_Tileset --
------------------
function Load_Tileset (N : Node;
Base_Dir : String)
return Map_Tileset
is
Source : constant String :=
GNAT.OS_Lib.Normalize_Pathname (Item_As_String (N, "source"),
Base_Dir);
First_Tile : constant Natural := Item_As_Natural (N, "firstgid");
begin
return (Tilesets.Load (Source), Tilesets.Map_Tile_Id (First_Tile));
end Load_Tileset;
----------
-- Load --
----------
function Load (Path : String; Name : String) return Map is
Dir : constant String := Containing_Directory (Path);
Input : File_Input;
Reader : Tree_Reader;
Doc : Document;
List : Node_List;
N : Node;
M : Map;
begin
Set_Public_Id (Input, "Map file");
Open (Path, Input);
Set_Feature (Reader, Validation_Feature, False);
Set_Feature (Reader, Namespace_Feature, False);
Parse (Reader, Input);
Close (Input);
Doc := Get_Tree (Reader);
List := Get_Elements_By_Tag_Name (Doc, "map");
if Length (List) > 1 then
raise Program_Error with "Too many map elements";
end if;
M := Create (Item (List, 0), Name);
Free (List);
List := Get_Elements_By_Tag_Name (Doc, "objectgroup");
for Index in 1 .. Length (List) loop
N := Item (List, Index - 1);
M.Obj_Group_List.Append (Object_Groups.Load (N));
end loop;
Free (List);
List := Get_Elements_By_Tag_Name (Doc, "tileset");
for Index in 1 .. Length (List) loop
N := Item (List, Index - 1);
M.Tileset_List.Append (Load_Tileset (N, Dir));
end loop;
Free (List);
List := Get_Elements_By_Tag_Name (Doc, "layer");
for Index in 1 .. Length (List) loop
N := Item (List, Index - 1);
M.Layer_List.Append (Tile_Layers.Load (N));
end loop;
Free (List);
Free (Reader);
return M;
end Load;
----------
-- Name --
----------
function Name (This : Map) return String
is (This.Name.all);
-----------
-- Width --
-----------
function Width (This : Map) return Natural
is (This.Width);
------------
-- Height --
------------
function Height (This : Map) return Natural
is (This.Height);
----------------
-- Tile_Width --
----------------
function Tile_Width (This : Map) return Natural
is (This.Tile_Width);
-----------------
-- Tile_Height --
-----------------
function Tile_Height (This : Map) return Natural
is (This.Tile_Height);
---------
-- Put --
---------
procedure Put
(This : Map)
is
begin
Put_Line ("Map " & This.Name.all & ":");
for TS of This.Tileset_List loop
Put_Line ("Tileset " & Tilesets.Name (TS.Id));
end loop;
for L of This.Layer_List loop
Tile_Layers.Put (L);
end loop;
end Put;
----------------------
-- Number_Of_Layers --
----------------------
function Number_Of_Layers (This : Map) return Natural
is (Natural (Layer_Vect.Length (This.Layer_List)));
-----------------
-- First_Index --
-----------------
function First_Layer (This : Map) return Natural
is (Natural (Layer_Vect.First_Index (This.Layer_List)));
----------------
-- Last_Index --
----------------
function Last_Layer (This : Map) return Natural
is (Natural (Layer_Vect.Last_Index (This.Layer_List)));
-----------
-- Layer --
-----------
function Layer (This : Map; Index : Natural) return Tile_Layers.Tile_Layer
is (This.Layer_List.Element (Index));
-----------------
-- Master_Tile --
-----------------
function Master_Tile (M : Map;
Id : Tilesets.Map_Tile_Id)
return Tilesets.Master_Tile_Id
is
use Tilesets;
First_Id : Map_Tile_Id := 0;
TS_Id : Tileset_Id := Invalid_Tileset;
begin
if Id = 0 then
return No_Tile;
end if;
for TS of M.Tileset_List loop
if TS.First_Tile > Id then
exit;
else
TS_Id := TS.Id;
First_Id := TS.First_Tile;
end if;
end loop;
return Convert (TS_Id, Local_Tile_Id (Id - First_Id));
end Master_Tile;
------------------------
-- First_Object_Group --
------------------------
function First_Object_Group (This : Map) return Natural
is (This.Obj_Group_List.First_Index);
-----------------------
-- Last_Object_Group --
-----------------------
function Last_Object_Group (This : Map) return Natural
is (This.Obj_Group_List.Last_Index);
------------------
-- Object_Group --
------------------
function Object_Group (This : Map; Index : Natural)
return Object_Groups.Object_Group
is (This.Obj_Group_List.Element (Index));
---------------------------
-- Generate_GESTE_Source --
---------------------------
procedure Generate_GESTE_Source (M : Map;
Package_Name : String;
Filepath : String)
is
Output : File_Type;
Indent : Natural := 0;
procedure P (Str : String);
procedure PL (Str : String);
procedure NL;
procedure Put_Object (M : Map;
Obj : Object_Groups.Object);
-------
-- P --
-------
procedure P (Str : String) is
begin
Put (Output, Str);
end P;
--------
-- PL --
--------
procedure PL (Str : String) is
begin
for X in 1 .. Indent loop
Put (Output, " ");
end loop;
Put_Line (Output, Str);
end PL;
--------
-- NL --
--------
procedure NL is
begin
New_Line (Output);
end NL;
----------------
-- Put_Object --
----------------
procedure Put_Object (M : Map;
Obj : Object_Groups.Object)
is
begin
PL ("Kind => " & Obj.Kind'Img & ",");
PL ("Id => " & Obj.Id'Img & ",");
if Obj.Name /= null then
PL ("Name => new String'(""" & Obj.Name.all & """),");
else
PL ("Name => null,");
end if;
PL ("X => " & Obj.Pt.X'Img & ",");
PL ("Y => " & Obj.Pt.Y'Img & ",");
PL ("Width => " & Obj.Width'Img & ",");
PL ("Height => " & Obj.Height'Img & ",");
PL ("Flip_Vertical => " & Obj.Flip_Vertical'Img & ",");
PL ("Flip_Horizontal => " & Obj.Flip_Horizontal'Img & ",");
PL ("Tile_Id => " & Master_Tile (M, Obj.Tile_Id)'Img & ",");
if Obj.Str /= null then
PL ("Str => new String'(""" & Obj.Str.all & """)");
else
PL ("Str => null");
end if;
end Put_Object;
begin
Create (Output, Out_File, Filepath);
PL ("with GESTE;");
PL ("with GESTE.Grid;");
PL ("pragma Style_Checks (Off);");
PL ("package " & Package_Name & " is");
NL;
Indent := Indent + 3;
PL ("-- " & M.Name.all);
PL ("Width : constant :=" & M.Width'Img & ";");
PL ("Height : constant :=" & M.Height'Img & ";");
PL ("Tile_Width : constant :=" & M.Tile_Width'Img & ";");
PL ("Tile_Height : constant :=" & M.Tile_Height'Img & ";");
NL;
for L of M.Layer_List loop
declare
Layer_Ada_Id : constant String := To_Ada_Identifier (Name (L));
begin
PL ("-- " & Name (L));
PL ("package " & Layer_Ada_Id & " is");
Indent := Indent + 3;
PL ("Width : constant := " & Width (L)'Img & ";");
PL ("Height : constant := " & Width (L)'Img & ";");
PL ("Data : aliased GESTE.Grid.Grid_Data :=");
P (" (");
for X in 1 .. Width (L) loop
if X /= 1 then
P (" ");
end if;
P ("(");
for Y in 1 .. Height (L) loop
P (Master_Tile (M, Tile (L, X, Y))'Img);
if Y /= Height (L) then
P (",");
end if;
end loop;
P (")");
if X /= Width (L) then
P (",");
NL;
else
P (")");
end if;
end loop;
PL (";");
Indent := Indent - 3;
PL ("end " & Layer_Ada_Id & ";");
NL;
end;
end loop;
for G of M.Obj_Group_List loop
declare
Group_Ada_Id : constant String := To_Ada_Identifier (Name (G));
begin
PL ("package " & Group_Ada_Id & " is");
Indent := Indent + 3;
if Length (G) /= 0 then
-- Objects as array
PL ("Objects : Object_Array :=");
Indent := Indent + 2;
PL ("(");
Indent := Indent + 2;
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
PL (Index'Img & " => (");
Indent := Indent + 2;
Put_Object (M, Obj);
Indent := Indent - 2;
if Index = Last_Index (G) then
PL (")");
else
PL ("),");
end if;
end;
end loop;
Indent := Indent - 2;
PL (");");
Indent := Indent - 2;
end if;
if Length (G) /= 0 then
-- Object as indivial declaration
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
if Obj.Name /= null then
PL (TCG.Utils.To_Ada_Identifier (Obj.Name.all) &
" : aliased constant Object := (");
Indent := Indent + 2;
Put_Object (M, Obj);
PL (");");
Indent := Indent - 2;
end if;
end;
end loop;
end if;
Indent := Indent - 3;
PL ("end " & Group_Ada_Id & ";");
end;
end loop;
Indent := Indent - 3;
PL ("end " & Package_Name & ";");
Close (Output);
end Generate_GESTE_Source;
----------------------------
-- Generate_LibGBA_Source --
----------------------------
procedure Generate_LibGBA_Source (M : Map;
Package_Name : String;
Filepath : String)
is
Output : File_Type;
Indent : Natural := 0;
procedure P (Str : String);
procedure PL (Str : String);
procedure NL;
procedure Put_Object (M : Map;
Obj : Object_Groups.Object);
-------
-- P --
-------
procedure P (Str : String) is
begin
Put (Output, Str);
end P;
--------
-- PL --
--------
procedure PL (Str : String) is
begin
for X in 1 .. Indent loop
Put (Output, " ");
end loop;
Put_Line (Output, Str);
end PL;
--------
-- NL --
--------
procedure NL is
begin
New_Line (Output);
end NL;
----------------
-- Put_Object --
----------------
procedure Put_Object (M : Map;
Obj : Object_Groups.Object)
is
begin
PL ("Kind => " & Obj.Kind'Img & ",");
PL ("Id => " & Obj.Id'Img & ",");
if Obj.Name /= null then
-- PL ("Name => new String'(""" & Obj.Name.all & """),");
PL ("Name => null,");
else
PL ("Name => null,");
end if;
PL ("X => " & Obj.Pt.X'Img & ",");
PL ("Y => " & Obj.Pt.Y'Img & ",");
PL ("Width => " & Obj.Width'Img & ",");
PL ("Height => " & Obj.Height'Img & ",");
PL ("Flip_Vertical => " & Obj.Flip_Vertical'Img & ",");
PL ("Flip_Horizontal => " & Obj.Flip_Horizontal'Img & ",");
PL ("Tile_Id => " & Master_Tile (M, Obj.Tile_Id)'Img & ",");
if Obj.Str /= null then
-- PL ("Str => new String'(""" & Obj.Str.all & """)");
PL ("Str => null");
else
PL ("Str => null");
end if;
end Put_Object;
begin
pragma Style_Checks ("M200");
Create (Output, Out_File, Filepath);
PL ("with GBA.Graphics.Background.Viewport;");
PL ("pragma Style_Checks (Off);");
PL ("package " & Package_Name & " is");
NL;
Indent := Indent + 3;
PL ("-- " & M.Name.all);
PL ("Width : constant :=" & M.Width'Img & ";");
PL ("Height : constant :=" & M.Height'Img & ";");
PL ("Tile_Width : constant :=" & M.Tile_Width'Img & ";");
PL ("Tile_Height : constant :=" & M.Tile_Height'Img & ";");
NL;
for L of M.Layer_List loop
declare
Layer_Ada_Id : constant String := To_Ada_Identifier (Name (L));
begin
PL ("-- " & Name (L));
PL ("package " & Layer_Ada_Id & " is");
Indent := Indent + 3;
PL ("Width : constant := " & Width (L)'Img & ";");
PL ("Height : constant := " & Height (L)'Img & ";");
PL ("Data : aliased GBA.Graphics.Background.Viewport.Raw_Screenblock :=");
P (" (");
for Y in 1 .. Height (L) loop
if Y /= 1 then
P (" ");
end if;
for X in 1 .. Width (L) loop
P (Master_Tile (M, Tile (L, X, Y))'Img);
if X /= Width (L) then
P (",");
end if;
end loop;
if Y /= Height (L) then
P (",");
NL;
else
P (")");
end if;
end loop;
PL (";");
PL ("Info : constant GBA.Graphics.Background.Viewport.Map_Info := (Data'Access, Width, Height);");
Indent := Indent - 3;
PL ("end " & Layer_Ada_Id & ";");
NL;
end;
end loop;
for G of M.Obj_Group_List loop
declare
Group_Ada_Id : constant String := To_Ada_Identifier (Name (G));
begin
PL ("package " & Group_Ada_Id & " is");
Indent := Indent + 3;
if Length (G) /= 0 then
-- Objects as array
PL ("Objects : Object_Array :=");
Indent := Indent + 2;
PL ("(");
Indent := Indent + 2;
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
PL (Index'Img & " => (");
Indent := Indent + 2;
Put_Object (M, Obj);
Indent := Indent - 2;
if Index = Last_Index (G) then
PL (")");
else
PL ("),");
end if;
end;
end loop;
Indent := Indent - 2;
PL (");");
Indent := Indent - 2;
end if;
if Length (G) /= 0 then
-- Object as indivial declaration
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
if Obj.Name /= null then
PL (TCG.Utils.To_Ada_Identifier (Obj.Name.all) &
" : aliased constant Object := (");
Indent := Indent + 2;
Put_Object (M, Obj);
PL (");");
Indent := Indent - 2;
end if;
end;
end loop;
end if;
Indent := Indent - 3;
PL ("end " & Group_Ada_Id & ";");
end;
end loop;
Indent := Indent - 3;
PL ("end " & Package_Name & ";");
Close (Output);
end Generate_LibGBA_Source;
--------------------------
-- Generate_RSTE_Source --
--------------------------
procedure Generate_RSTE_Source (M : Map;
Filepath : String)
is
Output : File_Type;
Indent : Natural := 0;
procedure P (Str : String);
procedure PL (Str : String);
procedure NL;
procedure Put_Object (M : Map;
Obj : Object_Groups.Object);
function Rust_Boolean (B : Boolean) return String;
function Rust_Object_Kind (O : Object_Kind) return String;
------------------
-- Rust_Boolean --
------------------
function Rust_Boolean (B : Boolean) return String
is (if B then "true" else "false");
----------------------
-- Rust_Object_Kind --
----------------------
function Rust_Object_Kind (O : Object_Kind) return String
is (case O is
when Point_Obj => "super::super::ObjectKind::Point",
when Rectangle_Obj => "super::super::ObjectKind::Rectangle",
when Ellipse_Obj => "super::super::ObjectKind::Ellipse",
when Polygon_Obj => "super::super::ObjectKind::Polygon",
when Tile_Obj => "super::super::ObjectKind::Tile",
when Text_Obj => "super::super::ObjectKind::Text");
-------
-- P --
-------
procedure P (Str : String) is
begin
Put (Output, Str);
end P;
--------
-- PL --
--------
procedure PL (Str : String) is
begin
for X in 1 .. Indent loop
Put (Output, " ");
end loop;
Put_Line (Output, Str);
end PL;
--------
-- NL --
--------
procedure NL is
begin
New_Line (Output);
end NL;
----------------
-- Put_Object --
----------------
procedure Put_Object (M : Map;
Obj : Object_Groups.Object)
is
begin
PL ("kind : " & Rust_Object_Kind (Obj.Kind) & ",");
PL ("id : " & Obj.Id'Img & ",");
if Obj.Name /= null then
PL ("name :""" & Obj.Name.all & """,");
else
PL ("name : """",");
end if;
PL ("x : " & Obj.Pt.X'Img & ",");
PL ("y : " & Obj.Pt.Y'Img & ",");
PL ("width : " & Obj.Width'Img & ",");
PL ("height : " & Obj.Height'Img & ",");
PL ("flip_vertical : " & Rust_Boolean (Obj.Flip_Vertical) & ",");
PL ("flip_horizontal : " & Rust_Boolean (Obj.Flip_Horizontal) & ",");
PL ("tile_id : " & Master_Tile (M, Obj.Tile_Id)'Img & ",");
if Obj.Str /= null then
PL ("str : """ & Obj.Str.all & """,");
else
PL ("str : """",");
end if;
end Put_Object;
begin
Create (Output, Out_File, Filepath);
PL ("// " & M.Name.all);
PL ("#[allow(unused_imports)]");
NL;
PL ("const WIDTH : usize =" & M.Width'Img & ";");
PL ("const HEIGHT : usize =" & M.Height'Img & ";");
PL ("const TILE_WIDTH : usize =" & M.Tile_Width'Img & ";");
PL ("const TILE_HEIGHT : usize =" & M.Tile_Height'Img & ";");
NL;
for L of M.Layer_List loop
PL ("pub mod " & To_Rust_Identifier (Name (L)) & " {");
Indent := Indent + 4;
PL ("use sprite_and_tile::*;");
PL ("pub const WIDTH : usize = " & Width (L)'Img & ";");
PL ("pub const HEIGHT : usize = " & Height (L)'Img & ";");
PL ("pub static TILE_MAP_DATA : [usize;" &
Integer'Image (Width (L) * Height (L)) & "] =");
P (" [");
for Y in 1 .. Height (L) loop
if Y /= 1 then
P (" ");
end if;
for X in 1 .. Width (L) loop
P (Master_Tile (M, Tile (L, X, Y))'Img);
P (",");
end loop;
if Y /= Height (L) then
NL;
end if;
end loop;
PL ("];");
PL ("static TILE_MAP : TileMap =");
PL (" TileMap {width : WIDTH,");
PL (" height : HEIGHT,");
PL (" map : & TILE_MAP_DATA}; ");
Indent := Indent - 4;
PL ("}");
NL;
end loop;
for G of M.Obj_Group_List loop
PL ("pub mod " & To_Rust_Identifier (Name (G)) & " {");
Indent := Indent + 3;
if Length (G) /= 0 then
-- Objects as array
PL ("pub static OBJECTS : [super::super::Object;" &
Length (G)'Img & "] =");
Indent := Indent + 2;
PL ("[");
Indent := Indent + 2;
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
PL ("super::super::Object {");
Indent := Indent + 2;
Put_Object (M, Obj);
Indent := Indent - 2;
PL ("},");
end;
end loop;
Indent := Indent - 2;
PL ("];");
Indent := Indent - 2;
end if;
if Length (G) /= 0 then
-- Object as indivial declaration
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
if Obj.Name /= null then
PL ("pub static " &
TCG.Utils.To_Rust_Static_Identifier (Obj.Name.all) &
" : super::super::Object = " &
"super::super::Object {");
Indent := Indent + 2;
Put_Object (M, Obj);
PL ("};");
Indent := Indent - 2;
end if;
end;
end loop;
end if;
Indent := Indent - 3;
PL ("}");
end loop;
Close (Output);
end Generate_RSTE_Source;
-------------------------
-- Fill_Master_Tileset --
-------------------------
procedure Fill_Master_Tileset (M : Map) is
Unused : Tilesets.Master_Tile_Id;
begin
-- For all layers...
for L of M.Layer_List loop
-- For all tiles...
for X in 1 .. Width (L) loop
for Y in 1 .. Height (L) loop
-- Convert to a Master_Tile_ID to make sure the tile is
-- added to the master tile set.
Unused := Master_Tile (M, Tile (L, X, Y));
end loop;
end loop;
-- For all groups...
for G of M.Obj_Group_List loop
if Length (G) /= 0 then
-- For all objects...
for Index in First_Index (G) .. Last_Index (G) loop
declare
Obj : constant Object_Groups.Object :=
Get_Object (G, Index);
begin
-- Convert the tile to a Master_Tile_ID to make sure the
-- tile is added to the master tile set.
Unused := Master_Tile (M, Obj.Tile_Id);
end;
end loop;
end if;
end loop;
end loop;
end Fill_Master_Tileset;
end TCG.Maps;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.CMOF.Classes;
with AMF.CMOF.Comments.Collections;
with AMF.CMOF.Elements.Collections;
with AMF.CMOF.Properties;
with AMF.Extents;
with AMF.Internals.Elements;
with League.Holders;
package AMF.Internals.CMOF_Elements is
type CMOF_Element_Proxy is
abstract limited new AMF.Internals.Elements.Element_Base
and AMF.CMOF.Elements.CMOF_Element with null record;
overriding function Get
(Self : not null access constant CMOF_Element_Proxy;
Property : not null AMF.CMOF.Properties.CMOF_Property_Access)
return League.Holders.Holder;
overriding function Get_Meta_Class
(Self : not null access constant CMOF_Element_Proxy)
return AMF.CMOF.Classes.CMOF_Class_Access;
overriding function Get_Owned_Comment
(Self : not null access constant CMOF_Element_Proxy)
return AMF.CMOF.Comments.Collections.Set_Of_CMOF_Comment;
overriding function Get_Owned_Element
(Self : not null access constant CMOF_Element_Proxy)
return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element;
overriding function Get_Owner
(Self : not null access constant CMOF_Element_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access;
overriding procedure Set
(Self : not null access CMOF_Element_Proxy;
Property : not null AMF.CMOF.Properties.CMOF_Property_Access;
Value : League.Holders.Holder);
overriding function Extent
(Self : not null access constant CMOF_Element_Proxy)
return AMF.Extents.Extent_Access;
overriding function Must_Be_Owned
(Self : not null access constant CMOF_Element_Proxy) return Boolean;
-- Operation Element::mustBeOwned.
--
-- The query mustBeOwned() indicates whether elements of this type must
-- have an owner. Subclasses of Element that do not require an owner must
-- override this operation.
end AMF.Internals.CMOF_Elements;
|
-- Copyright 2008-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pck is
type Position is record
X : Integer;
Y : Integer;
end record;
type Circle is record
Pos : Position;
Radius : Integer;
end record;
procedure Do_Nothing (C : in out Circle);
end Pck;
|
with
AdaM.Factory;
package body AdaM.access_Definition
is
-- Storage Pool
--
record_Version : constant := 1;
pool_Size : constant := 5_000;
package Pool is new AdaM.Factory.Pools (storage_Folder => ".adam-store",
pool_Name => "access_Definitions",
max_Items => pool_Size,
record_Version => record_Version,
Item => access_Definition.item,
View => access_Definition.view);
-- Forge
--
procedure define (Self : in out Item)
is
begin
null;
end define;
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
function new_Definition return access_Definition.view
is
new_View : constant access_Definition.view := Pool.new_Item;
begin
define (access_Definition.item (new_View.all));
return new_View;
end new_Definition;
procedure free (Self : in out access_Definition.view)
is
begin
destruct (access_Definition.item (Self.all));
Pool.free (Self);
end free;
-- Attributes
--
overriding function Id (Self : access Item) return AdaM.Id
is
begin
return Pool.to_Id (Self);
end Id;
overriding
function to_Source (Self : in Item) return text_Vectors.Vector
is
pragma Unreferenced (Self);
the_Source : text_Vectors.Vector;
begin
raise Program_Error with "TODO";
return the_Source;
end to_Source;
function is_Constrained (Self : in Item) return Boolean
is
begin
return Self.is_Constrained;
end is_Constrained;
procedure is_Constrained (Self : in out Item; Now : in Boolean := True)
is
begin
Self.is_Constrained := Now;
end is_Constrained;
function First (Self : in Item) return String
is
begin
return +Self.First;
end First;
procedure First_is (Self : in out Item; Now : in String)
is
begin
Self.First := +Now;
end First_is;
function Last (Self : in Item) return String
is
begin
return +Self.Last;
end Last;
procedure Last_is (Self : in out Item; Now : in String)
is
begin
Self.Last := +Now;
end Last_is;
function has_not_Null (Self : in Item) return Boolean
is
begin
return Self.has_not_Null;
end has_not_Null;
procedure has_not_Null (Self : in out Item; Now : in Boolean := True)
is
begin
Self.has_not_Null := Now;
end has_not_Null;
function main_Type (Self : access Item) return access AdaM.a_Type.view
is
begin
return Self.main_Type'Access;
end main_Type;
function main_Type (Self : in Item) return AdaM.a_Type.view
is
begin
return Self.main_Type;
end main_Type;
procedure main_Type_is (Self : in out Item; Now : in AdaM.a_Type.view)
is
begin
Self.main_Type := Now;
end main_Type_is;
overriding
function Name (Self : in Item) return Identifier
is
pragma Unreferenced (Self);
begin
return "";
end Name;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View)
renames Pool.View_write;
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View)
renames Pool.View_read;
end AdaM.access_Definition;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T A S K _ A T T R I B U T E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1991-1994, Florida State University --
-- Copyright (C) 1995-2006, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- The following notes are provided in case someone decides the implementation
-- of this package is too complicated, or too slow. Please read this before
-- making any "simplifications".
-- Correct implementation of this package is more difficult than one might
-- expect. After considering (and coding) several alternatives, we settled on
-- the present compromise. Things we do not like about this implementation
-- include:
-- - It is vulnerable to bad Task_Id values, to the extent of possibly
-- trashing memory and crashing the runtime system.
-- - It requires dynamic storage allocation for each new attribute value,
-- except for types that happen to be the same size as System.Address, or
-- shorter.
-- - Instantiations at other than the library level rely on being able to
-- do down-level calls to a procedure declared in the generic package body.
-- This makes it potentially vulnerable to compiler changes.
-- The main implementation issue here is that the connection from task to
-- attribute is a potential source of dangling references.
-- When a task goes away, we want to be able to recover all the storage
-- associated with its attributes. The Ada mechanism for this is finalization,
-- via controlled attribute types. For this reason, the ARM requires
-- finalization of attribute values when the associated task terminates.
-- This finalization must be triggered by the tasking runtime system, during
-- termination of the task. Given the active set of instantiations of
-- Ada.Task_Attributes is dynamic, the number and types of attributes
-- belonging to a task will not be known until the task actually terminates.
-- Some of these types may be controlled and some may not. The RTS must find
-- some way to determine which of these attributes need finalization, and
-- invoke the appropriate finalization on them.
-- One way this might be done is to create a special finalization chain for
-- each task, similar to the finalization chain that is used for controlled
-- objects within the task. This would differ from the usual finalization
-- chain in that it would not have a LIFO structure, since attributes may be
-- added to a task at any time during its lifetime. This might be the right
-- way to go for the longer term, but at present this approach is not open,
-- since GNAT does not provide such special finalization support.
-- Lacking special compiler support, the RTS is limited to the normal ways an
-- application invokes finalization, i.e.
-- a) Explicit call to the procedure Finalize, if we know the type has this
-- operation defined on it. This is not sufficient, since we have no way
-- of determining whether a given generic formal Attribute type is
-- controlled, and no visibility of the associated Finalize procedure, in
-- the generic body.
-- b) Leaving the scope of a local object of a controlled type. This does not
-- help, since the lifetime of an instantiation of Ada.Task_Attributes
-- does not correspond to the lifetimes of the various tasks which may
-- have that attribute.
-- c) Assignment of another value to the object. This would not help, since
-- we then have to finalize the new value of the object.
-- d) Unchecked deallocation of an object of a controlled type. This seems to
-- be the only mechanism available to the runtime system for finalization
-- of task attributes.
-- We considered two ways of using unchecked deallocation, both based on a
-- linked list of that would hang from the task control block.
-- In the first approach the objects on the attribute list are all derived
-- from one controlled type, say T, and are linked using an access type to
-- T'Class. The runtime system has an Unchecked_Deallocation for T'Class with
-- access type T'Class, and uses this to deallocate and finalize all the
-- items in the list. The limitation of this approach is that each
-- instantiation of the package Ada.Task_Attributes derives a new record
-- extension of T, and since T is controlled (RM 3.9.1 (3)), instantiation is
-- only allowed at the library level.
-- In the second approach the objects on the attribute list are of unrelated
-- but structurally similar types. Unchecked conversion is used to circument
-- Ada type checking. Each attribute-storage node contains not only the
-- attribute value and a link for chaining, but also a pointer to descriptor
-- for the corresponding instantiation of Task_Attributes. The instantiation
-- descriptor contains pointer to a procedure that can do the correct
-- deallocation and finalization for that type of attribute. On task
-- termination, the runtime system uses the pointer to call the appropriate
-- deallocator.
-- While this gets around the limitation that instantations be at the library
-- level, it relies on an implementation feature that may not always be safe,
-- i.e. that it is safe to call the Deallocate procedure for an instantiation
-- of Ada.Task_Attributes that no longer exists. In general, it seems this
-- might result in dangling references.
-- Another problem with instantiations deeper than the library level is that
-- there is risk of storage leakage, or dangling references to reused
-- storage. That is, if an instantiation of Ada.Task_Attributes is made
-- within a procedure, what happens to the storage allocated for attributes,
-- when the procedure call returns? Apparently (RM 7.6.1 (4)) any such
-- objects must be finalized, since they will no longer be accessible, and in
-- general one would expect that the storage they occupy would be recovered
-- for later reuse. (If not, we would have a case of storage leakage.)
-- Assuming the storage is recovered and later reused, we have potentially
-- dangerous dangling references. When the procedure containing the
-- instantiation of Ada.Task_Attributes returns, there may still be
-- unterminated tasks with associated attribute values for that instantiation.
-- When such tasks eventually terminate, the RTS will attempt to call the
-- Deallocate procedure on them. If the corresponding storage has already
-- been deallocated, when the master of the access type was left, we have a
-- potential disaster. This disaster is compounded since the pointer to
-- Deallocate is probably through a "trampoline" which will also have been
-- destroyed.
-- For this reason, we arrange to remove all dangling references before
-- leaving the scope of an instantiation. This is ugly, since it requires
-- traversing the list of all tasks, but it is no more ugly than a similar
-- traversal that we must do at the point of instantiation in order to
-- initialize the attributes of all tasks. At least we only need to do these
-- traversals if the type is controlled.
-- We chose to defer allocation of storage for attributes until the Reference
-- function is called or the attribute is first set to a value different from
-- the default initial one. This allows a potential savings in allocation,
-- for attributes that are not used by all tasks.
-- For efficiency, we reserve space in the TCB for a fixed number of
-- direct-access attributes. These are required to be of a size that fits in
-- the space of an object of type System.Address. Because we must use
-- unchecked bitwise copy operations on these values, they cannot be of a
-- controlled type, but that is covered automatically since controlled
-- objects are too large to fit in the spaces.
-- We originally deferred the initialization of these direct-access
-- attributes, just as we do for the indirect-access attributes, and used a
-- per-task bit vector to keep track of which attributes were currently
-- defined for that task. We found that the overhead of maintaining this
-- bit-vector seriously slowed down access to the attributes, and made the
-- fetch operation non-atomic, so that even to read an attribute value
-- required locking the TCB. Therefore, we now initialize such attributes for
-- all existing tasks at the time of the attribute instantiation, and
-- initialize existing attributes for each new task at the time it is
-- created.
-- The latter initialization requires a list of all the instantiation
-- descriptors. Updates to this list, as well as the bit-vector that is used
-- to reserve slots for attributes in the TCB, require mutual exclusion. That
-- is provided by the Lock/Unlock_RTS.
-- One special problem that added complexity to the design is that the
-- per-task list of indirect attributes contains objects of different types.
-- We use unchecked pointer conversion to link these nodes together and
-- access them, but the records may not have identical internal structure.
-- Initially, we thought it would be enough to allocate all the common
-- components of the records at the front of each record, so that their
-- positions would correspond. Unfortunately, GNAT adds "dope" information at
-- the front of a record, if the record contains any controlled-type
-- components.
--
-- This means that the offset of the fields we use to link the nodes is at
-- different positions on nodes of different types. To get around this, each
-- attribute storage record consists of a core node and wrapper. The core
-- nodes are all of the same type, and it is these that are linked together
-- and generally "seen" by the RTS. Each core node contains a pointer to its
-- own wrapper, which is a record that contains the core node along with an
-- attribute value, approximately as follows:
-- type Node;
-- type Node_Access is access all Node;
-- type Node_Access;
-- type Access_Wrapper is access all Wrapper;
-- type Node is record
-- Next : Node_Access;
-- ...
-- Wrapper : Access_Wrapper;
-- end record;
-- type Wrapper is record
-- Dummy_Node : aliased Node;
-- Value : aliased Attribute; -- the generic formal type
-- end record;
-- Another interesting problem is with the initialization of the
-- instantiation descriptors. Originally, we did this all via the Initialize
-- procedure of the descriptor type and code in the package body. It turned
-- out that the Initialize procedure needed quite a bit of information,
-- including the size of the attribute type, the initial value of the
-- attribute (if it fits in the TCB), and a pointer to the deallocator
-- procedure. These needed to be "passed" in via access discriminants. GNAT
-- was having trouble with access discriminants, so all this work was moved
-- to the package body.
with System.Error_Reporting;
-- Used for Shutdown;
with System.Storage_Elements;
-- Used for Integer_Address
with System.Task_Primitives.Operations;
-- Used for Write_Lock
-- Unlock
-- Lock/Unlock_RTS
with System.Tasking;
-- Used for Access_Address
-- Task_Id
-- Direct_Index_Vector
-- Direct_Index
with System.Tasking.Initialization;
-- Used for Defer_Abortion
-- Undefer_Abortion
-- Initialize_Attributes_Link
-- Finalize_Attributes_Link
with System.Tasking.Task_Attributes;
-- Used for Access_Node
-- Access_Dummy_Wrapper
-- Deallocator
-- Instance
-- Node
-- Access_Instance
with Ada.Exceptions;
-- Used for Raise_Exception
with Unchecked_Conversion;
with Unchecked_Deallocation;
pragma Elaborate_All (System.Tasking.Task_Attributes);
-- To ensure the initialization of object Local (below) will work
package body Ada.Task_Attributes is
use System.Error_Reporting,
System.Tasking.Initialization,
System.Tasking,
System.Tasking.Task_Attributes,
Ada.Exceptions;
use type System.Tasking.Access_Address;
package POP renames System.Task_Primitives.Operations;
---------------------------
-- Unchecked Conversions --
---------------------------
-- The following type corresponds to Dummy_Wrapper,
-- declared in System.Tasking.Task_Attributes.
type Wrapper;
type Access_Wrapper is access all Wrapper;
pragma Warnings (Off);
-- We turn warnings off for the following declarations of the
-- To_Attribute_Handle conversions, since these are used only for small
-- attributes where we know that there are no problems with alignment, but
-- the compiler will generate warnings for the occurrences in the large
-- attribute case, even though they will not actually be used.
function To_Attribute_Handle is new Unchecked_Conversion
(System.Address, Attribute_Handle);
function To_Direct_Attribute_Element is new Unchecked_Conversion
(System.Address, Direct_Attribute_Element);
-- For reference to directly addressed task attributes
type Access_Integer_Address is access all
System.Storage_Elements.Integer_Address;
function To_Attribute_Handle is new Unchecked_Conversion
(Access_Integer_Address, Attribute_Handle);
-- For reference to directly addressed task attributes
pragma Warnings (On);
-- End of warnings off region for directly addressed
-- attribute conversion functions.
function To_Access_Address is new Unchecked_Conversion
(Access_Node, Access_Address);
-- To store pointer to list of indirect attributes
pragma Warnings (Off);
function To_Access_Wrapper is new Unchecked_Conversion
(Access_Dummy_Wrapper, Access_Wrapper);
pragma Warnings (On);
-- To fetch pointer to actual wrapper of attribute node. We turn off
-- warnings since this may generate an alignment warning. The warning can
-- be ignored since Dummy_Wrapper is only a non-generic standin for the
-- real wrapper type (we never actually allocate objects of type
-- Dummy_Wrapper).
function To_Access_Dummy_Wrapper is new Unchecked_Conversion
(Access_Wrapper, Access_Dummy_Wrapper);
-- To store pointer to actual wrapper of attribute node
function To_Task_Id is new Unchecked_Conversion
(Task_Identification.Task_Id, Task_Id);
-- To access TCB of identified task
type Local_Deallocator is access procedure (P : in out Access_Node);
function To_Lib_Level_Deallocator is new Unchecked_Conversion
(Local_Deallocator, Deallocator);
-- To defeat accessibility check
pragma Warnings (On);
------------------------
-- Storage Management --
------------------------
procedure Deallocate (P : in out Access_Node);
-- Passed to the RTS via unchecked conversion of a pointer to
-- permit finalization and deallocation of attribute storage nodes
--------------------------
-- Instantiation Record --
--------------------------
Local : aliased Instance;
-- Initialized in package body
type Wrapper is record
Dummy_Node : aliased Node;
Value : aliased Attribute := Initial_Value;
-- The generic formal type, may be controlled
end record;
-- A number of unchecked conversions involving Wrapper_Access sources
-- are performed in this unit. We have to ensure that the designated
-- object is always strictly enough aligned.
for Wrapper'Alignment use Standard'Maximum_Alignment;
procedure Free is
new Unchecked_Deallocation (Wrapper, Access_Wrapper);
procedure Deallocate (P : in out Access_Node) is
T : Access_Wrapper := To_Access_Wrapper (P.Wrapper);
begin
Free (T);
end Deallocate;
---------------
-- Reference --
---------------
function Reference
(T : Task_Identification.Task_Id := Task_Identification.Current_Task)
return Attribute_Handle
is
TT : constant Task_Id := To_Task_Id (T);
Error_Message : constant String := "Trying to get the reference of a ";
begin
if TT = null then
Raise_Exception (Program_Error'Identity, Error_Message & "null task");
end if;
if TT.Common.State = Terminated then
Raise_Exception (Tasking_Error'Identity,
Error_Message & "terminated task");
end if;
-- Directly addressed case
if Local.Index /= 0 then
-- Return the attribute handle. Warnings off because this return
-- statement generates alignment warnings for large attributes
-- (but will never be executed in this case anyway).
pragma Warnings (Off);
return
To_Attribute_Handle (TT.Direct_Attributes (Local.Index)'Address);
pragma Warnings (On);
-- Not directly addressed
else
declare
P : Access_Node := To_Access_Node (TT.Indirect_Attributes);
W : Access_Wrapper;
Self_Id : constant Task_Id := POP.Self;
begin
Defer_Abort (Self_Id);
POP.Lock_RTS;
while P /= null loop
if P.Instance = Access_Instance'(Local'Unchecked_Access) then
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
return To_Access_Wrapper (P.Wrapper).Value'Access;
end if;
P := P.Next;
end loop;
-- Unlock the RTS here to follow the lock ordering rule
-- that prevent us from using new (i.e the Global_Lock) while
-- holding any other lock.
POP.Unlock_RTS;
W := new Wrapper'
((null, Local'Unchecked_Access, null), Initial_Value);
POP.Lock_RTS;
P := W.Dummy_Node'Unchecked_Access;
P.Wrapper := To_Access_Dummy_Wrapper (W);
P.Next := To_Access_Node (TT.Indirect_Attributes);
TT.Indirect_Attributes := To_Access_Address (P);
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
return W.Value'Access;
exception
when others =>
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
raise;
end;
end if;
pragma Assert (Shutdown ("Should never get here in Reference"));
return null;
exception
when Tasking_Error | Program_Error =>
raise;
when others =>
raise Program_Error;
end Reference;
------------------
-- Reinitialize --
------------------
procedure Reinitialize
(T : Task_Identification.Task_Id := Task_Identification.Current_Task)
is
TT : constant Task_Id := To_Task_Id (T);
Error_Message : constant String := "Trying to Reinitialize a ";
begin
if TT = null then
Raise_Exception (Program_Error'Identity, Error_Message & "null task");
end if;
if TT.Common.State = Terminated then
Raise_Exception (Tasking_Error'Identity,
Error_Message & "terminated task");
end if;
if Local.Index /= 0 then
Set_Value (Initial_Value, T);
else
declare
P, Q : Access_Node;
W : Access_Wrapper;
Self_Id : constant Task_Id := POP.Self;
begin
Defer_Abort (Self_Id);
POP.Lock_RTS;
Q := To_Access_Node (TT.Indirect_Attributes);
while Q /= null loop
if Q.Instance = Access_Instance'(Local'Unchecked_Access) then
if P = null then
TT.Indirect_Attributes := To_Access_Address (Q.Next);
else
P.Next := Q.Next;
end if;
W := To_Access_Wrapper (Q.Wrapper);
Free (W);
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
return;
end if;
P := Q;
Q := Q.Next;
end loop;
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
exception
when others =>
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
raise;
end;
end if;
exception
when Tasking_Error | Program_Error =>
raise;
when others =>
raise Program_Error;
end Reinitialize;
---------------
-- Set_Value --
---------------
procedure Set_Value
(Val : Attribute;
T : Task_Identification.Task_Id := Task_Identification.Current_Task)
is
TT : constant Task_Id := To_Task_Id (T);
Error_Message : constant String := "Trying to Set the Value of a ";
begin
if TT = null then
Raise_Exception (Program_Error'Identity, Error_Message & "null task");
end if;
if TT.Common.State = Terminated then
Raise_Exception (Tasking_Error'Identity,
Error_Message & "terminated task");
end if;
-- Directly addressed case
if Local.Index /= 0 then
-- Set attribute handle, warnings off, because this code can generate
-- alignment warnings with large attributes (but of course will not
-- be executed in this case, since we never have direct addressing in
-- such cases).
pragma Warnings (Off);
To_Attribute_Handle
(TT.Direct_Attributes (Local.Index)'Address).all := Val;
pragma Warnings (On);
return;
end if;
-- Not directly addressed
declare
P : Access_Node := To_Access_Node (TT.Indirect_Attributes);
W : Access_Wrapper;
Self_Id : constant Task_Id := POP.Self;
begin
Defer_Abort (Self_Id);
POP.Lock_RTS;
while P /= null loop
if P.Instance = Access_Instance'(Local'Unchecked_Access) then
To_Access_Wrapper (P.Wrapper).Value := Val;
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
return;
end if;
P := P.Next;
end loop;
-- Unlock RTS here to follow the lock ordering rule that prevent us
-- from using new (i.e the Global_Lock) while holding any other
-- lock.
POP.Unlock_RTS;
W := new Wrapper'((null, Local'Unchecked_Access, null), Val);
POP.Lock_RTS;
P := W.Dummy_Node'Unchecked_Access;
P.Wrapper := To_Access_Dummy_Wrapper (W);
P.Next := To_Access_Node (TT.Indirect_Attributes);
TT.Indirect_Attributes := To_Access_Address (P);
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
exception
when others =>
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
raise;
end;
exception
when Tasking_Error | Program_Error =>
raise;
when others =>
raise Program_Error;
end Set_Value;
-----------
-- Value --
-----------
function Value
(T : Task_Identification.Task_Id := Task_Identification.Current_Task)
return Attribute
is
TT : constant Task_Id := To_Task_Id (T);
Error_Message : constant String := "Trying to get the Value of a ";
begin
if TT = null then
Raise_Exception (Program_Error'Identity, Error_Message & "null task");
end if;
if TT.Common.State = Terminated then
Raise_Exception
(Program_Error'Identity, Error_Message & "terminated task");
end if;
-- Directly addressed case
if Local.Index /= 0 then
-- Get value of attribute. Warnings off, because for large
-- attributes, this code can generate alignment warnings. But of
-- course large attributes are never directly addressed so in fact
-- we will never execute the code in this case.
pragma Warnings (Off);
return To_Attribute_Handle
(TT.Direct_Attributes (Local.Index)'Address).all;
pragma Warnings (On);
end if;
-- Not directly addressed
declare
P : Access_Node;
Result : Attribute;
Self_Id : constant Task_Id := POP.Self;
begin
Defer_Abort (Self_Id);
POP.Lock_RTS;
P := To_Access_Node (TT.Indirect_Attributes);
while P /= null loop
if P.Instance = Access_Instance'(Local'Unchecked_Access) then
Result := To_Access_Wrapper (P.Wrapper).Value;
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
return Result;
end if;
P := P.Next;
end loop;
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
return Initial_Value;
exception
when others =>
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
raise;
end;
exception
when Tasking_Error | Program_Error =>
raise;
when others =>
raise Program_Error;
end Value;
-- Start of elaboration code for package Ada.Task_Attributes
begin
-- This unchecked conversion can give warnings when alignments
-- are incorrect, but they will not be used in such cases anyway,
-- so the warnings can be safely ignored.
pragma Warnings (Off);
Local.Deallocate := To_Lib_Level_Deallocator (Deallocate'Access);
pragma Warnings (On);
declare
Two_To_J : Direct_Index_Vector;
Self_Id : constant Task_Id := POP.Self;
begin
Defer_Abort (Self_Id);
-- Need protection for updating links to per-task initialization and
-- finalization routines, in case some task is being created or
-- terminated concurrently.
POP.Lock_RTS;
-- Add this instantiation to the list of all instantiations
Local.Next := System.Tasking.Task_Attributes.All_Attributes;
System.Tasking.Task_Attributes.All_Attributes :=
Local'Unchecked_Access;
-- Try to find space for the attribute in the TCB
Local.Index := 0;
Two_To_J := 1;
if Attribute'Size <= System.Address'Size then
for J in Direct_Index_Range loop
if (Two_To_J and In_Use) = 0 then
-- Reserve location J for this attribute
In_Use := In_Use or Two_To_J;
Local.Index := J;
-- This unchecked conversions can give a warning when the the
-- alignment is incorrect, but it will not be used in such a
-- case anyway, so the warning can be safely ignored.
pragma Warnings (Off);
To_Attribute_Handle (Local.Initial_Value'Access).all :=
Initial_Value;
pragma Warnings (On);
exit;
end if;
Two_To_J := Two_To_J * 2;
end loop;
end if;
-- Attribute goes directly in the TCB
if Local.Index /= 0 then
-- Replace stub for initialization routine that is called at task
-- creation.
Initialization.Initialize_Attributes_Link :=
System.Tasking.Task_Attributes.Initialize_Attributes'Access;
-- Initialize the attribute, for all tasks
declare
C : System.Tasking.Task_Id := System.Tasking.All_Tasks_List;
begin
while C /= null loop
C.Direct_Attributes (Local.Index) :=
To_Direct_Attribute_Element
(System.Storage_Elements.To_Address (Local.Initial_Value));
C := C.Common.All_Tasks_Link;
end loop;
end;
-- Attribute goes into a node onto a linked list
else
-- Replace stub for finalization routine that is called at task
-- termination.
Initialization.Finalize_Attributes_Link :=
System.Tasking.Task_Attributes.Finalize_Attributes'Access;
end if;
POP.Unlock_RTS;
Undefer_Abort (Self_Id);
end;
end Ada.Task_Attributes;
|
--- tools/configure/configure-tests-sqlite3.adb.orig 2015-05-13 12:17:27 UTC
+++ tools/configure/configure-tests-sqlite3.adb
@@ -87,7 +87,7 @@ package body Configure.Tests.SQLite3 is
(SQLite3_Library_Options,
+"""-L"
& Self.Switches.Libdir
- & """, ""-lsqlite3""");
+ & """, ""-Lsqlite3"", ""-Wl,-rpath,@PREFIX@/lib""");
Self.Report_Status ("yes (command line)");
@@ -126,6 +126,7 @@ package body Configure.Tests.SQLite3 is
Append (Opts, '"');
end loop;
+ Append (Opts, ", ""-Wl,-rpath,@PREFIX@/lib""");
Substitutions.Insert (SQLite3_Library_Options, Opts);
Self.Report_Status (+Opts);
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015-2016, 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$
------------------------------------------------------------------------------
-- Routines to convert HTTP date to/from string according to RFC-2616
with League.Strings;
with League.Calendars;
package Matreshka.RFC2616_Dates is
pragma Preelaborate;
type Format is tagged private;
procedure From_String
(Self : Format;
Text : League.Strings.Universal_String;
Value : out League.Calendars.Date_Time;
Success : out Boolean);
function To_String
(Self : Format;
Value : League.Calendars.Date_Time)
return League.Strings.Universal_String;
private
function "+"
(Text : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
type Format is tagged record
Month_List : League.Strings.Universal_String
:= +" JanFebMarAprMayJunJulAugSepOctNovDec";
GMT : League.Strings.Universal_String := +"GMT";
Pattern : League.Strings.Universal_String
:= +"EEE, dd MMM yyyy HH:mm:ss ";
end record;
end Matreshka.RFC2616_Dates;
|
-- CD2A24E.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 IF A SIZE CLAUSE AND AN ENUMERATION
-- REPRESENTATION CLAUSE ARE GIVEN FOR AN ENUMERATION TYPE,
-- AND THE SMALLEST SIZE APPROPRIATE FOR AN UNSIGNED REPRESENTATION
-- IS SPECIFIED, THEN OPERATIONS ON THE TYPE ARE NOT AFFECTED.
-- HISTORY:
-- JET 08/19/87 CREATED ORIGINAL TEST.
-- PWB 05/11/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA'.
-- WMC 03/27/92 ELIMINATED TEST REDUNDANCIES.
WITH REPORT; USE REPORT;
PROCEDURE CD2A24E IS
BASIC_SIZE : CONSTANT := 3;
TYPE CHECK_TYPE IS (ZERO, ONE, TWO);
FOR CHECK_TYPE USE (ZERO => 3, ONE => 4,
TWO => 5);
FOR CHECK_TYPE'SIZE USE BASIC_SIZE;
C0 : CHECK_TYPE := ZERO;
C1 : CHECK_TYPE := ONE;
C2 : CHECK_TYPE := TWO;
TYPE ARRAY_TYPE IS ARRAY (0 .. 2) OF CHECK_TYPE;
CHARRAY : ARRAY_TYPE := (ZERO, ONE, TWO);
TYPE REC_TYPE IS RECORD
COMP0 : CHECK_TYPE := ZERO;
COMP1 : CHECK_TYPE := ONE;
COMP2 : CHECK_TYPE := TWO;
END RECORD;
CHREC : REC_TYPE;
FUNCTION IDENT (CH : CHECK_TYPE) RETURN CHECK_TYPE IS
BEGIN
IF EQUAL (3, 3) THEN
RETURN CH;
ELSE
RETURN ONE;
END IF;
END IDENT;
PROCEDURE PROC (CI0, CI2 : CHECK_TYPE;
CIO1, CIO2 : IN OUT CHECK_TYPE;
CO2 : OUT CHECK_TYPE) IS
BEGIN
IF NOT ((CI0 < IDENT (ONE)) AND
(IDENT (CI2) > IDENT (CIO1)) AND
(CIO1 <= IDENT (ONE)) AND(IDENT (TWO) = CI2)) THEN
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS " &
"- 1");
END IF;
IF CHECK_TYPE'POS (CI0) /= IDENT_INT (0) OR
CHECK_TYPE'POS (CIO1) /= IDENT_INT (1) OR
CHECK_TYPE'POS (CI2) /= IDENT_INT (2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'POS - 1");
END IF;
IF CHECK_TYPE'SUCC (CI0) /= IDENT (CIO1) OR
CHECK_TYPE'SUCC (CIO1) /= IDENT (CI2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SUCC - 1");
END IF;
IF CHECK_TYPE'IMAGE (CI0) /= IDENT_STR ("ZERO") OR
CHECK_TYPE'IMAGE (CIO1) /= IDENT_STR ("ONE") OR
CHECK_TYPE'IMAGE (CI2) /= IDENT_STR ("TWO") THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'IMAGE - 1");
END IF;
CO2 := TWO;
END PROC;
BEGIN
TEST ("CD2A24E", "CHECK THAT IF A SIZE CLAUSE AND AN ENUMERATION " &
"REPRESENTATION CLAUSE ARE GIVEN FOR AN " &
"ENUMERATION TYPE, AND THE SMALLEST SIZE " &
"APPROPRIATE FOR AN UNSIGNED REPRESENTATION " &
"IS SPECIFIED, THEN OPERATIONS ON THE TYPE " &
"ARE NOT AFFECTED");
PROC (ZERO, TWO, C1, C2, C2);
IF C1 /= ONE OR C2 /= TWO THEN
FAILED ("INCORRECT VALUE RETURNED BY PROCEDURE");
END IF;
IF CHECK_TYPE'SIZE /= IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SIZE");
END IF;
IF C0'SIZE < IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR C0'SIZE");
END IF;
IF NOT ((IDENT (C1) IN C1 .. C2) AND
(C0 NOT IN IDENT (ONE) .. C2)) THEN
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP OPERATORS - 2");
END IF;
IF CHECK_TYPE'FIRST /= IDENT (ZERO) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'FIRST - 2");
END IF;
IF CHECK_TYPE'VAL (0) /= IDENT (C0) OR
CHECK_TYPE'VAL (1) /= IDENT (C1) OR
CHECK_TYPE'VAL (2) /= IDENT (C2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VAL - 2");
END IF;
IF CHECK_TYPE'PRED (C1) /= IDENT (C0) OR
CHECK_TYPE'PRED (C2) /= IDENT (C1) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'PRED - 2");
END IF;
IF CHECK_TYPE'VALUE ("ZERO") /= IDENT (C0) OR
CHECK_TYPE'VALUE ("ONE") /= IDENT (C1) OR
CHECK_TYPE'VALUE ("TWO") /= IDENT (C2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VALUE - 2");
END IF;
IF CHARRAY(1)'SIZE < IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR CHARRAY(1)'SIZE");
END IF;
IF NOT ((CHARRAY (0) < IDENT (ONE)) AND
(IDENT (CHARRAY (2)) > IDENT (CHARRAY (1))) AND
(CHARRAY (1) <= IDENT (ONE)) AND
(IDENT (TWO) = CHARRAY (2))) THEN
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 3");
END IF;
IF NOT ((IDENT (CHARRAY (1)) IN CHARRAY (1) .. CHARRAY (2)) AND
(CHARRAY (0) NOT IN IDENT (ONE) .. CHARRAY (2))) THEN
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP OPERATORS - 3");
END IF;
IF CHECK_TYPE'POS (CHARRAY (0)) /= IDENT_INT (0) OR
CHECK_TYPE'POS (CHARRAY (1)) /= IDENT_INT (1) OR
CHECK_TYPE'POS (CHARRAY (2)) /= IDENT_INT (2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'POS - 3");
END IF;
IF CHECK_TYPE'SUCC (CHARRAY (0)) /= IDENT (CHARRAY (1)) OR
CHECK_TYPE'SUCC (CHARRAY (1)) /= IDENT (CHARRAY (2)) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SUCC - 3");
END IF;
IF CHECK_TYPE'IMAGE (CHARRAY (0)) /= IDENT_STR ("ZERO") OR
CHECK_TYPE'IMAGE (CHARRAY (1)) /= IDENT_STR ("ONE") OR
CHECK_TYPE'IMAGE (CHARRAY (2)) /= IDENT_STR ("TWO") THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'IMAGE - 3");
END IF;
IF CHREC.COMP2'SIZE < IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR CHREC.COMP2'SIZE");
END IF;
IF NOT ((CHREC.COMP0 < IDENT (ONE)) AND
(IDENT (CHREC.COMP2) > IDENT (CHREC.COMP1)) AND
(CHREC.COMP1 <= IDENT (ONE)) AND
(IDENT (TWO) = CHREC.COMP2)) THEN
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 4");
END IF;
IF NOT ((IDENT (CHREC.COMP1) IN CHREC.COMP1 .. CHREC.COMP2) AND
(CHREC.COMP0 NOT IN IDENT (ONE) .. CHREC.COMP2)) THEN
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP OPERATORS - 4");
END IF;
IF CHECK_TYPE'VAL (0) /= IDENT (CHREC.COMP0) OR
CHECK_TYPE'VAL (1) /= IDENT (CHREC.COMP1) OR
CHECK_TYPE'VAL (2) /= IDENT (CHREC.COMP2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VAL - 4");
END IF;
IF CHECK_TYPE'PRED (CHREC.COMP1) /= IDENT (CHREC.COMP0) OR
CHECK_TYPE'PRED (CHREC.COMP2) /= IDENT (CHREC.COMP1) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'PRED - 4");
END IF;
IF CHECK_TYPE'VALUE ("ZERO") /= IDENT (CHREC.COMP0) OR
CHECK_TYPE'VALUE ("ONE") /= IDENT (CHREC.COMP1) OR
CHECK_TYPE'VALUE ("TWO") /= IDENT (CHREC.COMP2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VALUE - 4");
END IF;
RESULT;
END CD2A24E;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ A T T R --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Aspects; use Aspects;
with Atree; use Atree;
with Casing; use Casing;
with Checks; use Checks;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Eval_Fat;
with Exp_Dist; use Exp_Dist;
with Exp_Util; use Exp_Util;
with Expander; use Expander;
with Freeze; use Freeze;
with Gnatvsn; use Gnatvsn;
with Itypes; use Itypes;
with Lib; use Lib;
with Lib.Xref; use Lib.Xref;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Restrict; use Restrict;
with Rident; use Rident;
with Rtsfind; use Rtsfind;
with Sdefault;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Cat; use Sem_Cat;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch10; use Sem_Ch10;
with Sem_Dim; use Sem_Dim;
with Sem_Dist; use Sem_Dist;
with Sem_Elab; use Sem_Elab;
with Sem_Elim; use Sem_Elim;
with Sem_Eval; use Sem_Eval;
with Sem_Prag; use Sem_Prag;
with Sem_Res; use Sem_Res;
with Sem_Type; use Sem_Type;
with Sem_Util; use Sem_Util;
with Sem_Warn;
with Stand; use Stand;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with System;
with Stringt; use Stringt;
with Style;
with Stylesw; use Stylesw;
with Targparm; use Targparm;
with Ttypes; use Ttypes;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
with Uname; use Uname;
with Urealp; use Urealp;
with System.CRC32; use System.CRC32;
package body Sem_Attr is
True_Value : constant Uint := Uint_1;
False_Value : constant Uint := Uint_0;
-- Synonyms to be used when these constants are used as Boolean values
Bad_Attribute : exception;
-- Exception raised if an error is detected during attribute processing,
-- used so that we can abandon the processing so we don't run into
-- trouble with cascaded errors.
-- The following array is the list of attributes defined in the Ada 83 RM.
-- In Ada 83 mode, these are the only recognized attributes. In other Ada
-- modes all these attributes are recognized, even if removed in Ada 95.
Attribute_83 : constant Attribute_Class_Array := Attribute_Class_Array'(
Attribute_Address |
Attribute_Aft |
Attribute_Alignment |
Attribute_Base |
Attribute_Callable |
Attribute_Constrained |
Attribute_Count |
Attribute_Delta |
Attribute_Digits |
Attribute_Emax |
Attribute_Epsilon |
Attribute_First |
Attribute_First_Bit |
Attribute_Fore |
Attribute_Image |
Attribute_Large |
Attribute_Last |
Attribute_Last_Bit |
Attribute_Leading_Part |
Attribute_Length |
Attribute_Machine_Emax |
Attribute_Machine_Emin |
Attribute_Machine_Mantissa |
Attribute_Machine_Overflows |
Attribute_Machine_Radix |
Attribute_Machine_Rounds |
Attribute_Mantissa |
Attribute_Pos |
Attribute_Position |
Attribute_Pred |
Attribute_Range |
Attribute_Safe_Emax |
Attribute_Safe_Large |
Attribute_Safe_Small |
Attribute_Size |
Attribute_Small |
Attribute_Storage_Size |
Attribute_Succ |
Attribute_Terminated |
Attribute_Val |
Attribute_Value |
Attribute_Width => True,
others => False);
-- The following array is the list of attributes defined in the Ada 2005
-- RM which are not defined in Ada 95. These are recognized in Ada 95 mode,
-- but in Ada 95 they are considered to be implementation defined.
Attribute_05 : constant Attribute_Class_Array := Attribute_Class_Array'(
Attribute_Machine_Rounding |
Attribute_Mod |
Attribute_Priority |
Attribute_Stream_Size |
Attribute_Wide_Wide_Width => True,
others => False);
-- The following array is the list of attributes defined in the Ada 2012
-- RM which are not defined in Ada 2005. These are recognized in Ada 95
-- and Ada 2005 modes, but are considered to be implementation defined.
Attribute_12 : constant Attribute_Class_Array := Attribute_Class_Array'(
Attribute_First_Valid |
Attribute_Has_Same_Storage |
Attribute_Last_Valid |
Attribute_Max_Alignment_For_Allocation => True,
others => False);
-- The following array is the list of attributes defined in the Ada 2020
-- RM which are not defined in Ada 2012. These are recognized in Ada
-- 95/2005/2012 modes, but are considered to be implementation defined.
Attribute_20 : constant Attribute_Class_Array := Attribute_Class_Array'(
Attribute_Enum_Rep |
Attribute_Enum_Val => True,
others => False);
-- The following array contains all attributes that imply a modification
-- of their prefixes or result in an access value. Such prefixes can be
-- considered as lvalues.
Attribute_Name_Implies_Lvalue_Prefix : constant Attribute_Class_Array :=
Attribute_Class_Array'(
Attribute_Access |
Attribute_Address |
Attribute_Input |
Attribute_Read |
Attribute_Unchecked_Access |
Attribute_Unrestricted_Access => True,
others => False);
-----------------------
-- Local_Subprograms --
-----------------------
procedure Eval_Attribute (N : Node_Id);
-- Performs compile time evaluation of attributes where possible, leaving
-- the Is_Static_Expression/Raises_Constraint_Error flags appropriately
-- set, and replacing the node with a literal node if the value can be
-- computed at compile time. All static attribute references are folded,
-- as well as a number of cases of non-static attributes that can always
-- be computed at compile time (e.g. floating-point model attributes that
-- are applied to non-static subtypes). Of course in such cases, the
-- Is_Static_Expression flag will not be set on the resulting literal.
-- Note that the only required action of this procedure is to catch the
-- static expression cases as described in the RM. Folding of other cases
-- is done where convenient, but some additional non-static folding is in
-- Expand_N_Attribute_Reference in cases where this is more convenient.
function Is_Anonymous_Tagged_Base
(Anon : Entity_Id;
Typ : Entity_Id) return Boolean;
-- For derived tagged types that constrain parent discriminants we build
-- an anonymous unconstrained base type. We need to recognize the relation
-- between the two when analyzing an access attribute for a constrained
-- component, before the full declaration for Typ has been analyzed, and
-- where therefore the prefix of the attribute does not match the enclosing
-- scope.
procedure Set_Boolean_Result (N : Node_Id; B : Boolean);
-- Rewrites node N with an occurrence of either Standard_False or
-- Standard_True, depending on the value of the parameter B. The
-- result is marked as a static expression.
-----------------------
-- Analyze_Attribute --
-----------------------
procedure Analyze_Attribute (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Aname : constant Name_Id := Attribute_Name (N);
P : constant Node_Id := Prefix (N);
Exprs : constant List_Id := Expressions (N);
Attr_Id : constant Attribute_Id := Get_Attribute_Id (Aname);
E1 : Node_Id;
E2 : Node_Id;
P_Type : Entity_Id := Empty;
-- Type of prefix after analysis
P_Base_Type : Entity_Id := Empty;
-- Base type of prefix after analysis
-----------------------
-- Local Subprograms --
-----------------------
procedure Address_Checks;
-- Semantic checks for valid use of Address attribute. This was made
-- a separate routine with the idea of using it for unrestricted access
-- which seems like it should follow the same rules, but that turned
-- out to be impractical. So now this is only used for Address.
procedure Analyze_Access_Attribute;
-- Used for Access, Unchecked_Access, Unrestricted_Access attributes.
-- Internally, Id distinguishes which of the three cases is involved.
procedure Analyze_Attribute_Old_Result
(Legal : out Boolean;
Spec_Id : out Entity_Id);
-- Common processing for attributes 'Old and 'Result. The routine checks
-- that the attribute appears in a postcondition-like aspect or pragma
-- associated with a suitable subprogram or a body. Flag Legal is set
-- when the above criteria are met. Spec_Id denotes the entity of the
-- subprogram [body] or Empty if the attribute is illegal.
procedure Analyze_Image_Attribute (Str_Typ : Entity_Id);
-- Common processing for attributes 'Img, 'Image, 'Wide_Image, and
-- 'Wide_Wide_Image. The routine checks that the prefix is valid and
-- sets the type of the attribute to the one specified by Str_Typ (e.g.
-- Standard_String for 'Image and Standard_Wide_String for 'Wide_Image).
procedure Bad_Attribute_For_Predicate;
-- Output error message for use of a predicate (First, Last, Range) not
-- allowed with a type that has predicates. If the type is a generic
-- actual, then the message is a warning, and we generate code to raise
-- program error with an appropriate reason. No error message is given
-- for internally generated uses of the attributes. This legality rule
-- only applies to scalar types.
procedure Check_Array_Or_Scalar_Type;
-- Common procedure used by First, Last, Range attribute to check
-- that the prefix is a constrained array or scalar type, or a name
-- of an array object, and that an argument appears only if appropriate
-- (i.e. only in the array case).
procedure Check_Array_Type;
-- Common semantic checks for all array attributes. Checks that the
-- prefix is a constrained array type or the name of an array object.
-- The error message for non-arrays is specialized appropriately.
procedure Check_Asm_Attribute;
-- Common semantic checks for Asm_Input and Asm_Output attributes
procedure Check_Component;
-- Common processing for Bit_Position, First_Bit, Last_Bit, and
-- Position. Checks prefix is an appropriate selected component.
procedure Check_Decimal_Fixed_Point_Type;
-- Check that prefix of attribute N is a decimal fixed-point type
procedure Check_Dereference;
-- If the prefix of attribute is an object of an access type, then
-- introduce an explicit dereference, and adjust P_Type accordingly.
procedure Check_Discrete_Type;
-- Verify that prefix of attribute N is a discrete type
procedure Check_E0;
-- Check that no attribute arguments are present
procedure Check_Either_E0_Or_E1;
-- Check that there are zero or one attribute arguments present
procedure Check_E1;
-- Check that exactly one attribute argument is present
procedure Check_E2;
-- Check that two attribute arguments are present
procedure Check_Enum_Image;
-- If the prefix type of 'Image is an enumeration type, set all its
-- literals as referenced, since the image function could possibly end
-- up referencing any of the literals indirectly. Same for Enum_Val.
-- Set the flag only if the reference is in the main code unit. Same
-- restriction when resolving 'Value; otherwise an improperly set
-- reference when analyzing an inlined body will lose a proper
-- warning on a useless with_clause.
procedure Check_First_Last_Valid;
-- Perform all checks for First_Valid and Last_Valid attributes
procedure Check_Fixed_Point_Type;
-- Verify that prefix of attribute N is a fixed type
procedure Check_Fixed_Point_Type_0;
-- Verify that prefix of attribute N is a fixed type and that
-- no attribute expressions are present.
procedure Check_Floating_Point_Type;
-- Verify that prefix of attribute N is a float type
procedure Check_Floating_Point_Type_0;
-- Verify that prefix of attribute N is a float type and that
-- no attribute expressions are present.
procedure Check_Floating_Point_Type_1;
-- Verify that prefix of attribute N is a float type and that
-- exactly one attribute expression is present.
procedure Check_Floating_Point_Type_2;
-- Verify that prefix of attribute N is a float type and that
-- two attribute expressions are present
procedure Check_Integer_Type;
-- Verify that prefix of attribute N is an integer type
procedure Check_Modular_Integer_Type;
-- Verify that prefix of attribute N is a modular integer type
procedure Check_Not_CPP_Type;
-- Check that P (the prefix of the attribute) is not an CPP type
-- for which no Ada predefined primitive is available.
procedure Check_Not_Incomplete_Type;
-- Check that P (the prefix of the attribute) is not an incomplete
-- type or a private type for which no full view has been given.
procedure Check_Object_Reference (P : Node_Id);
-- Check that P is an object reference
procedure Check_PolyORB_Attribute;
-- Validity checking for PolyORB/DSA attribute
procedure Check_Program_Unit;
-- Verify that prefix of attribute N is a program unit
procedure Check_Real_Type;
-- Verify that prefix of attribute N is fixed or float type
procedure Check_Scalar_Type;
-- Verify that prefix of attribute N is a scalar type
procedure Check_Standard_Prefix;
-- Verify that prefix of attribute N is package Standard. Also checks
-- that there are no arguments.
procedure Check_Stream_Attribute (Nam : TSS_Name_Type);
-- Validity checking for stream attribute. Nam is the TSS name of the
-- corresponding possible defined attribute function (e.g. for the
-- Read attribute, Nam will be TSS_Stream_Read).
procedure Check_Put_Image_Attribute;
-- Validity checking for Put_Image attribute
procedure Check_System_Prefix;
-- Verify that prefix of attribute N is package System
procedure Check_Task_Prefix;
-- Verify that prefix of attribute N is a task or task type
procedure Check_Type;
-- Verify that the prefix of attribute N is a type
procedure Check_Unit_Name (Nod : Node_Id);
-- Check that Nod is of the form of a library unit name, i.e that
-- it is an identifier, or a selected component whose prefix is
-- itself of the form of a library unit name. Note that this is
-- quite different from Check_Program_Unit, since it only checks
-- the syntactic form of the name, not the semantic identity. This
-- is because it is used with attributes (Elab_Body, Elab_Spec and
-- Elaborated) which can refer to non-visible unit.
procedure Error_Attr (Msg : String; Error_Node : Node_Id);
pragma No_Return (Error_Attr);
procedure Error_Attr;
pragma No_Return (Error_Attr);
-- Posts error using Error_Msg_N at given node, sets type of attribute
-- node to Any_Type, and then raises Bad_Attribute to avoid any further
-- semantic processing. The message typically contains a % insertion
-- character which is replaced by the attribute name. The call with
-- no arguments is used when the caller has already generated the
-- required error messages.
procedure Error_Attr_P (Msg : String);
pragma No_Return (Error_Attr_P);
-- Like Error_Attr, but error is posted at the start of the prefix
procedure Legal_Formal_Attribute;
-- Common processing for attributes Definite and Has_Discriminants.
-- Checks that prefix is generic indefinite formal type.
procedure Max_Alignment_For_Allocation_Max_Size_In_Storage_Elements;
-- Common processing for attributes Max_Alignment_For_Allocation and
-- Max_Size_In_Storage_Elements.
procedure Min_Max;
-- Common processing for attributes Max and Min
procedure Standard_Attribute (Val : Int);
-- Used to process attributes whose prefix is package Standard which
-- yield values of type Universal_Integer. The attribute reference
-- node is rewritten with an integer literal of the given value which
-- is marked as static.
procedure Uneval_Old_Msg;
-- Called when Loop_Entry or Old is used in a potentially unevaluated
-- expression. Generates appropriate message or warning depending on
-- the setting of Opt.Uneval_Old (or flags in an N_Aspect_Specification
-- node in the aspect case).
procedure Unexpected_Argument (En : Node_Id);
pragma No_Return (Unexpected_Argument);
-- Signal unexpected attribute argument (En is the argument), and then
-- raises Bad_Attribute to avoid any further semantic processing.
procedure Validate_Non_Static_Attribute_Function_Call;
-- Called when processing an attribute that is a function call to a
-- non-static function, i.e. an attribute function that either takes
-- non-scalar arguments or returns a non-scalar result. Verifies that
-- such a call does not appear in a preelaborable context.
--------------------
-- Address_Checks --
--------------------
procedure Address_Checks is
begin
-- An Address attribute created by expansion is legal even when it
-- applies to other entity-denoting expressions.
if not Comes_From_Source (N) then
return;
-- Address attribute on a protected object self reference is legal
elsif Is_Protected_Self_Reference (P) then
return;
-- Address applied to an entity
elsif Is_Entity_Name (P) then
declare
Ent : constant Entity_Id := Entity (P);
begin
if Is_Subprogram (Ent) then
Set_Address_Taken (Ent);
Kill_Current_Values (Ent);
-- An Address attribute is accepted when generated by the
-- compiler for dispatching operation, and an error is
-- issued once the subprogram is frozen (to avoid confusing
-- errors about implicit uses of Address in the dispatch
-- table initialization).
if Has_Pragma_Inline_Always (Entity (P))
and then Comes_From_Source (P)
then
Error_Attr_P
("prefix of % attribute cannot be Inline_Always "
& "subprogram");
-- It is illegal to apply 'Address to an intrinsic
-- subprogram. This is now formalized in AI05-0095.
-- In an instance, an attempt to obtain 'Address of an
-- intrinsic subprogram (e.g the renaming of a predefined
-- operator that is an actual) raises Program_Error.
elsif Convention (Ent) = Convention_Intrinsic then
if In_Instance then
Rewrite (N,
Make_Raise_Program_Error (Loc,
Reason => PE_Address_Of_Intrinsic));
else
Error_Msg_Name_1 := Aname;
Error_Msg_N
("cannot take % of intrinsic subprogram", N);
end if;
-- Issue an error if prefix denotes an eliminated subprogram
else
Check_For_Eliminated_Subprogram (P, Ent);
end if;
-- Object or label reference
elsif Is_Object_Reference (P) or else Ekind (Ent) = E_Label then
Set_Address_Taken (Ent);
-- Deal with No_Implicit_Aliasing restriction
if Restriction_Check_Required (No_Implicit_Aliasing) then
if not Is_Aliased_View (P) then
Check_Restriction (No_Implicit_Aliasing, P);
else
Check_No_Implicit_Aliasing (P);
end if;
end if;
-- If we have an address of an object, and the attribute
-- comes from source, then set the object as potentially
-- source modified. We do this because the resulting address
-- can potentially be used to modify the variable and we
-- might not detect this, leading to some junk warnings.
Set_Never_Set_In_Source (Ent, False);
-- Allow Address to be applied to task or protected type,
-- returning null address (what is that about???)
elsif (Is_Concurrent_Type (Etype (Ent))
and then Etype (Ent) = Base_Type (Ent))
or else Ekind (Ent) = E_Package
or else Is_Generic_Unit (Ent)
then
Rewrite (N,
New_Occurrence_Of (RTE (RE_Null_Address), Sloc (N)));
-- Anything else is illegal
else
Error_Attr ("invalid prefix for % attribute", P);
end if;
end;
-- Object is OK
elsif Is_Object_Reference (P) then
return;
-- Subprogram called using dot notation
elsif Nkind (P) = N_Selected_Component
and then Is_Subprogram (Entity (Selector_Name (P)))
then
return;
-- What exactly are we allowing here ??? and is this properly
-- documented in the sinfo documentation for this node ???
elsif Relaxed_RM_Semantics
and then Nkind (P) = N_Attribute_Reference
then
return;
-- All other non-entity name cases are illegal
else
Error_Attr ("invalid prefix for % attribute", P);
end if;
end Address_Checks;
------------------------------
-- Analyze_Access_Attribute --
------------------------------
procedure Analyze_Access_Attribute is
Acc_Type : Entity_Id;
Scop : Entity_Id;
Typ : Entity_Id;
function Build_Access_Object_Type (DT : Entity_Id) return Entity_Id;
-- Build an access-to-object type whose designated type is DT,
-- and whose Ekind is appropriate to the attribute type. The
-- type that is constructed is returned as the result.
procedure Build_Access_Subprogram_Type (P : Node_Id);
-- Build an access to subprogram whose designated type is the type of
-- the prefix. If prefix is overloaded, so is the node itself. The
-- result is stored in Acc_Type.
function OK_Self_Reference return Boolean;
-- An access reference whose prefix is a type can legally appear
-- within an aggregate, where it is obtained by expansion of
-- a defaulted aggregate. The enclosing aggregate that contains
-- the self-referenced is flagged so that the self-reference can
-- be expanded into a reference to the target object (see exp_aggr).
------------------------------
-- Build_Access_Object_Type --
------------------------------
function Build_Access_Object_Type (DT : Entity_Id) return Entity_Id is
Typ : constant Entity_Id :=
New_Internal_Entity
(E_Access_Attribute_Type, Current_Scope, Loc, 'A');
begin
Set_Etype (Typ, Typ);
Set_Is_Itype (Typ);
Set_Associated_Node_For_Itype (Typ, N);
Set_Directly_Designated_Type (Typ, DT);
return Typ;
end Build_Access_Object_Type;
----------------------------------
-- Build_Access_Subprogram_Type --
----------------------------------
procedure Build_Access_Subprogram_Type (P : Node_Id) is
Index : Interp_Index;
It : Interp;
procedure Check_Local_Access (E : Entity_Id);
-- Deal with possible access to local subprogram. If we have such
-- an access, we set a flag to kill all tracked values on any call
-- because this access value may be passed around, and any called
-- code might use it to access a local procedure which clobbers a
-- tracked value. If the scope is a loop or block, indicate that
-- value tracking is disabled for the enclosing subprogram.
function Get_Convention (E : Entity_Id) return Convention_Id;
function Get_Kind (E : Entity_Id) return Entity_Kind;
-- Distinguish between access to regular/protected subprograms
------------------------
-- Check_Local_Access --
------------------------
procedure Check_Local_Access (E : Entity_Id) is
begin
if not Is_Library_Level_Entity (E) then
Set_Suppress_Value_Tracking_On_Call (Current_Scope);
Set_Suppress_Value_Tracking_On_Call
(Nearest_Dynamic_Scope (Current_Scope));
end if;
end Check_Local_Access;
--------------------
-- Get_Convention --
--------------------
function Get_Convention (E : Entity_Id) return Convention_Id is
begin
-- Restrict handling by_protected_procedure access subprograms
-- to source entities; required to avoid building access to
-- subprogram types with convention protected when building
-- dispatch tables.
if Comes_From_Source (P)
and then Is_By_Protected_Procedure (E)
then
return Convention_Protected;
else
return Convention (E);
end if;
end Get_Convention;
--------------
-- Get_Kind --
--------------
function Get_Kind (E : Entity_Id) return Entity_Kind is
begin
if Get_Convention (E) = Convention_Protected then
return E_Access_Protected_Subprogram_Type;
else
return E_Access_Subprogram_Type;
end if;
end Get_Kind;
-- Start of processing for Build_Access_Subprogram_Type
begin
-- In the case of an access to subprogram, use the name of the
-- subprogram itself as the designated type. Type-checking in
-- this case compares the signatures of the designated types.
-- Note: This fragment of the tree is temporarily malformed
-- because the correct tree requires an E_Subprogram_Type entity
-- as the designated type. In most cases this designated type is
-- later overridden by the semantics with the type imposed by the
-- context during the resolution phase. In the specific case of
-- the expression Address!(Prim'Unrestricted_Access), used to
-- initialize slots of dispatch tables, this work will be done by
-- the expander (see Exp_Aggr).
-- The reason to temporarily add this kind of node to the tree
-- instead of a proper E_Subprogram_Type itype, is the following:
-- in case of errors found in the source file we report better
-- error messages. For example, instead of generating the
-- following error:
-- "expected access to subprogram with profile
-- defined at line X"
-- we currently generate:
-- "expected access to function Z defined at line X"
Set_Etype (N, Any_Type);
if not Is_Overloaded (P) then
Check_Local_Access (Entity (P));
if not Is_Intrinsic_Subprogram (Entity (P)) then
Acc_Type := Create_Itype (Get_Kind (Entity (P)), N);
Set_Is_Public (Acc_Type, False);
Set_Etype (Acc_Type, Acc_Type);
Set_Convention (Acc_Type, Get_Convention (Entity (P)));
Set_Directly_Designated_Type (Acc_Type, Entity (P));
Set_Etype (N, Acc_Type);
Freeze_Before (N, Acc_Type);
end if;
else
Get_First_Interp (P, Index, It);
while Present (It.Nam) loop
Check_Local_Access (It.Nam);
if not Is_Intrinsic_Subprogram (It.Nam) then
Acc_Type := Create_Itype (Get_Kind (It.Nam), N);
Set_Is_Public (Acc_Type, False);
Set_Etype (Acc_Type, Acc_Type);
Set_Convention (Acc_Type, Get_Convention (It.Nam));
Set_Directly_Designated_Type (Acc_Type, It.Nam);
Add_One_Interp (N, Acc_Type, Acc_Type);
Freeze_Before (N, Acc_Type);
end if;
Get_Next_Interp (Index, It);
end loop;
end if;
-- Cannot be applied to intrinsic. Looking at the tests above,
-- the only way Etype (N) can still be set to Any_Type is if
-- Is_Intrinsic_Subprogram was True for some referenced entity.
if Etype (N) = Any_Type then
Error_Attr_P ("prefix of % attribute cannot be intrinsic");
end if;
end Build_Access_Subprogram_Type;
----------------------
-- OK_Self_Reference --
----------------------
function OK_Self_Reference return Boolean is
Par : Node_Id;
begin
Par := Parent (N);
while Present (Par)
and then
(Nkind (Par) = N_Component_Association
or else Nkind (Par) in N_Subexpr)
loop
if Nkind (Par) in N_Aggregate | N_Extension_Aggregate then
if Etype (Par) = Typ then
Set_Has_Self_Reference (Par);
-- Check the context: the aggregate must be part of the
-- initialization of a type or component, or it is the
-- resulting expansion in an initialization procedure.
if Is_Init_Proc (Current_Scope) then
return True;
else
Par := Parent (Par);
while Present (Par) loop
if Nkind (Par) = N_Full_Type_Declaration then
return True;
end if;
Par := Parent (Par);
end loop;
end if;
return False;
end if;
end if;
Par := Parent (Par);
end loop;
-- No enclosing aggregate, or not a self-reference
return False;
end OK_Self_Reference;
-- Start of processing for Analyze_Access_Attribute
begin
-- Access and Unchecked_Access are illegal in declare_expressions,
-- according to the RM. We also make the GNAT-specific
-- Unrestricted_Access attribute illegal.
if In_Declare_Expr > 0 then
Error_Attr ("% attribute cannot occur in a declare_expression", N);
end if;
Check_E0;
if Nkind (P) = N_Character_Literal then
Error_Attr_P
("prefix of % attribute cannot be enumeration literal");
end if;
-- Preserve relevant elaboration-related attributes of the context
-- which are no longer available or very expensive to recompute once
-- analysis, resolution, and expansion are over.
Mark_Elaboration_Attributes
(N_Id => N,
Checks => True,
Modes => True,
Warnings => True);
-- Save the scenario for later examination by the ABE Processing
-- phase.
Record_Elaboration_Scenario (N);
-- Case of access to subprogram
if Is_Entity_Name (P) and then Is_Overloadable (Entity (P)) then
if Has_Pragma_Inline_Always (Entity (P)) then
Error_Attr_P
("prefix of % attribute cannot be Inline_Always subprogram");
elsif Aname = Name_Unchecked_Access then
Error_Attr ("attribute% cannot be applied to a subprogram", P);
end if;
-- Issue an error if the prefix denotes an eliminated subprogram
Check_For_Eliminated_Subprogram (P, Entity (P));
-- Check for obsolescent subprogram reference
Check_Obsolescent_2005_Entity (Entity (P), P);
-- Build the appropriate subprogram type
Build_Access_Subprogram_Type (P);
-- For P'Access or P'Unrestricted_Access, where P is a nested
-- subprogram, we might be passing P to another subprogram (but we
-- don't check that here), which might call P. P could modify
-- local variables, so we need to kill current values. It is
-- important not to do this for library-level subprograms, because
-- Kill_Current_Values is very inefficient in the case of library
-- level packages with lots of tagged types.
if Is_Library_Level_Entity (Entity (Prefix (N))) then
null;
-- Do not kill values on nodes initializing dispatch tables
-- slots. The construct Prim_Ptr!(Prim'Unrestricted_Access)
-- is currently generated by the expander only for this
-- purpose. Done to keep the quality of warnings currently
-- generated by the compiler (otherwise any declaration of
-- a tagged type cleans constant indications from its scope).
elsif Nkind (Parent (N)) = N_Unchecked_Type_Conversion
and then (Etype (Parent (N)) = RTE (RE_Prim_Ptr)
or else
Etype (Parent (N)) = RTE (RE_Size_Ptr))
and then Is_Dispatching_Operation
(Directly_Designated_Type (Etype (N)))
then
null;
else
Kill_Current_Values;
end if;
-- In the static elaboration model, treat the attribute reference
-- as a subprogram call for elaboration purposes. Suppress this
-- treatment under debug flag. In any case, we are all done.
if Legacy_Elaboration_Checks
and not Dynamic_Elaboration_Checks
and not Debug_Flag_Dot_UU
then
Check_Elab_Call (N);
end if;
return;
-- Component is an operation of a protected type
elsif Nkind (P) = N_Selected_Component
and then Is_Overloadable (Entity (Selector_Name (P)))
then
if Ekind (Entity (Selector_Name (P))) = E_Entry then
Error_Attr_P ("prefix of % attribute must be subprogram");
end if;
Build_Access_Subprogram_Type (Selector_Name (P));
return;
end if;
-- Deal with incorrect reference to a type, but note that some
-- accesses are allowed: references to the current type instance,
-- or in Ada 2005 self-referential pointer in a default-initialized
-- aggregate.
if Is_Entity_Name (P) then
Typ := Entity (P);
-- The reference may appear in an aggregate that has been expanded
-- into a loop. Locate scope of type definition, if any.
Scop := Current_Scope;
while Ekind (Scop) = E_Loop loop
Scop := Scope (Scop);
end loop;
if Is_Type (Typ) then
-- OK if we are within the scope of a limited type
-- let's mark the component as having per object constraint
if Is_Anonymous_Tagged_Base (Scop, Typ) then
Typ := Scop;
Set_Entity (P, Typ);
Set_Etype (P, Typ);
end if;
if Typ = Scop then
declare
Q : Node_Id := Parent (N);
begin
while Present (Q)
and then Nkind (Q) /= N_Component_Declaration
loop
Q := Parent (Q);
end loop;
if Present (Q) then
Set_Has_Per_Object_Constraint
(Defining_Identifier (Q), True);
end if;
end;
if Nkind (P) = N_Expanded_Name then
Error_Msg_F
("current instance prefix must be a direct name", P);
end if;
-- If a current instance attribute appears in a component
-- constraint it must appear alone; other contexts (spec-
-- expressions, within a task body) are not subject to this
-- restriction.
if not In_Spec_Expression
and then not Has_Completion (Scop)
and then
Nkind (Parent (N)) not in
N_Discriminant_Association |
N_Index_Or_Discriminant_Constraint
then
Error_Msg_N
("current instance attribute must appear alone", N);
end if;
if Is_CPP_Class (Root_Type (Typ)) then
Error_Msg_N
("??current instance unsupported for derivations of "
& "'C'P'P types", N);
end if;
-- OK if we are in initialization procedure for the type
-- in question, in which case the reference to the type
-- is rewritten as a reference to the current object.
elsif Ekind (Scop) = E_Procedure
and then Is_Init_Proc (Scop)
and then Etype (First_Formal (Scop)) = Typ
then
Rewrite (N,
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_uInit),
Attribute_Name => Name_Unrestricted_Access));
Analyze (N);
return;
-- OK if a task type, this test needs sharpening up ???
elsif Is_Task_Type (Typ) then
null;
-- OK if self-reference in an aggregate in Ada 2005, and
-- the reference comes from a copied default expression.
-- Note that we check legality of self-reference even if the
-- expression comes from source, e.g. when a single component
-- association in an aggregate has a box association.
elsif Ada_Version >= Ada_2005
and then OK_Self_Reference
then
null;
-- OK if reference to current instance of a protected object
elsif Is_Protected_Self_Reference (P) then
null;
-- Otherwise we have an error case
else
Error_Attr ("% attribute cannot be applied to type", P);
return;
end if;
end if;
end if;
-- If we fall through, we have a normal access to object case
-- Unrestricted_Access is (for now) legal wherever an allocator would
-- be legal, so its Etype is set to E_Allocator. The expected type
-- of the other attributes is a general access type, and therefore
-- we label them with E_Access_Attribute_Type.
if not Is_Overloaded (P) then
Acc_Type := Build_Access_Object_Type (P_Type);
Set_Etype (N, Acc_Type);
else
declare
Index : Interp_Index;
It : Interp;
begin
Set_Etype (N, Any_Type);
Get_First_Interp (P, Index, It);
while Present (It.Typ) loop
Acc_Type := Build_Access_Object_Type (It.Typ);
Add_One_Interp (N, Acc_Type, Acc_Type);
Get_Next_Interp (Index, It);
end loop;
end;
end if;
-- Special cases when we can find a prefix that is an entity name
declare
PP : Node_Id;
Ent : Entity_Id;
begin
PP := P;
loop
if Is_Entity_Name (PP) then
Ent := Entity (PP);
-- If we have an access to an object, and the attribute
-- comes from source, then set the object as potentially
-- source modified. We do this because the resulting access
-- pointer can be used to modify the variable, and we might
-- not detect this, leading to some junk warnings.
-- We only do this for source references, since otherwise
-- we can suppress warnings, e.g. from the unrestricted
-- access generated for validity checks in -gnatVa mode.
if Comes_From_Source (N) then
Set_Never_Set_In_Source (Ent, False);
end if;
-- Mark entity as address taken in the case of
-- 'Unrestricted_Access or subprograms, and kill current
-- values.
if Aname = Name_Unrestricted_Access
or else Is_Subprogram (Ent)
then
Set_Address_Taken (Ent);
end if;
Kill_Current_Values (Ent);
exit;
elsif Nkind (PP) in N_Selected_Component | N_Indexed_Component
then
PP := Prefix (PP);
else
exit;
end if;
end loop;
end;
end Analyze_Access_Attribute;
----------------------------------
-- Analyze_Attribute_Old_Result --
----------------------------------
procedure Analyze_Attribute_Old_Result
(Legal : out Boolean;
Spec_Id : out Entity_Id)
is
procedure Check_Placement_In_Check (Prag : Node_Id);
-- Verify that the attribute appears within pragma Check that mimics
-- a postcondition.
procedure Check_Placement_In_Contract_Cases (Prag : Node_Id);
-- Verify that the attribute appears within a consequence of aspect
-- or pragma Contract_Cases denoted by Prag.
procedure Check_Placement_In_Test_Case (Prag : Node_Id);
-- Verify that the attribute appears within the "Ensures" argument of
-- aspect or pragma Test_Case denoted by Prag.
function Is_Within
(Nod : Node_Id;
Encl_Nod : Node_Id) return Boolean;
-- Subsidiary to Check_Placemenet_In_XXX. Determine whether arbitrary
-- node Nod is within enclosing node Encl_Nod.
procedure Placement_Error;
pragma No_Return (Placement_Error);
-- Emit a general error when the attributes does not appear in a
-- postcondition-like aspect or pragma, and then raises Bad_Attribute
-- to avoid any further semantic processing.
------------------------------
-- Check_Placement_In_Check --
------------------------------
procedure Check_Placement_In_Check (Prag : Node_Id) is
Args : constant List_Id := Pragma_Argument_Associations (Prag);
Nam : constant Name_Id := Chars (Get_Pragma_Arg (First (Args)));
begin
-- The "Name" argument of pragma Check denotes a postcondition
if Nam in Name_Post
| Name_Post_Class
| Name_Postcondition
| Name_Refined_Post
then
null;
-- Otherwise the placement of the attribute is illegal
else
Placement_Error;
end if;
end Check_Placement_In_Check;
---------------------------------------
-- Check_Placement_In_Contract_Cases --
---------------------------------------
procedure Check_Placement_In_Contract_Cases (Prag : Node_Id) is
Arg : Node_Id;
Cases : Node_Id;
CCase : Node_Id;
begin
-- Obtain the argument of the aspect or pragma
if Nkind (Prag) = N_Aspect_Specification then
Arg := Prag;
else
Arg := First (Pragma_Argument_Associations (Prag));
end if;
Cases := Expression (Arg);
if Present (Component_Associations (Cases)) then
CCase := First (Component_Associations (Cases));
while Present (CCase) loop
-- Detect whether the attribute appears within the
-- consequence of the current contract case.
if Nkind (CCase) = N_Component_Association
and then Is_Within (N, Expression (CCase))
then
return;
end if;
Next (CCase);
end loop;
end if;
-- Otherwise aspect or pragma Contract_Cases is either malformed
-- or the attribute does not appear within a consequence.
Error_Attr
("attribute % must appear in the consequence of a contract case",
P);
end Check_Placement_In_Contract_Cases;
----------------------------------
-- Check_Placement_In_Test_Case --
----------------------------------
procedure Check_Placement_In_Test_Case (Prag : Node_Id) is
Arg : constant Node_Id :=
Test_Case_Arg
(Prag => Prag,
Arg_Nam => Name_Ensures,
From_Aspect => Nkind (Prag) = N_Aspect_Specification);
begin
-- Detect whether the attribute appears within the "Ensures"
-- expression of aspect or pragma Test_Case.
if Present (Arg) and then Is_Within (N, Arg) then
null;
else
Error_Attr
("attribute % must appear in the ensures expression of a "
& "test case", P);
end if;
end Check_Placement_In_Test_Case;
---------------
-- Is_Within --
---------------
function Is_Within
(Nod : Node_Id;
Encl_Nod : Node_Id) return Boolean
is
Par : Node_Id;
begin
Par := Nod;
while Present (Par) loop
if Par = Encl_Nod then
return True;
-- Prevent the search from going too far
elsif Is_Body_Or_Package_Declaration (Par) then
exit;
end if;
Par := Parent (Par);
end loop;
return False;
end Is_Within;
---------------------
-- Placement_Error --
---------------------
procedure Placement_Error is
begin
if Aname = Name_Old then
Error_Attr ("attribute % can only appear in postcondition", P);
-- Specialize the error message for attribute 'Result
else
Error_Attr
("attribute % can only appear in postcondition of function",
P);
end if;
end Placement_Error;
-- Local variables
Prag : Node_Id;
Prag_Nam : Name_Id;
Subp_Decl : Node_Id;
-- Start of processing for Analyze_Attribute_Old_Result
begin
-- Assume that the attribute is illegal
Legal := False;
Spec_Id := Empty;
-- Traverse the parent chain to find the aspect or pragma where the
-- attribute resides.
Prag := N;
while Present (Prag) loop
if Nkind (Prag) in N_Aspect_Specification | N_Pragma then
exit;
-- Prevent the search from going too far
elsif Is_Body_Or_Package_Declaration (Prag) then
exit;
end if;
Prag := Parent (Prag);
end loop;
-- The attribute is allowed to appear only in postcondition-like
-- aspects or pragmas.
if Nkind (Prag) in N_Aspect_Specification | N_Pragma then
if Nkind (Prag) = N_Aspect_Specification then
Prag_Nam := Chars (Identifier (Prag));
else
Prag_Nam := Pragma_Name (Prag);
end if;
if Prag_Nam = Name_Check then
Check_Placement_In_Check (Prag);
elsif Prag_Nam = Name_Contract_Cases then
Check_Placement_In_Contract_Cases (Prag);
-- Attribute 'Result is allowed to appear in aspect or pragma
-- [Refined_]Depends (SPARK RM 6.1.5(11)).
elsif Prag_Nam in Name_Depends | Name_Refined_Depends
and then Aname = Name_Result
then
null;
-- Attribute 'Result is allowed to appear in aspect
-- Relaxed_Initialization (SPARK RM 6.10).
elsif Prag_Nam = Name_Relaxed_Initialization
and then Aname = Name_Result
then
null;
elsif Prag_Nam in Name_Post
| Name_Post_Class
| Name_Postcondition
| Name_Refined_Post
then
null;
elsif Prag_Nam = Name_Test_Case then
Check_Placement_In_Test_Case (Prag);
else
Placement_Error;
return;
end if;
-- Otherwise the placement of the attribute is illegal
else
Placement_Error;
return;
end if;
-- Find the related subprogram subject to the aspect or pragma
if Nkind (Prag) = N_Aspect_Specification then
Subp_Decl := Parent (Prag);
else
Subp_Decl := Find_Related_Declaration_Or_Body (Prag);
end if;
-- The aspect or pragma where the attribute resides should be
-- associated with a subprogram declaration or a body. If this is not
-- the case, then the aspect or pragma is illegal. Return as analysis
-- cannot be carried out. Note that it is legal to have the aspect
-- appear on a subprogram renaming, when the renamed entity is an
-- attribute reference.
-- Generating C code the internally built nested _postcondition
-- subprograms are inlined; after expanded, inlined aspects are
-- located in the internal block generated by the frontend.
if Nkind (Subp_Decl) = N_Block_Statement
and then Modify_Tree_For_C
and then In_Inlined_Body
then
null;
elsif Nkind (Subp_Decl) not in N_Abstract_Subprogram_Declaration
| N_Entry_Declaration
| N_Expression_Function
| N_Generic_Subprogram_Declaration
| N_Subprogram_Body
| N_Subprogram_Body_Stub
| N_Subprogram_Declaration
| N_Subprogram_Renaming_Declaration
then
return;
end if;
-- If we get here, then the attribute is legal
Legal := True;
Spec_Id := Unique_Defining_Entity (Subp_Decl);
-- When generating C code, nested _postcondition subprograms are
-- inlined by the front end to avoid problems (when unnested) with
-- referenced itypes. Handle that here, since as part of inlining the
-- expander nests subprogram within a dummy procedure named _parent
-- (see Build_Postconditions_Procedure and Build_Body_To_Inline).
-- Hence, in this context, the spec_id of _postconditions is the
-- enclosing scope.
if Modify_Tree_For_C
and then Chars (Spec_Id) = Name_uParent
and then Chars (Scope (Spec_Id)) = Name_uPostconditions
then
-- This situation occurs only when preanalyzing the inlined body
pragma Assert (not Full_Analysis);
Spec_Id := Scope (Spec_Id);
pragma Assert (Is_Inlined (Spec_Id));
end if;
end Analyze_Attribute_Old_Result;
-----------------------------
-- Analyze_Image_Attribute --
-----------------------------
procedure Analyze_Image_Attribute (Str_Typ : Entity_Id) is
procedure Check_Image_Type (Image_Type : Entity_Id);
-- Check that Image_Type is legal as the type of a prefix of 'Image.
-- Legality depends on the Ada language version.
procedure Check_Image_Type (Image_Type : Entity_Id) is
begin
if Ada_Version < Ada_2020
and then not Is_Scalar_Type (Image_Type)
then
Error_Msg_Ada_2020_Feature ("|nonscalar ''Image", Sloc (P));
Error_Attr;
end if;
end Check_Image_Type;
-- Start of processing for Analyze_Image_Attribute
begin
-- AI12-0124: The ARG has adopted the GNAT semantics of 'Img for
-- scalar types, so that the prefix can be an object, a named value,
-- or a type. If the prefix is an object, there is no argument.
if Is_Object_Image (P) then
Check_E0;
Set_Etype (N, Str_Typ);
Check_Image_Type (Etype (P));
if Attr_Id /= Attribute_Img and then Ada_Version < Ada_2012 then
Error_Msg_Ada_2012_Feature ("|Object''Image", Sloc (P));
end if;
else
Check_E1;
Set_Etype (N, Str_Typ);
-- ???It's not clear why 'Img should behave any differently than
-- 'Image.
if Attr_Id = Attribute_Img then
Error_Attr_P
("prefix of % attribute must be a scalar object name");
end if;
pragma Assert (Is_Entity_Name (P) and then Is_Type (Entity (P)));
if Ekind (Entity (P)) = E_Incomplete_Type
and then Present (Full_View (Entity (P)))
then
P_Type := Full_View (Entity (P));
P_Base_Type := Base_Type (P_Type);
Set_Entity (P, P_Type);
end if;
Check_Image_Type (P_Type);
Resolve (E1, P_Base_Type);
Validate_Non_Static_Attribute_Function_Call;
end if;
Check_Enum_Image;
-- Check restriction No_Fixed_IO. Note the check of Comes_From_Source
-- to avoid giving a duplicate message for when Image attributes
-- applied to object references get expanded into type-based Image
-- attributes.
if Restriction_Check_Required (No_Fixed_IO)
and then Comes_From_Source (N)
and then Is_Fixed_Point_Type (P_Type)
then
Check_Restriction (No_Fixed_IO, P);
end if;
end Analyze_Image_Attribute;
---------------------------------
-- Bad_Attribute_For_Predicate --
---------------------------------
procedure Bad_Attribute_For_Predicate is
begin
if Is_Scalar_Type (P_Type)
and then Comes_From_Source (N)
then
Error_Msg_Name_1 := Aname;
Bad_Predicated_Subtype_Use
("type& has predicates, attribute % not allowed", N, P_Type);
end if;
end Bad_Attribute_For_Predicate;
--------------------------------
-- Check_Array_Or_Scalar_Type --
--------------------------------
procedure Check_Array_Or_Scalar_Type is
function In_Aspect_Specification return Boolean;
-- A current instance of a type in an aspect specification is an
-- object and not a type, and therefore cannot be of a scalar type
-- in the prefix of one of the array attributes if the attribute
-- reference is part of an aspect expression.
-----------------------------
-- In_Aspect_Specification --
-----------------------------
function In_Aspect_Specification return Boolean is
P : Node_Id;
begin
P := Parent (N);
while Present (P) loop
if Nkind (P) = N_Aspect_Specification then
return P_Type = Entity (P);
elsif Nkind (P) in N_Declaration then
return False;
end if;
P := Parent (P);
end loop;
return False;
end In_Aspect_Specification;
-- Local variables
Dims : Int;
Index : Entity_Id;
-- Start of processing for Check_Array_Or_Scalar_Type
begin
-- Case of string literal or string literal subtype. These cases
-- cannot arise from legal Ada code, but the expander is allowed
-- to generate them. They require special handling because string
-- literal subtypes do not have standard bounds (the whole idea
-- of these subtypes is to avoid having to generate the bounds)
if Ekind (P_Type) = E_String_Literal_Subtype then
Set_Etype (N, Etype (First_Index (P_Base_Type)));
return;
-- Scalar types
elsif Is_Scalar_Type (P_Type) then
Check_Type;
if Present (E1) then
Error_Attr ("invalid argument in % attribute", E1);
elsif In_Aspect_Specification then
Error_Attr
("prefix of % attribute cannot be the current instance of a "
& "scalar type", P);
else
Set_Etype (N, P_Base_Type);
return;
end if;
-- The following is a special test to allow 'First to apply to
-- private scalar types if the attribute comes from generated
-- code. This occurs in the case of Normalize_Scalars code.
elsif Is_Private_Type (P_Type)
and then Present (Full_View (P_Type))
and then Is_Scalar_Type (Full_View (P_Type))
and then not Comes_From_Source (N)
then
Set_Etype (N, Implementation_Base_Type (P_Type));
-- Array types other than string literal subtypes handled above
else
Check_Array_Type;
-- We know prefix is an array type, or the name of an array
-- object, and that the expression, if present, is static
-- and within the range of the dimensions of the type.
pragma Assert (Is_Array_Type (P_Type));
Index := First_Index (P_Base_Type);
if No (E1) then
-- First dimension assumed
Set_Etype (N, Base_Type (Etype (Index)));
else
Dims := UI_To_Int (Intval (E1));
for J in 1 .. Dims - 1 loop
Next_Index (Index);
end loop;
Set_Etype (N, Base_Type (Etype (Index)));
Set_Etype (E1, Standard_Integer);
end if;
end if;
end Check_Array_Or_Scalar_Type;
----------------------
-- Check_Array_Type --
----------------------
procedure Check_Array_Type is
D : Int;
-- Dimension number for array attributes
begin
-- If the type is a string literal type, then this must be generated
-- internally, and no further check is required on its legality.
if Ekind (P_Type) = E_String_Literal_Subtype then
return;
-- If the type is a composite, it is an illegal aggregate, no point
-- in going on.
elsif P_Type = Any_Composite then
raise Bad_Attribute;
end if;
-- Normal case of array type or subtype. Note that if the
-- prefix is a current instance of a type declaration it
-- appears within an aspect specification and is legal.
Check_Either_E0_Or_E1;
Check_Dereference;
if Is_Array_Type (P_Type) then
if not Is_Constrained (P_Type)
and then Is_Entity_Name (P)
and then Is_Type (Entity (P))
and then not Is_Current_Instance (P)
then
-- Note: we do not call Error_Attr here, since we prefer to
-- continue, using the relevant index type of the array,
-- even though it is unconstrained. This gives better error
-- recovery behavior.
Error_Msg_Name_1 := Aname;
Error_Msg_F
("prefix for % attribute must be constrained array", P);
end if;
-- The attribute reference freezes the type, and thus the
-- component type, even if the attribute may not depend on the
-- component. Diagnose arrays with incomplete components now.
-- If the prefix is an access to array, this does not freeze
-- the designated type.
if Nkind (P) /= N_Explicit_Dereference then
Check_Fully_Declared (Component_Type (P_Type), P);
end if;
D := Number_Dimensions (P_Type);
else
if Is_Private_Type (P_Type) then
Error_Attr_P ("prefix for % attribute may not be private type");
elsif Is_Access_Type (P_Type)
and then Is_Array_Type (Designated_Type (P_Type))
and then Is_Entity_Name (P)
and then Is_Type (Entity (P))
then
Error_Attr_P ("prefix of % attribute cannot be access type");
elsif Attr_Id = Attribute_First
or else
Attr_Id = Attribute_Last
then
Error_Attr ("invalid prefix for % attribute", P);
else
Error_Attr_P ("prefix for % attribute must be array");
end if;
end if;
if Present (E1) then
Resolve (E1, Any_Integer);
Set_Etype (E1, Standard_Integer);
if not Is_OK_Static_Expression (E1)
or else Raises_Constraint_Error (E1)
then
Flag_Non_Static_Expr
("expression for dimension must be static!", E1);
Error_Attr;
elsif UI_To_Int (Expr_Value (E1)) > D
or else UI_To_Int (Expr_Value (E1)) < 1
then
Error_Attr ("invalid dimension number for array type", E1);
end if;
end if;
if (Style_Check and Style_Check_Array_Attribute_Index)
and then Comes_From_Source (N)
then
Style.Check_Array_Attribute_Index (N, E1, D);
end if;
end Check_Array_Type;
-------------------------
-- Check_Asm_Attribute --
-------------------------
procedure Check_Asm_Attribute is
begin
Check_Type;
Check_E2;
-- Check first argument is static string expression
Analyze_And_Resolve (E1, Standard_String);
if Etype (E1) = Any_Type then
return;
elsif not Is_OK_Static_Expression (E1) then
Flag_Non_Static_Expr
("constraint argument must be static string expression!", E1);
Error_Attr;
end if;
-- Check second argument is right type
Analyze_And_Resolve (E2, Entity (P));
-- Note: that is all we need to do, we don't need to check
-- that it appears in a correct context. The Ada type system
-- will do that for us.
end Check_Asm_Attribute;
---------------------
-- Check_Component --
---------------------
procedure Check_Component is
begin
Check_E0;
if Nkind (P) /= N_Selected_Component
or else
(Ekind (Entity (Selector_Name (P))) /= E_Component
and then
Ekind (Entity (Selector_Name (P))) /= E_Discriminant)
then
Error_Attr_P ("prefix for % attribute must be selected component");
end if;
end Check_Component;
------------------------------------
-- Check_Decimal_Fixed_Point_Type --
------------------------------------
procedure Check_Decimal_Fixed_Point_Type is
begin
Check_Type;
if not Is_Decimal_Fixed_Point_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be decimal type");
end if;
end Check_Decimal_Fixed_Point_Type;
-----------------------
-- Check_Dereference --
-----------------------
procedure Check_Dereference is
begin
-- Case of a subtype mark
if Is_Entity_Name (P) and then Is_Type (Entity (P)) then
return;
end if;
-- Case of an expression
Resolve (P);
if Is_Access_Type (P_Type) then
-- If there is an implicit dereference, then we must freeze the
-- designated type of the access type, since the type of the
-- referenced array is this type (see AI95-00106).
-- As done elsewhere, freezing must not happen when preanalyzing
-- a pre- or postcondition or a default value for an object or for
-- a formal parameter.
if not In_Spec_Expression then
Freeze_Before (N, Designated_Type (P_Type));
end if;
Rewrite (P,
Make_Explicit_Dereference (Sloc (P),
Prefix => Relocate_Node (P)));
Analyze_And_Resolve (P);
P_Type := Etype (P);
if P_Type = Any_Type then
raise Bad_Attribute;
end if;
P_Base_Type := Base_Type (P_Type);
end if;
end Check_Dereference;
-------------------------
-- Check_Discrete_Type --
-------------------------
procedure Check_Discrete_Type is
begin
Check_Type;
if not Is_Discrete_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be discrete type");
end if;
end Check_Discrete_Type;
--------------
-- Check_E0 --
--------------
procedure Check_E0 is
begin
if Present (E1) then
Unexpected_Argument (E1);
end if;
end Check_E0;
--------------
-- Check_E1 --
--------------
procedure Check_E1 is
begin
Check_Either_E0_Or_E1;
if No (E1) then
-- Special-case attributes that are functions and that appear as
-- the prefix of another attribute. Error is posted on parent.
if Nkind (Parent (N)) = N_Attribute_Reference
and then Attribute_Name (Parent (N)) in Name_Address
| Name_Code_Address
| Name_Access
then
Error_Msg_Name_1 := Attribute_Name (Parent (N));
Error_Msg_N ("illegal prefix for % attribute", Parent (N));
Set_Etype (Parent (N), Any_Type);
Set_Entity (Parent (N), Any_Type);
raise Bad_Attribute;
else
Error_Attr ("missing argument for % attribute", N);
end if;
end if;
end Check_E1;
--------------
-- Check_E2 --
--------------
procedure Check_E2 is
begin
if No (E1) then
Error_Attr ("missing arguments for % attribute (2 required)", N);
elsif No (E2) then
Error_Attr ("missing argument for % attribute (2 required)", N);
end if;
end Check_E2;
---------------------------
-- Check_Either_E0_Or_E1 --
---------------------------
procedure Check_Either_E0_Or_E1 is
begin
if Present (E2) then
Unexpected_Argument (E2);
end if;
end Check_Either_E0_Or_E1;
----------------------
-- Check_Enum_Image --
----------------------
procedure Check_Enum_Image is
Lit : Entity_Id;
begin
-- When an enumeration type appears in an attribute reference, all
-- literals of the type are marked as referenced. This must only be
-- done if the attribute reference appears in the current source.
-- Otherwise the information on references may differ between a
-- normal compilation and one that performs inlining.
if Is_Enumeration_Type (P_Base_Type)
and then In_Extended_Main_Code_Unit (N)
then
Lit := First_Literal (P_Base_Type);
while Present (Lit) loop
Set_Referenced (Lit);
Next_Literal (Lit);
end loop;
end if;
end Check_Enum_Image;
----------------------------
-- Check_First_Last_Valid --
----------------------------
procedure Check_First_Last_Valid is
begin
Check_Discrete_Type;
-- Freeze the subtype now, so that the following test for predicates
-- works (we set the predicates stuff up at freeze time)
Insert_Actions (N, Freeze_Entity (P_Type, P));
-- Now test for dynamic predicate
if Has_Predicates (P_Type)
and then not (Has_Static_Predicate (P_Type))
then
Error_Attr_P
("prefix of % attribute may not have dynamic predicate");
end if;
-- Check non-static subtype
if not Is_OK_Static_Subtype (P_Type) then
Error_Attr_P ("prefix of % attribute must be a static subtype");
end if;
-- Test case for no values
if Expr_Value (Type_Low_Bound (P_Type)) >
Expr_Value (Type_High_Bound (P_Type))
or else (Has_Predicates (P_Type)
and then
Is_Empty_List (Static_Discrete_Predicate (P_Type)))
then
Error_Attr_P
("prefix of % attribute must be subtype with at least one "
& "value");
end if;
end Check_First_Last_Valid;
----------------------------
-- Check_Fixed_Point_Type --
----------------------------
procedure Check_Fixed_Point_Type is
begin
Check_Type;
if not Is_Fixed_Point_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be fixed point type");
end if;
end Check_Fixed_Point_Type;
------------------------------
-- Check_Fixed_Point_Type_0 --
------------------------------
procedure Check_Fixed_Point_Type_0 is
begin
Check_Fixed_Point_Type;
Check_E0;
end Check_Fixed_Point_Type_0;
-------------------------------
-- Check_Floating_Point_Type --
-------------------------------
procedure Check_Floating_Point_Type is
begin
Check_Type;
if not Is_Floating_Point_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be float type");
end if;
end Check_Floating_Point_Type;
---------------------------------
-- Check_Floating_Point_Type_0 --
---------------------------------
procedure Check_Floating_Point_Type_0 is
begin
Check_Floating_Point_Type;
Check_E0;
end Check_Floating_Point_Type_0;
---------------------------------
-- Check_Floating_Point_Type_1 --
---------------------------------
procedure Check_Floating_Point_Type_1 is
begin
Check_Floating_Point_Type;
Check_E1;
end Check_Floating_Point_Type_1;
---------------------------------
-- Check_Floating_Point_Type_2 --
---------------------------------
procedure Check_Floating_Point_Type_2 is
begin
Check_Floating_Point_Type;
Check_E2;
end Check_Floating_Point_Type_2;
------------------------
-- Check_Integer_Type --
------------------------
procedure Check_Integer_Type is
begin
Check_Type;
if not Is_Integer_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be integer type");
end if;
end Check_Integer_Type;
--------------------------------
-- Check_Modular_Integer_Type --
--------------------------------
procedure Check_Modular_Integer_Type is
begin
Check_Type;
if not Is_Modular_Integer_Type (P_Type) then
Error_Attr_P
("prefix of % attribute must be modular integer type");
end if;
end Check_Modular_Integer_Type;
------------------------
-- Check_Not_CPP_Type --
------------------------
procedure Check_Not_CPP_Type is
begin
if Is_Tagged_Type (Etype (P))
and then Convention (Etype (P)) = Convention_CPP
and then Is_CPP_Class (Root_Type (Etype (P)))
then
Error_Attr_P
("invalid use of % attribute with 'C'P'P tagged type");
end if;
end Check_Not_CPP_Type;
-------------------------------
-- Check_Not_Incomplete_Type --
-------------------------------
procedure Check_Not_Incomplete_Type is
E : Entity_Id;
Typ : Entity_Id;
begin
-- Ada 2005 (AI-50217, AI-326): If the prefix is an explicit
-- dereference we have to check wrong uses of incomplete types
-- (other wrong uses are checked at their freezing point).
-- In Ada 2012, incomplete types can appear in subprogram
-- profiles, but formals with incomplete types cannot be the
-- prefix of attributes.
-- Example 1: Limited-with
-- limited with Pkg;
-- package P is
-- type Acc is access Pkg.T;
-- X : Acc;
-- S : Integer := X.all'Size; -- ERROR
-- end P;
-- Example 2: Tagged incomplete
-- type T is tagged;
-- type Acc is access all T;
-- X : Acc;
-- S : constant Integer := X.all'Size; -- ERROR
-- procedure Q (Obj : Integer := X.all'Alignment); -- ERROR
if Ada_Version >= Ada_2005
and then Nkind (P) = N_Explicit_Dereference
then
E := P;
while Nkind (E) = N_Explicit_Dereference loop
E := Prefix (E);
end loop;
Typ := Etype (E);
if From_Limited_With (Typ) then
Error_Attr_P
("prefix of % attribute cannot be an incomplete type");
-- If the prefix is an access type check the designated type
elsif Is_Access_Type (Typ)
and then Nkind (P) = N_Explicit_Dereference
then
Typ := Directly_Designated_Type (Typ);
end if;
if Is_Class_Wide_Type (Typ) then
Typ := Root_Type (Typ);
end if;
-- A legal use of a shadow entity occurs only when the unit where
-- the non-limited view resides is imported via a regular with
-- clause in the current body. Such references to shadow entities
-- may occur in subprogram formals.
if Is_Incomplete_Type (Typ)
and then From_Limited_With (Typ)
and then Present (Non_Limited_View (Typ))
and then Is_Legal_Shadow_Entity_In_Body (Typ)
then
Typ := Non_Limited_View (Typ);
end if;
-- If still incomplete, it can be a local incomplete type, or a
-- limited view whose scope is also a limited view.
if Ekind (Typ) = E_Incomplete_Type then
if not From_Limited_With (Typ)
and then No (Full_View (Typ))
then
Error_Attr_P
("prefix of % attribute cannot be an incomplete type");
-- The limited view may be available indirectly through
-- an intermediate unit. If the non-limited view is available
-- the attribute reference is legal.
elsif From_Limited_With (Typ)
and then
(No (Non_Limited_View (Typ))
or else Is_Incomplete_Type (Non_Limited_View (Typ)))
then
Error_Attr_P
("prefix of % attribute cannot be an incomplete type");
end if;
end if;
-- Ada 2012 : formals in bodies may be incomplete, but no attribute
-- legally applies.
elsif Is_Entity_Name (P)
and then Is_Formal (Entity (P))
and then Is_Incomplete_Type (Etype (Etype (P)))
then
Error_Attr_P
("prefix of % attribute cannot be an incomplete type");
end if;
if not Is_Entity_Name (P)
or else not Is_Type (Entity (P))
or else In_Spec_Expression
then
return;
else
Check_Fully_Declared (P_Type, P);
end if;
end Check_Not_Incomplete_Type;
----------------------------
-- Check_Object_Reference --
----------------------------
procedure Check_Object_Reference (P : Node_Id) is
Rtyp : Entity_Id;
begin
-- If we need an object, and we have a prefix that is the name of a
-- function entity, convert it into a function call.
if Is_Entity_Name (P)
and then Ekind (Entity (P)) = E_Function
then
Rtyp := Etype (Entity (P));
Rewrite (P,
Make_Function_Call (Sloc (P),
Name => Relocate_Node (P)));
Analyze_And_Resolve (P, Rtyp);
-- Otherwise we must have an object reference
elsif not Is_Object_Reference (P) then
Error_Attr_P ("prefix of % attribute must be object");
end if;
end Check_Object_Reference;
----------------------------
-- Check_PolyORB_Attribute --
----------------------------
procedure Check_PolyORB_Attribute is
begin
Validate_Non_Static_Attribute_Function_Call;
Check_Type;
Check_Not_CPP_Type;
if Get_PCS_Name /= Name_PolyORB_DSA then
Error_Attr
("attribute% requires the 'Poly'O'R'B 'P'C'S", N);
end if;
end Check_PolyORB_Attribute;
------------------------
-- Check_Program_Unit --
------------------------
procedure Check_Program_Unit is
begin
if Is_Entity_Name (P) then
declare
K : constant Entity_Kind := Ekind (Entity (P));
T : constant Entity_Id := Etype (Entity (P));
begin
if K in Subprogram_Kind
or else K in Task_Kind
or else K in Protected_Kind
or else K = E_Package
or else K in Generic_Unit_Kind
or else (K = E_Variable
and then
(Is_Task_Type (T)
or else
Is_Protected_Type (T)))
then
return;
end if;
end;
end if;
Error_Attr_P ("prefix of % attribute must be program unit");
end Check_Program_Unit;
---------------------
-- Check_Real_Type --
---------------------
procedure Check_Real_Type is
begin
Check_Type;
if not Is_Real_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be real type");
end if;
end Check_Real_Type;
-----------------------
-- Check_Scalar_Type --
-----------------------
procedure Check_Scalar_Type is
begin
Check_Type;
if not Is_Scalar_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be scalar type");
end if;
end Check_Scalar_Type;
---------------------------
-- Check_Standard_Prefix --
---------------------------
procedure Check_Standard_Prefix is
begin
Check_E0;
if Nkind (P) /= N_Identifier or else Chars (P) /= Name_Standard then
Error_Attr ("only allowed prefix for % attribute is Standard", P);
end if;
end Check_Standard_Prefix;
-------------------------------
-- Check_Put_Image_Attribute --
-------------------------------
procedure Check_Put_Image_Attribute is
begin
-- Put_Image is a procedure, and can only appear at the position of a
-- procedure call. If it's a list member and it's parent is a
-- procedure call or aggregate, then this is appearing as an actual
-- parameter or component association, which is wrong.
if Is_List_Member (N)
and then Nkind (Parent (N)) not in
N_Procedure_Call_Statement | N_Aggregate
then
null;
else
Error_Attr
("invalid context for attribute%, which is a procedure", N);
end if;
Check_Type;
Analyze_And_Resolve (E1);
-- Check that the first argument is
-- Ada.Strings.Text_Output.Sink'Class.
-- Note: the double call to Root_Type here is needed because the
-- root type of a class-wide type is the corresponding type (e.g.
-- X for X'Class, and we really want to go to the root.)
if Root_Type (Root_Type (Etype (E1))) /= RTE (RE_Sink) then
Error_Attr
("expected Ada.Strings.Text_Output.Sink''Class", E1);
end if;
-- Check that the second argument is of the right type
Analyze (E2);
Resolve (E2, P_Type);
end Check_Put_Image_Attribute;
----------------------------
-- Check_Stream_Attribute --
----------------------------
procedure Check_Stream_Attribute (Nam : TSS_Name_Type) is
Etyp : Entity_Id;
Btyp : Entity_Id;
In_Shared_Var_Procs : Boolean;
-- True when compiling System.Shared_Storage.Shared_Var_Procs body.
-- For this runtime package (always compiled in GNAT mode), we allow
-- stream attributes references for limited types for the case where
-- shared passive objects are implemented using stream attributes,
-- which is the default in GNAT's persistent storage implementation.
begin
Validate_Non_Static_Attribute_Function_Call;
-- With the exception of 'Input, Stream attributes are procedures,
-- and can only appear at the position of procedure calls. We check
-- for this here, before they are rewritten, to give a more precise
-- diagnostic.
if Nam = TSS_Stream_Input then
null;
elsif Is_List_Member (N)
and then Nkind (Parent (N)) not in
N_Procedure_Call_Statement | N_Aggregate
then
null;
else
Error_Attr
("invalid context for attribute%, which is a procedure", N);
end if;
Check_Type;
Btyp := Implementation_Base_Type (P_Type);
-- Stream attributes not allowed on limited types unless the
-- attribute reference was generated by the expander (in which
-- case the underlying type will be used, as described in Sinfo),
-- or the attribute was specified explicitly for the type itself
-- or one of its ancestors (taking visibility rules into account if
-- in Ada 2005 mode), or a pragma Stream_Convert applies to Btyp
-- (with no visibility restriction).
declare
Gen_Body : constant Node_Id := Enclosing_Generic_Body (N);
begin
if Present (Gen_Body) then
In_Shared_Var_Procs :=
Is_RTE (Corresponding_Spec (Gen_Body), RE_Shared_Var_Procs);
else
In_Shared_Var_Procs := False;
end if;
end;
if (Comes_From_Source (N)
and then not (In_Shared_Var_Procs or In_Instance))
and then not Stream_Attribute_Available (P_Type, Nam)
and then not Has_Rep_Pragma (Btyp, Name_Stream_Convert)
then
Error_Msg_Name_1 := Aname;
if Is_Limited_Type (P_Type) then
Error_Msg_NE
("limited type& has no% attribute", P, P_Type);
Explain_Limited_Type (P_Type, P);
else
Error_Msg_NE
("attribute% for type& is not available", P, P_Type);
end if;
end if;
-- Check for no stream operations allowed from No_Tagged_Streams
if Is_Tagged_Type (P_Type)
and then Present (No_Tagged_Streams_Pragma (P_Type))
then
Error_Msg_Sloc := Sloc (No_Tagged_Streams_Pragma (P_Type));
Error_Msg_NE
("no stream operations for & (No_Tagged_Streams #)", N, P_Type);
return;
end if;
-- Check restriction violations
-- First check the No_Streams restriction, which prohibits the use
-- of explicit stream attributes in the source program. We do not
-- prevent the occurrence of stream attributes in generated code,
-- for instance those generated implicitly for dispatching purposes.
if Comes_From_Source (N) then
Check_Restriction (No_Streams, P);
end if;
-- AI05-0057: if restriction No_Default_Stream_Attributes is active,
-- it is illegal to use a predefined elementary type stream attribute
-- either by itself, or more importantly as part of the attribute
-- subprogram for a composite type. However, if the broader
-- restriction No_Streams is active, stream operations are not
-- generated, and there is no error.
if Restriction_Active (No_Default_Stream_Attributes)
and then not Restriction_Active (No_Streams)
then
declare
T : Entity_Id;
begin
if Nam = TSS_Stream_Input
or else
Nam = TSS_Stream_Read
then
T :=
Type_Without_Stream_Operation (P_Type, TSS_Stream_Read);
else
T :=
Type_Without_Stream_Operation (P_Type, TSS_Stream_Write);
end if;
if Present (T) then
Check_Restriction (No_Default_Stream_Attributes, N);
Error_Msg_NE
("missing user-defined Stream Read or Write for type&",
N, T);
if not Is_Elementary_Type (P_Type) then
Error_Msg_NE
("\which is a component of type&", N, P_Type);
end if;
end if;
end;
end if;
-- Check special case of Exception_Id and Exception_Occurrence which
-- are not allowed for restriction No_Exception_Registration.
if Restriction_Check_Required (No_Exception_Registration)
and then (Is_RTE (P_Type, RE_Exception_Id)
or else
Is_RTE (P_Type, RE_Exception_Occurrence))
then
Check_Restriction (No_Exception_Registration, P);
end if;
-- Here we must check that the first argument is an access type
-- that is compatible with Ada.Streams.Root_Stream_Type'Class.
Analyze_And_Resolve (E1);
Etyp := Etype (E1);
-- Note: the double call to Root_Type here is needed because the
-- root type of a class-wide type is the corresponding type (e.g.
-- X for X'Class, and we really want to go to the root.)
if not Is_Access_Type (Etyp)
or else Root_Type (Root_Type (Designated_Type (Etyp))) /=
RTE (RE_Root_Stream_Type)
then
Error_Attr
("expected access to Ada.Streams.Root_Stream_Type''Class", E1);
end if;
-- Check that the second argument is of the right type if there is
-- one (the Input attribute has only one argument so this is skipped)
if Present (E2) then
Analyze (E2);
if Nam = TSS_Stream_Read
and then not Is_OK_Variable_For_Out_Formal (E2)
then
Error_Attr
("second argument of % attribute must be a variable", E2);
end if;
Resolve (E2, P_Type);
end if;
Check_Not_CPP_Type;
end Check_Stream_Attribute;
-------------------------
-- Check_System_Prefix --
-------------------------
procedure Check_System_Prefix is
begin
if Nkind (P) /= N_Identifier or else Chars (P) /= Name_System then
Error_Attr ("only allowed prefix for % attribute is System", P);
end if;
end Check_System_Prefix;
-----------------------
-- Check_Task_Prefix --
-----------------------
procedure Check_Task_Prefix is
begin
Analyze (P);
-- Ada 2005 (AI-345): Attribute 'Terminated can be applied to
-- task interface class-wide types.
if Is_Task_Type (Etype (P))
or else (Is_Access_Type (Etype (P))
and then Is_Task_Type (Designated_Type (Etype (P))))
or else (Ada_Version >= Ada_2005
and then Ekind (Etype (P)) = E_Class_Wide_Type
and then Is_Interface (Etype (P))
and then Is_Task_Interface (Etype (P)))
then
Resolve (P);
else
if Ada_Version >= Ada_2005 then
Error_Attr_P
("prefix of % attribute must be a task or a task " &
"interface class-wide object");
else
Error_Attr_P ("prefix of % attribute must be a task");
end if;
end if;
end Check_Task_Prefix;
----------------
-- Check_Type --
----------------
-- The possibilities are an entity name denoting a type, or an
-- attribute reference that denotes a type (Base or Class). If
-- the type is incomplete, replace it with its full view.
procedure Check_Type is
begin
if not Is_Entity_Name (P)
or else not Is_Type (Entity (P))
then
Error_Attr_P ("prefix of % attribute must be a type");
elsif Is_Protected_Self_Reference (P) then
Error_Attr_P
("prefix of % attribute denotes current instance "
& "(RM 9.4(21/2))");
elsif Ekind (Entity (P)) = E_Incomplete_Type
and then Present (Full_View (Entity (P)))
then
P_Type := Full_View (Entity (P));
Set_Entity (P, P_Type);
end if;
end Check_Type;
---------------------
-- Check_Unit_Name --
---------------------
procedure Check_Unit_Name (Nod : Node_Id) is
begin
if Nkind (Nod) = N_Identifier then
return;
elsif Nkind (Nod) in N_Selected_Component | N_Expanded_Name then
Check_Unit_Name (Prefix (Nod));
if Nkind (Selector_Name (Nod)) = N_Identifier then
return;
end if;
end if;
Error_Attr ("argument for % attribute must be unit name", P);
end Check_Unit_Name;
----------------
-- Error_Attr --
----------------
procedure Error_Attr is
begin
Set_Etype (N, Any_Type);
Set_Entity (N, Any_Type);
raise Bad_Attribute;
end Error_Attr;
procedure Error_Attr (Msg : String; Error_Node : Node_Id) is
begin
Error_Msg_Name_1 := Aname;
Error_Msg_N (Msg, Error_Node);
Error_Attr;
end Error_Attr;
------------------
-- Error_Attr_P --
------------------
procedure Error_Attr_P (Msg : String) is
begin
Error_Msg_Name_1 := Aname;
Error_Msg_F (Msg, P);
Error_Attr;
end Error_Attr_P;
----------------------------
-- Legal_Formal_Attribute --
----------------------------
procedure Legal_Formal_Attribute is
begin
Check_E0;
if not Is_Entity_Name (P)
or else not Is_Type (Entity (P))
then
Error_Attr_P ("prefix of % attribute must be generic type");
elsif Is_Generic_Actual_Type (Entity (P))
or else In_Instance
or else In_Inlined_Body
then
null;
elsif Is_Generic_Type (Entity (P)) then
if Is_Definite_Subtype (Entity (P)) then
Error_Attr_P
("prefix of % attribute must be indefinite generic type");
end if;
else
Error_Attr_P
("prefix of % attribute must be indefinite generic type");
end if;
Set_Etype (N, Standard_Boolean);
end Legal_Formal_Attribute;
---------------------------------------------------------------
-- Max_Alignment_For_Allocation_Max_Size_In_Storage_Elements --
---------------------------------------------------------------
procedure Max_Alignment_For_Allocation_Max_Size_In_Storage_Elements is
begin
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, Universal_Integer);
end Max_Alignment_For_Allocation_Max_Size_In_Storage_Elements;
-------------
-- Min_Max --
-------------
procedure Min_Max is
begin
-- Attribute can appear as function name in a reduction.
-- Semantic checks are performed later.
if Nkind (Parent (N)) = N_Attribute_Reference
and then Attribute_Name (Parent (N)) = Name_Reduce
then
Set_Etype (N, P_Base_Type);
return;
end if;
Check_E2;
Check_Scalar_Type;
Resolve (E1, P_Base_Type);
Resolve (E2, P_Base_Type);
Set_Etype (N, P_Base_Type);
-- Check for comparison on unordered enumeration type
if Bad_Unordered_Enumeration_Reference (N, P_Base_Type) then
Error_Msg_Sloc := Sloc (P_Base_Type);
Error_Msg_NE
("comparison on unordered enumeration type& declared#?U?",
N, P_Base_Type);
end if;
end Min_Max;
------------------------
-- Standard_Attribute --
------------------------
procedure Standard_Attribute (Val : Int) is
begin
Check_Standard_Prefix;
Rewrite (N, Make_Integer_Literal (Loc, Val));
Analyze (N);
Set_Is_Static_Expression (N, True);
end Standard_Attribute;
--------------------
-- Uneval_Old_Msg --
--------------------
procedure Uneval_Old_Msg is
Uneval_Old_Setting : Character;
Prag : Node_Id;
begin
-- If from aspect, then Uneval_Old_Setting comes from flags in the
-- N_Aspect_Specification node that corresponds to the attribute.
-- First find the pragma in which we appear (note that at this stage,
-- even if we appeared originally within an aspect specification, we
-- are now within the corresponding pragma).
Prag := N;
loop
Prag := Parent (Prag);
exit when No (Prag) or else Nkind (Prag) = N_Pragma;
end loop;
if Present (Prag) then
if Uneval_Old_Accept (Prag) then
Uneval_Old_Setting := 'A';
elsif Uneval_Old_Warn (Prag) then
Uneval_Old_Setting := 'W';
else
Uneval_Old_Setting := 'E';
end if;
-- If we did not find the pragma, that's odd, just use the setting
-- from Opt.Uneval_Old. Perhaps this is due to a previous error?
else
Uneval_Old_Setting := Opt.Uneval_Old;
end if;
-- Processing depends on the setting of Uneval_Old
case Uneval_Old_Setting is
when 'E' =>
-- ??? In the case where Ada_Version is < Ada_2020 and
-- an illegal 'Old prefix would be legal in Ada_2020,
-- we'd like to call Error_Msg_Ada_2020_Feature.
-- Identifying that case involves some work.
Error_Attr_P
("prefix of attribute % that is potentially "
& "unevaluated must statically name an entity"
-- further text needed for accuracy if Ada_2020
& (if Ada_Version >= Ada_2020
and then Attr_Id = Attribute_Old
then " or be eligible for conditional evaluation"
& " (RM 6.1.1 (27))"
else ""));
when 'W' =>
Error_Msg_Name_1 := Aname;
Error_Msg_F
("??prefix of attribute % appears in potentially "
& "unevaluated context, exception may be raised", P);
when 'A' =>
null;
when others =>
raise Program_Error;
end case;
end Uneval_Old_Msg;
-------------------------
-- Unexpected Argument --
-------------------------
procedure Unexpected_Argument (En : Node_Id) is
begin
Error_Attr ("unexpected argument for % attribute", En);
end Unexpected_Argument;
-------------------------------------------------
-- Validate_Non_Static_Attribute_Function_Call --
-------------------------------------------------
-- This function should be moved to Sem_Dist ???
procedure Validate_Non_Static_Attribute_Function_Call is
begin
if In_Preelaborated_Unit
and then not In_Subprogram_Or_Concurrent_Unit
then
Flag_Non_Static_Expr
("non-static function call in preelaborated unit!", N);
end if;
end Validate_Non_Static_Attribute_Function_Call;
-- Start of processing for Analyze_Attribute
begin
-- Immediate return if unrecognized attribute (already diagnosed by
-- parser, so there is nothing more that we need to do).
if not Is_Attribute_Name (Aname) then
raise Bad_Attribute;
end if;
Check_Restriction_No_Use_Of_Attribute (N);
-- Deal with Ada 83 issues
if Comes_From_Source (N) then
if not Attribute_83 (Attr_Id) then
if Ada_Version = Ada_83 and then Comes_From_Source (N) then
Error_Msg_Name_1 := Aname;
Error_Msg_N ("(Ada 83) attribute% is not standard??", N);
end if;
if Attribute_Impl_Def (Attr_Id) then
Check_Restriction (No_Implementation_Attributes, N);
end if;
end if;
end if;
-- Deal with Ada 2005 attributes that are implementation attributes
-- because they appear in a version of Ada before Ada 2005, ditto for
-- Ada 2012 and Ada 2020 attributes appearing in an earlier version.
if (Attribute_05 (Attr_Id) and then Ada_Version < Ada_2005)
or else
(Attribute_12 (Attr_Id) and then Ada_Version < Ada_2012)
or else
(Attribute_20 (Attr_Id) and then Ada_Version < Ada_2020)
then
Check_Restriction (No_Implementation_Attributes, N);
end if;
-- Remote access to subprogram type access attribute reference needs
-- unanalyzed copy for tree transformation. The analyzed copy is used
-- for its semantic information (whether prefix is a remote subprogram
-- name), the unanalyzed copy is used to construct new subtree rooted
-- with N_Aggregate which represents a fat pointer aggregate.
if Aname = Name_Access then
Discard_Node (Copy_Separate_Tree (N));
end if;
-- Analyze prefix and exit if error in analysis. If the prefix is an
-- incomplete type, use full view if available. Note that there are
-- some attributes for which we do not analyze the prefix, since the
-- prefix is not a normal name, or else needs special handling.
if Aname /= Name_Elab_Body and then
Aname /= Name_Elab_Spec and then
Aname /= Name_Elab_Subp_Body and then
Aname /= Name_Enabled and then
Aname /= Name_Old
then
Analyze (P);
P_Type := Etype (P);
if Is_Entity_Name (P)
and then Present (Entity (P))
and then Is_Type (Entity (P))
then
if Ekind (Entity (P)) = E_Incomplete_Type then
P_Type := Get_Full_View (P_Type);
Set_Entity (P, P_Type);
Set_Etype (P, P_Type);
elsif Entity (P) = Current_Scope
and then Is_Record_Type (Entity (P))
then
-- Use of current instance within the type. Verify that if the
-- attribute appears within a constraint, it yields an access
-- type, other uses are illegal.
declare
Par : Node_Id;
begin
Par := Parent (N);
while Present (Par)
and then Nkind (Parent (Par)) /= N_Component_Definition
loop
Par := Parent (Par);
end loop;
if Present (Par)
and then Nkind (Par) = N_Subtype_Indication
then
if Attr_Id /= Attribute_Access
and then Attr_Id /= Attribute_Unchecked_Access
and then Attr_Id /= Attribute_Unrestricted_Access
then
Error_Msg_N
("in a constraint the current instance can only "
& "be used with an access attribute", N);
end if;
end if;
end;
end if;
end if;
if P_Type = Any_Type then
raise Bad_Attribute;
end if;
P_Base_Type := Base_Type (P_Type);
end if;
-- Analyze expressions that may be present, exiting if an error occurs
if No (Exprs) then
E1 := Empty;
E2 := Empty;
else
E1 := First (Exprs);
-- Skip analysis for case of Restriction_Set, we do not expect
-- the argument to be analyzed in this case.
if Aname /= Name_Restriction_Set then
Analyze (E1);
-- Check for missing/bad expression (result of previous error)
if No (E1) or else Etype (E1) = Any_Type then
raise Bad_Attribute;
end if;
end if;
E2 := Next (E1);
if Present (E2) then
Analyze (E2);
if Etype (E2) = Any_Type then
raise Bad_Attribute;
end if;
if Present (Next (E2)) then
Unexpected_Argument (Next (E2));
end if;
end if;
end if;
-- Cases where prefix must be resolvable by itself
if Is_Overloaded (P)
and then Aname /= Name_Access
and then Aname /= Name_Address
and then Aname /= Name_Code_Address
and then Aname /= Name_Result
and then Aname /= Name_Unchecked_Access
then
-- The prefix must be resolvable by itself, without reference to the
-- attribute. One case that requires special handling is a prefix
-- that is a function name, where one interpretation may be a
-- parameterless call. Entry attributes are handled specially below.
if Is_Entity_Name (P)
and then Aname not in Name_Count | Name_Caller
then
Check_Parameterless_Call (P);
end if;
if Is_Overloaded (P) then
-- Ada 2005 (AI-345): Since protected and task types have
-- primitive entry wrappers, the attributes Count, and Caller
-- require a context check
if Aname in Name_Count | Name_Caller then
declare
Count : Natural := 0;
I : Interp_Index;
It : Interp;
begin
Get_First_Interp (P, I, It);
while Present (It.Nam) loop
if Comes_From_Source (It.Nam) then
Count := Count + 1;
else
Remove_Interp (I);
end if;
Get_Next_Interp (I, It);
end loop;
if Count > 1 then
Error_Attr ("ambiguous prefix for % attribute", P);
else
Set_Is_Overloaded (P, False);
end if;
end;
else
Error_Attr ("ambiguous prefix for % attribute", P);
end if;
end if;
end if;
-- Remaining processing depends on attribute
case Attr_Id is
-- Attributes related to Ada 2012 iterators. Attribute specifications
-- exist for these, but they cannot be queried.
when Attribute_Constant_Indexing
| Attribute_Default_Iterator
| Attribute_Implicit_Dereference
| Attribute_Iterator_Element
| Attribute_Iterable
| Attribute_Variable_Indexing
=>
Error_Msg_N ("illegal attribute", N);
-- Internal attributes used to deal with Ada 2012 delayed aspects. These
-- were already rejected by the parser. Thus they shouldn't appear here.
when Internal_Attribute_Id =>
raise Program_Error;
------------------
-- Abort_Signal --
------------------
when Attribute_Abort_Signal =>
Check_Standard_Prefix;
Rewrite (N, New_Occurrence_Of (Stand.Abort_Signal, Loc));
Analyze (N);
------------
-- Access --
------------
when Attribute_Access =>
Analyze_Access_Attribute;
Check_Not_Incomplete_Type;
-------------
-- Address --
-------------
when Attribute_Address =>
Check_E0;
Address_Checks;
Check_Not_Incomplete_Type;
Set_Etype (N, RTE (RE_Address));
------------------
-- Address_Size --
------------------
when Attribute_Address_Size =>
Standard_Attribute (System_Address_Size);
--------------
-- Adjacent --
--------------
when Attribute_Adjacent =>
Check_Floating_Point_Type_2;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
Resolve (E2, P_Base_Type);
---------
-- Aft --
---------
when Attribute_Aft =>
Check_Fixed_Point_Type_0;
Set_Etype (N, Universal_Integer);
---------------
-- Alignment --
---------------
when Attribute_Alignment =>
-- Don't we need more checking here, cf Size ???
Check_E0;
Check_Not_Incomplete_Type;
Check_Not_CPP_Type;
Set_Etype (N, Universal_Integer);
---------------
-- Asm_Input --
---------------
when Attribute_Asm_Input =>
Check_Asm_Attribute;
-- The back end may need to take the address of E2
if Is_Entity_Name (E2) then
Set_Address_Taken (Entity (E2));
end if;
Set_Etype (N, RTE (RE_Asm_Input_Operand));
----------------
-- Asm_Output --
----------------
when Attribute_Asm_Output =>
Check_Asm_Attribute;
if Etype (E2) = Any_Type then
return;
elsif Aname = Name_Asm_Output then
if not Is_Variable (E2) then
Error_Attr
("second argument for Asm_Output is not variable", E2);
end if;
end if;
Note_Possible_Modification (E2, Sure => True);
-- The back end may need to take the address of E2
if Is_Entity_Name (E2) then
Set_Address_Taken (Entity (E2));
end if;
Set_Etype (N, RTE (RE_Asm_Output_Operand));
-----------------------------
-- Atomic_Always_Lock_Free --
-----------------------------
when Attribute_Atomic_Always_Lock_Free =>
Check_E0;
Check_Type;
Set_Etype (N, Standard_Boolean);
----------
-- Base --
----------
-- Note: when the base attribute appears in the context of a subtype
-- mark, the analysis is done by Sem_Ch8.Find_Type, rather than by
-- the following circuit.
when Attribute_Base => Base : declare
Typ : Entity_Id;
begin
Check_E0;
Find_Type (P);
Typ := Entity (P);
if Ada_Version >= Ada_95
and then not Is_Scalar_Type (Typ)
and then not Is_Generic_Type (Typ)
then
Error_Attr_P ("prefix of Base attribute must be scalar type");
elsif Sloc (Typ) = Standard_Location
and then Base_Type (Typ) = Typ
and then Warn_On_Redundant_Constructs
then
Error_Msg_NE -- CODEFIX
("?r?redundant attribute, & is its own base type", N, Typ);
end if;
Set_Etype (N, Base_Type (Entity (P)));
Set_Entity (N, Base_Type (Entity (P)));
Rewrite (N, New_Occurrence_Of (Entity (N), Loc));
Analyze (N);
end Base;
---------
-- Bit --
---------
when Attribute_Bit =>
Check_E0;
if not Is_Object_Reference (P) then
Error_Attr_P ("prefix for % attribute must be object");
-- What about the access object cases ???
else
null;
end if;
Set_Etype (N, Universal_Integer);
---------------
-- Bit_Order --
---------------
when Attribute_Bit_Order =>
Check_E0;
Check_Type;
if not Is_Record_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be record type");
end if;
if Bytes_Big_Endian xor Reverse_Bit_Order (P_Type) then
Rewrite (N,
New_Occurrence_Of (RTE (RE_High_Order_First), Loc));
else
Rewrite (N,
New_Occurrence_Of (RTE (RE_Low_Order_First), Loc));
end if;
Set_Etype (N, RTE (RE_Bit_Order));
Resolve (N);
-- Reset incorrect indication of staticness
Set_Is_Static_Expression (N, False);
------------------
-- Bit_Position --
------------------
-- Note: in generated code, we can have a Bit_Position attribute
-- applied to a (naked) record component (i.e. the prefix is an
-- identifier that references an E_Component or E_Discriminant
-- entity directly, and this is interpreted as expected by Gigi.
-- The following code will not tolerate such usage, but when the
-- expander creates this special case, it marks it as analyzed
-- immediately and sets an appropriate type.
when Attribute_Bit_Position =>
if Comes_From_Source (N) then
Check_Component;
end if;
Set_Etype (N, Universal_Integer);
------------------
-- Body_Version --
------------------
when Attribute_Body_Version =>
Check_E0;
Check_Program_Unit;
Set_Etype (N, RTE (RE_Version_String));
--------------
-- Callable --
--------------
when Attribute_Callable =>
Check_E0;
Set_Etype (N, Standard_Boolean);
Check_Task_Prefix;
------------
-- Caller --
------------
when Attribute_Caller => Caller : declare
Ent : Entity_Id;
S : Entity_Id;
begin
Check_E0;
if Nkind (P) in N_Identifier | N_Expanded_Name then
Ent := Entity (P);
if not Is_Entry (Ent) then
Error_Attr ("invalid entry name", N);
end if;
else
Error_Attr ("invalid entry name", N);
return;
end if;
for J in reverse 0 .. Scope_Stack.Last loop
S := Scope_Stack.Table (J).Entity;
if S = Scope (Ent) then
Error_Attr ("Caller must appear in matching accept or body", N);
elsif S = Ent then
exit;
end if;
end loop;
Set_Etype (N, RTE (RO_AT_Task_Id));
end Caller;
-------------
-- Ceiling --
-------------
when Attribute_Ceiling =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
-----------
-- Class --
-----------
when Attribute_Class =>
Check_Restriction (No_Dispatch, N);
Check_E0;
Find_Type (N);
-- Applying Class to untagged incomplete type is obsolescent in Ada
-- 2005. Note that we can't test Is_Tagged_Type here on P_Type, since
-- this flag gets set by Find_Type in this situation.
if Restriction_Check_Required (No_Obsolescent_Features)
and then Ada_Version >= Ada_2005
and then Ekind (P_Type) = E_Incomplete_Type
then
declare
DN : constant Node_Id := Declaration_Node (P_Type);
begin
if Nkind (DN) = N_Incomplete_Type_Declaration
and then not Tagged_Present (DN)
then
Check_Restriction (No_Obsolescent_Features, P);
end if;
end;
end if;
------------------
-- Code_Address --
------------------
when Attribute_Code_Address =>
Check_E0;
if Nkind (P) = N_Attribute_Reference
and then Attribute_Name (P) in Name_Elab_Body | Name_Elab_Spec
then
null;
elsif not Is_Entity_Name (P)
or else (Ekind (Entity (P)) /= E_Function
and then
Ekind (Entity (P)) /= E_Procedure)
then
Error_Attr ("invalid prefix for % attribute", P);
Set_Address_Taken (Entity (P));
-- Issue an error if the prefix denotes an eliminated subprogram
else
Check_For_Eliminated_Subprogram (P, Entity (P));
end if;
Set_Etype (N, RTE (RE_Address));
----------------------
-- Compiler_Version --
----------------------
when Attribute_Compiler_Version =>
Check_E0;
Check_Standard_Prefix;
Rewrite (N, Make_String_Literal (Loc, "GNAT " & Gnat_Version_String));
Analyze_And_Resolve (N, Standard_String);
Set_Is_Static_Expression (N, True);
--------------------
-- Component_Size --
--------------------
when Attribute_Component_Size =>
Check_E0;
Set_Etype (N, Universal_Integer);
-- Note: unlike other array attributes, unconstrained arrays are OK
if Is_Array_Type (P_Type) and then not Is_Constrained (P_Type) then
null;
else
Check_Array_Type;
end if;
-------------
-- Compose --
-------------
when Attribute_Compose =>
Check_Floating_Point_Type_2;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
Resolve (E2, Any_Integer);
-----------------
-- Constrained --
-----------------
when Attribute_Constrained =>
Check_E0;
Set_Etype (N, Standard_Boolean);
-- Case from RM J.4(2) of constrained applied to private type
if Is_Entity_Name (P) and then Is_Type (Entity (P)) then
Check_Restriction (No_Obsolescent_Features, P);
if Warn_On_Obsolescent_Feature then
Error_Msg_N
("constrained for private type is an obsolescent feature "
& "(RM J.4)?j?", N);
end if;
-- If we are within an instance, the attribute must be legal
-- because it was valid in the generic unit. Ditto if this is
-- an inlining of a function declared in an instance.
if In_Instance or else In_Inlined_Body then
return;
-- For sure OK if we have a real private type itself, but must
-- be completed, cannot apply Constrained to incomplete type.
elsif Is_Private_Type (Entity (P)) then
-- Note: this is one of the Annex J features that does not
-- generate a warning from -gnatwj, since in fact it seems
-- very useful, and is used in the GNAT runtime.
Check_Not_Incomplete_Type;
return;
end if;
-- Normal (non-obsolescent case) of application to object or value of
-- a discriminated type.
else
-- AI12-0068: In a type or subtype aspect, a prefix denoting the
-- current instance of the (sub)type is defined to be a value,
-- not an object, so the Constrained attribute is always True
-- (see RM 8.6(18/5) and RM 3.7.2(3/5)). We issue a warning about
-- this unintuitive result, to help avoid confusion.
if Is_Current_Instance_Reference_In_Type_Aspect (P) then
Error_Msg_Name_1 := Aname;
Error_Msg_N
("current instance attribute % in subtype aspect always " &
"true??", N);
else
Check_Object_Reference (P);
end if;
-- If N does not come from source, then we allow the
-- the attribute prefix to be of a private type whose
-- full type has discriminants. This occurs in cases
-- involving expanded calls to stream attributes.
if not Comes_From_Source (N) then
P_Type := Underlying_Type (P_Type);
end if;
-- Must have discriminants or be an access type designating a type
-- with discriminants. If it is a class-wide type it has unknown
-- discriminants.
if Has_Discriminants (P_Type)
or else Has_Unknown_Discriminants (P_Type)
or else
(Is_Access_Type (P_Type)
and then Has_Discriminants (Designated_Type (P_Type)))
then
return;
-- The rule given in 3.7.2 is part of static semantics, but the
-- intent is clearly that it be treated as a legality rule, and
-- rechecked in the visible part of an instance. Nevertheless
-- the intent also seems to be it should legally apply to the
-- actual of a formal with unknown discriminants, regardless of
-- whether the actual has discriminants, in which case the value
-- of the attribute is determined using the J.4 rules. This choice
-- seems the most useful, and is compatible with existing tests.
elsif In_Instance then
return;
-- Also allow an object of a generic type if extensions allowed
-- and allow this for any type at all.
elsif (Is_Generic_Type (P_Type)
or else Is_Generic_Actual_Type (P_Type))
and then Extensions_Allowed
then
return;
end if;
end if;
-- Fall through if bad prefix
Error_Attr_P
("prefix of % attribute must be object of discriminated type");
---------------
-- Copy_Sign --
---------------
when Attribute_Copy_Sign =>
Check_Floating_Point_Type_2;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
Resolve (E2, P_Base_Type);
-----------
-- Count --
-----------
when Attribute_Count => Count : declare
Ent : Entity_Id;
S : Entity_Id;
Tsk : Entity_Id;
begin
Check_E0;
if Nkind (P) in N_Identifier | N_Expanded_Name then
Ent := Entity (P);
if Ekind (Ent) /= E_Entry then
Error_Attr ("invalid entry name", N);
end if;
elsif Nkind (P) = N_Indexed_Component then
if not Is_Entity_Name (Prefix (P))
or else No (Entity (Prefix (P)))
or else Ekind (Entity (Prefix (P))) /= E_Entry_Family
then
if Nkind (Prefix (P)) = N_Selected_Component
and then Present (Entity (Selector_Name (Prefix (P))))
and then Ekind (Entity (Selector_Name (Prefix (P)))) =
E_Entry_Family
then
Error_Attr
("attribute % must apply to entry of current task", P);
else
Error_Attr ("invalid entry family name", P);
end if;
return;
else
Ent := Entity (Prefix (P));
end if;
elsif Nkind (P) = N_Selected_Component
and then Present (Entity (Selector_Name (P)))
and then Ekind (Entity (Selector_Name (P))) = E_Entry
then
Error_Attr
("attribute % must apply to entry of current task", P);
else
Error_Attr ("invalid entry name", N);
return;
end if;
for J in reverse 0 .. Scope_Stack.Last loop
S := Scope_Stack.Table (J).Entity;
if S = Scope (Ent) then
if Nkind (P) = N_Expanded_Name then
Tsk := Entity (Prefix (P));
-- The prefix denotes either the task type, or else a
-- single task whose task type is being analyzed.
if (Is_Type (Tsk) and then Tsk = S)
or else (not Is_Type (Tsk)
and then Etype (Tsk) = S
and then not (Comes_From_Source (S)))
then
null;
else
Error_Attr
("Attribute % must apply to entry of current task", N);
end if;
end if;
exit;
elsif Ekind (Scope (Ent)) in Task_Kind
and then Ekind (S) not in E_Block
| E_Entry
| E_Entry_Family
| E_Loop
then
Error_Attr ("Attribute % cannot appear in inner unit", N);
elsif Ekind (Scope (Ent)) = E_Protected_Type
and then not Has_Completion (Scope (Ent))
then
Error_Attr ("attribute % can only be used inside body", N);
end if;
end loop;
if Is_Overloaded (P) then
declare
Index : Interp_Index;
It : Interp;
begin
Get_First_Interp (P, Index, It);
while Present (It.Nam) loop
if It.Nam = Ent then
null;
-- Ada 2005 (AI-345): Do not consider primitive entry
-- wrappers generated for task or protected types.
elsif Ada_Version >= Ada_2005
and then not Comes_From_Source (It.Nam)
then
null;
else
Error_Attr ("ambiguous entry name", N);
end if;
Get_Next_Interp (Index, It);
end loop;
end;
end if;
Set_Etype (N, Universal_Integer);
end Count;
-----------------------
-- Default_Bit_Order --
-----------------------
when Attribute_Default_Bit_Order => Default_Bit_Order : declare
Target_Default_Bit_Order : System.Bit_Order;
begin
Check_Standard_Prefix;
if Bytes_Big_Endian then
Target_Default_Bit_Order := System.High_Order_First;
else
Target_Default_Bit_Order := System.Low_Order_First;
end if;
Rewrite (N,
Make_Integer_Literal (Loc,
UI_From_Int (System.Bit_Order'Pos (Target_Default_Bit_Order))));
Set_Etype (N, Universal_Integer);
Set_Is_Static_Expression (N);
end Default_Bit_Order;
----------------------------------
-- Default_Scalar_Storage_Order --
----------------------------------
when Attribute_Default_Scalar_Storage_Order => Default_SSO : declare
RE_Default_SSO : RE_Id;
begin
Check_Standard_Prefix;
case Opt.Default_SSO is
when ' ' =>
if Bytes_Big_Endian then
RE_Default_SSO := RE_High_Order_First;
else
RE_Default_SSO := RE_Low_Order_First;
end if;
when 'H' =>
RE_Default_SSO := RE_High_Order_First;
when 'L' =>
RE_Default_SSO := RE_Low_Order_First;
when others =>
raise Program_Error;
end case;
Rewrite (N, New_Occurrence_Of (RTE (RE_Default_SSO), Loc));
end Default_SSO;
--------------
-- Definite --
--------------
when Attribute_Definite =>
Legal_Formal_Attribute;
-----------
-- Delta --
-----------
when Attribute_Delta =>
Check_Fixed_Point_Type_0;
Set_Etype (N, Universal_Real);
------------
-- Denorm --
------------
when Attribute_Denorm =>
Check_Floating_Point_Type_0;
Set_Etype (N, Standard_Boolean);
-----------
-- Deref --
-----------
when Attribute_Deref =>
Check_Type;
Check_E1;
Resolve (E1, RTE (RE_Address));
Set_Etype (N, P_Type);
---------------------
-- Descriptor_Size --
---------------------
when Attribute_Descriptor_Size =>
Check_E0;
if not Is_Entity_Name (P) or else not Is_Type (Entity (P)) then
Error_Attr_P ("prefix of attribute % must denote a type");
end if;
Set_Etype (N, Universal_Integer);
------------
-- Digits --
------------
when Attribute_Digits =>
Check_E0;
Check_Type;
if not Is_Floating_Point_Type (P_Type)
and then not Is_Decimal_Fixed_Point_Type (P_Type)
then
Error_Attr_P
("prefix of % attribute must be float or decimal type");
end if;
Set_Etype (N, Universal_Integer);
---------------
-- Elab_Body --
---------------
-- Also handles processing for Elab_Spec and Elab_Subp_Body
when Attribute_Elab_Body
| Attribute_Elab_Spec
| Attribute_Elab_Subp_Body
=>
Check_E0;
Check_Unit_Name (P);
Set_Etype (N, Standard_Void_Type);
-- We have to manually call the expander in this case to get
-- the necessary expansion (normally attributes that return
-- entities are not expanded).
Expand (N);
---------------
-- Elab_Spec --
---------------
-- Shares processing with Elab_Body
----------------
-- Elaborated --
----------------
when Attribute_Elaborated =>
Check_E0;
Check_Unit_Name (P);
Set_Etype (N, Standard_Boolean);
----------
-- Emax --
----------
when Attribute_Emax =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
-------------
-- Enabled --
-------------
when Attribute_Enabled =>
Check_Either_E0_Or_E1;
if Present (E1) then
if not Is_Entity_Name (E1) or else No (Entity (E1)) then
Error_Msg_N ("entity name expected for Enabled attribute", E1);
E1 := Empty;
end if;
end if;
if Nkind (P) /= N_Identifier then
Error_Msg_N ("identifier expected (check name)", P);
elsif Get_Check_Id (Chars (P)) = No_Check_Id then
Error_Msg_N ("& is not a recognized check name", P);
end if;
Set_Etype (N, Standard_Boolean);
--------------
-- Enum_Rep --
--------------
when Attribute_Enum_Rep =>
-- T'Enum_Rep (X) case
if Present (E1) then
Check_E1;
Check_Discrete_Type;
Resolve (E1, P_Base_Type);
-- X'Enum_Rep case. X must be an object or enumeration literal
-- (including an attribute reference), and it must be of a
-- discrete type.
elsif not
((Is_Object_Reference (P)
or else
(Is_Entity_Name (P)
and then Ekind (Entity (P)) = E_Enumeration_Literal)
or else Nkind (P) = N_Attribute_Reference)
and then Is_Discrete_Type (Etype (P)))
then
Error_Attr_P ("prefix of % attribute must be discrete object");
end if;
Set_Etype (N, Universal_Integer);
--------------
-- Enum_Val --
--------------
when Attribute_Enum_Val =>
Check_E1;
Check_Type;
if not Is_Enumeration_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be enumeration type");
end if;
-- If the enumeration type has a standard representation, the effect
-- is the same as 'Val, so rewrite the attribute as a 'Val.
if not Has_Non_Standard_Rep (P_Base_Type) then
Rewrite (N,
Make_Attribute_Reference (Loc,
Prefix => Relocate_Node (Prefix (N)),
Attribute_Name => Name_Val,
Expressions => New_List (Relocate_Node (E1))));
Analyze_And_Resolve (N, P_Base_Type);
-- Non-standard representation case (enumeration with holes)
else
Check_Enum_Image;
Resolve (E1, Any_Integer);
Set_Etype (N, P_Base_Type);
end if;
-------------
-- Epsilon --
-------------
when Attribute_Epsilon =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Real);
--------------
-- Exponent --
--------------
when Attribute_Exponent =>
Check_Floating_Point_Type_1;
Set_Etype (N, Universal_Integer);
Resolve (E1, P_Base_Type);
------------------
-- External_Tag --
------------------
when Attribute_External_Tag =>
Check_E0;
Check_Type;
Set_Etype (N, Standard_String);
if not Is_Tagged_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be tagged");
end if;
---------------
-- Fast_Math --
---------------
when Attribute_Fast_Math =>
Check_Standard_Prefix;
Rewrite (N, New_Occurrence_Of (Boolean_Literals (Fast_Math), Loc));
-----------------------
-- Finalization_Size --
-----------------------
when Attribute_Finalization_Size =>
Check_E0;
-- The prefix denotes an object
if Is_Object_Reference (P) then
Check_Object_Reference (P);
-- The prefix denotes a type
elsif Is_Entity_Name (P) and then Is_Type (Entity (P)) then
Check_Type;
Check_Not_Incomplete_Type;
-- Attribute 'Finalization_Size is not defined for class-wide
-- types because it is not possible to know statically whether
-- a definite type will have controlled components or not.
if Is_Class_Wide_Type (Etype (P)) then
Error_Attr_P
("prefix of % attribute cannot denote a class-wide type");
end if;
-- The prefix denotes an illegal construct
else
Error_Attr_P
("prefix of % attribute must be a definite type or an object");
end if;
Set_Etype (N, Universal_Integer);
-----------
-- First --
-----------
when Attribute_First =>
Check_Array_Or_Scalar_Type;
Bad_Attribute_For_Predicate;
---------------
-- First_Bit --
---------------
when Attribute_First_Bit =>
Check_Component;
Set_Etype (N, Universal_Integer);
-----------------
-- First_Valid --
-----------------
when Attribute_First_Valid =>
Check_First_Last_Valid;
Set_Etype (N, P_Type);
-----------------
-- Fixed_Value --
-----------------
when Attribute_Fixed_Value =>
Check_E1;
Check_Fixed_Point_Type;
Resolve (E1, Any_Integer);
Set_Etype (N, P_Base_Type);
-----------
-- Floor --
-----------
when Attribute_Floor =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
----------
-- Fore --
----------
when Attribute_Fore =>
Check_Fixed_Point_Type_0;
Set_Etype (N, Universal_Integer);
--------------
-- Fraction --
--------------
when Attribute_Fraction =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
--------------
-- From_Any --
--------------
when Attribute_From_Any =>
Check_E1;
Check_PolyORB_Attribute;
Set_Etype (N, P_Base_Type);
-----------------------
-- Has_Access_Values --
-----------------------
when Attribute_Has_Access_Values =>
Check_Type;
Check_E0;
Set_Etype (N, Standard_Boolean);
----------------------
-- Has_Same_Storage --
----------------------
when Attribute_Has_Same_Storage =>
Check_E1;
-- The arguments must be objects of any type
Analyze_And_Resolve (P);
Analyze_And_Resolve (E1);
Check_Object_Reference (P);
Check_Object_Reference (E1);
Set_Etype (N, Standard_Boolean);
-----------------------
-- Has_Tagged_Values --
-----------------------
when Attribute_Has_Tagged_Values =>
Check_Type;
Check_E0;
Set_Etype (N, Standard_Boolean);
-----------------------
-- Has_Discriminants --
-----------------------
when Attribute_Has_Discriminants =>
Legal_Formal_Attribute;
--------------
-- Identity --
--------------
when Attribute_Identity =>
Check_E0;
Analyze (P);
if Etype (P) = Standard_Exception_Type then
Set_Etype (N, RTE (RE_Exception_Id));
-- Ada 2005 (AI-345): Attribute 'Identity may be applied to task
-- interface class-wide types.
elsif Is_Task_Type (Etype (P))
or else (Is_Access_Type (Etype (P))
and then Is_Task_Type (Designated_Type (Etype (P))))
or else (Ada_Version >= Ada_2005
and then Ekind (Etype (P)) = E_Class_Wide_Type
and then Is_Interface (Etype (P))
and then Is_Task_Interface (Etype (P)))
then
Resolve (P);
Set_Etype (N, RTE (RO_AT_Task_Id));
else
if Ada_Version >= Ada_2005 then
Error_Attr_P
("prefix of % attribute must be an exception, a task or a "
& "task interface class-wide object");
else
Error_Attr_P
("prefix of % attribute must be a task or an exception");
end if;
end if;
-----------
-- Image --
-----------
when Attribute_Image =>
if Is_Real_Type (P_Type) then
if Ada_Version = Ada_83 and then Comes_From_Source (N) then
Error_Msg_Name_1 := Aname;
Error_Msg_N
("(Ada 83) % attribute not allowed for real types", N);
end if;
end if;
Analyze_Image_Attribute (Standard_String);
---------
-- Img --
---------
when Attribute_Img =>
Analyze_Image_Attribute (Standard_String);
-----------------
-- Initialized --
-----------------
when Attribute_Initialized =>
Check_E0;
if Comes_From_Source (N) then
-- This attribute be prefixed with references to objects or
-- values (such as a current instance value given within a type
-- or subtype aspect).
if not Is_Object_Reference (P)
and then not Is_Current_Instance_Reference_In_Type_Aspect (P)
then
Error_Attr_P ("prefix of % attribute must be object");
end if;
end if;
Set_Etype (N, Standard_Boolean);
-----------
-- Input --
-----------
when Attribute_Input =>
Check_E1;
Check_Stream_Attribute (TSS_Stream_Input);
Set_Etype (N, P_Base_Type);
-------------------
-- Integer_Value --
-------------------
when Attribute_Integer_Value =>
Check_E1;
Check_Integer_Type;
Resolve (E1, Any_Fixed);
-- Signal an error if argument type is not a specific fixed-point
-- subtype. An error has been signalled already if the argument
-- was not of a fixed-point type.
if Etype (E1) = Any_Fixed and then not Error_Posted (E1) then
Error_Attr ("argument of % must be of a fixed-point type", E1);
end if;
Set_Etype (N, P_Base_Type);
-------------------
-- Invalid_Value --
-------------------
when Attribute_Invalid_Value =>
Check_E0;
Check_Scalar_Type;
Set_Etype (N, P_Base_Type);
Invalid_Value_Used := True;
-----------
-- Large --
-----------
when Attribute_Large =>
Check_E0;
Check_Real_Type;
Set_Etype (N, Universal_Real);
----------
-- Last --
----------
when Attribute_Last =>
Check_Array_Or_Scalar_Type;
Bad_Attribute_For_Predicate;
--------------
-- Last_Bit --
--------------
when Attribute_Last_Bit =>
Check_Component;
Set_Etype (N, Universal_Integer);
----------------
-- Last_Valid --
----------------
when Attribute_Last_Valid =>
Check_First_Last_Valid;
Set_Etype (N, P_Type);
------------------
-- Leading_Part --
------------------
when Attribute_Leading_Part =>
Check_Floating_Point_Type_2;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
Resolve (E2, Any_Integer);
------------
-- Length --
------------
when Attribute_Length =>
Check_Array_Type;
Set_Etype (N, Universal_Integer);
-------------------
-- Library_Level --
-------------------
when Attribute_Library_Level =>
Check_E0;
if not Is_Entity_Name (P) then
Error_Attr_P ("prefix of % attribute must be an entity name");
end if;
if not Inside_A_Generic then
Set_Boolean_Result (N,
Is_Library_Level_Entity (Entity (P)));
end if;
Set_Etype (N, Standard_Boolean);
---------------
-- Lock_Free --
---------------
when Attribute_Lock_Free =>
Check_E0;
Set_Etype (N, Standard_Boolean);
if not Is_Protected_Type (P_Type) then
Error_Attr_P
("prefix of % attribute must be a protected object");
end if;
----------------
-- Loop_Entry --
----------------
when Attribute_Loop_Entry => Loop_Entry : declare
procedure Check_References_In_Prefix (Loop_Id : Entity_Id);
-- Inspect the prefix for any uses of entities declared within the
-- related loop. Loop_Id denotes the loop identifier.
--------------------------------
-- Check_References_In_Prefix --
--------------------------------
procedure Check_References_In_Prefix (Loop_Id : Entity_Id) is
Loop_Decl : constant Node_Id := Label_Construct (Parent (Loop_Id));
function Check_Reference (Nod : Node_Id) return Traverse_Result;
-- Determine whether a reference mentions an entity declared
-- within the related loop.
function Declared_Within (Nod : Node_Id) return Boolean;
-- Determine whether Nod appears in the subtree of Loop_Decl
---------------------
-- Check_Reference --
---------------------
function Check_Reference (Nod : Node_Id) return Traverse_Result is
begin
if Nkind (Nod) = N_Identifier
and then Present (Entity (Nod))
and then Declared_Within (Declaration_Node (Entity (Nod)))
then
Error_Attr
("prefix of attribute % cannot reference local entities",
Nod);
return Abandon;
else
return OK;
end if;
end Check_Reference;
procedure Check_References is new Traverse_Proc (Check_Reference);
---------------------
-- Declared_Within --
---------------------
function Declared_Within (Nod : Node_Id) return Boolean is
Stmt : Node_Id;
begin
Stmt := Nod;
while Present (Stmt) loop
if Stmt = Loop_Decl then
return True;
-- Prevent the search from going too far
elsif Is_Body_Or_Package_Declaration (Stmt) then
exit;
end if;
Stmt := Parent (Stmt);
end loop;
return False;
end Declared_Within;
-- Start of processing for Check_Prefix_For_Local_References
begin
Check_References (P);
end Check_References_In_Prefix;
-- Local variables
Context : constant Node_Id := Parent (N);
Attr : Node_Id;
Encl_Loop : Node_Id := Empty;
Encl_Prag : Node_Id := Empty;
Loop_Id : Entity_Id := Empty;
Scop : Entity_Id;
Stmt : Node_Id;
-- Start of processing for Loop_Entry
begin
Attr := N;
-- Set the type of the attribute now to ensure the successful
-- continuation of analysis even if the attribute is misplaced.
Set_Etype (Attr, P_Type);
-- Attribute 'Loop_Entry may appear in several flavors:
-- * Prefix'Loop_Entry - in this form, the attribute applies to the
-- nearest enclosing loop.
-- * Prefix'Loop_Entry (Expr) - depending on what Expr denotes, the
-- attribute may be related to a loop denoted by label Expr or
-- the prefix may denote an array object and Expr may act as an
-- indexed component.
-- * Prefix'Loop_Entry (Expr1, ..., ExprN) - the attribute applies
-- to the nearest enclosing loop, all expressions are part of
-- an indexed component.
-- * Prefix'Loop_Entry (Expr) (...) (...) - depending on what Expr
-- denotes, the attribute may be related to a loop denoted by
-- label Expr or the prefix may denote a multidimensional array
-- array object and Expr along with the rest of the expressions
-- may act as indexed components.
-- Regardless of variations, the attribute reference does not have an
-- expression list. Instead, all available expressions are stored as
-- indexed components.
-- When the attribute is part of an indexed component, find the first
-- expression as it will determine the semantics of 'Loop_Entry.
-- If the attribute is itself an index in an indexed component, i.e.
-- a member of a list, the context itself is not relevant (the code
-- below would lead to an infinite loop) and the attribute applies
-- to the enclosing loop.
if Nkind (Context) = N_Indexed_Component
and then not Is_List_Member (N)
then
E1 := First (Expressions (Context));
E2 := Next (E1);
-- The attribute reference appears in the following form:
-- Prefix'Loop_Entry (Exp1, Expr2, ..., ExprN) [(...)]
-- In this case, the loop name is omitted and no rewriting is
-- required.
if Present (E2) then
null;
-- The form of the attribute is:
-- Prefix'Loop_Entry (Expr) [(...)]
-- If Expr denotes a loop entry, the whole attribute and indexed
-- component will have to be rewritten to reflect this relation.
else
pragma Assert (Present (E1));
-- Do not expand the expression as it may have side effects.
-- Simply preanalyze to determine whether it is a loop name or
-- something else.
Preanalyze_And_Resolve (E1);
if Is_Entity_Name (E1)
and then Present (Entity (E1))
and then Ekind (Entity (E1)) = E_Loop
then
Loop_Id := Entity (E1);
-- Transform the attribute and enclosing indexed component
Set_Expressions (N, Expressions (Context));
Rewrite (Context, N);
Set_Etype (Context, P_Type);
Attr := Context;
end if;
end if;
end if;
-- The prefix must denote an object
if not Is_Object_Reference (P) then
Error_Attr_P ("prefix of attribute % must denote an object");
end if;
-- The prefix cannot be of a limited type because the expansion of
-- Loop_Entry must create a constant initialized by the evaluated
-- prefix.
if Is_Limited_View (Etype (P)) then
Error_Attr_P ("prefix of attribute % cannot be limited");
end if;
-- Climb the parent chain to verify the location of the attribute and
-- find the enclosing loop.
Stmt := Attr;
while Present (Stmt) loop
-- Locate the corresponding enclosing pragma. Note that in the
-- case of Assert[And_Cut] and Assume, we have already checked
-- that the pragma appears in an appropriate loop location.
if Nkind (Original_Node (Stmt)) = N_Pragma
and then
Pragma_Name_Unmapped (Original_Node (Stmt))
in Name_Loop_Invariant
| Name_Loop_Variant
| Name_Assert
| Name_Assert_And_Cut
| Name_Assume
then
Encl_Prag := Original_Node (Stmt);
-- Locate the enclosing loop (if any). Note that Ada 2012 array
-- iteration may be expanded into several nested loops, we are
-- interested in the outermost one which has the loop identifier,
-- and comes from source.
elsif Nkind (Stmt) = N_Loop_Statement
and then Present (Identifier (Stmt))
and then Comes_From_Source (Original_Node (Stmt))
and then Nkind (Original_Node (Stmt)) = N_Loop_Statement
then
Encl_Loop := Stmt;
-- The original attribute reference may lack a loop name. Use
-- the name of the enclosing loop because it is the related
-- loop.
if No (Loop_Id) then
Loop_Id := Entity (Identifier (Encl_Loop));
end if;
exit;
-- Prevent the search from going too far
elsif Is_Body_Or_Package_Declaration (Stmt) then
exit;
end if;
Stmt := Parent (Stmt);
end loop;
-- Loop_Entry must appear within a Loop_Assertion pragma (Assert,
-- Assert_And_Cut, Assume count as loop assertion pragmas for this
-- purpose if they appear in an appropriate location in a loop,
-- which was already checked by the top level pragma circuit).
-- Loop_Entry also denotes a value and as such can appear within an
-- expression that is an argument for another loop aspect. In that
-- case it will have been expanded into the corresponding assignment.
if Expander_Active
and then Nkind (Parent (N)) = N_Assignment_Statement
and then not Comes_From_Source (Parent (N))
then
null;
elsif No (Encl_Prag) then
Error_Attr ("attribute% must appear within appropriate pragma", N);
end if;
-- A Loop_Entry that applies to a given loop statement must not
-- appear within a body of accept statement, if this construct is
-- itself enclosed by the given loop statement.
for Index in reverse 0 .. Scope_Stack.Last loop
Scop := Scope_Stack.Table (Index).Entity;
if Ekind (Scop) = E_Loop and then Scop = Loop_Id then
exit;
elsif Ekind (Scop) in E_Block | E_Loop | E_Return_Statement then
null;
else
Error_Attr
("attribute % cannot appear in body or accept statement", N);
exit;
end if;
end loop;
-- The prefix cannot mention entities declared within the related
-- loop because they will not be visible once the prefix is moved
-- outside the loop.
Check_References_In_Prefix (Loop_Id);
-- The prefix must statically name an object if the pragma does not
-- apply to the innermost enclosing loop statement, or if it appears
-- within a potentially unevaluated expression.
if Is_Entity_Name (P)
or else Nkind (Parent (P)) = N_Object_Renaming_Declaration
or else Statically_Names_Object (P)
then
null;
elsif Present (Encl_Loop)
and then Entity (Identifier (Encl_Loop)) /= Loop_Id
then
Error_Attr_P
("prefix of attribute % that applies to outer loop must denote "
& "an entity");
elsif Is_Potentially_Unevaluated (P) then
Uneval_Old_Msg;
end if;
-- Replace the Loop_Entry attribute reference by its prefix if the
-- related pragma is ignored. This transformation is OK with respect
-- to typing because Loop_Entry's type is that of its prefix. This
-- early transformation also avoids the generation of a useless loop
-- entry constant.
if Present (Encl_Prag) and then Is_Ignored (Encl_Prag) then
Rewrite (N, Relocate_Node (P));
Preanalyze_And_Resolve (N);
else
Preanalyze_And_Resolve (P);
end if;
end Loop_Entry;
-------------
-- Machine --
-------------
when Attribute_Machine =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
------------------
-- Machine_Emax --
------------------
when Attribute_Machine_Emax =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
------------------
-- Machine_Emin --
------------------
when Attribute_Machine_Emin =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
----------------------
-- Machine_Mantissa --
----------------------
when Attribute_Machine_Mantissa =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
-----------------------
-- Machine_Overflows --
-----------------------
when Attribute_Machine_Overflows =>
Check_Real_Type;
Check_E0;
Set_Etype (N, Standard_Boolean);
-------------------
-- Machine_Radix --
-------------------
when Attribute_Machine_Radix =>
Check_Real_Type;
Check_E0;
Set_Etype (N, Universal_Integer);
----------------------
-- Machine_Rounding --
----------------------
when Attribute_Machine_Rounding =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
--------------------
-- Machine_Rounds --
--------------------
when Attribute_Machine_Rounds =>
Check_Real_Type;
Check_E0;
Set_Etype (N, Standard_Boolean);
------------------
-- Machine_Size --
------------------
when Attribute_Machine_Size =>
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, Universal_Integer);
--------------
-- Mantissa --
--------------
when Attribute_Mantissa =>
Check_E0;
Check_Real_Type;
Set_Etype (N, Universal_Integer);
---------
-- Max --
---------
when Attribute_Max =>
Min_Max;
----------------------------------
-- Max_Alignment_For_Allocation --
----------------------------------
when Attribute_Max_Size_In_Storage_Elements =>
Max_Alignment_For_Allocation_Max_Size_In_Storage_Elements;
----------------------
-- Max_Integer_Size --
----------------------
when Attribute_Max_Integer_Size =>
Standard_Attribute (System_Max_Integer_Size);
----------------------------------
-- Max_Size_In_Storage_Elements --
----------------------------------
when Attribute_Max_Alignment_For_Allocation =>
Max_Alignment_For_Allocation_Max_Size_In_Storage_Elements;
-----------------------
-- Maximum_Alignment --
-----------------------
when Attribute_Maximum_Alignment =>
Standard_Attribute (Ttypes.Maximum_Alignment);
--------------------
-- Mechanism_Code --
--------------------
when Attribute_Mechanism_Code =>
if not Is_Entity_Name (P)
or else not Is_Subprogram (Entity (P))
then
Error_Attr_P ("prefix of % attribute must be subprogram");
end if;
Check_Either_E0_Or_E1;
if Present (E1) then
Resolve (E1, Any_Integer);
Set_Etype (E1, Standard_Integer);
if not Is_OK_Static_Expression (E1) then
Flag_Non_Static_Expr
("expression for parameter number must be static!", E1);
Error_Attr;
elsif UI_To_Int (Intval (E1)) > Number_Formals (Entity (P))
or else UI_To_Int (Intval (E1)) < 0
then
Error_Attr ("invalid parameter number for % attribute", E1);
end if;
end if;
Set_Etype (N, Universal_Integer);
---------
-- Min --
---------
when Attribute_Min =>
Min_Max;
---------
-- Mod --
---------
when Attribute_Mod =>
-- Note: this attribute is only allowed in Ada 2005 mode, but
-- we do not need to test that here, since Mod is only recognized
-- as an attribute name in Ada 2005 mode during the parse.
Check_E1;
Check_Modular_Integer_Type;
Resolve (E1, Any_Integer);
Set_Etype (N, P_Base_Type);
-----------
-- Model --
-----------
when Attribute_Model =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
----------------
-- Model_Emin --
----------------
when Attribute_Model_Emin =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
-------------------
-- Model_Epsilon --
-------------------
when Attribute_Model_Epsilon =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Real);
--------------------
-- Model_Mantissa --
--------------------
when Attribute_Model_Mantissa =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
-----------------
-- Model_Small --
-----------------
when Attribute_Model_Small =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Real);
-------------
-- Modulus --
-------------
when Attribute_Modulus =>
Check_E0;
Check_Modular_Integer_Type;
Set_Etype (N, Universal_Integer);
--------------------
-- Null_Parameter --
--------------------
when Attribute_Null_Parameter => Null_Parameter : declare
Parnt : constant Node_Id := Parent (N);
GParnt : constant Node_Id := Parent (Parnt);
procedure Bad_Null_Parameter (Msg : String);
-- Used if bad Null parameter attribute node is found. Issues
-- given error message, and also sets the type to Any_Type to
-- avoid blowups later on from dealing with a junk node.
procedure Must_Be_Imported (Proc_Ent : Entity_Id);
-- Called to check that Proc_Ent is imported subprogram
------------------------
-- Bad_Null_Parameter --
------------------------
procedure Bad_Null_Parameter (Msg : String) is
begin
Error_Msg_N (Msg, N);
Set_Etype (N, Any_Type);
end Bad_Null_Parameter;
----------------------
-- Must_Be_Imported --
----------------------
procedure Must_Be_Imported (Proc_Ent : Entity_Id) is
Pent : constant Entity_Id := Ultimate_Alias (Proc_Ent);
begin
-- Ignore check if procedure not frozen yet (we will get
-- another chance when the default parameter is reanalyzed)
if not Is_Frozen (Pent) then
return;
elsif not Is_Imported (Pent) then
Bad_Null_Parameter
("Null_Parameter can only be used with imported subprogram");
else
return;
end if;
end Must_Be_Imported;
-- Start of processing for Null_Parameter
begin
Check_Type;
Check_E0;
Set_Etype (N, P_Type);
-- Case of attribute used as default expression
if Nkind (Parnt) = N_Parameter_Specification then
Must_Be_Imported (Defining_Entity (GParnt));
-- Case of attribute used as actual for subprogram (positional)
elsif Nkind (Parnt) in N_Subprogram_Call
and then Is_Entity_Name (Name (Parnt))
then
Must_Be_Imported (Entity (Name (Parnt)));
-- Case of attribute used as actual for subprogram (named)
elsif Nkind (Parnt) = N_Parameter_Association
and then Nkind (GParnt) in N_Subprogram_Call
and then Is_Entity_Name (Name (GParnt))
then
Must_Be_Imported (Entity (Name (GParnt)));
-- Not an allowed case
else
Bad_Null_Parameter
("Null_Parameter must be actual or default parameter");
end if;
end Null_Parameter;
-----------------
-- Object_Size --
-----------------
when Attribute_Object_Size =>
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, Universal_Integer);
---------
-- Old --
---------
when Attribute_Old => Old : declare
procedure Check_References_In_Prefix (Subp_Id : Entity_Id);
-- Inspect the contents of the prefix and detect illegal uses of a
-- nested 'Old, attribute 'Result or a use of an entity declared in
-- the related postcondition expression. Subp_Id is the subprogram to
-- which the related postcondition applies.
--------------------------------
-- Check_References_In_Prefix --
--------------------------------
procedure Check_References_In_Prefix (Subp_Id : Entity_Id) is
function Check_Reference (Nod : Node_Id) return Traverse_Result;
-- Detect attribute 'Old, attribute 'Result of a use of an entity
-- and perform the appropriate semantic check.
---------------------
-- Check_Reference --
---------------------
function Check_Reference (Nod : Node_Id) return Traverse_Result is
begin
-- Attributes 'Old and 'Result cannot appear in the prefix of
-- another attribute 'Old.
if Nkind (Nod) = N_Attribute_Reference
and then Attribute_Name (Nod) in Name_Old | Name_Result
then
Error_Msg_Name_1 := Attribute_Name (Nod);
Error_Msg_Name_2 := Name_Old;
Error_Msg_N
("attribute % cannot appear in the prefix of attribute %",
Nod);
return Abandon;
-- Entities mentioned within the prefix of attribute 'Old must
-- be global to the related postcondition. If this is not the
-- case, then the scope of the local entity is nested within
-- that of the subprogram.
elsif Is_Entity_Name (Nod)
and then Present (Entity (Nod))
and then Scope_Within (Scope (Entity (Nod)), Subp_Id)
then
Error_Attr
("prefix of attribute % cannot reference local entities",
Nod);
return Abandon;
-- Otherwise keep inspecting the prefix
else
return OK;
end if;
end Check_Reference;
procedure Check_References is new Traverse_Proc (Check_Reference);
-- Start of processing for Check_References_In_Prefix
begin
Check_References (P);
end Check_References_In_Prefix;
-- Local variables
Legal : Boolean;
Pref_Id : Entity_Id;
Pref_Typ : Entity_Id;
Spec_Id : Entity_Id;
-- Start of processing for Old
begin
-- The attribute reference is a primary. If any expressions follow,
-- then the attribute reference is an indexable object. Transform the
-- attribute into an indexed component and analyze it.
if Present (E1) then
Rewrite (N,
Make_Indexed_Component (Loc,
Prefix =>
Make_Attribute_Reference (Loc,
Prefix => Relocate_Node (P),
Attribute_Name => Name_Old),
Expressions => Expressions (N)));
Analyze (N);
return;
end if;
Analyze_Attribute_Old_Result (Legal, Spec_Id);
-- The aspect or pragma where attribute 'Old resides should be
-- associated with a subprogram declaration or a body. If this is not
-- the case, then the aspect or pragma is illegal. Return as analysis
-- cannot be carried out.
-- The exception to this rule is when generating C since in this case
-- postconditions are inlined.
if No (Spec_Id)
and then Modify_Tree_For_C
and then In_Inlined_Body
then
Spec_Id := Entity (P);
elsif not Legal then
return;
end if;
-- The prefix must be preanalyzed as the full analysis will take
-- place during expansion.
Preanalyze_And_Resolve (P);
-- Ensure that the prefix does not contain attributes 'Old or 'Result
Check_References_In_Prefix (Spec_Id);
-- Set the type of the attribute now to prevent cascaded errors
Pref_Typ := Etype (P);
Set_Etype (N, Pref_Typ);
-- Legality checks
if Is_Limited_Type (Pref_Typ) then
Error_Attr ("attribute % cannot apply to limited objects", P);
end if;
-- The prefix is a simple name
if Is_Entity_Name (P) and then Present (Entity (P)) then
Pref_Id := Entity (P);
-- Emit a warning when the prefix is a constant. Note that the use
-- of Error_Attr would reset the type of N to Any_Type even though
-- this is a warning. Use Error_Msg_XXX instead.
if Is_Constant_Object (Pref_Id) then
Error_Msg_Name_1 := Name_Old;
Error_Msg_N
("??attribute % applied to constant has no effect", P);
end if;
-- Otherwise the prefix is not a simple name
else
-- Ensure that the prefix of attribute 'Old is an entity when it
-- is potentially unevaluated (6.1.1 (27/3)). This rule is
-- relaxed in Ada2020 - this relaxation is reflected in the
-- call (below) to Eligible_For_Conditional_Evaluation.
if Is_Potentially_Unevaluated (N)
and then not Statically_Names_Object (P)
and then not
Old_Attr_Util.Conditional_Evaluation
.Eligible_For_Conditional_Evaluation (N)
then
Uneval_Old_Msg;
-- Detect a possible infinite recursion when the prefix denotes
-- the related function.
-- function Func (...) return ...
-- with Post => Func'Old ...;
-- The function may be specified in qualified form X.Y where X is
-- a protected object and Y is a protected function. In that case
-- ensure that the qualified form has an entity.
elsif Nkind (P) = N_Function_Call
and then Nkind (Name (P)) in N_Has_Entity
then
Pref_Id := Entity (Name (P));
if Ekind (Spec_Id) in E_Function | E_Generic_Function
and then Pref_Id = Spec_Id
then
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N ("!possible infinite recursion<<", P);
Error_Msg_N ("\!??Storage_Error ]<<", P);
end if;
end if;
-- The prefix of attribute 'Old may refer to a component of a
-- formal parameter. In this case its expansion may generate
-- actual subtypes that are referenced in an inner context and
-- that must be elaborated within the subprogram itself. If the
-- prefix includes a function call, it may involve finalization
-- actions that should be inserted when the attribute has been
-- rewritten as a declaration. Create a declaration for the prefix
-- and insert it at the start of the enclosing subprogram. This is
-- an expansion activity that has to be performed now to prevent
-- out-of-order issues.
-- This expansion is both harmful and not needed in SPARK mode,
-- since the formal verification back end relies on the types of
-- nodes (hence is not robust w.r.t. a change to base type here),
-- and does not suffer from the out-of-order issue described
-- above. Thus, this expansion is skipped in SPARK mode.
-- The expansion is not relevant for discrete types, which will
-- not generate extra declarations, and where use of the base type
-- may lead to spurious errors if context is a case.
if not GNATprove_Mode then
if not Is_Discrete_Type (Pref_Typ) then
Pref_Typ := Base_Type (Pref_Typ);
end if;
Set_Etype (N, Pref_Typ);
Set_Etype (P, Pref_Typ);
Analyze_Dimension (N);
Expand (N);
end if;
end if;
end Old;
----------------------
-- Overlaps_Storage --
----------------------
when Attribute_Overlaps_Storage =>
Check_E1;
-- Both arguments must be objects of any type
Analyze_And_Resolve (P);
Analyze_And_Resolve (E1);
Check_Object_Reference (P);
Check_Object_Reference (E1);
Set_Etype (N, Standard_Boolean);
------------
-- Output --
------------
when Attribute_Output =>
Check_E2;
Check_Stream_Attribute (TSS_Stream_Output);
Set_Etype (N, Standard_Void_Type);
Resolve (N, Standard_Void_Type);
------------------
-- Partition_ID --
------------------
when Attribute_Partition_ID =>
Check_E0;
if P_Type /= Any_Type then
if not Is_Library_Level_Entity (Entity (P)) then
Error_Attr_P
("prefix of % attribute must be library-level entity");
-- The defining entity of prefix should not be declared inside a
-- Pure unit. RM E.1(8). Is_Pure was set during declaration.
elsif Is_Entity_Name (P)
and then Is_Pure (Entity (P))
then
Error_Attr_P ("prefix of% attribute must not be declared pure");
end if;
end if;
Set_Etype (N, Universal_Integer);
-------------------------
-- Passed_By_Reference --
-------------------------
when Attribute_Passed_By_Reference =>
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, Standard_Boolean);
------------------
-- Pool_Address --
------------------
when Attribute_Pool_Address =>
Check_E0;
Set_Etype (N, RTE (RE_Address));
---------
-- Pos --
---------
when Attribute_Pos =>
Check_Discrete_Type;
Check_E1;
Resolve (E1, P_Base_Type);
Set_Etype (N, Universal_Integer);
--------------
-- Position --
--------------
when Attribute_Position =>
Check_Component;
Set_Etype (N, Universal_Integer);
----------
-- Pred --
----------
when Attribute_Pred =>
Check_Scalar_Type;
Check_E1;
Resolve (E1, P_Base_Type);
Set_Etype (N, P_Base_Type);
-- Since Pred works on the base type, we normally do no check for the
-- floating-point case, since the base type is unconstrained. But we
-- make an exception in Check_Float_Overflow mode.
if Is_Floating_Point_Type (P_Type) then
if not Range_Checks_Suppressed (P_Base_Type) then
Set_Do_Range_Check (E1);
end if;
-- If not modular type, test for overflow check required
else
if not Is_Modular_Integer_Type (P_Type)
and then not Range_Checks_Suppressed (P_Base_Type)
then
Enable_Range_Check (E1);
end if;
end if;
--------------
-- Priority --
--------------
-- Ada 2005 (AI-327): Dynamic ceiling priorities
when Attribute_Priority =>
if Ada_Version < Ada_2005 then
Error_Attr ("% attribute is allowed only in Ada 2005 mode", P);
end if;
Check_E0;
Check_Restriction (No_Dynamic_Priorities, N);
-- The prefix must be a protected object (AARM D.5.2 (2/2))
Analyze (P);
if Is_Protected_Type (Etype (P))
or else (Is_Access_Type (Etype (P))
and then Is_Protected_Type (Designated_Type (Etype (P))))
then
Resolve (P, Etype (P));
else
Error_Attr_P ("prefix of % attribute must be a protected object");
end if;
Set_Etype (N, Standard_Integer);
-- Must be called from within a protected procedure or entry of the
-- protected object.
declare
S : Entity_Id;
begin
S := Current_Scope;
while S /= Etype (P)
and then S /= Standard_Standard
loop
S := Scope (S);
end loop;
if S = Standard_Standard then
Error_Attr ("the attribute % is only allowed inside protected "
& "operations", P);
end if;
end;
Validate_Non_Static_Attribute_Function_Call;
---------------
-- Put_Image --
---------------
when Attribute_Put_Image =>
Check_E2;
Check_Put_Image_Attribute;
Set_Etype (N, Standard_Void_Type);
Resolve (N, Standard_Void_Type);
-----------
-- Range --
-----------
when Attribute_Range =>
Check_Array_Or_Scalar_Type;
Bad_Attribute_For_Predicate;
if Ada_Version = Ada_83
and then Is_Scalar_Type (P_Type)
and then Comes_From_Source (N)
then
Error_Attr
("(Ada 83) % attribute not allowed for scalar type", P);
end if;
------------
-- Result --
------------
when Attribute_Result => Result : declare
function Denote_Same_Function
(Pref_Id : Entity_Id;
Spec_Id : Entity_Id) return Boolean;
-- Determine whether the entity of the prefix Pref_Id denotes the
-- same entity as that of the related subprogram Spec_Id.
--------------------------
-- Denote_Same_Function --
--------------------------
function Denote_Same_Function
(Pref_Id : Entity_Id;
Spec_Id : Entity_Id) return Boolean
is
Over_Id : constant Entity_Id := Overridden_Operation (Spec_Id);
Subp_Spec : constant Node_Id := Parent (Spec_Id);
begin
-- The prefix denotes the related subprogram
if Pref_Id = Spec_Id then
return True;
-- Account for a special case when attribute 'Result appears in
-- the postcondition of a generic function.
-- generic
-- function Gen_Func return ...
-- with Post => Gen_Func'Result ...;
-- When the generic function is instantiated, the Chars field of
-- the instantiated prefix still denotes the name of the generic
-- function. Note that any preemptive transformation is impossible
-- without a proper analysis. The structure of the wrapper package
-- is as follows:
-- package Anon_Gen_Pack is
-- <subtypes and renamings>
-- function Subp_Decl return ...; -- (!)
-- pragma Postcondition (Gen_Func'Result ...); -- (!)
-- function Gen_Func ... renames Subp_Decl;
-- end Anon_Gen_Pack;
elsif Nkind (Subp_Spec) = N_Function_Specification
and then Present (Generic_Parent (Subp_Spec))
and then Ekind (Pref_Id) in E_Generic_Function | E_Function
then
if Generic_Parent (Subp_Spec) = Pref_Id then
return True;
elsif Present (Alias (Pref_Id))
and then Alias (Pref_Id) = Spec_Id
then
return True;
end if;
-- Account for a special case where a primitive of a tagged type
-- inherits a class-wide postcondition from a parent type. In this
-- case the prefix of attribute 'Result denotes the overriding
-- primitive.
elsif Present (Over_Id) and then Pref_Id = Over_Id then
return True;
end if;
-- Otherwise the prefix does not denote the related subprogram
return False;
end Denote_Same_Function;
-- Local variables
In_Inlined_C_Postcondition : constant Boolean :=
Modify_Tree_For_C
and then In_Inlined_Body;
Legal : Boolean;
Pref_Id : Entity_Id;
Spec_Id : Entity_Id;
-- Start of processing for Result
begin
-- The attribute reference is a primary. If any expressions follow,
-- then the attribute reference is an indexable object. Transform the
-- attribute into an indexed component and analyze it.
if Present (E1) then
Rewrite (N,
Make_Indexed_Component (Loc,
Prefix =>
Make_Attribute_Reference (Loc,
Prefix => Relocate_Node (P),
Attribute_Name => Name_Result),
Expressions => Expressions (N)));
Analyze (N);
return;
end if;
Analyze_Attribute_Old_Result (Legal, Spec_Id);
-- The aspect or pragma where attribute 'Result resides should be
-- associated with a subprogram declaration or a body. If this is not
-- the case, then the aspect or pragma is illegal. Return as analysis
-- cannot be carried out.
-- The exception to this rule is when generating C since in this case
-- postconditions are inlined.
if No (Spec_Id) and then In_Inlined_C_Postcondition then
Spec_Id := Entity (P);
elsif not Legal then
Error_Attr ("prefix of % attribute must be a function", P);
return;
end if;
-- Attribute 'Result is part of a _Postconditions procedure. There is
-- no need to perform the semantic checks below as they were already
-- verified when the attribute was analyzed in its original context.
-- Instead, rewrite the attribute as a reference to formal parameter
-- _Result of the _Postconditions procedure.
if Chars (Spec_Id) = Name_uPostconditions
or else
(In_Inlined_C_Postcondition
and then Nkind (Parent (Spec_Id)) = N_Block_Statement)
then
Rewrite (N, Make_Identifier (Loc, Name_uResult));
-- The type of formal parameter _Result is that of the function
-- encapsulating the _Postconditions procedure. Resolution must
-- be carried out against the function return type.
Analyze_And_Resolve (N, Etype (Scope (Spec_Id)));
-- Otherwise attribute 'Result appears in its original context and
-- all semantic checks should be carried out.
else
-- Verify the legality of the prefix. It must denotes the entity
-- of the related [generic] function.
if Is_Entity_Name (P) then
Pref_Id := Entity (P);
-- Either both the prefix and the annotated spec must be
-- generic functions, or they both must be nongeneric
-- functions, or the prefix must be generic and the spec
-- must be nongeneric (i.e. it must denote an instance).
if (Ekind (Pref_Id) in E_Function | E_Generic_Function
and then Ekind (Pref_Id) = Ekind (Spec_Id))
or else
(Ekind (Pref_Id) = E_Generic_Function
and then Ekind (Spec_Id) = E_Function)
then
if Denote_Same_Function (Pref_Id, Spec_Id) then
-- Correct the prefix of the attribute when the context
-- is a generic function.
if Pref_Id /= Spec_Id then
Rewrite (P, New_Occurrence_Of (Spec_Id, Loc));
Analyze (P);
end if;
Set_Etype (N, Etype (Spec_Id));
-- Otherwise the prefix denotes some unrelated function
else
Error_Msg_Name_2 := Chars (Spec_Id);
Error_Attr
("incorrect prefix for attribute %, expected %", P);
end if;
-- Otherwise the prefix denotes some other form of subprogram
-- entity.
else
Error_Attr
("attribute % can only appear in postcondition of "
& "function", P);
end if;
-- Otherwise the prefix is illegal
else
Error_Msg_Name_2 := Chars (Spec_Id);
Error_Attr ("incorrect prefix for attribute %, expected %", P);
end if;
end if;
end Result;
------------------
-- Range_Length --
------------------
when Attribute_Range_Length =>
Check_E0;
Check_Discrete_Type;
Set_Etype (N, Universal_Integer);
------------
-- Reduce --
------------
when Attribute_Reduce =>
Check_E2;
if not Extensions_Allowed then
Error_Attr
("% attribute only supported under -gnatX", P);
end if;
declare
Stream : constant Node_Id := Prefix (N);
Typ : Entity_Id;
begin
if Nkind (Stream) /= N_Aggregate then
-- Prefix is a name, as for other attributes.
-- If the object is a function we asume that it is not
-- overloaded. AI12-242 does not suggest a name resolution
-- rule for that case, but we can suppose that the expected
-- type of the reduction is the expected type of the component
-- of the prefix.
Analyze_And_Resolve (Stream);
Typ := Etype (Stream);
-- Verify that prefix can be iterated upon.
if Is_Array_Type (Typ)
or else Present (Find_Aspect (Typ, Aspect_Default_Iterator))
or else Present (Find_Aspect (Typ, Aspect_Iterable))
then
null;
else
Error_Msg_NE
("cannot apply reduce to object of type$", N, Typ);
end if;
elsif Present (Expressions (Stream))
or else No (Component_Associations (Stream))
or else Nkind (First (Component_Associations (Stream))) /=
N_Iterated_Component_Association
then
Error_Msg_N
("Prefix of reduce must be an iterated component", N);
end if;
Analyze (E1);
Analyze (E2);
Set_Etype (N, Etype (E2));
end;
----------
-- Read --
----------
when Attribute_Read =>
Check_E2;
Check_Stream_Attribute (TSS_Stream_Read);
Set_Etype (N, Standard_Void_Type);
Resolve (N, Standard_Void_Type);
Note_Possible_Modification (E2, Sure => True);
---------
-- Ref --
---------
when Attribute_Ref =>
Check_E1;
Analyze (P);
if Nkind (P) /= N_Expanded_Name
or else not Is_RTE (P_Type, RE_Address)
then
Error_Attr_P ("prefix of % attribute must be System.Address");
end if;
Analyze_And_Resolve (E1, Any_Integer);
Set_Etype (N, RTE (RE_Address));
---------------
-- Remainder --
---------------
when Attribute_Remainder =>
Check_Floating_Point_Type_2;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
Resolve (E2, P_Base_Type);
---------------------
-- Restriction_Set --
---------------------
when Attribute_Restriction_Set => Restriction_Set : declare
R : Restriction_Id;
U : Node_Id;
Unam : Unit_Name_Type;
begin
Check_E1;
Analyze (P);
Check_System_Prefix;
-- No_Dependence case
if Nkind (E1) = N_Parameter_Association then
pragma Assert (Chars (Selector_Name (E1)) = Name_No_Dependence);
U := Explicit_Actual_Parameter (E1);
if not OK_No_Dependence_Unit_Name (U) then
Set_Boolean_Result (N, False);
Error_Attr;
end if;
-- See if there is an entry already in the table. That's the
-- case in which we can return True.
for J in No_Dependences.First .. No_Dependences.Last loop
if Designate_Same_Unit (U, No_Dependences.Table (J).Unit)
and then No_Dependences.Table (J).Warn = False
then
Set_Boolean_Result (N, True);
return;
end if;
end loop;
-- If not in the No_Dependence table, result is False
Set_Boolean_Result (N, False);
-- In this case, we must ensure that the binder will reject any
-- other unit in the partition that sets No_Dependence for this
-- unit. We do that by making an entry in the special table kept
-- for this purpose (if the entry is not there already).
Unam := Get_Spec_Name (Get_Unit_Name (U));
for J in Restriction_Set_Dependences.First ..
Restriction_Set_Dependences.Last
loop
if Restriction_Set_Dependences.Table (J) = Unam then
return;
end if;
end loop;
Restriction_Set_Dependences.Append (Unam);
-- Normal restriction case
else
if Nkind (E1) /= N_Identifier then
Set_Boolean_Result (N, False);
Error_Attr ("attribute % requires restriction identifier", E1);
else
R := Get_Restriction_Id (Process_Restriction_Synonyms (E1));
if R = Not_A_Restriction_Id then
Set_Boolean_Result (N, False);
Error_Msg_Node_1 := E1;
Error_Attr ("invalid restriction identifier &", E1);
elsif R not in Partition_Boolean_Restrictions then
Set_Boolean_Result (N, False);
Error_Msg_Node_1 := E1;
Error_Attr
("& is not a boolean partition-wide restriction", E1);
end if;
if Restriction_Active (R) then
Set_Boolean_Result (N, True);
else
Check_Restriction (R, N);
Set_Boolean_Result (N, False);
end if;
end if;
end if;
end Restriction_Set;
-----------
-- Round --
-----------
when Attribute_Round =>
Check_E1;
Check_Decimal_Fixed_Point_Type;
Set_Etype (N, P_Base_Type);
-- Because the context is universal_real (3.5.10(12)) it is a
-- legal context for a universal fixed expression. This is the
-- only attribute whose functional description involves U_R.
if Etype (E1) = Universal_Fixed then
declare
Conv : constant Node_Id := Make_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (Universal_Real, Loc),
Expression => Relocate_Node (E1));
begin
Rewrite (E1, Conv);
Analyze (E1);
end;
end if;
Resolve (E1, Any_Real);
--------------
-- Rounding --
--------------
when Attribute_Rounding =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
---------------
-- Safe_Emax --
---------------
when Attribute_Safe_Emax =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Integer);
----------------
-- Safe_First --
----------------
when Attribute_Safe_First =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Real);
----------------
-- Safe_Large --
----------------
when Attribute_Safe_Large =>
Check_E0;
Check_Real_Type;
Set_Etype (N, Universal_Real);
---------------
-- Safe_Last --
---------------
when Attribute_Safe_Last =>
Check_Floating_Point_Type_0;
Set_Etype (N, Universal_Real);
----------------
-- Safe_Small --
----------------
when Attribute_Safe_Small =>
Check_E0;
Check_Real_Type;
Set_Etype (N, Universal_Real);
--------------------------
-- Scalar_Storage_Order --
--------------------------
when Attribute_Scalar_Storage_Order => Scalar_Storage_Order : declare
Ent : Entity_Id := Empty;
begin
Check_E0;
Check_Type;
if not (Is_Record_Type (P_Type) or else Is_Array_Type (P_Type)) then
-- The attribute applies to generic private types (in which case
-- the legality rule is applied in the instance) as well as to
-- composite types. For noncomposite types it always returns the
-- default bit order for the target.
-- Allowing formal private types was originally introduced in
-- GNAT_Mode only, to compile instances of Sequential_IO, but
-- users find it more generally useful in generic units.
if not (Is_Generic_Type (P_Type) and then Is_Private_Type (P_Type))
and then not In_Instance
then
Error_Attr_P
("prefix of % attribute must be record or array type");
elsif not Is_Generic_Type (P_Type) then
if Bytes_Big_Endian then
Ent := RTE (RE_High_Order_First);
else
Ent := RTE (RE_Low_Order_First);
end if;
end if;
elsif Bytes_Big_Endian xor Reverse_Storage_Order (P_Type) then
Ent := RTE (RE_High_Order_First);
else
Ent := RTE (RE_Low_Order_First);
end if;
if Present (Ent) then
Rewrite (N, New_Occurrence_Of (Ent, Loc));
end if;
Set_Etype (N, RTE (RE_Bit_Order));
Resolve (N);
-- Reset incorrect indication of staticness
Set_Is_Static_Expression (N, False);
end Scalar_Storage_Order;
-----------
-- Scale --
-----------
when Attribute_Scale =>
Check_E0;
Check_Decimal_Fixed_Point_Type;
Set_Etype (N, Universal_Integer);
-------------
-- Scaling --
-------------
when Attribute_Scaling =>
Check_Floating_Point_Type_2;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
------------------
-- Signed_Zeros --
------------------
when Attribute_Signed_Zeros =>
Check_Floating_Point_Type_0;
Set_Etype (N, Standard_Boolean);
----------
-- Size --
----------
when Attribute_Size
| Attribute_VADS_Size
=>
Check_E0;
-- If prefix is parameterless function call, rewrite and resolve
-- as such.
if Is_Entity_Name (P)
and then Ekind (Entity (P)) = E_Function
then
Resolve (P);
-- Similar processing for a protected function call
elsif Nkind (P) = N_Selected_Component
and then Ekind (Entity (Selector_Name (P))) = E_Function
then
Resolve (P);
end if;
if Is_Object_Reference (P) then
Check_Object_Reference (P);
elsif Is_Entity_Name (P)
and then (Is_Type (Entity (P))
or else Ekind (Entity (P)) = E_Enumeration_Literal)
then
null;
elsif Nkind (P) = N_Type_Conversion
and then not Comes_From_Source (P)
then
null;
-- Some other compilers allow dubious use of X'???'Size
elsif Relaxed_RM_Semantics
and then Nkind (P) = N_Attribute_Reference
then
null;
else
Error_Attr_P ("invalid prefix for % attribute");
end if;
Check_Not_Incomplete_Type;
Check_Not_CPP_Type;
Set_Etype (N, Universal_Integer);
-- If we are processing pragmas Compile_Time_Warning and Compile_
-- Time_Errors after the back end has been called and this occurrence
-- of 'Size is known at compile time then it is safe to perform this
-- evaluation. Needed to perform the static evaluation of the full
-- boolean expression of these pragmas. Note that Known_RM_Size is
-- sometimes True when Size_Known_At_Compile_Time is False, when the
-- back end has computed it.
if In_Compile_Time_Warning_Or_Error
and then Is_Entity_Name (P)
and then (Is_Type (Entity (P))
or else Ekind (Entity (P)) = E_Enumeration_Literal)
and then (Known_RM_Size (Entity (P))
or else Size_Known_At_Compile_Time (Entity (P)))
then
declare
Siz : Uint;
begin
if Known_Static_RM_Size (Entity (P)) then
Siz := RM_Size (Entity (P));
else
Siz := Esize (Entity (P));
end if;
Rewrite (N, Make_Integer_Literal (Sloc (N), Siz));
Analyze (N);
end;
end if;
-----------
-- Small --
-----------
when Attribute_Small =>
Check_E0;
Check_Real_Type;
Set_Etype (N, Universal_Real);
------------------
-- Storage_Pool --
------------------
when Attribute_Storage_Pool
| Attribute_Simple_Storage_Pool
=>
Check_E0;
if Is_Access_Type (P_Type) then
if Ekind (P_Type) = E_Access_Subprogram_Type then
Error_Attr_P
("cannot use % attribute for access-to-subprogram type");
end if;
-- Set appropriate entity
if Present (Associated_Storage_Pool (Root_Type (P_Type))) then
Set_Entity (N, Associated_Storage_Pool (Root_Type (P_Type)));
else
Set_Entity (N, RTE (RE_Global_Pool_Object));
end if;
if Attr_Id = Attribute_Storage_Pool then
if Present (Get_Rep_Pragma (Etype (Entity (N)),
Name_Simple_Storage_Pool_Type))
then
Error_Msg_Name_1 := Aname;
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_N
("cannot use % attribute for type with simple storage "
& "pool<<", N);
Error_Msg_N ("\Program_Error [<<", N);
Rewrite
(N, Make_Raise_Program_Error
(Sloc (N), Reason => PE_Explicit_Raise));
end if;
Set_Etype (N, Class_Wide_Type (RTE (RE_Root_Storage_Pool)));
-- In the Simple_Storage_Pool case, verify that the pool entity is
-- actually of a simple storage pool type, and set the attribute's
-- type to the pool object's type.
else
if not Present (Get_Rep_Pragma (Etype (Entity (N)),
Name_Simple_Storage_Pool_Type))
then
Error_Attr_P
("cannot use % attribute for type without simple " &
"storage pool");
end if;
Set_Etype (N, Etype (Entity (N)));
end if;
-- Validate_Remote_Access_To_Class_Wide_Type for attribute
-- Storage_Pool since this attribute is not defined for such
-- types (RM E.2.2(17)).
Validate_Remote_Access_To_Class_Wide_Type (N);
else
Error_Attr_P ("prefix of % attribute must be access type");
end if;
------------------
-- Storage_Size --
------------------
when Attribute_Storage_Size =>
Check_E0;
if Is_Task_Type (P_Type) then
Set_Etype (N, Universal_Integer);
-- Use with tasks is an obsolescent feature
Check_Restriction (No_Obsolescent_Features, P);
elsif Is_Access_Type (P_Type) then
if Ekind (P_Type) = E_Access_Subprogram_Type then
Error_Attr_P
("cannot use % attribute for access-to-subprogram type");
end if;
if Is_Entity_Name (P)
and then Is_Type (Entity (P))
then
Check_Type;
Set_Etype (N, Universal_Integer);
-- Validate_Remote_Access_To_Class_Wide_Type for attribute
-- Storage_Size since this attribute is not defined for
-- such types (RM E.2.2(17)).
Validate_Remote_Access_To_Class_Wide_Type (N);
-- The prefix is allowed to be an implicit dereference of an
-- access value designating a task.
else
Check_Task_Prefix;
Set_Etype (N, Universal_Integer);
end if;
else
Error_Attr_P ("prefix of % attribute must be access or task type");
end if;
------------------
-- Storage_Unit --
------------------
when Attribute_Storage_Unit =>
Standard_Attribute (Ttypes.System_Storage_Unit);
-----------------
-- Stream_Size --
-----------------
when Attribute_Stream_Size =>
Check_E0;
Check_Type;
if Is_Entity_Name (P)
and then Is_Elementary_Type (Entity (P))
then
Set_Etype (N, Universal_Integer);
else
Error_Attr_P ("invalid prefix for % attribute");
end if;
---------------
-- Stub_Type --
---------------
when Attribute_Stub_Type =>
Check_Type;
Check_E0;
if Is_Remote_Access_To_Class_Wide_Type (Base_Type (P_Type)) then
-- For a real RACW [sub]type, use corresponding stub type
if not Is_Generic_Type (P_Type) then
Rewrite (N,
New_Occurrence_Of
(Corresponding_Stub_Type (Base_Type (P_Type)), Loc));
-- For a generic type (that has been marked as an RACW using the
-- Remote_Access_Type aspect or pragma), use a generic RACW stub
-- type. Note that if the actual is not a remote access type, the
-- instantiation will fail.
else
-- Note: we go to the underlying type here because the view
-- returned by RTE (RE_RACW_Stub_Type) might be incomplete.
Rewrite (N,
New_Occurrence_Of
(Underlying_Type (RTE (RE_RACW_Stub_Type)), Loc));
end if;
else
Error_Attr_P
("prefix of% attribute must be remote access-to-class-wide");
end if;
----------
-- Succ --
----------
when Attribute_Succ =>
Check_Scalar_Type;
Check_E1;
Resolve (E1, P_Base_Type);
Set_Etype (N, P_Base_Type);
-- Since Pred works on the base type, we normally do no check for the
-- floating-point case, since the base type is unconstrained. But we
-- make an exception in Check_Float_Overflow mode.
if Is_Floating_Point_Type (P_Type) then
if not Range_Checks_Suppressed (P_Base_Type) then
Set_Do_Range_Check (E1);
end if;
-- If not modular type, test for overflow check required
else
if not Is_Modular_Integer_Type (P_Type)
and then not Range_Checks_Suppressed (P_Base_Type)
then
Enable_Range_Check (E1);
end if;
end if;
--------------------------------
-- System_Allocator_Alignment --
--------------------------------
when Attribute_System_Allocator_Alignment =>
Standard_Attribute (Ttypes.System_Allocator_Alignment);
---------
-- Tag --
---------
when Attribute_Tag =>
Check_E0;
Check_Dereference;
if not Is_Tagged_Type (P_Type) then
Error_Attr_P ("prefix of % attribute must be tagged");
-- Next test does not apply to generated code why not, and what does
-- the illegal reference mean???
elsif Is_Object_Reference (P)
and then not Is_Class_Wide_Type (P_Type)
and then Comes_From_Source (N)
then
Error_Attr_P
("% attribute can only be applied to objects " &
"of class - wide type");
end if;
-- The prefix cannot be an incomplete type. However, references to
-- 'Tag can be generated when expanding interface conversions, and
-- this is legal.
if Comes_From_Source (N) then
Check_Not_Incomplete_Type;
end if;
-- Set appropriate type
Set_Etype (N, RTE (RE_Tag));
-----------------
-- Target_Name --
-----------------
when Attribute_Target_Name => Target_Name : declare
TN : constant String := Sdefault.Target_Name.all;
TL : Natural;
begin
Check_Standard_Prefix;
TL := TN'Last;
if TN (TL) = '/' or else TN (TL) = '\' then
TL := TL - 1;
end if;
Rewrite (N,
Make_String_Literal (Loc,
Strval => TN (TN'First .. TL)));
Analyze_And_Resolve (N, Standard_String);
Set_Is_Static_Expression (N, True);
end Target_Name;
----------------
-- Terminated --
----------------
when Attribute_Terminated =>
Check_E0;
Set_Etype (N, Standard_Boolean);
Check_Task_Prefix;
----------------
-- To_Address --
----------------
when Attribute_To_Address => To_Address : declare
Val : Uint;
begin
Check_E1;
Analyze (P);
Check_System_Prefix;
Generate_Reference (RTE (RE_Address), P);
Analyze_And_Resolve (E1, Any_Integer);
Set_Etype (N, RTE (RE_Address));
Set_Is_Static_Expression (N, Is_Static_Expression (E1));
-- OK static expression case, check range and set appropriate type
if Is_OK_Static_Expression (E1) then
Val := Expr_Value (E1);
if Val < -(Uint_2 ** (System_Address_Size - 1))
or else
Val > Uint_2 ** System_Address_Size - 1
then
Error_Attr ("address value out of range for % attribute", E1);
end if;
-- In most cases the expression is a numeric literal or some other
-- address expression, but if it is a declared constant it may be
-- of a compatible type that must be left on the node.
if Is_Entity_Name (E1) then
null;
-- Set type to universal integer if negative
elsif Val < 0 then
Set_Etype (E1, Universal_Integer);
-- Otherwise set type to Unsigned_64 to accommodate large values
else
Set_Etype (E1, Standard_Unsigned_64);
end if;
end if;
end To_Address;
------------
-- To_Any --
------------
when Attribute_To_Any =>
Check_E1;
Check_PolyORB_Attribute;
Set_Etype (N, RTE (RE_Any));
----------------
-- Truncation --
----------------
when Attribute_Truncation =>
Check_Floating_Point_Type_1;
Resolve (E1, P_Base_Type);
Set_Etype (N, P_Base_Type);
----------------
-- Type_Class --
----------------
when Attribute_Type_Class =>
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, RTE (RE_Type_Class));
--------------
-- TypeCode --
--------------
when Attribute_TypeCode =>
Check_E0;
Check_PolyORB_Attribute;
Set_Etype (N, RTE (RE_TypeCode));
--------------
-- Type_Key --
--------------
when Attribute_Type_Key => Type_Key : declare
Full_Name : constant String_Id :=
Fully_Qualified_Name_String (Entity (P));
CRC : CRC32;
-- The computed signature for the type
Deref : Boolean;
-- To simplify the handling of mutually recursive types, follow a
-- single dereference link in a composite type.
procedure Compute_Type_Key (T : Entity_Id);
-- Create a CRC integer from the declaration of the type. For a
-- composite type, fold in the representation of its components in
-- recursive fashion. We use directly the source representation of
-- the types involved.
----------------------
-- Compute_Type_Key --
----------------------
procedure Compute_Type_Key (T : Entity_Id) is
Buffer : Source_Buffer_Ptr;
P_Max : Source_Ptr;
P_Min : Source_Ptr;
Rep : Node_Id;
SFI : Source_File_Index;
procedure Process_One_Declaration;
-- Update CRC with the characters of one type declaration, or a
-- representation pragma that applies to the type.
-----------------------------
-- Process_One_Declaration --
-----------------------------
procedure Process_One_Declaration is
begin
-- Scan type declaration, skipping blanks
for Ptr in P_Min .. P_Max loop
if Buffer (Ptr) /= ' ' then
System.CRC32.Update (CRC, Buffer (Ptr));
end if;
end loop;
end Process_One_Declaration;
-- Start of processing for Compute_Type_Key
begin
if Is_Itype (T) then
return;
end if;
-- If the type is declared in Standard, there is no source, so
-- just use its name.
if Scope (T) = Standard_Standard then
declare
Name : constant String := Get_Name_String (Chars (T));
begin
for J in Name'Range loop
System.CRC32.Update (CRC, Name (J));
end loop;
end;
return;
end if;
Sloc_Range (Enclosing_Declaration (T), P_Min, P_Max);
SFI := Get_Source_File_Index (P_Min);
pragma Assert (SFI = Get_Source_File_Index (P_Max));
Buffer := Source_Text (SFI);
Process_One_Declaration;
-- Recurse on relevant component types
if Is_Array_Type (T) then
Compute_Type_Key (Component_Type (T));
elsif Is_Access_Type (T) then
if not Deref then
Deref := True;
Compute_Type_Key (Designated_Type (T));
end if;
elsif Is_Derived_Type (T) then
Compute_Type_Key (Etype (T));
elsif Is_Record_Type (T) then
declare
Comp : Entity_Id;
begin
Comp := First_Component (T);
while Present (Comp) loop
Compute_Type_Key (Etype (Comp));
Next_Component (Comp);
end loop;
end;
end if;
if Is_First_Subtype (T) then
-- Fold in representation aspects for the type, which appear in
-- the same source buffer. If the representation aspects are in
-- a different source file, then skip them; they apply to some
-- other type, perhaps one we're derived from.
Rep := First_Rep_Item (T);
while Present (Rep) loop
if Comes_From_Source (Rep) then
Sloc_Range (Rep, P_Min, P_Max);
if SFI = Get_Source_File_Index (P_Min) then
pragma Assert (SFI = Get_Source_File_Index (P_Max));
Process_One_Declaration;
end if;
end if;
Next_Rep_Item (Rep);
end loop;
end if;
end Compute_Type_Key;
-- Start of processing for Type_Key
begin
Check_E0;
Check_Type;
Start_String;
Deref := False;
-- Copy all characters in Full_Name but the trailing NUL
for J in 1 .. String_Length (Full_Name) - 1 loop
Store_String_Char (Get_String_Char (Full_Name, Pos (J)));
end loop;
-- Compute CRC and convert it to string one character at a time, so
-- as not to use Image within the compiler.
Initialize (CRC);
Compute_Type_Key (Entity (P));
if not Is_Frozen (Entity (P)) then
Error_Msg_N ("premature usage of Type_Key?", N);
end if;
while CRC > 0 loop
Store_String_Char (Character'Val (48 + (CRC rem 10)));
CRC := CRC / 10;
end loop;
Rewrite (N, Make_String_Literal (Loc, End_String));
Analyze_And_Resolve (N, Standard_String);
end Type_Key;
-----------------------
-- Unbiased_Rounding --
-----------------------
when Attribute_Unbiased_Rounding =>
Check_Floating_Point_Type_1;
Set_Etype (N, P_Base_Type);
Resolve (E1, P_Base_Type);
----------------------
-- Unchecked_Access --
----------------------
when Attribute_Unchecked_Access =>
if Comes_From_Source (N) then
Check_Restriction (No_Unchecked_Access, N);
end if;
Analyze_Access_Attribute;
Check_Not_Incomplete_Type;
-------------------------
-- Unconstrained_Array --
-------------------------
when Attribute_Unconstrained_Array =>
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, Standard_Boolean);
Set_Is_Static_Expression (N, True);
------------------------------
-- Universal_Literal_String --
------------------------------
-- This is a GNAT specific attribute whose prefix must be a named
-- number where the expression is either a single numeric literal,
-- or a numeric literal immediately preceded by a minus sign. The
-- result is equivalent to a string literal containing the text of
-- the literal as it appeared in the source program with a possible
-- leading minus sign.
when Attribute_Universal_Literal_String =>
Check_E0;
if not Is_Entity_Name (P)
or else Ekind (Entity (P)) not in Named_Kind
then
Error_Attr_P ("prefix for % attribute must be named number");
else
declare
Expr : Node_Id;
Negative : Boolean;
S : Source_Ptr;
Src : Source_Buffer_Ptr;
begin
Expr := Original_Node (Expression (Parent (Entity (P))));
if Nkind (Expr) = N_Op_Minus then
Negative := True;
Expr := Original_Node (Right_Opnd (Expr));
else
Negative := False;
end if;
if Nkind (Expr) not in N_Integer_Literal | N_Real_Literal then
Error_Attr
("named number for % attribute must be simple literal", N);
end if;
-- Build string literal corresponding to source literal text
Start_String;
if Negative then
Store_String_Char (Get_Char_Code ('-'));
end if;
S := Sloc (Expr);
Src := Source_Text (Get_Source_File_Index (S));
while Src (S) /= ';' and then Src (S) /= ' ' loop
Store_String_Char (Get_Char_Code (Src (S)));
S := S + 1;
end loop;
-- Now we rewrite the attribute with the string literal
Rewrite (N,
Make_String_Literal (Loc, End_String));
Analyze (N);
Set_Is_Static_Expression (N, True);
end;
end if;
-------------------------
-- Unrestricted_Access --
-------------------------
-- This is a GNAT specific attribute which is like Access except that
-- all scope checks and checks for aliased views are omitted. It is
-- documented as being equivalent to the use of the Address attribute
-- followed by an unchecked conversion to the target access type.
when Attribute_Unrestricted_Access =>
-- If from source, deal with relevant restrictions
if Comes_From_Source (N) then
Check_Restriction (No_Unchecked_Access, N);
if Nkind (P) in N_Has_Entity
and then Present (Entity (P))
and then Is_Object (Entity (P))
then
Check_Restriction (No_Implicit_Aliasing, N);
end if;
end if;
if Is_Entity_Name (P) then
Set_Address_Taken (Entity (P));
end if;
-- It might seem reasonable to call Address_Checks here to apply the
-- same set of semantic checks that we enforce for 'Address (after
-- all we document Unrestricted_Access as being equivalent to the
-- use of Address followed by an Unchecked_Conversion). However, if
-- we do enable these checks, we get multiple failures in both the
-- compiler run-time and in our regression test suite, so we leave
-- out these checks for now. To be investigated further some time???
-- Address_Checks;
-- Now complete analysis using common access processing
Analyze_Access_Attribute;
------------
-- Update --
------------
when Attribute_Update => Update : declare
Common_Typ : Entity_Id;
-- The common type of a multiple component update for a record
Comps : Elist_Id := No_Elist;
-- A list used in the resolution of a record update. It contains the
-- entities of all record components processed so far.
procedure Analyze_Array_Component_Update (Assoc : Node_Id);
-- Analyze and resolve array_component_association Assoc against the
-- index of array type P_Type.
procedure Analyze_Record_Component_Update (Comp : Node_Id);
-- Analyze and resolve record_component_association Comp against
-- record type P_Type.
------------------------------------
-- Analyze_Array_Component_Update --
------------------------------------
procedure Analyze_Array_Component_Update (Assoc : Node_Id) is
Expr : Node_Id;
High : Node_Id;
Index : Node_Id;
Index_Typ : Entity_Id;
Low : Node_Id;
begin
-- The current association contains a sequence of indexes denoting
-- an element of a multidimensional array:
-- (Index_1, ..., Index_N)
-- Examine each individual index and resolve it against the proper
-- index type of the array.
if Nkind (First (Choices (Assoc))) = N_Aggregate then
Expr := First (Choices (Assoc));
while Present (Expr) loop
-- The use of others is illegal (SPARK RM 4.4.1(12))
if Nkind (Expr) = N_Others_Choice then
Error_Attr
("others choice not allowed in attribute %", Expr);
-- Otherwise analyze and resolve all indexes
else
Index := First (Expressions (Expr));
Index_Typ := First_Index (P_Type);
while Present (Index) and then Present (Index_Typ) loop
Analyze_And_Resolve (Index, Etype (Index_Typ));
Next (Index);
Next_Index (Index_Typ);
end loop;
-- Detect a case where the association either lacks an
-- index or contains an extra index.
if Present (Index) or else Present (Index_Typ) then
Error_Msg_N
("dimension mismatch in index list", Assoc);
end if;
end if;
Next (Expr);
end loop;
-- The current association denotes either a single component or a
-- range of components of a one dimensional array:
-- 1, 2 .. 5
-- Resolve the index or its high and low bounds (if range) against
-- the proper index type of the array.
else
Index := First (Choices (Assoc));
Index_Typ := First_Index (P_Type);
if Present (Next_Index (Index_Typ)) then
Error_Msg_N ("too few subscripts in array reference", Assoc);
end if;
while Present (Index) loop
-- The use of others is illegal (SPARK RM 4.4.1(12))
if Nkind (Index) = N_Others_Choice then
Error_Attr
("others choice not allowed in attribute %", Index);
-- The index denotes a range of elements
elsif Nkind (Index) = N_Range then
Low := Low_Bound (Index);
High := High_Bound (Index);
Analyze_And_Resolve (Low, Etype (Index_Typ));
Analyze_And_Resolve (High, Etype (Index_Typ));
-- Otherwise the index denotes a single element
else
Analyze_And_Resolve (Index, Etype (Index_Typ));
end if;
Next (Index);
end loop;
end if;
end Analyze_Array_Component_Update;
-------------------------------------
-- Analyze_Record_Component_Update --
-------------------------------------
procedure Analyze_Record_Component_Update (Comp : Node_Id) is
Comp_Name : constant Name_Id := Chars (Comp);
Base_Typ : Entity_Id;
Comp_Or_Discr : Entity_Id;
begin
-- Find the discriminant or component whose name corresponds to
-- Comp. A simple character comparison is sufficient because all
-- visible names within a record type are unique.
Comp_Or_Discr := First_Entity (P_Type);
while Present (Comp_Or_Discr) loop
if Chars (Comp_Or_Discr) = Comp_Name then
-- Decorate the component reference by setting its entity
-- and type for resolution purposes.
Set_Entity (Comp, Comp_Or_Discr);
Set_Etype (Comp, Etype (Comp_Or_Discr));
exit;
end if;
Next_Entity (Comp_Or_Discr);
end loop;
-- Diagnose an illegal reference
if Present (Comp_Or_Discr) then
if Ekind (Comp_Or_Discr) = E_Discriminant then
Error_Attr
("attribute % may not modify record discriminants", Comp);
else pragma Assert (Ekind (Comp_Or_Discr) = E_Component);
if Contains (Comps, Comp_Or_Discr) then
Error_Msg_N ("component & already updated", Comp);
-- Mark this component as processed
else
Append_New_Elmt (Comp_Or_Discr, Comps);
end if;
end if;
-- The update aggregate mentions an entity that does not belong to
-- the record type.
else
Error_Msg_N ("& is not a component of aggregate subtype", Comp);
end if;
-- Verify the consistency of types when the current component is
-- part of a multiple component update.
-- Comp_1 | ... | Comp_N => <value>
if Present (Etype (Comp)) then
Base_Typ := Base_Type (Etype (Comp));
-- Save the type of the first component reference as the
-- remaning references (if any) must resolve to this type.
if No (Common_Typ) then
Common_Typ := Base_Typ;
elsif Base_Typ /= Common_Typ then
Error_Msg_N
("components in choice list must have same type", Comp);
end if;
end if;
end Analyze_Record_Component_Update;
-- Local variables
Assoc : Node_Id;
Comp : Node_Id;
-- Start of processing for Update
begin
if Warn_On_Obsolescent_Feature then
Error_Msg_N ("?j?attribute Update is an obsolescent feature", N);
Error_Msg_N ("\?j?use a delta aggregate instead", N);
end if;
Check_E1;
if not Is_Object_Reference (P) then
Error_Attr_P ("prefix of attribute % must denote an object");
elsif not Is_Array_Type (P_Type)
and then not Is_Record_Type (P_Type)
then
Error_Attr_P ("prefix of attribute % must be a record or array");
elsif Is_Limited_View (P_Type) then
Error_Attr ("prefix of attribute % cannot be limited", N);
elsif Nkind (E1) /= N_Aggregate then
Error_Attr ("attribute % requires component association list", N);
elsif Present (Expressions (E1)) then
Error_Attr ("attribute % requires named component associations",
First (Expressions (E1)));
end if;
-- Inspect the update aggregate, looking at all the associations and
-- choices. Perform the following checks:
-- 1) Legality of "others" in all cases
-- 2) Legality of <>
-- 3) Component legality for arrays
-- 4) Component legality for records
-- The remaining checks are performed on the expanded attribute
Assoc := First (Component_Associations (E1));
while Present (Assoc) loop
-- The use of <> is illegal (SPARK RM 4.4.1(1))
if Box_Present (Assoc) then
Error_Attr
("default initialization not allowed in attribute %", Assoc);
-- Otherwise process the association
else
Analyze (Expression (Assoc));
if Is_Array_Type (P_Type) then
Analyze_Array_Component_Update (Assoc);
elsif Is_Record_Type (P_Type) then
-- Reset the common type used in a multiple component update
-- as we are processing the contents of a new association.
Common_Typ := Empty;
Comp := First (Choices (Assoc));
while Present (Comp) loop
if Nkind (Comp) = N_Identifier then
Analyze_Record_Component_Update (Comp);
-- The use of others is illegal (SPARK RM 4.4.1(5))
elsif Nkind (Comp) = N_Others_Choice then
Error_Attr
("others choice not allowed in attribute %", Comp);
-- The name of a record component cannot appear in any
-- other form.
else
Error_Msg_N
("name should be identifier or OTHERS", Comp);
end if;
Next (Comp);
end loop;
end if;
end if;
Next (Assoc);
end loop;
-- The type of attribute 'Update is that of the prefix
Set_Etype (N, P_Type);
Sem_Warn.Warn_On_Suspicious_Update (N);
end Update;
---------
-- Val --
---------
when Attribute_Val =>
Check_E1;
Check_Discrete_Type;
-- Note, we need a range check in general, but we wait for the
-- Resolve call to do this, since we want to let Eval_Attribute
-- have a chance to find an static illegality first.
Resolve (E1, Any_Integer);
Set_Etype (N, P_Base_Type);
-----------
-- Valid --
-----------
when Attribute_Valid => Valid : declare
Pred_Func : constant Entity_Id := Predicate_Function (P_Type);
begin
Check_E0;
-- Ignore check for object if we have a 'Valid reference generated
-- by the expanded code, since in some cases valid checks can occur
-- on items that are names, but are not objects (e.g. attributes).
if Comes_From_Source (N) then
Check_Object_Reference (P);
if not Is_Scalar_Type (P_Type) then
Error_Attr_P ("object for % attribute must be of scalar type");
end if;
-- If the attribute appears within the subtype's own predicate
-- function, then issue a warning that this will cause infinite
-- recursion.
if Present (Pred_Func) and then Current_Scope = Pred_Func then
Error_Msg_N ("attribute Valid requires a predicate check??", N);
Error_Msg_N ("\and will result in infinite recursion??", N);
end if;
end if;
Set_Etype (N, Standard_Boolean);
end Valid;
-------------------
-- Valid_Scalars --
-------------------
when Attribute_Valid_Scalars => Valid_Scalars : declare
begin
Check_E0;
if Comes_From_Source (N) then
Check_Object_Reference (P);
-- Do not emit any diagnostics related to private types to avoid
-- disclosing the structure of the type.
if Is_Private_Type (P_Type) then
-- Attribute 'Valid_Scalars is not supported on private tagged
-- types due to a code generation issue. Is_Visible_Component
-- does not allow for a component of a private tagged type to
-- be successfully retrieved.
-- ??? This attribute should simply ignore type privacy
-- (see Validated_View). It should examine components of the
-- tagged type extensions (if any) and recursively examine
-- 'Valid_Scalars of the parent's type (if any).
-- Do not use Error_Attr_P because this bypasses any subsequent
-- processing and leaves the attribute with type Any_Type. This
-- in turn prevents the proper expansion of the attribute into
-- True.
if Is_Tagged_Type (P_Type) then
Error_Msg_Name_1 := Aname;
Error_Msg_N ("??effects of attribute % are ignored", N);
end if;
-- Otherwise the type is not private
else
if not Scalar_Part_Present (P_Type) then
Error_Msg_Name_1 := Aname;
Error_Msg_F
("??attribute % always True, no scalars to check", P);
Set_Boolean_Result (N, True);
end if;
-- Attribute 'Valid_Scalars is illegal on unchecked union types
-- because it is not always guaranteed that the components are
-- retrievable based on whether the discriminants are inferable
if Has_Unchecked_Union (P_Type) then
Error_Attr_P
("attribute % not allowed for Unchecked_Union type");
end if;
end if;
end if;
Set_Etype (N, Standard_Boolean);
end Valid_Scalars;
-----------
-- Value --
-----------
when Attribute_Value =>
Check_E1;
Check_Scalar_Type;
-- Case of enumeration type
-- When an enumeration type appears in an attribute reference, all
-- literals of the type are marked as referenced. This must only be
-- done if the attribute reference appears in the current source.
-- Otherwise the information on references may differ between a
-- normal compilation and one that performs inlining.
if Is_Enumeration_Type (P_Type)
and then In_Extended_Main_Code_Unit (N)
then
Check_Restriction (No_Enumeration_Maps, N);
-- Mark all enumeration literals as referenced, since the use of
-- the Value attribute can implicitly reference any of the
-- literals of the enumeration base type.
declare
Ent : Entity_Id := First_Literal (P_Base_Type);
begin
while Present (Ent) loop
Set_Referenced (Ent);
Next_Literal (Ent);
end loop;
end;
end if;
-- Set Etype before resolving expression because expansion of
-- expression may require enclosing type. Note that the type
-- returned by 'Value is the base type of the prefix type.
Set_Etype (N, P_Base_Type);
Validate_Non_Static_Attribute_Function_Call;
-- Check restriction No_Fixed_IO
if Restriction_Check_Required (No_Fixed_IO)
and then Is_Fixed_Point_Type (P_Type)
then
Check_Restriction (No_Fixed_IO, P);
end if;
----------------
-- Value_Size --
----------------
when Attribute_Value_Size =>
Check_E0;
Check_Type;
Check_Not_Incomplete_Type;
Set_Etype (N, Universal_Integer);
-------------
-- Version --
-------------
when Attribute_Version =>
Check_E0;
Check_Program_Unit;
Set_Etype (N, RTE (RE_Version_String));
------------------
-- Wchar_T_Size --
------------------
when Attribute_Wchar_T_Size =>
Standard_Attribute (Interfaces_Wchar_T_Size);
----------------
-- Wide_Image --
----------------
when Attribute_Wide_Image =>
Analyze_Image_Attribute (Standard_Wide_String);
---------------------
-- Wide_Wide_Image --
---------------------
when Attribute_Wide_Wide_Image =>
Analyze_Image_Attribute (Standard_Wide_Wide_String);
----------------
-- Wide_Value --
----------------
when Attribute_Wide_Value =>
Check_E1;
Check_Scalar_Type;
-- Set Etype before resolving expression because expansion
-- of expression may require enclosing type.
Set_Etype (N, P_Type);
Validate_Non_Static_Attribute_Function_Call;
-- Check restriction No_Fixed_IO
if Restriction_Check_Required (No_Fixed_IO)
and then Is_Fixed_Point_Type (P_Type)
then
Check_Restriction (No_Fixed_IO, P);
end if;
---------------------
-- Wide_Wide_Value --
---------------------
when Attribute_Wide_Wide_Value =>
Check_E1;
Check_Scalar_Type;
-- Set Etype before resolving expression because expansion
-- of expression may require enclosing type.
Set_Etype (N, P_Type);
Validate_Non_Static_Attribute_Function_Call;
-- Check restriction No_Fixed_IO
if Restriction_Check_Required (No_Fixed_IO)
and then Is_Fixed_Point_Type (P_Type)
then
Check_Restriction (No_Fixed_IO, P);
end if;
---------------------
-- Wide_Wide_Width --
---------------------
when Attribute_Wide_Wide_Width =>
Check_E0;
Check_Scalar_Type;
Set_Etype (N, Universal_Integer);
----------------
-- Wide_Width --
----------------
when Attribute_Wide_Width =>
Check_E0;
Check_Scalar_Type;
Set_Etype (N, Universal_Integer);
-----------
-- Width --
-----------
when Attribute_Width =>
Check_E0;
Check_Scalar_Type;
Set_Etype (N, Universal_Integer);
---------------
-- Word_Size --
---------------
when Attribute_Word_Size =>
Standard_Attribute (System_Word_Size);
-----------
-- Write --
-----------
when Attribute_Write =>
Check_E2;
Check_Stream_Attribute (TSS_Stream_Write);
Set_Etype (N, Standard_Void_Type);
Resolve (N, Standard_Void_Type);
end case;
-- In SPARK certain attributes (see below) depend on Tasking_State.
-- Ensure that the entity is available for gnat2why by loading it.
-- See SPARK RM 9(18) for the relevant rule.
if GNATprove_Mode then
case Attr_Id is
when Attribute_Callable
| Attribute_Caller
| Attribute_Count
| Attribute_Terminated
=>
SPARK_Implicit_Load (RE_Tasking_State);
when others =>
null;
end case;
end if;
-- All errors raise Bad_Attribute, so that we get out before any further
-- damage occurs when an error is detected (for example, if we check for
-- one attribute expression, and the check succeeds, we want to be able
-- to proceed securely assuming that an expression is in fact present.
-- Note: we set the attribute analyzed in this case to prevent any
-- attempt at reanalysis which could generate spurious error msgs.
exception
when Bad_Attribute =>
Set_Analyzed (N);
Set_Etype (N, Any_Type);
return;
end Analyze_Attribute;
--------------------
-- Eval_Attribute --
--------------------
procedure Eval_Attribute (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
C_Type : constant Entity_Id := Etype (N);
-- The type imposed by the context
Aname : Name_Id;
-- Attribute_Name (N) after verification of validity of N
Id : Attribute_Id;
-- Get_Attribute_Id (Aname) after Aname is set
P : Node_Id;
-- Prefix (N) after verification of validity of N
E1 : Node_Id;
-- First expression, or Empty if none
E2 : Node_Id;
-- Second expression, or Empty if none
P_Entity : Entity_Id;
-- Entity denoted by prefix
P_Type : Entity_Id;
-- The type of the prefix
P_Base_Type : Entity_Id;
-- The base type of the prefix type
P_Root_Type : Entity_Id;
-- The root type of the prefix type
Static : Boolean := False;
-- True if the result is Static. This is set by the general processing
-- to true if the prefix is static, and all expressions are static. It
-- can be reset as processing continues for particular attributes. This
-- flag can still be True if the reference raises a constraint error.
-- Is_Static_Expression (N) is set to follow this value as it is set
-- and we could always reference this, but it is convenient to have a
-- simple short name to use, since it is frequently referenced.
Lo_Bound, Hi_Bound : Node_Id;
-- Expressions for low and high bounds of type or array index referenced
-- by First, Last, or Length attribute for array, set by Set_Bounds.
CE_Node : Node_Id;
-- Constraint error node used if we have an attribute reference has
-- an argument that raises a constraint error. In this case we replace
-- the attribute with a raise constraint_error node. This is important
-- processing, since otherwise gigi might see an attribute which it is
-- unprepared to deal with.
procedure Check_Concurrent_Discriminant (Bound : Node_Id);
-- If Bound is a reference to a discriminant of a task or protected type
-- occurring within the object's body, rewrite attribute reference into
-- a reference to the corresponding discriminal. Use for the expansion
-- of checks against bounds of entry family index subtypes.
procedure Check_Expressions;
-- In case where the attribute is not foldable, the expressions, if
-- any, of the attribute, are in a non-static context. This procedure
-- performs the required additional checks.
function Compile_Time_Known_Bounds (Typ : Entity_Id) return Boolean;
-- Determines if the given type has compile time known bounds. Note
-- that we enter the case statement even in cases where the prefix
-- type does NOT have known bounds, so it is important to guard any
-- attempt to evaluate both bounds with a call to this function.
procedure Compile_Time_Known_Attribute (N : Node_Id; Val : Uint);
-- This procedure is called when the attribute N has a non-static
-- but compile time known value given by Val. It includes the
-- necessary checks for out of range values.
function Fore_Value return Nat;
-- Computes the Fore value for the current attribute prefix, which is
-- known to be a static fixed-point type. Used by Fore and Width.
function Mantissa return Uint;
-- Returns the Mantissa value for the prefix type
procedure Set_Bounds;
-- Used for First, Last and Length attributes applied to an array or
-- array subtype. Sets the variables Lo_Bound and Hi_Bound to the low
-- and high bound expressions for the index referenced by the attribute
-- designator (i.e. the first index if no expression is present, and the
-- N'th index if the value N is present as an expression). Also used for
-- First and Last of scalar types and for First_Valid and Last_Valid.
-- Static is reset to False if the type or index type is not statically
-- constrained.
-----------------------------------
-- Check_Concurrent_Discriminant --
-----------------------------------
procedure Check_Concurrent_Discriminant (Bound : Node_Id) is
Tsk : Entity_Id;
-- The concurrent (task or protected) type
begin
if Nkind (Bound) = N_Identifier
and then Ekind (Entity (Bound)) = E_Discriminant
and then Is_Concurrent_Record_Type (Scope (Entity (Bound)))
then
Tsk := Corresponding_Concurrent_Type (Scope (Entity (Bound)));
if In_Open_Scopes (Tsk) and then Has_Completion (Tsk) then
-- Find discriminant of original concurrent type, and use
-- its current discriminal, which is the renaming within
-- the task/protected body.
Rewrite (N,
New_Occurrence_Of
(Find_Body_Discriminal (Entity (Bound)), Loc));
end if;
end if;
end Check_Concurrent_Discriminant;
-----------------------
-- Check_Expressions --
-----------------------
procedure Check_Expressions is
E : Node_Id;
begin
E := E1;
while Present (E) loop
Check_Non_Static_Context (E);
Next (E);
end loop;
end Check_Expressions;
----------------------------------
-- Compile_Time_Known_Attribute --
----------------------------------
procedure Compile_Time_Known_Attribute (N : Node_Id; Val : Uint) is
T : constant Entity_Id := Etype (N);
begin
Fold_Uint (N, Val, False);
-- Check that result is in bounds of the type if it is static
if Is_In_Range (N, T, Assume_Valid => False) then
null;
elsif Is_Out_Of_Range (N, T) then
Apply_Compile_Time_Constraint_Error
(N, "value not in range of}??", CE_Range_Check_Failed);
elsif not Range_Checks_Suppressed (T) then
Enable_Range_Check (N);
else
Set_Do_Range_Check (N, False);
end if;
end Compile_Time_Known_Attribute;
-------------------------------
-- Compile_Time_Known_Bounds --
-------------------------------
function Compile_Time_Known_Bounds (Typ : Entity_Id) return Boolean is
begin
return
Compile_Time_Known_Value (Type_Low_Bound (Typ))
and then
Compile_Time_Known_Value (Type_High_Bound (Typ));
end Compile_Time_Known_Bounds;
----------------
-- Fore_Value --
----------------
-- Note that the Fore calculation is based on the actual values
-- of the bounds, and does not take into account possible rounding.
function Fore_Value return Nat is
Lo : constant Uint := Expr_Value (Type_Low_Bound (P_Type));
Hi : constant Uint := Expr_Value (Type_High_Bound (P_Type));
Small : constant Ureal := Small_Value (P_Type);
Lo_Real : constant Ureal := Lo * Small;
Hi_Real : constant Ureal := Hi * Small;
T : Ureal;
R : Nat;
begin
-- Bounds are given in terms of small units, so first compute
-- proper values as reals.
T := UR_Max (abs Lo_Real, abs Hi_Real);
R := 2;
-- Loop to compute proper value if more than one digit required
while T >= Ureal_10 loop
R := R + 1;
T := T / Ureal_10;
end loop;
return R;
end Fore_Value;
--------------
-- Mantissa --
--------------
-- Table of mantissa values accessed by function Computed using
-- the relation:
-- T'Mantissa = integer next above (D * log(10)/log(2)) + 1)
-- where D is T'Digits (RM83 3.5.7)
Mantissa_Value : constant array (Nat range 1 .. 40) of Nat := (
1 => 5,
2 => 8,
3 => 11,
4 => 15,
5 => 18,
6 => 21,
7 => 25,
8 => 28,
9 => 31,
10 => 35,
11 => 38,
12 => 41,
13 => 45,
14 => 48,
15 => 51,
16 => 55,
17 => 58,
18 => 61,
19 => 65,
20 => 68,
21 => 71,
22 => 75,
23 => 78,
24 => 81,
25 => 85,
26 => 88,
27 => 91,
28 => 95,
29 => 98,
30 => 101,
31 => 104,
32 => 108,
33 => 111,
34 => 114,
35 => 118,
36 => 121,
37 => 124,
38 => 128,
39 => 131,
40 => 134);
function Mantissa return Uint is
begin
return
UI_From_Int (Mantissa_Value (UI_To_Int (Digits_Value (P_Type))));
end Mantissa;
----------------
-- Set_Bounds --
----------------
procedure Set_Bounds is
Ndim : Nat;
Indx : Node_Id;
Ityp : Entity_Id;
begin
-- For a string literal subtype, we have to construct the bounds.
-- Valid Ada code never applies attributes to string literals, but
-- it is convenient to allow the expander to generate attribute
-- references of this type (e.g. First and Last applied to a string
-- literal).
-- Note that the whole point of the E_String_Literal_Subtype is to
-- avoid this construction of bounds, but the cases in which we
-- have to materialize them are rare enough that we don't worry.
-- The low bound is simply the low bound of the base type. The
-- high bound is computed from the length of the string and this
-- low bound.
if Ekind (P_Type) = E_String_Literal_Subtype then
Ityp := Etype (First_Index (Base_Type (P_Type)));
Lo_Bound := Type_Low_Bound (Ityp);
Hi_Bound :=
Make_Integer_Literal (Sloc (P),
Intval =>
Expr_Value (Lo_Bound) + String_Literal_Length (P_Type) - 1);
Set_Parent (Hi_Bound, P);
Analyze_And_Resolve (Hi_Bound, Etype (Lo_Bound));
return;
-- For non-array case, just get bounds of scalar type
elsif Is_Scalar_Type (P_Type) then
Ityp := P_Type;
-- For a fixed-point type, we must freeze to get the attributes
-- of the fixed-point type set now so we can reference them.
if Is_Fixed_Point_Type (P_Type)
and then not Is_Frozen (Base_Type (P_Type))
and then Compile_Time_Known_Value (Type_Low_Bound (P_Type))
and then Compile_Time_Known_Value (Type_High_Bound (P_Type))
then
Freeze_Fixed_Point_Type (Base_Type (P_Type));
end if;
-- For array case, get type of proper index
else
if No (E1) then
Ndim := 1;
else
Ndim := UI_To_Int (Expr_Value (E1));
end if;
Indx := First_Index (P_Type);
for J in 1 .. Ndim - 1 loop
Next_Index (Indx);
end loop;
-- If no index type, get out (some other error occurred, and
-- we don't have enough information to complete the job).
if No (Indx) then
Lo_Bound := Error;
Hi_Bound := Error;
return;
end if;
Ityp := Etype (Indx);
end if;
-- A discrete range in an index constraint is allowed to be a
-- subtype indication. This is syntactically a pain, but should
-- not propagate to the entity for the corresponding index subtype.
-- After checking that the subtype indication is legal, the range
-- of the subtype indication should be transfered to the entity.
-- The attributes for the bounds should remain the simple retrievals
-- that they are now.
Lo_Bound := Type_Low_Bound (Ityp);
Hi_Bound := Type_High_Bound (Ityp);
-- If subtype is non-static, result is definitely non-static
if not Is_Static_Subtype (Ityp) then
Static := False;
Set_Is_Static_Expression (N, False);
-- Subtype is static, does it raise CE?
elsif not Is_OK_Static_Subtype (Ityp) then
Set_Raises_Constraint_Error (N);
end if;
end Set_Bounds;
-- Start of processing for Eval_Attribute
begin
-- Return immediately if e.g. N has been rewritten or is malformed due
-- to previous errors.
if Nkind (N) /= N_Attribute_Reference then
return;
end if;
Aname := Attribute_Name (N);
Id := Get_Attribute_Id (Aname);
P := Prefix (N);
-- The To_Address attribute can be static, but it cannot be evaluated at
-- compile time, so just return.
if Id = Attribute_To_Address then
return;
end if;
-- Initialize result as non-static, will be reset if appropriate
Set_Is_Static_Expression (N, False);
-- Acquire first two expressions (at the moment, no attributes take more
-- than two expressions in any case).
if Present (Expressions (N)) then
E1 := First (Expressions (N));
E2 := Next (E1);
else
E1 := Empty;
E2 := Empty;
end if;
-- Special processing for Enabled attribute. This attribute has a very
-- special prefix, and the easiest way to avoid lots of special checks
-- to protect this special prefix from causing trouble is to deal with
-- this attribute immediately and be done with it.
if Id = Attribute_Enabled then
-- We skip evaluation if the expander is not active. This is not just
-- an optimization. It is of key importance that we not rewrite the
-- attribute in a generic template, since we want to pick up the
-- setting of the check in the instance.
if not Inside_A_Generic then
declare
C : constant Check_Id := Get_Check_Id (Chars (P));
R : Boolean;
begin
if No (E1) then
if C in Predefined_Check_Id then
R := Scope_Suppress.Suppress (C);
else
R := Is_Check_Suppressed (Empty, C);
end if;
else
R := Is_Check_Suppressed (Entity (E1), C);
end if;
Rewrite (N, New_Occurrence_Of (Boolean_Literals (not R), Loc));
end;
end if;
return;
end if;
-- Attribute 'Img applied to a static enumeration value is static, and
-- we will do the folding right here (things get confused if we let this
-- case go through the normal circuitry).
if Attribute_Name (N) = Name_Img
and then Is_Entity_Name (P)
and then Is_Enumeration_Type (Etype (Entity (P)))
and then Is_OK_Static_Expression (P)
then
declare
Lit : constant Entity_Id := Expr_Value_E (P);
Str : String_Id;
begin
Start_String;
Get_Unqualified_Decoded_Name_String (Chars (Lit));
Set_Casing (All_Upper_Case);
Store_String_Chars (Name_Buffer (1 .. Name_Len));
Str := End_String;
Rewrite (N, Make_String_Literal (Loc, Strval => Str));
Analyze_And_Resolve (N, Standard_String);
Set_Is_Static_Expression (N, True);
end;
return;
end if;
-- Special processing for cases where the prefix is an object or value,
-- including string literals (attributes of string literals can only
-- appear in generated code) and current instance prefixes in type or
-- subtype aspects.
if Is_Object_Reference (P)
or else Is_Current_Instance_Reference_In_Type_Aspect (P)
or else Nkind (P) = N_String_Literal
or else (Is_Entity_Name (P)
and then Ekind (Entity (P)) = E_Enumeration_Literal)
then
-- For Alignment, give alignment of object if available, otherwise we
-- cannot fold Alignment.
if Id = Attribute_Alignment then
if Is_Entity_Name (P) and then Known_Alignment (Entity (P)) then
Compile_Time_Known_Attribute (N, Alignment (Entity (P)));
else
Check_Expressions;
end if;
return;
-- For Component_Size, the prefix is an array object, and we apply
-- the attribute to the type of the object. This is allowed for both
-- unconstrained and constrained arrays, since the bounds have no
-- influence on the value of this attribute.
elsif Id = Attribute_Component_Size then
P_Entity := Etype (P);
-- For Enum_Rep, evaluation depends on the nature of the prefix and
-- the optional argument.
elsif Id = Attribute_Enum_Rep then
if Is_Entity_Name (P) then
declare
Enum_Expr : Node_Id;
-- The enumeration-type expression of interest
begin
-- P'Enum_Rep case
if Ekind (Entity (P)) in E_Constant | E_Enumeration_Literal
then
Enum_Expr := P;
-- Enum_Type'Enum_Rep (E1) case
elsif Is_Enumeration_Type (Entity (P)) then
Enum_Expr := E1;
-- Otherwise the attribute must be expanded into a
-- conversion and evaluated at run time.
else
Check_Expressions;
return;
end if;
-- We can fold if the expression is an enumeration
-- literal, or if it denotes a constant whose value
-- is known at compile time.
if Nkind (Enum_Expr) in N_Has_Entity
and then (Ekind (Entity (Enum_Expr)) =
E_Enumeration_Literal
or else
(Ekind (Entity (Enum_Expr)) = E_Constant
and then Nkind (Parent (Entity (Enum_Expr))) =
N_Object_Declaration
and then Present
(Expression (Parent (Entity (P))))
and then Compile_Time_Known_Value
(Expression (Parent (Entity (P))))))
then
P_Entity := Etype (P);
else
Check_Expressions;
return;
end if;
end;
-- Otherwise the attribute is illegal, do not attempt to perform
-- any kind of folding.
else
return;
end if;
-- For Bit_Position, give Component_Bit_Offset of object if available
-- otherwise we cannot fold Bit_Position. Note that the attribute can
-- be applied to a naked record component in generated code, in which
-- case the prefix is an identifier that references the component or
-- discriminant entity.
elsif Id = Attribute_Bit_Position then
declare
CE : Entity_Id;
begin
if Is_Entity_Name (P) then
CE := Entity (P);
else
CE := Entity (Selector_Name (P));
end if;
if Known_Static_Component_Bit_Offset (CE) then
Compile_Time_Known_Attribute
(N, Component_Bit_Offset (Entity (P)));
else
Check_Expressions;
end if;
return;
end;
-- For Position, in Ada 2005 (or later) if we have the non-default
-- bit order, we return the original value as given in the component
-- clause (RM 2005 13.5.2(3/2)). Otherwise (Ada 83/95, or later with
-- default bit order) return the value if it is known statically.
elsif Id = Attribute_Position then
declare
CE : constant Entity_Id := Entity (Selector_Name (P));
begin
if Present (Component_Clause (CE))
and then Ada_Version >= Ada_2005
and then Reverse_Bit_Order (Scope (CE))
then
Compile_Time_Known_Attribute
(N, Expr_Value (Position (Component_Clause (CE))));
elsif Known_Static_Component_Bit_Offset (CE) then
Compile_Time_Known_Attribute
(N, Component_Bit_Offset (CE) / System_Storage_Unit);
else
Check_Expressions;
end if;
return;
end;
-- For First_Bit, in Ada 2005 (or later) if we have the non-default
-- bit order, we return the original value as given in the component
-- clause (RM 2005 13.5.2(3/2)). Otherwise (Ada 83/95, or later with
-- default bit order) return the value if it is known statically.
elsif Id = Attribute_First_Bit then
declare
CE : constant Entity_Id := Entity (Selector_Name (P));
begin
if Present (Component_Clause (CE))
and then Ada_Version >= Ada_2005
and then Reverse_Bit_Order (Scope (CE))
then
Compile_Time_Known_Attribute
(N, Expr_Value (First_Bit (Component_Clause (CE))));
elsif Known_Static_Component_Bit_Offset (CE) then
Compile_Time_Known_Attribute
(N, Component_Bit_Offset (CE) mod System_Storage_Unit);
else
Check_Expressions;
end if;
return;
end;
-- For Last_Bit, in Ada 2005 (or later) if we have the non-default
-- bit order, we return the original value as given in the component
-- clause (RM 2005 13.5.2(3/2)). Otherwise (Ada 83/95, or later with
-- default bit order) return the value if it is known statically.
elsif Id = Attribute_Last_Bit then
declare
CE : constant Entity_Id := Entity (Selector_Name (P));
begin
if Present (Component_Clause (CE))
and then Ada_Version >= Ada_2005
and then Reverse_Bit_Order (Scope (CE))
then
Compile_Time_Known_Attribute
(N, Expr_Value (Last_Bit (Component_Clause (CE))));
elsif Known_Static_Component_Bit_Offset (CE)
and then Known_Static_Esize (CE)
then
Compile_Time_Known_Attribute
(N, (Component_Bit_Offset (CE) mod System_Storage_Unit)
+ Esize (CE) - 1);
else
Check_Expressions;
end if;
return;
end;
-- For First, Last and Length, the prefix is an array object, and we
-- apply the attribute to its type, but we need a constrained type
-- for this, so we use the actual subtype if available.
elsif Id = Attribute_First
or else Id = Attribute_Last
or else Id = Attribute_Length
then
declare
AS : constant Entity_Id := Get_Actual_Subtype_If_Available (P);
begin
if Present (AS) and then Is_Constrained (AS) then
P_Entity := AS;
-- If we have an unconstrained type we cannot fold
else
Check_Expressions;
return;
end if;
end;
-- For Size, give size of object if available, otherwise we
-- cannot fold Size.
elsif Id = Attribute_Size then
if Is_Entity_Name (P)
and then Known_Static_Esize (Entity (P))
then
Compile_Time_Known_Attribute (N, Esize (Entity (P)));
else
Check_Expressions;
end if;
return;
-- For Lock_Free, we apply the attribute to the type of the object.
-- This is allowed since we have already verified that the type is a
-- protected type.
elsif Id = Attribute_Lock_Free then
P_Entity := Etype (P);
-- No other attributes for objects are folded
else
Check_Expressions;
return;
end if;
-- Cases where P is not an object. Cannot do anything if P is not the
-- name of an entity.
elsif not Is_Entity_Name (P) then
Check_Expressions;
return;
-- Otherwise get prefix entity
else
P_Entity := Entity (P);
end if;
-- If we are asked to evaluate an attribute where the prefix is a
-- non-frozen generic actual type whose RM_Size is still set to zero,
-- then abandon the effort.
if Is_Type (P_Entity)
and then (not Is_Frozen (P_Entity)
and then Is_Generic_Actual_Type (P_Entity)
and then RM_Size (P_Entity) = 0)
-- However, the attribute Unconstrained_Array must be evaluated,
-- since it is documented to be a static attribute (and can for
-- example appear in a Compile_Time_Warning pragma). The frozen
-- status of the type does not affect its evaluation.
and then Id /= Attribute_Unconstrained_Array
then
return;
end if;
-- At this stage P_Entity is the entity to which the attribute
-- is to be applied. This is usually simply the entity of the
-- prefix, except in some cases of attributes for objects, where
-- as described above, we apply the attribute to the object type.
-- Here is where we make sure that static attributes are properly
-- marked as such. These are attributes whose prefix is a static
-- scalar subtype, whose result is scalar, and whose arguments, if
-- present, are static scalar expressions. Note that such references
-- are static expressions even if they raise Constraint_Error.
-- For example, Boolean'Pos (1/0 = 0) is a static expression, even
-- though evaluating it raises constraint error. This means that a
-- declaration like:
-- X : constant := (if True then 1 else Boolean'Pos (1/0 = 0));
-- is legal, since here this expression appears in a statically
-- unevaluated position, so it does not actually raise an exception.
--
-- T'Descriptor_Size is never static, even if T is static.
if Is_Scalar_Type (P_Entity)
and then (not Is_Generic_Type (P_Entity))
and then Is_Static_Subtype (P_Entity)
and then Is_Scalar_Type (Etype (N))
and then
(No (E1)
or else (Is_Static_Expression (E1)
and then Is_Scalar_Type (Etype (E1))))
and then
(No (E2)
or else (Is_Static_Expression (E2)
and then Is_Scalar_Type (Etype (E1))))
and then Id /= Attribute_Descriptor_Size
then
Static := True;
Set_Is_Static_Expression (N, True);
end if;
-- First foldable possibility is a scalar or array type (RM 4.9(7))
-- that is not generic (generic types are eliminated by RM 4.9(25)).
-- Note we allow nonstatic nongeneric types at this stage as further
-- described below.
if Is_Type (P_Entity)
and then (Is_Scalar_Type (P_Entity) or Is_Array_Type (P_Entity))
and then (not Is_Generic_Type (P_Entity))
then
P_Type := P_Entity;
-- Second foldable possibility is an array object (RM 4.9(8))
elsif Ekind (P_Entity) in E_Variable | E_Constant
and then Is_Array_Type (Etype (P_Entity))
and then (not Is_Generic_Type (Etype (P_Entity)))
then
P_Type := Etype (P_Entity);
-- If the entity is an array constant with an unconstrained nominal
-- subtype then get the type from the initial value. If the value has
-- been expanded into assignments, there is no expression and the
-- attribute reference remains dynamic.
-- We could do better here and retrieve the type ???
if Ekind (P_Entity) = E_Constant
and then not Is_Constrained (P_Type)
then
if No (Constant_Value (P_Entity)) then
return;
else
P_Type := Etype (Constant_Value (P_Entity));
end if;
end if;
-- Definite must be folded if the prefix is not a generic type, that
-- is to say if we are within an instantiation. Same processing applies
-- to selected GNAT attributes.
elsif (Id = Attribute_Atomic_Always_Lock_Free or else
Id = Attribute_Definite or else
Id = Attribute_Descriptor_Size or else
Id = Attribute_Has_Access_Values or else
Id = Attribute_Has_Discriminants or else
Id = Attribute_Has_Tagged_Values or else
Id = Attribute_Lock_Free or else
Id = Attribute_Type_Class or else
Id = Attribute_Unconstrained_Array or else
Id = Attribute_Max_Alignment_For_Allocation)
and then not Is_Generic_Type (P_Entity)
then
P_Type := P_Entity;
-- We can fold 'Size applied to a type if the size is known (as happens
-- for a size from an attribute definition clause). At this stage, this
-- can happen only for types (e.g. record types) for which the size is
-- always non-static. We exclude generic types from consideration (since
-- they have bogus sizes set within templates). We can also fold
-- Max_Size_In_Storage_Elements in the same cases.
elsif (Id = Attribute_Size or
Id = Attribute_Max_Size_In_Storage_Elements)
and then Is_Type (P_Entity)
and then (not Is_Generic_Type (P_Entity))
and then Known_Static_RM_Size (P_Entity)
then
declare
Attr_Value : Uint := RM_Size (P_Entity);
begin
if Id = Attribute_Max_Size_In_Storage_Elements then
Attr_Value := (Attr_Value + System_Storage_Unit - 1)
/ System_Storage_Unit;
end if;
Compile_Time_Known_Attribute (N, Attr_Value);
end;
return;
-- We can fold 'Alignment applied to a type if the alignment is known
-- (as happens for an alignment from an attribute definition clause).
-- At this stage, this can happen only for types (e.g. record types) for
-- which the size is always non-static. We exclude generic types from
-- consideration (since they have bogus sizes set within templates).
elsif Id = Attribute_Alignment
and then Is_Type (P_Entity)
and then (not Is_Generic_Type (P_Entity))
and then Known_Alignment (P_Entity)
then
Compile_Time_Known_Attribute (N, Alignment (P_Entity));
return;
-- If this is an access attribute that is known to fail accessibility
-- check, rewrite accordingly.
elsif Attribute_Name (N) = Name_Access
and then Raises_Constraint_Error (N)
then
Rewrite (N,
Make_Raise_Program_Error (Loc,
Reason => PE_Accessibility_Check_Failed));
Set_Etype (N, C_Type);
return;
-- No other cases are foldable (they certainly aren't static, and at
-- the moment we don't try to fold any cases other than the ones above).
else
Check_Expressions;
return;
end if;
-- If either attribute or the prefix is Any_Type, then propagate
-- Any_Type to the result and don't do anything else at all.
if P_Type = Any_Type
or else (Present (E1) and then Etype (E1) = Any_Type)
or else (Present (E2) and then Etype (E2) = Any_Type)
then
Set_Etype (N, Any_Type);
return;
end if;
-- Scalar subtype case. We have not yet enforced the static requirement
-- of (RM 4.9(7)) and we don't intend to just yet, since there are cases
-- of non-static attribute references (e.g. S'Digits for a non-static
-- floating-point type, which we can compute at compile time).
-- Note: this folding of non-static attributes is not simply a case of
-- optimization. For many of the attributes affected, Gigi cannot handle
-- the attribute and depends on the front end having folded them away.
-- Note: although we don't require staticness at this stage, we do set
-- the Static variable to record the staticness, for easy reference by
-- those attributes where it matters (e.g. Succ and Pred), and also to
-- be used to ensure that non-static folded things are not marked as
-- being static (a check that is done right at the end).
P_Root_Type := Root_Type (P_Type);
P_Base_Type := Base_Type (P_Type);
-- If the root type or base type is generic, then we cannot fold. This
-- test is needed because subtypes of generic types are not always
-- marked as being generic themselves (which seems odd???)
if Is_Generic_Type (P_Root_Type)
or else Is_Generic_Type (P_Base_Type)
then
return;
end if;
if Is_Scalar_Type (P_Type) then
if not Is_Static_Subtype (P_Type) then
Static := False;
Set_Is_Static_Expression (N, False);
elsif not Is_OK_Static_Subtype (P_Type) then
Set_Raises_Constraint_Error (N);
end if;
-- Array case. We enforce the constrained requirement of (RM 4.9(7-8))
-- since we can't do anything with unconstrained arrays. In addition,
-- only the First, Last and Length attributes are possibly static.
-- Atomic_Always_Lock_Free, Definite, Descriptor_Size, Has_Access_Values
-- Has_Discriminants, Has_Tagged_Values, Lock_Free, Type_Class, and
-- Unconstrained_Array are again exceptions, because they apply as well
-- to unconstrained types.
-- In addition Component_Size is an exception since it is possibly
-- foldable, even though it is never static, and it does apply to
-- unconstrained arrays. Furthermore, it is essential to fold this
-- in the packed case, since otherwise the value will be incorrect.
elsif Id = Attribute_Atomic_Always_Lock_Free or else
Id = Attribute_Definite or else
Id = Attribute_Descriptor_Size or else
Id = Attribute_Has_Access_Values or else
Id = Attribute_Has_Discriminants or else
Id = Attribute_Has_Tagged_Values or else
Id = Attribute_Lock_Free or else
Id = Attribute_Type_Class or else
Id = Attribute_Unconstrained_Array or else
Id = Attribute_Component_Size
then
Static := False;
Set_Is_Static_Expression (N, False);
elsif Id /= Attribute_Max_Alignment_For_Allocation then
if not Is_Constrained (P_Type)
or else (Id /= Attribute_First and then
Id /= Attribute_Last and then
Id /= Attribute_Length)
then
Check_Expressions;
return;
end if;
-- The rules in (RM 4.9(7,8)) require a static array, but as in the
-- scalar case, we hold off on enforcing staticness, since there are
-- cases which we can fold at compile time even though they are not
-- static (e.g. 'Length applied to a static index, even though other
-- non-static indexes make the array type non-static). This is only
-- an optimization, but it falls out essentially free, so why not.
-- Again we compute the variable Static for easy reference later
-- (note that no array attributes are static in Ada 83).
-- We also need to set Static properly for subsequent legality checks
-- which might otherwise accept non-static constants in contexts
-- where they are not legal.
Static :=
Ada_Version >= Ada_95 and then Statically_Denotes_Entity (P);
Set_Is_Static_Expression (N, Static);
declare
Nod : Node_Id;
begin
Nod := First_Index (P_Type);
-- The expression is static if the array type is constrained
-- by given bounds, and not by an initial expression. Constant
-- strings are static in any case.
if Root_Type (P_Type) /= Standard_String then
Static :=
Static and then not Is_Constr_Subt_For_U_Nominal (P_Type);
Set_Is_Static_Expression (N, Static);
end if;
while Present (Nod) loop
if not Is_Static_Subtype (Etype (Nod)) then
Static := False;
Set_Is_Static_Expression (N, False);
elsif not Is_OK_Static_Subtype (Etype (Nod)) then
Set_Raises_Constraint_Error (N);
Static := False;
Set_Is_Static_Expression (N, False);
end if;
-- If however the index type is generic, or derived from
-- one, attributes cannot be folded.
if Is_Generic_Type (Root_Type (Etype (Nod)))
and then Id /= Attribute_Component_Size
then
return;
end if;
Next_Index (Nod);
end loop;
end;
end if;
-- Check any expressions that are present. Note that these expressions,
-- depending on the particular attribute type, are either part of the
-- attribute designator, or they are arguments in a case where the
-- attribute reference returns a function. In the latter case, the
-- rule in (RM 4.9(22)) applies and in particular requires the type
-- of the expressions to be scalar in order for the attribute to be
-- considered to be static.
declare
E : Node_Id;
begin
E := E1;
while Present (E) loop
-- If expression is not static, then the attribute reference
-- result certainly cannot be static.
if not Is_Static_Expression (E) then
Static := False;
Set_Is_Static_Expression (N, False);
end if;
if Raises_Constraint_Error (E) then
Set_Raises_Constraint_Error (N);
end if;
-- If the result is not known at compile time, or is not of
-- a scalar type, then the result is definitely not static,
-- so we can quit now.
if not Compile_Time_Known_Value (E)
or else not Is_Scalar_Type (Etype (E))
then
Check_Expressions;
return;
-- If the expression raises a constraint error, then so does
-- the attribute reference. We keep going in this case because
-- we are still interested in whether the attribute reference
-- is static even if it is not static.
elsif Raises_Constraint_Error (E) then
Set_Raises_Constraint_Error (N);
end if;
Next (E);
end loop;
if Raises_Constraint_Error (Prefix (N)) then
Set_Is_Static_Expression (N, False);
return;
end if;
end;
-- Deal with the case of a static attribute reference that raises
-- constraint error. The Raises_Constraint_Error flag will already
-- have been set, and the Static flag shows whether the attribute
-- reference is static. In any case we certainly can't fold such an
-- attribute reference.
-- Note that the rewriting of the attribute node with the constraint
-- error node is essential in this case, because otherwise Gigi might
-- blow up on one of the attributes it never expects to see.
-- The constraint_error node must have the type imposed by the context,
-- to avoid spurious errors in the enclosing expression.
if Raises_Constraint_Error (N) then
CE_Node :=
Make_Raise_Constraint_Error (Sloc (N),
Reason => CE_Range_Check_Failed);
Set_Etype (CE_Node, Etype (N));
Set_Raises_Constraint_Error (CE_Node);
Check_Expressions;
Rewrite (N, Relocate_Node (CE_Node));
Set_Raises_Constraint_Error (N, True);
return;
end if;
-- At this point we have a potentially foldable attribute reference.
-- If Static is set, then the attribute reference definitely obeys
-- the requirements in (RM 4.9(7,8,22)), and it definitely can be
-- folded. If Static is not set, then the attribute may or may not
-- be foldable, and the individual attribute processing routines
-- test Static as required in cases where it makes a difference.
-- In the case where Static is not set, we do know that all the
-- expressions present are at least known at compile time (we assumed
-- above that if this was not the case, then there was no hope of static
-- evaluation). However, we did not require that the bounds of the
-- prefix type be compile time known, let alone static). That's because
-- there are many attributes that can be computed at compile time on
-- non-static subtypes, even though such references are not static
-- expressions.
-- For VAX float, the root type is an IEEE type. So make sure to use the
-- base type instead of the root-type for floating point attributes.
case Id is
-- Attributes related to Ada 2012 iterators; nothing to evaluate for
-- these.
when Attribute_Constant_Indexing
| Attribute_Default_Iterator
| Attribute_Implicit_Dereference
| Attribute_Iterator_Element
| Attribute_Iterable
| Attribute_Reduce
| Attribute_Variable_Indexing
=>
null;
-- Internal attributes used to deal with Ada 2012 delayed aspects.
-- These were already rejected by the parser. Thus they shouldn't
-- appear here.
when Internal_Attribute_Id =>
raise Program_Error;
--------------
-- Adjacent --
--------------
when Attribute_Adjacent =>
Fold_Ureal
(N,
Eval_Fat.Adjacent
(P_Base_Type, Expr_Value_R (E1), Expr_Value_R (E2)),
Static);
---------
-- Aft --
---------
when Attribute_Aft =>
Fold_Uint (N, Aft_Value (P_Type), Static);
---------------
-- Alignment --
---------------
when Attribute_Alignment => Alignment_Block : declare
P_TypeA : constant Entity_Id := Underlying_Type (P_Type);
begin
-- Fold if alignment is set and not otherwise
if Known_Alignment (P_TypeA) then
Fold_Uint (N, Alignment (P_TypeA), Static);
end if;
end Alignment_Block;
-----------------------------
-- Atomic_Always_Lock_Free --
-----------------------------
-- Atomic_Always_Lock_Free attribute is a Boolean, thus no need to fold
-- here.
when Attribute_Atomic_Always_Lock_Free => Atomic_Always_Lock_Free :
declare
V : constant Entity_Id :=
Boolean_Literals
(Support_Atomic_Primitives_On_Target
and then Support_Atomic_Primitives (P_Type));
begin
Rewrite (N, New_Occurrence_Of (V, Loc));
-- Analyze and resolve as boolean. Note that this attribute is a
-- static attribute in GNAT.
Analyze_And_Resolve (N, Standard_Boolean);
Static := True;
Set_Is_Static_Expression (N);
end Atomic_Always_Lock_Free;
---------
-- Bit --
---------
-- Bit can never be folded
when Attribute_Bit =>
null;
------------------
-- Body_Version --
------------------
-- Body_version can never be static
when Attribute_Body_Version =>
null;
-------------
-- Ceiling --
-------------
when Attribute_Ceiling =>
Fold_Ureal
(N, Eval_Fat.Ceiling (P_Base_Type, Expr_Value_R (E1)), Static);
--------------------
-- Component_Size --
--------------------
-- Fold Component_Size if it is known at compile time, which is always
-- true in the packed array case. It is important that the packed array
-- case is handled here since the back end would otherwise get confused
-- by the equivalent packed array type.
when Attribute_Component_Size =>
if Known_Static_Component_Size (P_Type) then
Fold_Uint (N, Component_Size (P_Type), Static);
end if;
-------------
-- Compose --
-------------
when Attribute_Compose =>
Fold_Ureal
(N,
Eval_Fat.Compose (P_Base_Type, Expr_Value_R (E1), Expr_Value (E2)),
Static);
-----------------
-- Constrained --
-----------------
-- Constrained is never folded for now, there may be cases that
-- could be handled at compile time. To be looked at later.
when Attribute_Constrained =>
-- The expander might fold it and set the static flag accordingly,
-- but with expansion disabled, it remains as an attribute reference,
-- and this reference is not static.
Set_Is_Static_Expression (N, False);
---------------
-- Copy_Sign --
---------------
when Attribute_Copy_Sign =>
Fold_Ureal
(N,
Eval_Fat.Copy_Sign
(P_Base_Type, Expr_Value_R (E1), Expr_Value_R (E2)),
Static);
--------------
-- Definite --
--------------
when Attribute_Definite =>
Rewrite (N, New_Occurrence_Of (
Boolean_Literals (Is_Definite_Subtype (P_Entity)), Loc));
Analyze_And_Resolve (N, Standard_Boolean);
-----------
-- Delta --
-----------
when Attribute_Delta =>
Fold_Ureal (N, Delta_Value (P_Type), True);
------------
-- Denorm --
------------
when Attribute_Denorm =>
Fold_Uint
(N, UI_From_Int (Boolean'Pos (Has_Denormals (P_Type))), Static);
---------------------
-- Descriptor_Size --
---------------------
-- Descriptor_Size is nonnull only for unconstrained array types
when Attribute_Descriptor_Size =>
if not Is_Array_Type (P_Type) or else Is_Constrained (P_Type) then
Fold_Uint (N, Uint_0, Static);
end if;
------------
-- Digits --
------------
when Attribute_Digits =>
Fold_Uint (N, Digits_Value (P_Type), Static);
----------
-- Emax --
----------
when Attribute_Emax =>
-- Ada 83 attribute is defined as (RM83 3.5.8)
-- T'Emax = 4 * T'Mantissa
Fold_Uint (N, 4 * Mantissa, Static);
--------------
-- Enum_Rep --
--------------
when Attribute_Enum_Rep => Enum_Rep : declare
Val : Node_Id;
begin
-- The attribute appears in the form:
-- Enum_Typ'Enum_Rep (Const)
-- Enum_Typ'Enum_Rep (Enum_Lit)
if Present (E1) then
Val := E1;
-- Otherwise the prefix denotes a constant or enumeration literal:
-- Const'Enum_Rep
-- Enum_Lit'Enum_Rep
else
Val := P;
end if;
-- For an enumeration type with a non-standard representation use
-- the Enumeration_Rep field of the proper constant. Note that this
-- will not work for types Character/Wide_[Wide-]Character, since no
-- real entities are created for the enumeration literals, but that
-- does not matter since these two types do not have non-standard
-- representations anyway.
if Is_Enumeration_Type (P_Type)
and then Has_Non_Standard_Rep (P_Type)
then
Fold_Uint (N, Enumeration_Rep (Expr_Value_E (Val)), Static);
-- For enumeration types with standard representations and all other
-- cases (i.e. all integer and modular types), Enum_Rep is equivalent
-- to Pos.
else
Fold_Uint (N, Expr_Value (Val), Static);
end if;
end Enum_Rep;
--------------
-- Enum_Val --
--------------
when Attribute_Enum_Val => Enum_Val : declare
Lit : Entity_Id;
begin
-- We have something like Enum_Type'Enum_Val (23), so search for a
-- corresponding value in the list of Enum_Rep values for the type.
Lit := First_Literal (P_Base_Type);
loop
if Enumeration_Rep (Lit) = Expr_Value (E1) then
Fold_Uint (N, Enumeration_Pos (Lit), Static);
exit;
end if;
Next_Literal (Lit);
if No (Lit) then
Apply_Compile_Time_Constraint_Error
(N, "no representation value matches",
CE_Range_Check_Failed,
Warn => not Static);
exit;
end if;
end loop;
end Enum_Val;
-------------
-- Epsilon --
-------------
when Attribute_Epsilon =>
-- Ada 83 attribute is defined as (RM83 3.5.8)
-- T'Epsilon = 2.0**(1 - T'Mantissa)
Fold_Ureal (N, Ureal_2 ** (1 - Mantissa), True);
--------------
-- Exponent --
--------------
when Attribute_Exponent =>
Fold_Uint (N,
Eval_Fat.Exponent (P_Base_Type, Expr_Value_R (E1)), Static);
-----------------------
-- Finalization_Size --
-----------------------
when Attribute_Finalization_Size =>
null;
-----------
-- First --
-----------
when Attribute_First =>
Set_Bounds;
if Compile_Time_Known_Value (Lo_Bound) then
if Is_Real_Type (P_Type) then
Fold_Ureal (N, Expr_Value_R (Lo_Bound), Static);
else
Fold_Uint (N, Expr_Value (Lo_Bound), Static);
end if;
else
Check_Concurrent_Discriminant (Lo_Bound);
end if;
-----------------
-- First_Valid --
-----------------
when Attribute_First_Valid =>
if Has_Predicates (P_Type)
and then Has_Static_Predicate (P_Type)
then
declare
FirstN : constant Node_Id :=
First (Static_Discrete_Predicate (P_Type));
begin
if Nkind (FirstN) = N_Range then
Fold_Uint (N, Expr_Value (Low_Bound (FirstN)), Static);
else
Fold_Uint (N, Expr_Value (FirstN), Static);
end if;
end;
else
Set_Bounds;
Fold_Uint (N, Expr_Value (Lo_Bound), Static);
end if;
-----------------
-- Fixed_Value --
-----------------
when Attribute_Fixed_Value =>
null;
-----------
-- Floor --
-----------
when Attribute_Floor =>
Fold_Ureal
(N, Eval_Fat.Floor (P_Base_Type, Expr_Value_R (E1)), Static);
----------
-- Fore --
----------
when Attribute_Fore =>
if Compile_Time_Known_Bounds (P_Type) then
Fold_Uint (N, UI_From_Int (Fore_Value), Static);
end if;
--------------
-- Fraction --
--------------
when Attribute_Fraction =>
Fold_Ureal
(N, Eval_Fat.Fraction (P_Base_Type, Expr_Value_R (E1)), Static);
-----------------------
-- Has_Access_Values --
-----------------------
when Attribute_Has_Access_Values =>
Rewrite (N, New_Occurrence_Of
(Boolean_Literals (Has_Access_Values (P_Root_Type)), Loc));
Analyze_And_Resolve (N, Standard_Boolean);
-----------------------
-- Has_Discriminants --
-----------------------
when Attribute_Has_Discriminants =>
Rewrite (N, New_Occurrence_Of (
Boolean_Literals (Has_Discriminants (P_Entity)), Loc));
Analyze_And_Resolve (N, Standard_Boolean);
----------------------
-- Has_Same_Storage --
----------------------
when Attribute_Has_Same_Storage =>
null;
-----------------------
-- Has_Tagged_Values --
-----------------------
when Attribute_Has_Tagged_Values =>
Rewrite (N, New_Occurrence_Of
(Boolean_Literals (Has_Tagged_Component (P_Root_Type)), Loc));
Analyze_And_Resolve (N, Standard_Boolean);
--------------
-- Identity --
--------------
when Attribute_Identity =>
null;
-----------
-- Image --
-----------
-- Image is a scalar attribute, but is never static, because it is
-- not a static function (having a non-scalar argument (RM 4.9(22))
-- However, we can constant-fold the image of an enumeration literal
-- if names are available.
when Attribute_Image =>
if Is_Entity_Name (E1)
and then Ekind (Entity (E1)) = E_Enumeration_Literal
and then not Discard_Names (First_Subtype (Etype (E1)))
and then not Global_Discard_Names
then
declare
Lit : constant Entity_Id := Entity (E1);
Str : String_Id;
begin
Start_String;
Get_Unqualified_Decoded_Name_String (Chars (Lit));
Set_Casing (All_Upper_Case);
Store_String_Chars (Name_Buffer (1 .. Name_Len));
Str := End_String;
Rewrite (N, Make_String_Literal (Loc, Strval => Str));
Analyze_And_Resolve (N, Standard_String);
Set_Is_Static_Expression (N, False);
end;
end if;
-------------------
-- Integer_Value --
-------------------
-- We never try to fold Integer_Value (though perhaps we could???)
when Attribute_Integer_Value =>
null;
-------------------
-- Invalid_Value --
-------------------
-- Invalid_Value is a scalar attribute that is never static, because
-- the value is by design out of range.
when Attribute_Invalid_Value =>
null;
-----------
-- Large --
-----------
when Attribute_Large =>
-- For fixed-point, we use the identity:
-- T'Large = (2.0**T'Mantissa - 1.0) * T'Small
if Is_Fixed_Point_Type (P_Type) then
Rewrite (N,
Make_Op_Multiply (Loc,
Left_Opnd =>
Make_Op_Subtract (Loc,
Left_Opnd =>
Make_Op_Expon (Loc,
Left_Opnd =>
Make_Real_Literal (Loc, Ureal_2),
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix => P,
Attribute_Name => Name_Mantissa)),
Right_Opnd => Make_Real_Literal (Loc, Ureal_1)),
Right_Opnd =>
Make_Real_Literal (Loc, Small_Value (Entity (P)))));
Analyze_And_Resolve (N, C_Type);
-- Floating-point (Ada 83 compatibility)
else
-- Ada 83 attribute is defined as (RM83 3.5.8)
-- T'Large = 2.0**T'Emax * (1.0 - 2.0**(-T'Mantissa))
-- where
-- T'Emax = 4 * T'Mantissa
Fold_Ureal
(N,
Ureal_2 ** (4 * Mantissa) * (Ureal_1 - Ureal_2 ** (-Mantissa)),
True);
end if;
---------------
-- Lock_Free --
---------------
when Attribute_Lock_Free => Lock_Free : declare
V : constant Entity_Id := Boolean_Literals (Uses_Lock_Free (P_Type));
begin
Rewrite (N, New_Occurrence_Of (V, Loc));
-- Analyze and resolve as boolean. Note that this attribute is a
-- static attribute in GNAT.
Analyze_And_Resolve (N, Standard_Boolean);
Static := True;
Set_Is_Static_Expression (N);
end Lock_Free;
----------
-- Last --
----------
when Attribute_Last =>
Set_Bounds;
if Compile_Time_Known_Value (Hi_Bound) then
if Is_Real_Type (P_Type) then
Fold_Ureal (N, Expr_Value_R (Hi_Bound), Static);
else
Fold_Uint (N, Expr_Value (Hi_Bound), Static);
end if;
else
Check_Concurrent_Discriminant (Hi_Bound);
end if;
----------------
-- Last_Valid --
----------------
when Attribute_Last_Valid =>
if Has_Predicates (P_Type)
and then Has_Static_Predicate (P_Type)
then
declare
LastN : constant Node_Id :=
Last (Static_Discrete_Predicate (P_Type));
begin
if Nkind (LastN) = N_Range then
Fold_Uint (N, Expr_Value (High_Bound (LastN)), Static);
else
Fold_Uint (N, Expr_Value (LastN), Static);
end if;
end;
else
Set_Bounds;
Fold_Uint (N, Expr_Value (Hi_Bound), Static);
end if;
------------------
-- Leading_Part --
------------------
when Attribute_Leading_Part =>
Fold_Ureal
(N,
Eval_Fat.Leading_Part
(P_Base_Type, Expr_Value_R (E1), Expr_Value (E2)),
Static);
------------
-- Length --
------------
when Attribute_Length => Length : declare
Ind : Node_Id;
begin
-- If any index type is a formal type, or derived from one, the
-- bounds are not static. Treating them as static can produce
-- spurious warnings or improper constant folding.
Ind := First_Index (P_Type);
while Present (Ind) loop
if Is_Generic_Type (Root_Type (Etype (Ind))) then
return;
end if;
Next_Index (Ind);
end loop;
Set_Bounds;
-- For two compile time values, we can compute length
if Compile_Time_Known_Value (Lo_Bound)
and then Compile_Time_Known_Value (Hi_Bound)
then
Fold_Uint (N,
UI_Max (0, 1 + (Expr_Value (Hi_Bound) - Expr_Value (Lo_Bound))),
Static);
end if;
-- One more case is where Hi_Bound and Lo_Bound are compile-time
-- comparable, and we can figure out the difference between them.
declare
Diff : aliased Uint;
begin
case
Compile_Time_Compare
(Lo_Bound, Hi_Bound, Diff'Access, Assume_Valid => False)
is
when EQ =>
Fold_Uint (N, Uint_1, Static);
when GT =>
Fold_Uint (N, Uint_0, Static);
when LT =>
if Diff /= No_Uint then
Fold_Uint (N, Diff + 1, Static);
end if;
when others =>
null;
end case;
end;
end Length;
----------------
-- Loop_Entry --
----------------
-- Loop_Entry acts as an alias of a constant initialized to the prefix
-- of the said attribute at the point of entry into the related loop. As
-- such, the attribute reference does not need to be evaluated because
-- the prefix is the one that is evaluted.
when Attribute_Loop_Entry =>
null;
-------------
-- Machine --
-------------
when Attribute_Machine =>
Fold_Ureal
(N,
Eval_Fat.Machine
(P_Base_Type, Expr_Value_R (E1), Eval_Fat.Round, N),
Static);
------------------
-- Machine_Emax --
------------------
when Attribute_Machine_Emax =>
Fold_Uint (N, Machine_Emax_Value (P_Type), Static);
------------------
-- Machine_Emin --
------------------
when Attribute_Machine_Emin =>
Fold_Uint (N, Machine_Emin_Value (P_Type), Static);
----------------------
-- Machine_Mantissa --
----------------------
when Attribute_Machine_Mantissa =>
Fold_Uint (N, Machine_Mantissa_Value (P_Type), Static);
-----------------------
-- Machine_Overflows --
-----------------------
when Attribute_Machine_Overflows =>
-- Always true for fixed-point
if Is_Fixed_Point_Type (P_Type) then
Fold_Uint (N, True_Value, Static);
-- Floating point case
else
Fold_Uint (N,
UI_From_Int (Boolean'Pos (Machine_Overflows_On_Target)),
Static);
end if;
-------------------
-- Machine_Radix --
-------------------
when Attribute_Machine_Radix =>
if Is_Fixed_Point_Type (P_Type) then
if Is_Decimal_Fixed_Point_Type (P_Type)
and then Machine_Radix_10 (P_Type)
then
Fold_Uint (N, Uint_10, Static);
else
Fold_Uint (N, Uint_2, Static);
end if;
-- All floating-point type always have radix 2
else
Fold_Uint (N, Uint_2, Static);
end if;
----------------------
-- Machine_Rounding --
----------------------
-- Note: for the folding case, it is fine to treat Machine_Rounding
-- exactly the same way as Rounding, since this is one of the allowed
-- behaviors, and performance is not an issue here. It might be a bit
-- better to give the same result as it would give at run time, even
-- though the non-determinism is certainly permitted.
when Attribute_Machine_Rounding =>
Fold_Ureal
(N, Eval_Fat.Rounding (P_Base_Type, Expr_Value_R (E1)), Static);
--------------------
-- Machine_Rounds --
--------------------
when Attribute_Machine_Rounds =>
-- Always False for fixed-point
if Is_Fixed_Point_Type (P_Type) then
Fold_Uint (N, False_Value, Static);
-- Else yield proper floating-point result
else
Fold_Uint
(N, UI_From_Int (Boolean'Pos (Machine_Rounds_On_Target)),
Static);
end if;
------------------
-- Machine_Size --
------------------
-- Note: Machine_Size is identical to Object_Size
when Attribute_Machine_Size => Machine_Size : declare
P_TypeA : constant Entity_Id := Underlying_Type (P_Type);
begin
if Known_Esize (P_TypeA) then
Fold_Uint (N, Esize (P_TypeA), Static);
end if;
end Machine_Size;
--------------
-- Mantissa --
--------------
when Attribute_Mantissa =>
-- Fixed-point mantissa
if Is_Fixed_Point_Type (P_Type) then
-- Compile time foldable case
if Compile_Time_Known_Value (Type_Low_Bound (P_Type))
and then
Compile_Time_Known_Value (Type_High_Bound (P_Type))
then
-- The calculation of the obsolete Ada 83 attribute Mantissa
-- is annoying, because of AI00143, quoted here:
-- !question 84-01-10
-- Consider the model numbers for F:
-- type F is delta 1.0 range -7.0 .. 8.0;
-- The wording requires that F'MANTISSA be the SMALLEST
-- integer number for which each bound of the specified
-- range is either a model number or lies at most small
-- distant from a model number. This means F'MANTISSA
-- is required to be 3 since the range -7.0 .. 7.0 fits
-- in 3 signed bits, and 8 is "at most" 1.0 from a model
-- number, namely, 7. Is this analysis correct? Note that
-- this implies the upper bound of the range is not
-- represented as a model number.
-- !response 84-03-17
-- The analysis is correct. The upper and lower bounds for
-- a fixed point type can lie outside the range of model
-- numbers.
declare
Siz : Uint;
LBound : Ureal;
UBound : Ureal;
Bound : Ureal;
Max_Man : Uint;
begin
LBound := Expr_Value_R (Type_Low_Bound (P_Type));
UBound := Expr_Value_R (Type_High_Bound (P_Type));
Bound := UR_Max (UR_Abs (LBound), UR_Abs (UBound));
Max_Man := UR_Trunc (Bound / Small_Value (P_Type));
-- If the Bound is exactly a model number, i.e. a multiple
-- of Small, then we back it off by one to get the integer
-- value that must be representable.
if Small_Value (P_Type) * Max_Man = Bound then
Max_Man := Max_Man - 1;
end if;
-- Now find corresponding size = Mantissa value
Siz := Uint_0;
while 2 ** Siz < Max_Man loop
Siz := Siz + 1;
end loop;
Fold_Uint (N, Siz, Static);
end;
else
-- The case of dynamic bounds cannot be evaluated at compile
-- time. Instead we use a runtime routine (see Exp_Attr).
null;
end if;
-- Floating-point Mantissa
else
Fold_Uint (N, Mantissa, Static);
end if;
---------
-- Max --
---------
when Attribute_Max =>
if Is_Real_Type (P_Type) then
Fold_Ureal
(N, UR_Max (Expr_Value_R (E1), Expr_Value_R (E2)), Static);
else
Fold_Uint (N, UI_Max (Expr_Value (E1), Expr_Value (E2)), Static);
end if;
----------------------------------
-- Max_Alignment_For_Allocation --
----------------------------------
-- Max_Alignment_For_Allocation is usually the Alignment. However,
-- arrays are allocated with dope, so we need to take into account both
-- the alignment of the array, which comes from the component alignment,
-- and the alignment of the dope. Also, if the alignment is unknown, we
-- use the max (it's OK to be pessimistic).
when Attribute_Max_Alignment_For_Allocation => Max_Align : declare
A : Uint := UI_From_Int (Ttypes.Maximum_Alignment);
begin
if Known_Alignment (P_Type)
and then (not Is_Array_Type (P_Type) or else Alignment (P_Type) > A)
then
A := Alignment (P_Type);
end if;
Fold_Uint (N, A, Static);
end Max_Align;
----------------------------------
-- Max_Size_In_Storage_Elements --
----------------------------------
-- Max_Size_In_Storage_Elements is simply the Size rounded up to a
-- Storage_Unit boundary. We can fold any cases for which the size
-- is known by the front end.
when Attribute_Max_Size_In_Storage_Elements =>
if Known_Esize (P_Type) then
Fold_Uint (N,
(Esize (P_Type) + System_Storage_Unit - 1) /
System_Storage_Unit,
Static);
end if;
--------------------
-- Mechanism_Code --
--------------------
when Attribute_Mechanism_Code => Mechanism_Code : declare
Formal : Entity_Id;
Mech : Mechanism_Type;
Val : Int;
begin
if No (E1) then
Mech := Mechanism (P_Entity);
else
Val := UI_To_Int (Expr_Value (E1));
Formal := First_Formal (P_Entity);
for J in 1 .. Val - 1 loop
Next_Formal (Formal);
end loop;
Mech := Mechanism (Formal);
end if;
if Mech < 0 then
Fold_Uint (N, UI_From_Int (Int (-Mech)), Static);
end if;
end Mechanism_Code;
---------
-- Min --
---------
when Attribute_Min =>
if Is_Real_Type (P_Type) then
Fold_Ureal
(N, UR_Min (Expr_Value_R (E1), Expr_Value_R (E2)), Static);
else
Fold_Uint
(N, UI_Min (Expr_Value (E1), Expr_Value (E2)), Static);
end if;
---------
-- Mod --
---------
when Attribute_Mod =>
Fold_Uint
(N, UI_Mod (Expr_Value (E1), Modulus (P_Base_Type)), Static);
-----------
-- Model --
-----------
when Attribute_Model =>
Fold_Ureal
(N, Eval_Fat.Model (P_Base_Type, Expr_Value_R (E1)), Static);
----------------
-- Model_Emin --
----------------
when Attribute_Model_Emin =>
Fold_Uint (N, Model_Emin_Value (P_Base_Type), Static);
-------------------
-- Model_Epsilon --
-------------------
when Attribute_Model_Epsilon =>
Fold_Ureal (N, Model_Epsilon_Value (P_Base_Type), Static);
--------------------
-- Model_Mantissa --
--------------------
when Attribute_Model_Mantissa =>
Fold_Uint (N, Model_Mantissa_Value (P_Base_Type), Static);
-----------------
-- Model_Small --
-----------------
when Attribute_Model_Small =>
Fold_Ureal (N, Model_Small_Value (P_Base_Type), Static);
-------------
-- Modulus --
-------------
when Attribute_Modulus =>
Fold_Uint (N, Modulus (P_Type), Static);
--------------------
-- Null_Parameter --
--------------------
-- Cannot fold, we know the value sort of, but the whole point is
-- that there is no way to talk about this imaginary value except
-- by using the attribute, so we leave it the way it is.
when Attribute_Null_Parameter =>
null;
-----------------
-- Object_Size --
-----------------
-- The Object_Size attribute for a type returns the Esize of the
-- type and can be folded if this value is known.
when Attribute_Object_Size => Object_Size : declare
P_TypeA : constant Entity_Id := Underlying_Type (P_Type);
begin
if Known_Esize (P_TypeA) then
Fold_Uint (N, Esize (P_TypeA), Static);
end if;
end Object_Size;
----------------------
-- Overlaps_Storage --
----------------------
when Attribute_Overlaps_Storage =>
null;
-------------------------
-- Passed_By_Reference --
-------------------------
-- Scalar types are never passed by reference
when Attribute_Passed_By_Reference =>
Fold_Uint (N, False_Value, Static);
---------
-- Pos --
---------
when Attribute_Pos =>
Fold_Uint (N, Expr_Value (E1), Static);
----------
-- Pred --
----------
when Attribute_Pred =>
-- Floating-point case
if Is_Floating_Point_Type (P_Type) then
Fold_Ureal
(N, Eval_Fat.Pred (P_Base_Type, Expr_Value_R (E1)), Static);
-- Fixed-point case
elsif Is_Fixed_Point_Type (P_Type) then
Fold_Ureal
(N, Expr_Value_R (E1) - Small_Value (P_Type), True);
-- Modular integer case (wraps)
elsif Is_Modular_Integer_Type (P_Type) then
Fold_Uint (N, (Expr_Value (E1) - 1) mod Modulus (P_Type), Static);
-- Other scalar cases
else
pragma Assert (Is_Scalar_Type (P_Type));
if Is_Enumeration_Type (P_Type)
and then Expr_Value (E1) =
Expr_Value (Type_Low_Bound (P_Base_Type))
then
Apply_Compile_Time_Constraint_Error
(N, "Pred of `&''First`",
CE_Overflow_Check_Failed,
Ent => P_Base_Type,
Warn => not Static);
Check_Expressions;
return;
end if;
Fold_Uint (N, Expr_Value (E1) - 1, Static);
end if;
-----------
-- Range --
-----------
-- No processing required, because by this stage, Range has been
-- replaced by First .. Last, so this branch can never be taken.
when Attribute_Range =>
raise Program_Error;
------------------
-- Range_Length --
------------------
when Attribute_Range_Length => Range_Length : declare
Diff : aliased Uint;
begin
Set_Bounds;
-- Can fold if both bounds are compile time known
if Compile_Time_Known_Value (Hi_Bound)
and then Compile_Time_Known_Value (Lo_Bound)
then
Fold_Uint (N,
UI_Max
(0, Expr_Value (Hi_Bound) - Expr_Value (Lo_Bound) + 1),
Static);
end if;
-- One more case is where Hi_Bound and Lo_Bound are compile-time
-- comparable, and we can figure out the difference between them.
case Compile_Time_Compare
(Lo_Bound, Hi_Bound, Diff'Access, Assume_Valid => False)
is
when EQ =>
Fold_Uint (N, Uint_1, Static);
when GT =>
Fold_Uint (N, Uint_0, Static);
when LT =>
if Diff /= No_Uint then
Fold_Uint (N, Diff + 1, Static);
end if;
when others =>
null;
end case;
end Range_Length;
---------
-- Ref --
---------
when Attribute_Ref =>
Fold_Uint (N, Expr_Value (E1), Static);
---------------
-- Remainder --
---------------
when Attribute_Remainder => Remainder : declare
X : constant Ureal := Expr_Value_R (E1);
Y : constant Ureal := Expr_Value_R (E2);
begin
if UR_Is_Zero (Y) then
Apply_Compile_Time_Constraint_Error
(N, "division by zero in Remainder",
CE_Overflow_Check_Failed,
Warn => not Static);
Check_Expressions;
return;
end if;
Fold_Ureal (N, Eval_Fat.Remainder (P_Base_Type, X, Y), Static);
end Remainder;
-----------------
-- Restriction --
-----------------
when Attribute_Restriction_Set =>
Rewrite (N, New_Occurrence_Of (Standard_False, Loc));
Set_Is_Static_Expression (N);
-----------
-- Round --
-----------
when Attribute_Round => Round : declare
Sr : Ureal;
Si : Uint;
begin
-- First we get the (exact result) in units of small
Sr := Expr_Value_R (E1) / Small_Value (C_Type);
-- Now round that exactly to an integer
Si := UR_To_Uint (Sr);
-- Finally the result is obtained by converting back to real
Fold_Ureal (N, Si * Small_Value (C_Type), Static);
end Round;
--------------
-- Rounding --
--------------
when Attribute_Rounding =>
Fold_Ureal
(N, Eval_Fat.Rounding (P_Base_Type, Expr_Value_R (E1)), Static);
---------------
-- Safe_Emax --
---------------
when Attribute_Safe_Emax =>
Fold_Uint (N, Safe_Emax_Value (P_Type), Static);
----------------
-- Safe_First --
----------------
when Attribute_Safe_First =>
Fold_Ureal (N, Safe_First_Value (P_Type), Static);
----------------
-- Safe_Large --
----------------
when Attribute_Safe_Large =>
if Is_Fixed_Point_Type (P_Type) then
Fold_Ureal
(N, Expr_Value_R (Type_High_Bound (P_Base_Type)), Static);
else
Fold_Ureal (N, Safe_Last_Value (P_Type), Static);
end if;
---------------
-- Safe_Last --
---------------
when Attribute_Safe_Last =>
Fold_Ureal (N, Safe_Last_Value (P_Type), Static);
----------------
-- Safe_Small --
----------------
when Attribute_Safe_Small =>
-- In Ada 95, the old Ada 83 attribute Safe_Small is redundant
-- for fixed-point, since is the same as Small, but we implement
-- it for backwards compatibility.
if Is_Fixed_Point_Type (P_Type) then
Fold_Ureal (N, Small_Value (P_Type), Static);
-- Ada 83 Safe_Small for floating-point cases
else
Fold_Ureal (N, Model_Small_Value (P_Type), Static);
end if;
-----------
-- Scale --
-----------
when Attribute_Scale =>
Fold_Uint (N, Scale_Value (P_Type), Static);
-------------
-- Scaling --
-------------
when Attribute_Scaling =>
Fold_Ureal
(N,
Eval_Fat.Scaling
(P_Base_Type, Expr_Value_R (E1), Expr_Value (E2)),
Static);
------------------
-- Signed_Zeros --
------------------
when Attribute_Signed_Zeros =>
Fold_Uint
(N, UI_From_Int (Boolean'Pos (Has_Signed_Zeros (P_Type))), Static);
----------
-- Size --
----------
-- Size attribute returns the RM size. All scalar types can be folded,
-- as well as any types for which the size is known by the front end,
-- including any type for which a size attribute is specified. This is
-- one of the places where it is annoying that a size of zero means two
-- things (zero size for scalars, unspecified size for non-scalars).
when Attribute_Size
| Attribute_VADS_Size
=>
Size : declare
P_TypeA : constant Entity_Id := Underlying_Type (P_Type);
begin
if Is_Scalar_Type (P_TypeA)
or else RM_Size (P_TypeA) /= Uint_0
then
-- VADS_Size case
if Id = Attribute_VADS_Size or else Use_VADS_Size then
declare
S : constant Node_Id := Size_Clause (P_TypeA);
begin
-- If a size clause applies, then use the size from it.
-- This is one of the rare cases where we can use the
-- Size_Clause field for a subtype when Has_Size_Clause
-- is False. Consider:
-- type x is range 1 .. 64;
-- for x'size use 12;
-- subtype y is x range 0 .. 3;
-- Here y has a size clause inherited from x, but
-- normally it does not apply, and y'size is 2. However,
-- y'VADS_Size is indeed 12 and not 2.
if Present (S)
and then Is_OK_Static_Expression (Expression (S))
then
Fold_Uint (N, Expr_Value (Expression (S)), Static);
-- If no size is specified, then we simply use the object
-- size in the VADS_Size case (e.g. Natural'Size is equal
-- to Integer'Size, not one less).
else
Fold_Uint (N, Esize (P_TypeA), Static);
end if;
end;
-- Normal case (Size) in which case we want the RM_Size
else
Fold_Uint (N, RM_Size (P_TypeA), Static);
end if;
end if;
end Size;
-----------
-- Small --
-----------
when Attribute_Small =>
-- The floating-point case is present only for Ada 83 compatibility.
-- Note that strictly this is an illegal addition, since we are
-- extending an Ada 95 defined attribute, but we anticipate an
-- ARG ruling that will permit this.
if Is_Floating_Point_Type (P_Type) then
-- Ada 83 attribute is defined as (RM83 3.5.8)
-- T'Small = 2.0**(-T'Emax - 1)
-- where
-- T'Emax = 4 * T'Mantissa
Fold_Ureal (N, Ureal_2 ** ((-(4 * Mantissa)) - 1), Static);
-- Normal Ada 95 fixed-point case
else
Fold_Ureal (N, Small_Value (P_Type), True);
end if;
-----------------
-- Stream_Size --
-----------------
when Attribute_Stream_Size =>
null;
----------
-- Succ --
----------
when Attribute_Succ =>
-- Floating-point case
if Is_Floating_Point_Type (P_Type) then
Fold_Ureal
(N, Eval_Fat.Succ (P_Base_Type, Expr_Value_R (E1)), Static);
-- Fixed-point case
elsif Is_Fixed_Point_Type (P_Type) then
Fold_Ureal (N, Expr_Value_R (E1) + Small_Value (P_Type), Static);
-- Modular integer case (wraps)
elsif Is_Modular_Integer_Type (P_Type) then
Fold_Uint (N, (Expr_Value (E1) + 1) mod Modulus (P_Type), Static);
-- Other scalar cases
else
pragma Assert (Is_Scalar_Type (P_Type));
if Is_Enumeration_Type (P_Type)
and then Expr_Value (E1) =
Expr_Value (Type_High_Bound (P_Base_Type))
then
Apply_Compile_Time_Constraint_Error
(N, "Succ of `&''Last`",
CE_Overflow_Check_Failed,
Ent => P_Base_Type,
Warn => not Static);
Check_Expressions;
return;
else
Fold_Uint (N, Expr_Value (E1) + 1, Static);
end if;
end if;
----------------
-- Truncation --
----------------
when Attribute_Truncation =>
Fold_Ureal
(N,
Eval_Fat.Truncation (P_Base_Type, Expr_Value_R (E1)),
Static);
----------------
-- Type_Class --
----------------
when Attribute_Type_Class => Type_Class : declare
Typ : constant Entity_Id := Underlying_Type (P_Base_Type);
Id : RE_Id;
begin
if Is_Descendant_Of_Address (Typ) then
Id := RE_Type_Class_Address;
elsif Is_Enumeration_Type (Typ) then
Id := RE_Type_Class_Enumeration;
elsif Is_Integer_Type (Typ) then
Id := RE_Type_Class_Integer;
elsif Is_Fixed_Point_Type (Typ) then
Id := RE_Type_Class_Fixed_Point;
elsif Is_Floating_Point_Type (Typ) then
Id := RE_Type_Class_Floating_Point;
elsif Is_Array_Type (Typ) then
Id := RE_Type_Class_Array;
elsif Is_Record_Type (Typ) then
Id := RE_Type_Class_Record;
elsif Is_Access_Type (Typ) then
Id := RE_Type_Class_Access;
elsif Is_Task_Type (Typ) then
Id := RE_Type_Class_Task;
-- We treat protected types like task types. It would make more
-- sense to have another enumeration value, but after all the
-- whole point of this feature is to be exactly DEC compatible,
-- and changing the type Type_Class would not meet this requirement.
elsif Is_Protected_Type (Typ) then
Id := RE_Type_Class_Task;
-- Not clear if there are any other possibilities, but if there
-- are, then we will treat them as the address case.
else
Id := RE_Type_Class_Address;
end if;
Rewrite (N, New_Occurrence_Of (RTE (Id), Loc));
end Type_Class;
-----------------------
-- Unbiased_Rounding --
-----------------------
when Attribute_Unbiased_Rounding =>
Fold_Ureal
(N,
Eval_Fat.Unbiased_Rounding (P_Base_Type, Expr_Value_R (E1)),
Static);
-------------------------
-- Unconstrained_Array --
-------------------------
when Attribute_Unconstrained_Array => Unconstrained_Array : declare
Typ : constant Entity_Id := Underlying_Type (P_Type);
begin
Rewrite (N, New_Occurrence_Of (
Boolean_Literals (
Is_Array_Type (P_Type)
and then not Is_Constrained (Typ)), Loc));
-- Analyze and resolve as boolean, note that this attribute is
-- a static attribute in GNAT.
Analyze_And_Resolve (N, Standard_Boolean);
Static := True;
Set_Is_Static_Expression (N, True);
end Unconstrained_Array;
-- Attribute Update is never static
when Attribute_Update =>
return;
---------------
-- VADS_Size --
---------------
-- Processing is shared with Size
---------
-- Val --
---------
when Attribute_Val =>
if Expr_Value (E1) < Expr_Value (Type_Low_Bound (P_Base_Type))
or else
Expr_Value (E1) > Expr_Value (Type_High_Bound (P_Base_Type))
then
Apply_Compile_Time_Constraint_Error
(N, "Val expression out of range",
CE_Range_Check_Failed,
Warn => not Static);
Check_Expressions;
return;
else
Fold_Uint (N, Expr_Value (E1), Static);
end if;
----------------
-- Value_Size --
----------------
-- The Value_Size attribute for a type returns the RM size of the type.
-- This an always be folded for scalar types, and can also be folded for
-- non-scalar types if the size is set. This is one of the places where
-- it is annoying that a size of zero means two things!
when Attribute_Value_Size => Value_Size : declare
P_TypeA : constant Entity_Id := Underlying_Type (P_Type);
begin
if Is_Scalar_Type (P_TypeA) or else RM_Size (P_TypeA) /= Uint_0 then
Fold_Uint (N, RM_Size (P_TypeA), Static);
end if;
end Value_Size;
-------------
-- Version --
-------------
-- Version can never be static
when Attribute_Version =>
null;
----------------
-- Wide_Image --
----------------
-- Wide_Image is a scalar attribute, but is never static, because it
-- is not a static function (having a non-scalar argument (RM 4.9(22))
when Attribute_Wide_Image =>
null;
---------------------
-- Wide_Wide_Image --
---------------------
-- Wide_Wide_Image is a scalar attribute but is never static, because it
-- is not a static function (having a non-scalar argument (RM 4.9(22)).
when Attribute_Wide_Wide_Image =>
null;
---------------------
-- Wide_Wide_Width --
---------------------
-- Processing for Wide_Wide_Width is combined with Width
----------------
-- Wide_Width --
----------------
-- Processing for Wide_Width is combined with Width
-----------
-- Width --
-----------
-- This processing also handles the case of Wide_[Wide_]Width
when Attribute_Width
| Attribute_Wide_Width
| Attribute_Wide_Wide_Width
=>
if Compile_Time_Known_Bounds (P_Type) then
-- Floating-point types
if Is_Floating_Point_Type (P_Type) then
-- Width is zero for a null range (RM 3.5 (38))
if Expr_Value_R (Type_High_Bound (P_Type)) <
Expr_Value_R (Type_Low_Bound (P_Type))
then
Fold_Uint (N, Uint_0, Static);
else
-- For floating-point, we have +N.dddE+nnn where length
-- of ddd is determined by type'Digits - 1, but is one
-- if Digits is one (RM 3.5 (33)).
-- nnn is set to 2 for Short_Float and Float (32 bit
-- floats), and 3 for Long_Float and Long_Long_Float.
-- For machines where Long_Long_Float is the IEEE
-- extended precision type, the exponent takes 4 digits.
declare
Len : Int :=
Int'Max (2, UI_To_Int (Digits_Value (P_Type)));
begin
if Esize (P_Type) <= 32 then
Len := Len + 6;
elsif Esize (P_Type) = 64 then
Len := Len + 7;
else
Len := Len + 8;
end if;
Fold_Uint (N, UI_From_Int (Len), Static);
end;
end if;
-- Fixed-point types
elsif Is_Fixed_Point_Type (P_Type) then
-- Width is zero for a null range (RM 3.5 (38))
if Expr_Value (Type_High_Bound (P_Type)) <
Expr_Value (Type_Low_Bound (P_Type))
then
Fold_Uint (N, Uint_0, Static);
-- The non-null case depends on the specific real type
else
-- For fixed-point type width is Fore + 1 + Aft (RM 3.5(34))
Fold_Uint
(N, UI_From_Int (Fore_Value + 1) + Aft_Value (P_Type),
Static);
end if;
-- Discrete types
else
declare
R : constant Entity_Id := Root_Type (P_Type);
Lo : constant Uint := Expr_Value (Type_Low_Bound (P_Type));
Hi : constant Uint := Expr_Value (Type_High_Bound (P_Type));
W : Nat;
Wt : Nat;
T : Uint;
L : Node_Id;
C : Character;
begin
-- Empty ranges
if Lo > Hi then
W := 0;
-- Width for types derived from Standard.Character
-- and Standard.Wide_[Wide_]Character.
elsif Is_Standard_Character_Type (P_Type) then
W := 0;
-- Set W larger if needed
for J in UI_To_Int (Lo) .. UI_To_Int (Hi) loop
-- All wide characters look like Hex_hhhhhhhh
if J > 255 then
-- No need to compute this more than once
exit;
else
C := Character'Val (J);
-- Test for all cases where Character'Image
-- yields an image that is longer than three
-- characters. First the cases of Reserved_xxx
-- names (length = 12).
case C is
when Reserved_128
| Reserved_129
| Reserved_132
| Reserved_153
=>
Wt := 12;
when BS
| CR
| EM
| FF
| FS
| GS
| HT
| LF
| MW
| PM
| RI
| RS
| SI
| SO
| ST
| US
| VT
=>
Wt := 2;
when ACK
| APC
| BEL
| BPH
| CAN
| CCH
| CSI
| DC1
| DC2
| DC3
| DC4
| DCS
| DEL
| DLE
| ENQ
| EOT
| EPA
| ESA
| ESC
| ETB
| ETX
| HTJ
| HTS
| NAK
| NBH
| NEL
| NUL
| OSC
| PLD
| PLU
| PU1
| PU2
| SCI
| SOH
| SOS
| SPA
| SS2
| SS3
| SSA
| STS
| STX
| SUB
| SYN
| VTS
=>
Wt := 3;
when Space .. Tilde
| No_Break_Space .. LC_Y_Diaeresis
=>
-- Special case of soft hyphen in Ada 2005
if C = Character'Val (16#AD#)
and then Ada_Version >= Ada_2005
then
Wt := 11;
else
Wt := 3;
end if;
end case;
W := Int'Max (W, Wt);
end if;
end loop;
-- Width for types derived from Standard.Boolean
elsif R = Standard_Boolean then
if Lo = 0 then
W := 5; -- FALSE
else
W := 4; -- TRUE
end if;
-- Width for integer types
elsif Is_Integer_Type (P_Type) then
T := UI_Max (abs Lo, abs Hi);
W := 2;
while T >= 10 loop
W := W + 1;
T := T / 10;
end loop;
-- User declared enum type with discard names
elsif Discard_Names (R) then
-- If range is null, result is zero, that has already
-- been dealt with, so what we need is the power of ten
-- that accommodates the Pos of the largest value, which
-- is the high bound of the range + one for the space.
W := 1;
T := Hi;
while T /= 0 loop
T := T / 10;
W := W + 1;
end loop;
-- Only remaining possibility is user declared enum type
-- with normal case of Discard_Names not active.
else
pragma Assert (Is_Enumeration_Type (P_Type));
W := 0;
L := First_Literal (P_Type);
while Present (L) loop
-- Only pay attention to in range characters
if Lo <= Enumeration_Pos (L)
and then Enumeration_Pos (L) <= Hi
then
-- For Width case, use decoded name
if Id = Attribute_Width then
Get_Decoded_Name_String (Chars (L));
Wt := Nat (Name_Len);
-- For Wide_[Wide_]Width, use encoded name, and
-- then adjust for the encoding.
else
Get_Name_String (Chars (L));
-- Character literals are always of length 3
if Name_Buffer (1) = 'Q' then
Wt := 3;
-- Otherwise loop to adjust for upper/wide chars
else
Wt := Nat (Name_Len);
for J in 1 .. Name_Len loop
if Name_Buffer (J) = 'U' then
Wt := Wt - 2;
elsif Name_Buffer (J) = 'W' then
Wt := Wt - 4;
end if;
end loop;
end if;
end if;
W := Int'Max (W, Wt);
end if;
Next_Literal (L);
end loop;
end if;
Fold_Uint (N, UI_From_Int (W), Static);
end;
end if;
end if;
-- The following attributes denote functions that cannot be folded
when Attribute_From_Any
| Attribute_To_Any
| Attribute_TypeCode
=>
null;
-- The following attributes can never be folded, and furthermore we
-- should not even have entered the case statement for any of these.
-- Note that in some cases, the values have already been folded as
-- a result of the processing in Analyze_Attribute or earlier in
-- this procedure.
when Attribute_Abort_Signal
| Attribute_Access
| Attribute_Address
| Attribute_Address_Size
| Attribute_Asm_Input
| Attribute_Asm_Output
| Attribute_Base
| Attribute_Bit_Order
| Attribute_Bit_Position
| Attribute_Callable
| Attribute_Caller
| Attribute_Class
| Attribute_Code_Address
| Attribute_Compiler_Version
| Attribute_Count
| Attribute_Default_Bit_Order
| Attribute_Default_Scalar_Storage_Order
| Attribute_Deref
| Attribute_Elaborated
| Attribute_Elab_Body
| Attribute_Elab_Spec
| Attribute_Elab_Subp_Body
| Attribute_Enabled
| Attribute_External_Tag
| Attribute_Fast_Math
| Attribute_First_Bit
| Attribute_Img
| Attribute_Input
| Attribute_Initialized
| Attribute_Last_Bit
| Attribute_Library_Level
| Attribute_Max_Integer_Size
| Attribute_Maximum_Alignment
| Attribute_Old
| Attribute_Output
| Attribute_Partition_ID
| Attribute_Pool_Address
| Attribute_Position
| Attribute_Priority
| Attribute_Put_Image
| Attribute_Read
| Attribute_Result
| Attribute_Scalar_Storage_Order
| Attribute_Simple_Storage_Pool
| Attribute_Storage_Pool
| Attribute_Storage_Size
| Attribute_Storage_Unit
| Attribute_Stub_Type
| Attribute_System_Allocator_Alignment
| Attribute_Tag
| Attribute_Target_Name
| Attribute_Terminated
| Attribute_To_Address
| Attribute_Type_Key
| Attribute_Unchecked_Access
| Attribute_Universal_Literal_String
| Attribute_Unrestricted_Access
| Attribute_Valid
| Attribute_Valid_Scalars
| Attribute_Value
| Attribute_Wchar_T_Size
| Attribute_Wide_Value
| Attribute_Wide_Wide_Value
| Attribute_Word_Size
| Attribute_Write
=>
raise Program_Error;
end case;
-- At the end of the case, one more check. If we did a static evaluation
-- so that the result is now a literal, then set Is_Static_Expression
-- in the constant only if the prefix type is a static subtype. For
-- non-static subtypes, the folding is still OK, but not static.
-- An exception is the GNAT attribute Constrained_Array which is
-- defined to be a static attribute in all cases.
if Nkind (N) in N_Integer_Literal
| N_Real_Literal
| N_Character_Literal
| N_String_Literal
or else (Is_Entity_Name (N)
and then Ekind (Entity (N)) = E_Enumeration_Literal)
then
Set_Is_Static_Expression (N, Static);
-- If this is still an attribute reference, then it has not been folded
-- and that means that its expressions are in a non-static context.
elsif Nkind (N) = N_Attribute_Reference then
Check_Expressions;
-- Note: the else case not covered here are odd cases where the
-- processing has transformed the attribute into something other
-- than a constant. Nothing more to do in such cases.
else
null;
end if;
end Eval_Attribute;
------------------------------
-- Is_Anonymous_Tagged_Base --
------------------------------
function Is_Anonymous_Tagged_Base
(Anon : Entity_Id;
Typ : Entity_Id) return Boolean
is
begin
return
Anon = Current_Scope
and then Is_Itype (Anon)
and then Associated_Node_For_Itype (Anon) = Parent (Typ);
end Is_Anonymous_Tagged_Base;
--------------------------------
-- Name_Implies_Lvalue_Prefix --
--------------------------------
function Name_Implies_Lvalue_Prefix (Nam : Name_Id) return Boolean is
pragma Assert (Is_Attribute_Name (Nam));
begin
return Attribute_Name_Implies_Lvalue_Prefix (Get_Attribute_Id (Nam));
end Name_Implies_Lvalue_Prefix;
-----------------------
-- Resolve_Attribute --
-----------------------
procedure Resolve_Attribute (N : Node_Id; Typ : Entity_Id) is
Loc : constant Source_Ptr := Sloc (N);
P : constant Node_Id := Prefix (N);
Aname : constant Name_Id := Attribute_Name (N);
Attr_Id : constant Attribute_Id := Get_Attribute_Id (Aname);
Btyp : constant Entity_Id := Base_Type (Typ);
Des_Btyp : Entity_Id;
Index : Interp_Index;
It : Interp;
Nom_Subt : Entity_Id;
procedure Accessibility_Message;
-- Error, or warning within an instance, if the static accessibility
-- rules of 3.10.2 are violated.
function Declared_Within_Generic_Unit
(Entity : Entity_Id;
Generic_Unit : Node_Id) return Boolean;
-- Returns True if Declared_Entity is declared within the declarative
-- region of Generic_Unit; otherwise returns False.
function Prefix_With_Safe_Accessibility_Level return Boolean;
-- Return True if the prefix does not have a value conversion of an
-- array because a value conversion is like an aggregate with respect
-- to determining accessibility level (RM 3.10.2); even if evaluation
-- of a value conversion is guaranteed to not create a new object,
-- accessibility rules are defined as if it might.
---------------------------
-- Accessibility_Message --
---------------------------
procedure Accessibility_Message is
Indic : Node_Id := Parent (Parent (N));
begin
-- In an instance, this is a runtime check, but one we
-- know will fail, so generate an appropriate warning.
if In_Instance_Body then
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_F
("non-local pointer cannot point to local object<<", P);
Error_Msg_F ("\Program_Error [<<", P);
Rewrite (N,
Make_Raise_Program_Error (Loc,
Reason => PE_Accessibility_Check_Failed));
Set_Etype (N, Typ);
return;
else
Error_Msg_F ("non-local pointer cannot point to local object", P);
-- Check for case where we have a missing access definition
if Is_Record_Type (Current_Scope)
and then
Nkind (Parent (N)) in N_Discriminant_Association
| N_Index_Or_Discriminant_Constraint
then
Indic := Parent (Parent (N));
while Present (Indic)
and then Nkind (Indic) /= N_Subtype_Indication
loop
Indic := Parent (Indic);
end loop;
if Present (Indic) then
Error_Msg_NE
("\use an access definition for" &
" the access discriminant of&",
N, Entity (Subtype_Mark (Indic)));
end if;
end if;
end if;
end Accessibility_Message;
----------------------------------
-- Declared_Within_Generic_Unit --
----------------------------------
function Declared_Within_Generic_Unit
(Entity : Entity_Id;
Generic_Unit : Node_Id) return Boolean
is
Generic_Encloser : Node_Id := Enclosing_Generic_Unit (Entity);
begin
while Present (Generic_Encloser) loop
if Generic_Encloser = Generic_Unit then
return True;
end if;
-- We have to step to the scope of the generic's entity, because
-- otherwise we'll just get back the same generic.
Generic_Encloser :=
Enclosing_Generic_Unit
(Scope (Defining_Entity (Generic_Encloser)));
end loop;
return False;
end Declared_Within_Generic_Unit;
------------------------------------------
-- Prefix_With_Safe_Accessibility_Level --
------------------------------------------
function Prefix_With_Safe_Accessibility_Level return Boolean is
function Safe_Value_Conversions return Boolean;
-- Return False if the prefix has a value conversion of an array type
----------------------------
-- Safe_Value_Conversions --
----------------------------
function Safe_Value_Conversions return Boolean is
PP : Node_Id := P;
begin
loop
if Nkind (PP) in N_Selected_Component | N_Indexed_Component then
PP := Prefix (PP);
elsif Comes_From_Source (PP)
and then Nkind (PP) in N_Type_Conversion
| N_Unchecked_Type_Conversion
and then Is_Array_Type (Etype (PP))
then
return False;
elsif Comes_From_Source (PP)
and then Nkind (PP) = N_Qualified_Expression
and then Is_Array_Type (Etype (PP))
and then Nkind (Original_Node (Expression (PP))) in
N_Aggregate | N_Extension_Aggregate
then
return False;
else
exit;
end if;
end loop;
return True;
end Safe_Value_Conversions;
-- Start of processing for Prefix_With_Safe_Accessibility_Level
begin
-- No check required for unchecked and unrestricted access
if Attr_Id = Attribute_Unchecked_Access
or else Attr_Id = Attribute_Unrestricted_Access
then
return True;
-- Check value conversions
elsif Ekind (Btyp) = E_General_Access_Type
and then not Safe_Value_Conversions
then
return False;
end if;
return True;
end Prefix_With_Safe_Accessibility_Level;
-- Start of processing for Resolve_Attribute
begin
-- If error during analysis, no point in continuing, except for array
-- types, where we get better recovery by using unconstrained indexes
-- than nothing at all (see Check_Array_Type).
if Error_Posted (N)
and then Attr_Id /= Attribute_First
and then Attr_Id /= Attribute_Last
and then Attr_Id /= Attribute_Length
and then Attr_Id /= Attribute_Range
then
return;
end if;
-- If attribute was universal type, reset to actual type
if Etype (N) = Universal_Integer
or else Etype (N) = Universal_Real
then
Set_Etype (N, Typ);
end if;
-- Remaining processing depends on attribute
case Attr_Id is
------------
-- Access --
------------
-- For access attributes, if the prefix denotes an entity, it is
-- interpreted as a name, never as a call. It may be overloaded,
-- in which case resolution uses the profile of the context type.
-- Otherwise prefix must be resolved.
when Attribute_Access
| Attribute_Unchecked_Access
| Attribute_Unrestricted_Access
=>
-- Note possible modification if we have a variable
if Is_Variable (P) then
declare
PN : constant Node_Id := Parent (N);
Nm : Node_Id;
Note : Boolean := True;
-- Skip this for the case of Unrestricted_Access occuring in
-- the context of a Valid check, since this otherwise leads
-- to a missed warning (the Valid check does not really
-- modify!) If this case, Note will be reset to False.
-- Skip it as well if the type is an Access_To_Constant,
-- given that no use of the value can modify the prefix.
begin
if Attr_Id = Attribute_Unrestricted_Access
and then Nkind (PN) = N_Function_Call
then
Nm := Name (PN);
if Nkind (Nm) = N_Expanded_Name
and then Chars (Nm) = Name_Valid
and then Nkind (Prefix (Nm)) = N_Identifier
and then Chars (Prefix (Nm)) = Name_Attr_Long_Float
then
Note := False;
end if;
elsif Is_Access_Constant (Typ) then
Note := False;
end if;
if Note then
Note_Possible_Modification (P, Sure => False);
end if;
end;
end if;
-- Case where prefix is an entity name
if Is_Entity_Name (P) then
-- Deal with case where prefix itself is overloaded
if Is_Overloaded (P) then
Get_First_Interp (P, Index, It);
while Present (It.Nam) loop
if Type_Conformant (Designated_Type (Typ), It.Nam) then
Set_Entity (P, It.Nam);
-- The prefix is definitely NOT overloaded anymore at
-- this point, so we reset the Is_Overloaded flag to
-- avoid any confusion when reanalyzing the node.
Set_Is_Overloaded (P, False);
Set_Is_Overloaded (N, False);
Generate_Reference (Entity (P), P);
exit;
end if;
Get_Next_Interp (Index, It);
end loop;
-- If Prefix is a subprogram name, this reference freezes,
-- but not if within spec expression mode. The profile of
-- the subprogram is not frozen at this point.
if not In_Spec_Expression then
Freeze_Before (N, Entity (P), Do_Freeze_Profile => False);
end if;
-- If it is a type, there is nothing to resolve.
-- If it is a subprogram, do not freeze its profile.
-- If it is an object, complete its resolution.
elsif Is_Overloadable (Entity (P)) then
if not In_Spec_Expression then
Freeze_Before (N, Entity (P), Do_Freeze_Profile => False);
end if;
-- Nothing to do if prefix is a type name
elsif Is_Type (Entity (P)) then
null;
-- Otherwise non-overloaded other case, resolve the prefix
else
Resolve (P);
end if;
-- Some further error checks
Error_Msg_Name_1 := Aname;
if not Is_Entity_Name (P) then
null;
elsif Is_Overloadable (Entity (P))
and then Is_Abstract_Subprogram (Entity (P))
then
Error_Msg_F ("prefix of % attribute cannot be abstract", P);
Set_Etype (N, Any_Type);
elsif Ekind (Entity (P)) = E_Enumeration_Literal then
Error_Msg_F
("prefix of % attribute cannot be enumeration literal", P);
Set_Etype (N, Any_Type);
-- An attempt to take 'Access of a function that renames an
-- enumeration literal. Issue a specialized error message.
elsif Ekind (Entity (P)) = E_Function
and then Present (Alias (Entity (P)))
and then Ekind (Alias (Entity (P))) = E_Enumeration_Literal
then
Error_Msg_F
("prefix of % attribute cannot be function renaming "
& "an enumeration literal", P);
Set_Etype (N, Any_Type);
elsif Convention (Entity (P)) = Convention_Intrinsic then
Error_Msg_F ("prefix of % attribute cannot be intrinsic", P);
Set_Etype (N, Any_Type);
end if;
-- Assignments, return statements, components of aggregates,
-- generic instantiations will require convention checks if
-- the type is an access to subprogram. Given that there will
-- also be accessibility checks on those, this is where the
-- checks can eventually be centralized ???
if Ekind (Btyp) in E_Access_Protected_Subprogram_Type
| E_Access_Subprogram_Type
| E_Anonymous_Access_Protected_Subprogram_Type
| E_Anonymous_Access_Subprogram_Type
then
-- Deal with convention mismatch
if Convention (Designated_Type (Btyp)) /=
Convention (Entity (P))
then
-- The rule in 6.3.1 (8) deserves a special error
-- message.
if Convention (Btyp) = Convention_Intrinsic
and then Nkind (Parent (N)) = N_Procedure_Call_Statement
and then Is_Entity_Name (Name (Parent (N)))
and then Inside_A_Generic
then
declare
Subp : constant Entity_Id :=
Entity (Name (Parent (N)));
begin
if Convention (Subp) = Convention_Intrinsic then
Error_Msg_FE
("?subprogram and its formal access "
& "parameters have convention Intrinsic",
Parent (N), Subp);
Error_Msg_N
("actual cannot be access attribute", N);
end if;
end;
else
Error_Msg_FE
("subprogram & has wrong convention", P, Entity (P));
Error_Msg_Sloc := Sloc (Btyp);
Error_Msg_FE ("\does not match & declared#", P, Btyp);
end if;
if not Is_Itype (Btyp)
and then not Has_Convention_Pragma (Btyp)
and then Convention (Entity (P)) /= Convention_Intrinsic
then
Error_Msg_FE
("\probable missing pragma Convention for &",
P, Btyp);
end if;
else
Check_Subtype_Conformant
(New_Id => Entity (P),
Old_Id => Designated_Type (Btyp),
Err_Loc => P);
end if;
if Attr_Id = Attribute_Unchecked_Access then
Error_Msg_Name_1 := Aname;
Error_Msg_F
("attribute% cannot be applied to a subprogram", P);
elsif Aname = Name_Unrestricted_Access then
null; -- Nothing to check
-- Check the static accessibility rule of 3.10.2(32).
-- This rule also applies within the private part of an
-- instantiation. This rule does not apply to anonymous
-- access-to-subprogram types in access parameters.
elsif Attr_Id = Attribute_Access
and then not In_Instance_Body
and then
(Ekind (Btyp) = E_Access_Subprogram_Type
or else Is_Local_Anonymous_Access (Btyp))
and then Subprogram_Access_Level (Entity (P)) >
Type_Access_Level (Btyp)
then
Error_Msg_F
("subprogram must not be deeper than access type", P);
-- Check the restriction of 3.10.2(32) that disallows the
-- access attribute within a generic body when the ultimate
-- ancestor of the type of the attribute is declared outside
-- of the generic unit and the subprogram is declared within
-- that generic unit. This includes any such attribute that
-- occurs within the body of a generic unit that is a child
-- of the generic unit where the subprogram is declared.
-- The rule also prohibits applying the attribute when the
-- access type is a generic formal access type (since the
-- level of the actual type is not known). This restriction
-- does not apply when the attribute type is an anonymous
-- access-to-subprogram type. Note that this check was
-- revised by AI-229, because the original Ada 95 rule
-- was too lax. The original rule only applied when the
-- subprogram was declared within the body of the generic,
-- which allowed the possibility of dangling references).
-- The rule was also too strict in some cases, in that it
-- didn't permit the access to be declared in the generic
-- spec, whereas the revised rule does (as long as it's not
-- a formal type).
-- There are a couple of subtleties of the test for applying
-- the check that are worth noting. First, we only apply it
-- when the levels of the subprogram and access type are the
-- same (the case where the subprogram is statically deeper
-- was applied above, and the case where the type is deeper
-- is always safe). Second, we want the check to apply
-- within nested generic bodies and generic child unit
-- bodies, but not to apply to an attribute that appears in
-- the generic unit's specification. This is done by testing
-- that the attribute's innermost enclosing generic body is
-- not the same as the innermost generic body enclosing the
-- generic unit where the subprogram is declared (we don't
-- want the check to apply when the access attribute is in
-- the spec and there's some other generic body enclosing
-- generic). Finally, there's no point applying the check
-- when within an instance, because any violations will have
-- been caught by the compilation of the generic unit.
-- We relax this check in Relaxed_RM_Semantics mode for
-- compatibility with legacy code for use by Ada source
-- code analyzers (e.g. CodePeer).
elsif Attr_Id = Attribute_Access
and then not Relaxed_RM_Semantics
and then not In_Instance
and then Present (Enclosing_Generic_Unit (Entity (P)))
and then Present (Enclosing_Generic_Body (N))
and then Enclosing_Generic_Body (N) /=
Enclosing_Generic_Body
(Enclosing_Generic_Unit (Entity (P)))
and then Subprogram_Access_Level (Entity (P)) =
Type_Access_Level (Btyp)
and then Ekind (Btyp) /=
E_Anonymous_Access_Subprogram_Type
and then Ekind (Btyp) /=
E_Anonymous_Access_Protected_Subprogram_Type
then
-- The attribute type's ultimate ancestor must be
-- declared within the same generic unit as the
-- subprogram is declared (including within another
-- nested generic unit). The error message is
-- specialized to say "ancestor" for the case where the
-- access type is not its own ancestor, since saying
-- simply "access type" would be very confusing.
if not Declared_Within_Generic_Unit
(Root_Type (Btyp),
Enclosing_Generic_Unit (Entity (P)))
then
Error_Msg_N
("''Access attribute not allowed in generic body",
N);
if Root_Type (Btyp) = Btyp then
Error_Msg_NE
("\because " &
"access type & is declared outside " &
"generic unit (RM 3.10.2(32))", N, Btyp);
else
Error_Msg_NE
("\because ancestor of " &
"access type & is declared outside " &
"generic unit (RM 3.10.2(32))", N, Btyp);
end if;
Error_Msg_NE
("\move ''Access to private part, or " &
"(Ada 2005) use anonymous access type instead of &",
N, Btyp);
-- If the ultimate ancestor of the attribute's type is
-- a formal type, then the attribute is illegal because
-- the actual type might be declared at a higher level.
-- The error message is specialized to say "ancestor"
-- for the case where the access type is not its own
-- ancestor, since saying simply "access type" would be
-- very confusing.
elsif Is_Generic_Type (Root_Type (Btyp)) then
if Root_Type (Btyp) = Btyp then
Error_Msg_N
("access type must not be a generic formal type",
N);
else
Error_Msg_N
("ancestor access type must not be a generic " &
"formal type", N);
end if;
end if;
end if;
end if;
-- If this is a renaming, an inherited operation, or a
-- subprogram instance, use the original entity. This may make
-- the node type-inconsistent, so this transformation can only
-- be done if the node will not be reanalyzed. In particular,
-- if it is within a default expression, the transformation
-- must be delayed until the default subprogram is created for
-- it, when the enclosing subprogram is frozen.
if Is_Entity_Name (P)
and then Is_Overloadable (Entity (P))
and then Present (Alias (Entity (P)))
and then Expander_Active
then
Rewrite (P,
New_Occurrence_Of (Alias (Entity (P)), Sloc (P)));
end if;
elsif Nkind (P) = N_Selected_Component
and then Is_Overloadable (Entity (Selector_Name (P)))
then
-- Protected operation. If operation is overloaded, must
-- disambiguate. Prefix that denotes protected object itself
-- is resolved with its own type.
if Attr_Id = Attribute_Unchecked_Access then
Error_Msg_Name_1 := Aname;
Error_Msg_F
("attribute% cannot be applied to protected operation", P);
end if;
Resolve (Prefix (P));
if not Is_Overloaded (P) then
Generate_Reference (Entity (Selector_Name (P)), P);
else
Get_First_Interp (P, Index, It);
while Present (It.Nam) loop
if Type_Conformant (Designated_Type (Typ), It.Nam) then
Set_Entity (Selector_Name (P), It.Nam);
-- The prefix is definitely NOT overloaded anymore at
-- this point, so we reset the Is_Overloaded flag to
-- avoid any confusion when reanalyzing the node.
Set_Is_Overloaded (P, False);
Set_Is_Overloaded (N, False);
Generate_Reference (Entity (Selector_Name (P)), P);
exit;
end if;
Get_Next_Interp (Index, It);
end loop;
end if;
-- Implement check implied by 3.10.2 (18.1/2) : F.all'access is
-- statically illegal if F is an anonymous access to subprogram.
elsif Nkind (P) = N_Explicit_Dereference
and then Is_Entity_Name (Prefix (P))
and then Ekind (Etype (Entity (Prefix (P)))) =
E_Anonymous_Access_Subprogram_Type
then
Error_Msg_N ("anonymous access to subprogram "
& "has deeper accessibility than any master", P);
elsif Is_Overloaded (P) then
-- Use the designated type of the context to disambiguate
-- Note that this was not strictly conformant to Ada 95,
-- but was the implementation adopted by most Ada 95 compilers.
-- The use of the context type to resolve an Access attribute
-- reference is now mandated in AI-235 for Ada 2005.
declare
Index : Interp_Index;
It : Interp;
begin
Get_First_Interp (P, Index, It);
while Present (It.Typ) loop
if Covers (Designated_Type (Typ), It.Typ) then
Resolve (P, It.Typ);
exit;
end if;
Get_Next_Interp (Index, It);
end loop;
end;
else
Resolve (P);
end if;
-- X'Access is illegal if X denotes a constant and the access type
-- is access-to-variable. Same for 'Unchecked_Access. The rule
-- does not apply to 'Unrestricted_Access. If the reference is a
-- default-initialized aggregate component for a self-referential
-- type the reference is legal.
if not (Ekind (Btyp) = E_Access_Subprogram_Type
or else Ekind (Btyp) = E_Anonymous_Access_Subprogram_Type
or else (Is_Record_Type (Btyp)
and then
Present (Corresponding_Remote_Type (Btyp)))
or else Ekind (Btyp) = E_Access_Protected_Subprogram_Type
or else Ekind (Btyp)
= E_Anonymous_Access_Protected_Subprogram_Type
or else Is_Access_Constant (Btyp)
or else Is_Variable (P)
or else Attr_Id = Attribute_Unrestricted_Access)
then
if Is_Entity_Name (P)
and then Is_Type (Entity (P))
then
-- Legality of a self-reference through an access
-- attribute has been verified in Analyze_Access_Attribute.
null;
elsif Comes_From_Source (N) then
Error_Msg_F ("access-to-variable designates constant", P);
end if;
end if;
Des_Btyp := Designated_Type (Btyp);
if Ada_Version >= Ada_2005
and then Is_Incomplete_Type (Des_Btyp)
then
-- Ada 2005 (AI-412): If the (sub)type is a limited view of an
-- imported entity, and the non-limited view is visible, make
-- use of it. If it is an incomplete subtype, use the base type
-- in any case.
if From_Limited_With (Des_Btyp)
and then Present (Non_Limited_View (Des_Btyp))
then
Des_Btyp := Non_Limited_View (Des_Btyp);
elsif Ekind (Des_Btyp) = E_Incomplete_Subtype then
Des_Btyp := Etype (Des_Btyp);
end if;
end if;
if (Attr_Id = Attribute_Access
or else
Attr_Id = Attribute_Unchecked_Access)
and then (Ekind (Btyp) = E_General_Access_Type
or else Ekind (Btyp) = E_Anonymous_Access_Type)
then
-- Ada 2005 (AI-230): Check the accessibility of anonymous
-- access types for stand-alone objects, record and array
-- components, and return objects. For a component definition
-- the level is the same of the enclosing composite type.
if Ada_Version >= Ada_2005
and then (Is_Local_Anonymous_Access (Btyp)
-- Handle cases where Btyp is the anonymous access
-- type of an Ada 2012 stand-alone object.
or else Nkind (Associated_Node_For_Itype (Btyp)) =
N_Object_Declaration)
and then Attr_Id = Attribute_Access
-- Verify that static checking is OK (namely that we aren't
-- in a specific context requiring dynamic checks on
-- expicitly aliased parameters), and then check the level.
-- Otherwise a check will be generated later when the return
-- statement gets expanded.
and then not Is_Special_Aliased_Formal_Access
(N, Current_Scope)
and then
Object_Access_Level (P) > Deepest_Type_Access_Level (Btyp)
then
-- In an instance, this is a runtime check, but one we know
-- will fail, so generate an appropriate warning. As usual,
-- this kind of warning is an error in SPARK mode.
if In_Instance_Body then
Error_Msg_Warn := SPARK_Mode /= On;
Error_Msg_F
("non-local pointer cannot point to local object<<", P);
Error_Msg_F ("\Program_Error [<<", P);
Rewrite (N,
Make_Raise_Program_Error (Loc,
Reason => PE_Accessibility_Check_Failed));
Set_Etype (N, Typ);
else
Error_Msg_F
("non-local pointer cannot point to local object", P);
end if;
end if;
if Is_Dependent_Component_Of_Mutable_Object (P) then
Error_Msg_F
("illegal attribute for discriminant-dependent component",
P);
end if;
-- Check static matching rule of 3.10.2(27). Nominal subtype
-- of the prefix must statically match the designated type.
Nom_Subt := Etype (P);
if Is_Constr_Subt_For_U_Nominal (Nom_Subt) then
Nom_Subt := Base_Type (Nom_Subt);
end if;
if Is_Tagged_Type (Designated_Type (Typ)) then
-- If the attribute is in the context of an access
-- parameter, then the prefix is allowed to be of
-- the class-wide type (by AI-127).
if Ekind (Typ) = E_Anonymous_Access_Type then
if not Covers (Designated_Type (Typ), Nom_Subt)
and then not Covers (Nom_Subt, Designated_Type (Typ))
then
declare
Desig : Entity_Id;
begin
Desig := Designated_Type (Typ);
if Is_Class_Wide_Type (Desig) then
Desig := Etype (Desig);
end if;
if Is_Anonymous_Tagged_Base (Nom_Subt, Desig) then
null;
else
Error_Msg_FE
("type of prefix: & not compatible",
P, Nom_Subt);
Error_Msg_FE
("\with &, the expected designated type",
P, Designated_Type (Typ));
end if;
end;
end if;
elsif not Covers (Designated_Type (Typ), Nom_Subt)
or else
(not Is_Class_Wide_Type (Designated_Type (Typ))
and then Is_Class_Wide_Type (Nom_Subt))
then
Error_Msg_FE
("type of prefix: & is not covered", P, Nom_Subt);
Error_Msg_FE
("\by &, the expected designated type" &
" (RM 3.10.2 (27))", P, Designated_Type (Typ));
end if;
if Is_Class_Wide_Type (Designated_Type (Typ))
and then Has_Discriminants (Etype (Designated_Type (Typ)))
and then Is_Constrained (Etype (Designated_Type (Typ)))
and then Designated_Type (Typ) /= Nom_Subt
then
Apply_Discriminant_Check
(N, Etype (Designated_Type (Typ)));
end if;
-- Ada 2005 (AI-363): Require static matching when designated
-- type has discriminants and a constrained partial view, since
-- in general objects of such types are mutable, so we can't
-- allow the access value to designate a constrained object
-- (because access values must be assumed to designate mutable
-- objects when designated type does not impose a constraint).
elsif Subtypes_Statically_Match (Des_Btyp, Nom_Subt) then
null;
elsif Has_Discriminants (Designated_Type (Typ))
and then not Is_Constrained (Des_Btyp)
and then
(Ada_Version < Ada_2005
or else
not Object_Type_Has_Constrained_Partial_View
(Typ => Designated_Type (Base_Type (Typ)),
Scop => Current_Scope))
then
null;
else
Error_Msg_F
("object subtype must statically match "
& "designated subtype", P);
if Is_Entity_Name (P)
and then Is_Array_Type (Designated_Type (Typ))
then
declare
D : constant Node_Id := Declaration_Node (Entity (P));
begin
Error_Msg_N
("aliased object has explicit bounds??", D);
Error_Msg_N
("\declare without bounds (and with explicit "
& "initialization)??", D);
Error_Msg_N
("\for use with unconstrained access??", D);
end;
end if;
end if;
-- Check the static accessibility rule of 3.10.2(28). Note that
-- this check is not performed for the case of an anonymous
-- access type, since the access attribute is always legal
-- in such a context.
if Attr_Id /= Attribute_Unchecked_Access
and then Ekind (Btyp) = E_General_Access_Type
and then
Object_Access_Level (P) > Deepest_Type_Access_Level (Btyp)
then
Accessibility_Message;
return;
end if;
end if;
if Ekind (Btyp) in E_Access_Protected_Subprogram_Type
| E_Anonymous_Access_Protected_Subprogram_Type
then
if Is_Entity_Name (P)
and then not Is_Protected_Type (Scope (Entity (P)))
then
Error_Msg_F ("context requires a protected subprogram", P);
-- Check accessibility of protected object against that of the
-- access type, but only on user code, because the expander
-- creates access references for handlers. If the context is an
-- anonymous_access_to_protected, there are no accessibility
-- checks either. Omit check entirely for Unrestricted_Access.
elsif Object_Access_Level (P) > Deepest_Type_Access_Level (Btyp)
and then Comes_From_Source (N)
and then Ekind (Btyp) = E_Access_Protected_Subprogram_Type
and then Attr_Id /= Attribute_Unrestricted_Access
then
Accessibility_Message;
return;
-- AI05-0225: If the context is not an access to protected
-- function, the prefix must be a variable, given that it may
-- be used subsequently in a protected call.
elsif Nkind (P) = N_Selected_Component
and then not Is_Variable (Prefix (P))
and then Ekind (Entity (Selector_Name (P))) /= E_Function
then
Error_Msg_N
("target object of access to protected procedure "
& "must be variable", N);
elsif Is_Entity_Name (P) then
Check_Internal_Protected_Use (N, Entity (P));
end if;
elsif Ekind (Btyp) in E_Access_Subprogram_Type
| E_Anonymous_Access_Subprogram_Type
and then Ekind (Etype (N)) = E_Access_Protected_Subprogram_Type
then
Error_Msg_F ("context requires a non-protected subprogram", P);
end if;
-- The context cannot be a pool-specific type, but this is a
-- legality rule, not a resolution rule, so it must be checked
-- separately, after possibly disambiguation (see AI-245).
if Ekind (Btyp) = E_Access_Type
and then Attr_Id /= Attribute_Unrestricted_Access
then
Wrong_Type (N, Typ);
end if;
-- The context may be a constrained access type (however ill-
-- advised such subtypes might be) so in order to generate a
-- constraint check we need to set the type of the attribute
-- reference to the base type of the context.
Set_Etype (N, Btyp);
-- Check for incorrect atomic/volatile reference (RM C.6(12))
if Attr_Id /= Attribute_Unrestricted_Access then
if Is_Atomic_Object (P)
and then not Is_Atomic (Designated_Type (Typ))
then
Error_Msg_F
("access to atomic object cannot yield access-to-" &
"non-atomic type", P);
elsif Is_Volatile_Object (P)
and then not Is_Volatile (Designated_Type (Typ))
then
Error_Msg_F
("access to volatile object cannot yield access-to-" &
"non-volatile type", P);
end if;
end if;
-- Check for aliased view. We allow a nonaliased prefix when in
-- an instance because the prefix may have been a tagged formal
-- object, which is defined to be aliased even when the actual
-- might not be (other instance cases will have been caught in
-- the generic). Similarly, within an inlined body we know that
-- the attribute is legal in the original subprogram, therefore
-- legal in the expansion.
if not (Is_Entity_Name (P)
and then Is_Overloadable (Entity (P)))
and then not (Nkind (P) = N_Selected_Component
and then
Is_Overloadable (Entity (Selector_Name (P))))
and then not Is_Aliased_View (Original_Node (P))
and then not In_Instance
and then not In_Inlined_Body
and then Comes_From_Source (N)
then
-- Here we have a non-aliased view. This is illegal unless we
-- have the case of Unrestricted_Access, where for now we allow
-- this (we will reject later if expected type is access to an
-- unconstrained array with a thin pointer).
-- No need for an error message on a generated access reference
-- for the controlling argument in a dispatching call: error
-- will be reported when resolving the call.
if Attr_Id /= Attribute_Unrestricted_Access then
Error_Msg_Name_1 := Aname;
Error_Msg_N ("prefix of % attribute must be aliased", P);
-- Check for unrestricted access where expected type is a thin
-- pointer to an unconstrained array.
elsif Has_Size_Clause (Typ)
and then RM_Size (Typ) = System_Address_Size
then
declare
DT : constant Entity_Id := Designated_Type (Typ);
begin
if Is_Array_Type (DT)
and then not Is_Constrained (DT)
then
Error_Msg_N
("illegal use of Unrestricted_Access attribute", P);
Error_Msg_N
("\attempt to generate thin pointer to unaliased "
& "object", P);
end if;
end;
end if;
end if;
-- Check that the prefix does not have a value conversion of an
-- array type since a value conversion is like an aggregate with
-- respect to determining accessibility level (RM 3.10.2).
if not Prefix_With_Safe_Accessibility_Level then
Accessibility_Message;
return;
end if;
-- Mark that address of entity is taken in case of
-- 'Unrestricted_Access or in case of a subprogram.
if Is_Entity_Name (P)
and then (Attr_Id = Attribute_Unrestricted_Access
or else Is_Subprogram (Entity (P)))
then
Set_Address_Taken (Entity (P));
end if;
-- Deal with possible elaboration check
if Is_Entity_Name (P) and then Is_Subprogram (Entity (P)) then
declare
Subp_Id : constant Entity_Id := Entity (P);
Scop : constant Entity_Id := Scope (Subp_Id);
Subp_Decl : constant Node_Id :=
Unit_Declaration_Node (Subp_Id);
Flag_Id : Entity_Id;
Subp_Body : Node_Id;
-- If the access has been taken and the body of the subprogram
-- has not been see yet, indirect calls must be protected with
-- elaboration checks. We have the proper elaboration machinery
-- for subprograms declared in packages, but within a block or
-- a subprogram the body will appear in the same declarative
-- part, and we must insert a check in the eventual body itself
-- using the elaboration flag that we generate now. The check
-- is then inserted when the body is expanded. This processing
-- is not needed for a stand alone expression function because
-- the internally generated spec and body are always inserted
-- as a pair in the same declarative list.
begin
if Expander_Active
and then Comes_From_Source (Subp_Id)
and then Comes_From_Source (N)
and then In_Open_Scopes (Scop)
and then Ekind (Scop) in E_Block | E_Procedure | E_Function
and then not Has_Completion (Subp_Id)
and then No (Elaboration_Entity (Subp_Id))
and then Nkind (Subp_Decl) = N_Subprogram_Declaration
and then Nkind (Original_Node (Subp_Decl)) /=
N_Expression_Function
then
-- Create elaboration variable for it
Flag_Id := Make_Temporary (Loc, 'E');
Set_Elaboration_Entity (Subp_Id, Flag_Id);
Set_Is_Frozen (Flag_Id);
-- Insert declaration for flag after subprogram
-- declaration. Note that attribute reference may
-- appear within a nested scope.
Insert_After_And_Analyze (Subp_Decl,
Make_Object_Declaration (Loc,
Defining_Identifier => Flag_Id,
Object_Definition =>
New_Occurrence_Of (Standard_Short_Integer, Loc),
Expression =>
Make_Integer_Literal (Loc, Uint_0)));
-- The above sets the Scope of the flag entity to the
-- current scope, in which the attribute appears, but
-- the flag declaration has been inserted after that
-- of Subp_Id, so the scope of the flag is the same as
-- that of Subp_Id. This is relevant when unnesting,
-- where processing depends on correct scope setting.
Set_Scope (Flag_Id, Scop);
end if;
-- Taking the 'Access of an expression function freezes its
-- expression (RM 13.14 10.3/3). This does not apply to an
-- expression function that acts as a completion because the
-- generated body is immediately analyzed and the expression
-- is automatically frozen.
if Is_Expression_Function (Subp_Id)
and then Present (Corresponding_Body (Subp_Decl))
then
Subp_Body :=
Unit_Declaration_Node (Corresponding_Body (Subp_Decl));
-- The body has already been analyzed when the expression
-- function acts as a completion.
if Analyzed (Subp_Body) then
null;
-- Attribute 'Access may appear within the generated body
-- of the expression function subject to the attribute:
-- function F is (... F'Access ...);
-- If the expression function is on the scope stack, then
-- the body is currently being analyzed. Do not reanalyze
-- it because this will lead to infinite recursion.
elsif In_Open_Scopes (Subp_Id) then
null;
-- If reference to the expression function appears in an
-- inner scope, for example as an actual in an instance,
-- this is not a freeze point either.
elsif Scope (Subp_Id) /= Current_Scope then
null;
-- Analyze the body of the expression function to freeze
-- the expression. This takes care of the case where the
-- 'Access is part of dispatch table initialization and
-- the generated body of the expression function has not
-- been analyzed yet.
else
Analyze (Subp_Body);
end if;
end if;
end;
end if;
-------------
-- Address --
-------------
-- Deal with resolving the type for Address attribute, overloading
-- is not permitted here, since there is no context to resolve it.
when Attribute_Address
| Attribute_Code_Address
=>
-- To be safe, assume that if the address of a variable is taken,
-- it may be modified via this address, so note modification.
if Is_Variable (P) then
Note_Possible_Modification (P, Sure => False);
end if;
if Nkind (P) in N_Subexpr
and then Is_Overloaded (P)
then
Get_First_Interp (P, Index, It);
Get_Next_Interp (Index, It);
if Present (It.Nam) then
Error_Msg_Name_1 := Aname;
Error_Msg_F
("prefix of % attribute cannot be overloaded", P);
end if;
end if;
if not Is_Entity_Name (P)
or else not Is_Overloadable (Entity (P))
then
if not Is_Task_Type (Etype (P))
or else Nkind (P) = N_Explicit_Dereference
then
Resolve (P);
end if;
end if;
-- If this is the name of a derived subprogram, or that of a
-- generic actual, the address is that of the original entity.
if Is_Entity_Name (P)
and then Is_Overloadable (Entity (P))
and then Present (Alias (Entity (P)))
then
Rewrite (P,
New_Occurrence_Of (Alias (Entity (P)), Sloc (P)));
end if;
if Is_Entity_Name (P) then
Set_Address_Taken (Entity (P));
end if;
if Nkind (P) = N_Slice then
-- Arr (X .. Y)'address is identical to Arr (X)'address,
-- even if the array is packed and the slice itself is not
-- addressable. Transform the prefix into an indexed component.
-- Note that the transformation is safe only if we know that
-- the slice is non-null. That is because a null slice can have
-- an out of bounds index value.
-- Right now, gigi blows up if given 'Address on a slice as a
-- result of some incorrect freeze nodes generated by the front
-- end, and this covers up that bug in one case, but the bug is
-- likely still there in the cases not handled by this code ???
-- It's not clear what 'Address *should* return for a null
-- slice with out of bounds indexes, this might be worth an ARG
-- discussion ???
-- One approach would be to do a length check unconditionally,
-- and then do the transformation below unconditionally, but
-- analyze with checks off, avoiding the problem of the out of
-- bounds index. This approach would interpret the address of
-- an out of bounds null slice as being the address where the
-- array element would be if there was one, which is probably
-- as reasonable an interpretation as any ???
declare
Loc : constant Source_Ptr := Sloc (P);
D : constant Node_Id := Discrete_Range (P);
Lo : Node_Id;
begin
if Is_Entity_Name (D)
and then
Not_Null_Range
(Type_Low_Bound (Entity (D)),
Type_High_Bound (Entity (D)))
then
Lo :=
Make_Attribute_Reference (Loc,
Prefix => (New_Occurrence_Of (Entity (D), Loc)),
Attribute_Name => Name_First);
elsif Nkind (D) = N_Range
and then Not_Null_Range (Low_Bound (D), High_Bound (D))
then
Lo := Low_Bound (D);
else
Lo := Empty;
end if;
if Present (Lo) then
Rewrite (P,
Make_Indexed_Component (Loc,
Prefix => Relocate_Node (Prefix (P)),
Expressions => New_List (Lo)));
Analyze_And_Resolve (P);
end if;
end;
end if;
------------------
-- Body_Version --
------------------
-- Prefix of Body_Version attribute can be a subprogram name which
-- must not be resolved, since this is not a call.
when Attribute_Body_Version =>
null;
------------
-- Caller --
------------
-- Prefix of Caller attribute is an entry name which must not
-- be resolved, since this is definitely not an entry call.
when Attribute_Caller =>
null;
------------------
-- Code_Address --
------------------
-- Shares processing with Address attribute
-----------
-- Count --
-----------
-- If the prefix of the Count attribute is an entry name it must not
-- be resolved, since this is definitely not an entry call. However,
-- if it is an element of an entry family, the index itself may
-- have to be resolved because it can be a general expression.
when Attribute_Count =>
if Nkind (P) = N_Indexed_Component
and then Is_Entity_Name (Prefix (P))
then
declare
Indx : constant Node_Id := First (Expressions (P));
Fam : constant Entity_Id := Entity (Prefix (P));
begin
Resolve (Indx, Entry_Index_Type (Fam));
Apply_Scalar_Range_Check (Indx, Entry_Index_Type (Fam));
end;
end if;
----------------
-- Elaborated --
----------------
-- Prefix of the Elaborated attribute is a subprogram name which
-- must not be resolved, since this is definitely not a call. Note
-- that it is a library unit, so it cannot be overloaded here.
when Attribute_Elaborated =>
null;
-------------
-- Enabled --
-------------
-- Prefix of Enabled attribute is a check name, which must be treated
-- specially and not touched by Resolve.
when Attribute_Enabled =>
null;
----------------
-- Loop_Entry --
----------------
-- Do not resolve the prefix of Loop_Entry, instead wait until the
-- attribute has been expanded (see Expand_Loop_Entry_Attributes).
-- The delay ensures that any generated checks or temporaries are
-- inserted before the relocated prefix.
when Attribute_Loop_Entry =>
null;
--------------------
-- Mechanism_Code --
--------------------
-- Prefix of the Mechanism_Code attribute is a function name
-- which must not be resolved. Should we check for overloaded ???
when Attribute_Mechanism_Code =>
null;
------------------
-- Partition_ID --
------------------
-- Most processing is done in sem_dist, after determining the
-- context type. Node is rewritten as a conversion to a runtime call.
when Attribute_Partition_ID =>
Process_Partition_Id (N);
return;
------------------
-- Pool_Address --
------------------
when Attribute_Pool_Address =>
Resolve (P);
-----------
-- Range --
-----------
-- We replace the Range attribute node with a range expression whose
-- bounds are the 'First and 'Last attributes applied to the same
-- prefix. The reason that we do this transformation here instead of
-- in the expander is that it simplifies other parts of the semantic
-- analysis which assume that the Range has been replaced; thus it
-- must be done even when in semantic-only mode (note that the RM
-- specifically mentions this equivalence, we take care that the
-- prefix is only evaluated once).
when Attribute_Range => Range_Attribute : declare
Dims : List_Id;
HB : Node_Id;
LB : Node_Id;
begin
if not Is_Entity_Name (P) or else not Is_Type (Entity (P)) then
Resolve (P);
-- If the prefix is a function call returning on the secondary
-- stack, we must make sure to mark/release the stack.
if Nkind (P) = N_Function_Call
and then Nkind (Parent (N)) = N_Loop_Parameter_Specification
and then Requires_Transient_Scope (Etype (P))
then
Set_Uses_Sec_Stack (Scope (Current_Scope));
end if;
end if;
Dims := Expressions (N);
HB :=
Make_Attribute_Reference (Loc,
Prefix => Duplicate_Subexpr (P, Name_Req => True),
Attribute_Name => Name_Last,
Expressions => Dims);
LB :=
Make_Attribute_Reference (Loc,
Prefix => P,
Attribute_Name => Name_First,
Expressions => (Dims));
-- Do not share the dimension indicator, if present. Even though
-- it is a static constant, its source location may be modified
-- when printing expanded code and node sharing will lead to chaos
-- in Sprint.
if Present (Dims) then
Set_Expressions (LB, New_List (New_Copy_Tree (First (Dims))));
end if;
-- If the original was marked as Must_Not_Freeze (see code in
-- Sem_Ch3.Make_Index), then make sure the rewriting does not
-- freeze either.
if Must_Not_Freeze (N) then
Set_Must_Not_Freeze (HB);
Set_Must_Not_Freeze (LB);
Set_Must_Not_Freeze (Prefix (HB));
Set_Must_Not_Freeze (Prefix (LB));
end if;
if Raises_Constraint_Error (Prefix (N)) then
-- Preserve Sloc of prefix in the new bounds, so that the
-- posted warning can be removed if we are within unreachable
-- code.
Set_Sloc (LB, Sloc (Prefix (N)));
Set_Sloc (HB, Sloc (Prefix (N)));
end if;
Rewrite (N, Make_Range (Loc, LB, HB));
Analyze_And_Resolve (N, Typ);
-- Ensure that the expanded range does not have side effects
Force_Evaluation (LB);
Force_Evaluation (HB);
-- Normally after resolving attribute nodes, Eval_Attribute
-- is called to do any possible static evaluation of the node.
-- However, here since the Range attribute has just been
-- transformed into a range expression it is no longer an
-- attribute node and therefore the call needs to be avoided
-- and is accomplished by simply returning from the procedure.
return;
end Range_Attribute;
-------------
-- Reduce --
-------------
when Attribute_Reduce =>
declare
E1 : constant Node_Id := First (Expressions (N));
E2 : constant Node_Id := Next (E1);
Op : Entity_Id := Empty;
Index : Interp_Index;
It : Interp;
function Proper_Op (Op : Entity_Id) return Boolean;
---------------
-- Proper_Op --
---------------
function Proper_Op (Op : Entity_Id) return Boolean is
F1, F2 : Entity_Id;
begin
F1 := First_Formal (Op);
if No (F1) then
return False;
else
F2 := Next_Formal (F1);
if No (F2)
or else Present (Next_Formal (F2))
then
return False;
elsif Ekind (Op) = E_Procedure then
return Ekind (F1) = E_In_Out_Parameter
and then Covers (Typ, Etype (F1));
else
return
(Ekind (Op) = E_Operator
and then Scope (Op) = Standard_Standard)
or else Covers (Typ, Etype (Op));
end if;
end if;
end Proper_Op;
begin
Resolve (E2, Typ);
if Is_Overloaded (E1) then
Get_First_Interp (E1, Index, It);
while Present (It.Nam) loop
if Proper_Op (It.Nam) then
Op := It.Nam;
Set_Entity (E1, Op);
exit;
end if;
Get_Next_Interp (Index, It);
end loop;
elsif Nkind (E1) = N_Attribute_Reference
and then (Attribute_Name (E1) = Name_Max
or else Attribute_Name (E1) = Name_Min)
then
Op := E1;
elsif Proper_Op (Entity (E1)) then
Op := Entity (E1);
Set_Etype (N, Typ);
end if;
if No (Op) then
Error_Msg_N ("No visible subprogram for reduction", E1);
end if;
end;
------------
-- Result --
------------
-- We will only come here during the prescan of a spec expression
-- containing a Result attribute. In that case the proper Etype has
-- already been set, and nothing more needs to be done here.
when Attribute_Result =>
null;
----------------------
-- Unchecked_Access --
----------------------
-- Processing is shared with Access
-------------------------
-- Unrestricted_Access --
-------------------------
-- Processing is shared with Access
------------
-- Update --
------------
-- Resolve aggregate components in component associations
when Attribute_Update => Update : declare
Aggr : constant Node_Id := First (Expressions (N));
Typ : constant Entity_Id := Etype (Prefix (N));
Assoc : Node_Id;
Comp : Node_Id;
Expr : Node_Id;
begin
-- Set the Etype of the aggregate to that of the prefix, even
-- though the aggregate may not be a proper representation of a
-- value of the type (missing or duplicated associations, etc.)
-- Complete resolution of the prefix. Note that in Ada 2012 it
-- can be a qualified expression that is e.g. an aggregate.
Set_Etype (Aggr, Typ);
Resolve (Prefix (N), Typ);
-- For an array type, resolve expressions with the component type
-- of the array, and apply constraint checks when needed.
if Is_Array_Type (Typ) then
Assoc := First (Component_Associations (Aggr));
while Present (Assoc) loop
Expr := Expression (Assoc);
Resolve (Expr, Component_Type (Typ));
-- The choices in the association are static constants,
-- or static aggregates each of whose components belongs
-- to the proper index type. However, they must also
-- belong to the index subtype (s) of the prefix, which
-- may be a subtype (e.g. given by a slice).
-- Choices may also be identifiers with no staticness
-- requirements, in which case they must resolve to the
-- index type.
declare
C : Node_Id;
C_E : Node_Id;
Indx : Node_Id;
begin
C := First (Choices (Assoc));
while Present (C) loop
Indx := First_Index (Etype (Prefix (N)));
if Nkind (C) /= N_Aggregate then
Analyze_And_Resolve (C, Etype (Indx));
else
C_E := First (Expressions (C));
while Present (C_E) loop
Analyze_And_Resolve (C_E, Etype (Indx));
Next (C_E);
Next_Index (Indx);
end loop;
end if;
Next (C);
end loop;
end;
Next (Assoc);
end loop;
-- For a record type, use type of each component, which is
-- recorded during analysis.
else
Assoc := First (Component_Associations (Aggr));
while Present (Assoc) loop
Comp := First (Choices (Assoc));
Expr := Expression (Assoc);
if Nkind (Comp) /= N_Others_Choice
and then not Error_Posted (Comp)
then
Resolve (Expr, Etype (Entity (Comp)));
end if;
Next (Assoc);
end loop;
end if;
end Update;
---------
-- Val --
---------
-- Apply range check. Note that we did not do this during the
-- analysis phase, since we wanted Eval_Attribute to have a
-- chance at finding an illegal out of range value.
when Attribute_Val =>
-- Note that we do our own Eval_Attribute call here rather than
-- use the common one, because we need to do processing after
-- the call, as per above comment.
Eval_Attribute (N);
-- Eval_Attribute may replace the node with a raise CE, or
-- fold it to a constant. Obviously we only apply a scalar
-- range check if this did not happen.
if Nkind (N) = N_Attribute_Reference
and then Attribute_Name (N) = Name_Val
then
Apply_Scalar_Range_Check (First (Expressions (N)), Btyp);
end if;
return;
-------------
-- Version --
-------------
-- Prefix of Version attribute can be a subprogram name which
-- must not be resolved, since this is not a call.
when Attribute_Version =>
null;
----------------------
-- Other Attributes --
----------------------
-- For other attributes, resolve prefix unless it is a type. If
-- the attribute reference itself is a type name ('Base and 'Class)
-- then this is only legal within a task or protected record.
when others =>
if not Is_Entity_Name (P) or else not Is_Type (Entity (P)) then
Resolve (P);
end if;
-- If the attribute reference itself is a type name ('Base,
-- 'Class) then this is only legal within a task or protected
-- record. What is this all about ???
if Is_Entity_Name (N) and then Is_Type (Entity (N)) then
if Is_Concurrent_Type (Entity (N))
and then In_Open_Scopes (Entity (P))
then
null;
else
Error_Msg_N
("invalid use of subtype name in expression or call", N);
end if;
end if;
-- For attributes whose argument may be a string, complete
-- resolution of argument now. This avoids premature expansion
-- (and the creation of transient scopes) before the attribute
-- reference is resolved.
case Attr_Id is
when Attribute_Value =>
Resolve (First (Expressions (N)), Standard_String);
when Attribute_Wide_Value =>
Resolve (First (Expressions (N)), Standard_Wide_String);
when Attribute_Wide_Wide_Value =>
Resolve (First (Expressions (N)), Standard_Wide_Wide_String);
when others => null;
end case;
-- If the prefix of the attribute is a class-wide type then it
-- will be expanded into a dispatching call to a predefined
-- primitive. Therefore we must check for potential violation
-- of such restriction.
if Is_Class_Wide_Type (Etype (P)) then
Check_Restriction (No_Dispatching_Calls, N);
end if;
end case;
-- Mark use clauses of the original prefix if the attribute is applied
-- to an entity.
if Nkind (Original_Node (P)) in N_Has_Entity
and then Present (Entity (Original_Node (P)))
then
Mark_Use_Clauses (Original_Node (P));
end if;
-- Normally the Freezing is done by Resolve but sometimes the Prefix
-- is not resolved, in which case the freezing must be done now.
-- For an elaboration check on a subprogram, we do not freeze its type.
-- It may be declared in an unrelated scope, in particular in the case
-- of a generic function whose type may remain unelaborated.
if Attr_Id = Attribute_Elaborated then
null;
-- Should this be restricted to Expander_Active???
else
Freeze_Expression (P);
end if;
-- Finally perform static evaluation on the attribute reference
Analyze_Dimension (N);
Eval_Attribute (N);
end Resolve_Attribute;
------------------------
-- Set_Boolean_Result --
------------------------
procedure Set_Boolean_Result (N : Node_Id; B : Boolean) is
Loc : constant Source_Ptr := Sloc (N);
begin
if B then
Rewrite (N, New_Occurrence_Of (Standard_True, Loc));
else
Rewrite (N, New_Occurrence_Of (Standard_False, Loc));
end if;
end Set_Boolean_Result;
--------------------------------
-- Stream_Attribute_Available --
--------------------------------
function Stream_Attribute_Available
(Typ : Entity_Id;
Nam : TSS_Name_Type;
Partial_View : Node_Id := Empty) return Boolean
is
Etyp : Entity_Id := Typ;
-- Start of processing for Stream_Attribute_Available
begin
-- We need some comments in this body ???
if Has_Stream_Attribute_Definition (Typ, Nam) then
return True;
end if;
if Is_Class_Wide_Type (Typ) then
return not Is_Limited_Type (Typ)
or else Stream_Attribute_Available (Etype (Typ), Nam);
end if;
if Nam = TSS_Stream_Input
and then Is_Abstract_Type (Typ)
and then not Is_Class_Wide_Type (Typ)
then
return False;
end if;
if not (Is_Limited_Type (Typ)
or else (Present (Partial_View)
and then Is_Limited_Type (Partial_View)))
then
return True;
end if;
-- In Ada 2005, Input can invoke Read, and Output can invoke Write
if Nam = TSS_Stream_Input
and then Ada_Version >= Ada_2005
and then Stream_Attribute_Available (Etyp, TSS_Stream_Read)
then
return True;
elsif Nam = TSS_Stream_Output
and then Ada_Version >= Ada_2005
and then Stream_Attribute_Available (Etyp, TSS_Stream_Write)
then
return True;
end if;
-- Case of Read and Write: check for attribute definition clause that
-- applies to an ancestor type.
while Etype (Etyp) /= Etyp loop
Etyp := Etype (Etyp);
if Has_Stream_Attribute_Definition (Etyp, Nam) then
return True;
end if;
end loop;
if Ada_Version < Ada_2005 then
-- In Ada 95 mode, also consider a non-visible definition
declare
Btyp : constant Entity_Id := Implementation_Base_Type (Typ);
begin
return Btyp /= Typ
and then Stream_Attribute_Available
(Btyp, Nam, Partial_View => Typ);
end;
end if;
return False;
end Stream_Attribute_Available;
end Sem_Attr;
|
package zlib.Strings is
pragma Preelaborate;
procedure Deflate (
Stream : in out zlib.Stream;
In_Item : in String;
In_Last : out Natural;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean);
procedure Deflate (
Stream : in out zlib.Stream;
In_Item : in String;
In_Last : out Natural;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset);
procedure Deflate (
Stream : in out zlib.Stream;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : in Boolean;
Finished : out Boolean)
renames zlib.Deflate;
procedure Inflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out String;
Out_Last : out Natural;
Finish : in Boolean;
Finished : out Boolean);
procedure Inflate (
Stream : in out zlib.Stream;
In_Item : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out String;
Out_Last : out Natural);
procedure Inflate (
Stream : in out zlib.Stream;
Out_Item : out String;
Out_Last : out Natural;
Finish : in Boolean;
Finished : out Boolean);
end zlib.Strings;
|
with Ada.Containers.Ordered_Maps;
with Ada.Unchecked_Deallocation;
with Interfaces; use Interfaces;
package body kv.avm.Actor_Pool is
use kv.avm.Executables;
package Actors is new Ada.Containers.Ordered_Maps
(Key_Type => Interfaces.Unsigned_32,
Element_Type => kv.avm.Executables.Executable_Access ); -- kv.avm.Instances.Instance_Access );
Pool : Actors.Map;
Count : Interfaces.Unsigned_32 := 0;
-----------------------------------------------------------------------------
procedure Add
(Actor : in kv.avm.Executables.Executable_Access;
Reference : out kv.avm.Actor_References.Actor_Reference_Type) is
begin
Count := Count + 1;
Pool.Insert(Count, Actor);
Reference.Initialize(Count);
end Add;
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation(kv.avm.Executables.Executable_Interface'CLASS, kv.avm.Executables.Executable_Access);
-----------------------------------------------------------------------------
procedure Delete
(Reference : in kv.avm.Actor_References.Actor_Reference_Type) is
Location : Actors.Cursor;
Instance : kv.avm.Executables.Executable_Access;
use Actors;
begin
Location := Pool.Find(Reference.Get_Key);
if Location /= Actors.No_Element then
Instance := Actors.Element(Location);
Pool.Delete(Location);
Free(Instance);
end if;
end Delete;
-----------------------------------------------------------------------------
function Resolve(Reference : kv.avm.Actor_References.Actor_Reference_Type) return kv.avm.Executables.Executable_Access is
Location : Actors.Cursor;
use Actors;
begin
Location := Pool.Find(Reference.Get_Key);
if Location = Actors.No_Element then
return null;
else
return Actors.Element(Location);
end if;
end Resolve;
-----------------------------------------------------------------------------
procedure Empty_Actor_Pool is
begin
Pool.Clear;
end Empty_Actor_Pool;
end kv.avm.Actor_Pool;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2011, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.Atomics is
pragma Pure;
end Matreshka.Atomics;
|
address=/govjiangsu.cn/127.0.0.1
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.RED_BLACK_TREES.GENERIC_SET_OPERATIONS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with System; use type System.Address;
package body Ada.Containers.Red_Black_Trees.Generic_Set_Operations is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
procedure Clear (Tree : in out Tree_Type);
function Copy (Source : Tree_Type) return Tree_Type;
-----------
-- Clear --
-----------
procedure Clear (Tree : in out Tree_Type) is
use type Helpers.Tamper_Counts;
pragma Assert (Tree.TC = (Busy => 0, Lock => 0));
Root : Node_Access := Tree.Root;
pragma Warnings (Off, Root);
begin
Tree.Root := null;
Tree.First := null;
Tree.Last := null;
Tree.Length := 0;
Delete_Tree (Root);
end Clear;
----------
-- Copy --
----------
function Copy (Source : Tree_Type) return Tree_Type is
Target : Tree_Type;
begin
if Source.Length = 0 then
return Target;
end if;
Target.Root := Copy_Tree (Source.Root);
Target.First := Tree_Operations.Min (Target.Root);
Target.Last := Tree_Operations.Max (Target.Root);
Target.Length := Source.Length;
return Target;
end Copy;
----------------
-- Difference --
----------------
procedure Difference (Target : in out Tree_Type; Source : Tree_Type) is
Tgt : Node_Access;
Src : Node_Access;
Compare : Integer;
begin
TC_Check (Target.TC);
if Target'Address = Source'Address then
Clear (Target);
return;
end if;
if Source.Length = 0 then
return;
end if;
Tgt := Target.First;
Src := Source.First;
loop
if Tgt = null then
exit;
end if;
if Src = null then
exit;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Target : With_Lock (Target.TC'Unrestricted_Access);
Lock_Source : With_Lock (Source.TC'Unrestricted_Access);
begin
if Is_Less (Tgt, Src) then
Compare := -1;
elsif Is_Less (Src, Tgt) then
Compare := 1;
else
Compare := 0;
end if;
end;
if Compare < 0 then
Tgt := Tree_Operations.Next (Tgt);
elsif Compare > 0 then
Src := Tree_Operations.Next (Src);
else
declare
X : Node_Access := Tgt;
begin
Tgt := Tree_Operations.Next (Tgt);
Tree_Operations.Delete_Node_Sans_Free (Target, X);
Free (X);
end;
Src := Tree_Operations.Next (Src);
end if;
end loop;
end Difference;
function Difference (Left, Right : Tree_Type) return Tree_Type is
begin
if Left'Address = Right'Address then
return Tree_Type'(others => <>); -- Empty set
end if;
if Left.Length = 0 then
return Tree_Type'(others => <>); -- Empty set
end if;
if Right.Length = 0 then
return Copy (Left);
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
Tree : Tree_Type;
L_Node : Node_Access;
R_Node : Node_Access;
Dst_Node : Node_Access;
pragma Warnings (Off, Dst_Node);
begin
L_Node := Left.First;
R_Node := Right.First;
loop
if L_Node = null then
exit;
end if;
if R_Node = null then
while L_Node /= null loop
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => L_Node,
Dst_Node => Dst_Node);
L_Node := Tree_Operations.Next (L_Node);
end loop;
exit;
end if;
if Is_Less (L_Node, R_Node) then
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => L_Node,
Dst_Node => Dst_Node);
L_Node := Tree_Operations.Next (L_Node);
elsif Is_Less (R_Node, L_Node) then
R_Node := Tree_Operations.Next (R_Node);
else
L_Node := Tree_Operations.Next (L_Node);
R_Node := Tree_Operations.Next (R_Node);
end if;
end loop;
return Tree;
exception
when others =>
Delete_Tree (Tree.Root);
raise;
end;
end Difference;
------------------
-- Intersection --
------------------
procedure Intersection
(Target : in out Tree_Type;
Source : Tree_Type)
is
Tgt : Node_Access;
Src : Node_Access;
Compare : Integer;
begin
if Target'Address = Source'Address then
return;
end if;
TC_Check (Target.TC);
if Source.Length = 0 then
Clear (Target);
return;
end if;
Tgt := Target.First;
Src := Source.First;
while Tgt /= null
and then Src /= null
loop
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Target : With_Lock (Target.TC'Unrestricted_Access);
Lock_Source : With_Lock (Source.TC'Unrestricted_Access);
begin
if Is_Less (Tgt, Src) then
Compare := -1;
elsif Is_Less (Src, Tgt) then
Compare := 1;
else
Compare := 0;
end if;
end;
if Compare < 0 then
declare
X : Node_Access := Tgt;
begin
Tgt := Tree_Operations.Next (Tgt);
Tree_Operations.Delete_Node_Sans_Free (Target, X);
Free (X);
end;
elsif Compare > 0 then
Src := Tree_Operations.Next (Src);
else
Tgt := Tree_Operations.Next (Tgt);
Src := Tree_Operations.Next (Src);
end if;
end loop;
while Tgt /= null loop
declare
X : Node_Access := Tgt;
begin
Tgt := Tree_Operations.Next (Tgt);
Tree_Operations.Delete_Node_Sans_Free (Target, X);
Free (X);
end;
end loop;
end Intersection;
function Intersection (Left, Right : Tree_Type) return Tree_Type is
begin
if Left'Address = Right'Address then
return Copy (Left);
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
Tree : Tree_Type;
L_Node : Node_Access;
R_Node : Node_Access;
Dst_Node : Node_Access;
pragma Warnings (Off, Dst_Node);
begin
L_Node := Left.First;
R_Node := Right.First;
loop
if L_Node = null then
exit;
end if;
if R_Node = null then
exit;
end if;
if Is_Less (L_Node, R_Node) then
L_Node := Tree_Operations.Next (L_Node);
elsif Is_Less (R_Node, L_Node) then
R_Node := Tree_Operations.Next (R_Node);
else
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => L_Node,
Dst_Node => Dst_Node);
L_Node := Tree_Operations.Next (L_Node);
R_Node := Tree_Operations.Next (R_Node);
end if;
end loop;
return Tree;
exception
when others =>
Delete_Tree (Tree.Root);
raise;
end;
end Intersection;
---------------
-- Is_Subset --
---------------
function Is_Subset
(Subset : Tree_Type;
Of_Set : Tree_Type) return Boolean
is
begin
if Subset'Address = Of_Set'Address then
return True;
end if;
if Subset.Length > Of_Set.Length then
return False;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Subset : With_Lock (Subset.TC'Unrestricted_Access);
Lock_Of_Set : With_Lock (Of_Set.TC'Unrestricted_Access);
Subset_Node : Node_Access;
Set_Node : Node_Access;
begin
Subset_Node := Subset.First;
Set_Node := Of_Set.First;
loop
if Set_Node = null then
return Subset_Node = null;
end if;
if Subset_Node = null then
return True;
end if;
if Is_Less (Subset_Node, Set_Node) then
return False;
end if;
if Is_Less (Set_Node, Subset_Node) then
Set_Node := Tree_Operations.Next (Set_Node);
else
Set_Node := Tree_Operations.Next (Set_Node);
Subset_Node := Tree_Operations.Next (Subset_Node);
end if;
end loop;
end;
end Is_Subset;
-------------
-- Overlap --
-------------
function Overlap (Left, Right : Tree_Type) return Boolean is
begin
if Left'Address = Right'Address then
return Left.Length /= 0;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
L_Node : Node_Access;
R_Node : Node_Access;
begin
L_Node := Left.First;
R_Node := Right.First;
loop
if L_Node = null
or else R_Node = null
then
return False;
end if;
if Is_Less (L_Node, R_Node) then
L_Node := Tree_Operations.Next (L_Node);
elsif Is_Less (R_Node, L_Node) then
R_Node := Tree_Operations.Next (R_Node);
else
return True;
end if;
end loop;
end;
end Overlap;
--------------------------
-- Symmetric_Difference --
--------------------------
procedure Symmetric_Difference
(Target : in out Tree_Type;
Source : Tree_Type)
is
Tgt : Node_Access;
Src : Node_Access;
New_Tgt_Node : Node_Access;
pragma Warnings (Off, New_Tgt_Node);
Compare : Integer;
begin
if Target'Address = Source'Address then
Clear (Target);
return;
end if;
Tgt := Target.First;
Src := Source.First;
loop
if Tgt = null then
while Src /= null loop
Insert_With_Hint
(Dst_Tree => Target,
Dst_Hint => null,
Src_Node => Src,
Dst_Node => New_Tgt_Node);
Src := Tree_Operations.Next (Src);
end loop;
return;
end if;
if Src = null then
return;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Target : With_Lock (Target.TC'Unrestricted_Access);
Lock_Source : With_Lock (Source.TC'Unrestricted_Access);
begin
if Is_Less (Tgt, Src) then
Compare := -1;
elsif Is_Less (Src, Tgt) then
Compare := 1;
else
Compare := 0;
end if;
end;
if Compare < 0 then
Tgt := Tree_Operations.Next (Tgt);
elsif Compare > 0 then
Insert_With_Hint
(Dst_Tree => Target,
Dst_Hint => Tgt,
Src_Node => Src,
Dst_Node => New_Tgt_Node);
Src := Tree_Operations.Next (Src);
else
declare
X : Node_Access := Tgt;
begin
Tgt := Tree_Operations.Next (Tgt);
Tree_Operations.Delete_Node_Sans_Free (Target, X);
Free (X);
end;
Src := Tree_Operations.Next (Src);
end if;
end loop;
end Symmetric_Difference;
function Symmetric_Difference (Left, Right : Tree_Type) return Tree_Type is
begin
if Left'Address = Right'Address then
return Tree_Type'(others => <>); -- Empty set
end if;
if Right.Length = 0 then
return Copy (Left);
end if;
if Left.Length = 0 then
return Copy (Right);
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
Tree : Tree_Type;
L_Node : Node_Access;
R_Node : Node_Access;
Dst_Node : Node_Access;
pragma Warnings (Off, Dst_Node);
begin
L_Node := Left.First;
R_Node := Right.First;
loop
if L_Node = null then
while R_Node /= null loop
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => R_Node,
Dst_Node => Dst_Node);
R_Node := Tree_Operations.Next (R_Node);
end loop;
exit;
end if;
if R_Node = null then
while L_Node /= null loop
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => L_Node,
Dst_Node => Dst_Node);
L_Node := Tree_Operations.Next (L_Node);
end loop;
exit;
end if;
if Is_Less (L_Node, R_Node) then
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => L_Node,
Dst_Node => Dst_Node);
L_Node := Tree_Operations.Next (L_Node);
elsif Is_Less (R_Node, L_Node) then
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => null,
Src_Node => R_Node,
Dst_Node => Dst_Node);
R_Node := Tree_Operations.Next (R_Node);
else
L_Node := Tree_Operations.Next (L_Node);
R_Node := Tree_Operations.Next (R_Node);
end if;
end loop;
return Tree;
exception
when others =>
Delete_Tree (Tree.Root);
raise;
end;
end Symmetric_Difference;
-----------
-- Union --
-----------
procedure Union (Target : in out Tree_Type; Source : Tree_Type) is
Hint : Node_Access;
procedure Process (Node : Node_Access);
pragma Inline (Process);
procedure Iterate is new Tree_Operations.Generic_Iteration (Process);
-------------
-- Process --
-------------
procedure Process (Node : Node_Access) is
begin
Insert_With_Hint
(Dst_Tree => Target,
Dst_Hint => Hint, -- use node most recently inserted as hint
Src_Node => Node,
Dst_Node => Hint);
end Process;
-- Start of processing for Union
begin
if Target'Address = Source'Address then
return;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Source : With_Lock (Source.TC'Unrestricted_Access);
begin
Iterate (Source);
end;
end Union;
function Union (Left, Right : Tree_Type) return Tree_Type is
begin
if Left'Address = Right'Address then
return Copy (Left);
end if;
if Left.Length = 0 then
return Copy (Right);
end if;
if Right.Length = 0 then
return Copy (Left);
end if;
declare
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
Tree : Tree_Type := Copy (Left);
Hint : Node_Access;
procedure Process (Node : Node_Access);
pragma Inline (Process);
procedure Iterate is
new Tree_Operations.Generic_Iteration (Process);
-------------
-- Process --
-------------
procedure Process (Node : Node_Access) is
begin
Insert_With_Hint
(Dst_Tree => Tree,
Dst_Hint => Hint, -- use node most recently inserted as hint
Src_Node => Node,
Dst_Node => Hint);
end Process;
-- Start of processing for Union
begin
Iterate (Right);
return Tree;
exception
when others =>
Delete_Tree (Tree.Root);
raise;
end;
end Union;
end Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.