repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
rveenker/sdlada | Ada | 2,165 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
private with SDL.C_Pointers;
package body SDL.Inputs.Joysticks.Game_Controllers.Makers is
package C renames Interfaces.C;
use type C.int;
use type SDL.C_Pointers.Game_Controller_Pointer;
function SDL_Game_Controller_Open (Device : in C.int) return SDL.C_Pointers.Game_Controller_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerOpen";
function Create (Device : in Devices) return Game_Controller is
begin
return J : Game_Controller := (Ada.Finalization.Limited_Controlled with
Internal => SDL_Game_Controller_Open (C.int (Device) - 1), Owns => True) do
null;
end return;
end Create;
procedure Create (Device : in Devices; Actual_Controller : out Game_Controller) is
begin
Actual_Controller.Internal := SDL_Game_Controller_Open (C.int (Device) - 1);
end Create;
end SDL.Inputs.Joysticks.Game_Controllers.Makers;
|
zhmu/ananas | Ada | 17,091 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . M M A P --
-- --
-- B o d y --
-- --
-- Copyright (C) 2007-2022, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- 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.IO_Exceptions;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Strings; use System.Strings;
with System.Mmap.OS_Interface; use System.Mmap.OS_Interface;
package body System.Mmap is
type Mapped_File_Record is record
Current_Region : Mapped_Region;
-- The legacy API enables only one region to be mapped, directly
-- associated with the mapped file. This references this region.
File : System_File;
-- Underlying OS-level file
end record;
type Mapped_Region_Record is record
File : Mapped_File;
-- The file this region comes from. Be careful: for reading file, it is
-- valid to have it closed before one of its regions is free'd.
Write : Boolean;
-- Whether the file this region comes from is open for writing.
Data : Str_Access;
-- Unbounded access to the mapped content.
System_Offset : File_Size;
-- Position in the file of the first byte actually mapped in memory
User_Offset : File_Size;
-- Position in the file of the first byte requested by the user
System_Size : File_Size;
-- Size of the region actually mapped in memory
User_Size : File_Size;
-- Size of the region requested by the user
Mapped : Boolean;
-- Whether this region is actually memory mapped
Mutable : Boolean;
-- If the file is opened for reading, wheter this region is writable
Buffer : System.Strings.String_Access;
-- When this region is not actually memory mapped, contains the
-- requested bytes.
Mapping : System_Mapping;
-- Underlying OS-level data for the mapping, if any
end record;
Invalid_Mapped_Region_Record : constant Mapped_Region_Record :=
(null, False, null, 0, 0, 0, 0, False, False, null,
Invalid_System_Mapping);
Invalid_Mapped_File_Record : constant Mapped_File_Record :=
(Invalid_Mapped_Region, Invalid_System_File);
Empty_String : constant String := "";
-- Used to provide a valid empty Data for empty files, for instanc.
procedure Dispose is new Ada.Unchecked_Deallocation
(Mapped_File_Record, Mapped_File);
procedure Dispose is new Ada.Unchecked_Deallocation
(Mapped_Region_Record, Mapped_Region);
function Convert is new Ada.Unchecked_Conversion
(Standard.System.Address, Str_Access);
procedure Compute_Data (Region : Mapped_Region);
-- Fill the Data field according to system and user offsets. The region
-- must actually be mapped or bufferized.
procedure From_Disk (Region : Mapped_Region);
-- Read a region of some file from the disk
procedure To_Disk (Region : Mapped_Region);
-- Write the region of the file back to disk if necessary, and free memory
----------------------------
-- Open_Read_No_Exception --
----------------------------
function Open_Read_No_Exception
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return Mapped_File
is
File : constant System_File :=
Open_Read (Filename, Use_Mmap_If_Available);
begin
if File = Invalid_System_File then
return Invalid_Mapped_File;
end if;
return new Mapped_File_Record'
(Current_Region => Invalid_Mapped_Region,
File => File);
end Open_Read_No_Exception;
---------------
-- Open_Read --
---------------
function Open_Read
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return Mapped_File
is
Res : constant Mapped_File :=
Open_Read_No_Exception (Filename, Use_Mmap_If_Available);
begin
if Res = Invalid_Mapped_File then
raise Ada.IO_Exceptions.Name_Error
with "Cannot open " & Filename;
else
return Res;
end if;
end Open_Read;
----------------
-- Open_Write --
----------------
function Open_Write
(Filename : String;
Use_Mmap_If_Available : Boolean := True) return Mapped_File
is
File : constant System_File :=
Open_Write (Filename, Use_Mmap_If_Available);
begin
if File = Invalid_System_File then
raise Ada.IO_Exceptions.Name_Error
with "Cannot open " & Filename;
else
return new Mapped_File_Record'
(Current_Region => Invalid_Mapped_Region,
File => File);
end if;
end Open_Write;
-----------
-- Close --
-----------
procedure Close (File : in out Mapped_File) is
begin
-- Closing a closed file is allowed and should do nothing
if File = Invalid_Mapped_File then
return;
end if;
if File.Current_Region /= null then
Free (File.Current_Region);
end if;
if File.File /= Invalid_System_File then
Close (File.File);
end if;
Dispose (File);
end Close;
----------
-- Free --
----------
procedure Free (Region : in out Mapped_Region) is
Ignored : Integer;
pragma Unreferenced (Ignored);
begin
-- Freeing an already free'd file is allowed and should do nothing
if Region = Invalid_Mapped_Region then
return;
end if;
if Region.Mapping /= Invalid_System_Mapping then
Dispose_Mapping (Region.Mapping);
end if;
To_Disk (Region);
Dispose (Region);
end Free;
----------
-- Read --
----------
procedure Read
(File : Mapped_File;
Region : in out Mapped_Region;
Offset : File_Size := 0;
Length : File_Size := 0;
Mutable : Boolean := False)
is
File_Length : constant File_Size := Mmap.Length (File);
Req_Offset : constant File_Size := Offset;
Req_Length : File_Size := Length;
-- Offset and Length of the region to map, used to adjust mapping
-- bounds, reflecting what the user will see.
Region_Allocated : Boolean := False;
begin
-- If this region comes from another file, or simply if the file is
-- writeable, we cannot re-use this mapping: free it first.
if Region /= Invalid_Mapped_Region
and then
(Region.File /= File or else File.File.Write)
then
Free (Region);
end if;
if Region = Invalid_Mapped_Region then
Region := new Mapped_Region_Record'(Invalid_Mapped_Region_Record);
Region_Allocated := True;
end if;
Region.File := File;
if Req_Offset >= File_Length then
-- If the requested offset goes beyond file size, map nothing
Req_Length := 0;
elsif Length = 0
or else
Length > File_Length - Req_Offset
then
-- If Length is 0 or goes beyond file size, map till end of file
Req_Length := File_Length - Req_Offset;
else
Req_Length := Length;
end if;
-- Past this point, the offset/length the user will see is fixed. On the
-- other hand, the system offset/length is either already defined, from
-- a previous mapping, or it is set to 0. In the latter case, the next
-- step will set them according to the mapping.
Region.User_Offset := Req_Offset;
Region.User_Size := Req_Length;
-- If the requested region is inside an already mapped region, adjust
-- user-requested data and do nothing else.
if (File.File.Write or else Region.Mutable = Mutable)
and then
Req_Offset >= Region.System_Offset
and then
(Req_Offset + Req_Length
<= Region.System_Offset + Region.System_Size)
then
Region.User_Offset := Req_Offset;
Compute_Data (Region);
return;
elsif Region.Buffer /= null then
-- Otherwise, as we are not going to re-use the buffer, free it
System.Strings.Free (Region.Buffer);
Region.Buffer := null;
elsif Region.Mapping /= Invalid_System_Mapping then
-- Otherwise, there is a memory mapping that we need to unmap.
Dispose_Mapping (Region.Mapping);
end if;
-- mmap() will sometimes return NULL when the file exists but is empty,
-- which is not what we want, so in the case of a zero length file we
-- fall back to read(2)/write(2)-based mode.
if File_Length > 0 and then File.File.Mapped then
Region.System_Offset := Req_Offset;
Region.System_Size := Req_Length;
Create_Mapping
(File.File,
Region.System_Offset, Region.System_Size,
Mutable,
Region.Mapping);
Region.Mapped := True;
Region.Mutable := Mutable;
else
-- There is no alignment requirement when manually reading the file.
Region.System_Offset := Req_Offset;
Region.System_Size := Req_Length;
Region.Mapped := False;
Region.Mutable := True;
From_Disk (Region);
end if;
Region.Write := File.File.Write;
Compute_Data (Region);
exception
when others =>
-- Before propagating any exception, free any region we allocated
-- here.
if Region_Allocated then
Dispose (Region);
end if;
raise;
end Read;
----------
-- Read --
----------
procedure Read
(File : Mapped_File;
Offset : File_Size := 0;
Length : File_Size := 0;
Mutable : Boolean := False)
is
begin
Read (File, File.Current_Region, Offset, Length, Mutable);
end Read;
----------
-- Read --
----------
function Read
(File : Mapped_File;
Offset : File_Size := 0;
Length : File_Size := 0;
Mutable : Boolean := False) return Mapped_Region
is
Region : Mapped_Region := Invalid_Mapped_Region;
begin
Read (File, Region, Offset, Length, Mutable);
return Region;
end Read;
------------
-- Length --
------------
function Length (File : Mapped_File) return File_Size is
begin
return File.File.Length;
end Length;
------------
-- Offset --
------------
function Offset (Region : Mapped_Region) return File_Size is
begin
return Region.User_Offset;
end Offset;
------------
-- Offset --
------------
function Offset (File : Mapped_File) return File_Size is
begin
return Offset (File.Current_Region);
end Offset;
----------
-- Last --
----------
function Last (Region : Mapped_Region) return Integer is
begin
return Integer (Region.User_Size);
end Last;
----------
-- Last --
----------
function Last (File : Mapped_File) return Integer is
begin
return Last (File.Current_Region);
end Last;
-------------------
-- To_Str_Access --
-------------------
function To_Str_Access
(Str : System.Strings.String_Access) return Str_Access is
begin
if Str = null then
return null;
else
return Convert (Str.all'Address);
end if;
end To_Str_Access;
----------
-- Data --
----------
function Data (Region : Mapped_Region) return Str_Access is
begin
return Region.Data;
end Data;
----------
-- Data --
----------
function Data (File : Mapped_File) return Str_Access is
begin
return Data (File.Current_Region);
end Data;
----------------
-- Is_Mutable --
----------------
function Is_Mutable (Region : Mapped_Region) return Boolean is
begin
return Region.Mutable or Region.Write;
end Is_Mutable;
----------------
-- Is_Mmapped --
----------------
function Is_Mmapped (File : Mapped_File) return Boolean is
begin
return File.File.Mapped;
end Is_Mmapped;
-------------------
-- Get_Page_Size --
-------------------
function Get_Page_Size return Integer is
Result : constant File_Size := Get_Page_Size;
begin
return Integer (Result);
end Get_Page_Size;
---------------------
-- Read_Whole_File --
---------------------
function Read_Whole_File
(Filename : String;
Empty_If_Not_Found : Boolean := False)
return System.Strings.String_Access
is
File : Mapped_File := Open_Read (Filename);
Region : Mapped_Region renames File.Current_Region;
Result : String_Access;
begin
Read (File);
if Region.Data /= null then
Result := new String'(String
(Region.Data (1 .. Last (Region))));
elsif Region.Buffer /= null then
Result := Region.Buffer;
Region.Buffer := null; -- So that it is not deallocated
end if;
Close (File);
return Result;
exception
when Ada.IO_Exceptions.Name_Error =>
if Empty_If_Not_Found then
return new String'("");
else
return null;
end if;
when others =>
Close (File);
return null;
end Read_Whole_File;
---------------
-- From_Disk --
---------------
procedure From_Disk (Region : Mapped_Region) is
begin
pragma Assert (Region.File.all /= Invalid_Mapped_File_Record);
pragma Assert (Region.Buffer = null);
Region.Buffer := Read_From_Disk
(Region.File.File, Region.User_Offset, Region.User_Size);
Region.Mapped := False;
end From_Disk;
-------------
-- To_Disk --
-------------
procedure To_Disk (Region : Mapped_Region) is
begin
if Region.Write and then Region.Buffer /= null then
pragma Assert (Region.File.all /= Invalid_Mapped_File_Record);
Write_To_Disk
(Region.File.File,
Region.User_Offset, Region.User_Size,
Region.Buffer);
end if;
System.Strings.Free (Region.Buffer);
Region.Buffer := null;
end To_Disk;
------------------
-- Compute_Data --
------------------
procedure Compute_Data (Region : Mapped_Region) is
Base_Data : Str_Access;
-- Address of the first byte actually mapped in memory
Data_Shift : constant Integer :=
Integer (Region.User_Offset - Region.System_Offset);
begin
if Region.User_Size = 0 then
Region.Data := Convert (Empty_String'Address);
return;
elsif Region.Mapped then
Base_Data := Convert (Region.Mapping.Address);
else
Base_Data := Convert (Region.Buffer.all'Address);
end if;
Region.Data := Convert (Base_Data (Data_Shift + 1)'Address);
end Compute_Data;
end System.Mmap;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 3,724 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package HAL.I2C is
type I2C_Status is
(Ok,
Err_Error,
Err_Timeout,
Busy);
subtype I2C_Data is UInt8_Array;
type I2C_Memory_Address_Size is
(Memory_Size_8b,
Memory_Size_16b);
subtype I2C_Address is UInt10;
type I2C_Port is limited interface;
type Any_I2C_Port is access all I2C_Port'Class;
procedure Master_Transmit
(This : in out I2C_Port;
Addr : I2C_Address;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000) is abstract;
procedure Master_Receive
(This : in out I2C_Port;
Addr : I2C_Address;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000) is abstract;
procedure Mem_Write
(This : in out I2C_Port;
Addr : I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000) is abstract;
procedure Mem_Read
(This : in out I2C_Port;
Addr : I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000) is abstract;
end HAL.I2C;
|
KLOC-Karsten/adaoled | Ada | 531 | ads |
with Interfaces; use Interfaces;
with Interfaces.C; use Interfaces.C;
package GPIO is
function Init return Unsigned_8;
pragma Import (C, Init, "bcm2835_init");
procedure Close;
pragma Import (C, Close, "bcm2835_close");
procedure Write(Pin: Unsigned_16; Value: Unsigned_8);
pragma Import (C, Write, "bcm2835_gpio_write");
MODE_INPUT : Unsigned_8 := 0;
MODE_OUTPUT : Unsigned_8 := 1;
procedure Set_Mode(Pin: Unsigned_16; Value: Unsigned_8);
pragma Import (C, Set_Mode, "bcm2835_gpio_fsel");
end GPIO;
|
reznikmm/matreshka | Ada | 6,590 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- 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 Asis.Declarations;
package body Properties.Declarations.Element_Iterator_Specification is
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Text_Property)
return League.Strings.Universal_String
is
pragma Unreferenced (Name);
Text : League.Strings.Universal_String;
Index : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_ind");
begin
Text.Append (Index);
Text.Append ("++");
return Text;
end Code;
---------------
-- Condition --
---------------
function Condition
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Text_Property)
return League.Strings.Universal_String
is
pragma Unreferenced (Name);
Text : League.Strings.Universal_String;
Down : League.Strings.Universal_String;
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (Element);
Arr : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_arr");
Length : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_len");
Index : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_ind");
begin
Text.Append (Index);
Text.Append ("<");
Text.Append (Length);
Text.Append ("&&(");
Down := Engine.Text.Get_Property (Names (1), Engines.Code);
Text.Append (Down);
Text.Append ("=");
Text.Append (Arr);
Text.Append ("[");
Text.Append (Index);
Text.Append ("],true)");
return Text;
end Condition;
----------------
-- Initialize --
----------------
function Initialize
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Text_Property)
return League.Strings.Universal_String
is
pragma Unreferenced (Name);
Text : League.Strings.Universal_String;
Down : League.Strings.Universal_String;
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (Element);
Arr : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_arr");
Length : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_len");
Index : constant League.Strings.Universal_String :=
Engine.Unique.Get (Element, "_ind");
Iter : constant Asis.Discrete_Subtype_Definition :=
Asis.Declarations.Iteration_Scheme_Name (Element);
begin
Text.Append ("var ");
Text.Append (Arr);
Text.Append ("=");
Down := Engine.Text.Get_Property (Iter, Engines.Code);
Text.Append (Down);
Text.Append (".A,");
Text.Append (Length);
Text.Append ("=");
Text.Append (Arr);
Text.Append (".length,");
Text.Append (Index);
Text.Append ("=0,");
Down := Engine.Text.Get_Property (Names (1), Engines.Code);
Text.Append (Down);
return Text;
end Initialize;
end Properties.Declarations.Element_Iterator_Specification;
|
reznikmm/matreshka | Ada | 3,704 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Attributes;
package ODF.DOM.Fo_End_Indent_Attributes is
pragma Preelaborate;
type ODF_Fo_End_Indent_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Fo_End_Indent_Attribute_Access is
access all ODF_Fo_End_Indent_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Fo_End_Indent_Attributes;
|
AdaCore/gpr | Ada | 1,798 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
package body GPR2.Project.Unit_Info is
------------
-- Create --
------------
function Create
(Name : Name_Type;
Spec : Unit.Source_Unit_Identifier := Unit.Undefined_Id;
Main_Body : Unit.Source_Unit_Identifier := Unit.Undefined_Id;
Separates : Unit.Source_Unit_Vectors.Vector :=
Unit.Source_Unit_Vectors.Empty_Vector) return Object is
begin
return Object'(To_Unbounded_String (String (Name)),
Spec,
Main_Body,
Separates);
end Create;
-----------------
-- Remove_Body --
-----------------
procedure Remove_Body (Self : in out Object) is
begin
Self.Main_Body := Unit.Undefined_Id;
end Remove_Body;
-----------------
-- Update_Body --
-----------------
procedure Update_Body
(Self : in out Object; Source : Unit.Source_Unit_Identifier) is
begin
Self.Main_Body := Source;
end Update_Body;
-----------------
-- Update_Name --
-----------------
procedure Update_Name
(Self : in out Object; Name : Name_Type) is
begin
Self.Name := To_Unbounded_String (String (Name));
end Update_Name;
----------------------
-- Update_Separates --
----------------------
procedure Update_Separates
(Self : in out Object; Source : Unit.Source_Unit_Identifier) is
begin
Self.Separates.Append (Source);
end Update_Separates;
-----------------
-- Update_Spec --
-----------------
procedure Update_Spec
(Self : in out Object; Source : Unit.Source_Unit_Identifier) is
begin
Self.Spec := Source;
end Update_Spec;
end GPR2.Project.Unit_Info;
|
AdaCore/training_material | Ada | 1,075 | ads | with Display.Basic.Utils; use Display.Basic.Utils;
with SDL_SDL_stdinc_h; use SDL_SDL_stdinc_h;
with SDL_SDL_video_h; use SDL_SDL_video_h;
package Display.Basic.Fonts is
type BMP_Font is (Font8x8, Font12x12, Font16x24);
procedure Draw_Char
(S : access SDL_Surface;
P : Screen_Point;
Char : Character;
Font : BMP_Font;
FG, BG : Uint32);
procedure Draw_Char
(Canvas : T_Internal_Canvas;
P : Screen_Point;
Char : Character;
Font : BMP_Font;
FG, BG : Uint32);
procedure Draw_String
(S : access SDL_Surface;
P : Screen_Point;
Str : String;
Font : BMP_Font;
FG, BG : RGBA_T;
Wrap : Boolean := False);
procedure Draw_String
(Canvas : T_Internal_Canvas;
P : Screen_Point;
Str : String;
Font : BMP_Font;
FG, BG : RGBA_T;
Wrap : Boolean := False);
function Char_Size (Font : BMP_Font) return Screen_Point;
function String_Size (Font : BMP_Font; Text : String) return Screen_Point;
end Display.Basic.Fonts;
|
zhmu/ananas | Ada | 3,398 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . E X C E P T I O N S _ D E B U G --
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2022, 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 System.Exceptions_Debug is
---------------------------
-- Debug_Raise_Exception --
---------------------------
procedure Debug_Raise_Exception
(E : SSL.Exception_Data_Ptr; Message : String)
is
pragma Inspection_Point (E, Message);
begin
null;
end Debug_Raise_Exception;
-------------------------------
-- Debug_Unhandled_Exception --
-------------------------------
procedure Debug_Unhandled_Exception (E : SSL.Exception_Data_Ptr) is
pragma Inspection_Point (E);
begin
null;
end Debug_Unhandled_Exception;
--------------------------------
-- Debug_Raise_Assert_Failure --
--------------------------------
procedure Debug_Raise_Assert_Failure is
begin
null;
end Debug_Raise_Assert_Failure;
-----------------
-- Local_Raise --
-----------------
procedure Local_Raise (Excep : System.Address) is
pragma Warnings (Off, Excep);
begin
return;
end Local_Raise;
end System.Exceptions_Debug;
|
twdroeger/ada-awa | Ada | 16,839 | ads | -----------------------------------------------------------------------
-- AWA.Images.Models -- AWA.Images.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with ADO.Queries;
with ADO.Queries.Loaders;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
with AWA.Storages.Models;
with AWA.Users.Models;
with Util.Beans.Methods;
pragma Warnings (On);
package AWA.Images.Models is
pragma Style_Checks ("-mr");
type Image_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- - The workspace contains one or several folders.
-- - Each image folder contains a set of images that have been uploaded by the user.
-- - An image can be visible if a user has an ACL permission to read the associated folder.
-- - An image marked as 'public=True' can be visible by anybody
-- --------------------
-- Create an object key for Image.
function Image_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Image from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Image_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Image : constant Image_Ref;
function "=" (Left, Right : Image_Ref'Class) return Boolean;
-- Set the image identifier
procedure Set_Id (Object : in out Image_Ref;
Value : in ADO.Identifier);
-- Get the image identifier
function Get_Id (Object : in Image_Ref)
return ADO.Identifier;
-- Set the image width
procedure Set_Width (Object : in out Image_Ref;
Value : in Integer);
-- Get the image width
function Get_Width (Object : in Image_Ref)
return Integer;
-- Set the image height
procedure Set_Height (Object : in out Image_Ref;
Value : in Integer);
-- Get the image height
function Get_Height (Object : in Image_Ref)
return Integer;
-- Set the thumbnail width
procedure Set_Thumb_Width (Object : in out Image_Ref;
Value : in Integer);
-- Get the thumbnail width
function Get_Thumb_Width (Object : in Image_Ref)
return Integer;
-- Set the thumbnail height
procedure Set_Thumb_Height (Object : in out Image_Ref;
Value : in Integer);
-- Get the thumbnail height
function Get_Thumb_Height (Object : in Image_Ref)
return Integer;
--
procedure Set_Path (Object : in out Image_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Path (Object : in out Image_Ref;
Value : in String);
--
function Get_Path (Object : in Image_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Path (Object : in Image_Ref)
return String;
--
procedure Set_Public (Object : in out Image_Ref;
Value : in Boolean);
--
function Get_Public (Object : in Image_Ref)
return Boolean;
--
function Get_Version (Object : in Image_Ref)
return Integer;
--
procedure Set_Thumbnail (Object : in out Image_Ref;
Value : in AWA.Storages.Models.Storage_Ref'Class);
--
function Get_Thumbnail (Object : in Image_Ref)
return AWA.Storages.Models.Storage_Ref'Class;
--
procedure Set_Folder (Object : in out Image_Ref;
Value : in AWA.Storages.Models.Storage_Folder_Ref'Class);
--
function Get_Folder (Object : in Image_Ref)
return AWA.Storages.Models.Storage_Folder_Ref'Class;
--
procedure Set_Owner (Object : in out Image_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
--
function Get_Owner (Object : in Image_Ref)
return AWA.Users.Models.User_Ref'Class;
--
procedure Set_Storage (Object : in out Image_Ref;
Value : in AWA.Storages.Models.Storage_Ref'Class);
--
function Get_Storage (Object : in Image_Ref)
return AWA.Storages.Models.Storage_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Image_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Image_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Image_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Image_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Image_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Image_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
IMAGE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Image_Ref);
-- Copy of the object.
procedure Copy (Object : in Image_Ref;
Into : in out Image_Ref);
package Image_Vectors is
new Ada.Containers.Vectors (Index_Type => Natural,
Element_Type => Image_Ref,
"=" => "=");
subtype Image_Vector is Image_Vectors.Vector;
procedure List (Object : in out Image_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
-- --------------------
-- The information about an image.
-- --------------------
type Image_Bean is abstract
new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
-- the image folder identifier.
Folder_Id : ADO.Identifier;
-- the image folder name.
Folder_Name : Ada.Strings.Unbounded.Unbounded_String;
-- the image file identifier.
Id : ADO.Identifier;
-- the image file name.
Name : Ada.Strings.Unbounded.Unbounded_String;
-- the file creation date.
Create_Date : Ada.Calendar.Time;
-- the file storage URI.
Uri : Ada.Strings.Unbounded.Unbounded_String;
-- the file storage URI.
Storage : AWA.Storages.Models.Storage_Type;
-- the file mime type.
Mime_Type : Ada.Strings.Unbounded.Unbounded_String;
-- the file size.
File_Size : Integer;
-- whether the image is public.
Is_Public : Boolean;
-- the image width.
Width : Integer;
-- the image height.
Height : Integer;
end record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Image_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Image_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Image_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Load (Bean : in out Image_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
-- Read in the object the data from the query result and prepare to read the next row.
-- If there is no row, raise the ADO.NOT_FOUND exception.
procedure Read (Into : in out Image_Bean;
Stmt : in out ADO.Statements.Query_Statement'Class);
-- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>.
procedure Load (Object : in out Image_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class);
Query_Image_Info : constant ADO.Queries.Query_Definition_Access;
-- --------------------
-- The list of images for a given folder.
-- --------------------
type Image_Info is
new Util.Beans.Basic.Bean with record
-- the storage identifier which contains the image data.
Id : ADO.Identifier;
-- the image file name.
Name : Ada.Strings.Unbounded.Unbounded_String;
-- the image file creation date.
Create_Date : Ada.Calendar.Time;
-- the image file storage URI.
Uri : Ada.Strings.Unbounded.Unbounded_String;
-- the image file storage URI.
Storage : Integer;
-- the image file mime type.
Mime_Type : Ada.Strings.Unbounded.Unbounded_String;
-- the image file size.
File_Size : Integer;
-- the image width.
Width : Integer;
-- the image height.
Height : Integer;
-- the image thumbnail width.
Thumb_Width : Integer;
-- the image thumbnail height.
Thumb_Height : Integer;
-- the image thumbnail identifier.
Thumbnail_Id : ADO.Identifier;
end record;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Image_Info;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Image_Info;
Name : in String;
Value : in Util.Beans.Objects.Object);
package Image_Info_Beans is
new Util.Beans.Basic.Lists (Element_Type => Image_Info);
package Image_Info_Vectors renames Image_Info_Beans.Vectors;
subtype Image_Info_List_Bean is Image_Info_Beans.List_Bean;
type Image_Info_List_Bean_Access is access all Image_Info_List_Bean;
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
procedure List (Object : in out Image_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class);
subtype Image_Info_Vector is Image_Info_Vectors.Vector;
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
procedure List (Object : in out Image_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class);
Query_Image_List : constant ADO.Queries.Query_Definition_Access;
private
IMAGE_NAME : aliased constant String := "awa_image";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "width";
COL_2_1_NAME : aliased constant String := "height";
COL_3_1_NAME : aliased constant String := "thumb_width";
COL_4_1_NAME : aliased constant String := "thumb_height";
COL_5_1_NAME : aliased constant String := "path";
COL_6_1_NAME : aliased constant String := "public";
COL_7_1_NAME : aliased constant String := "version";
COL_8_1_NAME : aliased constant String := "thumbnail_id";
COL_9_1_NAME : aliased constant String := "folder_id";
COL_10_1_NAME : aliased constant String := "owner_id";
COL_11_1_NAME : aliased constant String := "storage_id";
IMAGE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 12,
Table => IMAGE_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access,
7 => COL_6_1_NAME'Access,
8 => COL_7_1_NAME'Access,
9 => COL_8_1_NAME'Access,
10 => COL_9_1_NAME'Access,
11 => COL_10_1_NAME'Access,
12 => COL_11_1_NAME'Access)
);
IMAGE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= IMAGE_DEF'Access;
Null_Image : constant Image_Ref
:= Image_Ref'(ADO.Objects.Object_Ref with null record);
type Image_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => IMAGE_DEF'Access)
with record
Width : Integer;
Height : Integer;
Thumb_Width : Integer;
Thumb_Height : Integer;
Path : Ada.Strings.Unbounded.Unbounded_String;
Public : Boolean;
Version : Integer;
Thumbnail : AWA.Storages.Models.Storage_Ref;
Folder : AWA.Storages.Models.Storage_Folder_Ref;
Owner : AWA.Users.Models.User_Ref;
Storage : AWA.Storages.Models.Storage_Ref;
end record;
type Image_Access is access all Image_Impl;
overriding
procedure Destroy (Object : access Image_Impl);
overriding
procedure Find (Object : in out Image_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Image_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Image_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Image_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Image_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Image_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Image_Ref'Class;
Impl : out Image_Access);
package File_1 is
new ADO.Queries.Loaders.File (Path => "image-info.xml",
Sha1 => "34E7D6E28ABCCCD3FA2E611655FCEAD246E0160F");
package Def_Imagebean_Image_Info is
new ADO.Queries.Loaders.Query (Name => "image-info",
File => File_1.File'Access);
Query_Image_Info : constant ADO.Queries.Query_Definition_Access
:= Def_Imagebean_Image_Info.Query'Access;
package File_2 is
new ADO.Queries.Loaders.File (Path => "image-list.xml",
Sha1 => "6A8E69BE2D48CAE5EEE4093D819F4015C272A10C");
package Def_Imageinfo_Image_List is
new ADO.Queries.Loaders.Query (Name => "image-list",
File => File_2.File'Access);
Query_Image_List : constant ADO.Queries.Query_Definition_Access
:= Def_Imageinfo_Image_List.Query'Access;
end AWA.Images.Models;
|
reznikmm/matreshka | Ada | 3,689 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Elements;
package ODF.DOM.Text_Execute_Macro_Elements is
pragma Preelaborate;
type ODF_Text_Execute_Macro is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Execute_Macro_Access is
access all ODF_Text_Execute_Macro'Class
with Storage_Size => 0;
end ODF.DOM.Text_Execute_Macro_Elements;
|
jhumphry/PRNG_Zoo | Ada | 13,680 | adb | --
-- PRNG Zoo
-- Copyright (c) 2014 - 2015, James Humphry
--
-- 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.
with AUnit.Assertions; use AUnit.Assertions;
with PRNG_Zoo.MT;
use all type PRNG_Zoo.MT.MT19937;
use all type PRNG_Zoo.MT.MT19937_64;
use all type PRNG_Zoo.MT.TinyMT_64;
package body PRNGTests_Suite.MT_Tests is
--------------------
-- Register_Tests --
--------------------
procedure Register_Tests (T: in out MT_Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Sanity_Check_MT19937'Access, "Basic sanity checks on MT19937 generator.");
Register_Routine (T, Sanity_Check_MT19937_64'Access, "Basic sanity checks on MT19937_64 generator.");
Register_Routine (T, Sanity_Check_TinyMT_64'Access, "Basic sanity checks on TinyMT_64 generator.");
Register_Routine (T, Test_MT19937'Access, "Test MT19937 generator against expected (initial) output");
Register_Routine (T, Test_MT19937_64'Access, "Test MT19937_64 generator against expected (initial) output");
Register_Routine (T, Test_TinyMT_64'Access, "Test TinyMT_64 generator against expected (initial) output");
end Register_Tests;
----------
-- Name --
----------
function Name (T : MT_Test) return Test_String is
pragma Unreferenced (T);
begin
return Format ("Mersenne Twister PRNG Tests");
end Name;
------------
-- Set_Up --
------------
procedure Set_Up (T : in out MT_Test) is
begin
null;
end Set_Up;
------------------
-- Test_MT19937 --
------------------
procedure Test_MT19937 (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
G : MT.MT19937;
-- This array was generated from a quick C program using the
-- canonical C version of MT19937 (2002 version) with initial seed array
-- {0x123, 0x234, 0x345, 0x456}, as used in the demonstration code
-- from the authors
Expected_Array : constant U32_array := (
1067595299, 955945823, 477289528, 4107218783,
4228976476, 3344332714, 3355579695, 227628506,
810200273, 2591290167, 2560260675, 3242736208,
646746669, 1479517882, 4245472273, 1143372638,
3863670494, 3221021970, 1773610557, 1138697238,
1421897700, 1269916527, 2859934041, 1764463362,
3874892047, 3965319921, 72549643, 2383988930,
2600218693, 3237492380, 2792901476, 725331109,
605841842, 271258942, 715137098, 3297999536,
1322965544, 4229579109, 1395091102, 3735697720,
2101727825, 3730287744, 2950434330, 1661921839,
2895579582, 2370511479, 1004092106, 2247096681,
2111242379, 3237345263, 4082424759, 219785033,
2454039889, 3709582971, 835606218, 2411949883,
2735205030, 756421180, 2175209704, 1873865952,
2762534237, 4161807854, 3351099340, 181129879
);
-- This array was generated from a quick C program using the
-- canonical C version of MT19937 (2002 version) with initial seed
-- 5489.
Expected_5489 : constant U32_array := (
3499211612, 581869302, 3890346734, 3586334585,
545404204, 4161255391, 3922919429, 949333985,
2715962298, 1323567403, 418932835, 2350294565,
1196140740, 809094426, 2348838239, 4264392720,
4112460519, 4279768804, 4144164697, 4156218106,
676943009, 3117454609, 4168664243, 4213834039,
4111000746, 471852626, 2084672536, 3427838553,
3437178460, 1275731771, 609397212, 20544909,
1811450929, 483031418, 3933054126, 2747762695,
3402504553, 3772830893, 4120988587, 2163214728,
2816384844, 3427077306, 153380495, 1551745920,
3646982597, 910208076, 4011470445, 2926416934,
2915145307, 1712568902, 3254469058, 3181055693,
3191729660, 2039073006, 1684602222, 1812852786,
2815256116, 746745227, 735241234, 1296707006,
3032444839, 3424291161, 136721026, 1359573808
);
begin
Reset(G, U64_array'(16#0123#, 16#0234#, 16#0345#, 16#0456#));
for E of Expected_Array loop
Assert(U32'(Generate(G)) = E,
"MT19937 implementation produces unexpected result for seed {0x123, 0x234, 0x345, 0x456}");
end loop;
Reset(G, 5489);
for E of Expected_5489 loop
Assert(U32'(Generate(G)) = E,
"MT19937 implementation produces unexpected result for seed 5489");
end loop;
end Test_MT19937;
---------------------
-- Test_MT19937_64 --
---------------------
procedure Test_MT19937_64 (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
G : MT.MT19937_64;
-- This array was generated from a quick C program using the
-- canonical C version of MT19937-64 (2004/9/29 version) with initial seed
-- array {0x12345ULL, 0x23456ULL, 0x34567ULL, 0x45678ULL}, as used in the
-- demonstration code from the authors
Expected_Array : constant U64_array := (
7266447313870364031, 4946485549665804864,
16945909448695747420, 16394063075524226720,
4873882236456199058, 14877448043947020171,
6740343660852211943, 13857871200353263164,
5249110015610582907, 10205081126064480383,
1235879089597390050, 17320312680810499042,
16489141110565194782, 8942268601720066061,
13520575722002588570, 14226945236717732373,
9383926873555417063, 15690281668532552105,
11510704754157191257, 15864264574919463609,
6489677788245343319, 5112602299894754389,
10828930062652518694, 15942305434158995996,
15445717675088218264, 4764500002345775851,
14673753115101942098, 236502320419669032,
13670483975188204088, 14931360615268175698,
8904234204977263924, 12836915408046564963,
12120302420213647524, 15755110976537356441,
5405758943702519480, 10951858968426898805,
17251681303478610375, 4144140664012008120,
18286145806977825275, 13075804672185204371,
10831805955733617705, 6172975950399619139,
12837097014497293886, 12903857913610213846,
560691676108914154, 1074659097419704618,
14266121283820281686, 11696403736022963346,
13383246710985227247, 7132746073714321322,
10608108217231874211, 9027884570906061560,
12893913769120703138, 15675160838921962454,
2511068401785704737, 14483183001716371453,
3774730664208216065, 5083371700846102796,
9583498264570933637, 17119870085051257224,
5217910858257235075, 10612176809475689857,
1924700483125896976, 7171619684536160599
);
begin
Reset(G, U64_array'(16#012345#, 16#023456#, 16#034567#, 16#045678#));
for E of Expected_Array loop
Assert(Generate(G) = E,
"MT19937-64 implementation produces unexpected result for seed {0x12345ULL, 0x23456ULL, 0x34567ULL, 0x45678ULL}");
end loop;
end Test_MT19937_64;
--------------------
-- Test_TinyMT_64 --
--------------------
procedure Test_TinyMT_64 (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
G : MT.TinyMT_64;
-- This array was generated from a quick C program using the
-- canonical C version of TinyMT-64 (2011 version) with initial seed
-- of 1, and parameters 0xfa051f40 0xffd0fff4 0x58d02ffeffbfffbc
-- as used in the demonstration code (check64.c) from the authors
Seed : constant U64 := 1;
Expected_Array : constant U64_array := (
15503804787016557143,17280942441431881838, 2177846447079362065,
10087979609567186558, 8925138365609588954,13030236470185662861,
4821755207395923002,11414418928600017220,18168456707151075513,
1749899882787913913, 2383809859898491614, 4819668342796295952,
11996915412652201592,11312565842793520524, 995000466268691999,
6363016470553061398, 7460106683467501926, 981478760989475592,
11852898451934348777, 5976355772385089998,16662491692959689977,
4997134580858653476,11142084553658001518,12405136656253403414,
10700258834832712655,13440132573874649640,15190104899818839732,
14179849157427519166,10328306841423370385, 9266343271776906817
);
Seed_Array : constant U64_array(0..0) := (others => 1);
Expected_Array_2 : constant U64_array := (
2316304586286922237, 15094277089150361724, 5685675787316092711,
15229481068059623199, 4714098425347676722, 16281862982583854132,
3901922025624662484, 5886484389080126014, 16107583395258923453,
13952088220369493459, 17758435316338264754, 2351799565271811353,
12362529980853249542, 1719516909033106250, 8766952554732792269,
7859523628104690493, 15389348425598624967, 5147268256773563271,
9499111560078684970, 667293060984396585, 16412518715911243540,
4644561915126619944, 7147182560776836637, 1588726635616164641,
14118193191231902733, 10534117574818039474, 5944505171977344673,
443288919934395040, 1633068730058384525, 17771926205819909233
);
begin
Reset(G, Seed);
for E of Expected_Array loop
Assert(Generate(G) = E,
"TinyMT_64 implementation produces unexpected result for seed 1");
end loop;
Reset(G, Seed_Array);
for E of Expected_Array_2 loop
Assert(Generate(G) = E,
"TinyMT_64 implementation produces unexpected result for array seed (1)");
end loop;
end Test_TinyMT_64;
end PRNGTests_Suite.MT_Tests;
|
reznikmm/matreshka | Ada | 4,091 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Style_Text_Underline_Style_Attributes;
package Matreshka.ODF_Style.Text_Underline_Style_Attributes is
type Style_Text_Underline_Style_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Text_Underline_Style_Attributes.ODF_Style_Text_Underline_Style_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Text_Underline_Style_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Underline_Style_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Text_Underline_Style_Attributes;
|
reznikmm/matreshka | Ada | 4,027 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Chart_Legend_Align_Attributes;
package Matreshka.ODF_Chart.Legend_Align_Attributes is
type Chart_Legend_Align_Attribute_Node is
new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node
and ODF.DOM.Chart_Legend_Align_Attributes.ODF_Chart_Legend_Align_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Legend_Align_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Chart_Legend_Align_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Chart.Legend_Align_Attributes;
|
AdaCore/libadalang | Ada | 263 | adb | procedure Foo is
-- Decl_Defines used to crash on the Anonymous_Type_Decl in the Char_Set
-- declaration because it has no name.
Char_Set : array (Character) of Boolean;
type Char_Set_Type is array (Character) of Boolean;
begin
null;
end Foo;
|
reznikmm/matreshka | Ada | 4,027 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Style_Column_Width_Attributes;
package Matreshka.ODF_Style.Column_Width_Attributes is
type Style_Column_Width_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Column_Width_Attributes.ODF_Style_Column_Width_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Column_Width_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Column_Width_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Column_Width_Attributes;
|
charlie5/lace | Ada | 16,267 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with box2d_c.Pointers;
with box2d_c.b2d_Contact;
with box2d_c.b2d_ray_Collision;
with box2d_c.joint_Cursor;
with c_math_c;
with c_math_c.Matrix_3x3;
with c_math_c.Matrix_4x4;
with c_math_c.Pointers;
with c_math_c.Vector_2;
with c_math_c.Vector_3;
with interfaces.c;
with swig;
package box2d_c.Binding is
function b2d_new_Circle (Radius : in c_math_c.Real) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Polygon (Vertices : in c_math_c.Vector_2.Pointer;
vertex_Count : in interfaces.c.int) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Box (half_Extents : in c_math_c.Vector_3.Pointer) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Capsule (Radii : in c_math_c.Vector_2.Pointer;
Height : in c_math_c.Real) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Cone (Radius : in c_math_c.Real;
Height : in c_math_c.Real) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_convex_Hull (Points : in c_math_c.Vector_3.Pointer;
point_Count : in interfaces.c.int) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Cylinder (half_Extents : in c_math_c.Vector_3.Pointer) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Heightfield (Width : in interfaces.c.int;
Depth : in interfaces.c.int;
Heights : in c_math_c.Pointers.Real_Pointer;
min_Height : in c_math_c.Real;
max_Height : in c_math_c.Real;
Scale : in c_math_c.Vector_3.Pointer) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_multiSphere (Positions : in c_math_c.Vector_3.Pointer;
Radii : in c_math_c.Pointers.Real_Pointer;
sphere_Count : in interfaces.c.int) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Plane (Normal : in c_math_c.Vector_3.Pointer;
Offset : in c_math_c.Real) return box2d_c.Pointers.Shape_Pointer;
function b2d_new_Sphere (Radius : in c_math_c.Real) return box2d_c.Pointers.Shape_Pointer;
procedure b2d_free_Shape (Self : in box2d_c.Pointers.Shape_Pointer);
function b2d_Shape_user_Data (Self : in box2d_c.Pointers.Shape_Pointer) return swig.void_ptr;
procedure b2d_Shape_user_Data_is (Self : in box2d_c.Pointers.Shape_Pointer;
Now : in swig.void_ptr);
procedure b2d_shape_Scale_is (Self : in box2d_c.Pointers.Shape_Pointer;
Now : in c_math_c.Vector_2.Item);
function b2d_new_Object (Site : in c_math_c.Vector_2.Pointer;
Mass : in c_math_c.Real;
Friction : in c_math_c.Real;
Restitution : in c_math_c.Real;
the_Shape : in box2d_c.Pointers.Shape_Pointer) return box2d_c.Pointers.Object_Pointer;
procedure b2d_free_Object (Self : in box2d_c.Pointers.Object_Pointer);
procedure b2d_Object_Scale_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Vector_2.Pointer);
function b2d_Object_Shape (Self : in box2d_c.Pointers.Object_Pointer) return box2d_c.Pointers.Shape_Pointer;
function b2d_Object_user_Data (Self : in box2d_c.Pointers.Object_Pointer) return swig.void_ptr;
procedure b2d_Object_user_Data_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in swig.void_ptr);
function b2d_Object_Mass (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Real;
procedure b2d_Object_Friction_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Real);
procedure b2d_Object_Restitution_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Real);
function b2d_Object_Site (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Vector_3.Item;
procedure b2d_Object_Site_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Vector_3.Pointer);
function b2d_Object_Spin (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Matrix_3x3.Item;
procedure b2d_Object_Spin_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Matrix_3x3.Pointer);
function b2d_Object_xy_Spin (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Real;
procedure b2d_Object_xy_Spin_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Real);
function b2d_Object_Transform (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Matrix_4x4.Item;
procedure b2d_Object_Transform_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Matrix_4x4.Pointer);
function b2d_Object_Speed (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Vector_3.Item;
procedure b2d_Object_Speed_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Vector_3.Pointer);
function b2d_Object_Gyre (Self : in box2d_c.Pointers.Object_Pointer) return c_math_c.Vector_3.Item;
procedure b2d_Object_Gyre_is (Self : in box2d_c.Pointers.Object_Pointer;
Now : in c_math_c.Vector_3.Pointer);
procedure b2d_Object_apply_Force (Self : in box2d_c.Pointers.Object_Pointer;
Force : in c_math_c.Vector_3.Pointer);
procedure b2d_Object_apply_Torque (Self : in box2d_c.Pointers.Object_Pointer;
Torque : in c_math_c.Vector_3.Pointer);
procedure b2d_Object_apply_Torque_impulse (Self : in box2d_c.Pointers.Object_Pointer;
Torque : in c_math_c.Vector_3.Pointer);
procedure b2d_dump (Self : in box2d_c.Pointers.Object_Pointer);
function b2d_new_hinge_Joint_with_local_anchors (in_Space : in box2d_c.Pointers.Space_Pointer;
Object_A : in box2d_c.Pointers.Object_Pointer;
Object_B : in box2d_c.Pointers.Object_Pointer;
Anchor_in_A : in c_math_c.Vector_3.Pointer;
Anchor_in_B : in c_math_c.Vector_3.Pointer;
low_Limit : in interfaces.c.c_float;
high_Limit : in interfaces.c.c_float;
collide_Connected : in swig.bool) return box2d_c.Pointers.Joint_Pointer;
function b2d_new_hinge_Joint (in_Space : in box2d_c.Pointers.Space_Pointer;
Object_A : in box2d_c.Pointers.Object_Pointer;
Object_B : in box2d_c.Pointers.Object_Pointer;
Frame_A : in c_math_c.Matrix_4x4.Pointer;
Frame_B : in c_math_c.Matrix_4x4.Pointer;
low_Limit : in interfaces.c.c_float;
high_Limit : in interfaces.c.c_float;
collide_Connected : in swig.bool) return box2d_c.Pointers.Joint_Pointer;
procedure b2d_free_hinge_Joint (Self : in box2d_c.Pointers.Joint_Pointer);
function b2d_new_space_hinge_Joint (Object_A : in box2d_c.Pointers.Object_Pointer;
Frame_A : in c_math_c.Matrix_4x4.Pointer) return box2d_c.Pointers.Joint_Pointer;
function b2d_new_DoF6_Joint (Object_A : in box2d_c.Pointers.Object_Pointer;
Object_B : in box2d_c.Pointers.Object_Pointer;
Frame_A : in c_math_c.Matrix_4x4.Pointer;
Frame_B : in c_math_c.Matrix_4x4.Pointer) return box2d_c.Pointers.Joint_Pointer;
function b2d_new_cone_twist_Joint (Object_A : in box2d_c.Pointers.Object_Pointer;
Object_B : in box2d_c.Pointers.Object_Pointer;
Frame_A : in c_math_c.Matrix_4x4.Pointer;
Frame_B : in c_math_c.Matrix_4x4.Pointer) return box2d_c.Pointers.Joint_Pointer;
function b2d_new_slider_Joint (Object_A : in box2d_c.Pointers.Object_Pointer;
Object_B : in box2d_c.Pointers.Object_Pointer;
Frame_A : in c_math_c.Matrix_4x4.Pointer;
Frame_B : in c_math_c.Matrix_4x4.Pointer) return box2d_c.Pointers.Joint_Pointer;
function b2d_new_ball_Joint (Object_A : in box2d_c.Pointers.Object_Pointer;
Object_B : in box2d_c.Pointers.Object_Pointer;
Pivot_in_A : in c_math_c.Vector_3.Pointer;
Pivot_in_B : in c_math_c.Vector_3.Pointer) return box2d_c.Pointers.Joint_Pointer;
function b2d_Joint_user_Data (Self : in box2d_c.Pointers.Joint_Pointer) return swig.void_ptr;
procedure b2d_Joint_user_Data_is (Self : in box2d_c.Pointers.Joint_Pointer;
Now : in swig.void_ptr);
function b2d_Joint_Object_A (Self : in box2d_c.Pointers.Joint_Pointer) return box2d_c.Pointers.Object_Pointer;
function b2d_Joint_Object_B (Self : in box2d_c.Pointers.Joint_Pointer) return box2d_c.Pointers.Object_Pointer;
function b2d_Joint_Frame_A (Self : in box2d_c.Pointers.Joint_Pointer) return c_math_c.Matrix_4x4.Item;
function b2d_Joint_Frame_B (Self : in box2d_c.Pointers.Joint_Pointer) return c_math_c.Matrix_4x4.Item;
procedure b2d_Joint_Frame_A_is (Self : in box2d_c.Pointers.Joint_Pointer;
Now : in c_math_c.Matrix_4x4.Pointer);
procedure b2d_Joint_Frame_B_is (Self : in box2d_c.Pointers.Joint_Pointer;
Now : in c_math_c.Matrix_4x4.Pointer);
procedure b2d_Joint_set_local_Anchor (Self : in box2d_c.Pointers.Joint_Pointer;
is_Anchor_A : in swig.bool;
local_Anchor : in c_math_c.Vector_3.Pointer);
function b2d_Joint_is_Limited (Self : in box2d_c.Pointers.Joint_Pointer;
DoF : in interfaces.c.int) return swig.bool;
function b2d_Joint_Extent (Self : in box2d_c.Pointers.Joint_Pointer;
DoF : in interfaces.c.int) return swig.bool;
procedure b2d_Joint_Velocity_is (Self : in box2d_c.Pointers.Joint_Pointer;
DoF : in interfaces.c.int;
Now : in c_math_c.Real);
function b2d_Joint_reaction_Force (Self : in box2d_c.Pointers.Joint_Pointer) return c_math_c.Vector_3.Item;
function b2d_Joint_reaction_Torque (Self : in box2d_c.Pointers.Joint_Pointer) return c_math_c.Real;
procedure b2d_Joint_hinge_Limits_are (Self : in box2d_c.Pointers.Joint_Pointer;
Low : in c_math_c.Real;
High : in c_math_c.Real);
function b2d_new_Space return box2d_c.Pointers.Space_Pointer;
procedure b2d_free_Space (Self : in box2d_c.Pointers.Space_Pointer);
procedure b2d_Space_add_Object (Self : in box2d_c.Pointers.Space_Pointer;
the_Object : in box2d_c.Pointers.Object_Pointer);
procedure b2d_Space_rid_Object (Self : in box2d_c.Pointers.Space_Pointer;
the_Object : in box2d_c.Pointers.Object_Pointer);
procedure b2d_Space_add_Joint (Self : in box2d_c.Pointers.Space_Pointer;
the_Joint : in box2d_c.Pointers.Joint_Pointer);
procedure b2d_Space_rid_Joint (Self : in box2d_c.Pointers.Space_Pointer;
the_Joint : in box2d_c.Pointers.Joint_Pointer);
function b2d_b2Joint_user_Data (the_Joint : in box2d_c.Pointers.b2Joint_Pointer) return swig.void_ptr;
function b2d_Space_first_Joint (Self : in box2d_c.Pointers.Space_Pointer) return box2d_c.joint_Cursor.Item;
procedure b2d_Space_next_Joint (Cursor : in box2d_c.joint_Cursor.Pointer);
function b2d_Space_joint_Element (Cursor : in box2d_c.joint_Cursor.Pointer) return box2d_c.Pointers.b2Joint_Pointer;
procedure b2d_Space_Gravity_is (Self : in box2d_c.Pointers.Space_Pointer;
Now : in c_math_c.Vector_3.Pointer);
procedure b2d_Space_evolve (Self : in box2d_c.Pointers.Space_Pointer;
By : in interfaces.c.c_float);
function b2d_Space_cast_Ray (Self : in box2d_c.Pointers.Space_Pointer;
From : in c_math_c.Vector_3.Pointer;
To : in c_math_c.Vector_3.Pointer) return box2d_c.b2d_ray_Collision.Item;
function b2d_space_contact_Count (Self : in box2d_c.Pointers.Space_Pointer) return interfaces.c.int;
function b2d_space_Contact (Self : in box2d_c.Pointers.Space_Pointer;
contact_Id : in interfaces.c.int) return box2d_c.b2d_Contact.Item;
private
pragma Import (C, b2d_new_Circle, "Ada_b2d_new_Circle");
pragma Import (C, b2d_new_Polygon, "Ada_b2d_new_Polygon");
pragma Import (C, b2d_new_Box, "Ada_b2d_new_Box");
pragma Import (C, b2d_new_Capsule, "Ada_b2d_new_Capsule");
pragma Import (C, b2d_new_Cone, "Ada_b2d_new_Cone");
pragma Import (C, b2d_new_convex_Hull, "Ada_b2d_new_convex_Hull");
pragma Import (C, b2d_new_Cylinder, "Ada_b2d_new_Cylinder");
pragma Import (C, b2d_new_Heightfield, "Ada_b2d_new_Heightfield");
pragma Import (C, b2d_new_multiSphere, "Ada_b2d_new_multiSphere");
pragma Import (C, b2d_new_Plane, "Ada_b2d_new_Plane");
pragma Import (C, b2d_new_Sphere, "Ada_b2d_new_Sphere");
pragma Import (C, b2d_free_Shape, "Ada_b2d_free_Shape");
pragma Import (C, b2d_Shape_user_Data, "Ada_b2d_Shape_user_Data");
pragma Import (C, b2d_Shape_user_Data_is, "Ada_b2d_Shape_user_Data_is");
pragma Import (C, b2d_shape_Scale_is, "Ada_b2d_shape_Scale_is");
pragma Import (C, b2d_new_Object, "Ada_b2d_new_Object");
pragma Import (C, b2d_free_Object, "Ada_b2d_free_Object");
pragma Import (C, b2d_Object_Scale_is, "Ada_b2d_Object_Scale_is");
pragma Import (C, b2d_Object_Shape, "Ada_b2d_Object_Shape");
pragma Import (C, b2d_Object_user_Data, "Ada_b2d_Object_user_Data");
pragma Import (C, b2d_Object_user_Data_is, "Ada_b2d_Object_user_Data_is");
pragma Import (C, b2d_Object_Mass, "Ada_b2d_Object_Mass");
pragma Import (C, b2d_Object_Friction_is, "Ada_b2d_Object_Friction_is");
pragma Import (C, b2d_Object_Restitution_is, "Ada_b2d_Object_Restitution_is");
pragma Import (C, b2d_Object_Site, "Ada_b2d_Object_Site");
pragma Import (C, b2d_Object_Site_is, "Ada_b2d_Object_Site_is");
pragma Import (C, b2d_Object_Spin, "Ada_b2d_Object_Spin");
pragma Import (C, b2d_Object_Spin_is, "Ada_b2d_Object_Spin_is");
pragma Import (C, b2d_Object_xy_Spin, "Ada_b2d_Object_xy_Spin");
pragma Import (C, b2d_Object_xy_Spin_is, "Ada_b2d_Object_xy_Spin_is");
pragma Import (C, b2d_Object_Transform, "Ada_b2d_Object_Transform");
pragma Import (C, b2d_Object_Transform_is, "Ada_b2d_Object_Transform_is");
pragma Import (C, b2d_Object_Speed, "Ada_b2d_Object_Speed");
pragma Import (C, b2d_Object_Speed_is, "Ada_b2d_Object_Speed_is");
pragma Import (C, b2d_Object_Gyre, "Ada_b2d_Object_Gyre");
pragma Import (C, b2d_Object_Gyre_is, "Ada_b2d_Object_Gyre_is");
pragma Import (C, b2d_Object_apply_Force, "Ada_b2d_Object_apply_Force");
pragma Import (C, b2d_Object_apply_Torque, "Ada_b2d_Object_apply_Torque");
pragma Import (C, b2d_Object_apply_Torque_impulse, "Ada_b2d_Object_apply_Torque_impulse");
pragma Import (C, b2d_dump, "Ada_b2d_dump");
pragma Import (C, b2d_new_hinge_Joint_with_local_anchors, "Ada_b2d_new_hinge_Joint_with_local_anchors");
pragma Import (C, b2d_new_hinge_Joint, "Ada_b2d_new_hinge_Joint");
pragma Import (C, b2d_free_hinge_Joint, "Ada_b2d_free_hinge_Joint");
pragma Import (C, b2d_new_space_hinge_Joint, "Ada_b2d_new_space_hinge_Joint");
pragma Import (C, b2d_new_DoF6_Joint, "Ada_b2d_new_DoF6_Joint");
pragma Import (C, b2d_new_cone_twist_Joint, "Ada_b2d_new_cone_twist_Joint");
pragma Import (C, b2d_new_slider_Joint, "Ada_b2d_new_slider_Joint");
pragma Import (C, b2d_new_ball_Joint, "Ada_b2d_new_ball_Joint");
pragma Import (C, b2d_Joint_user_Data, "Ada_b2d_Joint_user_Data");
pragma Import (C, b2d_Joint_user_Data_is, "Ada_b2d_Joint_user_Data_is");
pragma Import (C, b2d_Joint_Object_A, "Ada_b2d_Joint_Object_A");
pragma Import (C, b2d_Joint_Object_B, "Ada_b2d_Joint_Object_B");
pragma Import (C, b2d_Joint_Frame_A, "Ada_b2d_Joint_Frame_A");
pragma Import (C, b2d_Joint_Frame_B, "Ada_b2d_Joint_Frame_B");
pragma Import (C, b2d_Joint_Frame_A_is, "Ada_b2d_Joint_Frame_A_is");
pragma Import (C, b2d_Joint_Frame_B_is, "Ada_b2d_Joint_Frame_B_is");
pragma Import (C, b2d_Joint_set_local_Anchor, "Ada_b2d_Joint_set_local_Anchor");
pragma Import (C, b2d_Joint_is_Limited, "Ada_b2d_Joint_is_Limited");
pragma Import (C, b2d_Joint_Extent, "Ada_b2d_Joint_Extent");
pragma Import (C, b2d_Joint_Velocity_is, "Ada_b2d_Joint_Velocity_is");
pragma Import (C, b2d_Joint_reaction_Force, "Ada_b2d_Joint_reaction_Force");
pragma Import (C, b2d_Joint_reaction_Torque, "Ada_b2d_Joint_reaction_Torque");
pragma Import (C, b2d_Joint_hinge_Limits_are, "Ada_b2d_Joint_hinge_Limits_are");
pragma Import (C, b2d_new_Space, "Ada_b2d_new_Space");
pragma Import (C, b2d_free_Space, "Ada_b2d_free_Space");
pragma Import (C, b2d_Space_add_Object, "Ada_b2d_Space_add_Object");
pragma Import (C, b2d_Space_rid_Object, "Ada_b2d_Space_rid_Object");
pragma Import (C, b2d_Space_add_Joint, "Ada_b2d_Space_add_Joint");
pragma Import (C, b2d_Space_rid_Joint, "Ada_b2d_Space_rid_Joint");
pragma Import (C, b2d_b2Joint_user_Data, "Ada_b2d_b2Joint_user_Data");
pragma Import (C, b2d_Space_first_Joint, "Ada_b2d_Space_first_Joint");
pragma Import (C, b2d_Space_next_Joint, "Ada_b2d_Space_next_Joint");
pragma Import (C, b2d_Space_joint_Element, "Ada_b2d_Space_joint_Element");
pragma Import (C, b2d_Space_Gravity_is, "Ada_b2d_Space_Gravity_is");
pragma Import (C, b2d_Space_evolve, "Ada_b2d_Space_evolve");
pragma Import (C, b2d_Space_cast_Ray, "Ada_b2d_Space_cast_Ray");
pragma Import (C, b2d_space_contact_Count, "Ada_b2d_space_contact_Count");
pragma Import (C, b2d_space_Contact, "Ada_b2d_space_Contact");
end box2d_c.Binding;
|
micahwelf/FLTK-Ada | Ada | 1,442 | ads |
with
FLTK.Widgets.Groups.Windows;
package FLTK.Devices.Surfaces.Copy is
type Copy_Surface is new Surface_Device with private;
type Copy_Surface_Reference (Data : not null access Copy_Surface'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(W, H : in Natural)
return Copy_Surface;
end Forge;
function Get_W
(This : in Copy_Surface)
return Integer;
function Get_H
(This : in Copy_Surface)
return Integer;
procedure Draw_Widget
(This : in out Copy_Surface;
Item : in FLTK.Widgets.Widget'Class;
Offset_X, Offset_Y : in Integer := 0);
procedure Draw_Decorated_Window
(This : in out Copy_Surface;
Item : in FLTK.Widgets.Groups.Windows.Window'Class;
Offset_X, Offset_Y : in Integer := 0);
procedure Set_Current
(This : in out Copy_Surface);
private
type Copy_Surface is new Surface_Device with null record;
overriding procedure Finalize
(This : in out Copy_Surface);
pragma Inline (Get_W);
pragma Inline (Get_H);
pragma Inline (Draw_Widget);
pragma Inline (Draw_Decorated_Window);
pragma Inline (Set_Current);
end FLTK.Devices.Surfaces.Copy;
|
AdaCore/langkit | Ada | 1,889 | adb | with Ada.Text_IO; use Ada.Text_IO;
with System.Assertions; use System.Assertions;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Libfoolang.Rewriting; use Libfoolang.Rewriting;
with Libfoolang.Unparsing; use Libfoolang.Unparsing;
with Libfoolang.Common;
procedure Main is
Buffer : constant String :=
"def a = 1;"
& ASCII.LF & "b;"
& ASCII.LF & "def c = 2;";
Ctx : constant Analysis_Context := Create_Context;
U : constant Analysis_Unit := Get_From_Buffer
(Ctx, "main.txt", Buffer => Buffer);
begin
Put_Line ("main.adb: starting...");
if Has_Diagnostics (U) then
Put_Line ("Errors:");
for D of Diagnostics (U) loop
Put_Line (Format_GNU_Diagnostic (U, D));
end loop;
end if;
New_Line;
declare
R : constant Foo_Node'Class := Root (U);
begin
Put_Line ("Unparsing: " & Unparse (R));
raise Program_Error;
exception
when Assert_Failure =>
Put_Line ("Assertion failure on unparsing badly parsed unit");
end;
New_Line;
declare
RH : Rewriting_Handle := Start_Rewriting (Ctx);
URH : Unit_Rewriting_Handle with Unreferenced;
NRH : Node_Rewriting_Handle with Unreferenced;
begin
begin
URH := Handle (U);
raise Program_Error;
exception
when Libfoolang.Common.Precondition_Failure =>
Put_Line ("Assertion failure on getting badly parsed unit"
& " rewriting handle");
end;
begin
NRH := Handle (U.Root);
raise Program_Error;
exception
when Libfoolang.Common.Precondition_Failure =>
Put_Line ("Assertion failure on getting rewriting handle for root"
& " of badly parsed unit");
end;
Abort_Rewriting (RH);
end;
New_Line;
Put_Line ("main.adb: done.");
end Main;
|
reznikmm/matreshka | Ada | 4,728 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Visitors;
with ODF.DOM.Meta_Auto_Reload_Elements;
package Matreshka.ODF_Meta.Auto_Reload_Elements is
type Meta_Auto_Reload_Element_Node is
new Matreshka.ODF_Meta.Abstract_Meta_Element_Node
and ODF.DOM.Meta_Auto_Reload_Elements.ODF_Meta_Auto_Reload
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Meta_Auto_Reload_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Meta_Auto_Reload_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Meta_Auto_Reload_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Meta_Auto_Reload_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Meta_Auto_Reload_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Meta.Auto_Reload_Elements;
|
optikos/oasis | Ada | 3,434 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Null_Statements is
function Create
(Null_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Null_Statement is
begin
return Result : Null_Statement :=
(Null_Token => Null_Token, Semicolon_Token => Semicolon_Token,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Null_Statement is
begin
return Result : Implicit_Null_Statement :=
(Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Null_Token
(Self : Null_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Null_Token;
end Null_Token;
overriding function Semicolon_Token
(Self : Null_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Null_Statement)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Null_Statement)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Null_Statement)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize (Self : aliased in out Base_Null_Statement'Class) is
begin
null;
end Initialize;
overriding function Is_Null_Statement_Element
(Self : Base_Null_Statement)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Null_Statement_Element;
overriding function Is_Statement_Element
(Self : Base_Null_Statement)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Statement_Element;
overriding procedure Visit
(Self : not null access Base_Null_Statement;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Null_Statement (Self);
end Visit;
overriding function To_Null_Statement_Text
(Self : aliased in out Null_Statement)
return Program.Elements.Null_Statements.Null_Statement_Text_Access is
begin
return Self'Unchecked_Access;
end To_Null_Statement_Text;
overriding function To_Null_Statement_Text
(Self : aliased in out Implicit_Null_Statement)
return Program.Elements.Null_Statements.Null_Statement_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Null_Statement_Text;
end Program.Nodes.Null_Statements;
|
reznikmm/gela | Ada | 740 | ads | with Gela.Elements.Defining_Names;
package Gela.Int.Defining_Names is
pragma Preelaborate;
type Defining_Name is new Interpretation with private;
function Create
(Down : Gela.Interpretations.Interpretation_Index_Array;
Name : Gela.Elements.Defining_Names.Defining_Name_Access)
return Defining_Name;
function Name
(Self : Defining_Name)
return Gela.Elements.Defining_Names.Defining_Name_Access;
private
type Defining_Name is new Interpretation with record
Name : Gela.Elements.Defining_Names.Defining_Name_Access;
end record;
overriding procedure Visit
(Self : Defining_Name;
Visiter : access Gela.Int.Visiters.Visiter'Class);
end Gela.Int.Defining_Names;
|
LionelDraghi/smk | Ada | 5,789 | adb | -- -----------------------------------------------------------------------------
-- smk, the smart make (http://lionel.draghi.free.fr/smk/)
-- © 2018, 2019 Lionel Draghi <[email protected]>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
-- http://www.apache.org/licenses/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Text_IO;
package body Smk.IO is
Warnings : Natural := 0;
-- --------------------------------------------------------------------------
-- Function: GNU_Prefix
--
-- Purpose:
-- This function return a source/line/column prefix to messages compatible
-- whith GNU Standard
-- (refer to <https://www.gnu.org/prep/standards/html_node/Errors.html>),
-- That is :
-- > program:sourcefile:lineno: message
-- when there is an appropriate source file, or :
-- > program: message
-- otherwise.
--
-- --------------------------------------------------------------------------
function GNU_Prefix (File : in String;
Line : in Integer := 0) return String
is
use Ada.Strings;
use Ada.Strings.Fixed;
Trimed_File : constant String := Trim (File, Side => Both);
Trimed_Line : constant String := Trim (Positive'Image (Line),
Side => Both);
Common_Part : constant String := "smk:" & Trimed_File;
begin
if File = "" then
return "";
elsif Line = 0 then
return Common_Part & " ";
else
return Common_Part & ":" & Trimed_Line & ": ";
end if;
end GNU_Prefix;
-- --------------------------------------------------------------------------
procedure Put_Warning (Msg : in String;
File : in String := "";
Line : in Integer := 0) is
begin
Warnings := Warnings + 1;
Put_Line ("Warning : " & Msg, File, Line);
-- use the local version of Put_Line, and not the Ada.Text_IO one,
-- so that Warning messages are also ignored when --quiet.
end Put_Warning;
Errors : Natural := 0;
-- --------------------------------------------------------------------------
procedure Put_Error (Msg : in String;
File : in String := "";
Line : in Integer := 0) is
begin
Errors := Errors + 1;
Put_Line ("Error : " & Msg, File, Line, Level => Quiet);
-- Quiet because Error Msg should not be ignored
end Put_Error;
-- --------------------------------------------------------------------------
procedure Put_Exception (Msg : in String;
File : in String := "";
Line : in Integer := 0) is
begin
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
GNU_Prefix (File, Line) & "Exception : " & Msg);
end Put_Exception;
-- --------------------------------------------------------------------------
function Error_Count return Natural is (Errors);
function Warning_Count return Natural is (Warnings);
-- --------------------------------------------------------------------------
procedure Put_Debug_Line (Msg : in String;
Debug : in Boolean;
Prefix : in String;
File : in String := "";
Line : in Integer := 0) is
begin
if Debug then
Ada.Text_IO.Put_Line (GNU_Prefix (File, Line) & Prefix & Msg);
end if;
end Put_Debug_Line;
-- --------------------------------------------------------------------------
procedure Put_Line (Item : String;
File : in String := "";
Line : in Integer := 0;
Level : Print_Out_Level := Normal) is
begin
if Level >= Settings.Verbosity then
Ada.Text_IO.Put_Line (GNU_Prefix (File, Line) & Item);
end if;
end Put_Line;
-- --------------------------------------------------------------------------
procedure Put (Item : String;
File : in String := "";
Line : in Integer := 0;
Level : Print_Out_Level := Normal) is
begin
if Level >= Settings.Verbosity then
Ada.Text_IO.Put (GNU_Prefix (File, Line) & Item);
end if;
end Put;
-- --------------------------------------------------------------------------
procedure New_Line (Level : Print_Out_Level := Normal) is
begin
if Level >= Settings.Verbosity then
Ada.Text_IO.New_Line;
end if;
end New_Line;
-- --------------------------------------------------------------------------
function Image (Time : in Ada.Calendar.Time) return String is
begin
return Ada.Calendar.Formatting.Image
(Date => Time,
Include_Time_Fraction => True,
Time_Zone => Ada.Calendar.Time_Zones.UTC_Time_Offset);
end Image;
end Smk.IO;
|
zhmu/ananas | Ada | 275 | ads | package Default_Initial_Condition_Pack is
type T;
type T is private
with Default_Initial_Condition => Is_OK (T);
function Is_OK (Val : T) return Boolean;
DIC_Called : Boolean := False;
private
type T is null record;
end Default_Initial_Condition_Pack;
|
charlie5/cBound | Ada | 1,606 | ads | -- 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_set_font_path_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
font_qty : aliased Interfaces.Unsigned_16;
pad1 : aliased swig.int8_t_Array (0 .. 1);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_set_font_path_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_set_font_path_request_t.Item,
Element_Array => xcb.xcb_set_font_path_request_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_set_font_path_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_set_font_path_request_t.Pointer,
Element_Array => xcb.xcb_set_font_path_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_set_font_path_request_t;
|
charlie5/lace | Ada | 11,407 | adb | with
openGL.Program.lit,
openGL.Palette,
openGL.Shader,
openGL.Buffer.general,
openGL.Attribute,
openGL.Texture,
openGL.Tasks,
openGL.Errors,
GL.Binding,
GL.lean,
GL.Pointers,
Interfaces.C.Strings,
System.storage_Elements;
package body openGL.Geometry.lit_colored_textured
is
use GL.lean,
GL.Pointers,
Interfaces,
System;
------------------
-- Shader Program
--
type program_Id is (rgba_Texture, alpha_Texture);
type Program is
record
vertex_Shader : aliased Shader.item;
fragment_Shader : aliased Shader.item;
Program : openGL.Program.lit.view;
end record;
type Programs is array (program_Id) of aliased Program;
-----------
--- Globals
--
the_Programs : Programs;
Name_1 : constant String := "Site";
Name_2 : constant String := "Normal";
Name_3 : constant String := "Color";
Name_4 : constant String := "Coords";
Name_5 : constant String := "Shine";
Attribute_1_Name : aliased C.char_array := C.to_C (Name_1);
Attribute_2_Name : aliased C.char_array := C.to_C (Name_2);
Attribute_3_Name : aliased C.char_array := C.to_C (Name_3);
Attribute_4_Name : aliased C.char_array := C.to_C (Name_4);
Attribute_5_Name : aliased C.char_array := C.to_C (Name_5);
Attribute_1_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_1_Name'Access);
Attribute_2_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_2_Name'Access);
Attribute_3_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_3_Name'Access);
Attribute_4_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_4_Name'Access);
Attribute_5_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_5_Name'Access);
white_Texture : openGL.Texture.Object;
---------
-- Forge
--
type Geometry_view is access all Geometry.lit_colored_textured.item'Class;
function new_Geometry (texture_is_Alpha : in Boolean) return access Geometry.lit_colored_textured.item'Class
is
use type openGL.Program.lit.view;
procedure define (the_Program : access Program;
use_fragment_Shader : in String)
is
use openGL.Palette,
Attribute.Forge,
system.Storage_Elements;
Sample : Vertex;
Attribute_1 : openGL.Attribute.view;
Attribute_2 : openGL.Attribute.view;
Attribute_3 : openGL.Attribute.view;
Attribute_4 : openGL.Attribute.view;
Attribute_5 : openGL.Attribute.view;
white_Image : constant openGL.Image := [1 .. 2 => [1 .. 2 => +White]];
begin
white_Texture := openGL.Texture.Forge.to_Texture (white_Image);
the_Program.Program := new openGL.Program.lit.item;
the_Program. vertex_Shader.define (Shader.Vertex, "assets/opengl/shader/lit_colored_textured.vert");
the_Program.fragment_Shader.define (Shader.Fragment, use_fragment_Shader);
the_Program.Program.define (the_Program. vertex_Shader'Access,
the_Program.fragment_Shader'Access);
the_Program.Program.enable;
Attribute_1 := new_Attribute (Name => Name_1,
gl_Location => the_Program.Program.attribute_Location (Name_1),
Size => 3,
data_Kind => attribute.GL_FLOAT,
Stride => lit_colored_textured.Vertex'Size / 8,
Offset => 0,
Normalized => False);
Attribute_2 := new_Attribute (Name => Name_2,
gl_Location => the_Program.Program.attribute_Location (Name_2),
Size => 3,
data_Kind => attribute.GL_FLOAT,
Stride => lit_colored_textured.Vertex'Size / 8,
Offset => Sample.Normal (1)'Address
- Sample.Site (1)'Address,
Normalized => False);
Attribute_3 := new_Attribute (Name => Name_3,
gl_Location => the_Program.Program.attribute_Location (Name_3),
Size => 4,
data_Kind => attribute.GL_UNSIGNED_BYTE,
Stride => lit_colored_textured.Vertex'Size / 8,
Offset => Sample.Color.Primary.Red'Address
- Sample.Site (1) 'Address,
Normalized => True);
Attribute_4 := new_Attribute (Name => Name_4,
gl_Location => the_Program.Program.attribute_Location (Name_4),
Size => 2,
data_Kind => attribute.GL_FLOAT,
Stride => lit_colored_textured.Vertex'Size / 8,
Offset => Sample.Coords.S'Address
- Sample.Site (1)'Address,
Normalized => False);
Attribute_5 := new_Attribute (Name => Name_5,
gl_Location => the_Program.Program.attribute_Location (Name_5),
Size => 1,
data_Kind => attribute.GL_FLOAT,
Stride => lit_colored_textured.Vertex'Size / 8,
Offset => Sample.Shine 'Address
- Sample.Site (1)'Address,
Normalized => False);
the_Program.Program.add (Attribute_1);
the_Program.Program.add (Attribute_2);
the_Program.Program.add (Attribute_3);
the_Program.Program.add (Attribute_4);
the_Program.Program.add (Attribute_5);
glBindAttribLocation (Program => the_Program.Program.gl_Program,
Index => the_Program.Program.Attribute (named => Name_1).gl_Location,
Name => +Attribute_1_Name_ptr);
Errors.log;
glBindAttribLocation (Program => the_Program.Program.gl_Program,
Index => the_Program.Program.Attribute (named => Name_2).gl_Location,
Name => +Attribute_2_Name_ptr);
Errors.log;
glBindAttribLocation (Program => the_Program.Program.gl_Program,
Index => the_Program.Program.Attribute (named => Name_3).gl_Location,
Name => +Attribute_3_Name_ptr);
Errors.log;
glBindAttribLocation (Program => the_Program.Program.gl_Program,
Index => the_Program.Program.Attribute (named => Name_4).gl_Location,
Name => +Attribute_4_Name_ptr);
Errors.log;
glBindAttribLocation (Program => the_Program.Program.gl_Program,
Index => the_Program.Program.Attribute (named => Name_5).gl_Location,
Name => +Attribute_5_Name_ptr);
Errors.log;
end define;
Self : constant Geometry_view := new Geometry.lit_colored_textured.item;
begin
Tasks.check;
if texture_is_Alpha -- Define the shaders and program, if required.
then
if the_Programs (alpha_Texture).Program = null
then
define (the_Programs (alpha_Texture)'Access,
use_fragment_Shader => "assets/opengl/shader/lit_colored_text.frag");
end if;
else
if the_Programs (rgba_Texture).Program = null
then
define (the_Programs (rgba_Texture)'Access,
use_fragment_Shader => "assets/opengl/shader/lit_colored_textured.frag");
end if;
end if;
if texture_is_Alpha
then Self.is_Transparent := True;
Self.Program_is (the_Programs (alpha_Texture).Program.all'Access);
else Self.Program_is (the_Programs ( rgba_Texture).Program.all'Access);
end if;
return Self;
end new_Geometry;
----------
-- Vertex
--
function is_Transparent (Self : in Vertex_array) return Boolean
is
function get_Color (Index : in Index_t) return rgba_Color
is (Self (Index).Color);
function my_Transparency is new get_Transparency (any_Index_t => Index_t,
get_Color => get_Color);
begin
return my_Transparency (Count => Self'Length);
end is_Transparent;
--------------
-- Attributes
--
package openGL_Buffer_of_geometry_Vertices is new Buffer.general (base_Object => Buffer.array_Object,
Index => Index_t,
Element => Vertex,
Element_Array => Vertex_array);
procedure Vertices_are (Self : in out Item; Now : in Vertex_array)
is
use openGL_Buffer_of_geometry_Vertices;
use type Buffer.view;
begin
if Self.Vertices = null
then
self.Vertices := new openGL_Buffer_of_geometry_Vertices.Object' (Forge.to_Buffer (Now,
usage => Buffer.static_Draw));
else
set (openGL_Buffer_of_geometry_Vertices.Object (Self.Vertices.all),
to => Now);
end if;
Self.is_Transparent := is_Transparent (Now);
-- Set the bounds.
--
declare
function get_Site (Index : in Index_t) return Vector_3
is (Now (Index).Site);
function bounding_Box is new get_Bounds (Index_t, get_Site);
begin
Self.Bounds_are (bounding_Box (Count => Now'Length));
end;
end Vertices_are;
overriding
procedure Indices_are (Self : in out Item; Now : in Indices;
for_Facia : in Positive)
is
begin
raise Error with "TODO";
end Indices_are;
overriding
procedure enable_Texture (Self : in Item)
is
use GL,
GL.Binding,
openGL.Texture;
begin
Tasks.check;
glActiveTexture (gl.GL_TEXTURE0);
Errors.log;
if Self.Texture = openGL.Texture.null_Object
then enable (white_Texture);
else enable (Self.Texture);
end if;
end enable_Texture;
end openGL.Geometry.lit_colored_textured;
|
reznikmm/matreshka | Ada | 3,659 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Elements;
package ODF.DOM.Dr3d_Extrude_Elements is
pragma Preelaborate;
type ODF_Dr3d_Extrude is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Dr3d_Extrude_Access is
access all ODF_Dr3d_Extrude'Class
with Storage_Size => 0;
end ODF.DOM.Dr3d_Extrude_Elements;
|
AdaCore/ada-traits-containers | Ada | 597 | adb | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Ada.Unchecked_Deallocation;
package body Conts.Elements.Indefinite_SPARK with SPARK_Mode => Off is
package body Impl with SPARK_Mode => Off is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Element_Type, Element_Access);
----------
-- Free --
----------
procedure Free (X : in out Element_Access) is
begin
Unchecked_Free (X);
end Free;
end Impl;
end Conts.Elements.Indefinite_SPARK;
|
charlie5/lace | Ada | 8,081 | adb | with
openGL.Palette,
openGL.Geometry.lit_colored_textured,
openGL.Texture,
openGL.IO,
openGL.Primitive.indexed;
package body openGL.Model.sphere.lit_colored_textured
is
---------
--- Forge
--
function new_Sphere (Radius : in Real;
lat_Count : in Positive := default_latitude_Count;
long_Count : in Positive := default_longitude_Count;
Image : in asset_Name := null_Asset) return View
is
Self : constant View := new Item;
begin
Self.define (Radius);
Self.lat_Count := lat_Count;
Self.long_Count := long_Count;
Self.Image := Image;
return Self;
end new_Sphere;
--------------
--- Attributes
--
type Geometry_view is access all Geometry.lit_colored_textured.item'Class;
-- NB: - An extra vertex is required at the end of each latitude ring.
-- - This last vertex has the same site as the rings initial vertex.
-- - The last vertex has 's' texture coord of 1.0, whereas
-- the initial vertex has 's' texture coord of 0.0.
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views
is
pragma unreferenced (Textures, Fonts);
use openGL.Geometry,
openGL.Palette,
openGL.Geometry.lit_colored_textured;
lat_Count : Positive renames Self.lat_Count;
long_Count : Positive renames Self.long_Count;
Num_lat_strips : constant Positive := lat_Count - 1;
lat_Spacing : constant Real := Degrees_180 / Real (lat_Count - 1);
long_Spacing : constant Real := Degrees_360 / Real (long_Count);
vertex_Count : constant Index_t := 1 + 1 -- North and south pole.
+ Index_t ((long_Count + 1) * (lat_Count - 2)); -- Each latitude ring.
indices_Count : constant long_Index_t := long_Index_t (Num_lat_strips * (long_Count + 1) * 2);
the_Vertices : aliased Geometry.lit_colored_textured.Vertex_array := [1 .. vertex_Count => <>];
the_Indices : aliased Indices := [1 .. indices_Count => <>];
the_Sites : aliased Sites := [1 .. vertex_Count => <>];
the_Geometry : constant Geometry_view := Geometry.lit_colored_textured.new_Geometry (texture_is_Alpha => False);
begin
set_Sites:
declare
use linear_Algebra,
linear_Algebra_3d;
north_Pole : constant Site := [0.0, 0.5, 0.0];
south_Pole : constant Site := [0.0, -0.5, 0.0];
the_Site : Site := north_Pole;
vert_Id : Index_t := 1; -- Start at '1' (not '0')to account for north pole.
a, b : Real := 0.0; -- Angular 'cursors' used to track lat/long for texture coords.
latitude_line_First : Site;
begin
the_Sites (the_Vertices'First) := north_Pole;
the_Vertices (the_Vertices'First).Site := north_Pole;
the_Vertices (the_Vertices'First).Normal := Normalised (north_Pole);
the_Vertices (the_Vertices'First).Shine := 0.5;
the_Vertices (the_Vertices'First).Coords := (S => 0.5, T => 1.0);
the_Vertices (the_Vertices'First).Color := (Primary => +White,
Alpha => opaque_Value);
the_Sites (the_Vertices'Last) := south_Pole;
the_Vertices (the_Vertices'Last).Site := south_Pole;
the_Vertices (the_Vertices'Last).Normal := Normalised (south_Pole);
the_Vertices (the_Vertices'Last).Shine := 0.5;
the_Vertices (the_Vertices'Last).Coords := (S => 0.5, T => 0.0);
the_Vertices (the_Vertices'Last).Color := (Primary => +White,
Alpha => opaque_Value);
for lat_Id in 2 .. lat_Count - 1
loop
a := 0.0;
b := b + lat_Spacing;
the_Site := the_Site * z_Rotation_from (lat_Spacing);
latitude_line_First := the_Site; -- Store initial latitude lines 1st point.
vert_Id := vert_Id + 1;
the_Sites (vert_Id) := the_Site; -- Add 1st point on a line of latitude.
the_Vertices (vert_Id).Site := the_Site;
the_Vertices (vert_Id).Normal := Normalised (the_Site);
the_Vertices (vert_Id).Shine := 0.5;
the_Vertices (vert_Id).Color := (Primary => +White,
Alpha => opaque_Value);
the_Vertices (vert_Id).Coords := (S => a / Degrees_360,
T => 1.0 - b / Degrees_180);
for long_Id in 1 .. long_Count
loop
a := a + long_Spacing;
if long_Id /= long_Count
then the_Site := the_Site * y_Rotation_from (-long_Spacing);
else the_Site := latitude_line_First; -- Restore the_Vertex back to initial latitude lines 1st point.
end if;
vert_Id := vert_Id + 1;
the_Sites (vert_Id) := the_Site; -- Add each succesive point on a line of latitude.
the_Vertices (vert_Id).Site := the_Site;
the_Vertices (vert_Id).Normal := Normalised (the_Site);
the_Vertices (vert_Id).Shine := 0.5;
the_Vertices (vert_Id).Color := (Primary => +White,
Alpha => opaque_Value);
the_Vertices (vert_Id).Coords := (S => a / Degrees_360,
T => 1.0 - b / Degrees_180);
end loop;
end loop;
end set_Sites;
for i in the_Vertices'Range
loop
the_Vertices (i).Site := the_Vertices (i).Site * Self.Radius * 2.0;
end loop;
set_Indices:
declare
strip_Id : long_Index_t := 0;
Upper : Index_t;
Lower : Index_t;
begin
Upper := 1;
Lower := 2;
for lat_Strip in 1 .. num_lat_Strips
loop
for Each in 1 .. long_Count + 1
loop
strip_Id := strip_Id + 1; the_Indices (strip_Id) := Upper;
strip_Id := strip_Id + 1; the_Indices (strip_Id) := Lower;
if lat_Strip /= 1 then Upper := Upper + 1; end if;
if lat_Strip /= num_lat_Strips then Lower := Lower + 1; end if;
end loop;
if lat_Strip = 1
then
Upper := 2;
end if;
Lower := Upper + Index_t (long_Count) + 1;
end loop;
end set_Indices;
if Self.Image /= null_Asset -- TODO: Use 'Textures' (ie name_Map_of_texture) here and in other models.
then
set_Texture:
declare
use Texture;
the_Image : constant Image := IO.to_Image (Self.Image);
the_Texture : constant Texture.object := Forge.to_Texture ( the_Image);
begin
the_Geometry.Texture_is (the_Texture);
end set_Texture;
end if;
the_Geometry.is_Transparent (False);
the_Geometry.Vertices_are (the_Vertices);
declare
the_Primitive : constant Primitive.indexed.view
:= Primitive.indexed.new_Primitive (Primitive.triangle_Strip,
the_Indices);
begin
the_Geometry.add (Primitive.view (the_Primitive));
end;
return [1 => Geometry.view (the_Geometry)];
end to_GL_Geometries;
end openGL.Model.sphere.lit_colored_textured;
|
Letractively/ada-ado | Ada | 4,253 | adb | -----------------------------------------------------------------------
-- schemas Tests -- Test loading of database schema
-- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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 ADO.Sessions;
with ADO.Schemas.Entities;
with Regtests;
with Regtests.Simple.Model;
package body ADO.Schemas.Tests is
use Util.Tests;
package Caller is new Util.Test_Caller (Test, "ADO.Schemas");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.Schemas.Entities.Find_Entity_Type",
Test_Find_Entity_Type'Access);
Caller.Add_Test (Suite, "Test ADO.Schemas.Entities.Find_Entity_Type (error)",
Test_Find_Entity_Type_Error'Access);
end Add_Tests;
-- ------------------------------
-- Test reading the entity cache and the Find_Entity_Type operation
-- ------------------------------
procedure Test_Find_Entity_Type (T : in out Test) is
S : ADO.Sessions.Session := Regtests.Get_Database;
C : ADO.Schemas.Entities.Entity_Cache;
begin
ADO.Schemas.Entities.Initialize (Cache => C,
Session => S);
declare
-- T1 : constant ADO.Model.Entity_Type_Ref
-- := Entities.Find_Entity_Type (Cache => C,
-- Table => Regtests.Simple.Model.USER_TABLE'Access);
-- T2 : constant ADO.Model.Entity_Type_Ref
-- := Entities.Find_Entity_Type (Cache => C,
-- Table => Regtests.Simple.Model.ALLOCATE_TABLE'Access);
T4 : constant ADO.Entity_Type
:= Entities.Find_Entity_Type (Cache => C,
Table => Regtests.Simple.Model.ALLOCATE_TABLE'Access);
T5 : constant ADO.Entity_Type
:= Entities.Find_Entity_Type (Cache => C,
Table => Regtests.Simple.Model.USER_TABLE'Access);
begin
-- T.Assert (not ADO.Objects.Is_Null (T1), "Find_Entity_Type returned a null value");
-- T.Assert (not ADO.Objects.Is_Null (T2), "Find_Entity_Type returned a null value");
T.Assert (T4 /= T5, "Two distinct tables have different entity types");
T.Assert (T4 > 0, "T1.Id must be positive");
T.Assert (T5 > 0, "T2.Id must be positive");
-- T.Assert (T1.Get_Id /= T2.Get_Id, "Two distinct tables have different ids");
--
-- Assert_Equals (T, Integer (T2.Get_Id), Integer (T4),
-- "Invalid entity type for allocate_table");
-- Assert_Equals (T, Integer (T1.Get_Id), Integer (T5),
-- "Invalid entity type for user_table");
end;
end Test_Find_Entity_Type;
-- ------------------------------
-- Test calling Find_Entity_Type with an invalid table.
-- ------------------------------
procedure Test_Find_Entity_Type_Error (T : in out Test) is
C : ADO.Schemas.Entities.Entity_Cache;
begin
declare
R : ADO.Entity_Type;
pragma Unreferenced (R);
begin
R := Entities.Find_Entity_Type (Cache => C,
Table => Regtests.Simple.Model.USER_TABLE'Access);
T.Assert (False, "Find_Entity_Type did not raise the No_Entity_Type exception");
exception
when ADO.Schemas.Entities.No_Entity_Type =>
null;
end;
end Test_Find_Entity_Type_Error;
end ADO.Schemas.Tests;
|
AdaCore/training_material | Ada | 44,844 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package avx512vlintrin_h is
-- Copyright (C) 2014-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3, or (at your option)
-- any later version.
-- GCC is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- Under Section 7 of GPL version 3, you are granted additional
-- permissions described in the GCC Runtime Library Exception, version
-- 3.1, as published by the Free Software Foundation.
-- You should have received a copy of the GNU General Public License and
-- a copy of the GCC Runtime Library Exception along with this program;
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-- <http://www.gnu.org/licenses/>.
-- Internal data types for implementing the intrinsics.
subtype uu_mmask32 is unsigned; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avx512vlintrin.h:38
-- skipped func _mm256_mask_mov_pd
-- skipped func _mm256_maskz_mov_pd
-- skipped func _mm_mask_mov_pd
-- skipped func _mm_maskz_mov_pd
-- skipped func _mm256_mask_load_pd
-- skipped func _mm256_maskz_load_pd
-- skipped func _mm_mask_load_pd
-- skipped func _mm_maskz_load_pd
-- skipped func _mm256_mask_store_pd
-- skipped func _mm_mask_store_pd
-- skipped func _mm256_mask_mov_ps
-- skipped func _mm256_maskz_mov_ps
-- skipped func _mm_mask_mov_ps
-- skipped func _mm_maskz_mov_ps
-- skipped func _mm256_mask_load_ps
-- skipped func _mm256_maskz_load_ps
-- skipped func _mm_mask_load_ps
-- skipped func _mm_maskz_load_ps
-- skipped func _mm256_mask_store_ps
-- skipped func _mm_mask_store_ps
-- skipped func _mm256_mask_mov_epi64
-- skipped func _mm256_maskz_mov_epi64
-- skipped func _mm_mask_mov_epi64
-- skipped func _mm_maskz_mov_epi64
-- skipped func _mm256_mask_load_epi64
-- skipped func _mm256_maskz_load_epi64
-- skipped func _mm_mask_load_epi64
-- skipped func _mm_maskz_load_epi64
-- skipped func _mm256_mask_store_epi64
-- skipped func _mm_mask_store_epi64
-- skipped func _mm256_mask_mov_epi32
-- skipped func _mm256_maskz_mov_epi32
-- skipped func _mm_mask_mov_epi32
-- skipped func _mm_maskz_mov_epi32
-- skipped func _mm256_mask_load_epi32
-- skipped func _mm256_maskz_load_epi32
-- skipped func _mm_mask_load_epi32
-- skipped func _mm_maskz_load_epi32
-- skipped func _mm256_mask_store_epi32
-- skipped func _mm_mask_store_epi32
-- skipped func _mm_mask_add_pd
-- skipped func _mm_maskz_add_pd
-- skipped func _mm256_mask_add_pd
-- skipped func _mm256_maskz_add_pd
-- skipped func _mm_mask_add_ps
-- skipped func _mm_maskz_add_ps
-- skipped func _mm256_mask_add_ps
-- skipped func _mm256_maskz_add_ps
-- skipped func _mm_mask_sub_pd
-- skipped func _mm_maskz_sub_pd
-- skipped func _mm256_mask_sub_pd
-- skipped func _mm256_maskz_sub_pd
-- skipped func _mm_mask_sub_ps
-- skipped func _mm_maskz_sub_ps
-- skipped func _mm256_mask_sub_ps
-- skipped func _mm256_maskz_sub_ps
-- skipped func _mm256_store_epi64
-- skipped func _mm_store_epi64
-- skipped func _mm256_mask_loadu_pd
-- skipped func _mm256_maskz_loadu_pd
-- skipped func _mm_mask_loadu_pd
-- skipped func _mm_maskz_loadu_pd
-- skipped func _mm256_mask_storeu_pd
-- skipped func _mm_mask_storeu_pd
-- skipped func _mm256_mask_loadu_ps
-- skipped func _mm256_maskz_loadu_ps
-- skipped func _mm_mask_loadu_ps
-- skipped func _mm_maskz_loadu_ps
-- skipped func _mm256_mask_storeu_ps
-- skipped func _mm_mask_storeu_ps
-- skipped func _mm256_mask_loadu_epi64
-- skipped func _mm256_maskz_loadu_epi64
-- skipped func _mm_mask_loadu_epi64
-- skipped func _mm_maskz_loadu_epi64
-- skipped func _mm256_mask_storeu_epi64
-- skipped func _mm_mask_storeu_epi64
-- skipped func _mm256_mask_loadu_epi32
-- skipped func _mm256_maskz_loadu_epi32
-- skipped func _mm_mask_loadu_epi32
-- skipped func _mm_maskz_loadu_epi32
-- skipped func _mm256_mask_storeu_epi32
-- skipped func _mm_mask_storeu_epi32
-- skipped func _mm256_mask_abs_epi32
-- skipped func _mm256_maskz_abs_epi32
-- skipped func _mm_mask_abs_epi32
-- skipped func _mm_maskz_abs_epi32
-- skipped func _mm256_abs_epi64
-- skipped func _mm256_mask_abs_epi64
-- skipped func _mm256_maskz_abs_epi64
-- skipped func _mm_abs_epi64
-- skipped func _mm_mask_abs_epi64
-- skipped func _mm_maskz_abs_epi64
-- skipped func _mm256_cvtpd_epu32
-- skipped func _mm256_mask_cvtpd_epu32
-- skipped func _mm256_maskz_cvtpd_epu32
-- skipped func _mm_cvtpd_epu32
-- skipped func _mm_mask_cvtpd_epu32
-- skipped func _mm_maskz_cvtpd_epu32
-- skipped func _mm256_mask_cvttps_epi32
-- skipped func _mm256_maskz_cvttps_epi32
-- skipped func _mm_mask_cvttps_epi32
-- skipped func _mm_maskz_cvttps_epi32
-- skipped func _mm256_cvttps_epu32
-- skipped func _mm256_mask_cvttps_epu32
-- skipped func _mm256_maskz_cvttps_epu32
-- skipped func _mm_cvttps_epu32
-- skipped func _mm_mask_cvttps_epu32
-- skipped func _mm_maskz_cvttps_epu32
-- skipped func _mm256_mask_cvttpd_epi32
-- skipped func _mm256_maskz_cvttpd_epi32
-- skipped func _mm_mask_cvttpd_epi32
-- skipped func _mm_maskz_cvttpd_epi32
-- skipped func _mm256_cvttpd_epu32
-- skipped func _mm256_mask_cvttpd_epu32
-- skipped func _mm256_maskz_cvttpd_epu32
-- skipped func _mm_cvttpd_epu32
-- skipped func _mm_mask_cvttpd_epu32
-- skipped func _mm_maskz_cvttpd_epu32
-- skipped func _mm256_mask_cvtpd_epi32
-- skipped func _mm256_maskz_cvtpd_epi32
-- skipped func _mm_mask_cvtpd_epi32
-- skipped func _mm_maskz_cvtpd_epi32
-- skipped func _mm256_mask_cvtepi32_pd
-- skipped func _mm256_maskz_cvtepi32_pd
-- skipped func _mm_mask_cvtepi32_pd
-- skipped func _mm_maskz_cvtepi32_pd
-- skipped func _mm256_cvtepu32_pd
-- skipped func _mm256_mask_cvtepu32_pd
-- skipped func _mm256_maskz_cvtepu32_pd
-- skipped func _mm_cvtepu32_pd
-- skipped func _mm_mask_cvtepu32_pd
-- skipped func _mm_maskz_cvtepu32_pd
-- skipped func _mm256_mask_cvtepi32_ps
-- skipped func _mm256_maskz_cvtepi32_ps
-- skipped func _mm_mask_cvtepi32_ps
-- skipped func _mm_maskz_cvtepi32_ps
-- skipped func _mm256_cvtepu32_ps
-- skipped func _mm256_mask_cvtepu32_ps
-- skipped func _mm256_maskz_cvtepu32_ps
-- skipped func _mm_cvtepu32_ps
-- skipped func _mm_mask_cvtepu32_ps
-- skipped func _mm_maskz_cvtepu32_ps
-- skipped func _mm256_mask_cvtps_pd
-- skipped func _mm256_maskz_cvtps_pd
-- skipped func _mm_mask_cvtps_pd
-- skipped func _mm_maskz_cvtps_pd
-- skipped func _mm_cvtepi32_epi8
-- skipped func _mm_mask_cvtepi32_storeu_epi8
-- skipped func _mm_mask_cvtepi32_epi8
-- skipped func _mm_maskz_cvtepi32_epi8
-- skipped func _mm256_cvtepi32_epi8
-- skipped func _mm256_mask_cvtepi32_epi8
-- skipped func _mm256_mask_cvtepi32_storeu_epi8
-- skipped func _mm256_maskz_cvtepi32_epi8
-- skipped func _mm_cvtsepi32_epi8
-- skipped func _mm_mask_cvtsepi32_storeu_epi8
-- skipped func _mm_mask_cvtsepi32_epi8
-- skipped func _mm_maskz_cvtsepi32_epi8
-- skipped func _mm256_cvtsepi32_epi8
-- skipped func _mm256_mask_cvtsepi32_storeu_epi8
-- skipped func _mm256_mask_cvtsepi32_epi8
-- skipped func _mm256_maskz_cvtsepi32_epi8
-- skipped func _mm_cvtusepi32_epi8
-- skipped func _mm_mask_cvtusepi32_storeu_epi8
-- skipped func _mm_mask_cvtusepi32_epi8
-- skipped func _mm_maskz_cvtusepi32_epi8
-- skipped func _mm256_cvtusepi32_epi8
-- skipped func _mm256_mask_cvtusepi32_storeu_epi8
-- skipped func _mm256_mask_cvtusepi32_epi8
-- skipped func _mm256_maskz_cvtusepi32_epi8
-- skipped func _mm_cvtepi32_epi16
-- skipped func _mm_mask_cvtepi32_storeu_epi16
-- skipped func _mm_mask_cvtepi32_epi16
-- skipped func _mm_maskz_cvtepi32_epi16
-- skipped func _mm256_cvtepi32_epi16
-- skipped func _mm256_mask_cvtepi32_storeu_epi16
-- skipped func _mm256_mask_cvtepi32_epi16
-- skipped func _mm256_maskz_cvtepi32_epi16
-- skipped func _mm_cvtsepi32_epi16
-- skipped func _mm_mask_cvtsepi32_storeu_epi16
-- skipped func _mm_mask_cvtsepi32_epi16
-- skipped func _mm_maskz_cvtsepi32_epi16
-- skipped func _mm256_cvtsepi32_epi16
-- skipped func _mm256_mask_cvtsepi32_storeu_epi16
-- skipped func _mm256_mask_cvtsepi32_epi16
-- skipped func _mm256_maskz_cvtsepi32_epi16
-- skipped func _mm_cvtusepi32_epi16
-- skipped func _mm_mask_cvtusepi32_storeu_epi16
-- skipped func _mm_mask_cvtusepi32_epi16
-- skipped func _mm_maskz_cvtusepi32_epi16
-- skipped func _mm256_cvtusepi32_epi16
-- skipped func _mm256_mask_cvtusepi32_storeu_epi16
-- skipped func _mm256_mask_cvtusepi32_epi16
-- skipped func _mm256_maskz_cvtusepi32_epi16
-- skipped func _mm_cvtepi64_epi8
-- skipped func _mm_mask_cvtepi64_storeu_epi8
-- skipped func _mm_mask_cvtepi64_epi8
-- skipped func _mm_maskz_cvtepi64_epi8
-- skipped func _mm256_cvtepi64_epi8
-- skipped func _mm256_mask_cvtepi64_storeu_epi8
-- skipped func _mm256_mask_cvtepi64_epi8
-- skipped func _mm256_maskz_cvtepi64_epi8
-- skipped func _mm_cvtsepi64_epi8
-- skipped func _mm_mask_cvtsepi64_storeu_epi8
-- skipped func _mm_mask_cvtsepi64_epi8
-- skipped func _mm_maskz_cvtsepi64_epi8
-- skipped func _mm256_cvtsepi64_epi8
-- skipped func _mm256_mask_cvtsepi64_storeu_epi8
-- skipped func _mm256_mask_cvtsepi64_epi8
-- skipped func _mm256_maskz_cvtsepi64_epi8
-- skipped func _mm_cvtusepi64_epi8
-- skipped func _mm_mask_cvtusepi64_storeu_epi8
-- skipped func _mm_mask_cvtusepi64_epi8
-- skipped func _mm_maskz_cvtusepi64_epi8
-- skipped func _mm256_cvtusepi64_epi8
-- skipped func _mm256_mask_cvtusepi64_storeu_epi8
-- skipped func _mm256_mask_cvtusepi64_epi8
-- skipped func _mm256_maskz_cvtusepi64_epi8
-- skipped func _mm_cvtepi64_epi16
-- skipped func _mm_mask_cvtepi64_storeu_epi16
-- skipped func _mm_mask_cvtepi64_epi16
-- skipped func _mm_maskz_cvtepi64_epi16
-- skipped func _mm256_cvtepi64_epi16
-- skipped func _mm256_mask_cvtepi64_storeu_epi16
-- skipped func _mm256_mask_cvtepi64_epi16
-- skipped func _mm256_maskz_cvtepi64_epi16
-- skipped func _mm_cvtsepi64_epi16
-- skipped func _mm_mask_cvtsepi64_storeu_epi16
-- skipped func _mm_mask_cvtsepi64_epi16
-- skipped func _mm_maskz_cvtsepi64_epi16
-- skipped func _mm256_cvtsepi64_epi16
-- skipped func _mm256_mask_cvtsepi64_storeu_epi16
-- skipped func _mm256_mask_cvtsepi64_epi16
-- skipped func _mm256_maskz_cvtsepi64_epi16
-- skipped func _mm_cvtusepi64_epi16
-- skipped func _mm_mask_cvtusepi64_storeu_epi16
-- skipped func _mm_mask_cvtusepi64_epi16
-- skipped func _mm_maskz_cvtusepi64_epi16
-- skipped func _mm256_cvtusepi64_epi16
-- skipped func _mm256_mask_cvtusepi64_storeu_epi16
-- skipped func _mm256_mask_cvtusepi64_epi16
-- skipped func _mm256_maskz_cvtusepi64_epi16
-- skipped func _mm_cvtepi64_epi32
-- skipped func _mm_mask_cvtepi64_storeu_epi32
-- skipped func _mm_mask_cvtepi64_epi32
-- skipped func _mm_maskz_cvtepi64_epi32
-- skipped func _mm256_cvtepi64_epi32
-- skipped func _mm256_mask_cvtepi64_storeu_epi32
-- skipped func _mm256_mask_cvtepi64_epi32
-- skipped func _mm256_maskz_cvtepi64_epi32
-- skipped func _mm_cvtsepi64_epi32
-- skipped func _mm_mask_cvtsepi64_storeu_epi32
-- skipped func _mm_mask_cvtsepi64_epi32
-- skipped func _mm_maskz_cvtsepi64_epi32
-- skipped func _mm256_cvtsepi64_epi32
-- skipped func _mm256_mask_cvtsepi64_storeu_epi32
-- skipped func _mm256_mask_cvtsepi64_epi32
-- skipped func _mm256_maskz_cvtsepi64_epi32
-- skipped func _mm_cvtusepi64_epi32
-- skipped func _mm_mask_cvtusepi64_storeu_epi32
-- skipped func _mm_mask_cvtusepi64_epi32
-- skipped func _mm_maskz_cvtusepi64_epi32
-- skipped func _mm256_cvtusepi64_epi32
-- skipped func _mm256_mask_cvtusepi64_storeu_epi32
-- skipped func _mm256_mask_cvtusepi64_epi32
-- skipped func _mm256_maskz_cvtusepi64_epi32
-- skipped func _mm256_mask_broadcastss_ps
-- skipped func _mm256_maskz_broadcastss_ps
-- skipped func _mm_mask_broadcastss_ps
-- skipped func _mm_maskz_broadcastss_ps
-- skipped func _mm256_mask_broadcastsd_pd
-- skipped func _mm256_maskz_broadcastsd_pd
-- skipped func _mm256_mask_broadcastd_epi32
-- skipped func _mm256_maskz_broadcastd_epi32
-- skipped func _mm256_mask_set1_epi32
-- skipped func _mm256_maskz_set1_epi32
-- skipped func _mm_mask_broadcastd_epi32
-- skipped func _mm_maskz_broadcastd_epi32
-- skipped func _mm_mask_set1_epi32
-- skipped func _mm_maskz_set1_epi32
-- skipped func _mm256_mask_broadcastq_epi64
-- skipped func _mm256_maskz_broadcastq_epi64
-- skipped func _mm256_mask_set1_epi64
-- skipped func _mm256_maskz_set1_epi64
-- skipped func _mm_mask_broadcastq_epi64
-- skipped func _mm_maskz_broadcastq_epi64
-- skipped func _mm_mask_set1_epi64
-- skipped func _mm_maskz_set1_epi64
-- skipped func _mm256_broadcast_f32x4
-- skipped func _mm256_mask_broadcast_f32x4
-- skipped func _mm256_maskz_broadcast_f32x4
-- skipped func _mm256_broadcast_i32x4
-- skipped func _mm256_mask_broadcast_i32x4
-- skipped func _mm256_maskz_broadcast_i32x4
-- skipped func _mm256_mask_cvtepi8_epi32
-- skipped func _mm256_maskz_cvtepi8_epi32
-- skipped func _mm_mask_cvtepi8_epi32
-- skipped func _mm_maskz_cvtepi8_epi32
-- skipped func _mm256_mask_cvtepi8_epi64
-- skipped func _mm256_maskz_cvtepi8_epi64
-- skipped func _mm_mask_cvtepi8_epi64
-- skipped func _mm_maskz_cvtepi8_epi64
-- skipped func _mm256_mask_cvtepi16_epi32
-- skipped func _mm256_maskz_cvtepi16_epi32
-- skipped func _mm_mask_cvtepi16_epi32
-- skipped func _mm_maskz_cvtepi16_epi32
-- skipped func _mm256_mask_cvtepi16_epi64
-- skipped func _mm256_maskz_cvtepi16_epi64
-- skipped func _mm_mask_cvtepi16_epi64
-- skipped func _mm_maskz_cvtepi16_epi64
-- skipped func _mm256_mask_cvtepi32_epi64
-- skipped func _mm256_maskz_cvtepi32_epi64
-- skipped func _mm_mask_cvtepi32_epi64
-- skipped func _mm_maskz_cvtepi32_epi64
-- skipped func _mm256_mask_cvtepu8_epi32
-- skipped func _mm256_maskz_cvtepu8_epi32
-- skipped func _mm_mask_cvtepu8_epi32
-- skipped func _mm_maskz_cvtepu8_epi32
-- skipped func _mm256_mask_cvtepu8_epi64
-- skipped func _mm256_maskz_cvtepu8_epi64
-- skipped func _mm_mask_cvtepu8_epi64
-- skipped func _mm_maskz_cvtepu8_epi64
-- skipped func _mm256_mask_cvtepu16_epi32
-- skipped func _mm256_maskz_cvtepu16_epi32
-- skipped func _mm_mask_cvtepu16_epi32
-- skipped func _mm_maskz_cvtepu16_epi32
-- skipped func _mm256_mask_cvtepu16_epi64
-- skipped func _mm256_maskz_cvtepu16_epi64
-- skipped func _mm_mask_cvtepu16_epi64
-- skipped func _mm_maskz_cvtepu16_epi64
-- skipped func _mm256_mask_cvtepu32_epi64
-- skipped func _mm256_maskz_cvtepu32_epi64
-- skipped func _mm_mask_cvtepu32_epi64
-- skipped func _mm_maskz_cvtepu32_epi64
-- skipped func _mm256_rcp14_pd
-- skipped func _mm256_mask_rcp14_pd
-- skipped func _mm256_maskz_rcp14_pd
-- skipped func _mm_rcp14_pd
-- skipped func _mm_mask_rcp14_pd
-- skipped func _mm_maskz_rcp14_pd
-- skipped func _mm256_rcp14_ps
-- skipped func _mm256_mask_rcp14_ps
-- skipped func _mm256_maskz_rcp14_ps
-- skipped func _mm_rcp14_ps
-- skipped func _mm_mask_rcp14_ps
-- skipped func _mm_maskz_rcp14_ps
-- skipped func _mm256_rsqrt14_pd
-- skipped func _mm256_mask_rsqrt14_pd
-- skipped func _mm256_maskz_rsqrt14_pd
-- skipped func _mm_rsqrt14_pd
-- skipped func _mm_mask_rsqrt14_pd
-- skipped func _mm_maskz_rsqrt14_pd
-- skipped func _mm256_rsqrt14_ps
-- skipped func _mm256_mask_rsqrt14_ps
-- skipped func _mm256_maskz_rsqrt14_ps
-- skipped func _mm_rsqrt14_ps
-- skipped func _mm_mask_rsqrt14_ps
-- skipped func _mm_maskz_rsqrt14_ps
-- skipped func _mm256_mask_sqrt_pd
-- skipped func _mm256_maskz_sqrt_pd
-- skipped func _mm_mask_sqrt_pd
-- skipped func _mm_maskz_sqrt_pd
-- skipped func _mm256_mask_sqrt_ps
-- skipped func _mm256_maskz_sqrt_ps
-- skipped func _mm_mask_sqrt_ps
-- skipped func _mm_maskz_sqrt_ps
-- skipped func _mm256_mask_add_epi32
-- skipped func _mm256_maskz_add_epi32
-- skipped func _mm256_mask_add_epi64
-- skipped func _mm256_maskz_add_epi64
-- skipped func _mm256_mask_sub_epi32
-- skipped func _mm256_maskz_sub_epi32
-- skipped func _mm256_mask_sub_epi64
-- skipped func _mm256_maskz_sub_epi64
-- skipped func _mm_mask_add_epi32
-- skipped func _mm_maskz_add_epi32
-- skipped func _mm_mask_add_epi64
-- skipped func _mm_maskz_add_epi64
-- skipped func _mm_mask_sub_epi32
-- skipped func _mm_maskz_sub_epi32
-- skipped func _mm_mask_sub_epi64
-- skipped func _mm_maskz_sub_epi64
-- skipped func _mm256_getexp_ps
-- skipped func _mm256_mask_getexp_ps
-- skipped func _mm256_maskz_getexp_ps
-- skipped func _mm256_getexp_pd
-- skipped func _mm256_mask_getexp_pd
-- skipped func _mm256_maskz_getexp_pd
-- skipped func _mm_getexp_ps
-- skipped func _mm_mask_getexp_ps
-- skipped func _mm_maskz_getexp_ps
-- skipped func _mm_getexp_pd
-- skipped func _mm_mask_getexp_pd
-- skipped func _mm_maskz_getexp_pd
-- skipped func _mm256_mask_srl_epi32
-- skipped func _mm256_maskz_srl_epi32
-- skipped func _mm_mask_srl_epi32
-- skipped func _mm_maskz_srl_epi32
-- skipped func _mm256_mask_srl_epi64
-- skipped func _mm256_maskz_srl_epi64
-- skipped func _mm_mask_srl_epi64
-- skipped func _mm_maskz_srl_epi64
-- skipped func _mm256_mask_and_epi32
-- skipped func _mm256_maskz_and_epi32
-- skipped func _mm256_scalef_pd
-- skipped func _mm256_mask_scalef_pd
-- skipped func _mm256_maskz_scalef_pd
-- skipped func _mm256_scalef_ps
-- skipped func _mm256_mask_scalef_ps
-- skipped func _mm256_maskz_scalef_ps
-- skipped func _mm_scalef_pd
-- skipped func _mm_mask_scalef_pd
-- skipped func _mm_maskz_scalef_pd
-- skipped func _mm_scalef_ps
-- skipped func _mm_mask_scalef_ps
-- skipped func _mm_maskz_scalef_ps
-- skipped func _mm256_mask_fmadd_pd
-- skipped func _mm256_mask3_fmadd_pd
-- skipped func _mm256_maskz_fmadd_pd
-- skipped func _mm_mask_fmadd_pd
-- skipped func _mm_mask3_fmadd_pd
-- skipped func _mm_maskz_fmadd_pd
-- skipped func _mm256_mask_fmadd_ps
-- skipped func _mm256_mask3_fmadd_ps
-- skipped func _mm256_maskz_fmadd_ps
-- skipped func _mm_mask_fmadd_ps
-- skipped func _mm_mask3_fmadd_ps
-- skipped func _mm_maskz_fmadd_ps
-- skipped func _mm256_mask_fmsub_pd
-- skipped func _mm256_mask3_fmsub_pd
-- skipped func _mm256_maskz_fmsub_pd
-- skipped func _mm_mask_fmsub_pd
-- skipped func _mm_mask3_fmsub_pd
-- skipped func _mm_maskz_fmsub_pd
-- skipped func _mm256_mask_fmsub_ps
-- skipped func _mm256_mask3_fmsub_ps
-- skipped func _mm256_maskz_fmsub_ps
-- skipped func _mm_mask_fmsub_ps
-- skipped func _mm_mask3_fmsub_ps
-- skipped func _mm_maskz_fmsub_ps
-- skipped func _mm256_mask_fmaddsub_pd
-- skipped func _mm256_mask3_fmaddsub_pd
-- skipped func _mm256_maskz_fmaddsub_pd
-- skipped func _mm_mask_fmaddsub_pd
-- skipped func _mm_mask3_fmaddsub_pd
-- skipped func _mm_maskz_fmaddsub_pd
-- skipped func _mm256_mask_fmaddsub_ps
-- skipped func _mm256_mask3_fmaddsub_ps
-- skipped func _mm256_maskz_fmaddsub_ps
-- skipped func _mm_mask_fmaddsub_ps
-- skipped func _mm_mask3_fmaddsub_ps
-- skipped func _mm_maskz_fmaddsub_ps
-- skipped func _mm256_mask_fmsubadd_pd
-- skipped func _mm256_mask3_fmsubadd_pd
-- skipped func _mm256_maskz_fmsubadd_pd
-- skipped func _mm_mask_fmsubadd_pd
-- skipped func _mm_mask3_fmsubadd_pd
-- skipped func _mm_maskz_fmsubadd_pd
-- skipped func _mm256_mask_fmsubadd_ps
-- skipped func _mm256_mask3_fmsubadd_ps
-- skipped func _mm256_maskz_fmsubadd_ps
-- skipped func _mm_mask_fmsubadd_ps
-- skipped func _mm_mask3_fmsubadd_ps
-- skipped func _mm_maskz_fmsubadd_ps
-- skipped func _mm256_mask_fnmadd_pd
-- skipped func _mm256_mask3_fnmadd_pd
-- skipped func _mm256_maskz_fnmadd_pd
-- skipped func _mm_mask_fnmadd_pd
-- skipped func _mm_mask3_fnmadd_pd
-- skipped func _mm_maskz_fnmadd_pd
-- skipped func _mm256_mask_fnmadd_ps
-- skipped func _mm256_mask3_fnmadd_ps
-- skipped func _mm256_maskz_fnmadd_ps
-- skipped func _mm_mask_fnmadd_ps
-- skipped func _mm_mask3_fnmadd_ps
-- skipped func _mm_maskz_fnmadd_ps
-- skipped func _mm256_mask_fnmsub_pd
-- skipped func _mm256_mask3_fnmsub_pd
-- skipped func _mm256_maskz_fnmsub_pd
-- skipped func _mm_mask_fnmsub_pd
-- skipped func _mm_mask3_fnmsub_pd
-- skipped func _mm_maskz_fnmsub_pd
-- skipped func _mm256_mask_fnmsub_ps
-- skipped func _mm256_mask3_fnmsub_ps
-- skipped func _mm256_maskz_fnmsub_ps
-- skipped func _mm_mask_fnmsub_ps
-- skipped func _mm_mask3_fnmsub_ps
-- skipped func _mm_maskz_fnmsub_ps
-- skipped func _mm_mask_and_epi32
-- skipped func _mm_maskz_and_epi32
-- skipped func _mm256_mask_andnot_epi32
-- skipped func _mm256_maskz_andnot_epi32
-- skipped func _mm_mask_andnot_epi32
-- skipped func _mm_maskz_andnot_epi32
-- skipped func _mm256_mask_or_epi32
-- skipped func _mm256_maskz_or_epi32
-- skipped func _mm_mask_or_epi32
-- skipped func _mm_maskz_or_epi32
-- skipped func _mm256_mask_xor_epi32
-- skipped func _mm256_maskz_xor_epi32
-- skipped func _mm_mask_xor_epi32
-- skipped func _mm_maskz_xor_epi32
-- skipped func _mm_mask_cvtpd_ps
-- skipped func _mm_maskz_cvtpd_ps
-- skipped func _mm256_mask_cvtpd_ps
-- skipped func _mm256_maskz_cvtpd_ps
-- skipped func _mm256_mask_cvtps_epi32
-- skipped func _mm256_maskz_cvtps_epi32
-- skipped func _mm_mask_cvtps_epi32
-- skipped func _mm_maskz_cvtps_epi32
-- skipped func _mm256_cvtps_epu32
-- skipped func _mm256_mask_cvtps_epu32
-- skipped func _mm256_maskz_cvtps_epu32
-- skipped func _mm_cvtps_epu32
-- skipped func _mm_mask_cvtps_epu32
-- skipped func _mm_maskz_cvtps_epu32
-- skipped func _mm256_mask_movedup_pd
-- skipped func _mm256_maskz_movedup_pd
-- skipped func _mm_mask_movedup_pd
-- skipped func _mm_maskz_movedup_pd
-- skipped func _mm256_mask_movehdup_ps
-- skipped func _mm256_maskz_movehdup_ps
-- skipped func _mm_mask_movehdup_ps
-- skipped func _mm_maskz_movehdup_ps
-- skipped func _mm256_mask_moveldup_ps
-- skipped func _mm256_maskz_moveldup_ps
-- skipped func _mm_mask_moveldup_ps
-- skipped func _mm_maskz_moveldup_ps
-- skipped func _mm_mask_unpackhi_epi32
-- skipped func _mm_maskz_unpackhi_epi32
-- skipped func _mm256_mask_unpackhi_epi32
-- skipped func _mm256_maskz_unpackhi_epi32
-- skipped func _mm_mask_unpackhi_epi64
-- skipped func _mm_maskz_unpackhi_epi64
-- skipped func _mm256_mask_unpackhi_epi64
-- skipped func _mm256_maskz_unpackhi_epi64
-- skipped func _mm_mask_unpacklo_epi32
-- skipped func _mm_maskz_unpacklo_epi32
-- skipped func _mm256_mask_unpacklo_epi32
-- skipped func _mm256_maskz_unpacklo_epi32
-- skipped func _mm_mask_unpacklo_epi64
-- skipped func _mm_maskz_unpacklo_epi64
-- skipped func _mm256_mask_unpacklo_epi64
-- skipped func _mm256_maskz_unpacklo_epi64
-- skipped func _mm_cmpeq_epu32_mask
-- skipped func _mm_cmpeq_epi32_mask
-- skipped func _mm_mask_cmpeq_epu32_mask
-- skipped func _mm_mask_cmpeq_epi32_mask
-- skipped func _mm256_cmpeq_epu32_mask
-- skipped func _mm256_cmpeq_epi32_mask
-- skipped func _mm256_mask_cmpeq_epu32_mask
-- skipped func _mm256_mask_cmpeq_epi32_mask
-- skipped func _mm_cmpeq_epu64_mask
-- skipped func _mm_cmpeq_epi64_mask
-- skipped func _mm_mask_cmpeq_epu64_mask
-- skipped func _mm_mask_cmpeq_epi64_mask
-- skipped func _mm256_cmpeq_epu64_mask
-- skipped func _mm256_cmpeq_epi64_mask
-- skipped func _mm256_mask_cmpeq_epu64_mask
-- skipped func _mm256_mask_cmpeq_epi64_mask
-- skipped func _mm_cmpgt_epu32_mask
-- skipped func _mm_cmpgt_epi32_mask
-- skipped func _mm_mask_cmpgt_epu32_mask
-- skipped func _mm_mask_cmpgt_epi32_mask
-- skipped func _mm256_cmpgt_epu32_mask
-- skipped func _mm256_cmpgt_epi32_mask
-- skipped func _mm256_mask_cmpgt_epu32_mask
-- skipped func _mm256_mask_cmpgt_epi32_mask
-- skipped func _mm_cmpgt_epu64_mask
-- skipped func _mm_cmpgt_epi64_mask
-- skipped func _mm_mask_cmpgt_epu64_mask
-- skipped func _mm_mask_cmpgt_epi64_mask
-- skipped func _mm256_cmpgt_epu64_mask
-- skipped func _mm256_cmpgt_epi64_mask
-- skipped func _mm256_mask_cmpgt_epu64_mask
-- skipped func _mm256_mask_cmpgt_epi64_mask
-- skipped func _mm_test_epi32_mask
-- skipped func _mm_mask_test_epi32_mask
-- skipped func _mm256_test_epi32_mask
-- skipped func _mm256_mask_test_epi32_mask
-- skipped func _mm_test_epi64_mask
-- skipped func _mm_mask_test_epi64_mask
-- skipped func _mm256_test_epi64_mask
-- skipped func _mm256_mask_test_epi64_mask
-- skipped func _mm_testn_epi32_mask
-- skipped func _mm_mask_testn_epi32_mask
-- skipped func _mm256_testn_epi32_mask
-- skipped func _mm256_mask_testn_epi32_mask
-- skipped func _mm_testn_epi64_mask
-- skipped func _mm_mask_testn_epi64_mask
-- skipped func _mm256_testn_epi64_mask
-- skipped func _mm256_mask_testn_epi64_mask
-- skipped func _mm256_mask_compress_pd
-- skipped func _mm256_maskz_compress_pd
-- skipped func _mm256_mask_compressstoreu_pd
-- skipped func _mm_mask_compress_pd
-- skipped func _mm_maskz_compress_pd
-- skipped func _mm_mask_compressstoreu_pd
-- skipped func _mm256_mask_compress_ps
-- skipped func _mm256_maskz_compress_ps
-- skipped func _mm256_mask_compressstoreu_ps
-- skipped func _mm_mask_compress_ps
-- skipped func _mm_maskz_compress_ps
-- skipped func _mm_mask_compressstoreu_ps
-- skipped func _mm256_mask_compress_epi64
-- skipped func _mm256_maskz_compress_epi64
-- skipped func _mm256_mask_compressstoreu_epi64
-- skipped func _mm_mask_compress_epi64
-- skipped func _mm_maskz_compress_epi64
-- skipped func _mm_mask_compressstoreu_epi64
-- skipped func _mm256_mask_compress_epi32
-- skipped func _mm256_maskz_compress_epi32
-- skipped func _mm256_mask_compressstoreu_epi32
-- skipped func _mm_mask_compress_epi32
-- skipped func _mm_maskz_compress_epi32
-- skipped func _mm_mask_compressstoreu_epi32
-- skipped func _mm256_mask_expand_pd
-- skipped func _mm256_maskz_expand_pd
-- skipped func _mm256_mask_expandloadu_pd
-- skipped func _mm256_maskz_expandloadu_pd
-- skipped func _mm_mask_expand_pd
-- skipped func _mm_maskz_expand_pd
-- skipped func _mm_mask_expandloadu_pd
-- skipped func _mm_maskz_expandloadu_pd
-- skipped func _mm256_mask_expand_ps
-- skipped func _mm256_maskz_expand_ps
-- skipped func _mm256_mask_expandloadu_ps
-- skipped func _mm256_maskz_expandloadu_ps
-- skipped func _mm_mask_expand_ps
-- skipped func _mm_maskz_expand_ps
-- skipped func _mm_mask_expandloadu_ps
-- skipped func _mm_maskz_expandloadu_ps
-- skipped func _mm256_mask_expand_epi64
-- skipped func _mm256_maskz_expand_epi64
-- skipped func _mm256_mask_expandloadu_epi64
-- skipped func _mm256_maskz_expandloadu_epi64
-- skipped func _mm_mask_expand_epi64
-- skipped func _mm_maskz_expand_epi64
-- skipped func _mm_mask_expandloadu_epi64
-- skipped func _mm_maskz_expandloadu_epi64
-- skipped func _mm256_mask_expand_epi32
-- skipped func _mm256_maskz_expand_epi32
-- skipped func _mm256_mask_expandloadu_epi32
-- skipped func _mm256_maskz_expandloadu_epi32
-- skipped func _mm_mask_expand_epi32
-- skipped func _mm_maskz_expand_epi32
-- skipped func _mm_mask_expandloadu_epi32
-- skipped func _mm_maskz_expandloadu_epi32
-- skipped func _mm256_permutex2var_pd
-- idx
-- skipped func _mm256_mask_permutex2var_pd
-- idx
-- skipped func _mm256_mask2_permutex2var_pd
-- idx
-- skipped func _mm256_maskz_permutex2var_pd
-- idx
-- skipped func _mm256_permutex2var_ps
-- idx
-- skipped func _mm256_mask_permutex2var_ps
-- idx
-- skipped func _mm256_mask2_permutex2var_ps
-- idx
-- skipped func _mm256_maskz_permutex2var_ps
-- idx
-- skipped func _mm_permutex2var_epi64
-- idx
-- skipped func _mm_mask_permutex2var_epi64
-- idx
-- skipped func _mm_mask2_permutex2var_epi64
-- idx
-- skipped func _mm_maskz_permutex2var_epi64
-- idx
-- skipped func _mm_permutex2var_epi32
-- idx
-- skipped func _mm_mask_permutex2var_epi32
-- idx
-- skipped func _mm_mask2_permutex2var_epi32
-- idx
-- skipped func _mm_maskz_permutex2var_epi32
-- idx
-- skipped func _mm256_permutex2var_epi64
-- idx
-- skipped func _mm256_mask_permutex2var_epi64
-- idx
-- skipped func _mm256_mask2_permutex2var_epi64
-- idx
-- skipped func _mm256_maskz_permutex2var_epi64
-- idx
-- skipped func _mm256_permutex2var_epi32
-- idx
-- skipped func _mm256_mask_permutex2var_epi32
-- idx
-- skipped func _mm256_mask2_permutex2var_epi32
-- idx
-- skipped func _mm256_maskz_permutex2var_epi32
-- idx
-- skipped func _mm_permutex2var_pd
-- idx
-- skipped func _mm_mask_permutex2var_pd
-- idx
-- skipped func _mm_mask2_permutex2var_pd
-- idx
-- skipped func _mm_maskz_permutex2var_pd
-- idx
-- skipped func _mm_permutex2var_ps
-- idx
-- skipped func _mm_mask_permutex2var_ps
-- idx
-- skipped func _mm_mask2_permutex2var_ps
-- idx
-- skipped func _mm_maskz_permutex2var_ps
-- idx
-- skipped func _mm_srav_epi64
-- skipped func _mm_mask_srav_epi64
-- skipped func _mm_maskz_srav_epi64
-- skipped func _mm256_mask_sllv_epi32
-- skipped func _mm256_maskz_sllv_epi32
-- skipped func _mm_mask_sllv_epi32
-- skipped func _mm_maskz_sllv_epi32
-- skipped func _mm256_mask_sllv_epi64
-- skipped func _mm256_maskz_sllv_epi64
-- skipped func _mm_mask_sllv_epi64
-- skipped func _mm_maskz_sllv_epi64
-- skipped func _mm256_mask_srav_epi32
-- skipped func _mm256_maskz_srav_epi32
-- skipped func _mm_mask_srav_epi32
-- skipped func _mm_maskz_srav_epi32
-- skipped func _mm256_mask_srlv_epi32
-- skipped func _mm256_maskz_srlv_epi32
-- skipped func _mm_mask_srlv_epi32
-- skipped func _mm_maskz_srlv_epi32
-- skipped func _mm256_mask_srlv_epi64
-- skipped func _mm256_maskz_srlv_epi64
-- skipped func _mm_mask_srlv_epi64
-- skipped func _mm_maskz_srlv_epi64
-- skipped func _mm256_rolv_epi32
-- skipped func _mm256_mask_rolv_epi32
-- skipped func _mm256_maskz_rolv_epi32
-- skipped func _mm_rolv_epi32
-- skipped func _mm_mask_rolv_epi32
-- skipped func _mm_maskz_rolv_epi32
-- skipped func _mm256_rorv_epi32
-- skipped func _mm256_mask_rorv_epi32
-- skipped func _mm256_maskz_rorv_epi32
-- skipped func _mm_rorv_epi32
-- skipped func _mm_mask_rorv_epi32
-- skipped func _mm_maskz_rorv_epi32
-- skipped func _mm256_rolv_epi64
-- skipped func _mm256_mask_rolv_epi64
-- skipped func _mm256_maskz_rolv_epi64
-- skipped func _mm_rolv_epi64
-- skipped func _mm_mask_rolv_epi64
-- skipped func _mm_maskz_rolv_epi64
-- skipped func _mm256_rorv_epi64
-- skipped func _mm256_mask_rorv_epi64
-- skipped func _mm256_maskz_rorv_epi64
-- skipped func _mm_rorv_epi64
-- skipped func _mm_mask_rorv_epi64
-- skipped func _mm_maskz_rorv_epi64
-- skipped func _mm256_srav_epi64
-- skipped func _mm256_mask_srav_epi64
-- skipped func _mm256_maskz_srav_epi64
-- skipped func _mm256_mask_and_epi64
-- skipped func _mm256_maskz_and_epi64
-- skipped func _mm_mask_and_epi64
-- skipped func _mm_maskz_and_epi64
-- skipped func _mm256_mask_andnot_epi64
-- skipped func _mm256_maskz_andnot_epi64
-- skipped func _mm_mask_andnot_epi64
-- skipped func _mm_maskz_andnot_epi64
-- skipped func _mm256_mask_or_epi64
-- skipped func _mm256_maskz_or_epi64
-- skipped func _mm_mask_or_epi64
-- skipped func _mm_maskz_or_epi64
-- skipped func _mm256_mask_xor_epi64
-- skipped func _mm256_maskz_xor_epi64
-- skipped func _mm_mask_xor_epi64
-- skipped func _mm_maskz_xor_epi64
-- skipped func _mm256_mask_max_pd
-- skipped func _mm256_maskz_max_pd
-- skipped func _mm256_mask_max_ps
-- skipped func _mm256_maskz_max_ps
-- skipped func _mm_mask_div_ps
-- skipped func _mm_maskz_div_ps
-- skipped func _mm_mask_div_pd
-- skipped func _mm_maskz_div_pd
-- skipped func _mm256_mask_min_pd
-- skipped func _mm256_mask_div_pd
-- skipped func _mm256_maskz_min_pd
-- skipped func _mm256_mask_min_ps
-- skipped func _mm256_maskz_div_pd
-- skipped func _mm256_mask_div_ps
-- skipped func _mm256_maskz_min_ps
-- skipped func _mm256_maskz_div_ps
-- skipped func _mm_mask_min_ps
-- skipped func _mm_mask_mul_ps
-- skipped func _mm_maskz_min_ps
-- skipped func _mm_maskz_mul_ps
-- skipped func _mm_mask_max_ps
-- skipped func _mm_maskz_max_ps
-- skipped func _mm_mask_min_pd
-- skipped func _mm_maskz_min_pd
-- skipped func _mm_mask_max_pd
-- skipped func _mm_maskz_max_pd
-- skipped func _mm_mask_mul_pd
-- skipped func _mm_maskz_mul_pd
-- skipped func _mm256_mask_mul_ps
-- skipped func _mm256_maskz_mul_ps
-- skipped func _mm256_mask_mul_pd
-- skipped func _mm256_maskz_mul_pd
-- skipped func _mm256_maskz_max_epi64
-- skipped func _mm256_mask_max_epi64
-- skipped func _mm256_min_epi64
-- skipped func _mm256_mask_min_epi64
-- skipped func _mm256_maskz_min_epi64
-- skipped func _mm256_maskz_max_epu64
-- skipped func _mm256_max_epi64
-- skipped func _mm256_max_epu64
-- skipped func _mm256_mask_max_epu64
-- skipped func _mm256_min_epu64
-- skipped func _mm256_mask_min_epu64
-- skipped func _mm256_maskz_min_epu64
-- skipped func _mm256_maskz_max_epi32
-- skipped func _mm256_mask_max_epi32
-- skipped func _mm256_maskz_min_epi32
-- skipped func _mm256_mask_min_epi32
-- skipped func _mm256_maskz_max_epu32
-- skipped func _mm256_mask_max_epu32
-- skipped func _mm256_maskz_min_epu32
-- skipped func _mm256_mask_min_epu32
-- skipped func _mm_maskz_max_epi64
-- skipped func _mm_mask_max_epi64
-- skipped func _mm_min_epi64
-- skipped func _mm_mask_min_epi64
-- skipped func _mm_maskz_min_epi64
-- skipped func _mm_maskz_max_epu64
-- skipped func _mm_max_epi64
-- skipped func _mm_max_epu64
-- skipped func _mm_mask_max_epu64
-- skipped func _mm_min_epu64
-- skipped func _mm_mask_min_epu64
-- skipped func _mm_maskz_min_epu64
-- skipped func _mm_maskz_max_epi32
-- skipped func _mm_mask_max_epi32
-- skipped func _mm_maskz_min_epi32
-- skipped func _mm_mask_min_epi32
-- skipped func _mm_maskz_max_epu32
-- skipped func _mm_mask_max_epu32
-- skipped func _mm_maskz_min_epu32
-- skipped func _mm_mask_min_epu32
-- skipped func _mm_broadcastmb_epi64
-- skipped func _mm256_broadcastmb_epi64
-- skipped func _mm_broadcastmw_epi32
-- skipped func _mm256_broadcastmw_epi32
-- skipped func _mm256_lzcnt_epi32
-- skipped func _mm256_mask_lzcnt_epi32
-- skipped func _mm256_maskz_lzcnt_epi32
-- skipped func _mm256_lzcnt_epi64
-- skipped func _mm256_mask_lzcnt_epi64
-- skipped func _mm256_maskz_lzcnt_epi64
-- skipped func _mm256_conflict_epi64
-- skipped func _mm256_mask_conflict_epi64
-- skipped func _mm256_maskz_conflict_epi64
-- skipped func _mm256_conflict_epi32
-- skipped func _mm256_mask_conflict_epi32
-- skipped func _mm256_maskz_conflict_epi32
-- skipped func _mm_lzcnt_epi32
-- skipped func _mm_mask_lzcnt_epi32
-- skipped func _mm_maskz_lzcnt_epi32
-- skipped func _mm_lzcnt_epi64
-- skipped func _mm_mask_lzcnt_epi64
-- skipped func _mm_maskz_lzcnt_epi64
-- skipped func _mm_conflict_epi64
-- skipped func _mm_mask_conflict_epi64
-- skipped func _mm_maskz_conflict_epi64
-- skipped func _mm_conflict_epi32
-- skipped func _mm_mask_conflict_epi32
-- skipped func _mm_maskz_conflict_epi32
-- skipped func _mm256_mask_unpacklo_pd
-- skipped func _mm256_maskz_unpacklo_pd
-- skipped func _mm_mask_unpacklo_pd
-- skipped func _mm_maskz_unpacklo_pd
-- skipped func _mm256_mask_unpacklo_ps
-- skipped func _mm256_mask_unpackhi_pd
-- skipped func _mm256_maskz_unpackhi_pd
-- skipped func _mm_mask_unpackhi_pd
-- skipped func _mm_maskz_unpackhi_pd
-- skipped func _mm256_mask_unpackhi_ps
-- skipped func _mm256_maskz_unpackhi_ps
-- skipped func _mm_mask_unpackhi_ps
-- skipped func _mm_maskz_unpackhi_ps
-- skipped func _mm_mask_cvtph_ps
-- skipped func _mm_maskz_cvtph_ps
-- skipped func _mm256_maskz_unpacklo_ps
-- skipped func _mm256_mask_cvtph_ps
-- skipped func _mm256_maskz_cvtph_ps
-- skipped func _mm_mask_unpacklo_ps
-- skipped func _mm_maskz_unpacklo_ps
-- skipped func _mm256_mask_sra_epi32
-- skipped func _mm256_maskz_sra_epi32
-- skipped func _mm_mask_sra_epi32
-- skipped func _mm_maskz_sra_epi32
-- skipped func _mm256_sra_epi64
-- skipped func _mm256_mask_sra_epi64
-- skipped func _mm256_maskz_sra_epi64
-- skipped func _mm_sra_epi64
-- skipped func _mm_mask_sra_epi64
-- skipped func _mm_maskz_sra_epi64
-- skipped func _mm_mask_sll_epi32
-- skipped func _mm_maskz_sll_epi32
-- skipped func _mm_mask_sll_epi64
-- skipped func _mm_maskz_sll_epi64
-- skipped func _mm256_mask_sll_epi32
-- skipped func _mm256_maskz_sll_epi32
-- skipped func _mm256_mask_sll_epi64
-- skipped func _mm256_maskz_sll_epi64
-- skipped func _mm256_mask_permutexvar_ps
-- skipped func _mm256_maskz_permutexvar_ps
-- skipped func _mm256_permutexvar_pd
-- skipped func _mm256_mask_permutexvar_pd
-- skipped func _mm256_maskz_permutexvar_pd
-- skipped func _mm256_mask_permutevar_pd
-- skipped func _mm256_maskz_permutevar_pd
-- skipped func _mm256_mask_permutevar_ps
-- skipped func _mm256_maskz_permutevar_ps
-- skipped func _mm_mask_permutevar_pd
-- skipped func _mm_maskz_permutevar_pd
-- skipped func _mm_mask_permutevar_ps
-- skipped func _mm_maskz_permutevar_ps
-- skipped func _mm256_maskz_mullo_epi32
-- skipped func _mm256_maskz_permutexvar_epi64
-- skipped func _mm256_mask_mullo_epi32
-- skipped func _mm_maskz_mullo_epi32
-- skipped func _mm_mask_mullo_epi32
-- skipped func _mm256_mask_mul_epi32
-- skipped func _mm256_maskz_mul_epi32
-- skipped func _mm_mask_mul_epi32
-- skipped func _mm_maskz_mul_epi32
-- skipped func _mm256_permutexvar_epi64
-- skipped func _mm256_mask_permutexvar_epi64
-- skipped func _mm256_mask_mul_epu32
-- skipped func _mm256_maskz_permutexvar_epi32
-- skipped func _mm256_maskz_mul_epu32
-- skipped func _mm_mask_mul_epu32
-- skipped func _mm_maskz_mul_epu32
-- skipped func _mm256_permutexvar_epi32
-- skipped func _mm256_mask_permutexvar_epi32
-- skipped func _mm256_mask_cmpneq_epu32_mask
-- skipped func _mm256_cmpneq_epu32_mask
-- skipped func _mm256_mask_cmplt_epu32_mask
-- skipped func _mm256_cmplt_epu32_mask
-- skipped func _mm256_mask_cmpge_epu32_mask
-- skipped func _mm256_cmpge_epu32_mask
-- skipped func _mm256_mask_cmple_epu32_mask
-- skipped func _mm256_cmple_epu32_mask
-- skipped func _mm256_mask_cmpneq_epu64_mask
-- skipped func _mm256_cmpneq_epu64_mask
-- skipped func _mm256_mask_cmplt_epu64_mask
-- skipped func _mm256_cmplt_epu64_mask
-- skipped func _mm256_mask_cmpge_epu64_mask
-- skipped func _mm256_cmpge_epu64_mask
-- skipped func _mm256_mask_cmple_epu64_mask
-- skipped func _mm256_cmple_epu64_mask
-- skipped func _mm256_mask_cmpneq_epi32_mask
-- skipped func _mm256_cmpneq_epi32_mask
-- skipped func _mm256_mask_cmplt_epi32_mask
-- skipped func _mm256_cmplt_epi32_mask
-- skipped func _mm256_mask_cmpge_epi32_mask
-- skipped func _mm256_cmpge_epi32_mask
-- skipped func _mm256_mask_cmple_epi32_mask
-- skipped func _mm256_cmple_epi32_mask
-- skipped func _mm256_mask_cmpneq_epi64_mask
-- skipped func _mm256_cmpneq_epi64_mask
-- skipped func _mm256_mask_cmplt_epi64_mask
-- skipped func _mm256_cmplt_epi64_mask
-- skipped func _mm256_mask_cmpge_epi64_mask
-- skipped func _mm256_cmpge_epi64_mask
-- skipped func _mm256_mask_cmple_epi64_mask
-- skipped func _mm256_cmple_epi64_mask
-- skipped func _mm_mask_cmpneq_epu32_mask
-- skipped func _mm_cmpneq_epu32_mask
-- skipped func _mm_mask_cmplt_epu32_mask
-- skipped func _mm_cmplt_epu32_mask
-- skipped func _mm_mask_cmpge_epu32_mask
-- skipped func _mm_cmpge_epu32_mask
-- skipped func _mm_mask_cmple_epu32_mask
-- skipped func _mm_cmple_epu32_mask
-- skipped func _mm_mask_cmpneq_epu64_mask
-- skipped func _mm_cmpneq_epu64_mask
-- skipped func _mm_mask_cmplt_epu64_mask
-- skipped func _mm_cmplt_epu64_mask
-- skipped func _mm_mask_cmpge_epu64_mask
-- skipped func _mm_cmpge_epu64_mask
-- skipped func _mm_mask_cmple_epu64_mask
-- skipped func _mm_cmple_epu64_mask
-- skipped func _mm_mask_cmpneq_epi32_mask
-- skipped func _mm_cmpneq_epi32_mask
-- skipped func _mm_mask_cmplt_epi32_mask
-- skipped func _mm_cmplt_epi32_mask
-- skipped func _mm_mask_cmpge_epi32_mask
-- skipped func _mm_cmpge_epi32_mask
-- skipped func _mm_mask_cmple_epi32_mask
-- skipped func _mm_cmple_epi32_mask
-- skipped func _mm_mask_cmpneq_epi64_mask
-- skipped func _mm_cmpneq_epi64_mask
-- skipped func _mm_mask_cmplt_epi64_mask
-- skipped func _mm_cmplt_epi64_mask
-- skipped func _mm_mask_cmpge_epi64_mask
-- skipped func _mm_cmpge_epi64_mask
-- skipped func _mm_mask_cmple_epi64_mask
-- skipped func _mm_cmple_epi64_mask
end avx512vlintrin_h;
|
sungyeon/drake | Ada | 9,636 | adb | -- reference:
-- http://www.mudpedia.org/mediawiki/index.php/Xterm_256_colors
with System.Address_To_Named_Access_Conversions;
with System.Formatting;
with System.Long_Long_Integer_Types;
with System.Once;
with C.stdlib;
package body System.Native_Text_IO.Terminal_Colors is
use type C.char_array;
use type C.char_ptr;
use type C.signed_int;
use type C.size_t;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
function strlen (s : not null access constant C.char) return C.size_t
with Import,
Convention => Intrinsic, External_Name => "__builtin_strlen";
package char_ptr_Conv is
new Address_To_Named_Access_Conversions (C.char, C.char_ptr);
TERM_Variable : constant C.char_array (0 .. 4) := "TERM" & C.char'Val (0);
xterm_256color : constant String (1 .. 14) := "xterm-256color";
Support_256_Color_Flag : aliased Once.Flag := 0;
Support_256_Color : Boolean;
procedure Support_256_Color_Init;
procedure Support_256_Color_Init is
TERM : C.char_ptr;
begin
TERM := C.stdlib.getenv (TERM_Variable (0)'Access);
if TERM /= null
and then strlen (TERM) = xterm_256color'Length
then
declare
TERM_All : String (1 .. xterm_256color'Length);
for TERM_All'Address use char_ptr_Conv.To_Address (TERM);
begin
Support_256_Color := TERM_All = xterm_256color;
end;
else
Support_256_Color := False;
end if;
end Support_256_Color_Init;
procedure Initialize;
procedure Initialize is
begin
Once.Initialize (
Support_256_Color_Flag'Access,
Support_256_Color_Init'Access);
end Initialize;
function RGB_To_256_Color (Item : Ada.Colors.RGB) return Color;
function RGB_To_256_Color (Item : Ada.Colors.RGB) return Color is
subtype B is Ada.Colors.Brightness'Base;
function Color_Scale (Item : B) return Color;
function Color_Scale (Item : B) return Color is
begin
if Item < (0.0 + 16#5F.0#) / 2.0 / 255.0 then
return 0;
elsif Item < (16#5F.0# + 16#87.0#) / 2.0 / 255.0 then
return 1;
elsif Item < (16#87.0# + 16#AF.0#) / 2.0 / 255.0 then
return 2;
elsif Item < (16#AF.0# + 16#D7.0#) / 2.0 / 255.0 then
return 3;
elsif Item < (16#D7.0# + 16#FF.0#) / 2.0 / 255.0 then
return 4;
else
return 5;
end if;
end Color_Scale;
begin
return 16
+ 36 * Color_Scale (Item.Red)
+ 6 * Color_Scale (Item.Green)
+ Color_Scale (Item.Blue);
end RGB_To_256_Color;
function Brightness_To_Grayscale_256_Color (Item : Ada.Colors.Brightness)
return Color;
function Brightness_To_Grayscale_256_Color (Item : Ada.Colors.Brightness)
return Color
is
subtype B is Ada.Colors.Brightness'Base;
Grayscale_Index : constant Integer :=
(Integer (B'Floor (Item * B'Pred (250.0))) + 5) / 10 - 1 + 232;
begin
if Grayscale_Index < 232 then
return 16; -- 16#00#
elsif Grayscale_Index <= 255 then -- in 232 .. 255
return Color (Grayscale_Index);
else
return 16 + 6#555#; -- 16#FF#
end if;
end Brightness_To_Grayscale_256_Color;
function RGB_To_System_Color (Item : Ada.Colors.RGB) return Color;
function RGB_To_System_Color (Item : Ada.Colors.RGB) return Color is
subtype B is Ada.Colors.Brightness'Base;
Result : Color;
begin
if Item.Red in 0.25 .. B'Pred (0.675)
and then Item.Green in 0.25 .. B'Pred (0.675)
and then Item.Blue in 0.25 .. B'Pred (0.675)
then -- Dark_Gray = (16#80#, 16#80#, 16#80#)
Result := 8;
elsif Item.Red >= 0.875
or else Item.Green >= 0.875
or else Item.Blue >= 0.875
then -- bright colors
Result := 8;
if Item.Red >= 0.875 then
Result := Result or 1;
end if;
if Item.Green >= 0.875 then
Result := Result or 2;
end if;
if Item.Blue >= 0.875 then
Result := Result or 4;
end if;
else -- dark colors
Result := 0;
if Item.Red >= 0.375 then
Result := Result or 1;
end if;
if Item.Green >= 0.375 then
Result := Result or 2;
end if;
if Item.Blue >= 0.375 then
Result := Result or 4;
end if;
end if;
return Result;
end RGB_To_System_Color;
function Brightness_To_Grayscale_System_Color (Item : Ada.Colors.Brightness)
return Color;
function Brightness_To_Grayscale_System_Color (Item : Ada.Colors.Brightness)
return Color is
begin
-- [0.000 .. 0.250) => 0
-- [0.250 .. 0.625) => 16#80# = 8
-- [0.625 .. 0.875) => 16#C0# = 7
-- [0.875 .. 1.000] => 16#FF# = 15
return RGB_To_System_Color ((Red => Item, Green => Item, Blue => Item));
end Brightness_To_Grayscale_System_Color;
-- implementation
function RGB_To_Color (Item : Ada.Colors.RGB) return Color is
begin
Initialize;
if Support_256_Color then
return RGB_To_256_Color (Item);
else
return RGB_To_System_Color (Item);
end if;
end RGB_To_Color;
function Brightness_To_Grayscale_Color (Item : Ada.Colors.Brightness)
return Color is
begin
Initialize;
if Support_256_Color then
return Brightness_To_Grayscale_256_Color (Item);
else
return Brightness_To_Grayscale_System_Color (Item);
end if;
end Brightness_To_Grayscale_Color;
procedure Set (
Handle : Handle_Type;
Reset : Boolean;
Bold_Changing : Boolean;
Bold : Boolean;
Underline_Changing : Boolean;
Underline : Boolean;
Blink_Changing : Boolean;
Blink : Boolean;
Reversed_Changing : Boolean;
Reversed : Boolean;
Foreground_Changing : Boolean;
Foreground : Color;
Background_Changing : Boolean;
Background : Color)
is
Seq : String (1 .. 256);
Last : Natural;
Error : Boolean;
begin
Seq (1) := Character'Val (16#1B#);
Seq (2) := '[';
Last := 2;
-- changing
if Reset then
Last := Last + 1;
Seq (Last) := '0';
end if;
if Bold_Changing and then Bold then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '1';
end if;
if Underline_Changing and then Underline then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '4';
end if;
if Blink_Changing and then Blink then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '5';
end if;
if Reversed_Changing and then Reversed then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
Last := Last + 1;
Seq (Last) := '7';
end if;
if Foreground_Changing then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
declare
Color_Index : Word_Unsigned := Word_Unsigned (Foreground);
begin
if Foreground < 16#10# then
-- system color
if (Foreground and 8) = 0 then
Last := Last + 1;
Seq (Last) := '3';
else
Last := Last + 1;
Seq (Last) := '9';
Color_Index := Word_Unsigned (Foreground and 7);
end if;
else
-- 256 color
Seq (Last + 1 .. Last + 5) := "38;5;";
Last := Last + 5;
end if;
Formatting.Image (
Color_Index,
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
end;
end if;
if Background_Changing then
if Last > 2 then
Last := Last + 1;
Seq (Last) := ';';
end if;
declare
Color_Index : Word_Unsigned := Word_Unsigned (Background);
begin
if Background < 16#10# then
-- system color
if (Background and 8) = 0 then
Last := Last + 1;
Seq (Last) := '4';
else
Last := Last + 1;
Seq (Last) := '1';
Last := Last + 1;
Seq (Last) := '0';
Color_Index := Word_Unsigned (Background and 7);
end if;
else
-- 256 color
Seq (Last + 1 .. Last + 5) := "48;5;";
Last := Last + 5;
end if;
Formatting.Image (
Color_Index,
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
end;
end if;
-- setting
if Last > 2 then
Last := Last + 1;
Seq (Last) := 'm';
Write_Just (Handle, Seq (1 .. Last));
end if;
end Set;
procedure Reset (
Handle : Handle_Type)
is
Seq : constant String (1 .. 4) :=
(Character'Val (16#1b#), '[', '0', 'm');
begin
Write_Just (Handle, Seq);
end Reset;
end System.Native_Text_IO.Terminal_Colors;
|
faicaltoubali/ENSEEIHT | Ada | 1,999 | ads | generic
Capacite : integer;
package Arbre_Foret is
type T_Abr_Foret is private;
type T_Tableau is private;
Capacite_Tableau_Compagnon_Maximale : Exception;
Compagnon_Existe : Exception;
Epoux_Existe : Exception;
Pere_Existe : Exception;
Mere_Existe : Exception;
Cle_Absente : Exception;
procedure Initialiser(Abr : out T_Abr_Foret) with
Post => Vide(Abr);
function Vide (Abr : in T_Abr_Foret) return Boolean;
procedure Creer_Minimal (Abr : out T_Abr_Foret; Cle : in integer) with
Post => not Vide(Abr);
Procedure Ajouter_Pere ( Abr : in out T_Abr_Foret ; Cle : in integer; Cle_Pere : in integer);
Procedure Ajouter_Mere ( Abr : in out T_Abr_Foret ; Cle : in integer ; Cle_Mere : in integer);
procedure Ajouter_Epoux ( Abr : in out T_Abr_Foret ; Cle : in integer; Cle_Epoux : in integer);
procedure Ajouter_Compagnon ( Abr : in out T_Abr_Foret ; Cle : in integer; Cle_Compagnon : in integer);
function Existe ( Abr : in T_Abr_Foret ; Cle : in integer) return Boolean;
procedure Demis_Soeurs_Freres_Pere ( Abr : in T_Abr_Foret ) ;
procedure Afficher_Fils_Pere ( Abr : in T_Abr_Foret ; Cle_Pere : in integer; Cle_Mere : in integer) ;
procedure Demis_Soeurs_Freres_Mere ( Abr : in T_Abr_Foret ) ;
procedure Afficher_Fils_Mere ( Abr : in T_Abr_Foret ; Cle_Mere : in integer; Cle_Pere : in integer) ;
procedure Avoir_Arbre (Abr : in T_Abr_Foret ; Cle : in integer ; Curseur : in out T_Abr_Foret ) with
Pre => Existe ( Abr , Cle );
function Existe_Compagnon (TableauCompagnon : in T_Tableau; Cle_Compagnon : in integer) return Boolean;
private
type T_Cellule;
type T_Abr_Foret is access T_Cellule;
type T_Tab is array(1..Capacite) of T_Abr_Foret;
type T_Tableau is
record
Taille : integer;
Tableau : T_Tab;
end record;
type T_Cellule is
record
Cle : integer;
Pere : T_Abr_Foret;
Mere : T_Abr_Foret;
Epoux : T_Abr_Foret;
Tableau_Compagnons : T_Tableau;
end record;
end Arbre_Foret;
|
tum-ei-rcs/StratoX | Ada | 7,301 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- Copyright (C) 2012-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This file provides register definitions for the STM32Fx (ARM Cortex M4/7)
-- microcontrollers from ST Microelectronics.
pragma Restrictions (No_Elaboration_Code);
with Interfaces.Bit_Types;
package System.STM32
with SPARK_Mode => On is
pragma Preelaborate (System.STM32);
subtype Frequency is Interfaces.Bit_Types.Word;
type RCC_System_Clocks is record
SYSCLK : Frequency;
HCLK : Frequency;
PCLK1 : Frequency;
PCLK2 : Frequency;
TIMCLK1 : Frequency;
TIMCLK2 : Frequency;
end record;
function System_Clocks return RCC_System_Clocks;
-- MODER constants
subtype GPIO_MODER_Values is Interfaces.Bit_Types.UInt2;
Mode_IN : constant GPIO_MODER_Values := 0;
Mode_OUT : constant GPIO_MODER_Values := 1;
Mode_AF : constant GPIO_MODER_Values := 2;
Mode_AN : constant GPIO_MODER_Values := 3;
-- OTYPER constants
subtype GPIO_OTYPER_Values is Interfaces.Bit_Types.Bit;
Push_Pull : constant GPIO_OTYPER_Values := 0;
Open_Drain : constant GPIO_OTYPER_Values := 1;
-- OSPEEDR constants
subtype GPIO_OSPEEDR_Values is Interfaces.Bit_Types.UInt2;
Speed_2MHz : constant GPIO_OSPEEDR_Values := 0; -- Low speed
Speed_25MHz : constant GPIO_OSPEEDR_Values := 1; -- Medium speed
Speed_50MHz : constant GPIO_OSPEEDR_Values := 2; -- Fast speed
Speed_100MHz : constant GPIO_OSPEEDR_Values := 3; -- High speed
-- PUPDR constants
subtype GPIO_PUPDR_Values is Interfaces.Bit_Types.UInt2;
No_Pull : constant GPIO_PUPDR_Values := 0;
Pull_Up : constant GPIO_PUPDR_Values := 1;
Pull_Down : constant GPIO_PUPDR_Values := 2;
-- AFL constants
AF_USART1 : constant Interfaces.Bit_Types.UInt4 := 7;
AF_USART6 : constant Interfaces.Bit_Types.UInt4 := 8;
type MCU_ID_Register is record
DEV_ID : Interfaces.Bit_Types.UInt12;
Reserved : Interfaces.Bit_Types.UInt4;
REV_ID : Interfaces.Bit_Types.Short;
end record with Pack, Size => 32;
-- RCC constants
type PLL_Source is
(PLL_SRC_HSI,
PLL_SRC_HSE)
with Size => 1;
type SYSCLK_Source is
(SYSCLK_SRC_HSI,
SYSCLK_SRC_HSE,
SYSCLK_SRC_PLL)
with Size => 2;
type AHB_Prescaler_Enum is
(DIV2, DIV4, DIV8, DIV16,
DIV64, DIV128, DIV256, DIV512)
with Size => 3;
type AHB_Prescaler is record
Enabled : Boolean := False;
Value : AHB_Prescaler_Enum := AHB_Prescaler_Enum'First;
end record with Size => 4;
for AHB_Prescaler use record
Enabled at 0 range 3 .. 3;
Value at 0 range 0 .. 2;
end record;
AHBPRE_DIV1 : constant AHB_Prescaler := (Enabled => False, Value => DIV2);
type APB_Prescaler_Enum is
(DIV2, DIV4, DIV8, DIV16)
with Size => 2;
type APB_Prescaler is record
Enabled : Boolean;
Value : APB_Prescaler_Enum;
end record with Size => 3;
for APB_Prescaler use record
Enabled at 0 range 2 .. 2;
Value at 0 range 0 .. 1;
end record;
type I2S_Clock_Selection is
(I2SSEL_PLL,
I2SSEL_CKIN)
with Size => 1;
type MC01_Clock_Selection is
(MC01SEL_HSI,
MC01SEL_LSE,
MC01SEL_HSE,
MC01SEL_PLL)
with Size => 2;
type MC02_Clock_Selection is
(MC02SEL_SYSCLK,
MC02SEL_PLLI2S,
MC02SEL_HSE,
MC02SEL_PLL)
with Size => 2;
type MC0x_Prescaler is
(MC0xPRE_DIV1,
MC0xPRE_DIV2,
MC0xPRE_DIV3,
MC0xPRE_DIV4,
MC0xPRE_DIV5)
with Size => 3;
for MC0x_Prescaler use
(MC0xPRE_DIV1 => 0,
MC0xPRE_DIV2 => 2#100#,
MC0xPRE_DIV3 => 2#101#,
MC0xPRE_DIV4 => 2#110#,
MC0xPRE_DIV5 => 2#111#);
-- Constants for RCC CR register
subtype PLLM_Range is Integer range 2 .. 63;
subtype PLLN_Range is Integer range 50 .. 432;
subtype PLLP_Range is Integer range 2 .. 8
with Static_Predicate => (PLLP_Range in 2 | 4 | 6 | 8);
subtype PLLQ_Range is Integer range 2 .. 15;
subtype HSECLK_Range is Integer range 1_000_000 .. 26_000_000;
subtype PLLIN_Range is Integer range 950_000 .. 2_000_000;
subtype PLLVC0_Range is Integer range 192_000_000 .. 432_000_000;
subtype PLLOUT_Range is Integer range 24_000_000 .. 216_000_000;
subtype SYSCLK_Range is Integer range 1 .. 216_000_000;
subtype HCLK_Range is Integer range 1 .. 216_000_000;
subtype PCLK1_Range is Integer range 1 .. 54_000_000;
subtype PCLK2_Range is Integer range 1 .. 108_000_000;
subtype SPII2S_Range is Integer range 1 .. 37_500_000;
pragma Unreferenced (SPII2S_Range);
-- These internal low and high speed clocks are fixed (do not modify)
HSICLK : constant := 16_000_000;
LSICLK : constant := 32_000;
MCU_ID : MCU_ID_Register with Volatile,
Address => System'To_Address (16#E004_2000#);
-- Only 32-bits access supported (read-only)
DEV_ID_STM32F40xxx : constant := 16#413#; -- STM32F40xxx/41xxx
DEV_ID_STM32F42xxx : constant := 16#419#; -- STM32F42xxx/43xxx
DEV_ID_STM32F46xxx : constant := 16#434#; -- STM32F469xx/479xx
DEV_ID_STM32F74xxx : constant := 16#449#; -- STM32F74xxx/75xxx
end System.STM32;
|
sungyeon/drake | Ada | 5,993 | ads | pragma License (Unrestricted);
-- generalized unit of Interfaces.C.Strings
with Interfaces.C.Pointers;
generic
type Character_Type is (<>);
type String_Type is array (Positive range <>) of Character_Type;
type Element is (<>);
type Element_Array is array (size_t range <>) of aliased Element;
with package Pointers is
new C.Pointers (
Index => size_t,
Element => Element,
Element_Array => Element_Array,
Default_Terminator => Element'Val (0));
with function To_C (
Item : String_Type;
Append_Nul : Boolean := True;
Substitute : Element_Array)
return Element_Array;
with function To_Ada (
Item : Element_Array;
Trim_Nul : Boolean := True;
Substitute : String_Type)
return String_Type;
package Interfaces.C.Generic_Strings is
pragma Preelaborate;
-- type char_array_access is access all char_array;
type char_array_access is access all Element_Array;
-- type chars_ptr is private;
-- pragma Preelaborable_Initialization (chars_ptr);
subtype chars_ptr is Pointers.Pointer;
function "=" (Left, Right : chars_ptr) return Boolean
renames Pointers."=";
type chars_ptr_array is array (size_t range <>) of aliased chars_ptr;
-- extended from here
subtype const_chars_ptr is Pointers.Constant_Pointer;
function "=" (Left, Right : const_chars_ptr) return Boolean
renames Pointers."=";
type const_chars_ptr_array is
array (size_t range <>) of aliased const_chars_ptr;
type const_chars_ptr_With_Length is record
ptr : const_chars_ptr;
Length : size_t;
end record;
type const_chars_ptr_With_Length_array is
array (size_t range <>) of aliased const_chars_ptr_With_Length;
-- to here
Null_Ptr : constant chars_ptr := null;
-- function To_Chars_Ptr (
-- Item : char_array_access;
-- Nul_Check : Boolean := False)
-- return chars_ptr;
function To_Chars_Ptr (
Item : access Element_Array; -- CXB3009 requires null
Nul_Check : Boolean := False)
return chars_ptr;
pragma Pure_Function (To_Chars_Ptr);
pragma Inline (To_Chars_Ptr);
-- extended
function To_Const_Chars_Ptr (Item : not null access constant Element_Array)
return not null const_chars_ptr;
pragma Pure_Function (To_Const_Chars_Ptr);
pragma Inline (To_Const_Chars_Ptr);
-- function New_Char_Array (Chars : char_array) return chars_ptr;
function New_Char_Array (Chars : Element_Array) return not null chars_ptr;
-- modified
-- function New_String (Str : String) return chars_ptr;
function New_String (
Str : String_Type;
Substitute : Element_Array :=
(0 => Element'Val (Character'Pos ('?')))) -- additional
return not null chars_ptr;
-- extended
function New_Chars_Ptr (Length : size_t) return not null chars_ptr;
function New_Chars_Ptr (
Item : not null access constant Element;
Length : size_t)
return not null chars_ptr;
function New_Chars_Ptr (Item : not null access constant Element)
return not null chars_ptr;
-- extended
function New_Strcat (Items : const_chars_ptr_array)
return not null chars_ptr;
function New_Strcat (Items : const_chars_ptr_With_Length_array)
return not null chars_ptr;
procedure Free (Item : in out chars_ptr);
Dereference_Error : exception
renames C.Dereference_Error;
-- function Value (Item : chars_ptr) return char_array;
function Value (
Item : access constant Element) -- CXB3010 requires null
return Element_Array;
-- modified
-- function Value (Item : chars_ptr; Length : size_t)
-- return char_array;
function Value (
Item : access constant Element; -- CXB3010 requires null
Length : size_t;
Append_Nul : Boolean := False) -- additional
return Element_Array;
-- Note: Value (no Append_Nul, default) produces an unterminated result
-- if there is no nul in the first Length elements of Item.
-- This behavior is danger similar to strncpy.
-- Insert the parameter Append_Nul => True.
-- modified
-- function Value (Item : chars_ptr) return String;
function Value (
Item : access constant Element; -- CXB3011 requires null
Substitute : String_Type :=
(1 => Character_Type'Val (Character'Pos ('?')))) -- additional
return String_Type;
-- modified
-- function Value (Item : chars_ptr; Length : size_t) return String;
function Value (
Item : access constant Element; -- CXB3011 requires null
Length : size_t;
Substitute : String_Type :=
(1 => Character_Type'Val (Character'Pos ('?')))) -- additional
return String_Type;
-- function Strlen (Item : chars_ptr) return size_t;
function Strlen (
Item : access constant Element) -- CXB3011 requires null
return size_t;
-- extended
-- This overloaded version Strlen gets the length of Item
-- less than or equal to Limit.
function Strlen (Item : not null access constant Element; Limit : size_t)
return size_t;
-- procedure Update (
-- Item : chars_ptr;
-- Offset : size_t;
-- Chars : char_array;
-- Check : Boolean := True);
procedure Update (
Item : access Element; -- CXB3012 requires null
Offset : size_t;
Chars : Element_Array;
Check : Boolean := True);
-- modified
-- procedure Update (
-- Item : chars_ptr;
-- Offset : size_t;
-- Str : String;
-- Check : Boolean := True);
procedure Update (
Item : access Element; -- CXB3012 requires null
Offset : size_t;
Str : String_Type;
Check : Boolean := True;
Substitute : Element_Array :=
(0 => Element'Val (Character'Pos ('?')))); -- additional
-- Note: Update (.., Str) is danger in drake,
-- because Str may be encoded and its length could be changed.
Update_Error : exception
renames C.Update_Error;
end Interfaces.C.Generic_Strings;
|
ytomino/zlib-ada | Ada | 2,096 | adb | with Ada.Command_Line;
with Ada.Streams;
with Ada.Streams.Stream_IO;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with zlib.Streams;
procedure test_streams is
Verbose : Boolean := False;
Text : constant String := "Hello, zlib!";
Temporary_File : Ada.Streams.Stream_IO.File_Type;
Extracted : String (1 .. 1024);
Extracted_Last : Natural;
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (I) = "-v" then
Verbose := True;
end if;
end loop;
Ada.Streams.Stream_IO.Create (Temporary_File); -- temporary file
declare
Deflator : zlib.Streams.Out_Type :=
zlib.Streams.Open (
Ada.Streams.Stream_IO.Stream (Temporary_File),
Header => zlib.GZip);
begin
String'Write (zlib.Streams.Stream (Deflator), Text);
zlib.Streams.Finish (Deflator);
end;
Ada.Streams.Stream_IO.Reset (Temporary_File, Ada.Streams.Stream_IO.In_File);
declare
Inflator : zlib.Streams.In_Type :=
zlib.Streams.Open (
Ada.Streams.Stream_IO.Stream (Temporary_File),
Header => zlib.GZip);
begin
Extracted_Last := Text'Length;
String'Read (zlib.Streams.Stream (Inflator), Extracted (1 .. Extracted_Last));
begin
String'Read (
zlib.Streams.Stream (Inflator),
Extracted (Extracted_Last + 1 .. Extracted'Last));
raise Program_Error; -- bad
exception
when zlib.Streams.End_Error => null;
end;
end;
declare
use Ada.Text_IO, Ada.Integer_Text_IO;
Compressed_Length : constant Natural :=
Integer (Ada.Streams.Stream_IO.Size (Temporary_File));
Extracted_Length : constant Natural := Extracted_Last - Extracted'First + 1;
begin
if Verbose then
Ada.Integer_Text_IO.Default_Width := 0;
Put ("source length = ");
Put (Text'Length);
New_Line;
Put ("compressed length = ");
Put (Compressed_Length);
New_Line;
Put ("extracted length = ");
Put (Extracted_Length);
New_Line;
end if;
pragma Assert (Extracted (Extracted'First .. Extracted_Last) = Text);
end;
Ada.Streams.Stream_IO.Close (Temporary_File);
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_streams;
|
reznikmm/matreshka | Ada | 7,040 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Index_Source_Styles_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Index_Source_Styles_Element_Node is
begin
return Self : Text_Index_Source_Styles_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Index_Source_Styles_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Index_Source_Styles
(ODF.DOM.Text_Index_Source_Styles_Elements.ODF_Text_Index_Source_Styles_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Index_Source_Styles_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Index_Source_Styles_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Index_Source_Styles_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Index_Source_Styles
(ODF.DOM.Text_Index_Source_Styles_Elements.ODF_Text_Index_Source_Styles_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Index_Source_Styles_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Index_Source_Styles
(Visitor,
ODF.DOM.Text_Index_Source_Styles_Elements.ODF_Text_Index_Source_Styles_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Index_Source_Styles_Element,
Text_Index_Source_Styles_Element_Node'Tag);
end Matreshka.ODF_Text.Index_Source_Styles_Elements;
|
reznikmm/matreshka | Ada | 4,655 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Master_Page_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Master_Page_Name_Attribute_Node is
begin
return Self : Draw_Master_Page_Name_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Master_Page_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Master_Page_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Master_Page_Name_Attribute,
Draw_Master_Page_Name_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Master_Page_Name_Attributes;
|
MinimSecure/unum-sdk | Ada | 902 | ads | -- Copyright 2011-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 System;
package Pck is
type Color is (Black, Red, Green, Blue, White);
type RGB_Color is new Color range Red .. Blue;
procedure Do_Nothing (A : System.Address);
end Pck;
|
reznikmm/matreshka | Ada | 6,901 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Last_Column_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Last_Column_Element_Node is
begin
return Self : Table_Last_Column_Element_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Table_Last_Column_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Table_Last_Column
(ODF.DOM.Table_Last_Column_Elements.ODF_Table_Last_Column_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Last_Column_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Last_Column_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Last_Column_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Table_Last_Column
(ODF.DOM.Table_Last_Column_Elements.ODF_Table_Last_Column_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Table_Last_Column_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Table_Last_Column
(Visitor,
ODF.DOM.Table_Last_Column_Elements.ODF_Table_Last_Column_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Last_Column_Element,
Table_Last_Column_Element_Node'Tag);
end Matreshka.ODF_Table.Last_Column_Elements;
|
stcarrez/dynamo | Ada | 3,978 | ads | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT INTERFACE COMPONENTS --
-- --
-- A S I S . E R R O R S --
-- --
-- S p e c --
-- --
-- $Revision: 14416 $
-- --
-- This specification is adapted from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) for use with GNAT. In accordance --
-- with the copyright of that document, you can freely copy and modify this --
-- specification, provided that if you redistribute a modified version, any --
-- changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 4 package Asis.Errors
------------------------------------------------------------------------------
------------------------------------------------------------------------------
package Asis.Errors is
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--
-- ASIS reports all operational errors by raising an exception. Whenever an
-- ASIS implementation raises one of the exceptions declared in package
-- Asis.Exceptions, it will previously have set the values returned by the
-- Status and Diagnosis queries to indicate the cause of the error. The
-- possible values for Status are indicated in the definition of Error_Kinds
-- below, with suggestions for the associated contents of the Diagnosis
-- string as a comment.
--
-- The Diagnosis and Status queries are provided in the Asis.Implementation
-- package to supply more information about the reasons for raising any
-- exception.
--
-- ASIS applications are encouraged to follow this same convention whenever
-- they explicitly raise any ASIS exception--always record a Status and
-- Diagnosis prior to raising the exception.
------------------------------------------------------------------------------
-- 4.1 type Error_Kinds
------------------------------------------------------------------------------
-- This enumeration type describes the various kinds of errors.
--
type Error_Kinds is (
Not_An_Error, -- No error is presently recorded
Value_Error, -- Routine argument value invalid
Initialization_Error, -- ASIS is uninitialized
Environment_Error, -- ASIS could not initialize
Parameter_Error, -- Bad Parameter given to Initialize
Capacity_Error, -- Implementation overloaded
Name_Error, -- Context/unit not found
Use_Error, -- Context/unit not use/open-able
Data_Error, -- Context/unit bad/invalid/corrupt
Text_Error, -- The program text cannot be located
Storage_Error, -- Storage_Error suppressed
Obsolete_Reference_Error, -- Argument or result is invalid due to
-- and inconsistent compilation unit
Unhandled_Exception_Error, -- Unexpected exception suppressed
Not_Implemented_Error, -- Functionality not implemented
Internal_Error); -- Implementation internal failure
end Asis.Errors;
|
reznikmm/matreshka | Ada | 4,757 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_01F2 is
pragma Preelaborate;
Group_01F2 : aliased constant Core_Second_Stage
:= (16#00# .. 16#02# => -- 01F200 .. 01F202
(Other_Symbol, Wide,
Other, Other, Other, Ideographic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#10# .. 16#3A# => -- 01F210 .. 01F23A
(Other_Symbol, Wide,
Other, Other, Other, Ideographic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#40# .. 16#48# => -- 01F240 .. 01F248
(Other_Symbol, Wide,
Other, Other, Other, Ideographic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#50# .. 16#51# => -- 01F250 .. 01F251
(Other_Symbol, Wide,
Other, Other, Other, Ideographic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_01F2;
|
DerickEddington/tarmi | Ada | 1,151 | adb | with Text_IO; use Text_IO;
with Tarmi; use Tarmi;
with Tarmi.Environments; use Tarmi.Environments;
with Tarmi.Evaluation; use Tarmi.Evaluation;
with Tarmi.Symbols; use Tarmi.Symbols;
with Tarmi.Combiners; use Tarmi.Combiners;
use type Tarmi.Datum;
procedure Test_Eval is
Env : Environment := Make_Environment ((Datum(Interned("foo")), Nil));
A : Datum := Eval (Nil, Env);
B : Datum := Eval (Datum(Interned("foo")), Env);
Op1 : Operative := new Operative_R'(Param_Tree_Formals => Ignore ,
Dyn_Env_Formal => Ignore ,
Static_Env => Env ,
Body_Form => Datum (Interned("foo")) ) ;
Expr1 : Pair := new Pair_R'(Datum (Op1), Nil) ;
C : Datum := Eval (Datum (Expr1), Env);
-- Op2 : Operative_R := (Param_Tree_Formals => Interned("foo") ,
-- Dyn_Env_Formal => Ignore ,
-- Static_Env => Env ,
-- Body_Form => ) ;
begin
Put_Line (Boolean'Image(A = Nil));
Put_Line (Boolean'Image(B = Nil));
Put_Line (Boolean'Image(C = Nil));
end Test_Eval;
|
kishan811/Hello-world | Ada | 178 | adb | with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
procedure Solution is
begin
Ada.Text_IO.Put_Line("Hello-world");
end Solution;
--thank in advance for hackerank XD |
noekleby/TTK4145 | Ada | 3,546 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
procedure backwarderrorrecovery is
Count_Failed : exception; -- Exception to be raised when counting fails
Gen : Generator; -- Random number generator
protected type Transaction_Manager (N : Positive) is
entry Finished;
function Commit return Boolean;
procedure Signal_Abort;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
Should_Commit : Boolean := True;
end Transaction_Manager;
protected body Transaction_Manager is
entry Finished when Finished_Gate_Open or Finished'Count = N is
begin
------------------------------------------
if Finished'count = N-1 then -- (N = 3)
Should_Commit := not Aborted;
Finished_Gate_Open := True;
end if;
if Finished'count = 0 then
Finished_Gate_Open := False;
Aborted := False;
end if;
------------------------------------------
end Finished;
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
function Commit return Boolean is
begin
return Should_Commit;
end Commit;
end Transaction_Manager;
function Unreliable_Slow_Add (x : Integer) return Integer is
Error_Rate : Constant := 0.15; -- (between 0 and 1)
num : float;
begin
-------------------------------------------
num := Random(Gen);
if Error_Rate >= num then
delay Duration(1.0*num);
put_line("Task failed");
raise Count_Failed;
else
delay Duration(0.4*num);
return x+10;
end if;
-------------------------------------------
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
begin
---------------------------------------
Num := Unreliable_Slow_Add(Num);
exception
when Count_Failed =>
Manager.Signal_Abort;
end;
Manager.Finished;
---------------------------------------
if Manager.Commit = True then
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
else
Put_Line (" Worker" & Integer'Image(Initial) &
" reverting from" & Integer'Image(Num) &
" to" & Integer'Image(Prev));
-------------------------------------------
Num := Prev;
-------------------------------------------
end if;
Prev := Num;
delay 0.5;
end loop;
end Transaction_Worker;
Manager : aliased Transaction_Manager (3);
Worker_1 : Transaction_Worker (0, Manager'Access);
Worker_2 : Transaction_Worker (1, Manager'Access);
Worker_3 : Transaction_Worker (2, Manager'Access);
begin
Reset(Gen); -- Seed the random number generator
end backwarderrorrecovery;
|
ficorax/PortAudioAda | Ada | 2,054 | ads | with Ada.Numerics;
with Gtk.Widget; use Gtk.Widget;
with PortAudioAda; use PortAudioAda;
package GA_Sine_Globals is
Frames_Per_Buffer : Long_Float := 64.0;
Sample_Rate : Long_Float := 44_100.0;
stream : aliased PA_Stream_Ptr;
Two_Pi : Long_Float := Ada.Numerics.Pi * 2.0;
type Float_Array is array (Integer range <>) of aliased Float;
pragma Convention (C, Float_Array);
type User_Data is record
amplitude : aliased Long_Float := 0.5;
frequency : aliased Long_Float := 440.0;
phase : aliased Long_Float := 0.0;
end record;
pragma Convention (C, User_Data);
type User_Data_Ptr is access all User_Data;
pragma Convention (C, User_Data_Ptr);
pragma No_Strict_Aliasing (User_Data_Ptr);
gUserData : aliased User_Data;
type Option_Use is
(OU_Before,
OU_After,
OU_NoMatter);
type One_Option is record
optionWidget : access Gtk_Widget_Record'Class;
optionUse : Option_Use;
end record;
type Enum_Options is
(EO_frames_Per_Buffer,
EO_Sample_Rate,
EO_Amplitude,
EO_Frequency);
options : array (Enum_Options) of One_Option;
type Samples is record
numRate : Long_Float;
txtRate : String (1 .. 6);
end record;
sample_Rates : array (Natural range <>) of Samples :=
((8000.0, " 8000"),
(9600.0, " 9600"),
(1025.0, " 11025"),
(12000.0, " 12000"),
(16000.0, " 16000"),
(22050.0, " 22050"),
(24000.0, " 24000"),
(32000.0, " 32000"),
(44100.0, " 44100"),
(48000.0, " 48000"),
(88200.0, " 88200"),
(96000.0, " 96000"),
(192000.0, "192000"));
-----------------------------------------------------------------------------
procedure Toggle_Options (started : Boolean);
end GA_Sine_Globals;
|
tum-ei-rcs/StratoX | Ada | 30 | ads | ../../../lib/units-vectors.ads |
reznikmm/matreshka | Ada | 6,860 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Text_Input_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Text_Input_Element_Node is
begin
return Self : Text_Text_Input_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Text_Input_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Text_Input
(ODF.DOM.Text_Text_Input_Elements.ODF_Text_Text_Input_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Text_Input_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Text_Input_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Text_Input_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Text_Input
(ODF.DOM.Text_Text_Input_Elements.ODF_Text_Text_Input_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Text_Input_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Text_Input
(Visitor,
ODF.DOM.Text_Text_Input_Elements.ODF_Text_Text_Input_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Text_Input_Element,
Text_Text_Input_Element_Node'Tag);
end Matreshka.ODF_Text.Text_Input_Elements;
|
zhmu/ananas | Ada | 6,448 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . D I R E C T O R I E S . V A L I D I T Y --
-- --
-- B o d y --
-- (Windows Version) --
-- --
-- Copyright (C) 2004-2022, 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 is the Windows version of this package
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
package body Ada.Directories.Validity is
Invalid_Character : constant array (Character) of Boolean :=
(NUL .. US | '\' => True,
'/' | ':' | '*' | '?' => True,
'"' | '<' | '>' | '|' => True,
DEL => True,
others => False);
-- Note that a valid file-name or path-name is implementation defined.
-- To support UTF-8 file and directory names, we do not want to be too
-- restrictive here.
---------------------------------
-- Is_Path_Name_Case_Sensitive --
---------------------------------
function Is_Path_Name_Case_Sensitive return Boolean is
begin
return False;
end Is_Path_Name_Case_Sensitive;
------------------------
-- Is_Valid_Path_Name --
------------------------
function Is_Valid_Path_Name (Name : String) return Boolean is
Start : Positive := Name'First;
Last : Natural;
begin
-- A path name cannot be empty, cannot contain more than 256 characters,
-- cannot contain invalid characters and each directory/file name need
-- to be valid.
if Name'Length = 0 or else Name'Length > 256 then
return False;
else
-- A drive letter may be specified at the beginning
if Name'Length >= 2
and then Name (Start + 1) = ':'
and then
(Name (Start) in 'A' .. 'Z' or else Name (Start) in 'a' .. 'z')
then
Start := Start + 2;
-- A drive letter followed by a colon and followed by nothing or
-- by a relative path is an ambiguous path name on Windows, so we
-- don't accept it.
if Start > Name'Last
or else (Name (Start) /= '/' and then Name (Start) /= '\')
then
return False;
end if;
end if;
loop
-- Look for the start of the next directory or file name
while Start <= Name'Last
and then (Name (Start) = '\' or Name (Start) = '/')
loop
Start := Start + 1;
end loop;
-- If all directories/file names are OK, return True
exit when Start > Name'Last;
Last := Start;
-- Look for the end of the directory/file name
while Last < Name'Last loop
exit when Name (Last + 1) = '\' or Name (Last + 1) = '/';
Last := Last + 1;
end loop;
-- Check if the directory/file name is valid
if not Is_Valid_Simple_Name (Name (Start .. Last)) then
return False;
end if;
-- Move to the next name
Start := Last + 1;
end loop;
end if;
-- If Name follows the rules, it is valid
return True;
end Is_Valid_Path_Name;
--------------------------
-- Is_Valid_Simple_Name --
--------------------------
function Is_Valid_Simple_Name (Name : String) return Boolean is
Only_Spaces : Boolean;
begin
-- A file name cannot be empty, cannot contain more than 256 characters,
-- and cannot contain invalid characters.
if Name'Length = 0 or else Name'Length > 256 then
return False;
-- Name length is OK
else
Only_Spaces := True;
for J in Name'Range loop
if Invalid_Character (Name (J)) then
return False;
elsif Name (J) /= ' ' then
Only_Spaces := False;
end if;
end loop;
-- If no invalid chars, and not all spaces, file name is valid
return not Only_Spaces;
end if;
end Is_Valid_Simple_Name;
-------------
-- Windows --
-------------
function Windows return Boolean is
begin
return True;
end Windows;
end Ada.Directories.Validity;
|
faelys/natools | Ada | 8,129 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2016, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Smaz_Tools provides dictionary-independant tools to deal with --
-- word lists and prepare dictionary creation. --
-- Note that the dictionary is intended to be generated and hard-coded, --
-- so the final client shouldn't need this package. --
------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Doubly_Linked_Lists;
with Natools.S_Expressions;
private with Ada.Containers.Indefinite_Ordered_Maps;
private with Ada.Containers.Indefinite_Ordered_Sets;
private with Ada.Finalization;
package Natools.Smaz_Tools is
pragma Preelaborate;
package String_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists
(String);
procedure Read_List
(List : out String_Lists.List;
Descriptor : in out S_Expressions.Descriptor'Class);
-- Read atoms from Descriptor to fill List
List_For_Linear_Search : String_Lists.List;
function Linear_Search (Value : String) return Natural;
-- Function and data source for inefficient but dynamic function
-- that can be used with Dictionary.Hash.
procedure Set_Dictionary_For_Map_Search (List : in String_Lists.List);
function Map_Search (Value : String) return Natural;
-- Function and data source for logarithmic search using standard
-- ordered map, that can be used with Dictionary.Hash.
type Search_Trie is private;
procedure Initialize (Trie : out Search_Trie; List : in String_Lists.List);
function Search (Trie : in Search_Trie; Value : in String) return Natural;
-- Trie-based search in a dynamic dictionary, for lookup whose
-- speed-vs-memory is even more skewed towards speed.
procedure Set_Dictionary_For_Trie_Search (List : in String_Lists.List);
function Trie_Search (Value : String) return Natural;
-- Function and data source for trie-based search that can be
-- used with Dictionary.Hash.
function Dummy_Hash (Value : String) return Natural;
-- Placeholder for Hash dictionary member, always raises Program_Error
type String_Count is range 0 .. 2 ** 31 - 1;
-- Type for a number of substring occurrences
package Methods is
type Enum is (Encoded, Frequency, Gain);
end Methods;
-- Evaluation methods to select words to remove or include
type Word_Counter is private;
-- Accumulate frequency/occurrence counts for a set of strings
procedure Add_Word
(Counter : in out Word_Counter;
Word : in String;
Count : in String_Count := 1);
-- Include Count number of occurrences of Word in Counter
procedure Add_Substrings
(Counter : in out Word_Counter;
Phrase : in String;
Min_Size : in Positive;
Max_Size : in Positive);
-- Include all the substrings of Phrase whose lengths are
-- between Min_Size and Max_Size.
procedure Add_Words
(Counter : in out Word_Counter;
Phrase : in String;
Min_Size : in Positive;
Max_Size : in Positive);
-- Add the "words" from Phrase into Counter, with a word being currently
-- defined as anything between ASCII blanks or punctuation,
-- or in other words [0-9A-Za-z\x80-\xFF]+
procedure Filter_By_Count
(Counter : in out Word_Counter;
Threshold_Count : in String_Count);
-- Remove from Counter all entries whose count is below the threshold
function Simple_Dictionary
(Counter : in Word_Counter;
Word_Count : in Natural;
Method : in Methods.Enum := Methods.Encoded)
return String_Lists.List;
-- Return the Word_Count words in Counter that have the highest score,
-- the score being count * length.
procedure Simple_Dictionary_And_Pending
(Counter : in Word_Counter;
Word_Count : in Natural;
Selected : out String_Lists.List;
Pending : out String_Lists.List;
Method : in Methods.Enum := Methods.Encoded;
Max_Pending_Count : in Ada.Containers.Count_Type
:= Ada.Containers.Count_Type'Last);
-- Return in Selected the Word_Count words in Counter that have the
-- highest score, and in Pending the remaining words,
-- the score being count * length.
type Score_Value is range 0 .. 2 ** 31 - 1;
function Score_Encoded
(Count : in String_Count; Length : in Positive) return Score_Value
is (Score_Value (Count) * Score_Value (Length));
-- Score value using the amount of encoded data by the element
function Score_Frequency
(Count : in String_Count; Length : in Positive) return Score_Value
is (Score_Value (Count));
-- Score value using the number of times the element was used
function Score_Gain
(Count : in String_Count; Length : in Positive) return Score_Value
is (Score_Value (Count) * (Score_Value (Length) - 1));
-- Score value using the number of bytes saved using the element
function Score
(Count : in String_Count;
Length : in Positive;
Method : in Methods.Enum)
return Score_Value
is (case Method is
when Methods.Encoded => Score_Encoded (Count, Length),
when Methods.Frequency => Score_Frequency (Count, Length),
when Methods.Gain => Score_Gain (Count, Length));
-- Scare value with dynamically chosen method
private
package Word_Maps is new Ada.Containers.Indefinite_Ordered_Maps
(String, String_Count);
type Word_Counter is record
Map : Word_Maps.Map;
end record;
type Scored_Word (Size : Natural) is record
Word : String (1 .. Size);
Score : Score_Value;
end record;
function "<" (Left, Right : Scored_Word) return Boolean
is (Left.Score > Right.Score
or else (Left.Score = Right.Score and then Left.Word < Right.Word));
function To_Scored_Word
(Cursor : in Word_Maps.Cursor;
Method : in Methods.Enum)
return Scored_Word;
package Scored_Word_Sets is new Ada.Containers.Indefinite_Ordered_Sets
(Scored_Word);
package Dictionary_Maps is new Ada.Containers.Indefinite_Ordered_Maps
(String, Natural);
Search_Map : Dictionary_Maps.Map;
type Trie_Node;
type Trie_Node_Access is access Trie_Node;
type Trie_Node_Array is array (Character) of Trie_Node_Access;
type Trie_Node (Is_Leaf : Boolean) is new Ada.Finalization.Controlled
with record
Index : Natural;
case Is_Leaf is
when True => null;
when False => Children : Trie_Node_Array;
end case;
end record;
overriding procedure Adjust (Node : in out Trie_Node);
overriding procedure Finalize (Node : in out Trie_Node);
type Search_Trie is record
Not_Found : Natural;
Root : Trie_Node (False);
end record;
Trie_For_Search : Search_Trie;
end Natools.Smaz_Tools;
|
zrmyers/VulkanAda | Ada | 2,956 | adb | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
--
-- This package instantiates Ada generic numerical operations for use by the
-- Vulkan Math Library.
--------------------------------------------------------------------------------
package body Vulkan.Math.Numerics is
----------------------------------------------------------------------------
function Compute_Modf (x : in Floating_Point;
i : out Floating_Point) return Floating_Point is
begin
i := Floating_Point'Truncation(x);
return x - i;
end Compute_Modf;
function Smooth_Step
(edge0, edge1, x : in Floating_Point) return Floating_Point
is
t : constant Floating_Point := Clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
begin
return (t * t * (3.0 - 2.0 * t));
end Smooth_Step;
function Is_Inf (x : in Floating_Point) return Vkm_Bool is
pragma Unreferenced(x);
begin
return False;
end Is_Inf;
function Is_Nan (x : in Floating_Point) return Vkm_Bool is
pragma Unreferenced(x);
begin
return False;
end Is_Nan;
function Frexp (x : in Floating_Point;
exponent : out Vkm_Int) return Floating_Point is
begin
exponent := Floating_Point'Exponent(x);
return Floating_Point'Fraction(x);
end Frexp;
function Ldexp (significand : in Floating_Point;
exponent : in Vkm_Int) return Floating_Point is
begin
return Floating_Point'Compose(significand, exponent);
end Ldexp;
end Vulkan.Math.Numerics;
|
gerr135/gnat_bugs | Ada | 168 | adb | package body Lists is
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= No_Element;
end Has_Element;
end Lists;
|
optikos/oasis | Ada | 4,726 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Assignment_Statements is
function Create
(Variable_Name : not null Program.Elements.Expressions
.Expression_Access;
Assignment_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Expression : not null Program.Elements.Expressions
.Expression_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Assignment_Statement is
begin
return Result : Assignment_Statement :=
(Variable_Name => Variable_Name, Assignment_Token => Assignment_Token,
Expression => Expression, Semicolon_Token => Semicolon_Token,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Variable_Name : not null Program.Elements.Expressions
.Expression_Access;
Expression : not null Program.Elements.Expressions
.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Assignment_Statement is
begin
return Result : Implicit_Assignment_Statement :=
(Variable_Name => Variable_Name, Expression => Expression,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Variable_Name
(Self : Base_Assignment_Statement)
return not null Program.Elements.Expressions.Expression_Access is
begin
return Self.Variable_Name;
end Variable_Name;
overriding function Expression
(Self : Base_Assignment_Statement)
return not null Program.Elements.Expressions.Expression_Access is
begin
return Self.Expression;
end Expression;
overriding function Assignment_Token
(Self : Assignment_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Assignment_Token;
end Assignment_Token;
overriding function Semicolon_Token
(Self : Assignment_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Assignment_Statement)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Assignment_Statement)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Assignment_Statement)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize
(Self : aliased in out Base_Assignment_Statement'Class) is
begin
Set_Enclosing_Element (Self.Variable_Name, Self'Unchecked_Access);
Set_Enclosing_Element (Self.Expression, Self'Unchecked_Access);
null;
end Initialize;
overriding function Is_Assignment_Statement_Element
(Self : Base_Assignment_Statement)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Assignment_Statement_Element;
overriding function Is_Statement_Element
(Self : Base_Assignment_Statement)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Statement_Element;
overriding procedure Visit
(Self : not null access Base_Assignment_Statement;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Assignment_Statement (Self);
end Visit;
overriding function To_Assignment_Statement_Text
(Self : aliased in out Assignment_Statement)
return Program.Elements.Assignment_Statements
.Assignment_Statement_Text_Access is
begin
return Self'Unchecked_Access;
end To_Assignment_Statement_Text;
overriding function To_Assignment_Statement_Text
(Self : aliased in out Implicit_Assignment_Statement)
return Program.Elements.Assignment_Statements
.Assignment_Statement_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Assignment_Statement_Text;
end Program.Nodes.Assignment_Statements;
|
97kovacspeter/ADA | Ada | 1,058 | ads | with Card_Dir;
use Card_Dir;
with Coords;
use Coords;
generic
type Id is (<>);
with function "<"(I,J: in Id) return Boolean is <>;
package Aircraft is
type Aircraft_Type (Temp:Id) is private;
function GetName (A: Aircraft_Type) return Id;
procedure Ascend(A: in out Aircraft_Type);
procedure Land(A: in out Aircraft_Type);
function Get_Is_In_The_Air(A:Aircraft_Type) return Boolean;
function Get_Coord(A:Aircraft_Type) return Coord;
procedure Set_Card_Dir_Coord(A: in out Aircraft_Type;C:Cardinal_Direction);
procedure Start(A: in out Aircraft_Type);
function Compare(A1:Aircraft_Type;A2:Aircraft_Type) return Boolean;
function Get_Distance(A1:Aircraft_Type;A2:Aircraft_Type) return Integer;
generic
with procedure ActionHelp(I: out Id; C: out Coord; B: out Boolean);
procedure Action(A: in out Aircraft_Type);
private
procedure Set_Coord(A: in out Aircraft_Type; C: Coord);
type Aircraft_Type (Temp:Id) is Record
Name: Id := Temp;
Position: Coord;
Is_In_The_Air: Boolean := false;
end record;
end Aircraft; |
reznikmm/matreshka | Ada | 3,618 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- 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.DI.Diagram_Elements.Hash is
new AMF.Elements.Generic_Hash (DI_Diagram_Element, DI_Diagram_Element_Access);
|
reznikmm/matreshka | Ada | 4,615 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Start_Shape_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Start_Shape_Attribute_Node is
begin
return Self : Draw_Start_Shape_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Start_Shape_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Start_Shape_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Start_Shape_Attribute,
Draw_Start_Shape_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Start_Shape_Attributes;
|
jrcarter/Ada_GUI | Ada | 1,663 | adb | -- Ada_GUI version of Random_Int
--
-- Copyright (C) 2021 by PragmAda Software Engineering
--
-- Released under the terms of the 3-Clause BSD License. See https://opensource.org/licenses/BSD-3-Clause
--
-- The main-program procedure
with Ada.Numerics.Discrete_Random;
with Random_Int.UI;
procedure Random_Int.Program is
procedure Generate_One is
Low : Integer;
High : Integer;
Value : Integer;
begin -- Generate_One
Min_Error : begin
Low := Integer'Value (UI.Min_Text);
exception -- Min_Error
when others =>
UI.Min_Error;
return;
end Min_Error;
Max_Error : begin
High := Integer'Value (UI.Max_Text);
exception -- Max_Error
when others =>
UI.Max_Error;
return;
end Max_Error;
if High < Low then
Value := High;
High := Low;
Low := Value;
end if;
UI.Set_Min (Value => Low);
UI.Set_Max (Value => High);
Get_Value : declare
subtype Desired is Integer range Low .. High;
package Random is new Ada.Numerics.Discrete_Random (Result_Subtype => Desired);
Gen : Random.Generator;
begin -- Get_Value
Random.Reset (Gen => Gen);
Value := Random.Random (Gen);
UI.Show_Result (Value => Value);
end Get_Value;
end Generate_One;
Event : UI.Event_ID;
begin -- Random_Int.Program
All_Events : loop
Event := UI.Next_Event;
case Event is
when UI.Generate =>
Generate_One;
when UI.Quit =>
exit All_Events;
end case;
end loop All_Events;
end Random_Int.Program;
|
onox/orka | Ada | 5,689 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Streams;
with Ada.Unchecked_Conversion;
with Wayland.Enums.Client;
with AWT.OS;
with AWT.Registry;
package body AWT.Drag_And_Drop is
protected body Signal is
procedure Set is
begin
Signaled := True;
end Set;
entry Wait when Signaled is
begin
Signaled := False;
end Wait;
end Signal;
----------------------------------------------------------------------------
package WE renames Wayland.Enums;
Global : AWT.Registry.Compositor renames AWT.Registry.Global;
task Drag_And_Drop is
entry Receive (FD : Wayland.File_Descriptor; CB : not null Receive_Callback);
end Drag_And_Drop;
task body Drag_And_Drop is
Process_FD : Wayland.File_Descriptor;
Process_CB : Receive_Callback;
begin
loop
select
accept Receive (FD : Wayland.File_Descriptor; CB : not null Receive_Callback) do
Process_FD := FD;
Process_CB := CB;
end Receive;
declare
File : AWT.OS.File (Process_FD);
Received_Content : SU.Unbounded_String;
begin
loop
begin
declare
Result : constant Ada.Streams.Stream_Element_Array := File.Read;
subtype Byte_Array is Ada.Streams.Stream_Element_Array (Result'Range);
subtype Bytes_String is String (1 .. Result'Length);
function Convert is new Ada.Unchecked_Conversion
(Source => Byte_Array, Target => Bytes_String);
begin
exit when Result'Length = 0;
SU.Append (Received_Content, Convert (Result));
end;
exception
when Constraint_Error =>
File.Close;
raise;
end;
end loop;
File.Close;
Process_CB (Received_Content);
end;
or
terminate;
end select;
end loop;
end Drag_And_Drop;
function Supported_Actions return AWT.Inputs.Actions is
(Global.Seat.Supported_Drag_Drop_Actions);
function Valid_Action return AWT.Inputs.Action_Kind is
(Global.Seat.Valid_Drag_Drop_Action);
procedure Set_Action (Action : AWT.Inputs.Action_Kind) is
Preferred_Action : WE.Client.Data_Device_Manager_Dnd_Action := (others => False);
begin
case Action is
when Copy =>
Preferred_Action.Copy := True;
when Move =>
Preferred_Action.Move := True;
when Ask =>
Preferred_Action.Ask := True;
when None =>
null;
end case;
Global.Seat.Data_Offer.Set_Actions (Preferred_Action, Preferred_Action);
end Set_Action;
procedure Finish (Action : AWT.Inputs.Action_Kind) is
begin
if Action /= None then
if Valid_Action = Ask then
Set_Action (Action);
else
case Action is
when Copy =>
pragma Assert (Valid_Action = Copy);
when Move =>
pragma Assert (Valid_Action = Move);
when Ask | None =>
raise Program_Error;
end case;
end if;
Global.Seat.Data_Offer.Finish;
end if;
Global.Seat.Data_Offer.Destroy;
end Finish;
procedure Get (Callback : not null Receive_Callback) is
File_Descriptors : AWT.OS.Pipe;
begin
if not Global.Seat.Drag_Drop_Mime_Type_Valid or not Global.Seat.Data_Offer.Has_Proxy then
raise Program_Error;
end if;
AWT.OS.Create_Pipe (File_Descriptors);
Global.Seat.Data_Offer.Receive (AWT.Registry.URIs_Mime_Type, File_Descriptors.Write);
declare
File : AWT.OS.File (File_Descriptors.Write);
begin
File.Close;
end;
Global.Display.Roundtrip;
Drag_And_Drop.Receive (File_Descriptors.Read, Callback);
end Get;
protected type Receive_Future is
procedure Set (Value : SU.Unbounded_String);
entry Get (Value : out SU.Unbounded_String);
private
Content : SU.Unbounded_String;
Done : Boolean := False;
end Receive_Future;
protected body Receive_Future is
procedure Set (Value : SU.Unbounded_String) is
begin
Content := Value;
Done := True;
end Set;
entry Get (Value : out SU.Unbounded_String) when Done is
begin
Value := Content;
Done := False;
Content := SU.Null_Unbounded_String;
end Get;
end Receive_Future;
Future : Receive_Future;
function Get return String is
begin
Get (Future.Set'Access);
declare
Value : SU.Unbounded_String;
begin
Future.Get (Value);
return +Value;
end;
end Get;
end AWT.Drag_And_Drop;
|
JeremyGrosser/clock3 | Ada | 12,410 | ads | pragma Style_Checks (Off);
-- Copyright (c) 2018 Microchip Technology Inc.
--
-- SPDX-License-Identifier: Apache-2.0
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- This spec has been automatically generated from ATSAMD21G18A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAMD21_SVD.NVMCTRL is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Command
type CTRLA_CMDSelect is
(-- Reset value for the field
CTRLA_CMDSelect_Reset,
-- Erase Row - Erases the row addressed by the ADDR register.
ER,
-- Write Page - Writes the contents of the page buffer to the page addressed
-- by the ADDR register.
WP,
-- Erase Auxiliary Row - Erases the auxiliary row addressed by the ADDR
-- register. This command can be given only when the security bit is not set
-- and only to the user configuration row.
EAR,
-- Write Auxiliary Page - Writes the contents of the page buffer to the page
-- addressed by the ADDR register. This command can be given only when the
-- security bit is not set and only to the user configuration row.
WAP,
-- Security Flow Command
SF,
-- Write lockbits
WL,
-- Lock Region - Locks the region containing the address location in the ADDR
-- register.
LR,
-- Unlock Region - Unlocks the region containing the address location in the
-- ADDR register.
UR,
-- Sets the power reduction mode.
SPRM,
-- Clears the power reduction mode.
CPRM,
-- Page Buffer Clear - Clears the page buffer.
PBC,
-- Set Security Bit - Sets the security bit by writing 0x00 to the first byte
-- in the lockbit row.
SSB,
-- Invalidates all cache lines.
INVALL)
with Size => 7;
for CTRLA_CMDSelect use
(CTRLA_CMDSelect_Reset => 0,
ER => 2,
WP => 4,
EAR => 5,
WAP => 6,
SF => 10,
WL => 15,
LR => 64,
UR => 65,
SPRM => 66,
CPRM => 67,
PBC => 68,
SSB => 69,
INVALL => 70);
-- Command Execution
type CTRLA_CMDEXSelect is
(-- Reset value for the field
CTRLA_CMDEXSelect_Reset,
-- Execution Key
KEY)
with Size => 8;
for CTRLA_CMDEXSelect use
(CTRLA_CMDEXSelect_Reset => 0,
KEY => 165);
-- Control A
type NVMCTRL_CTRLA_Register is record
-- Command
CMD : CTRLA_CMDSelect := CTRLA_CMDSelect_Reset;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Command Execution
CMDEX : CTRLA_CMDEXSelect := CTRLA_CMDEXSelect_Reset;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for NVMCTRL_CTRLA_Register use record
CMD at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CMDEX at 0 range 8 .. 15;
end record;
-- NVM Read Wait States
type CTRLB_RWSSelect is
(-- Single Auto Wait State
SINGLE,
-- Half Auto Wait State
HALF,
-- Dual Auto Wait State
DUAL)
with Size => 4;
for CTRLB_RWSSelect use
(SINGLE => 0,
HALF => 1,
DUAL => 2);
-- Power Reduction Mode during Sleep
type CTRLB_SLEEPPRMSelect is
(-- NVM block enters low-power mode when entering sleep.NVM block exits
-- low-power mode upon first access.
WAKEONACCESS,
-- NVM block enters low-power mode when entering sleep.NVM block exits
-- low-power mode when exiting sleep.
WAKEUPINSTANT,
-- Auto power reduction disabled.
DISABLED)
with Size => 2;
for CTRLB_SLEEPPRMSelect use
(WAKEONACCESS => 0,
WAKEUPINSTANT => 1,
DISABLED => 3);
-- NVMCTRL Read Mode
type CTRLB_READMODESelect is
(-- The NVM Controller (cache system) does not insert wait states on a cache
-- miss. Gives the best system performance.
NO_MISS_PENALTY,
-- Reduces power consumption of the cache system, but inserts a wait state
-- each time there is a cache miss. This mode may not be relevant if CPU
-- performance is required, as the application will be stalled and may lead to
-- increase run time.
LOW_POWER,
-- The cache system ensures that a cache hit or miss takes the same amount of
-- time, determined by the number of programmed flash wait states. This mode
-- can be used for real-time applications that require deterministic execution
-- timings.
DETERMINISTIC)
with Size => 2;
for CTRLB_READMODESelect use
(NO_MISS_PENALTY => 0,
LOW_POWER => 1,
DETERMINISTIC => 2);
-- Control B
type NVMCTRL_CTRLB_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- NVM Read Wait States
RWS : CTRLB_RWSSelect := SAMD21_SVD.NVMCTRL.SINGLE;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- Manual Write
MANW : Boolean := False;
-- Power Reduction Mode during Sleep
SLEEPPRM : CTRLB_SLEEPPRMSelect :=
SAMD21_SVD.NVMCTRL.WAKEONACCESS;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- NVMCTRL Read Mode
READMODE : CTRLB_READMODESelect :=
SAMD21_SVD.NVMCTRL.NO_MISS_PENALTY;
-- Cache Disable
CACHEDIS : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NVMCTRL_CTRLB_Register use record
Reserved_0_0 at 0 range 0 .. 0;
RWS at 0 range 1 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
MANW at 0 range 7 .. 7;
SLEEPPRM at 0 range 8 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
READMODE at 0 range 16 .. 17;
CACHEDIS at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype NVMCTRL_PARAM_NVMP_Field is HAL.UInt16;
-- Page Size
type PARAM_PSZSelect is
(-- 8 bytes
Val_8,
-- 16 bytes
Val_16,
-- 32 bytes
Val_32,
-- 64 bytes
Val_64,
-- 128 bytes
Val_128,
-- 256 bytes
Val_256,
-- 512 bytes
Val_512,
-- 1024 bytes
Val_1024)
with Size => 3;
for PARAM_PSZSelect use
(Val_8 => 0,
Val_16 => 1,
Val_32 => 2,
Val_64 => 3,
Val_128 => 4,
Val_256 => 5,
Val_512 => 6,
Val_1024 => 7);
-- NVM Parameter
type NVMCTRL_PARAM_Register is record
-- Read-only. NVM Pages
NVMP : NVMCTRL_PARAM_NVMP_Field;
-- Read-only. Page Size
PSZ : PARAM_PSZSelect;
-- unspecified
Reserved_19_31 : HAL.UInt13;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NVMCTRL_PARAM_Register use record
NVMP at 0 range 0 .. 15;
PSZ at 0 range 16 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- Interrupt Enable Clear
type NVMCTRL_INTENCLR_Register is record
-- NVM Ready Interrupt Enable
READY : Boolean := False;
-- Error Interrupt Enable
ERROR : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for NVMCTRL_INTENCLR_Register use record
READY at 0 range 0 .. 0;
ERROR at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- Interrupt Enable Set
type NVMCTRL_INTENSET_Register is record
-- NVM Ready Interrupt Enable
READY : Boolean := False;
-- Error Interrupt Enable
ERROR : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for NVMCTRL_INTENSET_Register use record
READY at 0 range 0 .. 0;
ERROR at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- Interrupt Flag Status and Clear
type NVMCTRL_INTFLAG_Register is record
-- Read-only. NVM Ready
READY : Boolean := False;
-- Error
ERROR : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for NVMCTRL_INTFLAG_Register use record
READY at 0 range 0 .. 0;
ERROR at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- Status
type NVMCTRL_STATUS_Register is record
-- Read-only. Power Reduction Mode
PRM : Boolean := False;
-- NVM Page Buffer Active Loading
LOAD : Boolean := False;
-- Programming Error Status
PROGE : Boolean := False;
-- Lock Error Status
LOCKE : Boolean := False;
-- NVM Error
NVME : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Read-only. Security Bit Status
SB : Boolean := False;
-- unspecified
Reserved_9_15 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for NVMCTRL_STATUS_Register use record
PRM at 0 range 0 .. 0;
LOAD at 0 range 1 .. 1;
PROGE at 0 range 2 .. 2;
LOCKE at 0 range 3 .. 3;
NVME at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
SB at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
end record;
subtype NVMCTRL_ADDR_ADDR_Field is HAL.UInt22;
-- Address
type NVMCTRL_ADDR_Register is record
-- NVM Address
ADDR : NVMCTRL_ADDR_ADDR_Field := 16#0#;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NVMCTRL_ADDR_Register use record
ADDR at 0 range 0 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Non-Volatile Memory Controller
type NVMCTRL_Peripheral is record
-- Control A
CTRLA : aliased NVMCTRL_CTRLA_Register;
-- Control B
CTRLB : aliased NVMCTRL_CTRLB_Register;
-- NVM Parameter
PARAM : aliased NVMCTRL_PARAM_Register;
-- Interrupt Enable Clear
INTENCLR : aliased NVMCTRL_INTENCLR_Register;
-- Interrupt Enable Set
INTENSET : aliased NVMCTRL_INTENSET_Register;
-- Interrupt Flag Status and Clear
INTFLAG : aliased NVMCTRL_INTFLAG_Register;
-- Status
STATUS : aliased NVMCTRL_STATUS_Register;
-- Address
ADDR : aliased NVMCTRL_ADDR_Register;
-- Lock Section
LOCK : aliased HAL.UInt16;
end record
with Volatile;
for NVMCTRL_Peripheral use record
CTRLA at 16#0# range 0 .. 15;
CTRLB at 16#4# range 0 .. 31;
PARAM at 16#8# range 0 .. 31;
INTENCLR at 16#C# range 0 .. 7;
INTENSET at 16#10# range 0 .. 7;
INTFLAG at 16#14# range 0 .. 7;
STATUS at 16#18# range 0 .. 15;
ADDR at 16#1C# range 0 .. 31;
LOCK at 16#20# range 0 .. 15;
end record;
-- Non-Volatile Memory Controller
NVMCTRL_Periph : aliased NVMCTRL_Peripheral
with Import, Address => NVMCTRL_Base;
end SAMD21_SVD.NVMCTRL;
|
zhmu/ananas | Ada | 234 | adb | -- { dg-do run }
-- { dg-options "-O -fno-inline" }
with Opt77_Pkg; use Opt77_Pkg;
procedure Opt77 is
N : Natural := 0;
To_Add : Boolean;
begin
Proc ("One", N, To_Add);
if To_Add then
raise Program_Error;
end if;
end;
|
onox/orka | Ada | 9,236 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- 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.
private with Ada.Containers.Indefinite_Holders;
with GL.Buffers;
with GL.Objects.Framebuffers;
with GL.Objects.Textures;
with GL.Types.Colors;
with Orka.Rendering.Textures;
package Orka.Rendering.Framebuffers is
pragma Preelaborate;
use GL.Types;
use all type Rendering.Textures.Format_Kind;
package FB renames GL.Objects.Framebuffers;
package Textures renames GL.Objects.Textures;
subtype Color_Attachment_Point is FB.Attachment_Point
range FB.Color_Attachment_0 .. FB.Color_Attachment_7;
type Use_Point_Array is array (Rendering.Framebuffers.Color_Attachment_Point) of Boolean;
-- TODO Use as formal parameter in procedure Invalidate
type Buffer_Values is record
Color : Colors.Color := (0.0, 0.0, 0.0, 1.0);
Depth : GL.Buffers.Depth := 0.0;
Stencil : GL.Buffers.Stencil_Index := 0;
end record;
type Framebuffer (Default : Boolean) is tagged private;
function Create_Framebuffer
(Width, Height : Size;
Samples : Size := 0) return Framebuffer
with Post => not Create_Framebuffer'Result.Default;
-----------------------------------------------------------------------------
function Create_Default_Framebuffer
(Width, Height : Natural) return Framebuffer
with Post => Create_Default_Framebuffer'Result.Default;
-----------------------------------------------------------------------------
function Width (Object : Framebuffer) return Size;
function Height (Object : Framebuffer) return Size;
function Samples (Object : Framebuffer) return Size;
function Image (Object : Framebuffer) return String;
-- Return a description of the given framebuffer
procedure Use_Framebuffer (Object : Framebuffer);
-- Use the framebuffer during rendering
--
-- The viewport is adjusted to the size of the framebuffer.
procedure Set_Default_Values (Object : in out Framebuffer; Values : Buffer_Values);
-- Set the default values for the color buffers and depth and stencil
-- buffers
function Default_Values (Object : Framebuffer) return Buffer_Values;
-- Return the current default values used when clearing the attached
-- textures
procedure Set_Read_Buffer
(Object : Framebuffer;
Buffer : GL.Buffers.Color_Buffer_Selector);
-- Set the buffer to use when blitting to another framebuffer with
-- procedure Resolve_To
procedure Set_Draw_Buffers
(Object : in out Framebuffer;
Buffers : GL.Buffers.Color_Buffer_List);
-- Set the buffers to use when drawing to output variables in a fragment
-- shader, when calling procedure Clear, or when another framebuffer
-- blits its read buffer to this framebuffer with procedure Resolve_To
procedure Clear
(Object : Framebuffer;
Mask : GL.Buffers.Buffer_Bits := (others => True));
-- Clear the attached textures for which the mask is True using
-- the default values set with Set_Default_Values
--
-- For clearing to be effective, the following conditions must apply:
--
-- - Write mask off
-- - Rasterizer discard disabled
-- - Scissor test off or scissor rectangle set to the desired region
-- - Called procedure Set_Draw_Buffers with a list of attachments
--
-- If a combined depth/stencil texture has been attached, the depth
-- and stencil components can be cleared separately, but it may be
-- faster to clear both components.
procedure Invalidate
(Object : Framebuffer;
Mask : GL.Buffers.Buffer_Bits);
-- Invalidate the attached textures for which the mask is True
procedure Resolve_To
(Object, Subject : Framebuffer;
Mask : GL.Buffers.Buffer_Bits := (Color => True, others => False))
with Pre => Object /= Subject and
(Mask.Color or Mask.Depth or Mask.Stencil) and
(if Object.Samples > 0 and Subject.Samples > 0 then
Object.Samples = Subject.Samples);
-- Copy one or more buffers, resolving multiple samples and scaling
-- if necessary, from the source to the destination framebuffer
--
-- If a buffer is specified in the mask, then the buffer should exist
-- in both framebuffers, otherwise the buffer is not copied. Call
-- Set_Read_Buffer and Set_Draw_Buffers to control which buffer is read
-- from and which buffers are written to.
--
-- Format of color buffers may differ and will be converted (if
-- supported). Formats of depth and stencil buffers must match.
--
-- Note: simultaneously resolving multiple samples and scaling
-- of color buffers requires GL_EXT_framebuffer_multisample_blit_scaled.
-- If this extension is not present, then two separate calls to this
-- procedure are needed.
procedure Attach
(Object : in out Framebuffer;
Texture : Textures.Texture;
Attachment : Color_Attachment_Point := FB.Color_Attachment_0;
Level : Textures.Mipmap_Level := 0)
with Pre => (not Object.Default and Texture.Allocated and
(if Rendering.Textures.Get_Format_Kind (Texture.Internal_Format) = Color then
(Object.Width = Texture.Width (Level) and
Object.Height = Texture.Height (Level))))
or else raise Constraint_Error with
"Cannot attach " & Rendering.Textures.Image (Texture, Level) &
" to " & Object.Image,
Post => (if Rendering.Textures.Get_Format_Kind (Texture.Internal_Format) = Color then
Object.Has_Attachment (Attachment));
-- Attach the texture to an attachment point based on the internal
-- format of the texture or to the given attachment point if the
-- texture is color renderable
--
-- The internal format of the texture must be valid for the given
-- attachment point.
--
-- If one of the attached textures is layered (3D, 1D/2D array, cube
-- map [array], or 2D multisampled array), then all attachments must
-- have the same kind.
--
-- If the texture is layered and you want to attach a specific layer,
-- then you must call the procedure Attach_Layer below instead.
--
-- All attachments of the framebuffer must have the same amount of
-- samples and they must all have fixed sample locations, or none of
-- them must have them.
procedure Attach_Layer
(Object : in out Framebuffer;
Texture : Textures.Texture;
Attachment : FB.Attachment_Point;
Layer : Natural;
Level : Textures.Mipmap_Level := 0)
with Pre => (not Object.Default and Texture.Allocated and
Texture.Layered and
(if Attachment in Color_Attachment_Point then
(Object.Width = Texture.Width (Level) and
Object.Height = Texture.Height (Level))))
or else raise Constraint_Error with
"Cannot attach layer of " & Rendering.Textures.Image (Texture, Level) &
" to " & Object.Image,
Post => Object.Has_Attachment (Attachment);
-- Attach the selected 1D/2D layer of the texture to the attachment point
--
-- The internal format of the texture must be valid for the given
-- attachment point.
--
-- The texture must be layered (3D, 1D/2D array, cube
-- map [array], or 2D multisampled array).
procedure Detach
(Object : in out Framebuffer;
Attachment : FB.Attachment_Point)
with Pre => not Object.Default,
Post => not Object.Has_Attachment (Attachment);
-- Detach any texture currently attached to the given attachment point
function Has_Attachment
(Object : Framebuffer;
Attachment : FB.Attachment_Point) return Boolean;
Framebuffer_Incomplete_Error : exception;
private
package Attachment_Holder is new Ada.Containers.Indefinite_Holders
(Element_Type => Textures.Texture, "=" => Textures."=");
package Color_Buffer_List_Holder is new Ada.Containers.Indefinite_Holders
(Element_Type => GL.Buffers.Color_Buffer_List, "=" => GL.Buffers."=");
type Attachment_Array is array (FB.Attachment_Point)
of Attachment_Holder.Holder;
type Framebuffer (Default : Boolean) is tagged record
GL_Framebuffer : FB.Framebuffer;
Attachments : Attachment_Array;
Defaults : Buffer_Values;
Draw_Buffers : Color_Buffer_List_Holder.Holder;
Width, Height, Samples : Size;
end record;
end Orka.Rendering.Framebuffers;
|
Rodeo-McCabe/orka | Ada | 2,029 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.Rendering.Buffers.Mapped.Unsynchronized is
function Create_Buffer
(Kind : Orka.Types.Element_Type;
Length : Natural;
Mode : IO_Mode) return Unsynchronized_Mapped_Buffer
is
Storage_Flags : constant GL.Objects.Buffers.Storage_Bits :=
(Write => Mode = Write, Read => Mode = Read, others => False);
begin
return Result : Unsynchronized_Mapped_Buffer (Kind, Mode) do
Result.Buffer := Buffers.Create_Buffer (Storage_Flags, Kind, Length);
Result.Offset := 0;
end return;
end Create_Buffer;
procedure Map (Object : in out Unsynchronized_Mapped_Buffer) is
Access_Flags : constant GL.Objects.Buffers.Access_Bits :=
(Write => Object.Mode = Write, Read => Object.Mode = Read,
Unsynchronized => True, Invalidate_Range => Object.Mode = Write,
others => False);
begin
Object.Map (Size (Object.Length), Access_Flags);
end Map;
procedure Unmap (Object : in out Unsynchronized_Mapped_Buffer) is
begin
Object.Buffer.Buffer.Unmap;
end Unmap;
function Mapped (Object : in out Unsynchronized_Mapped_Buffer) return Boolean is
(Object.Buffer.Buffer.Mapped);
function Buffer (Object : in out Unsynchronized_Mapped_Buffer) return Buffers.Buffer is
(Object.Buffer);
end Orka.Rendering.Buffers.Mapped.Unsynchronized;
|
reznikmm/matreshka | Ada | 2,432 | ads | with League.Calendars;
with League.Stream_Element_Vectors;
with League.String_Vectors;
with League.Strings;
private with Ada.Containers.Vectors;
private with Ada.Streams.Stream_IO;
private with Zip.IO;
private with Zip.Metadata;
package Zip.Archives is
procedure Initialize;
type Input is tagged limited private;
-- Zip archive opened for reading
not overriding procedure Open
(Self : out Input;
Path : League.Strings.Universal_String);
-- Open existing archive for reading
not overriding function Entry_Count (Self : Input) return Natural;
-- Return count of file/dir nested in given archive.
not overriding function Path
(Self : Input;
Index : Positive) return League.Strings.Universal_String;
-- Return path of given entry.
not overriding procedure Close (Self : in out Input);
type Output is tagged limited private;
-- Zip archive opened for writing
not overriding procedure Create
(Self : out Output;
Path : League.Strings.Universal_String);
not overriding procedure Copy
(To : in out Output'Class;
From : in out Input;
Index : Positive);
not overriding procedure Append
(Self : in out Output;
Path : League.Strings.Universal_String;
Data : League.Stream_Element_Vectors.Stream_Element_Vector;
Modified : League.Calendars.Date_Time;
Method : Zip.Compression_Method := Zip.Deflate);
not overriding procedure Close (Self : in out Output);
private
type Input is tagged limited record
File : aliased Zip.IO.File_Type;
Directory : Zip.Metadata.Central_Directory;
end record;
type Counting_Stream is new Ada.Streams.Root_Stream_Type with record
Parent : access Ada.Streams.Root_Stream_Type'Class;
Offset : Ada.Streams.Stream_Element_Offset := 0;
end record;
-- Decorator to count written elements
overriding procedure Read
(Stream : in out Counting_Stream;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is null;
overriding procedure Write
(Stream : in out Counting_Stream;
Item : Ada.Streams.Stream_Element_Array);
type Output is tagged limited record
File : Ada.Streams.Stream_IO.File_Type;
Stream : aliased Counting_Stream;
Directory : Zip.Metadata.Central_Directory;
end record;
end Zip.Archives;
|
sungyeon/drake | Ada | 531 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Storage_Pools.Standard_Pools;
package System.Pool_Global is
pragma Preelaborate;
subtype Unbounded_No_Reclaim_Pool is
Storage_Pools.Standard_Pools.Standard_Pool;
pragma Suppress (All_Checks); -- for renaming
-- required for default of 'Storage_Pool by compiler (s-pooglo.ads)
Global_Pool_Object : Unbounded_No_Reclaim_Pool
renames Storage_Pools.Standard_Pools.Standard_Storage_Pool.all;
end System.Pool_Global;
|
KLOC-Karsten/lsm303agr | Ada | 3,977 | ads | -- Copyright (c) 2021, Karsten Lüth ([email protected])
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form 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 HAL.I2C; use HAL.I2C;
private with Ada.Unchecked_Conversion;
package LSM303AGR is
type LSM303AGR_Accelerometer (Port : not null Any_I2C_Port)
is tagged limited private;
type Dynamic_Range is (Two_G, Four_G, Heigh_G);
type Data_Rate is (Hz_1, Hz_10, Hz_25, Hz_50, Hz_100, Hz_200, Hz_400);
procedure Configure (This : in out LSM303AGR_Accelerometer;
Dyna_Range : Dynamic_Range;
Rate : Data_Rate);
function Check_Device_Id (This : LSM303AGR_Accelerometer) return Boolean;
-- Return False if device ID in incorrect or cannot be read
type Axis_Data is range -2 ** 9 .. 2 ** 9 - 1
with Size => 10;
type All_Axes_Data is record
X, Y, Z : Axis_Data;
end record;
function Read_Data (This : LSM303AGR_Accelerometer) return All_Axes_Data;
private
type LSM303AGR_Accelerometer (Port : not null Any_I2C_Port) is tagged limited
null record;
type Register_Addresss is new UInt8;
for Dynamic_Range use (Two_G => 16#00#,
Four_G => 16#10#,
Heigh_G => 16#20#);
for Data_Rate use (Hz_1 => 16#10#,
Hz_10 => 16#20#,
Hz_25 => 16#30#,
Hz_50 => 16#40#,
Hz_100 => 16#50#,
Hz_200 => 16#60#,
Hz_400 => 16#70#);
Device_Id : constant := 16#33#;
Who_Am_I : constant Register_Addresss := 16#0F#;
CTRL_REG1_A : constant Register_Addresss := 16#20#;
CTRL_REG2_A : constant Register_Addresss := 16#21#;
CTRL_REG3_A : constant Register_Addresss := 16#22#;
CTRL_REG4_A : constant Register_Addresss := 16#23#;
CTRL_REG5_A : constant Register_Addresss := 16#24#;
CTRL_REG6_A : constant Register_Addresss := 16#25#;
DATA_STATUS : constant Register_Addresss := 16#27#;
OUT_X_LSB : constant Register_Addresss := 16#28#;
OUT_X_MSB : constant Register_Addresss := 16#29#;
OUT_Y_LSB : constant Register_Addresss := 16#2A#;
OUT_Y_MSB : constant Register_Addresss := 16#2B#;
OUT_Z_LSB : constant Register_Addresss := 16#2C#;
OUT_Z_MSB : constant Register_Addresss := 16#2D#;
Device_Address : constant I2C_Address := 16#32#;
end LSM303AGR;
|
reznikmm/matreshka | Ada | 4,695 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Form.Convert_Empty_To_Null_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Convert_Empty_To_Null_Attribute_Node is
begin
return Self : Form_Convert_Empty_To_Null_Attribute_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_Convert_Empty_To_Null_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Convert_Empty_To_Null_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.Convert_Empty_To_Null_Attribute,
Form_Convert_Empty_To_Null_Attribute_Node'Tag);
end Matreshka.ODF_Form.Convert_Empty_To_Null_Attributes;
|
sungyeon/drake | Ada | 5,274 | ads | pragma License (Unrestricted);
-- Ada 2012
private with System.Finalization_Masters;
private with System.Storage_Barriers;
package System.Storage_Pools.Subpools is
pragma Preelaborate;
type Root_Storage_Pool_With_Subpools is
abstract limited new Root_Storage_Pool with private;
type Root_Subpool is abstract tagged limited private;
type Subpool_Handle is access all Root_Subpool'Class;
for Subpool_Handle'Storage_Size use 0;
function Create_Subpool (Pool : in out Root_Storage_Pool_With_Subpools)
return not null Subpool_Handle is abstract;
-- The following operations are intended for pool implementers:
-- function Pool_of_Subpool (
function Pool_Of_Subpool (
Subpool : not null Subpool_Handle)
return access Root_Storage_Pool_With_Subpools'Class;
pragma Inline (Pool_Of_Subpool);
-- Note: RM defined Pool_*o*f_Subpool,
-- but GNAT runtime defined Pool_*O*f_Subpool.
-- procedure Set_Pool_of_Subpool (
procedure Set_Pool_Of_Subpool (
Subpool : not null Subpool_Handle;
To : in out Root_Storage_Pool_With_Subpools'Class);
-- Note: RM defined Set_Pool_*o*f_Subpool,
-- but GNAT runtime defined Set_Pool_*O*f_Subpool.
procedure Allocate_From_Subpool (
Pool : in out Root_Storage_Pool_With_Subpools;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count;
Subpool : not null Subpool_Handle) is abstract;
-- with Pre'Class => Pool_of_Subpool(Subpool) = Pool'Access;
procedure Deallocate_Subpool (
Pool : in out Root_Storage_Pool_With_Subpools;
Subpool : in out Subpool_Handle) is abstract;
-- with Pre'Class => Pool_of_Subpool(Subpool) = Pool'Access;
-- function Default_Subpool_for_Pool (
function Default_Subpool_For_Pool (
Pool : in out Root_Storage_Pool_With_Subpools)
return not null Subpool_Handle;
-- Note: RM defined Default_Subpool_*f*or_Pool,
-- but GNAT runtime defined Default_Subpool_*F*or_Pool.
overriding procedure Allocate (
Pool : in out Root_Storage_Pool_With_Subpools;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count);
overriding procedure Deallocate (
Pool : in out Root_Storage_Pool_With_Subpools;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is null;
pragma Inline (Deallocate); -- [gcc-7] can not skip calling null procedure
overriding function Storage_Size (Pool : Root_Storage_Pool_With_Subpools)
return Storage_Elements.Storage_Count is
(Storage_Elements.Storage_Count'Last);
-- extended
-- This is same as/called from Ada.Unchecked_Deallocate_Subpool.
procedure Unchecked_Deallocate_Subpool (Subpool : in out Subpool_Handle);
private
use type Storage_Elements.Storage_Offset;
type Root_Storage_Pool_With_Subpools is
abstract limited new Root_Storage_Pool with
record
Last : Subpool_Handle := null;
Finalization_Started : aliased Storage_Barriers.Flag;
end record;
overriding procedure Initialize (
Object : in out Root_Storage_Pool_With_Subpools);
overriding procedure Finalize (
Object : in out Root_Storage_Pool_With_Subpools);
-- reraise some exception propagated from its own objects
type Root_Storage_Pool_With_Subpools_Access is
access all Root_Storage_Pool_With_Subpools'Class;
for Root_Storage_Pool_With_Subpools_Access'Storage_Size use 0;
-- Root_Subpool
type Root_Subpool is abstract tagged limited record
Owner : Root_Storage_Pool_With_Subpools_Access := null;
Previous : Subpool_Handle := null;
Next : Subpool_Handle := null;
-- for owned objects
Master : aliased Finalization_Masters.Finalization_Master;
end record;
-- required by compiler (s-stposu.ads)
procedure Allocate_Any_Controlled (
Pool : in out Root_Storage_Pool'Class;
Context_Subpool : Subpool_Handle;
Context_Master : Finalization_Masters.Finalization_Master_Ptr;
Fin_Address : Finalization_Masters.Finalize_Address_Ptr;
Addr : out Address;
Storage_Size : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count;
Is_Controlled : Boolean;
On_Subpool : Boolean);
-- required by compiler (s-stposu.ads)
procedure Deallocate_Any_Controlled (
Pool : in out Root_Storage_Pool'Class;
Addr : Address;
Storage_Size : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count;
Is_Controlled : Boolean);
-- required by compiler (s-stposu.ads)
function Header_Size_With_Padding (
Alignment : Storage_Elements.Storage_Count)
return Storage_Elements.Storage_Count;
pragma Inline (Header_Size_With_Padding);
-- required for checked pool by compiler (s-stposu.ads)
-- procedure Adjust_Controlled_Dereference (
-- Addr : in out Address;
-- Storage_Size : in out Storage_Elements.Storage_Count;
-- Alignment : Storage_Elements.Storage_Count);
end System.Storage_Pools.Subpools;
|
BrickBot/Bound-T-H8-300 | Ada | 3,297 | adb | -- Bounds.Stacking.Opt (body)
--
-- Author: Niklas Holsti, Tidorum Ltd
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form 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.
--
-- 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.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.2 $
-- $Date: 2015/10/24 20:05:46 $
--
-- $Log: bounds-stacking-opt.adb,v $
-- Revision 1.2 2015/10/24 20:05:46 niklas
-- Moved to free licence.
--
-- Revision 1.1 2012-02-13 17:51:49 niklas
-- First version, for BT-CH-0230.
--
with Arithmetic;
with Options;
with Options.Groups;
with Output;
package body Bounds.Stacking.Opt is
procedure Ignore_Huge_Bounds (
Limit : in out Programs.Execution.Stack_Limit_T)
is
use Storage.Bounds;
use type Arithmetic.Value_T;
begin
if Known (Limit.Min)
and then Over (abs Value (Limit.Min), Max_Abs_Height)
then
Output.Warning (
"Large lower bound on stack height ignored as spurious"
& Output.Field_Separator
& Arithmetic.Image (Value (Limit.Min)));
Limit.Min := Not_Limited;
end if;
if Known (Limit.Max)
and then Over (abs Value (Limit.Max), Max_Abs_Height)
then
Output.Warning (
"Large upper bound on stack height ignored as spurious"
& Output.Field_Separator
& Arithmetic.Image (Value (Limit.Max)));
Limit.Max := Not_Limited;
end if;
end Ignore_Huge_Bounds;
begin -- Bounds.Stacking.Opt
Options.Register (
Option => Max_Abs_Height_Opt'Access,
Name => "max_stack",
Group => Options.Groups.Stack_Usage);
end Bounds.Stacking.Opt;
|
reznikmm/matreshka | Ada | 12,121 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- 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.OCL_Elements;
with AMF.OCL.Variable_Exps;
with AMF.OCL.Variables;
with AMF.UML.Comments.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Types;
with AMF.Visitors;
package AMF.Internals.OCL_Variable_Exps is
type OCL_Variable_Exp_Proxy is
limited new AMF.Internals.OCL_Elements.OCL_Element_Proxy
and AMF.OCL.Variable_Exps.OCL_Variable_Exp with null record;
overriding function Get_Referred_Variable
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.OCL.Variables.OCL_Variable_Access;
-- Getter of VariableExp::referredVariable.
--
overriding procedure Set_Referred_Variable
(Self : not null access OCL_Variable_Exp_Proxy;
To : AMF.OCL.Variables.OCL_Variable_Access);
-- Setter of VariableExp::referredVariable.
--
overriding function Get_Type
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Types.UML_Type_Access;
-- Getter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding procedure Set_Type
(Self : not null access OCL_Variable_Exp_Proxy;
To : AMF.UML.Types.UML_Type_Access);
-- Setter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding function Get_Client_Dependency
(Self : not null access constant OCL_Variable_Exp_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
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::name.
--
-- The name of the NamedElement.
overriding procedure Set_Name
(Self : not null access OCL_Variable_Exp_Proxy;
To : AMF.Optional_String);
-- Setter of NamedElement::name.
--
-- The name of the NamedElement.
overriding function Get_Name_Expression
(Self : not null access constant OCL_Variable_Exp_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 OCL_Variable_Exp_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 OCL_Variable_Exp_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 OCL_Variable_Exp_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 Get_Visibility
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Optional_UML_Visibility_Kind;
-- Getter of NamedElement::visibility.
--
-- Determines where the NamedElement appears within different Namespaces
-- within the overall model, and its accessibility.
overriding procedure Set_Visibility
(Self : not null access OCL_Variable_Exp_Proxy;
To : AMF.UML.Optional_UML_Visibility_Kind);
-- Setter of NamedElement::visibility.
--
-- Determines where the NamedElement appears within different Namespaces
-- within the overall model, and its accessibility.
overriding function Get_Owned_Comment
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Comments.Collections.Set_Of_UML_Comment;
-- Getter of Element::ownedComment.
--
-- The Comments owned by this element.
overriding function Get_Owned_Element
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Element::ownedElement.
--
-- The Elements owned by this element.
overriding function Get_Owner
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Elements.UML_Element_Access;
-- Getter of Element::owner.
--
-- The Element that owns this element.
overriding function All_Namespaces
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace;
-- Operation NamedElement::allNamespaces.
--
-- The query allNamespaces() gives the sequence of namespaces in which the
-- NamedElement is nested, working outwards.
overriding function All_Owning_Packages
(Self : not null access constant OCL_Variable_Exp_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 OCL_Variable_Exp_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 OCL_Variable_Exp_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Qualified_Name
(Self : not null access constant OCL_Variable_Exp_Proxy)
return League.Strings.Universal_String;
-- Operation NamedElement::qualifiedName.
--
-- When there is a name, and all of the containing namespaces have a name,
-- the qualified name is constructed from the names of the containing
-- namespaces.
overriding function Separator
(Self : not null access constant OCL_Variable_Exp_Proxy)
return League.Strings.Universal_String;
-- Operation NamedElement::separator.
--
-- The query separator() gives the string that is used to separate names
-- when constructing a qualified name.
overriding function All_Owned_Elements
(Self : not null access constant OCL_Variable_Exp_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Operation Element::allOwnedElements.
--
-- The query allOwnedElements() gives all of the direct and indirect owned
-- elements of an element.
overriding function Must_Be_Owned
(Self : not null access constant OCL_Variable_Exp_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.
overriding procedure Enter_Element
(Self : not null access constant OCL_Variable_Exp_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 OCL_Variable_Exp_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 OCL_Variable_Exp_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.OCL_Variable_Exps;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Elements;
package ODF.DOM.Table_Content_Validation_Elements is
pragma Preelaborate;
type ODF_Table_Content_Validation is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Content_Validation_Access is
access all ODF_Table_Content_Validation'Class
with Storage_Size => 0;
end ODF.DOM.Table_Content_Validation_Elements;
|
zhmu/ananas | Ada | 117 | ads | package Inline7_Pkg2 is
generic
D : Integer;
function Calc (A : Integer) return Integer;
end Inline7_Pkg2;
|
reznikmm/matreshka | Ada | 6,352 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- 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.
------------------------------------------------------------------------------
-- A value specification is the specification of a (possibly empty) set of
-- instances, including both objects and data values.
------------------------------------------------------------------------------
with AMF.CMOF.Packageable_Elements;
with AMF.CMOF.Typed_Elements;
with League.Strings;
package AMF.CMOF.Value_Specifications is
pragma Preelaborate;
type CMOF_Value_Specification is limited interface
and AMF.CMOF.Typed_Elements.CMOF_Typed_Element
and AMF.CMOF.Packageable_Elements.CMOF_Packageable_Element;
type CMOF_Value_Specification_Access is
access all CMOF_Value_Specification'Class;
for CMOF_Value_Specification_Access'Storage_Size use 0;
not overriding function Is_Computable
(Self : not null access constant CMOF_Value_Specification)
return Boolean is abstract;
-- Operation ValueSpecification::isComputable.
--
-- The query isComputable() determines whether a value specification can
-- be computed in a model. This operation cannot be fully defined in OCL.
-- A conforming implementation is expected to deliver true for this
-- operation for all value specifications that it can compute, and to
-- compute all of those for which the operation is true. A conforming
-- implementation is expected to be able to compute the value of all
-- literals.
not overriding function Integer_Value
(Self : not null access constant CMOF_Value_Specification)
return Integer is abstract;
-- Operation ValueSpecification::integerValue.
--
-- The query integerValue() gives a single Integer value when one can be
-- computed.
not overriding function Boolean_Value
(Self : not null access constant CMOF_Value_Specification)
return Boolean is abstract;
-- Operation ValueSpecification::booleanValue.
--
-- The query booleanValue() gives a single Boolean value when one can be
-- computed.
not overriding function String_Value
(Self : not null access constant CMOF_Value_Specification)
return League.Strings.Universal_String is abstract;
-- Operation ValueSpecification::stringValue.
--
-- The query stringValue() gives a single String value when one can be
-- computed.
not overriding function Unlimited_Value
(Self : not null access constant CMOF_Value_Specification)
return AMF.Unlimited_Natural is abstract;
-- Operation ValueSpecification::unlimitedValue.
--
-- The query unlimitedValue() gives a single UnlimitedNatural value when
-- one can be computed.
not overriding function Is_Null
(Self : not null access constant CMOF_Value_Specification)
return Boolean is abstract;
-- Operation ValueSpecification::isNull.
--
-- The query isNull() returns true when it can be computed that the value
-- is null.
end AMF.CMOF.Value_Specifications;
|
optikos/oasis | Ada | 9,260 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Entry_Declarations is
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access;
Entry_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Entry_Family_Definition : Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Left_Bracket_Token_2 : Program.Lexical_Elements.Lexical_Element_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Right_Bracket_Token_2 : Program.Lexical_Elements.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Entry_Declaration is
begin
return Result : Entry_Declaration :=
(Not_Token => Not_Token, Overriding_Token => Overriding_Token,
Entry_Token => Entry_Token, Name => Name,
Left_Bracket_Token => Left_Bracket_Token,
Entry_Family_Definition => Entry_Family_Definition,
Right_Bracket_Token => Right_Bracket_Token,
Left_Bracket_Token_2 => Left_Bracket_Token_2,
Parameters => Parameters,
Right_Bracket_Token_2 => Right_Bracket_Token_2,
With_Token => With_Token, Aspects => Aspects,
Semicolon_Token => Semicolon_Token, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Entry_Family_Definition : Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not : Boolean := False;
Has_Overriding : Boolean := False)
return Implicit_Entry_Declaration is
begin
return Result : Implicit_Entry_Declaration :=
(Name => Name, Entry_Family_Definition => Entry_Family_Definition,
Parameters => Parameters, Aspects => Aspects,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Has_Not => Has_Not,
Has_Overriding => Has_Overriding, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Name
(Self : Base_Entry_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is
begin
return Self.Name;
end Name;
overriding function Entry_Family_Definition
(Self : Base_Entry_Declaration)
return Program.Elements.Discrete_Ranges.Discrete_Range_Access is
begin
return Self.Entry_Family_Definition;
end Entry_Family_Definition;
overriding function Parameters
(Self : Base_Entry_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is
begin
return Self.Parameters;
end Parameters;
overriding function Aspects
(Self : Base_Entry_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is
begin
return Self.Aspects;
end Aspects;
overriding function Not_Token
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Not_Token;
end Not_Token;
overriding function Overriding_Token
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Overriding_Token;
end Overriding_Token;
overriding function Entry_Token
(Self : Entry_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Entry_Token;
end Entry_Token;
overriding function Left_Bracket_Token
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Left_Bracket_Token;
end Left_Bracket_Token;
overriding function Right_Bracket_Token
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Right_Bracket_Token;
end Right_Bracket_Token;
overriding function Left_Bracket_Token_2
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Left_Bracket_Token_2;
end Left_Bracket_Token_2;
overriding function Right_Bracket_Token_2
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Right_Bracket_Token_2;
end Right_Bracket_Token_2;
overriding function With_Token
(Self : Entry_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.With_Token;
end With_Token;
overriding function Semicolon_Token
(Self : Entry_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Has_Not (Self : Entry_Declaration) return Boolean is
begin
return Self.Not_Token.Assigned;
end Has_Not;
overriding function Has_Overriding
(Self : Entry_Declaration)
return Boolean is
begin
return Self.Overriding_Token.Assigned;
end Has_Overriding;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Entry_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Entry_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Entry_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Not
(Self : Implicit_Entry_Declaration)
return Boolean is
begin
return Self.Has_Not;
end Has_Not;
overriding function Has_Overriding
(Self : Implicit_Entry_Declaration)
return Boolean is
begin
return Self.Has_Overriding;
end Has_Overriding;
procedure Initialize (Self : aliased in out Base_Entry_Declaration'Class) is
begin
Set_Enclosing_Element (Self.Name, Self'Unchecked_Access);
if Self.Entry_Family_Definition.Assigned then
Set_Enclosing_Element
(Self.Entry_Family_Definition, Self'Unchecked_Access);
end if;
for Item in Self.Parameters.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Aspects.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
null;
end Initialize;
overriding function Is_Entry_Declaration_Element
(Self : Base_Entry_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Entry_Declaration_Element;
overriding function Is_Declaration_Element
(Self : Base_Entry_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration_Element;
overriding procedure Visit
(Self : not null access Base_Entry_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Entry_Declaration (Self);
end Visit;
overriding function To_Entry_Declaration_Text
(Self : aliased in out Entry_Declaration)
return Program.Elements.Entry_Declarations
.Entry_Declaration_Text_Access is
begin
return Self'Unchecked_Access;
end To_Entry_Declaration_Text;
overriding function To_Entry_Declaration_Text
(Self : aliased in out Implicit_Entry_Declaration)
return Program.Elements.Entry_Declarations
.Entry_Declaration_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Entry_Declaration_Text;
end Program.Nodes.Entry_Declarations;
|
optikos/oasis | Ada | 3,723 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Element_Vectors;
with Program.Elements.Defining_Names;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Generic_Function_Declarations is
pragma Pure (Program.Elements.Generic_Function_Declarations);
type Generic_Function_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Generic_Function_Declaration_Access is
access all Generic_Function_Declaration'Class with Storage_Size => 0;
not overriding function Formal_Parameters
(Self : Generic_Function_Declaration)
return Program.Element_Vectors.Element_Vector_Access is abstract;
not overriding function Name
(Self : Generic_Function_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access
is abstract;
not overriding function Parameters
(Self : Generic_Function_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is abstract;
not overriding function Result_Subtype
(Self : Generic_Function_Declaration)
return not null Program.Elements.Element_Access is abstract;
not overriding function Aspects
(Self : Generic_Function_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
not overriding function Has_Not_Null
(Self : Generic_Function_Declaration)
return Boolean is abstract;
type Generic_Function_Declaration_Text is limited interface;
type Generic_Function_Declaration_Text_Access is
access all Generic_Function_Declaration_Text'Class with Storage_Size => 0;
not overriding function To_Generic_Function_Declaration_Text
(Self : aliased in out Generic_Function_Declaration)
return Generic_Function_Declaration_Text_Access is abstract;
not overriding function Generic_Token
(Self : Generic_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Function_Token
(Self : Generic_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Generic_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Generic_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Return_Token
(Self : Generic_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Not_Token
(Self : Generic_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Null_Token
(Self : Generic_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function With_Token
(Self : Generic_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Generic_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Generic_Function_Declarations;
|
zhmu/ananas | Ada | 201 | adb | with System; use System;
package body Deferred_Const2_Pkg is
procedure Dummy is begin null; end;
begin
if S'Address /= I'Address then
raise Program_Error;
end if;
end Deferred_Const2_Pkg;
|
reznikmm/matreshka | Ada | 4,605 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Db.Is_Ascending_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Db_Is_Ascending_Attribute_Node is
begin
return Self : Db_Is_Ascending_Attribute_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_Is_Ascending_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Is_Ascending_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.Is_Ascending_Attribute,
Db_Is_Ascending_Attribute_Node'Tag);
end Matreshka.ODF_Db.Is_Ascending_Attributes;
|
MinimSecure/unum-sdk | Ada | 860 | adb | -- Copyright 2013-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 Pck; use Pck;
procedure Foo is
begin
Set_Float (1.0); -- START
Set_Double (1, 1.0);
Set_Long_Double (1, (I => 2), 1.0);
end Foo;
|
zhmu/ananas | Ada | 9,051 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 4 6 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, 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 System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_46 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_46;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
-- The following declarations are for the case where the address
-- passed to GetU_46 or SetU_46 is not guaranteed to be aligned.
-- These routines are used when the packed array is itself a
-- component of a packed record, and therefore may not be aligned.
type ClusterU is new Cluster;
for ClusterU'Alignment use 1;
type ClusterU_Ref is access ClusterU;
type Rev_ClusterU is new ClusterU
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_ClusterU_Ref is access Rev_ClusterU;
------------
-- Get_46 --
------------
function Get_46
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_46
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_46;
-------------
-- GetU_46 --
-------------
function GetU_46
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_46
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end GetU_46;
------------
-- Set_46 --
------------
procedure Set_46
(Arr : System.Address;
N : Natural;
E : Bits_46;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_46;
-------------
-- SetU_46 --
-------------
procedure SetU_46
(Arr : System.Address;
N : Natural;
E : Bits_46;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end SetU_46;
end System.Pack_46;
|
JohnYang97/Space-Convoy | Ada | 1,295 | ads | --
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
with Vectors_xD; pragma Elaborate_All (Vectors_xD);
package Vectors_3D_LF is
type Coordinates is (x, y, z);
package Vectors_3Di is new Vectors_xD (Long_Float, Coordinates);
subtype Vector_3D_LF is Vectors_3Di.Vector_xD;
Zero_Vector_3D_LF : constant Vector_3D_LF := Vectors_3Di.Zero_Vector_xD;
function Image (V : Vector_3D_LF) return String renames Vectors_3Di.Image;
function Norm (V : Vector_3D_LF) return Vector_3D_LF renames Vectors_3Di.Norm;
function "*" (Scalar : Long_Float; V : Vector_3D_LF) return Vector_3D_LF renames Vectors_3Di."*";
function "*" (V : Vector_3D_LF; Scalar : Long_Float) return Vector_3D_LF renames Vectors_3Di."*";
function "*" (V_Left, V_Right : Vector_3D_LF) return Long_Float renames Vectors_3Di."*";
function "*" (V_Left, V_Right : Vector_3D_LF) return Vector_3D_LF;
function Angle_Between (V_Left, V_Right : Vector_3D_LF) return Long_Float renames Vectors_3Di.Angle_Between;
function "+" (V_Left, V_Right : Vector_3D_LF) return Vector_3D_LF renames Vectors_3Di."+";
function "-" (V_Left, V_Right : Vector_3D_LF) return Vector_3D_LF renames Vectors_3Di."-";
function "abs" (V : Vector_3D_LF) return Long_Float renames Vectors_3Di."abs";
end Vectors_3D_LF;
|
charlie5/lace | Ada | 18,716 | ads | with
interfaces.C.Pointers,
interfaces.C.Strings,
system.Address_To_Access_Conversions;
package swig.Pointers
--
-- Contains pointers to Swig related C type definitions not found in the 'interfaces.C' family.
--
is
-- void_ptr
--
package C_void_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.void_ptr,
element_Array => void_ptr_Array,
default_Terminator => system.null_Address);
subtype void_ptr_Pointer is C_void_ptr_Pointers.Pointer;
-- opaque struct_ptr
--
type opaque_structure_ptr is access swig.opaque_structure;
type opaque_structure_ptr_array is array (interfaces.c.Size_t range <>) of aliased opaque_structure_ptr;
package C_opaque_structure_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => opaque_structure_ptr,
element_Array => opaque_structure_ptr_array,
default_Terminator => null);
subtype opaque_structure_ptr_Pointer is C_opaque_structure_ptr_Pointers.Pointer;
-- incomplete class
--
type incomplete_class_ptr is access swig.incomplete_class;
type incomplete_class_ptr_array is array (interfaces.c.Size_t range <>) of aliased incomplete_class_ptr;
package C_incomplete_class_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => incomplete_class_ptr,
element_Array => incomplete_class_ptr_array,
default_Terminator => null);
subtype incomplete_class_ptr_Pointer is C_incomplete_class_ptr_Pointers.Pointer;
-- bool*
--
package c_bool_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.bool,
element_Array => bool_Array,
default_Terminator => 0);
subtype bool_Pointer is c_bool_Pointers.Pointer;
type bool_Pointer_array is array (interfaces.c.Size_t range <>) of aliased bool_Pointer;
-- bool**
--
package C_bool_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => bool_Pointer,
element_Array => bool_Pointer_array,
default_Terminator => null);
subtype bool_pointer_Pointer is C_bool_pointer_Pointers.Pointer;
-- char* []
--
type chars_ptr_array is array (interfaces.c.Size_t range <>) of aliased interfaces.c.strings.chars_Ptr; -- standard Ada does not have 'aliased'
package C_chars_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.strings.chars_ptr,
element_Array => chars_ptr_array,
default_Terminator => interfaces.c.strings.Null_Ptr);
subtype chars_ptr_Pointer is C_chars_ptr_Pointers.Pointer;
-- char** []
--
type chars_ptr_Pointer_array is array (interfaces.c.Size_t range <>) of aliased chars_ptr_Pointer;
package C_chars_ptr_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => chars_ptr_Pointer,
element_Array => chars_ptr_Pointer_array,
default_Terminator => null);
subtype chars_ptr_pointer_Pointer is C_chars_ptr_pointer_Pointers.Pointer;
-- wchar_t*
--
package c_wchar_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.wchar_t,
element_Array => interfaces.c.wchar_array,
default_Terminator => interfaces.c.wchar_t'First);
subtype wchar_t_Pointer is c_wchar_t_Pointers.Pointer;
-- signed char*
--
package c_signed_char_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.signed_Char,
element_Array => swig.signed_char_Array,
default_Terminator => 0);
subtype signed_char_Pointer is c_signed_char_Pointers.Pointer;
-- unsigned char*
--
package c_unsigned_char_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.unsigned_Char,
element_Array => unsigned_char_Array,
default_Terminator => 0);
subtype unsigned_char_Pointer is c_unsigned_char_Pointers.Pointer;
-- short*
--
package c_short_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Short,
element_Array => short_Array,
default_Terminator => 0);
subtype short_Pointer is c_short_Pointers.Pointer;
-- unsigned short*
--
package c_unsigned_short_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.unsigned_Short,
element_Array => unsigned_short_Array,
default_Terminator => 0);
subtype unsigned_short_Pointer is c_unsigned_short_Pointers.Pointer;
-- int*
--
package c_int_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Int,
element_Array => int_Array,
default_Terminator => 0);
subtype int_Pointer is c_int_Pointers.Pointer;
-- int**
--
type int_pointer_Array is array (interfaces.c.size_t range <>) of aliased int_Pointer;
package c_int_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => int_Pointer,
element_Array => int_pointer_Array,
default_Terminator => null);
subtype int_pointer_Pointer is c_int_pointer_Pointers.Pointer;
-- size_t*
--
package c_size_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Size_t,
element_Array => size_t_Array,
default_Terminator => 0);
subtype size_t_Pointer is c_size_t_Pointers.Pointer;
-- unsigned*
--
package c_unsigned_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Unsigned,
element_Array => unsigned_Array,
default_Terminator => 0);
subtype unsigned_Pointer is c_unsigned_Pointers.Pointer;
-- long*
--
package c_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Long,
element_Array => long_Array,
default_Terminator => 0);
subtype long_Pointer is c_long_Pointers.Pointer;
-- unsigned long*
--
package c_unsigned_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.unsigned_Long,
element_Array => unsigned_long_Array,
default_Terminator => 0);
subtype unsigned_long_Pointer is c_unsigned_long_Pointers.Pointer;
-- long long*
--
package c_long_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.long_Long,
element_Array => long_long_Array,
default_Terminator => 0);
subtype long_long_Pointer is c_long_long_Pointers.Pointer;
-- unsigned long long*
--
package c_unsigned_long_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.unsigned_long_Long,
element_Array => unsigned_long_long_Array,
default_Terminator => 0);
subtype unsigned_long_long_Pointer is c_unsigned_long_long_Pointers.Pointer;
-- int8_t*
--
package c_int8_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int8_t,
element_Array => swig.int8_t_Array,
default_Terminator => 0);
subtype int8_t_Pointer is c_int8_t_Pointers.Pointer;
-- int16_t*
--
package c_int16_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int16_t,
element_Array => swig.int16_t_Array,
default_Terminator => 0);
subtype int16_t_Pointer is c_int16_t_Pointers.Pointer;
-- int32_t*
--
package c_int32_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int32_t,
element_Array => swig.int32_t_Array,
default_Terminator => 0);
subtype int32_t_Pointer is c_int32_t_Pointers.Pointer;
-- int64_t*
--
package c_int64_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int64_t,
element_Array => swig.int64_t_Array,
default_Terminator => 0);
subtype int64_t_Pointer is c_int64_t_Pointers.Pointer;
-- uint8_t*'
--
package c_uint8_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint8_t,
element_Array => swig.uint8_t_Array,
default_Terminator => 0);
subtype uint8_t_Pointer is c_uint8_t_Pointers.Pointer;
-- uint16_t*'
--
package c_uint16_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint16_t,
element_Array => swig.uint16_t_Array,
default_Terminator => 0);
subtype uint16_t_Pointer is c_uint16_t_Pointers.Pointer;
-- uint32_t*'
--
package c_uint32_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint32_t,
element_Array => swig.uint32_t_Array,
default_Terminator => 0);
subtype uint32_t_Pointer is c_uint32_t_Pointers.Pointer;
-- uint64_t*'
--
package c_uint64_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint64_t,
element_Array => swig.uint64_t_Array,
default_Terminator => 0);
subtype uint64_t_Pointer is c_uint64_t_Pointers.Pointer;
-- float*'
package c_float_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.c_Float,
element_Array => float_Array,
default_Terminator => 0.0);
subtype float_Pointer is c_float_Pointers.Pointer;
-- float**
--
type float_pointer_Array is array (interfaces.C.size_t range <>) of aliased float_Pointer;
package c_float_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => float_Pointer,
element_Array => float_pointer_Array,
default_Terminator => null);
subtype float_pointer_Pointer is c_float_pointer_Pointers.Pointer;
-- double*'
--
package c_double_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Double,
element_Array => double_Array,
default_Terminator => 0.0);
subtype double_Pointer is c_double_Pointers.Pointer;
-- double**
--
type double_pointer_Array is array (interfaces.C.size_t range <>) of aliased double_Pointer;
package c_double_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => double_Pointer,
element_Array => double_pointer_Array,
default_Terminator => null);
subtype double_pointer_Pointer is c_double_pointer_Pointers.Pointer;
-- long double*'
--
package c_long_double_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.long_Double,
element_Array => long_double_Array,
default_Terminator => 0.0);
subtype long_double_Pointer is c_long_double_Pointers.Pointer;
-- long double**
--
type long_double_pointer_Array is array (interfaces.C.size_t range <>) of aliased long_double_Pointer;
package c_long_double_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => long_double_Pointer,
element_Array => long_double_pointer_Array,
default_Terminator => null);
subtype long_double_pointer_Pointer is c_long_double_pointer_Pointers.Pointer;
-- std::string
--
type std_string is private;
type std_string_Pointer is access all std_String;
type std_string_Array is array (interfaces.c.size_t range <>) of aliased std_String;
-- Utility
--
package void_Conversions is new system.Address_To_Access_Conversions (swig.Void);
private
type std_String is
record
M_dataplus : swig.void_ptr; -- which is a subtype of system.Address
end record;
end Swig.Pointers;
-- tbd: use sensible default_Terminator's.
|
stcarrez/ada-keystore | Ada | 1,992 | adb | -----------------------------------------------------------------------
-- keystore-passwords-unsafe -- Unsafe password provider
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Keystore.Passwords.Unsafe is
type Provider (Len : Natural) is limited new Keystore.Passwords.Provider with record
Password : String (1 .. Len);
end record;
-- Get the password through the Getter operation.
overriding
procedure Get_Password (From : in Provider;
Getter : not null access procedure (Password : in Secret_Key));
-- ------------------------------
-- Create a unsafe command line base password provider.
-- ------------------------------
function Create (Password : in String) return Provider_Access is
begin
return new Provider '(Len => Password'Length,
Password => Password);
end Create;
-- ------------------------------
-- Get the password through the Getter operation.
-- ------------------------------
overriding
procedure Get_Password (From : in Provider;
Getter : not null access procedure (Password : in Secret_Key)) is
begin
Getter (Keystore.Create (From.Password));
end Get_Password;
end Keystore.Passwords.Unsafe;
|
kontena/ruby-packer | Ada | 3,609 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.AlphaNumeric --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2011,2014 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.13 $
-- $Date: 2014/05/24 21:31:05 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.AlphaNumeric is
procedure Set_Field_Type (Fld : Field;
Typ : AlphaNumeric_Field)
is
function Set_Fld_Type (F : Field := Fld;
Arg1 : C_Int) return Eti_Error;
pragma Import (C, Set_Fld_Type, "set_field_type_alnum");
begin
Eti_Exception (Set_Fld_Type (Arg1 => C_Int (Typ.Minimum_Field_Width)));
Wrap_Builtin (Fld, Typ);
end Set_Field_Type;
end Terminal_Interface.Curses.Forms.Field_Types.AlphaNumeric;
|
reznikmm/matreshka | Ada | 6,900 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Change_Start_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Change_Start_Element_Node is
begin
return Self : Text_Change_Start_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Change_Start_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Change_Start
(ODF.DOM.Text_Change_Start_Elements.ODF_Text_Change_Start_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Change_Start_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Change_Start_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Change_Start_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Change_Start
(ODF.DOM.Text_Change_Start_Elements.ODF_Text_Change_Start_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Change_Start_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Change_Start
(Visitor,
ODF.DOM.Text_Change_Start_Elements.ODF_Text_Change_Start_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Change_Start_Element,
Text_Change_Start_Element_Node'Tag);
end Matreshka.ODF_Text.Change_Start_Elements;
|
MinimSecure/unum-sdk | Ada | 821 | adb | -- 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 Pck; use Pck;
procedure Foo_NA07_019 is
begin
Increment (Something); -- START
end Foo_NA07_019;
|
AdaCore/training_material | Ada | 522 | adb | with Ada.Text_IO; use Ada.Text_IO;
package body Protected_Objects is
protected body Object is
procedure Initialize (My_Id : Character) is
begin
Id := My_Id;
end Initialize;
procedure Set (Caller : Character; V : Integer) is
begin
Local := V;
Put_Line ( "Task-" & Caller & " Object-" & Id & " => " & V'Image );
end Set;
function Get return Integer is
begin
return Local;
end Get;
end Object;
end Protected_Objects;
|
reznikmm/matreshka | Ada | 12,953 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- 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_Packageable_Elements;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Deployments.Collections;
with AMF.UML.Instance_Specifications;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements;
with AMF.UML.Slots.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Template_Parameters;
with AMF.UML.Value_Specifications;
with AMF.Visitors;
package AMF.Internals.UML_Instance_Specifications is
type UML_Instance_Specification_Proxy is
limited new AMF.Internals.UML_Packageable_Elements.UML_Packageable_Element_Proxy
and AMF.UML.Instance_Specifications.UML_Instance_Specification with null record;
overriding function Get_Classifier
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of InstanceSpecification::classifier.
--
-- The classifier or classifiers of the represented instance. If multiple
-- classifiers are specified, the instance is classified by all of them.
overriding function Get_Slot
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Slots.Collections.Set_Of_UML_Slot;
-- Getter of InstanceSpecification::slot.
--
-- A slot giving the value or values of a structural feature of the
-- instance. An instance specification can have one slot per structural
-- feature of its classifiers, including inherited features. It is not
-- necessary to model a slot for each structural feature, in which case
-- the instance specification is a partial description.
overriding function Get_Specification
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of InstanceSpecification::specification.
--
-- A specification of how to compute, derive, or construct the instance.
overriding procedure Set_Specification
(Self : not null access UML_Instance_Specification_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of InstanceSpecification::specification.
--
-- A specification of how to compute, derive, or construct the instance.
overriding function Get_Deployed_Element
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of DeploymentTarget::deployedElement.
--
-- The set of elements that are manifested in an Artifact that is involved
-- in Deployment to a DeploymentTarget.
overriding function Get_Deployment
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Deployments.Collections.Set_Of_UML_Deployment;
-- Getter of DeploymentTarget::deployment.
--
-- The set of Deployments for a DeploymentTarget.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Instance_Specification_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_Instance_Specification_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_Instance_Specification_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_Instance_Specification_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_Instance_Specification_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 Get_Owning_Template_Parameter
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Instance_Specification_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Instance_Specification_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Deployed_Element
(Self : not null access constant UML_Instance_Specification_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation DeploymentTarget::deployedElement.
--
-- Missing derivation for DeploymentTarget::/deployedElement :
-- PackageableElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Instance_Specification_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_Instance_Specification_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_Instance_Specification_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Is_Compatible_With
(Self : not null access constant UML_Instance_Specification_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Instance_Specification_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding procedure Enter_Element
(Self : not null access constant UML_Instance_Specification_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_Instance_Specification_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_Instance_Specification_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_Instance_Specifications;
|
redparavoz/ada-wiki | Ada | 6,827 | ads | -----------------------------------------------------------------------
-- wiki -- Ada Wiki Engine
-- Copyright (C) 2015, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.
-----------------------------------------------------------------------
-- == Wiki ==
-- The Wiki engine parses a Wiki text in several Wiki syntax such as <tt>MediaWiki</tt>,
-- <tt>Creole</tt>, <tt>Markdown</tt> and renders the result either in HTML, text or into
-- another Wiki format. The Wiki engine is used in two steps:
--
-- * The Wiki text is parsed according to its syntax to produce a Wiki Document instance.
-- * The Wiki document is then rendered by a renderer to produce the final HTML, text.
--
-- [images/ada-wiki.png]
--
-- The Ada Wiki engine is organized in several packages:
--
-- * The [Wiki_Streams Wiki stream] packages define the interface, types and operations
-- for the Wiki engine to read the Wiki or HTML content and for the Wiki renderer to generate
-- the HTML or text outputs.
-- * The Wiki parser is responsible for parsing HTML or Wiki content according to a
-- selected Wiki syntax. It builds the final Wiki document through filters and plugins.
-- * The [Wiki_Filters Wiki filters] provides a simple filter framework that allows to plug
-- specific filters when a Wiki document is parsed and processed. Filters are used for the
-- table of content generation, for the HTML filtering, to collect words or links
-- and so on.
-- * The [Wiki_Plugins Wiki plugins] defines the plugin interface that is used by the Wiki engine
-- to provide pluggable extensions in the Wiki. Plugins are used for the Wiki template
-- support, to hide some Wiki text content when it is rendered or to interact with
-- other systems.
-- * The Wiki documents and attributes are used for the representation of the Wiki
-- document after the Wiki content is parsed.
-- * The [Wiki_Render Wiki renderers] are the last packages which are used for the rendering
-- of the Wiki document to produce the final HTML or text.
--
-- @include wiki-documents.ads
-- @include wiki-attributes.ads
-- @include wiki-parsers.ads
package Wiki is
pragma Preelaborate;
-- Defines the possible wiki syntax supported by the parser.
type Wiki_Syntax
is (
-- Google wiki syntax http://code.google.com/p/support/wiki/WikiSyntax
SYNTAX_GOOGLE,
-- Creole wiki syntax http://www.wikicreole.org/wiki/Creole1.0
SYNTAX_CREOLE,
-- Dotclear syntax http://dotclear.org/documentation/2.0/usage/syntaxes
SYNTAX_DOTCLEAR,
-- PhpBB syntax http://wiki.phpbb.com/Help:Formatting
SYNTAX_PHPBB,
-- MediaWiki syntax http://www.mediawiki.org/wiki/Help:Formatting
SYNTAX_MEDIA_WIKI,
-- Markdown
SYNTAX_MARKDOWN,
-- A mix of the above
SYNTAX_MIX,
-- The input is plain possibly incorrect HTML.
SYNTAX_HTML);
-- Defines the possible text formats.
type Format_Type is (BOLD, ITALIC, CODE, SUPERSCRIPT, SUBSCRIPT, STRIKEOUT, PREFORMAT);
type Format_Map is array (Format_Type) of Boolean;
-- The possible HTML tags as described in HTML5 specification.
type Html_Tag is
(
-- Section 4.1 The root element
ROOT_HTML_TAG,
-- Section 4.2 Document metadata
HEAD_TAG, TITLE_TAG, BASE_TAG, LINK_TAG, META_TAG, STYLE_TAG,
-- Section 4.3 Sections
BODY_TAG, ARTICLE_TAG, SECTION_TAG, NAV_TAG, ASIDE_TAG,
H1_TAG, H2_TAG, H3_TAG, H4_TAG, H5_TAG, H6_TAG,
HEADER_TAG, FOOTER_TAG,
ADDRESS_TAG,
-- Section 4.4 Grouping content
P_TAG, HR_TAG, PRE_TAG, BLOCKQUOTE_TAG,
OL_TAG, UL_TAG, LI_TAG,
DL_TAG, DT_TAG, DD_TAG,
FIGURE_TAG, FIGCAPTION_TAG,
DIV_TAG, MAIN_TAG,
-- Section 4.5 Text-level semantics
A_TAG, EM_TAG, STRONG_TAG, SMALL_TAG,
S_TAG, CITE_TAG, Q_TAG, DFN_TAG, ABBR_TAG,
DATA_TAG, TIME_TAG, CODE_TAG, VAR_TAG, SAMP_TAG,
KBD_TAG, SUB_TAG, SUP_TAG,
I_TAG, B_TAG, U_TAG,
MARK_TAG, RUBY_TAG, RB_TAG, RT_TAG, RTC_TAG,
RP_TAG, BDI_TAG, BDO_TAG, SPAN_TAG,
BR_TAG, WBR_TAG,
-- Section 4.6 Edits
INS_TAG, DEL_TAG,
-- Section 4.7 Embedded content
IMG_TAG,
IFRAME_TAG,
EMBED_TAG,
OBJECT_TAG,
PARAM_TAG,
VIDEO_TAG,
AUDIO_TAG,
SOURCE_TAG,
TRACK_TAG,
MAP_TAG,
AREA_TAG,
-- Section 4.9 Tabular data
TABLE_TAG, CAPTION_TAG, COLGROUP_TAG, COL_TAG,
TBODY_TAG, THEAD_TAG, TFOOT_TAG,
TR_TAG, TD_TAG, TH_TAG,
-- Section 4.10 Forms
FORM_TAG, LABEL_TAG, INPUT_TAG,
BUTTON_TAG, SELECT_TAG, DATALIST_TAG, OPTGROUP_TAG,
OPTION_TAG, TEXTAREA_TAG, KEYGEN_TAG, OUTPUT_TAG,
PROGRESS_TAG, METER_TAG, FIELDSET_TAG, LEGEND_TAG,
-- Section 4.11 Scripting
SCRIPT_TAG, NOSCRIPT_TAG,
TEMPLATE_TAG, CANVAS_TAG,
-- Unknown tags
UNKNOWN_TAG
);
-- Find the tag from the tag name.
function Find_Tag (Name : in Wide_Wide_String) return Html_Tag;
type String_Access is access constant String;
-- Get the HTML tag name.
function Get_Tag_Name (Tag : in Html_Tag) return String_Access;
type Tag_Boolean_Array is array (Html_Tag) of Boolean;
No_End_Tag : constant Tag_Boolean_Array :=
(
BASE_TAG => True,
LINK_TAG => True,
META_TAG => True,
IMG_TAG => True,
HR_TAG => True,
BR_TAG => True,
WBR_TAG => True,
INPUT_TAG => True,
KEYGEN_TAG => True,
others => False);
Tag_Omission : constant Tag_Boolean_Array :=
(
-- Section 4.4 Grouping content
LI_TAG => True,
DT_TAG => True,
DD_TAG => True,
-- Section 4.5 Text-level semantics
RB_TAG => True,
RT_TAG => True,
RTC_TAG => True,
RP_TAG => True,
-- Section 4.9 Tabular data
TH_TAG => True,
TD_TAG => True,
TR_TAG => True,
TBODY_TAG => True,
THEAD_TAG => True,
TFOOT_TAG => True,
OPTGROUP_TAG => True,
OPTION_TAG => True,
others => False);
end Wiki;
|
reznikmm/matreshka | Ada | 3,612 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- 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.CMOF.Associations.Hash is
new AMF.Elements.Generic_Hash (CMOF_Association, CMOF_Association_Access);
|
AdaCore/libadalang | Ada | 1,147 | adb | with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.File_Paths; use GNATCOLL.File_Paths;
with Langkit_Support.Errors; use Langkit_Support.Errors;
with Libadalang.Preprocessing; use Libadalang.Preprocessing;
procedure Main is
Path : constant Any_Path := Parse_Path ("defs");
procedure Parse (Filename : String);
-----------
-- Parse --
-----------
procedure Parse (Filename : String) is
Data : Preprocessor_Data;
begin
Put_Line ("== " & Filename & " ==");
New_Line;
begin
Data := Parse_Preprocessor_Data_File (Filename, Path);
exception
when Exc : Syntax_Error | File_Read_Error =>
Put_Line (Exception_Name (Exc) & ": " & Exception_Message (Exc));
New_Line;
return;
end;
Dump (Data);
New_Line;
end Parse;
begin
Parse ("cannot-read-def-file.txt");
Parse ("invalid-def-1.txt");
Parse ("invalid-def-2.txt");
Parse ("invalid-def-3.txt");
Parse ("standard.txt");
Parse ("unknown-switch.txt");
Parse ("no-such-file.txt");
Put_Line ("Done.");
end Main;
|
zhmu/ananas | Ada | 178,919 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ W A R N --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2022, 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 Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
with Errout; use Errout;
with Exp_Code; use Exp_Code;
with Lib; use Lib;
with Lib.Xref; use Lib.Xref;
with Namet; use Namet;
with Nlists; use Nlists;
with Opt; use Opt;
with Par_SCO; use Par_SCO;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Ch8; use Sem_Ch8;
with Sem_Aux; use Sem_Aux;
with Sem_Eval; use Sem_Eval;
with Sem_Prag; use Sem_Prag;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Sinput; use Sinput;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
package body Sem_Warn is
-- The following table collects Id's of entities that are potentially
-- unreferenced. See Check_Unset_Reference for further details.
-- ??? Check_Unset_Reference has zero information about this table.
package Unreferenced_Entities is new Table.Table (
Table_Component_Type => Entity_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.Unreferenced_Entities_Initial,
Table_Increment => Alloc.Unreferenced_Entities_Increment,
Table_Name => "Unreferenced_Entities");
-- The following table collects potential warnings for IN OUT parameters
-- that are referenced but not modified. These warnings are processed when
-- the front end calls the procedure Output_Non_Modified_In_Out_Warnings.
-- The reason that we defer output of these messages is that we want to
-- detect the case where the relevant procedure is used as a generic actual
-- in an instantiation, since we suppress the warnings in this case. The
-- flag Used_As_Generic_Actual will be set in this case, but only at the
-- point of usage. Similarly, we suppress the message if the address of the
-- procedure is taken, where the flag Address_Taken may be set later.
package In_Out_Warnings is new Table.Table (
Table_Component_Type => Entity_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.In_Out_Warnings_Initial,
Table_Increment => Alloc.In_Out_Warnings_Increment,
Table_Name => "In_Out_Warnings");
--------------------------------------------------------
-- Handling of Warnings Off, Unmodified, Unreferenced --
--------------------------------------------------------
-- The functions Has_Warnings_Off, Has_Unmodified, Has_Unreferenced must
-- generally be used instead of Warnings_Off, Has_Pragma_Unmodified and
-- Has_Pragma_Unreferenced, as noted in the specs in Einfo.
-- In order to avoid losing warnings in -gnatw.w (warn on unnecessary
-- warnings off pragma) mode, i.e. to avoid false negatives, the code
-- must follow some important rules.
-- Call these functions as late as possible, after completing all other
-- tests, just before the warnings is given. For example, don't write:
-- if not Has_Warnings_Off (E)
-- and then some-other-predicate-on-E then ..
-- Instead the following is preferred
-- if some-other-predicate-on-E
-- and then Has_Warnings_Off (E)
-- This way if some-other-predicate is false, we avoid a false indication
-- that a Warnings (Off, E) pragma was useful in preventing a warning.
-- The second rule is that if both Has_Unmodified and Has_Warnings_Off, or
-- Has_Unreferenced and Has_Warnings_Off are called, make sure that the
-- call to Has_Unmodified/Has_Unreferenced comes first, this way we record
-- that the Warnings (Off) could have been Unreferenced or Unmodified. In
-- fact Has_Unmodified/Has_Unreferenced includes a test for Warnings Off,
-- and so a subsequent test is not needed anyway (though it is harmless).
-----------------------
-- Local Subprograms --
-----------------------
function Generic_Package_Spec_Entity (E : Entity_Id) return Boolean;
-- This returns true if the entity E is declared within a generic package.
-- The point of this is to detect variables which are not assigned within
-- the generic, but might be assigned outside the package for any given
-- instance. These are cases where we leave the warnings to be posted for
-- the instance, when we will know more.
function Goto_Spec_Entity (E : Entity_Id) return Entity_Id;
-- If E is a parameter entity for a subprogram body, then this function
-- returns the corresponding spec entity, if not, E is returned unchanged.
function Has_Pragma_Unmodified_Check_Spec (E : Entity_Id) return Boolean;
-- Tests Has_Pragma_Unmodified flag for entity E. If E is not a formal,
-- this is simply the setting of the flag Has_Pragma_Unmodified. If E is
-- a body formal, the setting of the flag in the corresponding spec is
-- also checked (and True returned if either flag is True).
function Has_Pragma_Unreferenced_Check_Spec (E : Entity_Id) return Boolean;
-- Tests Has_Pragma_Unreferenced flag for entity E. If E is not a formal,
-- this is simply the setting of the flag Has_Pragma_Unreferenced. If E is
-- a body formal, the setting of the flag in the corresponding spec is
-- also checked (and True returned if either flag is True).
function Is_Attribute_And_Known_Value_Comparison
(Op : Node_Id) return Boolean;
-- Determine whether operator Op denotes a comparison where the left
-- operand is an attribute reference and the value of the right operand is
-- known at compile time.
function Never_Set_In_Source_Check_Spec (E : Entity_Id) return Boolean;
-- Tests Never_Set_In_Source status for entity E. If E is not a formal,
-- this is simply the setting of the flag Never_Set_In_Source. If E is
-- a body formal, the setting of the flag in the corresponding spec is
-- also checked (and False returned if either flag is False).
function Operand_Has_Warnings_Suppressed (N : Node_Id) return Boolean;
-- This function traverses the expression tree represented by the node N
-- and determines if any sub-operand is a reference to an entity for which
-- the Warnings_Off flag is set. True is returned if such an entity is
-- encountered, and False otherwise.
function Referenced_Check_Spec (E : Entity_Id) return Boolean;
-- Tests Referenced status for entity E. If E is not a formal, this is
-- simply the setting of the flag Referenced. If E is a body formal, the
-- setting of the flag in the corresponding spec is also checked (and True
-- returned if either flag is True).
function Referenced_As_LHS_Check_Spec (E : Entity_Id) return Boolean;
-- Tests Referenced_As_LHS status for entity E. If E is not a formal, this
-- is simply the setting of the flag Referenced_As_LHS. If E is a body
-- formal, the setting of the flag in the corresponding spec is also
-- checked (and True returned if either flag is True).
function Referenced_As_Out_Parameter_Check_Spec
(E : Entity_Id) return Boolean;
-- Tests Referenced_As_Out_Parameter status for entity E. If E is not a
-- formal, this is simply the setting of Referenced_As_Out_Parameter. If E
-- is a body formal, the setting of the flag in the corresponding spec is
-- also checked (and True returned if either flag is True).
procedure Warn_On_Unreferenced_Entity
(Spec_E : Entity_Id;
Body_E : Entity_Id := Empty);
-- Output warnings for unreferenced entity E. For the case of an entry
-- formal, Body_E is the corresponding body entity for a particular
-- accept statement, and the message is posted on Body_E. In all other
-- cases, Body_E is ignored and must be Empty.
function Warnings_Off_Check_Spec (E : Entity_Id) return Boolean;
-- Returns True if Warnings_Off is set for the entity E or (in the case
-- where there is a Spec_Entity), Warnings_Off is set for the Spec_Entity.
--------------------------
-- Check_Code_Statement --
--------------------------
procedure Check_Code_Statement (N : Node_Id) is
begin
-- If volatile, nothing to worry about
if Is_Asm_Volatile (N) then
return;
end if;
-- Warn if no input or no output
Setup_Asm_Inputs (N);
if No (Asm_Input_Value) then
Error_Msg_F
("??code statement with no inputs should usually be Volatile!", N);
return;
end if;
Setup_Asm_Outputs (N);
if No (Asm_Output_Variable) then
Error_Msg_F
("??code statement with no outputs should usually be Volatile!", N);
return;
end if;
end Check_Code_Statement;
---------------------------------
-- Check_Infinite_Loop_Warning --
---------------------------------
-- The case we look for is a while loop which tests a local variable, where
-- there is no obvious direct or possible indirect update of the variable
-- within the body of the loop.
procedure Check_Infinite_Loop_Warning (Loop_Statement : Node_Id) is
Expression : Node_Id := Empty;
-- Set to WHILE or EXIT WHEN condition to be tested
Ref : Node_Id := Empty;
-- Reference in Expression to variable that might not be modified
-- in loop, indicating a possible infinite loop.
Var : Entity_Id := Empty;
-- Corresponding entity (entity of Ref)
Function_Call_Found : Boolean := False;
-- True if Find_Var found a function call in the condition
procedure Find_Var (N : Node_Id);
-- Inspect condition to see if it depends on a single entity reference.
-- If so, Ref is set to point to the reference node, and Var is set to
-- the referenced Entity.
function Has_Condition_Actions (Iter : Node_Id) return Boolean;
-- Determine whether iteration scheme Iter has meaningful condition
-- actions.
function Has_Indirection (T : Entity_Id) return Boolean;
-- If the controlling variable is an access type, or is a record type
-- with access components, assume that it is changed indirectly and
-- suppress the warning. As a concession to low-level programming, in
-- particular within Declib, we also suppress warnings on a record
-- type that contains components of type Address or Short_Address.
function Is_Suspicious_Function_Name (E : Entity_Id) return Boolean;
-- Given an entity name, see if the name appears to have something to
-- do with I/O or network stuff, and if so, return True. Used to kill
-- some false positives on a heuristic basis that such functions will
-- likely have some strange side effect dependencies. A rather strange
-- test, but warning messages are in the heuristics business.
function Test_Ref (N : Node_Id) return Traverse_Result;
-- Test for reference to variable in question. Returns Abandon if
-- matching reference found. Used in instantiation of No_Ref_Found.
function No_Ref_Found is new Traverse_Func (Test_Ref);
-- Function to traverse body of procedure. Returns Abandon if matching
-- reference found.
--------------
-- Find_Var --
--------------
procedure Find_Var (N : Node_Id) is
begin
-- Condition is a direct variable reference
if Is_Entity_Name (N) then
Ref := N;
Var := Entity (Ref);
-- Case of condition is a comparison with compile time known value
elsif Nkind (N) in N_Op_Compare then
if Compile_Time_Known_Value (Right_Opnd (N)) then
Find_Var (Left_Opnd (N));
elsif Compile_Time_Known_Value (Left_Opnd (N)) then
Find_Var (Right_Opnd (N));
-- Ignore any other comparison
else
return;
end if;
-- If condition is a negation, check its operand
elsif Nkind (N) = N_Op_Not then
Find_Var (Right_Opnd (N));
-- Case of condition is function call
elsif Nkind (N) = N_Function_Call then
Function_Call_Found := True;
-- Forget it if function name is not entity, who knows what
-- we might be calling?
if not Is_Entity_Name (Name (N)) then
return;
-- Forget it if function name is suspicious. A strange test
-- but warning generation is in the heuristics business.
elsif Is_Suspicious_Function_Name (Entity (Name (N))) then
return;
-- Forget it if function is marked Volatile_Function
elsif Is_Volatile_Function (Entity (Name (N))) then
return;
-- Forget it if warnings are suppressed on function entity
elsif Has_Warnings_Off (Entity (Name (N))) then
return;
-- Forget it if the parameter is not In
elsif Has_Out_Or_In_Out_Parameter (Entity (Name (N))) then
return;
end if;
-- OK, see if we have one argument
declare
PA : constant List_Id := Parameter_Associations (N);
begin
-- One argument, so check the argument
if Present (PA) and then List_Length (PA) = 1 then
if Nkind (First (PA)) = N_Parameter_Association then
Find_Var (Explicit_Actual_Parameter (First (PA)));
else
Find_Var (First (PA));
end if;
-- Not one argument
else
return;
end if;
end;
-- Any other kind of node is not something we warn for
else
return;
end if;
end Find_Var;
---------------------------
-- Has_Condition_Actions --
---------------------------
function Has_Condition_Actions (Iter : Node_Id) return Boolean is
Action : Node_Id;
begin
-- A call marker is not considered a meaningful action because it
-- acts as an annotation and has no runtime semantics.
Action := First (Condition_Actions (Iter));
while Present (Action) loop
if Nkind (Action) /= N_Call_Marker then
return True;
end if;
Next (Action);
end loop;
return False;
end Has_Condition_Actions;
---------------------
-- Has_Indirection --
---------------------
function Has_Indirection (T : Entity_Id) return Boolean is
Comp : Entity_Id;
Rec : Entity_Id;
begin
if Is_Access_Type (T) then
return True;
elsif Is_Private_Type (T)
and then Present (Full_View (T))
and then Is_Access_Type (Full_View (T))
then
return True;
elsif Is_Record_Type (T) then
Rec := T;
elsif Is_Private_Type (T)
and then Present (Full_View (T))
and then Is_Record_Type (Full_View (T))
then
Rec := Full_View (T);
else
return False;
end if;
Comp := First_Component (Rec);
while Present (Comp) loop
if Is_Access_Type (Etype (Comp))
or else Is_Descendant_Of_Address (Etype (Comp))
then
return True;
end if;
Next_Component (Comp);
end loop;
return False;
end Has_Indirection;
---------------------------------
-- Is_Suspicious_Function_Name --
---------------------------------
function Is_Suspicious_Function_Name (E : Entity_Id) return Boolean is
S : Entity_Id;
function Substring_Present (S : String) return Boolean;
-- Returns True if name buffer has given string delimited by non-
-- alphabetic characters or by end of string. S is lower case.
-----------------------
-- Substring_Present --
-----------------------
function Substring_Present (S : String) return Boolean is
Len : constant Natural := S'Length;
begin
for J in 1 .. Name_Len - (Len - 1) loop
if Name_Buffer (J .. J + (Len - 1)) = S
and then (J = 1 or else Name_Buffer (J - 1) not in 'a' .. 'z')
and then
(J + Len > Name_Len
or else Name_Buffer (J + Len) not in 'a' .. 'z')
then
return True;
end if;
end loop;
return False;
end Substring_Present;
-- Start of processing for Is_Suspicious_Function_Name
begin
S := E;
while Present (S) and then S /= Standard_Standard loop
Get_Name_String (Chars (S));
if Substring_Present ("io")
or else Substring_Present ("file")
or else Substring_Present ("network")
then
return True;
else
S := Scope (S);
end if;
end loop;
return False;
end Is_Suspicious_Function_Name;
--------------
-- Test_Ref --
--------------
function Test_Ref (N : Node_Id) return Traverse_Result is
begin
-- Waste of time to look at the expression we are testing
if N = Expression then
return Skip;
-- Direct reference to variable in question
elsif Is_Entity_Name (N)
and then Present (Entity (N))
and then Entity (N) = Var
then
-- If this is an lvalue, then definitely abandon, since
-- this could be a direct modification of the variable.
if Known_To_Be_Assigned (N) then
return Abandon;
end if;
-- If the condition contains a function call, we consider it may
-- be modified by side effects from a procedure call. Otherwise,
-- we consider the condition may not be modified, although that
-- might happen if Variable is itself a by-reference parameter,
-- and the procedure called modifies the global object referred to
-- by Variable, but we actually prefer to issue a warning in this
-- odd case. Note that the case where the procedure called has
-- visibility over Variable is treated in another case below.
if Function_Call_Found then
declare
P : Node_Id;
begin
P := N;
loop
P := Parent (P);
exit when P = Loop_Statement;
-- Abandon if at procedure call, or something strange is
-- going on (perhaps a node with no parent that should
-- have one but does not?) As always, for a warning we
-- prefer to just abandon the warning than get into the
-- business of complaining about the tree structure here.
if No (P)
or else Nkind (P) = N_Procedure_Call_Statement
then
return Abandon;
end if;
end loop;
end;
end if;
-- Reference to variable renaming variable in question
elsif Is_Entity_Name (N)
and then Present (Entity (N))
and then Ekind (Entity (N)) = E_Variable
and then Present (Renamed_Object (Entity (N)))
and then Is_Entity_Name (Renamed_Object (Entity (N)))
and then Entity (Renamed_Object (Entity (N))) = Var
and then Known_To_Be_Assigned (N)
then
return Abandon;
-- Call to subprogram
elsif Nkind (N) in N_Subprogram_Call then
-- If subprogram is within the scope of the entity we are dealing
-- with as the loop variable, then it could modify this parameter,
-- so we abandon in this case. In the case of a subprogram that is
-- not an entity we also abandon. The check for no entity being
-- present is a defense against previous errors.
if not Is_Entity_Name (Name (N))
or else No (Entity (Name (N)))
or else Scope_Within (Entity (Name (N)), Scope (Var))
then
return Abandon;
end if;
-- If any of the arguments are of type access to subprogram, then
-- we may have funny side effects, so no warning in this case.
declare
Actual : Node_Id;
begin
Actual := First_Actual (N);
while Present (Actual) loop
if Is_Access_Subprogram_Type (Etype (Actual)) then
return Abandon;
else
Next_Actual (Actual);
end if;
end loop;
end;
-- Declaration of the variable in question
elsif Nkind (N) = N_Object_Declaration
and then Defining_Identifier (N) = Var
then
return Abandon;
end if;
-- All OK, continue scan
return OK;
end Test_Ref;
-- Start of processing for Check_Infinite_Loop_Warning
begin
-- Skip processing if debug flag gnatd.w is set
if Debug_Flag_Dot_W then
return;
end if;
-- Deal with Iteration scheme present
declare
Iter : constant Node_Id := Iteration_Scheme (Loop_Statement);
begin
if Present (Iter) then
-- While iteration
if Present (Condition (Iter)) then
-- Skip processing for while iteration with conditions actions,
-- since they make it too complicated to get the warning right.
if Has_Condition_Actions (Iter) then
return;
end if;
-- Capture WHILE condition
Expression := Condition (Iter);
-- For Loop_Parameter_Specification, do not process, since loop
-- will always terminate. For Iterator_Specification, also do not
-- process. Either it will always terminate (e.g. "for X of
-- Some_Array ..."), or we can't tell if it's going to terminate
-- without looking at the iterator, so any warning here would be
-- noise.
elsif Present (Loop_Parameter_Specification (Iter))
or else Present (Iterator_Specification (Iter))
then
return;
end if;
end if;
end;
-- Check chain of EXIT statements, we only process loops that have a
-- single exit condition (either a single EXIT WHEN statement, or a
-- WHILE loop not containing any EXIT WHEN statements).
declare
Ident : constant Node_Id := Identifier (Loop_Statement);
Exit_Stmt : Node_Id;
begin
-- If we don't have a proper chain set, ignore call entirely. This
-- happens because of previous errors.
if No (Entity (Ident))
or else Ekind (Entity (Ident)) /= E_Loop
then
Check_Error_Detected;
return;
end if;
-- Otherwise prepare to scan list of EXIT statements
Exit_Stmt := First_Exit_Statement (Entity (Ident));
while Present (Exit_Stmt) loop
-- Check for EXIT WHEN
if Present (Condition (Exit_Stmt)) then
-- Quit processing if EXIT WHEN in WHILE loop, or more than
-- one EXIT WHEN statement present in the loop.
if Present (Expression) then
return;
-- Otherwise capture condition from EXIT WHEN statement
else
Expression := Condition (Exit_Stmt);
end if;
-- If an unconditional exit statement is the last statement in the
-- loop, assume that no warning is needed, without any attempt at
-- checking whether the exit is reachable.
elsif Exit_Stmt = Last (Statements (Loop_Statement)) then
return;
end if;
Exit_Stmt := Next_Exit_Statement (Exit_Stmt);
end loop;
end;
-- Return if no condition to test
if No (Expression) then
return;
end if;
-- Initial conditions met, see if condition is of right form
Find_Var (Expression);
-- Nothing to do if local variable from source not found. If it's a
-- renaming, it is probably renaming something too complicated to deal
-- with here.
if No (Var)
or else Ekind (Var) /= E_Variable
or else Is_Library_Level_Entity (Var)
or else not Comes_From_Source (Var)
or else Nkind (Parent (Var)) = N_Object_Renaming_Declaration
then
return;
-- Nothing to do if there is some indirection involved (assume that the
-- designated variable might be modified in some way we don't see).
-- However, if no function call was found, then we don't care about
-- indirections, because the condition must be something like "while X
-- /= null loop", so we don't care if X.all is modified in the loop.
elsif Function_Call_Found and then Has_Indirection (Etype (Var)) then
return;
-- Same sort of thing for volatile variable, might be modified by
-- some other task or by the operating system in some way.
elsif Is_Volatile (Var) then
return;
end if;
-- Filter out case of original statement sequence starting with delay.
-- We assume this is a multi-tasking program and that the condition
-- is affected by other threads (some kind of busy wait).
declare
Fstm : constant Node_Id :=
Original_Node (First (Statements (Loop_Statement)));
begin
if Nkind (Fstm) in N_Delay_Statement then
return;
end if;
end;
-- We have a variable reference of the right form, now we scan the loop
-- body to see if it looks like it might not be modified
if No_Ref_Found (Loop_Statement) = OK then
Error_Msg_NE
("??variable& is not modified in loop body!", Ref, Var);
Error_Msg_N
("\??possible infinite loop!", Ref);
end if;
end Check_Infinite_Loop_Warning;
----------------------------
-- Check_Low_Bound_Tested --
----------------------------
procedure Check_Low_Bound_Tested (Expr : Node_Id) is
procedure Check_Low_Bound_Tested_For (Opnd : Node_Id);
-- Determine whether operand Opnd denotes attribute 'First whose prefix
-- is a formal parameter. If this is the case, mark the entity of the
-- prefix as having its low bound tested.
--------------------------------
-- Check_Low_Bound_Tested_For --
--------------------------------
procedure Check_Low_Bound_Tested_For (Opnd : Node_Id) is
begin
if Nkind (Opnd) = N_Attribute_Reference
and then Attribute_Name (Opnd) = Name_First
and then Is_Entity_Name (Prefix (Opnd))
and then Present (Entity (Prefix (Opnd)))
and then Is_Formal (Entity (Prefix (Opnd)))
then
Set_Low_Bound_Tested (Entity (Prefix (Opnd)));
end if;
end Check_Low_Bound_Tested_For;
-- Start of processing for Check_Low_Bound_Tested
begin
if Comes_From_Source (Expr) then
Check_Low_Bound_Tested_For (Left_Opnd (Expr));
Check_Low_Bound_Tested_For (Right_Opnd (Expr));
end if;
end Check_Low_Bound_Tested;
----------------------
-- Check_References --
----------------------
procedure Check_References (E : Entity_Id; Anod : Node_Id := Empty) is
E1 : Entity_Id;
E1T : Entity_Id;
UR : Node_Id;
function Body_Formal
(E : Entity_Id;
Accept_Statement : Node_Id) return Entity_Id;
-- For an entry formal entity from an entry declaration, find the
-- corresponding body formal from the given accept statement.
function Generic_Body_Formal (E : Entity_Id) return Entity_Id;
-- Warnings on unused formals of subprograms are placed on the entity
-- in the subprogram body, which seems preferable because it suggests
-- a better codefix for GNAT Studio. The analysis of generic subprogram
-- bodies uses a different circuitry, so the choice for the proper
-- placement of the warning in the generic case takes place here, by
-- finding the body entity that corresponds to a formal in a spec.
procedure May_Need_Initialized_Actual (Ent : Entity_Id);
-- If an entity of a generic type has default initialization, then the
-- corresponding actual type should be fully initialized, or else there
-- will be uninitialized components in the instantiation, that might go
-- unreported. This routine marks the type of the uninitialized variable
-- appropriately to allow the compiler to emit an appropriate warning
-- in the instance. In a sense, the use of a type that requires full
-- initialization is a weak part of the generic contract.
function Missing_Subunits return Boolean;
-- We suppress warnings when there are missing subunits, because this
-- may generate too many false positives: entities in a parent may only
-- be referenced in one of the subunits. We make an exception for
-- subunits that contain no other stubs.
procedure Output_Reference_Error (M : String);
-- Used to output an error message. Deals with posting the error on the
-- body formal in the accept case.
function Publicly_Referenceable (Ent : Entity_Id) return Boolean;
-- This is true if the entity in question is potentially referenceable
-- from another unit. This is true for entities in packages that are at
-- the library level.
function Warnings_Off_E1 return Boolean;
-- Return True if Warnings_Off is set for E1, or for its Etype (E1T),
-- or for the base type of E1T.
-----------------
-- Body_Formal --
-----------------
function Body_Formal
(E : Entity_Id;
Accept_Statement : Node_Id) return Entity_Id
is
Body_Param : Node_Id;
Body_E : Entity_Id;
begin
-- Loop to find matching parameter in accept statement
Body_Param := First (Parameter_Specifications (Accept_Statement));
while Present (Body_Param) loop
Body_E := Defining_Identifier (Body_Param);
if Chars (Body_E) = Chars (E) then
return Body_E;
end if;
Next (Body_Param);
end loop;
-- Should never fall through, should always find a match
raise Program_Error;
end Body_Formal;
-------------------------
-- Generic_Body_Formal --
-------------------------
function Generic_Body_Formal (E : Entity_Id) return Entity_Id is
Gen_Decl : constant Node_Id := Unit_Declaration_Node (Scope (E));
Gen_Body : constant Entity_Id := Corresponding_Body (Gen_Decl);
Form : Entity_Id;
begin
if No (Gen_Body) then
return E;
else
Form := First_Entity (Gen_Body);
while Present (Form) loop
if Chars (Form) = Chars (E) then
return Form;
end if;
Next_Entity (Form);
end loop;
end if;
-- Should never fall through, should always find a match
raise Program_Error;
end Generic_Body_Formal;
---------------------------------
-- May_Need_Initialized_Actual --
---------------------------------
procedure May_Need_Initialized_Actual (Ent : Entity_Id) is
T : constant Entity_Id := Etype (Ent);
Par : constant Node_Id := Parent (T);
begin
if not Is_Generic_Type (T) then
null;
elsif (Nkind (Par)) = N_Private_Extension_Declaration then
-- We only indicate the first such variable in the generic.
if No (Uninitialized_Variable (Par)) then
Set_Uninitialized_Variable (Par, Ent);
end if;
elsif (Nkind (Par)) = N_Formal_Type_Declaration
and then Nkind (Formal_Type_Definition (Par)) =
N_Formal_Private_Type_Definition
then
if No (Uninitialized_Variable (Formal_Type_Definition (Par))) then
Set_Uninitialized_Variable (Formal_Type_Definition (Par), Ent);
end if;
end if;
end May_Need_Initialized_Actual;
----------------------
-- Missing_Subunits --
----------------------
function Missing_Subunits return Boolean is
D : Node_Id;
begin
if not Unloaded_Subunits then
-- Normal compilation, all subunits are present
return False;
elsif E /= Main_Unit_Entity then
-- No warnings on a stub that is not the main unit
return True;
elsif Nkind (Unit_Declaration_Node (E)) in N_Proper_Body then
D := First (Declarations (Unit_Declaration_Node (E)));
while Present (D) loop
-- No warnings if the proper body contains nested stubs
if Nkind (D) in N_Body_Stub then
return True;
end if;
Next (D);
end loop;
return False;
else
-- Missing stubs elsewhere
return True;
end if;
end Missing_Subunits;
----------------------------
-- Output_Reference_Error --
----------------------------
procedure Output_Reference_Error (M : String) is
begin
-- Never issue messages for internal names or renamings
if Is_Internal_Name (Chars (E1))
or else Nkind (Parent (E1)) = N_Object_Renaming_Declaration
then
return;
end if;
-- Don't output message for IN OUT formal unless we have the warning
-- flag specifically set. It is a bit odd to distinguish IN OUT
-- formals from other cases. This distinction is historical in
-- nature. Warnings for IN OUT formals were added fairly late.
if Ekind (E1) = E_In_Out_Parameter
and then not Check_Unreferenced_Formals
then
return;
end if;
-- Other than accept case, post error on defining identifier
if No (Anod) then
Error_Msg_N (M, E1);
-- Accept case, find body formal to post the message
else
Error_Msg_NE (M, Body_Formal (E1, Accept_Statement => Anod), E1);
end if;
end Output_Reference_Error;
----------------------------
-- Publicly_Referenceable --
----------------------------
function Publicly_Referenceable (Ent : Entity_Id) return Boolean is
P : Node_Id;
Prev : Node_Id;
begin
-- A formal parameter is never referenceable outside the body of its
-- subprogram or entry.
if Is_Formal (Ent) then
return False;
end if;
-- Examine parents to look for a library level package spec. But if
-- we find a body or block or other similar construct along the way,
-- we cannot be referenced.
Prev := Ent;
P := Parent (Ent);
loop
case Nkind (P) is
-- If we get to top of tree, then publicly referenceable
when N_Empty =>
return True;
-- If we reach a generic package declaration, then always
-- consider this referenceable, since any instantiation will
-- have access to the entities in the generic package. Note
-- that the package itself may not be instantiated, but then
-- we will get a warning for the package entity.
-- Note that generic formal parameters are themselves not
-- publicly referenceable in an instance, and warnings on them
-- are useful.
when N_Generic_Package_Declaration =>
return
not Is_List_Member (Prev)
or else List_Containing (Prev) /=
Generic_Formal_Declarations (P);
-- Similarly, the generic formals of a generic subprogram are
-- not accessible.
when N_Generic_Subprogram_Declaration =>
if Is_List_Member (Prev)
and then List_Containing (Prev) =
Generic_Formal_Declarations (P)
then
return False;
else
P := Parent (P);
end if;
-- If we reach a subprogram body, entity is not referenceable
-- unless it is the defining entity of the body. This will
-- happen, e.g. when a function is an attribute renaming that
-- is rewritten as a body.
when N_Subprogram_Body =>
if Ent /= Defining_Entity (P) then
return False;
else
P := Parent (P);
end if;
-- If we reach any other body, definitely not referenceable
when N_Block_Statement
| N_Entry_Body
| N_Package_Body
| N_Protected_Body
| N_Subunit
| N_Task_Body
=>
return False;
-- For all other cases, keep looking up tree
when others =>
Prev := P;
P := Parent (P);
end case;
end loop;
end Publicly_Referenceable;
---------------------
-- Warnings_Off_E1 --
---------------------
function Warnings_Off_E1 return Boolean is
begin
return Has_Warnings_Off (E1T)
or else Has_Warnings_Off (Base_Type (E1T))
or else Warnings_Off_Check_Spec (E1);
end Warnings_Off_E1;
-- Start of processing for Check_References
begin
Process_Deferred_References;
-- No messages if warnings are suppressed, or if we have detected any
-- real errors so far (this last check avoids junk messages resulting
-- from errors, e.g. a subunit that is not loaded).
if Warning_Mode = Suppress or else Serious_Errors_Detected /= 0 then
return;
end if;
-- We also skip the messages if any subunits were not loaded (see
-- comment in Sem_Ch10 to understand how this is set, and why it is
-- necessary to suppress the warnings in this case).
if Missing_Subunits then
return;
end if;
-- Otherwise loop through entities, looking for suspicious stuff
E1 := First_Entity (E);
while Present (E1) loop
E1T := Etype (E1);
-- We are only interested in source entities. We also don't issue
-- warnings within instances, since the proper place for such
-- warnings is on the template when it is compiled, and we don't
-- issue warnings for variables with names like Junk, Discard etc.
if Comes_From_Source (E1)
and then Instantiation_Location (Sloc (E1)) = No_Location
then
-- We are interested in variables and out/in-out parameters, but
-- we exclude protected types, too complicated to worry about.
if Ekind (E1) = E_Variable
or else
(Ekind (E1) in E_Out_Parameter | E_In_Out_Parameter
and then not Is_Protected_Type (Current_Scope))
then
-- If the formal has a class-wide type, retrieve its type
-- because checks below depend on its private nature.
if Is_Class_Wide_Type (E1T) then
E1T := Etype (E1T);
end if;
-- Case of an unassigned variable
-- First gather any Unset_Reference indication for E1. In the
-- case of an 'out' parameter, it is the Spec_Entity that is
-- relevant.
if Ekind (E1) = E_Out_Parameter
and then Present (Spec_Entity (E1))
then
UR := Unset_Reference (Spec_Entity (E1));
else
UR := Unset_Reference (E1);
end if;
-- Special processing for access types
if Present (UR) and then Is_Access_Type (E1T) then
-- For access types, the only time we made a UR entry was
-- for a dereference, and so we post the appropriate warning
-- here (note that the dereference may not be explicit in
-- the source, for example in the case of a dispatching call
-- with an anonymous access controlling formal, or of an
-- assignment of a pointer involving discriminant check on
-- the designated object).
if not Warnings_Off_E1 then
Error_Msg_NE ("??& may be null!", UR, E1);
end if;
goto Continue;
-- Case of variable that could be a constant. Note that we
-- never signal such messages for generic package entities,
-- since a given instance could have modifications outside
-- the package.
-- Note that we used to check Address_Taken here, but we don't
-- want to do that since it can be set for non-source cases,
-- e.g. the Unrestricted_Access from a valid attribute, and
-- the wanted effect is included in Never_Set_In_Source.
elsif Warn_On_Constant
and then Ekind (E1) = E_Variable
and then Has_Initial_Value (E1)
and then Never_Set_In_Source_Check_Spec (E1)
and then not Generic_Package_Spec_Entity (E1)
then
-- A special case, if this variable is volatile and not
-- imported, it is not helpful to tell the programmer
-- to mark the variable as constant, since this would be
-- illegal by virtue of RM C.6(13). Instead we suggest
-- using pragma Export (can't be Import because of the
-- initial value).
if (Is_Volatile (E1) or else Has_Volatile_Components (E1))
and then not Is_Imported (E1)
then
Error_Msg_N
("?k?& is not modified, consider pragma Export for "
& "volatile variable!", E1);
-- Another special case, Exception_Occurrence, this catches
-- the case of exception choice (and a bit more too, but not
-- worth doing more investigation here).
elsif Is_RTE (E1T, RE_Exception_Occurrence) then
null;
-- Here we give the warning if referenced and no pragma
-- Unreferenced or Unmodified is present.
else
-- Variable case
if Ekind (E1) = E_Variable then
if Referenced_Check_Spec (E1)
and then not Has_Pragma_Unreferenced_Check_Spec (E1)
and then not Has_Pragma_Unmodified_Check_Spec (E1)
then
if not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
Error_Msg_N -- CODEFIX
("?k?& is not modified, "
& "could be declared constant!",
E1);
end if;
end if;
end if;
end if;
-- Other cases of a variable or parameter never set in source
elsif Never_Set_In_Source_Check_Spec (E1)
-- No warning if warning for this case turned off
and then Warn_On_No_Value_Assigned
-- No warning if address taken somewhere
and then not Address_Taken (E1)
-- No warning if explicit initial value
and then not Has_Initial_Value (E1)
-- No warning for generic package spec entities, since we
-- might set them in a child unit or something like that
and then not Generic_Package_Spec_Entity (E1)
-- No warning if fully initialized type, except that for
-- this purpose we do not consider access types to qualify
-- as fully initialized types (relying on an access type
-- variable being null when it is never set is a bit odd).
-- Also we generate warning for an out parameter that is
-- never referenced, since again it seems odd to rely on
-- default initialization to set an out parameter value.
and then (Is_Access_Type (E1T)
or else Ekind (E1) = E_Out_Parameter
or else not Is_Fully_Initialized_Type (E1T))
then
-- Do not output complaint about never being assigned a
-- value if a pragma Unmodified applies to the variable
-- we are examining, or if it is a parameter, if there is
-- a pragma Unreferenced for the corresponding spec, or
-- if the type is marked as having unreferenced objects.
-- The last is a little peculiar, but better too few than
-- too many warnings in this situation.
if Has_Pragma_Unreferenced_Objects (E1T)
or else Has_Pragma_Unmodified_Check_Spec (E1)
then
null;
-- IN OUT parameter case where parameter is referenced. We
-- separate this out, since this is the case where we delay
-- output of the warning until more information is available
-- (about use in an instantiation or address being taken).
elsif Ekind (E1) = E_In_Out_Parameter
and then Referenced_Check_Spec (E1)
then
-- Suppress warning if private type, and the procedure
-- has a separate declaration in a different unit. This
-- is the case where the client of a package sees only
-- the private type, and it may be quite reasonable
-- for the logical view to be IN OUT, even if the
-- implementation ends up using access types or some
-- other method to achieve the local effect of a
-- modification. On the other hand if the spec and body
-- are in the same unit, we are in the package body and
-- there we have less excuse for a junk IN OUT parameter.
if Has_Private_Declaration (E1T)
and then Present (Spec_Entity (E1))
and then not In_Same_Source_Unit (E1, Spec_Entity (E1))
then
null;
-- Suppress warning for any parameter of a dispatching
-- operation, since it is quite reasonable to have an
-- operation that is overridden, and for some subclasses
-- needs the formal to be IN OUT and for others happens
-- not to assign it.
elsif Is_Dispatching_Operation
(Scope (Goto_Spec_Entity (E1)))
then
null;
-- Suppress warning if composite type contains any access
-- component, since the logical effect of modifying a
-- parameter may be achieved by modifying a referenced
-- object. This rationale does not apply to private
-- types, so we warn in that case.
elsif Is_Composite_Type (E1T)
and then not Is_Private_Type (E1T)
and then Has_Access_Values (E1T)
then
null;
-- Suppress warning on formals of an entry body. All
-- references are attached to the formal in the entry
-- declaration, which are marked Is_Entry_Formal.
elsif Ekind (Scope (E1)) = E_Entry
and then not Is_Entry_Formal (E1)
then
null;
-- OK, looks like warning for an IN OUT parameter that
-- could be IN makes sense, but we delay the output of
-- the warning, pending possibly finding out later on
-- that the associated subprogram is used as a generic
-- actual, or its address/access is taken. In these two
-- cases, we suppress the warning because the context may
-- force use of IN OUT, even if in this particular case
-- the formal is not modified.
else
-- Suppress the warnings for a junk name
if not Has_Junk_Name (E1) then
In_Out_Warnings.Append (E1);
end if;
end if;
-- Other cases of formals
elsif Is_Formal (E1) then
if not Is_Trivial_Subprogram (Scope (E1)) then
if Referenced_Check_Spec (E1) then
if not Has_Pragma_Unmodified_Check_Spec (E1)
and then not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
Output_Reference_Error
("?f?formal parameter& is read but "
& "never assigned!");
end if;
elsif not Has_Pragma_Unreferenced_Check_Spec (E1)
and then not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
Output_Reference_Error
("?f?formal parameter& is not referenced!");
end if;
end if;
-- Case of variable
else
if Referenced (E1) then
if not Has_Unmodified (E1)
and then not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
if Is_Access_Type (E1T)
or else
not Is_Partially_Initialized_Type (E1T, False)
then
Output_Reference_Error
("?v?variable& is read but never assigned!");
end if;
May_Need_Initialized_Actual (E1);
end if;
elsif not Has_Unreferenced (E1)
and then not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
Output_Reference_Error -- CODEFIX
("?v?variable& is never read and never assigned!");
end if;
-- Deal with special case where this variable is hidden
-- by a loop variable.
if Ekind (E1) = E_Variable
and then Present (Hiding_Loop_Variable (E1))
and then not Warnings_Off_E1
then
Error_Msg_N
("?v?for loop implicitly declares loop variable!",
Hiding_Loop_Variable (E1));
Error_Msg_Sloc := Sloc (E1);
Error_Msg_N
("\?v?declaration hides & declared#!",
Hiding_Loop_Variable (E1));
end if;
end if;
goto Continue;
end if;
-- Check for unset reference. If type of object has
-- preelaborable initialization, warning is misleading.
if Warn_On_No_Value_Assigned
and then Present (UR)
and then not Known_To_Have_Preelab_Init (Etype (E1))
then
-- For other than access type, go back to original node to
-- deal with case where original unset reference has been
-- rewritten during expansion.
-- In some cases, the original node may be a type
-- conversion, a qualification or an attribute reference and
-- in this case we want the object entity inside. Same for
-- an expression with actions.
UR := Original_Node (UR);
loop
if Nkind (UR) in N_Expression_With_Actions
| N_Qualified_Expression
| N_Type_Conversion
then
UR := Expression (UR);
elsif Nkind (UR) = N_Attribute_Reference then
UR := Prefix (UR);
else
exit;
end if;
end loop;
-- Don't issue warning if appearing inside Initial_Condition
-- pragma or aspect, since that expression is not evaluated
-- at the point where it occurs in the source.
if In_Pragma_Expression (UR, Name_Initial_Condition) then
goto Continue;
end if;
-- Here we issue the warning, all checks completed
-- If we have a return statement, this was a case of an OUT
-- parameter not being set at the time of the return. (Note:
-- it can't be N_Extended_Return_Statement, because those
-- are only for functions, and functions do not allow OUT
-- parameters.)
if not Is_Trivial_Subprogram (Scope (E1)) then
if Nkind (UR) = N_Simple_Return_Statement
and then not Has_Pragma_Unmodified_Check_Spec (E1)
then
if not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
Error_Msg_NE
("?v?OUT parameter& not set before return",
UR, E1);
end if;
-- If the unset reference is a selected component
-- prefix from source, mention the component as well.
-- If the selected component comes from expansion, all
-- we know is that the entity is not fully initialized
-- at the point of the reference. Locate a random
-- uninitialized component to get a better message.
elsif Nkind (Parent (UR)) = N_Selected_Component then
-- Suppress possibly superfluous warning if component
-- is known to exist and is partially initialized.
if not Has_Discriminants (Etype (E1))
and then
Is_Partially_Initialized_Type
(Etype (Parent (UR)), False)
then
goto Continue;
end if;
Error_Msg_Node_2 := Selector_Name (Parent (UR));
if not Comes_From_Source (Parent (UR)) then
declare
Comp : Entity_Id;
begin
Comp := First_Component (E1T);
while Present (Comp) loop
if Nkind (Parent (Comp)) =
N_Component_Declaration
and then No (Expression (Parent (Comp)))
then
Error_Msg_Node_2 := Comp;
exit;
end if;
Next_Component (Comp);
end loop;
end;
end if;
-- Issue proper warning. This is a case of referencing
-- a variable before it has been explicitly assigned.
-- For access types, UR was only set for dereferences,
-- so the issue is that the value may be null.
if not Warnings_Off_E1 then
if Is_Access_Type (Etype (Parent (UR))) then
Error_Msg_N ("??`&.&` may be null!", UR);
else
Error_Msg_N
("??`&.&` may be referenced before "
& "it has a value!", UR);
end if;
end if;
-- All other cases of unset reference active
elsif not Warnings_Off_E1 then
Error_Msg_N
("??& may be referenced before it has a value!", UR);
end if;
end if;
goto Continue;
end if;
end if;
-- Then check for unreferenced entities. Note that we are only
-- interested in entities whose Referenced flag is not set.
if not Referenced_Check_Spec (E1)
-- If Referenced_As_LHS is set, then that's still interesting
-- (potential "assigned but never read" case), but not if we
-- have pragma Unreferenced, which cancels this warning.
and then (not Referenced_As_LHS_Check_Spec (E1)
or else not Has_Unreferenced (E1))
-- Check that warnings on unreferenced entities are enabled
and then
((Check_Unreferenced and then not Is_Formal (E1))
-- Case of warning on unreferenced formal
or else (Check_Unreferenced_Formals and then Is_Formal (E1))
-- Case of warning on unread variables modified by an
-- assignment, or an OUT parameter if it is the only one.
or else (Warn_On_Modified_Unread
and then Referenced_As_LHS_Check_Spec (E1))
-- Case of warning on any unread OUT parameter (note such
-- indications are only set if the appropriate warning
-- options were set, so no need to recheck here.)
or else Referenced_As_Out_Parameter_Check_Spec (E1))
-- All other entities, including local packages that cannot be
-- referenced from elsewhere, including those declared within a
-- package body.
and then (Is_Object (E1)
or else Is_Type (E1)
or else Ekind (E1) = E_Label
or else Ekind (E1) in E_Exception
| E_Named_Integer
| E_Named_Real
or else Is_Overloadable (E1)
-- Package case, if the main unit is a package spec
-- or generic package spec, then there may be a
-- corresponding body that references this package
-- in some other file. Otherwise we can be sure
-- that there is no other reference.
or else
(Ekind (E1) = E_Package
and then
not Is_Package_Or_Generic_Package
(Cunit_Entity (Current_Sem_Unit))))
-- Exclude instantiations, since there is no reason why every
-- entity in an instantiation should be referenced.
and then Instantiation_Location (Sloc (E1)) = No_Location
-- Exclude formal parameters from bodies if the corresponding
-- spec entity has been referenced in the case where there is
-- a separate spec.
and then not (Is_Formal (E1)
and then Ekind (Scope (E1)) = E_Subprogram_Body
and then Present (Spec_Entity (E1))
and then Referenced (Spec_Entity (E1)))
-- Consider private type referenced if full view is referenced.
-- If there is not full view, this is a generic type on which
-- warnings are also useful.
and then
not (Is_Private_Type (E1)
and then Present (Full_View (E1))
and then Referenced (Full_View (E1)))
-- Don't worry about full view, only about private type
and then not Has_Private_Declaration (E1)
-- Eliminate dispatching operations from consideration, we
-- cannot tell if these are referenced or not in any easy
-- manner (note this also catches Adjust/Finalize/Initialize).
and then not Is_Dispatching_Operation (E1)
-- Check entity that can be publicly referenced (we do not give
-- messages for such entities, since there could be other
-- units, not involved in this compilation, that contain
-- relevant references.
and then not Publicly_Referenceable (E1)
-- Class wide types are marked as source entities, but they are
-- not really source entities, and are always created, so we do
-- not care if they are not referenced.
and then Ekind (E1) /= E_Class_Wide_Type
-- Objects other than parameters of task types are allowed to
-- be non-referenced, since they start up tasks.
and then ((Ekind (E1) /= E_Variable
and then Ekind (E1) /= E_Constant
and then Ekind (E1) /= E_Component)
-- Check that E1T is not a task or a composite type
-- with a task component.
or else not Has_Task (E1T))
-- For subunits, only place warnings on the main unit itself,
-- since parent units are not completely compiled.
and then (Nkind (Unit (Cunit (Main_Unit))) /= N_Subunit
or else Get_Source_Unit (E1) = Main_Unit)
-- No warning on a return object, because these are often
-- created with a single expression and an implicit return.
-- If the object is a variable there will be a warning
-- indicating that it could be declared constant.
and then not
(Ekind (E1) = E_Constant and then Is_Return_Object (E1))
then
-- Suppress warnings in internal units if not in -gnatg mode
-- (these would be junk warnings for an applications program,
-- since they refer to problems in internal units).
if GNAT_Mode or else not In_Internal_Unit (E1) then
-- We do not immediately flag the error. This is because we
-- have not expanded generic bodies yet, and they may have
-- the missing reference. So instead we park the entity on a
-- list, for later processing. However for the case of an
-- accept statement we want to output messages now, since
-- we know we already have all information at hand, and we
-- also want to have separate warnings for each accept
-- statement for the same entry.
if Present (Anod) then
pragma Assert (Is_Formal (E1));
-- The unreferenced entity is E1, but post the warning
-- on the body entity for this accept statement.
if not Warnings_Off_E1 then
Warn_On_Unreferenced_Entity
(E1, Body_Formal (E1, Accept_Statement => Anod));
end if;
elsif not Warnings_Off_E1
and then not Has_Junk_Name (E1)
then
if Is_Formal (E1)
and then Nkind (Unit_Declaration_Node (Scope (E1)))
= N_Generic_Subprogram_Declaration
then
Unreferenced_Entities.Append
(Generic_Body_Formal (E1));
else
Unreferenced_Entities.Append (E1);
end if;
end if;
end if;
-- Generic units are referenced in the generic body, but if they
-- are not public and never instantiated we want to force a
-- warning on them. We treat them as redundant constructs to
-- minimize noise.
elsif Is_Generic_Subprogram (E1)
and then not Is_Instantiated (E1)
and then not Publicly_Referenceable (E1)
and then Instantiation_Depth (Sloc (E1)) = 0
and then Warn_On_Redundant_Constructs
then
if not Warnings_Off_E1 and then not Has_Junk_Name (E1) then
Unreferenced_Entities.Append (E1);
-- Force warning on entity
Set_Referenced (E1, False);
end if;
end if;
end if;
-- Recurse into nested package or block. Do not recurse into a formal
-- package, because the corresponding body is not analyzed.
<<Continue>>
if (Is_Package_Or_Generic_Package (E1)
and then Nkind (Parent (E1)) = N_Package_Specification
and then
Nkind (Original_Node (Unit_Declaration_Node (E1))) /=
N_Formal_Package_Declaration)
or else Ekind (E1) = E_Block
then
Check_References (E1);
end if;
Next_Entity (E1);
end loop;
end Check_References;
---------------------------
-- Check_Unset_Reference --
---------------------------
procedure Check_Unset_Reference (N : Node_Id) is
Typ : constant Entity_Id := Etype (N);
function Is_OK_Fully_Initialized return Boolean;
-- This function returns true if the given node N is fully initialized
-- so that the reference is safe as far as this routine is concerned.
-- Safe generally means that the type of N is a fully initialized type.
-- The one special case is that for access types, which are always fully
-- initialized, we don't consider a dereference OK since it will surely
-- be dereferencing a null value, which won't do.
function Prefix_Has_Dereference (Pref : Node_Id) return Boolean;
-- Used to test indexed or selected component or slice to see if the
-- evaluation of the prefix depends on a dereference, and if so, returns
-- True, in which case we always check the prefix, even if we know that
-- the referenced component is initialized. Pref is the prefix to test.
-----------------------------
-- Is_OK_Fully_Initialized --
-----------------------------
function Is_OK_Fully_Initialized return Boolean is
begin
if Is_Access_Type (Typ) and then Is_Dereferenced (N) then
return False;
-- A type subject to pragma Default_Initial_Condition may be fully
-- default initialized depending on inheritance and the argument of
-- the pragma (SPARK RM 3.1 and SPARK RM 7.3.3).
elsif Has_Fully_Default_Initializing_DIC_Pragma (Typ) then
return True;
else
return Is_Fully_Initialized_Type (Typ);
end if;
end Is_OK_Fully_Initialized;
----------------------------
-- Prefix_Has_Dereference --
----------------------------
function Prefix_Has_Dereference (Pref : Node_Id) return Boolean is
begin
-- If prefix is of an access type, it certainly needs a dereference
if Is_Access_Type (Etype (Pref)) then
return True;
-- If prefix is explicit dereference, that's a dereference for sure
elsif Nkind (Pref) = N_Explicit_Dereference then
return True;
-- If prefix is itself a component reference or slice check prefix
elsif Nkind (Pref) = N_Slice
or else Nkind (Pref) = N_Indexed_Component
or else Nkind (Pref) = N_Selected_Component
then
return Prefix_Has_Dereference (Prefix (Pref));
-- All other cases do not involve a dereference
else
return False;
end if;
end Prefix_Has_Dereference;
-- Start of processing for Check_Unset_Reference
begin
-- Nothing to do if warnings suppressed
if Warning_Mode = Suppress then
return;
end if;
-- Nothing to do for numeric or string literal. Do this test early to
-- save time in a common case (it does not matter that we do not include
-- character literal here, since that will be caught later on in the
-- when others branch of the case statement).
if Nkind (N) in N_Numeric_Or_String_Literal then
return;
end if;
-- Ignore reference unless it comes from source. Almost always if we
-- have a reference from generated code, it is bogus (e.g. calls to init
-- procs to set default discriminant values).
if not Comes_From_Source (Original_Node (N)) then
return;
end if;
-- Otherwise see what kind of node we have. If the entity already has an
-- unset reference, it is not necessarily the earliest in the text,
-- because resolution of the prefix of selected components is completed
-- before the resolution of the selected component itself. As a result,
-- given (R /= null and then R.X > 0), the occurrences of R are examined
-- in right-to-left order. If there is already an unset reference, we
-- check whether N is earlier before proceeding.
case Nkind (N) is
-- For identifier or expanded name, examine the entity involved
when N_Expanded_Name
| N_Identifier
=>
declare
E : constant Entity_Id := Entity (N);
begin
if Ekind (E) in E_Variable | E_Out_Parameter
and then Never_Set_In_Source_Check_Spec (E)
and then not Has_Initial_Value (E)
and then (No (Unset_Reference (E))
or else
Earlier_In_Extended_Unit
(Sloc (N), Sloc (Unset_Reference (E))))
and then not Has_Pragma_Unmodified_Check_Spec (E)
and then not Warnings_Off_Check_Spec (E)
and then not Has_Junk_Name (E)
then
-- We may have an unset reference. The first test is whether
-- this is an access to a discriminant of a record or a
-- component with default initialization. Both of these
-- cases can be ignored, since the actual object that is
-- referenced is definitely initialized. Note that this
-- covers the case of reading discriminants of an OUT
-- parameter, which is OK even in Ada 83.
-- Note that we are only interested in a direct reference to
-- a record component here. If the reference is through an
-- access type, then the access object is being referenced,
-- not the record, and still deserves an unset reference.
if Nkind (Parent (N)) = N_Selected_Component
and not Is_Access_Type (Typ)
then
declare
ES : constant Entity_Id :=
Entity (Selector_Name (Parent (N)));
begin
if Ekind (ES) = E_Discriminant
or else
(Present (Declaration_Node (ES))
and then
Present (Expression (Declaration_Node (ES))))
then
return;
end if;
end;
end if;
-- Exclude fully initialized types
if Is_OK_Fully_Initialized then
return;
end if;
-- Here we have a potential unset reference. But before we
-- get worried about it, we have to make sure that the
-- entity declaration is in the same procedure as the
-- reference, since if they are in separate procedures, then
-- we have no idea about sequential execution.
-- The tests in the loop below catch all such cases, but do
-- allow the reference to appear in a loop, block, or
-- package spec that is nested within the declaring scope.
-- As always, it is possible to construct cases where the
-- warning is wrong, that is why it is a warning.
Potential_Unset_Reference : declare
SR : Entity_Id;
SE : constant Entity_Id := Scope (E);
function Within_Postcondition return Boolean;
-- Returns True if N is within a Postcondition, a
-- Refined_Post, an Ensures component in a Test_Case,
-- or a Contract_Cases.
--------------------------
-- Within_Postcondition --
--------------------------
function Within_Postcondition return Boolean is
Nod, P : Node_Id;
begin
Nod := Parent (N);
while Present (Nod) loop
if Nkind (Nod) = N_Pragma
and then
Pragma_Name_Unmapped (Nod)
in Name_Postcondition
| Name_Refined_Post
| Name_Contract_Cases
then
return True;
elsif Present (Parent (Nod)) then
P := Parent (Nod);
if Nkind (P) = N_Pragma
and then Pragma_Name (P) =
Name_Test_Case
and then Nod = Test_Case_Arg (P, Name_Ensures)
then
return True;
end if;
end if;
Nod := Parent (Nod);
end loop;
return False;
end Within_Postcondition;
-- Start of processing for Potential_Unset_Reference
begin
SR := Current_Scope;
while SR /= SE loop
if SR = Standard_Standard
or else Is_Subprogram (SR)
or else Is_Concurrent_Body (SR)
or else Is_Concurrent_Type (SR)
then
return;
end if;
SR := Scope (SR);
end loop;
-- Case of reference has an access type. This is a
-- special case since access types are always set to null
-- so cannot be truly uninitialized, but we still want to
-- warn about cases of obvious null dereference.
if Is_Access_Type (Typ) then
Access_Type_Case : declare
P : Node_Id;
function Process
(N : Node_Id) return Traverse_Result;
-- Process function for instantiation of Traverse
-- below. Checks if N contains reference to E other
-- than a dereference.
function Ref_In (Nod : Node_Id) return Boolean;
-- Determines whether Nod contains a reference to
-- the entity E that is not a dereference.
-------------
-- Process --
-------------
function Process
(N : Node_Id) return Traverse_Result
is
begin
if Is_Entity_Name (N)
and then Entity (N) = E
and then not Is_Dereferenced (N)
then
return Abandon;
else
return OK;
end if;
end Process;
------------
-- Ref_In --
------------
function Ref_In (Nod : Node_Id) return Boolean is
function Traverse is new Traverse_Func (Process);
begin
return Traverse (Nod) = Abandon;
end Ref_In;
-- Start of processing for Access_Type_Case
begin
-- Don't bother if we are inside an instance, since
-- the compilation of the generic template is where
-- the warning should be issued.
if In_Instance then
return;
end if;
-- Don't bother if this is not the main unit. If we
-- try to give this warning for with'ed units, we
-- get some false positives, since we do not record
-- references in other units.
if not In_Extended_Main_Source_Unit (E)
or else
not In_Extended_Main_Source_Unit (N)
then
return;
end if;
-- We are only interested in dereferences
if not Is_Dereferenced (N) then
return;
end if;
-- One more check, don't bother with references
-- that are inside conditional statements or WHILE
-- loops if the condition references the entity in
-- question. This avoids most false positives.
P := Parent (N);
loop
P := Parent (P);
exit when No (P);
if Nkind (P) in N_If_Statement | N_Elsif_Part
and then Ref_In (Condition (P))
then
return;
elsif Nkind (P) = N_Loop_Statement
and then Present (Iteration_Scheme (P))
and then
Ref_In (Condition (Iteration_Scheme (P)))
then
return;
end if;
end loop;
end Access_Type_Case;
end if;
-- One more check, don't bother if we are within a
-- postcondition, since the expression occurs in a
-- place unrelated to the actual test.
if not Within_Postcondition then
-- Here we definitely have a case for giving a warning
-- for a reference to an unset value. But we don't
-- give the warning now. Instead set Unset_Reference
-- in the identifier involved. The reason for this is
-- that if we find the variable is never ever assigned
-- a value then that warning is more important and
-- there is no point in giving the reference warning.
-- If this is an identifier, set the field directly
if Nkind (N) = N_Identifier then
Set_Unset_Reference (E, N);
-- Otherwise it is an expanded name, so set the field
-- of the actual identifier for the reference.
else
Set_Unset_Reference (E, Selector_Name (N));
end if;
end if;
end Potential_Unset_Reference;
end if;
end;
-- Indexed component or slice
when N_Indexed_Component
| N_Slice
=>
-- If prefix does not involve dereferencing an access type, then
-- we know we are OK if the component type is fully initialized,
-- since the component will have been set as part of the default
-- initialization.
if not Prefix_Has_Dereference (Prefix (N))
and then Is_OK_Fully_Initialized
then
return;
-- Look at prefix in access type case, or if the component is not
-- fully initialized.
else
Check_Unset_Reference (Prefix (N));
end if;
-- Record component
when N_Selected_Component =>
declare
Pref : constant Node_Id := Prefix (N);
Ent : constant Entity_Id := Entity (Selector_Name (N));
begin
-- If prefix involves dereferencing an access type, always
-- check the prefix, since the issue then is whether this
-- access value is null.
if Prefix_Has_Dereference (Pref) then
null;
-- Always go to prefix if no selector entity is set. Can this
-- happen in the normal case? Not clear, but it definitely can
-- happen in error cases.
elsif No (Ent) then
null;
-- For a record component, check some cases where we have
-- reasonable cause to consider that the component is known to
-- be or probably is initialized. In this case, we don't care
-- if the prefix itself was explicitly initialized.
-- Discriminants are always considered initialized
elsif Ekind (Ent) = E_Discriminant then
return;
-- An explicitly initialized component is certainly initialized
elsif Nkind (Parent (Ent)) = N_Component_Declaration
and then Present (Expression (Parent (Ent)))
then
return;
-- A fully initialized component is initialized
elsif Is_OK_Fully_Initialized then
return;
end if;
-- If none of those cases apply, check the record type prefix
Check_Unset_Reference (Pref);
end;
-- For type conversions, qualifications, or expressions with actions,
-- examine the expression.
when N_Expression_With_Actions
| N_Qualified_Expression
| N_Type_Conversion
=>
Check_Unset_Reference (Expression (N));
-- For explicit dereference, always check prefix, which will generate
-- an unset reference (since this is a case of dereferencing null).
when N_Explicit_Dereference =>
Check_Unset_Reference (Prefix (N));
-- All other cases are not cases of an unset reference
when others =>
null;
end case;
end Check_Unset_Reference;
------------------------
-- Check_Unused_Withs --
------------------------
procedure Check_Unused_Withs (Spec_Unit : Unit_Number_Type := No_Unit) is
Munite : constant Entity_Id := Cunit_Entity (Main_Unit);
-- This is needed for checking the special renaming case
procedure Check_One_Unit (Unit : Unit_Number_Type);
-- Subsidiary procedure, performs checks for specified unit
--------------------
-- Check_One_Unit --
--------------------
procedure Check_One_Unit (Unit : Unit_Number_Type) is
Cnode : constant Node_Id := Cunit (Unit);
Is_Visible_Renaming : Boolean := False;
procedure Check_Inner_Package (Pack : Entity_Id);
-- Pack is a package local to a unit in a with_clause. Both the unit
-- and Pack are referenced. If none of the entities in Pack are
-- referenced, then the only occurrence of Pack is in a USE clause
-- or a pragma, and a warning is worthwhile as well.
function Check_System_Aux (Lunit : Entity_Id) return Boolean;
-- Before giving a warning on a with_clause for System, check whether
-- a system extension is present.
function Find_Package_Renaming
(P : Entity_Id;
L : Entity_Id) return Entity_Id;
-- The only reference to a context unit may be in a renaming
-- declaration. If this renaming declares a visible entity, do not
-- warn that the context clause could be moved to the body, because
-- the renaming may be intended to re-export the unit.
function Has_Visible_Entities (P : Entity_Id) return Boolean;
-- This function determines if a package has any visible entities.
-- True is returned if there is at least one declared visible entity,
-- otherwise False is returned (e.g. case of only pragmas present).
-------------------------
-- Check_Inner_Package --
-------------------------
procedure Check_Inner_Package (Pack : Entity_Id) is
E : Entity_Id;
Un : constant Node_Id := Sinfo.Nodes.Unit (Cnode);
function Check_Use_Clause (N : Node_Id) return Traverse_Result;
-- If N is a use_clause for Pack, emit warning
procedure Check_Use_Clauses is new
Traverse_Proc (Check_Use_Clause);
----------------------
-- Check_Use_Clause --
----------------------
function Check_Use_Clause (N : Node_Id) return Traverse_Result is
begin
if Nkind (N) = N_Use_Package_Clause
and then Entity (Name (N)) = Pack
then
-- Suppress message if any serious errors detected that turn
-- off expansion, and thus result in false positives for
-- this warning.
if Serious_Errors_Detected = 0 then
Error_Msg_Qual_Level := 1;
Error_Msg_NE -- CODEFIX
("?u?no entities of package& are referenced!",
Name (N), Pack);
Error_Msg_Qual_Level := 0;
end if;
end if;
return OK;
end Check_Use_Clause;
-- Start of processing for Check_Inner_Package
begin
E := First_Entity (Pack);
while Present (E) loop
if Referenced_Check_Spec (E) then
return;
end if;
Next_Entity (E);
end loop;
-- No entities of the package are referenced. Check whether the
-- reference to the package itself is a use clause, and if so
-- place a warning on it.
Check_Use_Clauses (Un);
end Check_Inner_Package;
----------------------
-- Check_System_Aux --
----------------------
function Check_System_Aux (Lunit : Entity_Id) return Boolean is
Ent : Entity_Id;
begin
if Chars (Lunit) = Name_System
and then Scope (Lunit) = Standard_Standard
and then Present_System_Aux
then
Ent := First_Entity (System_Aux_Id);
while Present (Ent) loop
if Referenced_Check_Spec (Ent) then
return True;
end if;
Next_Entity (Ent);
end loop;
end if;
return False;
end Check_System_Aux;
---------------------------
-- Find_Package_Renaming --
---------------------------
function Find_Package_Renaming
(P : Entity_Id;
L : Entity_Id) return Entity_Id
is
E1 : Entity_Id;
R : Entity_Id;
begin
Is_Visible_Renaming := False;
E1 := First_Entity (P);
while Present (E1) loop
if Ekind (E1) = E_Package and then Renamed_Entity (E1) = L then
Is_Visible_Renaming := not Is_Hidden (E1);
return E1;
elsif Ekind (E1) = E_Package
and then No (Renamed_Entity (E1))
and then not Is_Generic_Instance (E1)
then
R := Find_Package_Renaming (E1, L);
if Present (R) then
Is_Visible_Renaming := not Is_Hidden (R);
return R;
end if;
end if;
Next_Entity (E1);
end loop;
return Empty;
end Find_Package_Renaming;
--------------------------
-- Has_Visible_Entities --
--------------------------
function Has_Visible_Entities (P : Entity_Id) return Boolean is
E : Entity_Id;
begin
-- If unit in context is not a package, it is a subprogram that
-- is not called or a generic unit that is not instantiated
-- in the current unit, and warning is appropriate.
if Ekind (P) /= E_Package then
return True;
end if;
-- If unit comes from a limited_with clause, look for declaration
-- of shadow entities.
if Present (Limited_View (P)) then
E := First_Entity (Limited_View (P));
else
E := First_Entity (P);
end if;
while Present (E) and then E /= First_Private_Entity (P) loop
if Comes_From_Source (E) or else Present (Limited_View (P)) then
return True;
end if;
Next_Entity (E);
end loop;
return False;
end Has_Visible_Entities;
-- Local variables
Ent : Entity_Id;
Item : Node_Id;
Lunit : Entity_Id;
Pack : Entity_Id;
-- Start of processing for Check_One_Unit
begin
-- Only do check in units that are part of the extended main unit.
-- This is actually a necessary restriction, because in the case of
-- subprogram acting as its own specification, there can be with's in
-- subunits that we will not see.
if not In_Extended_Main_Source_Unit (Cnode) then
return;
end if;
-- Loop through context items in this unit
Item := First (Context_Items (Cnode));
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then not Implicit_With (Item)
and then In_Extended_Main_Source_Unit (Item)
-- Guard for no entity present. Not clear under what conditions
-- this happens, but it does occur, and since this is only a
-- warning, we just suppress the warning in this case.
and then Nkind (Name (Item)) in N_Has_Entity
and then Present (Entity (Name (Item)))
then
Lunit := Entity (Name (Item));
-- Check if this unit is referenced (skip the check if this
-- is explicitly marked by a pragma Unreferenced).
if not Referenced (Lunit) and then not Has_Unreferenced (Lunit)
then
-- Suppress warnings in internal units if not in -gnatg mode
-- (these would be junk warnings for an application program,
-- since they refer to problems in internal units).
if GNAT_Mode or else not Is_Internal_Unit (Unit) then
-- Here we definitely have a non-referenced unit. If it
-- is the special call for a spec unit, then just set the
-- flag to be read later.
if Unit = Spec_Unit then
Set_Unreferenced_In_Spec (Item);
-- Otherwise simple unreferenced message, but skip this
-- if no visible entities, because that is most likely a
-- case where warning would be false positive (e.g. a
-- package with only a linker options pragma and nothing
-- else or a pragma elaborate with a body library task).
elsif Has_Visible_Entities (Lunit) then
Error_Msg_N -- CODEFIX
("?u?unit& is not referenced!", Name (Item));
end if;
end if;
-- If main unit is a renaming of this unit, then we consider
-- the with to be OK (obviously it is needed in this case).
-- This may be transitive: the unit in the with_clause may
-- itself be a renaming, in which case both it and the main
-- unit rename the same ultimate package.
elsif Present (Renamed_Entity (Munite))
and then
(Renamed_Entity (Munite) = Lunit
or else Renamed_Entity (Munite) = Renamed_Entity (Lunit))
then
null;
-- If this unit is referenced, and it is a package, we do
-- another test, to see if any of the entities in the package
-- are referenced. If none of the entities are referenced, we
-- still post a warning. This occurs if the only use of the
-- package is in a use clause, or in a package renaming
-- declaration. This check is skipped for packages that are
-- renamed in a spec, since the entities in such a package are
-- visible to clients via the renaming.
elsif Ekind (Lunit) = E_Package
and then not Renamed_In_Spec (Lunit)
then
-- If Is_Instantiated is set, it means that the package is
-- implicitly instantiated (this is the case of parent
-- instance or an actual for a generic package formal), and
-- this counts as a reference.
if Is_Instantiated (Lunit) then
null;
-- If no entities in package, and there is a pragma
-- Elaborate_Body present, then assume that this with is
-- done for purposes of this elaboration.
elsif No (First_Entity (Lunit))
and then Has_Pragma_Elaborate_Body (Lunit)
then
null;
-- Otherwise see if any entities have been referenced
else
if Limited_Present (Item) then
Ent := First_Entity (Limited_View (Lunit));
else
Ent := First_Entity (Lunit);
end if;
loop
-- No more entities, and we did not find one that was
-- referenced. Means we have a definite case of a with
-- none of whose entities was referenced.
if No (Ent) then
-- If in spec, just set the flag
if Unit = Spec_Unit then
Set_No_Entities_Ref_In_Spec (Item);
elsif Check_System_Aux (Lunit) then
null;
-- Else the warning may be needed
else
-- Warn if we unreferenced flag set and we have
-- not had serious errors. The reason we inhibit
-- the message if there are errors is to prevent
-- false positives from disabling expansion.
if not Has_Unreferenced (Lunit)
and then Serious_Errors_Detected = 0
then
-- Get possible package renaming
Pack := Find_Package_Renaming (Munite, Lunit);
-- No warning if either the package or its
-- renaming is used as a generic actual.
if Used_As_Generic_Actual (Lunit)
or else
(Present (Pack)
and then
Used_As_Generic_Actual (Pack))
then
exit;
end if;
-- Here we give the warning
Error_Msg_N -- CODEFIX
("?u?no entities of & are referenced!",
Name (Item));
-- Flag renaming of package as well. If
-- the original package has warnings off,
-- we suppress the warning on the renaming
-- as well.
if Present (Pack)
and then not Has_Warnings_Off (Lunit)
and then not Has_Unreferenced (Pack)
then
Error_Msg_NE -- CODEFIX
("?u?no entities of& are referenced!",
Unit_Declaration_Node (Pack), Pack);
end if;
end if;
end if;
exit;
-- Case of entity being referenced. The reference may
-- come from a limited_with_clause, in which case the
-- limited view of the entity carries the flag.
elsif Referenced_Check_Spec (Ent)
or else Referenced_As_LHS_Check_Spec (Ent)
or else Referenced_As_Out_Parameter_Check_Spec (Ent)
or else
(From_Limited_With (Ent)
and then Is_Incomplete_Type (Ent)
and then Present (Non_Limited_View (Ent))
and then Referenced (Non_Limited_View (Ent)))
then
-- This means that the with is indeed fine, in that
-- it is definitely needed somewhere, and we can
-- quit worrying about this one...
-- Except for one little detail: if either of the
-- flags was set during spec processing, this is
-- where we complain that the with could be moved
-- from the spec. If the spec contains a visible
-- renaming of the package, inhibit warning to move
-- with_clause to body.
if Ekind (Munite) = E_Package_Body then
Pack :=
Find_Package_Renaming
(Spec_Entity (Munite), Lunit);
else
Pack := Empty;
end if;
-- If a renaming is present in the spec do not warn
-- because the body or child unit may depend on it.
if Present (Pack)
and then Renamed_Entity (Pack) = Lunit
then
exit;
elsif Unreferenced_In_Spec (Item) then
Error_Msg_N -- CODEFIX
("?u?unit& is not referenced in spec!",
Name (Item));
elsif No_Entities_Ref_In_Spec (Item) then
Error_Msg_N -- CODEFIX
("?u?no entities of & are referenced in spec!",
Name (Item));
else
if Ekind (Ent) = E_Package then
Check_Inner_Package (Ent);
end if;
exit;
end if;
if not Is_Visible_Renaming then
Error_Msg_N -- CODEFIX
("\?u?with clause might be moved to body!",
Name (Item));
end if;
exit;
-- Move to next entity to continue search
else
Next_Entity (Ent);
end if;
end loop;
end if;
-- For a generic package, the only interesting kind of
-- reference is an instantiation, since entities cannot be
-- referenced directly.
elsif Is_Generic_Unit (Lunit) then
-- Unit was never instantiated, set flag for case of spec
-- call, or give warning for normal call.
if not Is_Instantiated (Lunit) then
if Unit = Spec_Unit then
Set_Unreferenced_In_Spec (Item);
else
Error_Msg_N -- CODEFIX
("?u?unit& is never instantiated!", Name (Item));
end if;
-- If unit was indeed instantiated, make sure that flag is
-- not set showing it was uninstantiated in the spec, and if
-- so, give warning.
elsif Unreferenced_In_Spec (Item) then
Error_Msg_N
("?u?unit& is not instantiated in spec!", Name (Item));
Error_Msg_N -- CODEFIX
("\?u?with clause can be moved to body!", Name (Item));
end if;
end if;
end if;
Next (Item);
end loop;
end Check_One_Unit;
-- Start of processing for Check_Unused_Withs
begin
-- Immediate return if no semantics or warning flag not set
if not Opt.Check_Withs or else Operating_Mode = Check_Syntax then
return;
end if;
Process_Deferred_References;
-- Flag any unused with clauses. For a subunit, check only the units
-- in its context, not those of the parent, which may be needed by other
-- subunits. We will get the full warnings when we compile the parent,
-- but the following is helpful when compiling a subunit by itself.
if Nkind (Unit (Cunit (Main_Unit))) = N_Subunit then
if Current_Sem_Unit = Main_Unit then
Check_One_Unit (Main_Unit);
end if;
return;
end if;
-- Process specified units
if Spec_Unit = No_Unit then
-- For main call, check all units
for Unit in Main_Unit .. Last_Unit loop
Check_One_Unit (Unit);
end loop;
else
-- For call for spec, check only the spec
Check_One_Unit (Spec_Unit);
end if;
end Check_Unused_Withs;
---------------------------------
-- Generic_Package_Spec_Entity --
---------------------------------
function Generic_Package_Spec_Entity (E : Entity_Id) return Boolean is
S : Entity_Id;
begin
if Is_Package_Body_Entity (E) then
return False;
else
S := Scope (E);
loop
if S = Standard_Standard then
return False;
elsif Ekind (S) = E_Generic_Package then
return True;
elsif Ekind (S) = E_Package then
S := Scope (S);
else
return False;
end if;
end loop;
end if;
end Generic_Package_Spec_Entity;
----------------------
-- Goto_Spec_Entity --
----------------------
function Goto_Spec_Entity (E : Entity_Id) return Entity_Id is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
return Spec_Entity (E);
else
return E;
end if;
end Goto_Spec_Entity;
-------------------
-- Has_Junk_Name --
-------------------
function Has_Junk_Name (E : Entity_Id) return Boolean is
function Match (S : String) return Boolean;
-- Return true if substring S is found in Name_Buffer (1 .. Name_Len)
-----------
-- Match --
-----------
function Match (S : String) return Boolean is
Slen1 : constant Integer := S'Length - 1;
begin
for J in 1 .. Name_Len - S'Length + 1 loop
if Name_Buffer (J .. J + Slen1) = S then
return True;
end if;
end loop;
return False;
end Match;
-- Start of processing for Has_Junk_Name
begin
Get_Unqualified_Decoded_Name_String (Chars (E));
return
Match ("discard") or else
Match ("dummy") or else
Match ("ignore") or else
Match ("junk") or else
Match ("unused");
end Has_Junk_Name;
--------------------------------------
-- Has_Pragma_Unmodified_Check_Spec --
--------------------------------------
function Has_Pragma_Unmodified_Check_Spec
(E : Entity_Id) return Boolean
is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
-- Note: use of OR instead of OR ELSE here is deliberate, we want
-- to mess with Unmodified flags on both body and spec entities.
-- Has_Unmodified has side effects!
return Has_Unmodified (E)
or
Has_Unmodified (Spec_Entity (E));
else
return Has_Unmodified (E);
end if;
end Has_Pragma_Unmodified_Check_Spec;
----------------------------------------
-- Has_Pragma_Unreferenced_Check_Spec --
----------------------------------------
function Has_Pragma_Unreferenced_Check_Spec
(E : Entity_Id) return Boolean
is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
-- Note: use of OR here instead of OR ELSE is deliberate, we want
-- to mess with flags on both entities.
return Has_Unreferenced (E)
or
Has_Unreferenced (Spec_Entity (E));
else
return Has_Unreferenced (E);
end if;
end Has_Pragma_Unreferenced_Check_Spec;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Warnings_Off_Pragmas.Init;
Unreferenced_Entities.Init;
In_Out_Warnings.Init;
end Initialize;
---------------------------------------------
-- Is_Attribute_And_Known_Value_Comparison --
---------------------------------------------
function Is_Attribute_And_Known_Value_Comparison
(Op : Node_Id) return Boolean
is
Orig_Op : constant Node_Id := Original_Node (Op);
begin
return
Nkind (Orig_Op) in N_Op_Compare
and then Nkind (Original_Node (Left_Opnd (Orig_Op))) =
N_Attribute_Reference
and then Compile_Time_Known_Value (Right_Opnd (Orig_Op));
end Is_Attribute_And_Known_Value_Comparison;
------------------------------------
-- Never_Set_In_Source_Check_Spec --
------------------------------------
function Never_Set_In_Source_Check_Spec (E : Entity_Id) return Boolean is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
return Never_Set_In_Source (E)
and then
Never_Set_In_Source (Spec_Entity (E));
else
return Never_Set_In_Source (E);
end if;
end Never_Set_In_Source_Check_Spec;
-------------------------------------
-- Operand_Has_Warnings_Suppressed --
-------------------------------------
function Operand_Has_Warnings_Suppressed (N : Node_Id) return Boolean is
function Check_For_Warnings (N : Node_Id) return Traverse_Result;
-- Function used to check one node to see if it is or was originally
-- a reference to an entity for which Warnings are off. If so, Abandon
-- is returned, otherwise OK_Orig is returned to continue the traversal
-- of the original expression.
function Traverse is new Traverse_Func (Check_For_Warnings);
-- Function used to traverse tree looking for warnings
------------------------
-- Check_For_Warnings --
------------------------
function Check_For_Warnings (N : Node_Id) return Traverse_Result is
R : constant Node_Id := Original_Node (N);
begin
if Nkind (R) in N_Has_Entity
and then Present (Entity (R))
and then Has_Warnings_Off (Entity (R))
then
return Abandon;
else
return OK_Orig;
end if;
end Check_For_Warnings;
-- Start of processing for Operand_Has_Warnings_Suppressed
begin
return Traverse (N) = Abandon;
-- If any exception occurs, then something has gone wrong, and this is
-- only a minor aesthetic issue anyway, so just say we did not find what
-- we are looking for, rather than blow up.
exception
when others =>
-- With debug flag K we will get an exception unless an error has
-- already occurred (useful for debugging).
if Debug_Flag_K then
Check_Error_Detected;
end if;
return False;
end Operand_Has_Warnings_Suppressed;
-----------------------------------------
-- Output_Non_Modified_In_Out_Warnings --
-----------------------------------------
procedure Output_Non_Modified_In_Out_Warnings is
function No_Warn_On_In_Out (E : Entity_Id) return Boolean;
-- Given a formal parameter entity E, determines if there is a reason to
-- suppress IN OUT warnings (not modified, could be IN) for formals of
-- the subprogram. We suppress these warnings if Warnings Off is set, or
-- if we have seen the address of the subprogram being taken, or if the
-- subprogram is used as a generic actual (in the latter cases the
-- context may force use of IN OUT, even if the parameter is not
-- modified for this particular case.
-----------------------
-- No_Warn_On_In_Out --
-----------------------
function No_Warn_On_In_Out (E : Entity_Id) return Boolean is
S : constant Entity_Id := Scope (E);
SE : constant Entity_Id := Spec_Entity (E);
begin
-- Do not warn if address is taken, since funny business may be going
-- on in treating the parameter indirectly as IN OUT.
if Address_Taken (S)
or else (Present (SE) and then Address_Taken (Scope (SE)))
then
return True;
-- Do not warn if used as a generic actual, since the generic may be
-- what is forcing the use of an "unnecessary" IN OUT.
elsif Used_As_Generic_Actual (S)
or else (Present (SE) and then Used_As_Generic_Actual (Scope (SE)))
then
return True;
-- Else test warnings off
elsif Warnings_Off_Check_Spec (S) then
return True;
-- All tests for suppressing warning failed
else
return False;
end if;
end No_Warn_On_In_Out;
-- Start of processing for Output_Non_Modified_In_Out_Warnings
begin
-- Loop through entities for which a warning may be needed
for J in In_Out_Warnings.First .. In_Out_Warnings.Last loop
declare
E1 : constant Entity_Id := In_Out_Warnings.Table (J);
begin
-- Suppress warning in specific cases (see details in comments for
-- No_Warn_On_In_Out), or if there is a pragma Unmodified.
if Has_Pragma_Unmodified_Check_Spec (E1)
or else No_Warn_On_In_Out (E1)
then
null;
-- Here we generate the warning
else
-- If -gnatwk is set then output message that it could be IN
if not Is_Trivial_Subprogram (Scope (E1)) then
if Warn_On_Constant then
Error_Msg_N
("?k?formal parameter & is not modified!", E1);
Error_Msg_N
("\?k?mode could be IN instead of `IN OUT`!", E1);
-- We do not generate warnings for IN OUT parameters
-- unless we have at least -gnatwu. This is deliberately
-- inconsistent with the treatment of variables, but
-- otherwise we get too many unexpected warnings in
-- default mode.
elsif Check_Unreferenced then
Error_Msg_N
("?u?formal parameter& is read but "
& "never assigned!", E1);
end if;
end if;
-- Kill any other warnings on this entity, since this is the
-- one that should dominate any other unreferenced warning.
Set_Warnings_Off (E1);
end if;
end;
end loop;
end Output_Non_Modified_In_Out_Warnings;
----------------------------------------
-- Output_Obsolescent_Entity_Warnings --
----------------------------------------
procedure Output_Obsolescent_Entity_Warnings (N : Node_Id; E : Entity_Id) is
P : constant Node_Id := Parent (N);
S : Entity_Id;
begin
S := Current_Scope;
-- Do not output message if we are the scope of standard. This means
-- we have a reference from a context clause from when it is originally
-- processed, and that's too early to tell whether it is an obsolescent
-- unit doing the with'ing. In Sem_Ch10.Analyze_Compilation_Unit we make
-- sure that we have a later call when the scope is available. This test
-- also eliminates all messages for use clauses, which is fine (we do
-- not want messages for use clauses, since they are always redundant
-- with respect to the associated with clause).
if S = Standard_Standard then
return;
end if;
-- Do not output message if we are in scope of an obsolescent package
-- or subprogram.
loop
if Is_Obsolescent (S) then
return;
end if;
S := Scope (S);
exit when S = Standard_Standard;
end loop;
-- Here we will output the message
Error_Msg_Sloc := Sloc (E);
-- Case of with clause
if Nkind (P) = N_With_Clause then
if Ekind (E) = E_Package then
Error_Msg_NE
("?j?with of obsolescent package& declared#", N, E);
elsif Ekind (E) = E_Procedure then
Error_Msg_NE
("?j?with of obsolescent procedure& declared#", N, E);
else
Error_Msg_NE
("??with of obsolescent function& declared#", N, E);
end if;
-- If we do not have a with clause, then ignore any reference to an
-- obsolescent package name. We only want to give the one warning of
-- withing the package, not one each time it is used to qualify.
elsif Ekind (E) = E_Package then
return;
-- Procedure call statement
elsif Nkind (P) = N_Procedure_Call_Statement then
Error_Msg_NE
("??call to obsolescent procedure& declared#", N, E);
-- Function call
elsif Nkind (P) = N_Function_Call then
Error_Msg_NE
("??call to obsolescent function& declared#", N, E);
-- Reference to obsolescent type
elsif Is_Type (E) then
Error_Msg_NE
("??reference to obsolescent type& declared#", N, E);
-- Reference to obsolescent component
elsif Ekind (E) in E_Component | E_Discriminant then
Error_Msg_NE
("??reference to obsolescent component& declared#", N, E);
-- Reference to obsolescent variable
elsif Ekind (E) = E_Variable then
Error_Msg_NE
("??reference to obsolescent variable& declared#", N, E);
-- Reference to obsolescent constant
elsif Ekind (E) = E_Constant or else Ekind (E) in Named_Kind then
Error_Msg_NE
("??reference to obsolescent constant& declared#", N, E);
-- Reference to obsolescent enumeration literal
elsif Ekind (E) = E_Enumeration_Literal then
Error_Msg_NE
("??reference to obsolescent enumeration literal& declared#", N, E);
-- Generic message for any other case we missed
else
Error_Msg_NE
("??reference to obsolescent entity& declared#", N, E);
end if;
-- Output additional warning if present
for J in Obsolescent_Warnings.First .. Obsolescent_Warnings.Last loop
if Obsolescent_Warnings.Table (J).Ent = E then
String_To_Name_Buffer (Obsolescent_Warnings.Table (J).Msg);
Error_Msg_Strlen := Name_Len;
Error_Msg_String (1 .. Name_Len) := Name_Buffer (1 .. Name_Len);
Error_Msg_N ("\\??~", N);
exit;
end if;
end loop;
end Output_Obsolescent_Entity_Warnings;
----------------------------------
-- Output_Unreferenced_Messages --
----------------------------------
procedure Output_Unreferenced_Messages is
begin
for J in Unreferenced_Entities.First .. Unreferenced_Entities.Last loop
Warn_On_Unreferenced_Entity (Unreferenced_Entities.Table (J));
end loop;
end Output_Unreferenced_Messages;
-----------------------------------------
-- Output_Unused_Warnings_Off_Warnings --
-----------------------------------------
procedure Output_Unused_Warnings_Off_Warnings is
begin
for J in Warnings_Off_Pragmas.First .. Warnings_Off_Pragmas.Last loop
declare
Wentry : Warnings_Off_Entry renames Warnings_Off_Pragmas.Table (J);
N : Node_Id renames Wentry.N;
E : Node_Id renames Wentry.E;
begin
-- Turn off Warnings_Off, or we won't get the warning
Set_Warnings_Off (E, False);
-- Nothing to do if pragma was used to suppress a general warning
if Warnings_Off_Used (E) then
null;
-- If pragma was used both in unmodified and unreferenced contexts
-- then that's as good as the general case, no warning.
elsif Warnings_Off_Used_Unmodified (E)
and
Warnings_Off_Used_Unreferenced (E)
then
null;
-- Used only in context where Unmodified would have worked
elsif Warnings_Off_Used_Unmodified (E) then
Error_Msg_NE
("?.w?could use Unmodified instead of "
& "Warnings Off for &", Pragma_Identifier (N), E);
-- Used only in context where Unreferenced would have worked
elsif Warnings_Off_Used_Unreferenced (E) then
Error_Msg_NE
("?.w?could use Unreferenced instead of "
& "Warnings Off for &", Pragma_Identifier (N), E);
-- Not used at all
else
Error_Msg_NE
("?.w?pragma Warnings Off for & unused, "
& "could be omitted", N, E);
end if;
end;
end loop;
end Output_Unused_Warnings_Off_Warnings;
---------------------------
-- Referenced_Check_Spec --
---------------------------
function Referenced_Check_Spec (E : Entity_Id) return Boolean is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
return Referenced (E) or else Referenced (Spec_Entity (E));
else
return Referenced (E);
end if;
end Referenced_Check_Spec;
----------------------------------
-- Referenced_As_LHS_Check_Spec --
----------------------------------
function Referenced_As_LHS_Check_Spec (E : Entity_Id) return Boolean is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
return Referenced_As_LHS (E)
or else Referenced_As_LHS (Spec_Entity (E));
else
return Referenced_As_LHS (E);
end if;
end Referenced_As_LHS_Check_Spec;
--------------------------------------------
-- Referenced_As_Out_Parameter_Check_Spec --
--------------------------------------------
function Referenced_As_Out_Parameter_Check_Spec
(E : Entity_Id) return Boolean
is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
return Referenced_As_Out_Parameter (E)
or else Referenced_As_Out_Parameter (Spec_Entity (E));
else
return Referenced_As_Out_Parameter (E);
end if;
end Referenced_As_Out_Parameter_Check_Spec;
--------------------------------------
-- Warn_On_Constant_Valid_Condition --
--------------------------------------
procedure Warn_On_Constant_Valid_Condition (Op : Node_Id) is
Left : constant Node_Id := Left_Opnd (Op);
Right : constant Node_Id := Right_Opnd (Op);
True_Result : Boolean;
False_Result : Boolean;
begin
-- Determine the potential outcome of the comparison assuming that the
-- scalar operands are valid.
if Constant_Condition_Warnings
and then Comes_From_Source (Original_Node (Op))
and then Is_Scalar_Type (Etype (Left))
and then Is_Scalar_Type (Etype (Right))
-- Do not consider instances because the check was already performed
-- in the generic.
and then not In_Instance
-- Do not consider comparisons between two static expressions such as
-- constants or literals because those values cannot be invalidated.
and then not (Is_Static_Expression (Left)
and then Is_Static_Expression (Right))
-- Do not consider comparison between an attribute reference and a
-- compile-time known value since this is most likely a conditional
-- compilation.
and then not Is_Attribute_And_Known_Value_Comparison (Op)
-- Do not consider internal files to allow for various assertions and
-- safeguards within our runtime.
and then not In_Internal_Unit (Op)
then
Test_Comparison
(Op => Op,
Assume_Valid => True,
True_Result => True_Result,
False_Result => False_Result);
-- Warn on a possible evaluation to False / True in the presence of
-- invalid values.
if True_Result then
Error_Msg_N
("condition can only be False if invalid values present?c?", Op);
elsif False_Result then
Error_Msg_N
("condition can only be True if invalid values present?c?", Op);
end if;
end if;
end Warn_On_Constant_Valid_Condition;
-----------------------------
-- Warn_On_Known_Condition --
-----------------------------
procedure Warn_On_Known_Condition (C : Node_Id) is
Test_Result : Boolean := False;
-- Force initialization to facilitate static analysis
function Is_Known_Branch return Boolean;
-- If the type of the condition is Boolean, the constant value of the
-- condition is a boolean literal. If the type is a derived boolean
-- type, the constant is wrapped in a type conversion of the derived
-- literal. If the value of the condition is not a literal, no warnings
-- can be produced. This function returns True if the result can be
-- determined, and Test_Result is set True/False accordingly. Otherwise
-- False is returned, and Test_Result is unchanged.
procedure Track (N : Node_Id; Loc : Node_Id);
-- Adds continuation warning(s) pointing to reason (assignment or test)
-- for the operand of the conditional having a known value (or at least
-- enough is known about the value to issue the warning). N is the node
-- which is judged to have a known value. Loc is the warning location.
---------------------
-- Is_Known_Branch --
---------------------
function Is_Known_Branch return Boolean is
begin
if Etype (C) = Standard_Boolean
and then Is_Entity_Name (C)
and then
(Entity (C) = Standard_False or else Entity (C) = Standard_True)
then
Test_Result := Entity (C) = Standard_True;
return True;
elsif Is_Boolean_Type (Etype (C))
and then Nkind (C) = N_Unchecked_Type_Conversion
and then Is_Entity_Name (Expression (C))
and then Ekind (Entity (Expression (C))) = E_Enumeration_Literal
then
Test_Result :=
Chars (Entity (Expression (C))) = Chars (Standard_True);
return True;
else
return False;
end if;
end Is_Known_Branch;
-----------
-- Track --
-----------
procedure Track (N : Node_Id; Loc : Node_Id) is
Nod : constant Node_Id := Original_Node (N);
begin
if Nkind (Nod) in N_Op_Compare then
Track (Left_Opnd (Nod), Loc);
Track (Right_Opnd (Nod), Loc);
elsif Is_Entity_Name (Nod) and then Is_Object (Entity (Nod)) then
declare
CV : constant Node_Id := Current_Value (Entity (Nod));
begin
if Present (CV) then
Error_Msg_Sloc := Sloc (CV);
if Nkind (CV) not in N_Subexpr then
Error_Msg_N ("\\??(see test #)", Loc);
elsif Nkind (Parent (CV)) =
N_Case_Statement_Alternative
then
Error_Msg_N ("\\??(see case alternative #)", Loc);
else
Error_Msg_N ("\\??(see assignment #)", Loc);
end if;
end if;
end;
end if;
end Track;
-- Local variables
Orig : constant Node_Id := Original_Node (C);
P : Node_Id;
-- Start of processing for Warn_On_Known_Condition
begin
-- Adjust SCO condition if from source
if Generate_SCO
and then Comes_From_Source (Orig)
and then Is_Known_Branch
then
declare
Atrue : Boolean;
begin
Atrue := Test_Result;
if Present (Parent (C)) and then Nkind (Parent (C)) = N_Op_Not then
Atrue := not Atrue;
end if;
Set_SCO_Condition (Orig, Atrue);
end;
end if;
-- Argument replacement in an inlined body can make conditions static.
-- Do not emit warnings in this case.
if In_Inlined_Body then
return;
end if;
if Constant_Condition_Warnings
and then Is_Known_Branch
and then Comes_From_Source (Orig)
and then Nkind (Orig) in N_Has_Entity
and then not In_Instance
then
-- Don't warn if comparison of result of attribute against a constant
-- value, since this is likely legitimate conditional compilation.
if Is_Attribute_And_Known_Value_Comparison (C) then
return;
end if;
-- See if this is in a statement or a declaration
P := Parent (C);
loop
-- If tree is not attached, do not issue warning (this is very
-- peculiar, and probably arises from some other error condition).
if No (P) then
return;
-- If we are in a declaration, then no warning, since in practice
-- conditionals in declarations are used for intended tests which
-- may be known at compile time, e.g. things like
-- x : constant Integer := 2 + (Word'Size = 32);
-- And a warning is annoying in such cases
elsif Nkind (P) in N_Declaration
or else
Nkind (P) in N_Later_Decl_Item
then
return;
-- Don't warn in assert or check pragma, since presumably tests in
-- such a context are very definitely intended, and might well be
-- known at compile time. Note that we have to test the original
-- node, since assert pragmas get rewritten at analysis time.
elsif Nkind (Original_Node (P)) = N_Pragma
and then
Pragma_Name_Unmapped (Original_Node (P))
in Name_Assert | Name_Check
then
return;
end if;
exit when Is_Statement (P);
P := Parent (P);
end loop;
-- Here we issue the warning unless some sub-operand has warnings
-- set off, in which case we suppress the warning for the node. If
-- the original expression is an inequality, it has been expanded
-- into a negation, and the value of the original expression is the
-- negation of the equality. If the expression is an entity that
-- appears within a negation, it is clearer to flag the negation
-- itself, and report on its constant value.
if not Operand_Has_Warnings_Suppressed (C) then
declare
True_Branch : Boolean := Test_Result;
Cond : Node_Id := C;
begin
if Present (Parent (C))
and then Nkind (Parent (C)) = N_Op_Not
then
True_Branch := not True_Branch;
Cond := Parent (C);
end if;
-- Condition always True
if True_Branch then
if Is_Entity_Name (Original_Node (C))
and then Nkind (Cond) /= N_Op_Not
then
Error_Msg_NE
("object & is always True at this point?c?",
Cond, Original_Node (C));
Track (Original_Node (C), Cond);
else
Error_Msg_N ("condition is always True?c?", Cond);
Track (Cond, Cond);
end if;
-- Condition always False
else
if Is_Entity_Name (Original_Node (C))
and then Nkind (Cond) /= N_Op_Not
then
Error_Msg_NE
("object & is always False at this point?c?",
Cond, Original_Node (C));
Track (Original_Node (C), Cond);
else
Error_Msg_N ("condition is always False?c?", Cond);
Track (Cond, Cond);
end if;
end if;
end;
end if;
end if;
end Warn_On_Known_Condition;
---------------------------------------
-- Warn_On_Modified_As_Out_Parameter --
---------------------------------------
function Warn_On_Modified_As_Out_Parameter (E : Entity_Id) return Boolean is
begin
return
(Warn_On_Modified_Unread and then Is_Only_Out_Parameter (E))
or else Warn_On_All_Unread_Out_Parameters;
end Warn_On_Modified_As_Out_Parameter;
---------------------------------
-- Warn_On_Overlapping_Actuals --
---------------------------------
procedure Warn_On_Overlapping_Actuals (Subp : Entity_Id; N : Node_Id) is
function Explicitly_By_Reference (Formal_Id : Entity_Id) return Boolean;
-- Returns True iff the type of Formal_Id is explicitly by-reference
function Refer_Same_Object
(Act1 : Node_Id;
Act2 : Node_Id) return Boolean;
-- Two names are known to refer to the same object if the two names
-- are known to denote the same object; or one of the names is a
-- selected_component, indexed_component, or slice and its prefix is
-- known to refer to the same object as the other name; or one of the
-- two names statically denotes a renaming declaration whose renamed
-- object_name is known to refer to the same object as the other name
-- (RM 6.4.1(6.11/3))
-----------------------------
-- Explicitly_By_Reference --
-----------------------------
function Explicitly_By_Reference
(Formal_Id : Entity_Id)
return Boolean
is
Typ : constant Entity_Id := Underlying_Type (Etype (Formal_Id));
begin
if Present (Typ) then
return Is_By_Reference_Type (Typ)
or else Convention (Typ) = Convention_Ada_Pass_By_Reference;
else
return False;
end if;
end Explicitly_By_Reference;
-----------------------
-- Refer_Same_Object --
-----------------------
function Refer_Same_Object
(Act1 : Node_Id;
Act2 : Node_Id) return Boolean
is
begin
return
Denotes_Same_Object (Act1, Act2)
or else Denotes_Same_Prefix (Act1, Act2);
end Refer_Same_Object;
-- Local variables
Act1 : Node_Id;
Act2 : Node_Id;
Form1 : Entity_Id;
Form2 : Entity_Id;
-- Start of processing for Warn_On_Overlapping_Actuals
begin
-- Exclude calls rewritten as enumeration literals
if Nkind (N) not in N_Subprogram_Call | N_Entry_Call_Statement then
return;
-- Guard against previous errors
elsif Error_Posted (N) then
return;
end if;
-- If a call C has two or more parameters of mode in out or out that are
-- of an elementary type, then the call is legal only if for each name
-- N that is passed as a parameter of mode in out or out to the call C,
-- there is no other name among the other parameters of mode in out or
-- out to C that is known to denote the same object (RM 6.4.1(6.15/3))
-- This has been clarified in AI12-0216 to indicate that the illegality
-- only occurs if both formals are of an elementary type, because of the
-- nondeterminism on the write-back of the corresponding actuals.
-- Earlier versions of the language made it illegal if only one of the
-- actuals was an elementary parameter that overlapped a composite
-- actual, and both were writable.
-- If appropriate warning switch is set, we also report warnings on
-- overlapping parameters that are composite types. Users find these
-- warnings useful, and they are used in style guides.
-- It is also worthwhile to warn on overlaps of composite objects when
-- only one of the formals is (in)-out. Note that the RM rule above is
-- a legality rule. We choose to implement this check as a warning to
-- avoid major incompatibilities with legacy code.
-- Note also that the rule in 6.4.1 (6.17/3), introduced by AI12-0324,
-- is potentially more expensive to verify, and is not yet implemented.
Form1 := First_Formal (Subp);
Act1 := First_Actual (N);
while Present (Form1) and then Present (Act1) loop
Form2 := Next_Formal (Form1);
Act2 := Next_Actual (Act1);
while Present (Form2) and then Present (Act2) loop
-- Ignore formals of generic types; they will be examined when
-- instantiated.
if Is_Generic_Type (Etype (Form1))
or else Is_Generic_Type (Etype (Form2))
then
null;
elsif Refer_Same_Object (Act1, Act2) then
-- Case 1: two writable elementary parameters that overlap
if (Is_Elementary_Type (Etype (Form1))
and then Is_Elementary_Type (Etype (Form2))
and then Ekind (Form1) /= E_In_Parameter
and then Ekind (Form2) /= E_In_Parameter)
-- Case 2: two composite parameters that overlap, one of
-- which is writable.
or else (Is_Composite_Type (Etype (Form1))
and then Is_Composite_Type (Etype (Form2))
and then (Ekind (Form1) /= E_In_Parameter
or else Ekind (Form2) /= E_In_Parameter))
-- Case 3: an elementary writable parameter that overlaps
-- a composite one.
or else (Is_Elementary_Type (Etype (Form1))
and then Ekind (Form1) /= E_In_Parameter
and then Is_Composite_Type (Etype (Form2)))
or else (Is_Elementary_Type (Etype (Form2))
and then Ekind (Form2) /= E_In_Parameter
and then Is_Composite_Type (Etype (Form1)))
then
-- Guard against previous errors
if No (Etype (Act1))
or else No (Etype (Act2))
then
null;
-- If type is explicitly by-reference, then it is not
-- covered by the legality rule, which only applies to
-- elementary types. Actually, the aliasing is most
-- likely intended, so don't emit a warning either.
elsif Explicitly_By_Reference (Form1)
or else Explicitly_By_Reference (Form2)
then
null;
-- We only report warnings on overlapping arrays and record
-- types if switch is set.
elsif not Warn_On_Overlap
and then not (Is_Elementary_Type (Etype (Form1))
and then
Is_Elementary_Type (Etype (Form2)))
then
null;
-- Here we may need to issue overlap message
else
Error_Msg_Warn :=
-- Overlap checking is an error only in Ada 2012. For
-- earlier versions of Ada, this is a warning.
Ada_Version < Ada_2012
-- Overlap is only illegal since Ada 2012 and only for
-- elementary types (passed by copy). For other types
-- we always have a warning in all versions. This is
-- clarified by AI12-0216.
or else not
(Is_Elementary_Type (Etype (Form1))
and then Is_Elementary_Type (Etype (Form2)))
-- debug flag -gnatd.E changes the error to a warning
-- even in Ada 2012 mode.
or else Error_To_Warning;
-- For greater clarity, give name of formal
Error_Msg_Node_2 := Form2;
-- This is one of the messages
Error_Msg_FE
("<.i<writable actual for & overlaps with actual for &",
Act1, Form1);
end if;
end if;
end if;
Next_Formal (Form2);
Next_Actual (Act2);
end loop;
Next_Formal (Form1);
Next_Actual (Act1);
end loop;
end Warn_On_Overlapping_Actuals;
------------------------------
-- Warn_On_Suspicious_Index --
------------------------------
procedure Warn_On_Suspicious_Index (Name : Entity_Id; X : Node_Id) is
Low_Bound : Uint;
-- Set to lower bound for a suspicious type
Ent : Entity_Id;
-- Entity for array reference
Typ : Entity_Id;
-- Array type
function Is_Suspicious_Type (Typ : Entity_Id) return Boolean;
-- Tests to see if Typ is a type for which we may have a suspicious
-- index, namely an unconstrained array type, whose lower bound is
-- either zero or one. If so, True is returned, and Low_Bound is set
-- to this lower bound. If not, False is returned, and Low_Bound is
-- undefined on return.
--
-- For now, we limit this to standard string types, so any other
-- unconstrained types return False. We may change our minds on this
-- later on, but strings seem the most important case.
procedure Test_Suspicious_Index;
-- Test if index is of suspicious type and if so, generate warning
------------------------
-- Is_Suspicious_Type --
------------------------
function Is_Suspicious_Type (Typ : Entity_Id) return Boolean is
LB : Node_Id;
begin
if Is_Array_Type (Typ)
and then not Is_Constrained (Typ)
and then Number_Dimensions (Typ) = 1
and then Is_Standard_String_Type (Typ)
and then not Has_Warnings_Off (Typ)
then
LB := Type_Low_Bound (Etype (First_Index (Typ)));
if Compile_Time_Known_Value (LB) then
Low_Bound := Expr_Value (LB);
return Low_Bound = Uint_0 or else Low_Bound = Uint_1;
end if;
end if;
return False;
end Is_Suspicious_Type;
---------------------------
-- Test_Suspicious_Index --
---------------------------
procedure Test_Suspicious_Index is
function Length_Reference (N : Node_Id) return Boolean;
-- Check if node N is of the form Name'Length
procedure Warn1;
-- Generate first warning line
procedure Warn_On_Index_Below_Lower_Bound;
-- Generate a warning on indexing the array with a literal value
-- below the lower bound of the index type.
procedure Warn_On_Literal_Index;
-- Generate a warning on indexing the array with a literal value
----------------------
-- Length_Reference --
----------------------
function Length_Reference (N : Node_Id) return Boolean is
R : constant Node_Id := Original_Node (N);
begin
return
Nkind (R) = N_Attribute_Reference
and then Attribute_Name (R) = Name_Length
and then Is_Entity_Name (Prefix (R))
and then Entity (Prefix (R)) = Ent;
end Length_Reference;
-----------
-- Warn1 --
-----------
procedure Warn1 is
begin
Error_Msg_Uint_1 := Low_Bound;
Error_Msg_FE -- CODEFIX
("?w?index for& may assume lower bound of^", X, Ent);
end Warn1;
-------------------------------------
-- Warn_On_Index_Below_Lower_Bound --
-------------------------------------
procedure Warn_On_Index_Below_Lower_Bound is
begin
if Is_Standard_String_Type (Typ) then
Discard_Node
(Compile_Time_Constraint_Error
(N => X,
Msg => "?w?string index should be positive"));
else
Discard_Node
(Compile_Time_Constraint_Error
(N => X,
Msg => "?w?index out of the allowed range"));
end if;
end Warn_On_Index_Below_Lower_Bound;
---------------------------
-- Warn_On_Literal_Index --
---------------------------
procedure Warn_On_Literal_Index is
begin
Warn1;
-- Case where original form of subscript is an integer literal
if Nkind (Original_Node (X)) = N_Integer_Literal then
if Intval (X) = Low_Bound then
Error_Msg_FE -- CODEFIX
("\?w?suggested replacement: `&''First`", X, Ent);
else
Error_Msg_Uint_1 := Intval (X) - Low_Bound;
Error_Msg_FE -- CODEFIX
("\?w?suggested replacement: `&''First + ^`", X, Ent);
end if;
-- Case where original form of subscript is more complex
else
-- Build string X'First - 1 + expression where the expression
-- is the original subscript. If the expression starts with "1
-- + ", then the "- 1 + 1" is elided.
Error_Msg_String (1 .. 13) := "'First - 1 + ";
Error_Msg_Strlen := 13;
declare
Sref : Source_Ptr := Sloc (First_Node (Original_Node (X)));
Tref : constant Source_Buffer_Ptr :=
Source_Text (Get_Source_File_Index (Sref));
-- Tref (Sref) is used to scan the subscript
Pctr : Natural;
-- Parentheses counter when scanning subscript
begin
-- Tref (Sref) points to start of subscript
-- Elide - 1 if subscript starts with 1 +
if Tref (Sref .. Sref + 2) = "1 +" then
Error_Msg_Strlen := Error_Msg_Strlen - 6;
Sref := Sref + 2;
elsif Tref (Sref .. Sref + 1) = "1+" then
Error_Msg_Strlen := Error_Msg_Strlen - 6;
Sref := Sref + 1;
end if;
-- Now we will copy the subscript to the string buffer
Pctr := 0;
loop
-- Count parens, exit if terminating right paren. Note
-- check to ignore paren appearing as character literal.
if Tref (Sref + 1) = '''
and then
Tref (Sref - 1) = '''
then
null;
else
if Tref (Sref) = '(' then
Pctr := Pctr + 1;
elsif Tref (Sref) = ')' then
exit when Pctr = 0;
Pctr := Pctr - 1;
end if;
end if;
-- Done if terminating double dot (slice case)
exit when Pctr = 0
and then (Tref (Sref .. Sref + 1) = ".."
or else
Tref (Sref .. Sref + 2) = " ..");
-- Quit if we have hit EOF character, something wrong
if Tref (Sref) = EOF then
return;
end if;
-- String literals are too much of a pain to handle
if Tref (Sref) = '"' or else Tref (Sref) = '%' then
return;
end if;
-- If we have a 'Range reference, then this is a case
-- where we cannot easily give a replacement. Don't try.
if Tref (Sref .. Sref + 4) = "range"
and then Tref (Sref - 1) < 'A'
and then Tref (Sref + 5) < 'A'
then
return;
end if;
-- Else store next character
Error_Msg_Strlen := Error_Msg_Strlen + 1;
Error_Msg_String (Error_Msg_Strlen) := Tref (Sref);
Sref := Sref + 1;
-- If we get more than 40 characters then the expression
-- is too long to copy, or something has gone wrong. In
-- either case, just skip the attempt at a suggested fix.
if Error_Msg_Strlen > 40 then
return;
end if;
end loop;
end;
-- Replacement subscript is now in string buffer
Error_Msg_FE -- CODEFIX
("\?w?suggested replacement: `&~`", Original_Node (X), Ent);
end if;
end Warn_On_Literal_Index;
-- Start of processing for Test_Suspicious_Index
begin
-- Nothing to do if subscript does not come from source (we don't
-- want to give garbage warnings on compiler expanded code, e.g. the
-- loops generated for slice assignments. Such junk warnings would
-- be placed on source constructs with no subscript in sight).
if not Comes_From_Source (Original_Node (X)) then
return;
end if;
-- Case where subscript is a constant integer
if Nkind (X) = N_Integer_Literal then
-- Case where subscript is lower than the lowest possible bound.
-- This might be the case for example when programmers try to
-- access a string at index 0, as they are used to in other
-- programming languages like C.
if Intval (X) < Low_Bound then
Warn_On_Index_Below_Lower_Bound;
else
Warn_On_Literal_Index;
end if;
-- Case where subscript is of the form X'Length
elsif Length_Reference (X) then
Warn1;
Error_Msg_Node_2 := Ent;
Error_Msg_FE
("\?w?suggest replacement of `&''Length` by `&''Last`",
X, Ent);
-- Case where subscript is of the form X'Length - expression
elsif Nkind (X) = N_Op_Subtract
and then Length_Reference (Left_Opnd (X))
then
Warn1;
Error_Msg_Node_2 := Ent;
Error_Msg_FE
("\?w?suggest replacement of `&''Length` by `&''Last`",
Left_Opnd (X), Ent);
end if;
end Test_Suspicious_Index;
-- Start of processing for Warn_On_Suspicious_Index
begin
-- Only process if warnings activated
if Warn_On_Assumed_Low_Bound then
-- Test if array is simple entity name
if Is_Entity_Name (Name) then
-- Test if array is parameter of unconstrained string type
Ent := Entity (Name);
Typ := Etype (Ent);
if Is_Formal (Ent)
and then Is_Suspicious_Type (Typ)
and then not Low_Bound_Tested (Ent)
then
Test_Suspicious_Index;
end if;
end if;
end if;
end Warn_On_Suspicious_Index;
-------------------------------
-- Warn_On_Suspicious_Update --
-------------------------------
procedure Warn_On_Suspicious_Update (N : Node_Id) is
Par : constant Node_Id := Parent (N);
Arg : Node_Id;
begin
-- Only process if warnings activated
if Warn_On_Suspicious_Contract then
if Nkind (Par) in N_Op_Eq | N_Op_Ne then
if N = Left_Opnd (Par) then
Arg := Right_Opnd (Par);
else
Arg := Left_Opnd (Par);
end if;
if Same_Object (Prefix (N), Arg) then
if Nkind (Par) = N_Op_Eq then
Error_Msg_N
("suspicious equality test with modified version of "
& "same object?.t?", Par);
else
Error_Msg_N
("suspicious inequality test with modified version of "
& "same object?.t?", Par);
end if;
end if;
end if;
end if;
end Warn_On_Suspicious_Update;
--------------------------------------
-- Warn_On_Unassigned_Out_Parameter --
--------------------------------------
procedure Warn_On_Unassigned_Out_Parameter
(Return_Node : Node_Id;
Scope_Id : Entity_Id)
is
Form : Entity_Id;
begin
-- Ignore if procedure or return statement does not come from source
if not Comes_From_Source (Scope_Id)
or else not Comes_From_Source (Return_Node)
then
return;
end if;
-- Before we issue the warning, add an ad hoc defence against the most
-- common case of false positives with this warning which is the case
-- where there is a Boolean OUT parameter that has been set, and whose
-- meaning is "ignore the values of the other parameters". We can't of
-- course reliably tell this case at compile time, but the following
-- test kills a lot of false positives, without generating a significant
-- number of false negatives (missed real warnings).
Form := First_Formal (Scope_Id);
while Present (Form) loop
if Ekind (Form) = E_Out_Parameter
and then Root_Type (Etype (Form)) = Standard_Boolean
and then not Never_Set_In_Source_Check_Spec (Form)
then
return;
end if;
Next_Formal (Form);
end loop;
-- Loop through formals
Form := First_Formal (Scope_Id);
while Present (Form) loop
-- We are only interested in OUT parameters that come from source
-- and are never set in the source, and furthermore only in scalars
-- since non-scalars generate too many false positives.
if Ekind (Form) = E_Out_Parameter
and then Never_Set_In_Source_Check_Spec (Form)
and then Is_Scalar_Type (Etype (Form))
and then not Present (Unset_Reference (Form))
then
-- Here all conditions are met, record possible unset reference
Set_Unset_Reference (Form, Return_Node);
end if;
Next_Formal (Form);
end loop;
end Warn_On_Unassigned_Out_Parameter;
---------------------------------
-- Warn_On_Unreferenced_Entity --
---------------------------------
procedure Warn_On_Unreferenced_Entity
(Spec_E : Entity_Id;
Body_E : Entity_Id := Empty)
is
E : Entity_Id := Spec_E;
begin
if not Referenced_Check_Spec (E)
and then not Has_Pragma_Unreferenced_Check_Spec (E)
and then not Warnings_Off_Check_Spec (E)
and then not Has_Junk_Name (Spec_E)
and then not Is_Exported (Spec_E)
then
case Ekind (E) is
when E_Variable =>
-- Case of variable that is assigned but not read. We suppress
-- the message if the variable is volatile, has an address
-- clause, is aliased, or is a renaming, or is imported.
if Referenced_As_LHS_Check_Spec (E) then
if Warn_On_Modified_Unread
and then No (Address_Clause (E))
and then not Is_Volatile (E)
and then not Is_Imported (E)
and then not Is_Aliased (E)
and then No (Renamed_Object (E))
then
if not Has_Pragma_Unmodified_Check_Spec (E) then
Error_Msg_N -- CODEFIX
("?m?variable & is assigned but never read!", E);
end if;
Set_Last_Assignment (E, Empty);
end if;
-- Normal case of neither assigned nor read (exclude variables
-- referenced as out parameters, since we already generated
-- appropriate warnings at the call point in this case).
elsif not Referenced_As_Out_Parameter (E) then
-- We suppress the message for types for which a valid
-- pragma Unreferenced_Objects has been given, otherwise
-- we go ahead and give the message.
if not Has_Pragma_Unreferenced_Objects (Etype (E)) then
-- Distinguish renamed case in message
if Present (Renamed_Object (E))
and then Comes_From_Source (Renamed_Object (E))
then
Error_Msg_N -- CODEFIX
("?u?renamed variable & is not referenced!", E);
else
Error_Msg_N -- CODEFIX
("?u?variable & is not referenced!", E);
end if;
end if;
end if;
when E_Constant =>
if not Has_Pragma_Unreferenced_Objects (Etype (E)) then
if Present (Renamed_Object (E))
and then Comes_From_Source (Renamed_Object (E))
then
Error_Msg_N -- CODEFIX
("?u?renamed constant & is not referenced!", E);
else
Error_Msg_N -- CODEFIX
("?u?constant & is not referenced!", E);
end if;
end if;
when E_In_Out_Parameter
| E_In_Parameter
=>
-- Do not emit message for formals of a renaming, because they
-- are never referenced explicitly.
if Nkind (Original_Node (Unit_Declaration_Node (Scope (E)))) /=
N_Subprogram_Renaming_Declaration
then
-- Suppress this message for an IN OUT parameter of a
-- non-scalar type, since it is normal to have only an
-- assignment in such a case.
if Ekind (E) = E_In_Parameter
or else not Referenced_As_LHS_Check_Spec (E)
or else Is_Scalar_Type (Etype (E))
then
if Present (Body_E) then
E := Body_E;
end if;
declare
S : Node_Id := Scope (E);
begin
if Ekind (S) = E_Subprogram_Body then
S := Parent (S);
while Nkind (S) not in
N_Expression_Function |
N_Subprogram_Body |
N_Subprogram_Renaming_Declaration |
N_Empty
loop
S := Parent (S);
end loop;
if Present (S) then
S := Corresponding_Spec (S);
end if;
end if;
-- Do not warn for dispatching operations, because
-- that causes too much noise. Also do not warn for
-- trivial subprograms (e.g. stubs).
if (No (S) or else not Is_Dispatching_Operation (S))
and then not Is_Trivial_Subprogram (Scope (E))
then
Error_Msg_NE -- CODEFIX
("?u?formal parameter & is not referenced!",
E, Spec_E);
end if;
end;
end if;
end if;
when E_Out_Parameter =>
null;
when E_Discriminant =>
Error_Msg_N ("?u?discriminant & is not referenced!", E);
when E_Named_Integer
| E_Named_Real
=>
Error_Msg_N -- CODEFIX
("?u?named number & is not referenced!", E);
when Formal_Object_Kind =>
Error_Msg_N -- CODEFIX
("?u?formal object & is not referenced!", E);
when E_Enumeration_Literal =>
Error_Msg_N -- CODEFIX
("?u?literal & is not referenced!", E);
when E_Function =>
Error_Msg_N -- CODEFIX
("?u?function & is not referenced!", E);
when E_Procedure =>
Error_Msg_N -- CODEFIX
("?u?procedure & is not referenced!", E);
when E_Package =>
Error_Msg_N -- CODEFIX
("?u?package & is not referenced!", E);
when E_Exception =>
Error_Msg_N -- CODEFIX
("?u?exception & is not referenced!", E);
when E_Label =>
Error_Msg_N -- CODEFIX
("?u?label & is not referenced!", E);
when E_Generic_Procedure =>
Error_Msg_N -- CODEFIX
("?u?generic procedure & is never instantiated!", E);
when E_Generic_Function =>
Error_Msg_N -- CODEFIX
("?u?generic function & is never instantiated!", E);
when Type_Kind =>
Error_Msg_N -- CODEFIX
("?u?type & is not referenced!", E);
when others =>
Error_Msg_N -- CODEFIX
("?u?& is not referenced!", E);
end case;
-- Kill warnings on the entity on which the message has been posted
-- (nothing is posted on out parameters because back end might be
-- able to uncover an uninitialized path, and warn accordingly).
if Ekind (E) /= E_Out_Parameter then
Set_Warnings_Off (E);
end if;
end if;
end Warn_On_Unreferenced_Entity;
--------------------------------
-- Warn_On_Useless_Assignment --
--------------------------------
procedure Warn_On_Useless_Assignment
(Ent : Entity_Id;
N : Node_Id := Empty)
is
P : Node_Id;
X : Node_Id;
function Check_Ref (N : Node_Id) return Traverse_Result;
-- Used to instantiate Traverse_Func. Returns Abandon if a reference to
-- the entity in question is found.
function Test_No_Refs is new Traverse_Func (Check_Ref);
---------------
-- Check_Ref --
---------------
function Check_Ref (N : Node_Id) return Traverse_Result is
begin
-- Check reference to our identifier. We use name equality here
-- because the exception handlers have not yet been analyzed. This
-- is not quite right, but it really does not matter that we fail
-- to output the warning in some obscure cases of name clashes.
if Nkind (N) = N_Identifier and then Chars (N) = Chars (Ent) then
return Abandon;
else
return OK;
end if;
end Check_Ref;
-- Start of processing for Warn_On_Useless_Assignment
begin
-- Check if this is a case we want to warn on, a scalar or access
-- variable with the last assignment field set, with warnings enabled,
-- and which is not imported or exported. We also check that it is OK
-- to capture the value. We are not going to capture any value, but
-- the warning message depends on the same kind of conditions.
-- If the assignment appears as an out-parameter in a call within an
-- expression function it may be detected twice: once when expression
-- itself is analyzed, and once when the constructed body is analyzed.
-- We don't want to emit a spurious warning in this case.
if Is_Assignable (Ent)
and then not Is_Return_Object (Ent)
and then Present (Last_Assignment (Ent))
and then Last_Assignment (Ent) /= N
and then not Is_Imported (Ent)
and then not Is_Exported (Ent)
and then Safe_To_Capture_Value (N, Ent)
and then not Has_Pragma_Unreferenced_Check_Spec (Ent)
and then not Has_Junk_Name (Ent)
then
-- Before we issue the message, check covering exception handlers.
-- Search up tree for enclosing statement sequences and handlers.
P := Parent (Last_Assignment (Ent));
while Present (P) loop
-- Something is really wrong if we don't find a handled statement
-- sequence, so just suppress the warning.
if No (P) then
Set_Last_Assignment (Ent, Empty);
return;
-- When we hit a package/subprogram body, issue warning and exit
elsif Nkind (P) in N_Entry_Body
| N_Package_Body
| N_Subprogram_Body
| N_Task_Body
then
-- Case of assigned value never referenced
if No (N) then
declare
LA : constant Node_Id := Last_Assignment (Ent);
begin
-- Don't give this for OUT and IN OUT formals, since
-- clearly caller may reference the assigned value. Also
-- never give such warnings for internal variables. In
-- either case, word the warning in a conditional way,
-- because in the case of a component of a controlled
-- type, the assigned value might be referenced in the
-- Finalize operation, so we can't make a definitive
-- statement that it's never referenced.
if Ekind (Ent) = E_Variable
and then not Is_Internal_Name (Chars (Ent))
then
-- Give appropriate message, distinguishing between
-- assignment statements and out parameters.
if Nkind (Parent (LA)) in N_Parameter_Association
| N_Procedure_Call_Statement
then
if Warn_On_All_Unread_Out_Parameters then
Error_Msg_NE
("?m?& modified by call, but value might not "
& "be referenced", LA, Ent);
end if;
else
Error_Msg_NE -- CODEFIX
("?m?possibly useless assignment to&, value "
& "might not be referenced!", LA, Ent);
end if;
end if;
end;
-- Case of assigned value overwritten
else
declare
LA : constant Node_Id := Last_Assignment (Ent);
begin
Error_Msg_Sloc := Sloc (N);
-- Give appropriate message, distinguishing between
-- assignment statements and out parameters.
if Nkind (Parent (LA)) in N_Procedure_Call_Statement
| N_Parameter_Association
then
Error_Msg_NE
("?m?& modified by call, but value overwritten #!",
LA, Ent);
else
Error_Msg_NE -- CODEFIX
("?m?useless assignment to&, value overwritten #!",
LA, Ent);
end if;
end;
end if;
-- Clear last assignment indication and we are done
Set_Last_Assignment (Ent, Empty);
return;
-- Enclosing handled sequence of statements
elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
-- Check exception handlers present
if Present (Exception_Handlers (P)) then
-- If we are not at the top level, we regard an inner
-- exception handler as a decisive indicator that we should
-- not generate the warning, since the variable in question
-- may be accessed after an exception in the outer block.
if Nkind (Parent (P)) not in N_Entry_Body
| N_Package_Body
| N_Subprogram_Body
| N_Task_Body
then
Set_Last_Assignment (Ent, Empty);
return;
-- Otherwise we are at the outer level. An exception
-- handler is significant only if it references the
-- variable in question, or if the entity in question
-- is an OUT or IN OUT parameter, in which case
-- the caller can reference it after the exception
-- handler completes.
else
if Is_Formal (Ent) then
Set_Last_Assignment (Ent, Empty);
return;
else
X := First (Exception_Handlers (P));
while Present (X) loop
if Test_No_Refs (X) = Abandon then
Set_Last_Assignment (Ent, Empty);
return;
end if;
Next (X);
end loop;
end if;
end if;
end if;
end if;
P := Parent (P);
end loop;
end if;
end Warn_On_Useless_Assignment;
---------------------------------
-- Warn_On_Useless_Assignments --
---------------------------------
procedure Warn_On_Useless_Assignments (E : Entity_Id) is
Ent : Entity_Id;
begin
Process_Deferred_References;
if Warn_On_Modified_Unread
and then In_Extended_Main_Source_Unit (E)
then
Ent := First_Entity (E);
while Present (Ent) loop
Warn_On_Useless_Assignment (Ent);
Next_Entity (Ent);
end loop;
end if;
end Warn_On_Useless_Assignments;
-----------------------------
-- Warnings_Off_Check_Spec --
-----------------------------
function Warnings_Off_Check_Spec (E : Entity_Id) return Boolean is
begin
if Is_Formal (E) and then Present (Spec_Entity (E)) then
-- Note: use of OR here instead of OR ELSE is deliberate, we want
-- to mess with flags on both entities.
return Has_Warnings_Off (E)
or
Has_Warnings_Off (Spec_Entity (E));
else
return Has_Warnings_Off (E);
end if;
end Warnings_Off_Check_Spec;
end Sem_Warn;
|
francesco-bongiovanni/ewok-kernel | Ada | 6,656 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with debug;
with ewok.exported.gpios; use ewok.exported.gpios;
with soc.gpio; use type soc.gpio.t_GPIO_port_access;
use type soc.gpio.t_gpio_pin_index;
with soc.rcc;
package body ewok.gpio
with spark_mode => off
is
function to_pin_alt_func
(u : unsigned_32) return soc.gpio.t_pin_alt_func
is
pragma warnings (off);
function conv is new ada.unchecked_conversion
(unsigned_32, soc.gpio.t_pin_alt_func);
pragma warnings (on);
begin
if u > 15 then
raise program_error;
end if;
return conv (u);
end to_pin_alt_func;
function is_used
(ref : ewok.exported.gpios.t_gpio_ref)
return boolean
is
begin
return gpio_points(ref.port, ref.pin).used;
end is_used;
procedure register
(task_id : in ewok.tasks_shared.t_task_id;
device_id : in ewok.devices_shared.t_device_id;
conf_a : in ewok.exported.gpios.t_gpio_config_access;
success : out boolean)
is
ref : constant ewok.exported.gpios.t_gpio_ref := conf_a.all.kref;
begin
if gpio_points(ref.port, ref.pin).used then
debug.log (debug.WARNING, "Registering GPIO: port" &
soc.gpio.t_gpio_port_index'image (ref.port) & ", pin" &
soc.gpio.t_gpio_pin_index'image (ref.pin) & " is already used.");
success := false;
else
gpio_points(ref.port, ref.pin).used := true;
gpio_points(ref.port, ref.pin).task_id := task_id;
gpio_points(ref.port, ref.pin).device_id := device_id;
gpio_points(ref.port, ref.pin).config := conf_a;
success := true;
end if;
end register;
procedure config
(conf : in ewok.exported.gpios.t_gpio_config_access)
is
gpio : soc.gpio.t_GPIO_port_access;
begin
-- Enable RCC
case conf.all.kref.port is
when soc.gpio.GPIO_PA => soc.rcc.RCC.AHB1.GPIOAEN := true;
when soc.gpio.GPIO_PB => soc.rcc.RCC.AHB1.GPIOBEN := true;
when soc.gpio.GPIO_PC => soc.rcc.RCC.AHB1.GPIOCEN := true;
when soc.gpio.GPIO_PD => soc.rcc.RCC.AHB1.GPIODEN := true;
when soc.gpio.GPIO_PE => soc.rcc.RCC.AHB1.GPIOEEN := true;
when soc.gpio.GPIO_PF => soc.rcc.RCC.AHB1.GPIOFEN := true;
when soc.gpio.GPIO_PG => soc.rcc.RCC.AHB1.GPIOGEN := true;
when soc.gpio.GPIO_PH => soc.rcc.RCC.AHB1.GPIOHEN := true;
when soc.gpio.GPIO_PI => soc.rcc.RCC.AHB1.GPIOIEN := true;
end case;
gpio := soc.gpio.get_port_access (conf.all.kref.port);
if conf.all.settings.set_mode then
gpio.all.MODER.pin (conf.all.kref.pin) :=
soc.gpio.t_pin_mode'val
(t_interface_gpio_mode'pos (conf.all.mode));
end if;
if conf.all.settings.set_type then
gpio.all.OTYPER.pin (conf.all.kref.pin) :=
soc.gpio.t_pin_output_type'val
(t_interface_gpio_type'pos (conf.all.otype));
end if;
if conf.all.settings.set_speed then
gpio.all.OSPEEDR.pin (conf.all.kref.pin) :=
soc.gpio.t_pin_output_speed'val
(t_interface_gpio_speed'pos (conf.all.ospeed));
end if;
if conf.all.settings.set_pupd then
gpio.all.PUPDR.pin (conf.all.kref.pin) :=
soc.gpio.t_pin_pupd'val
(t_interface_gpio_pupd'pos (conf.all.pupd));
end if;
if conf.all.settings.set_bsr_r then
gpio.all.BSRR.BR (conf.all.kref.pin) := types.to_bit (conf.all.bsr_r);
end if;
if conf.all.settings.set_bsr_s then
gpio.all.BSRR.BS (conf.all.kref.pin) := types.to_bit (conf.all.bsr_s);
end if;
-- FIXME - Writing to LCKR register requires a specific sequence
-- describe in section 8.4.8 (RM 00090)
if conf.all.settings.set_lck then
gpio.all.LCKR.pin (conf.all.kref.pin) :=
soc.gpio.t_pin_lock'val (conf.all.lck);
end if;
if conf.all.settings.set_af then
if conf.all.kref.pin < 8 then
gpio.all.AFRL.pin (conf.all.kref.pin) :=
to_pin_alt_func (conf.all.af);
else
gpio.all.AFRH.pin (conf.all.kref.pin) :=
to_pin_alt_func (conf.all.af);
end if;
end if;
end config;
procedure write_pin
(ref : in ewok.exported.gpios.t_gpio_ref;
value : in bit)
is
port : soc.gpio.t_GPIO_port_access;
begin
port := soc.gpio.get_port_access (ref.port);
port.all.ODR.pin (ref.pin) := value;
end write_pin;
function read_pin
(ref : ewok.exported.gpios.t_gpio_ref)
return bit
is
port : soc.gpio.t_GPIO_port_access;
begin
port := soc.gpio.get_port_access (ref.port);
return port.all.IDR.pin (ref.pin);
end read_pin;
function belong_to
(task_id : ewok.tasks_shared.t_task_id;
ref : ewok.exported.gpios.t_gpio_ref)
return boolean
is
begin
if gpio_points(ref.port, ref.pin).used and
gpio_points(ref.port, ref.pin).task_id = task_id
then
return true;
else
return false;
end if;
end belong_to;
function get_task_id
(ref : in ewok.exported.gpios.t_gpio_ref)
return ewok.tasks_shared.t_task_id
is
begin
return gpio_points(ref.port, ref.pin).task_id;
end get_task_id;
function get_device_id
(ref : in ewok.exported.gpios.t_gpio_ref)
return ewok.devices_shared.t_device_id
is
begin
return gpio_points(ref.port, ref.pin).device_id;
end get_device_id;
function get_config
(ref : in ewok.exported.gpios.t_gpio_ref)
return ewok.exported.gpios.t_gpio_config_access
is
begin
return gpio_points(ref.port, ref.pin).config;
end get_config;
end ewok.gpio;
|
CarlosCaravaca/Space-Software-Project-Ada | Ada | 4,138 | adb | ---------------
-- Package body
---------------
-- Includes
with Ada.Text_IO; use Ada.Text_IO;
package body Rasp_Code is
-- Define constants
MAX_TEMPERATURE : Float := 90.0;
MIN_TEMPERATURE : Float := -10.0;
AVG_TEMPERATURE : Float := 40.0;
procedure control_temperature is
begin
-- check if the temperature is lower or higher
if temperature < AVG_TEMPERATURE then
-- set heater
heater_on := 1;
elsif temperature >= AVG_TEMPERATURE then
-- unset heater
heater_on := 0;
end if;
end control_temperature;
procedure send_cmd_msg (cmd : Command) is
begin
loop
case cmd is
-- First we check if the command is SET_HEAT_CMD
when SET_HEAT_CMD =>
-- We fill the variable next_cmd_msg to contain
-- the corresponding information.
next_cmd_msg.cmd := Command'Pos(SET_HEAT_CMD);
next_cmd_msg.set_heater := heater_on;
exit;
when others =>
-- For the rest of the commands the field
-- set_heater is not necessary, but it is
-- specified to avoid undefined behaviour.
next_cmd_msg.cmd := Command'Pos(cmd);
next_cmd_msg.set_heater := 0;
exit;
end case;
end loop;
end send_cmd_msg;
procedure recv_res_msg is
begin
loop
case last_res_msg.cmd is
when Command'Pos(NO_CMD) =>
-- Do nothing
exit;
when Command'Pos(SET_HEAT_CMD) =>
-- Read status
check_status (last_res_msg.status);
-- Clean the response
last_res_msg := (Command'Pos(NO_CMD), 0);
exit;
when Command'Pos(READ_SUN_CMD) =>
-- Read status
check_status (last_res_msg.status);
-- Update sunlight_on variable
sunlight_on := last_res_msg.sunlight_on;
-- Clean the response
last_res_msg := (Command'Pos(NO_CMD), 0);
exit;
when Command'Pos(READ_TEMP_CMD) =>
-- Read status
check_status (last_res_msg.status);
-- Update temperature variable
temperature := last_res_msg.temperature;
-- Clean the response
last_res_msg := (Command'Pos(NO_CMD), 0);
exit;
when Command'Pos(READ_POS_CMD) =>
-- Read status
check_status (last_res_msg.status);
-- Update position variable
position.x := last_res_msg.position.x;
position.y := last_res_msg.position.y;
position.z := last_res_msg.position.z;
-- Clean the response
last_res_msg := (Command'Pos(NO_CMD), 0);
exit;
when others =>
-- Acoid undefined behaviour
exit;
end case;
end loop;
end recv_res_msg;
procedure check_status (status : Integer) is
begin
loop
case status is
when 1 =>
-- The execution went well
Put_Line ("The operation was correctly performed.");
exit;
when 0 =>
-- The execution went well
Put_Line ("ERROR: The operation could not be performed.");
exit;
when others =>
-- The execution went well
Put_Line ("ERROR: Something really bad happened.");
exit;
end case;
end loop;
end check_status;
end Rasp_Code; |
zhmu/ananas | Ada | 32,014 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ P A K D --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, 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. --
-- --
------------------------------------------------------------------------------
-- Expand routines for manipulation of packed arrays
with Rtsfind; use Rtsfind;
with Types; use Types;
package Exp_Pakd is
-------------------------------------
-- Implementation of Packed Arrays --
-------------------------------------
-- When a packed array (sub)type is frozen, we create a corresponding
-- type that will be used to hold the bits of the packed value, and store
-- the entity for this type in the Packed_Array_Impl_Type field of the
-- E_Array_Type or E_Array_Subtype entity for the packed array.
-- This packed array type has the name xxxPn, where xxx is the name
-- of the packed type, and n is the component size. The expanded
-- declaration declares a type that is one of the following:
-- For an unconstrained array with component size 1,2,4 or any other
-- odd component size. These are the cases in which we do not need
-- to align the underlying array.
-- type xxxPn is new Packed_Bytes1;
-- For an unconstrained array with component size that is divisible
-- by 2, but not divisible by 4 (other than 2 itself). These are the
-- cases in which we can generate better code if the underlying array
-- is 2-byte aligned (see System.Pack_14 in file s-pack14 for example).
-- type xxxPn is new Packed_Bytes2;
-- For an unconstrained array with component size that is divisible
-- by 4, other than powers of 2 (which either come under the 1,2,4
-- exception above, or are not packed at all). These are cases where
-- we can generate better code if the underlying array is 4-byte
-- aligned (see System.Pack_20 in file s-pack20 for example).
-- type xxxPn is new Packed_Bytes4;
-- For a constrained array with a static index type where the number
-- of bits does not exceed the size of Unsigned:
-- type xxxPn is new Unsigned range 0 .. 2 ** nbits - 1;
-- For a constrained array with a static index type where the number
-- of bits is greater than the size of Unsigned, but does not exceed
-- the size of Long_Long_Unsigned:
-- type xxxPn is new Long_Long_Unsigned range 0 .. 2 ** nbits - 1;
-- For all other constrained arrays, we use one of
-- type xxxPn is new Packed_Bytes1 (0 .. m);
-- type xxxPn is new Packed_Bytes2 (0 .. m);
-- type xxxPn is new Packed_Bytes4 (0 .. m);
-- where m is calculated (from the length of the original packed array)
-- to hold the required number of bits, and the choice of the particular
-- Packed_Bytes{1,2,4} type is made on the basis of alignment needs as
-- described above for the unconstrained case.
-- When the packed array (sub)type is specified to have the reverse scalar
-- storage order, the Packed_Bytes{1,2,4} references above are replaced
-- with Rev_Packed_Bytes{1,2,4}. This is necessary because, although the
-- component type is Packed_Byte and therefore endian neutral, the scalar
-- storage order of the new type must be compatible with that of an outer
-- composite type, if this composite type contains a component whose type
-- is the packed array (sub)type and which does not start or does not end
-- on a storage unit boundary.
-- When a variable of packed array type is allocated, gigi will allocate
-- the amount of space indicated by the corresponding packed array type.
-- However, we do NOT attempt to rewrite the types of any references or
-- to retype the variable itself, since this would cause all kinds of
-- semantic problems in the front end (remember that expansion proceeds
-- at the same time as analysis).
-- For an indexed reference to a packed array, we simply convert the
-- reference to the appropriate equivalent reference to the object
-- of the packed array type (using unchecked conversion).
-- In some cases (for internally generated types, and for the subtypes
-- for record fields that depend on a discriminant), the corresponding
-- packed type cannot be easily generated in advance. In these cases,
-- we generate the required subtype on the fly at the reference point.
-- For the modular case, any unused bits are initialized to zero, and
-- all operations maintain these bits as zero (where necessary all
-- unchecked conversions from corresponding array values require
-- these bits to be clear, which is done automatically by gigi).
-- For the array cases, there can be unused bits in the last byte, and
-- these are neither initialized, nor treated specially in operations
-- (i.e. it is allowable for these bits to be clobbered, e.g. by not).
---------------------------
-- Endian Considerations --
---------------------------
-- The standard does not specify the way in which bits are numbered in
-- a packed array. There are two reasonable rules for deciding this:
-- Store the first bit at right end (low order) word. This means
-- that the scaled subscript can be used directly as a left shift
-- count (if we put bit 0 at the left end, then we need an extra
-- subtract to compute the shift count).
-- Layout the bits so that if the packed boolean array is overlaid on
-- a record, using unchecked conversion, then bit 0 of the array is
-- the same as the bit numbered bit 0 in a record representation
-- clause applying to the record. For example:
-- type Rec is record
-- C : Bits4;
-- D : Bits7;
-- E : Bits5;
-- end record;
-- for Rec use record
-- C at 0 range 0 .. 3;
-- D at 0 range 4 .. 10;
-- E at 0 range 11 .. 15;
-- end record;
-- type P16 is array (0 .. 15) of Boolean;
-- pragma Pack (P16);
-- Now if we use unchecked conversion to convert a value of the record
-- type to the packed array type, according to this second criterion,
-- we would expect field D to occupy bits 4..10 of the Boolean array.
-- Although not required, this correspondence seems a highly desirable
-- property, and is one that GNAT decides to guarantee. For a little
-- endian machine, we can also meet the first requirement, but for a
-- big endian machine, it will be necessary to store the first bit of
-- a Boolean array in the left end (most significant) bit of the word.
-- This may cost an extra instruction on some machines, but we consider
-- that a worthwhile price to pay for the consistency.
-- One more important point arises in the case where we have a constrained
-- subtype of an unconstrained array. Take the case of 20 bits. For the
-- unconstrained representation, we would use an array of bytes:
-- Little-endian case
-- 8-7-6-5-4-3-2-1 16-15-14-13-12-11-10-9 x-x-x-x-20-19-18-17
-- Big-endian case
-- 1-2-3-4-5-6-7-8 9-10-11-12-13-14-15-16 17-18-19-20-x-x-x-x
-- For the constrained case, we use a 20-bit modular value, but in
-- general this value may well be stored in 32 bits. Let's look at
-- what it looks like:
-- Little-endian case
-- x-x-x-x-x-x-x-x-x-x-x-x-20-19-18-17-...-10-9-8-7-6-5-4-3-2-1
-- which stored in memory looks like
-- 8-7-...-2-1 16-15-...-10-9 x-x-x-x-20-19-18-17 x-x-x-x-x-x-x
-- An important rule is that the constrained and unconstrained cases
-- must have the same bit representation in memory, since we will often
-- convert from one to the other (e.g. when calling a procedure whose
-- formal is unconstrained). As we see, that criterion is met for the
-- little-endian case above. Now let's look at the big-endian case:
-- Big-endian case
-- x-x-x-x-x-x-x-x-x-x-x-x-1-2-3-4-5-6-7-8-9-10-...-17-18-19-20
-- which stored in memory looks like
-- x-x-x-x-x-x-x-x x-x-x-x-1-2-3-4 5-6-...11-12 13-14-...-19-20
-- That won't do, the representation value in memory is NOT the same in
-- the constrained and unconstrained case. The solution is to store the
-- modular value left-justified:
-- 1-2-3-4-5-6-7-8-9-10-...-17-18-19-20-x-x-x-x-x-x-x-x-x-x-x
-- which stored in memory looks like
-- 1-2-...-7-8 9-10-...15-16 17-18-19-20-x-x-x-x x-x-x-x-x-x-x-x
-- and now, we do indeed have the same representation for the memory
-- version in the constrained and unconstrained cases.
----------------------------------------------
-- Entity Tables for Packed Access Routines --
----------------------------------------------
-- For the cases of component size = 3,5-7,9-15,17-31,33-63,65-127 we call
-- library routines. These tables provide the entity for the right routine.
-- They are exposed in the spec to allow checking for the presence of the
-- needed routine when an array is subject to pragma Pack.
type E_Array is array (Int range 1 .. 127) of RE_Id;
-- Array of Bits_nn entities. Note that we do not use library routines
-- for the 8-bit and 16-bit cases, but we still fill in the table, using
-- entries from System.Unsigned, because we also use this table for
-- certain special unchecked conversions in the big-endian case.
Bits_Id : constant E_Array :=
(01 => RE_Bits_1,
02 => RE_Bits_2,
03 => RE_Bits_03,
04 => RE_Bits_4,
05 => RE_Bits_05,
06 => RE_Bits_06,
07 => RE_Bits_07,
08 => RE_Unsigned_8,
09 => RE_Bits_09,
10 => RE_Bits_10,
11 => RE_Bits_11,
12 => RE_Bits_12,
13 => RE_Bits_13,
14 => RE_Bits_14,
15 => RE_Bits_15,
16 => RE_Unsigned_16,
17 => RE_Bits_17,
18 => RE_Bits_18,
19 => RE_Bits_19,
20 => RE_Bits_20,
21 => RE_Bits_21,
22 => RE_Bits_22,
23 => RE_Bits_23,
24 => RE_Bits_24,
25 => RE_Bits_25,
26 => RE_Bits_26,
27 => RE_Bits_27,
28 => RE_Bits_28,
29 => RE_Bits_29,
30 => RE_Bits_30,
31 => RE_Bits_31,
32 => RE_Unsigned_32,
33 => RE_Bits_33,
34 => RE_Bits_34,
35 => RE_Bits_35,
36 => RE_Bits_36,
37 => RE_Bits_37,
38 => RE_Bits_38,
39 => RE_Bits_39,
40 => RE_Bits_40,
41 => RE_Bits_41,
42 => RE_Bits_42,
43 => RE_Bits_43,
44 => RE_Bits_44,
45 => RE_Bits_45,
46 => RE_Bits_46,
47 => RE_Bits_47,
48 => RE_Bits_48,
49 => RE_Bits_49,
50 => RE_Bits_50,
51 => RE_Bits_51,
52 => RE_Bits_52,
53 => RE_Bits_53,
54 => RE_Bits_54,
55 => RE_Bits_55,
56 => RE_Bits_56,
57 => RE_Bits_57,
58 => RE_Bits_58,
59 => RE_Bits_59,
60 => RE_Bits_60,
61 => RE_Bits_61,
62 => RE_Bits_62,
63 => RE_Bits_63,
64 => RE_Unsigned_64,
65 => RE_Bits_65,
66 => RE_Bits_66,
67 => RE_Bits_67,
68 => RE_Bits_68,
69 => RE_Bits_69,
70 => RE_Bits_70,
71 => RE_Bits_71,
72 => RE_Bits_72,
73 => RE_Bits_73,
74 => RE_Bits_74,
75 => RE_Bits_75,
76 => RE_Bits_76,
77 => RE_Bits_77,
78 => RE_Bits_78,
79 => RE_Bits_79,
80 => RE_Bits_80,
81 => RE_Bits_81,
82 => RE_Bits_82,
83 => RE_Bits_83,
84 => RE_Bits_84,
85 => RE_Bits_85,
86 => RE_Bits_86,
87 => RE_Bits_87,
88 => RE_Bits_88,
89 => RE_Bits_89,
90 => RE_Bits_90,
91 => RE_Bits_91,
92 => RE_Bits_92,
93 => RE_Bits_93,
94 => RE_Bits_94,
95 => RE_Bits_95,
96 => RE_Bits_96,
97 => RE_Bits_97,
98 => RE_Bits_98,
99 => RE_Bits_99,
100 => RE_Bits_100,
101 => RE_Bits_101,
102 => RE_Bits_102,
103 => RE_Bits_103,
104 => RE_Bits_104,
105 => RE_Bits_105,
106 => RE_Bits_106,
107 => RE_Bits_107,
108 => RE_Bits_108,
109 => RE_Bits_109,
110 => RE_Bits_110,
111 => RE_Bits_111,
112 => RE_Bits_112,
113 => RE_Bits_113,
114 => RE_Bits_114,
115 => RE_Bits_115,
116 => RE_Bits_116,
117 => RE_Bits_117,
118 => RE_Bits_118,
119 => RE_Bits_119,
120 => RE_Bits_120,
121 => RE_Bits_121,
122 => RE_Bits_122,
123 => RE_Bits_123,
124 => RE_Bits_124,
125 => RE_Bits_125,
126 => RE_Bits_126,
127 => RE_Bits_127);
-- Array of Get routine entities. These are used to obtain an element from
-- a packed array. The N'th entry is used to obtain elements from a packed
-- array whose component size is N. RE_Null is used as a null entry, for
-- the cases where a library routine is not used.
Get_Id : constant E_Array :=
(01 => RE_Null,
02 => RE_Null,
03 => RE_Get_03,
04 => RE_Null,
05 => RE_Get_05,
06 => RE_Get_06,
07 => RE_Get_07,
08 => RE_Null,
09 => RE_Get_09,
10 => RE_Get_10,
11 => RE_Get_11,
12 => RE_Get_12,
13 => RE_Get_13,
14 => RE_Get_14,
15 => RE_Get_15,
16 => RE_Null,
17 => RE_Get_17,
18 => RE_Get_18,
19 => RE_Get_19,
20 => RE_Get_20,
21 => RE_Get_21,
22 => RE_Get_22,
23 => RE_Get_23,
24 => RE_Get_24,
25 => RE_Get_25,
26 => RE_Get_26,
27 => RE_Get_27,
28 => RE_Get_28,
29 => RE_Get_29,
30 => RE_Get_30,
31 => RE_Get_31,
32 => RE_Null,
33 => RE_Get_33,
34 => RE_Get_34,
35 => RE_Get_35,
36 => RE_Get_36,
37 => RE_Get_37,
38 => RE_Get_38,
39 => RE_Get_39,
40 => RE_Get_40,
41 => RE_Get_41,
42 => RE_Get_42,
43 => RE_Get_43,
44 => RE_Get_44,
45 => RE_Get_45,
46 => RE_Get_46,
47 => RE_Get_47,
48 => RE_Get_48,
49 => RE_Get_49,
50 => RE_Get_50,
51 => RE_Get_51,
52 => RE_Get_52,
53 => RE_Get_53,
54 => RE_Get_54,
55 => RE_Get_55,
56 => RE_Get_56,
57 => RE_Get_57,
58 => RE_Get_58,
59 => RE_Get_59,
60 => RE_Get_60,
61 => RE_Get_61,
62 => RE_Get_62,
63 => RE_Get_63,
64 => RE_Null,
65 => RE_Get_65,
66 => RE_Get_66,
67 => RE_Get_67,
68 => RE_Get_68,
69 => RE_Get_69,
70 => RE_Get_70,
71 => RE_Get_71,
72 => RE_Get_72,
73 => RE_Get_73,
74 => RE_Get_74,
75 => RE_Get_75,
76 => RE_Get_76,
77 => RE_Get_77,
78 => RE_Get_78,
79 => RE_Get_79,
80 => RE_Get_80,
81 => RE_Get_81,
82 => RE_Get_82,
83 => RE_Get_83,
84 => RE_Get_84,
85 => RE_Get_85,
86 => RE_Get_86,
87 => RE_Get_87,
88 => RE_Get_88,
89 => RE_Get_89,
90 => RE_Get_90,
91 => RE_Get_91,
92 => RE_Get_92,
93 => RE_Get_93,
94 => RE_Get_94,
95 => RE_Get_95,
96 => RE_Get_96,
97 => RE_Get_97,
98 => RE_Get_98,
99 => RE_Get_99,
100 => RE_Get_100,
101 => RE_Get_101,
102 => RE_Get_102,
103 => RE_Get_103,
104 => RE_Get_104,
105 => RE_Get_105,
106 => RE_Get_106,
107 => RE_Get_107,
108 => RE_Get_108,
109 => RE_Get_109,
110 => RE_Get_110,
111 => RE_Get_111,
112 => RE_Get_112,
113 => RE_Get_113,
114 => RE_Get_114,
115 => RE_Get_115,
116 => RE_Get_116,
117 => RE_Get_117,
118 => RE_Get_118,
119 => RE_Get_119,
120 => RE_Get_120,
121 => RE_Get_121,
122 => RE_Get_122,
123 => RE_Get_123,
124 => RE_Get_124,
125 => RE_Get_125,
126 => RE_Get_126,
127 => RE_Get_127);
-- Array of Get routine entities to be used in the case where the packed
-- array is itself a component of a packed structure, and therefore may not
-- be fully aligned. This only affects the even sizes, since for the odd
-- sizes, we do not get any fixed alignment in any case.
GetU_Id : constant E_Array :=
(01 => RE_Null,
02 => RE_Null,
03 => RE_Get_03,
04 => RE_Null,
05 => RE_Get_05,
06 => RE_GetU_06,
07 => RE_Get_07,
08 => RE_Null,
09 => RE_Get_09,
10 => RE_GetU_10,
11 => RE_Get_11,
12 => RE_GetU_12,
13 => RE_Get_13,
14 => RE_GetU_14,
15 => RE_Get_15,
16 => RE_Null,
17 => RE_Get_17,
18 => RE_GetU_18,
19 => RE_Get_19,
20 => RE_GetU_20,
21 => RE_Get_21,
22 => RE_GetU_22,
23 => RE_Get_23,
24 => RE_GetU_24,
25 => RE_Get_25,
26 => RE_GetU_26,
27 => RE_Get_27,
28 => RE_GetU_28,
29 => RE_Get_29,
30 => RE_GetU_30,
31 => RE_Get_31,
32 => RE_Null,
33 => RE_Get_33,
34 => RE_GetU_34,
35 => RE_Get_35,
36 => RE_GetU_36,
37 => RE_Get_37,
38 => RE_GetU_38,
39 => RE_Get_39,
40 => RE_GetU_40,
41 => RE_Get_41,
42 => RE_GetU_42,
43 => RE_Get_43,
44 => RE_GetU_44,
45 => RE_Get_45,
46 => RE_GetU_46,
47 => RE_Get_47,
48 => RE_GetU_48,
49 => RE_Get_49,
50 => RE_GetU_50,
51 => RE_Get_51,
52 => RE_GetU_52,
53 => RE_Get_53,
54 => RE_GetU_54,
55 => RE_Get_55,
56 => RE_GetU_56,
57 => RE_Get_57,
58 => RE_GetU_58,
59 => RE_Get_59,
60 => RE_GetU_60,
61 => RE_Get_61,
62 => RE_GetU_62,
63 => RE_Get_63,
64 => RE_Null,
65 => RE_Get_65,
66 => RE_GetU_66,
67 => RE_Get_67,
68 => RE_GetU_68,
69 => RE_Get_69,
70 => RE_GetU_70,
71 => RE_Get_71,
72 => RE_GetU_72,
73 => RE_Get_73,
74 => RE_GetU_74,
75 => RE_Get_75,
76 => RE_GetU_76,
77 => RE_Get_77,
78 => RE_GetU_78,
79 => RE_Get_79,
80 => RE_GetU_80,
81 => RE_Get_81,
82 => RE_GetU_82,
83 => RE_Get_83,
84 => RE_GetU_84,
85 => RE_Get_85,
86 => RE_GetU_86,
87 => RE_Get_87,
88 => RE_GetU_88,
89 => RE_Get_89,
90 => RE_GetU_90,
91 => RE_Get_91,
92 => RE_GetU_92,
93 => RE_Get_93,
94 => RE_GetU_94,
95 => RE_Get_95,
96 => RE_GetU_96,
97 => RE_Get_97,
98 => RE_GetU_98,
99 => RE_Get_99,
100 => RE_GetU_100,
101 => RE_Get_101,
102 => RE_GetU_102,
103 => RE_Get_103,
104 => RE_GetU_104,
105 => RE_Get_105,
106 => RE_GetU_106,
107 => RE_Get_107,
108 => RE_GetU_108,
109 => RE_Get_109,
110 => RE_GetU_110,
111 => RE_Get_111,
112 => RE_GetU_112,
113 => RE_Get_113,
114 => RE_GetU_114,
115 => RE_Get_115,
116 => RE_GetU_116,
117 => RE_Get_117,
118 => RE_GetU_118,
119 => RE_Get_119,
120 => RE_GetU_120,
121 => RE_Get_121,
122 => RE_GetU_122,
123 => RE_Get_123,
124 => RE_GetU_124,
125 => RE_Get_125,
126 => RE_GetU_126,
127 => RE_Get_127);
-- Array of Set routine entities. These are used to assign an element of a
-- packed array. The N'th entry is used to assign elements for a packed
-- array whose component size is N. RE_Null is used as a null entry, for
-- the cases where a library routine is not used.
Set_Id : constant E_Array :=
(01 => RE_Null,
02 => RE_Null,
03 => RE_Set_03,
04 => RE_Null,
05 => RE_Set_05,
06 => RE_Set_06,
07 => RE_Set_07,
08 => RE_Null,
09 => RE_Set_09,
10 => RE_Set_10,
11 => RE_Set_11,
12 => RE_Set_12,
13 => RE_Set_13,
14 => RE_Set_14,
15 => RE_Set_15,
16 => RE_Null,
17 => RE_Set_17,
18 => RE_Set_18,
19 => RE_Set_19,
20 => RE_Set_20,
21 => RE_Set_21,
22 => RE_Set_22,
23 => RE_Set_23,
24 => RE_Set_24,
25 => RE_Set_25,
26 => RE_Set_26,
27 => RE_Set_27,
28 => RE_Set_28,
29 => RE_Set_29,
30 => RE_Set_30,
31 => RE_Set_31,
32 => RE_Null,
33 => RE_Set_33,
34 => RE_Set_34,
35 => RE_Set_35,
36 => RE_Set_36,
37 => RE_Set_37,
38 => RE_Set_38,
39 => RE_Set_39,
40 => RE_Set_40,
41 => RE_Set_41,
42 => RE_Set_42,
43 => RE_Set_43,
44 => RE_Set_44,
45 => RE_Set_45,
46 => RE_Set_46,
47 => RE_Set_47,
48 => RE_Set_48,
49 => RE_Set_49,
50 => RE_Set_50,
51 => RE_Set_51,
52 => RE_Set_52,
53 => RE_Set_53,
54 => RE_Set_54,
55 => RE_Set_55,
56 => RE_Set_56,
57 => RE_Set_57,
58 => RE_Set_58,
59 => RE_Set_59,
60 => RE_Set_60,
61 => RE_Set_61,
62 => RE_Set_62,
63 => RE_Set_63,
64 => RE_Null,
65 => RE_Set_65,
66 => RE_Set_66,
67 => RE_Set_67,
68 => RE_Set_68,
69 => RE_Set_69,
70 => RE_Set_70,
71 => RE_Set_71,
72 => RE_Set_72,
73 => RE_Set_73,
74 => RE_Set_74,
75 => RE_Set_75,
76 => RE_Set_76,
77 => RE_Set_77,
78 => RE_Set_78,
79 => RE_Set_79,
80 => RE_Set_80,
81 => RE_Set_81,
82 => RE_Set_82,
83 => RE_Set_83,
84 => RE_Set_84,
85 => RE_Set_85,
86 => RE_Set_86,
87 => RE_Set_87,
88 => RE_Set_88,
89 => RE_Set_89,
90 => RE_Set_90,
91 => RE_Set_91,
92 => RE_Set_92,
93 => RE_Set_93,
94 => RE_Set_94,
95 => RE_Set_95,
96 => RE_Set_96,
97 => RE_Set_97,
98 => RE_Set_98,
99 => RE_Set_99,
100 => RE_Set_100,
101 => RE_Set_101,
102 => RE_Set_102,
103 => RE_Set_103,
104 => RE_Set_104,
105 => RE_Set_105,
106 => RE_Set_106,
107 => RE_Set_107,
108 => RE_Set_108,
109 => RE_Set_109,
110 => RE_Set_110,
111 => RE_Set_111,
112 => RE_Set_112,
113 => RE_Set_113,
114 => RE_Set_114,
115 => RE_Set_115,
116 => RE_Set_116,
117 => RE_Set_117,
118 => RE_Set_118,
119 => RE_Set_119,
120 => RE_Set_120,
121 => RE_Set_121,
122 => RE_Set_122,
123 => RE_Set_123,
124 => RE_Set_124,
125 => RE_Set_125,
126 => RE_Set_126,
127 => RE_Set_127);
-- Array of Set routine entities to be used in the case where the packed
-- array is itself a component of a packed structure, and therefore may not
-- be fully aligned. This only affects the even sizes, since for the odd
-- sizes, we do not get any fixed alignment in any case.
SetU_Id : constant E_Array :=
(01 => RE_Null,
02 => RE_Null,
03 => RE_Set_03,
04 => RE_Null,
05 => RE_Set_05,
06 => RE_SetU_06,
07 => RE_Set_07,
08 => RE_Null,
09 => RE_Set_09,
10 => RE_SetU_10,
11 => RE_Set_11,
12 => RE_SetU_12,
13 => RE_Set_13,
14 => RE_SetU_14,
15 => RE_Set_15,
16 => RE_Null,
17 => RE_Set_17,
18 => RE_SetU_18,
19 => RE_Set_19,
20 => RE_SetU_20,
21 => RE_Set_21,
22 => RE_SetU_22,
23 => RE_Set_23,
24 => RE_SetU_24,
25 => RE_Set_25,
26 => RE_SetU_26,
27 => RE_Set_27,
28 => RE_SetU_28,
29 => RE_Set_29,
30 => RE_SetU_30,
31 => RE_Set_31,
32 => RE_Null,
33 => RE_Set_33,
34 => RE_SetU_34,
35 => RE_Set_35,
36 => RE_SetU_36,
37 => RE_Set_37,
38 => RE_SetU_38,
39 => RE_Set_39,
40 => RE_SetU_40,
41 => RE_Set_41,
42 => RE_SetU_42,
43 => RE_Set_43,
44 => RE_SetU_44,
45 => RE_Set_45,
46 => RE_SetU_46,
47 => RE_Set_47,
48 => RE_SetU_48,
49 => RE_Set_49,
50 => RE_SetU_50,
51 => RE_Set_51,
52 => RE_SetU_52,
53 => RE_Set_53,
54 => RE_SetU_54,
55 => RE_Set_55,
56 => RE_SetU_56,
57 => RE_Set_57,
58 => RE_SetU_58,
59 => RE_Set_59,
60 => RE_SetU_60,
61 => RE_Set_61,
62 => RE_SetU_62,
63 => RE_Set_63,
64 => RE_Null,
65 => RE_Set_65,
66 => RE_SetU_66,
67 => RE_Set_67,
68 => RE_SetU_68,
69 => RE_Set_69,
70 => RE_SetU_70,
71 => RE_Set_71,
72 => RE_SetU_72,
73 => RE_Set_73,
74 => RE_SetU_74,
75 => RE_Set_75,
76 => RE_SetU_76,
77 => RE_Set_77,
78 => RE_SetU_78,
79 => RE_Set_79,
80 => RE_SetU_80,
81 => RE_Set_81,
82 => RE_SetU_82,
83 => RE_Set_83,
84 => RE_SetU_84,
85 => RE_Set_85,
86 => RE_SetU_86,
87 => RE_Set_87,
88 => RE_SetU_88,
89 => RE_Set_89,
90 => RE_SetU_90,
91 => RE_Set_91,
92 => RE_SetU_92,
93 => RE_Set_93,
94 => RE_SetU_94,
95 => RE_Set_95,
96 => RE_SetU_96,
97 => RE_Set_97,
98 => RE_SetU_98,
99 => RE_Set_99,
100 => RE_SetU_100,
101 => RE_Set_101,
102 => RE_SetU_102,
103 => RE_Set_103,
104 => RE_SetU_104,
105 => RE_Set_105,
106 => RE_SetU_106,
107 => RE_Set_107,
108 => RE_SetU_108,
109 => RE_Set_109,
110 => RE_SetU_110,
111 => RE_Set_111,
112 => RE_SetU_112,
113 => RE_Set_113,
114 => RE_SetU_114,
115 => RE_Set_115,
116 => RE_SetU_116,
117 => RE_Set_117,
118 => RE_SetU_118,
119 => RE_Set_119,
120 => RE_SetU_120,
121 => RE_Set_121,
122 => RE_SetU_122,
123 => RE_Set_123,
124 => RE_SetU_124,
125 => RE_Set_125,
126 => RE_SetU_126,
127 => RE_Set_127);
-----------------
-- Subprograms --
-----------------
procedure Create_Packed_Array_Impl_Type (Typ : Entity_Id);
-- Typ is a array type or subtype to which pragma Pack applies. If the
-- Packed_Array_Impl_Type field of Typ is already set, then the call has
-- no effect, otherwise a suitable type or subtype is created and stored in
-- the Packed_Array_Impl_Type field of Typ. This created type is an Itype
-- so that Gigi will simply elaborate and freeze the type on first use
-- (which is typically the definition of the corresponding array type).
--
-- Note: although this routine is included in the expander package for
-- packed types, it is actually called unconditionally from Freeze,
-- whether or not expansion (and code generation) is enabled. We do this
-- since we want gigi to be able to properly compute type characteristics
-- (for the Data Decomposition Annex of ASIS, and possible other future
-- uses) even if code generation is not active. Strictly this means that
-- this procedure is not part of the expander, but it seems appropriate
-- to keep it together with the other expansion routines that have to do
-- with packed array types.
procedure Expand_Packed_Boolean_Operator (N : Node_Id);
-- N is an N_Op_And, N_Op_Or or N_Op_Xor node whose operand type is a
-- packed boolean array. This routine expands the appropriate operations
-- to carry out the logical operation on the packed arrays. It handles
-- both the modular and array representation cases.
procedure Expand_Packed_Element_Reference (N : Node_Id);
-- N is an N_Indexed_Component node whose prefix is a packed array. In
-- the bit packed case, this routine can only be used for the expression
-- evaluation case, not the assignment case, since the result is not a
-- variable. See Expand_Bit_Packed_Element_Set for how the assignment case
-- is handled in the bit packed case. For the enumeration case, the result
-- of this call is always a variable, so the call can be used for both the
-- expression evaluation and assignment cases.
procedure Expand_Bit_Packed_Element_Set (N : Node_Id);
-- N is an N_Assignment_Statement node whose name is an indexed
-- component of a bit-packed array. This procedure rewrites the entire
-- assignment statement with appropriate code to set the referenced
-- bits of the packed array type object. Note that this procedure is
-- used only for the bit-packed case, not for the enumeration case.
procedure Expand_Packed_Eq (N : Node_Id);
-- N is an N_Op_Eq node where the operands are packed arrays whose
-- representation is an array-of-bytes type (the case where a modular
-- type is used for the representation does not require any special
-- handling, because in the modular case, unused bits are zeroes.
procedure Expand_Packed_Not (N : Node_Id);
-- N is an N_Op_Not node where the operand is packed array of Boolean
-- in standard representation (i.e. component size is one bit). This
-- procedure expands the corresponding not operation. Note that the
-- non-standard representation case is handled by using a loop through
-- elements generated by the normal non-packed circuitry.
function Involves_Packed_Array_Reference (N : Node_Id) return Boolean;
-- N is the node for a name. This function returns true if the name
-- involves a packed array reference. A node involves a packed array
-- reference if it is itself an indexed component referring to a bit-
-- packed array, or it is a selected component whose prefix involves
-- a packed array reference.
procedure Expand_Packed_Address_Reference (N : Node_Id);
-- The node N is an attribute reference for the 'Address reference, where
-- the prefix involves a packed array reference. This routine expands the
-- necessary code for performing the address reference in this case.
procedure Expand_Packed_Bit_Reference (N : Node_Id);
-- The node N is an attribute reference for the 'Bit reference, where the
-- prefix involves a packed array reference. This routine expands the
-- necessary code for performing the bit reference in this case.
end Exp_Pakd;
|
stcarrez/dynamo | Ada | 5,281 | adb | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . C O M P I L A T I O N _ U N I T S . T I M E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2008, 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, 59 Temple Place --
-- - Suite 330, Boston, MA 02111-1307, 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 Ada Core Technologies Inc --
-- (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Errors; use Asis.Errors;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.Vcheck; use A4G.Vcheck;
package body Asis.Compilation_Units.Times is
Package_Name : constant String := "Asis.Compilation_Units.Times.";
Standard_Time : constant Ada.Calendar.Time :=
Ada.Calendar.Time_Of (1994, 12, 21, 0.0);
-- used as Time_Of_Last_Update for the predefined Standard package
--------------------
-- Attribute_Time --
--------------------
function Attribute_Time
(Compilation_Unit : Asis.Compilation_Unit;
Attribute : Wide_String)
return Ada.Calendar.Time
is
begin
pragma Unreferenced (Attribute);
Check_Validity (Compilation_Unit, Package_Name & "Attribute_Time");
return Nil_ASIS_Time;
end Attribute_Time;
------------------------------
-- Compilation_CPU_Duration --
------------------------------
function Compilation_CPU_Duration
(Compilation_Unit : Asis.Compilation_Unit)
return Standard.Duration
is
begin
Check_Validity
(Compilation_Unit, Package_Name & "Compilation_CPU_Duration");
return 0.0;
end Compilation_CPU_Duration;
-------------------------
-- Time_Of_Last_Update --
-------------------------
function Time_Of_Last_Update
(Compilation_Unit : Asis.Compilation_Unit)
return Ada.Calendar.Time
is
begin
Check_Validity (Compilation_Unit, Package_Name & "Time_Of_Last_Update");
if Get_Unit_Id (Compilation_Unit) = Standard_Id then
return Standard_Time;
else
return Time_Stamp (Compilation_Unit);
end if;
exception
when ASIS_Inappropriate_Compilation_Unit =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Time_Of_Last_Update");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Time_Of_Last_Update",
Ex => Ex,
Arg_CU => Compilation_Unit);
end Time_Of_Last_Update;
end Asis.Compilation_Units.Times;
|
dan76/Amass | Ada | 1,093 | ads | -- Copyright © by Jeff Foley 2017-2023. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-- SPDX-License-Identifier: Apache-2.0
name = "AskDNS"
type = "scrape"
function start()
set_rate_limit(2)
end
function horizontal(ctx, domain)
local resp, err = request(ctx, {['url']=build_url(domain)})
if (err ~= nil and err ~= "") then
log(ctx, "horizontal request to service failed: " .. err)
return
elseif (resp.status_code < 200 or resp.status_code >= 400) then
log(ctx, "horizontal request to service returned with status code: " .. resp.status)
return
end
local pattern = "\"/domain/(.*)\""
local matches = submatch(resp.body, pattern)
if (matches == nil or #matches == 0) then
return
end
for i, match in pairs(matches) do
if (match ~= nil and #match >= 2 and match[2] ~= "") then
associated(ctx, domain, match[2])
end
end
end
function build_url(domain)
return "https://askdns.com/domain/" .. domain
end
|
reznikmm/ada-pretty | Ada | 15,843 | adb | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada_Pretty.Definitions;
package body Ada_Pretty.Declarations is
--------------
-- Document --
--------------
overriding function Document
(Self : Package_Body;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
Content : League.Pretty_Printers.Document := Printer.New_Document;
Name : constant League.Pretty_Printers.Document :=
Self.Name.Document (Printer, Pad);
begin
Result.New_Line;
Result.Put ("package body ");
Result.Append (Name);
Result.Put (" is");
if Self.List /= null then
Content := Printer.New_Document;
Content.New_Line;
Content.Append (Self.List.Document (Printer, Pad));
Content.Nest (3);
Result.Append (Content);
end if;
Result.New_Line;
Result.New_Line;
Result.Put ("end ");
Result.Append (Name);
Result.Put (";");
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Package_Instantiation;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
Definition : League.Pretty_Printers.Document := Printer.New_Document;
Actual_Part : League.Pretty_Printers.Document := Printer.New_Document;
Name : constant League.Pretty_Printers.Document :=
Self.Name.Document (Printer, Pad);
begin
Actual_Part.New_Line;
Actual_Part.Put ("(");
Actual_Part.Append (Self.Actual_Part.Document (Printer, 0).Nest (1));
Actual_Part.Put (");");
Actual_Part.Nest (2);
Actual_Part.Group;
Definition.New_Line;
Definition.Put ("new ");
Definition.Append (Self.Template.Document (Printer, 0).Nest (2));
Definition.Append (Actual_Part);
Definition.Nest (2);
Definition.Group;
Result.New_Line;
Result.Put ("package ");
Result.Append (Name);
Result.Put (" is");
Result.Append (Definition);
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Package_Spec;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
Content : League.Pretty_Printers.Document := Printer.New_Document;
Name : constant League.Pretty_Printers.Document :=
Self.Name.Document (Printer, Pad);
begin
Result.New_Line;
Result.Put ("package ");
Result.Append (Name);
Result.Put (" is");
if not Self.Comment.Is_Empty or Self.Public_Part /= null then
Content := Printer.New_Document;
Content.New_Line;
if not Self.Comment.Is_Empty then
Content.Put ("-- ");
Content.Put (Self.Comment);
end if;
if Self.Public_Part /= null then
Content.Append (Self.Public_Part.Document (Printer, Pad));
end if;
Content.Nest (3);
Result.Append (Content);
end if;
if Self.Private_Part /= null then
Content := Printer.New_Document;
Content.Append (Self.Private_Part.Document (Printer, Pad));
Content.Nest (3);
Result.New_Line;
Result.Put_Line ("private");
Result.Append (Content);
end if;
Result.New_Line;
Result.New_Line;
Result.Put ("end ");
Result.Append (Name);
Result.Put (";");
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Parameter;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.Append (Self.Name.Document (Printer, Pad));
Result.Put (" :");
if Self.Is_Aliased then
Result.Put (" aliased");
end if;
if Self.Is_In then
Result.Put (" in");
end if;
if Self.Is_Out then
Result.Put (" out");
end if;
Result.Put (" ");
Result.Append (Self.Type_Definition.Document (Printer, 0).Nest (2));
if Self.Initialization /= null then
Result.Put (" := ");
Result.Append (Self.Initialization.Document (Printer, 0));
end if;
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Subprogram_Body;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
pragma Unreferenced (Pad);
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.New_Line;
Result.Append (Self.Specification.Document (Printer, 0));
Result.Put (" is");
if Self.Declarations /= null then
Result.Append (Self.Declarations.Document (Printer, 0).Nest (3));
end if;
Result.New_Line;
Result.Put ("begin");
if Self.Statements /= null then
Result.Append (Self.Statements.Document (Printer, 0).Nest (3));
end if;
if Self.Exceptions /= null then
Result.Put ("exception");
Result.Append (Self.Exceptions.Document (Printer, 0).Nest (3));
end if;
Result.New_Line;
Result.Put ("end ");
Result.Append
(Ada_Pretty.Definitions.Subprogram
(Self.Specification.all).Name.Document (Printer, 0));
Result.Put (";");
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Subprogram_Declaration;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.New_Line;
Result.Append (Self.Specification.Document (Printer, Pad));
if Self.Is_Abstract or Self.Is_Null then
declare
Tail : League.Pretty_Printers.Document := Printer.New_Document;
begin
Tail.New_Line;
if Self.Is_Abstract then
Tail.Put ("is abstract");
else
Tail.Put ("is null");
end if;
Tail.Nest (2);
Tail.Group;
Result.Append (Tail);
end;
elsif Self.Expression /= null then
declare
Tail : League.Pretty_Printers.Document := Printer.New_Document;
Expr : League.Pretty_Printers.Document := Printer.New_Document;
begin
Expr.Put ("is (");
Expr.Append (Self.Expression.Document (Printer, Pad).Nest (4));
Expr.Put (")");
Tail.New_Line;
Tail.Append (Expr);
Tail.Nest (2);
Tail.Group;
Result.Append (Tail);
end;
elsif Self.Renamed /= null then
declare
Tail : League.Pretty_Printers.Document := Printer.New_Document;
Expr : League.Pretty_Printers.Document := Printer.New_Document;
begin
Expr.Put ("renames ");
Expr.Append (Self.Renamed.Document (Printer, Pad).Nest (2));
Tail.New_Line;
Tail.Append (Expr);
Tail.Nest (2);
Tail.Group;
Result.Append (Tail);
end;
end if;
if Self.Aspects /= null then
Result.Append (Print_Aspect (Self.Aspects, Printer));
end if;
Result.Put (";");
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Type_Declaration;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
pragma Unreferenced (Pad);
Result : League.Pretty_Printers.Document := Printer.New_Document;
Params : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.New_Line;
Result.Put ("type ");
Result.Append (Self.Name.Document (Printer, 0));
if Self.Discriminants /= null then
Params.New_Line;
Params.Put (" (");
Params.Append (Self.Discriminants.Document (Printer, 0).Nest (1));
Params.Put (")");
Params.Nest (1);
Params.Group;
Result.Append (Params);
end if;
if Self.Definition /= null then
declare
Def : League.Pretty_Printers.Document := Printer.New_Document;
begin
Def.New_Line;
Def.Append (Self.Definition.Document (Printer, 0));
Def.Nest (2);
Def.Group;
Result.Put (" is");
Result.Append (Def);
end;
end if;
Result.Append (Print_Aspect (Self.Aspects, Printer));
Result.Put (";");
return Result;
end Document;
--------------
-- Document --
--------------
overriding function Document
(Self : Variable;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.New_Line;
Result.Append (Self.Name.Document (Printer, Pad));
Result.Put (" :");
if Self.Is_Aliased then
Result.Put (" aliased");
end if;
if Self.Is_Constant then
Result.Put (" constant");
end if;
if Self.Type_Definition /= null then
Result.Put (" ");
Result.Append (Self.Type_Definition.Document (Printer, 0));
end if;
if Self.Initialization /= null then
declare
Init : League.Pretty_Printers.Document := Printer.New_Document;
begin
Init.New_Line;
Init.Append (Self.Initialization.Document (Printer, 0));
Init.Nest (2);
Init.Group;
Result.Put (" :=");
Result.Append (Init);
end;
elsif Self.Rename /= null then
declare
Init : League.Pretty_Printers.Document := Printer.New_Document;
begin
Init.New_Line;
Init.Append (Self.Rename.Document (Printer, 0));
Init.Nest (2);
Init.Group;
Result.Put (" renames");
Result.Append (Init);
end;
end if;
Result.Append (Print_Aspect (Self.Aspects, Printer));
Result.Put (";");
return Result;
end Document;
----------
-- Join --
----------
overriding function Join
(Self : Parameter;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.Append (Self.Document (Printer, Pad));
for J in List'Range loop
Result.Put (";");
Result.New_Line;
Result.Append (List (J).Document (Printer, Pad));
end loop;
return Result;
end Join;
-----------------
-- New_Package --
-----------------
function New_Package
(Name : not null Node_Access;
Public_Part : Node_Access;
Private_Part : Node_Access;
Comment : League.Strings.Universal_String)
return Node'Class is
begin
return Package_Spec'(Name, Public_Part, Private_Part, Comment);
end New_Package;
----------------------
-- New_Package_Body --
----------------------
function New_Package_Body
(Name : not null Node_Access;
List : Node_Access) return Node'Class is
begin
return Package_Body'(Name, List);
end New_Package_Body;
-------------------------------
-- New_Package_Instantiation --
-------------------------------
function New_Package_Instantiation
(Name : not null Node_Access;
Template : not null Node_Access;
Actual_Part : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class is
begin
return Package_Instantiation'(Name, Template, Actual_Part, Comment);
end New_Package_Instantiation;
-------------------
-- New_Parameter --
-------------------
function New_Parameter
(Name : not null Node_Access;
Type_Definition : Node_Access;
Initialization : Node_Access;
Is_In : Boolean;
Is_Out : Boolean;
Is_Aliased : Boolean;
Comment : League.Strings.Universal_String) return Node'Class is
begin
return Parameter'(Name,
Type_Definition,
Initialization,
Is_In,
Is_Out,
Is_Aliased,
Comment);
end New_Parameter;
-------------------------
-- New_Subprogram_Body --
-------------------------
function New_Subprogram_Body
(Specification : not null Node_Access;
Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access) return Node'Class is
begin
return Subprogram_Body'
(Specification, Declarations, Statements, Exceptions);
end New_Subprogram_Body;
--------------------------------
-- New_Subprogram_Declaration --
--------------------------------
function New_Subprogram_Declaration
(Specification : not null Node_Access;
Aspects : Node_Access := null;
Is_Abstract : Boolean;
Is_Null : Boolean;
Expression : Node_Access;
Renamed : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class is
begin
return Subprogram_Declaration'
(Specification, Aspects,
Is_Abstract, Is_Null,
Expression, Renamed, Comment);
end New_Subprogram_Declaration;
--------------
-- New_Type --
--------------
function New_Type
(Name : not null Node_Access;
Discriminants : Node_Access;
Definition : Node_Access;
Aspects : Node_Access;
Comment : League.Strings.Universal_String)
return Node'Class
is
begin
return Type_Declaration'
(Name,
Discriminants,
Definition,
Aspects,
Comment);
end New_Type;
------------------
-- New_Variable --
------------------
function New_Variable
(Name : not null Node_Access;
Type_Definition : Node_Access;
Initialization : Node_Access;
Rename : Node_Access;
Is_Constant : Boolean;
Is_Aliased : Boolean;
Aspects : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class is
begin
return Variable'
(Name,
Type_Definition,
Initialization,
Rename,
Is_Constant,
Is_Aliased,
Aspects,
Comment);
end New_Variable;
end Ada_Pretty.Declarations;
|
persan/AdaYaml | Ada | 3,947 | adb | -- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Unchecked_Deallocation;
package body Lexer.Base is
procedure Free is new Ada.Unchecked_Deallocation
(String, Buffer_Type);
subtype Line_End is Character with Static_Predicate =>
Line_End in Line_Feed | Carriage_Return | End_Of_Input;
procedure Init (Object : in out Instance; Input : Source.Pointer;
Initial_Buffer_Size : Positive :=
Default_Initial_Buffer_Size) is
begin
Object.Internal.Input := Input;
Object.Buffer := new String (1 .. Initial_Buffer_Size);
Object.Internal.Sentinel := Initial_Buffer_Size + 1;
Refill_Buffer (Object);
end Init;
procedure Init (Object : in out Instance; Input : String) is
begin
Object.Internal.Input := null;
Object.Buffer := new String (1 .. Input'Length + 1);
Object.Internal.Sentinel := Input'Length + 2;
Object.Buffer.all := Input & End_Of_Input;
end Init;
function Next (Object : in out Instance) return Character is
begin
return C : constant Character := Object.Buffer (Object.Pos) do
Object.Pos := Object.Pos + 1;
end return;
end Next;
procedure Refill_Buffer (L : in out Instance) is
Bytes_To_Copy : constant Natural := L.Buffer'Last + 1 - L.Internal.Sentinel;
Fill_At : Positive := Bytes_To_Copy + 1;
Bytes_Read : Positive;
function Search_Sentinel return Boolean with Inline is
Peek : Positive := L.Buffer'Last;
begin
while not (L.Buffer (Peek) in Line_End) loop
if Peek = Fill_At then
return False;
else
Peek := Peek - 1;
end if;
end loop;
L.Internal.Sentinel := Peek + 1;
return True;
end Search_Sentinel;
begin
if Bytes_To_Copy > 0 then
L.Buffer (1 .. Bytes_To_Copy) :=
L.Buffer (L.Internal.Sentinel .. L.Buffer'Last);
end if;
loop
L.Internal.Input.Read_Data
(L.Buffer (Fill_At .. L.Buffer'Last), Bytes_Read);
if Bytes_Read < L.Buffer'Last - Fill_At then
L.Internal.Sentinel := Fill_At + Bytes_Read + 1;
L.Buffer (L.Internal.Sentinel - 1) := End_Of_Input;
exit;
else
exit when Search_Sentinel;
Fill_At := L.Buffer'Last + 1;
declare
New_Buffer : constant Buffer_Type :=
new String (1 .. 2 * L.Buffer'Last);
begin
New_Buffer.all (L.Buffer'Range) := L.Buffer.all;
Free (L.Buffer);
L.Buffer := New_Buffer;
end;
end if;
end loop;
end Refill_Buffer;
procedure Handle_CR (L : in out Instance) is
begin
if L.Buffer (L.Pos) = Line_Feed then
L.Pos := L.Pos + 1;
else
raise Lexer_Error with "pure CR line breaks not allowed.";
end if;
L.Prev_Lines_Chars :=
L.Prev_Lines_Chars + L.Pos - L.Line_Start;
if L.Pos = L.Internal.Sentinel then
Refill_Buffer (L);
L.Pos := 1;
end if;
L.Line_Start := L.Pos;
L.Cur_Line := L.Cur_Line + 1;
end Handle_CR;
procedure Handle_LF (L : in out Instance) is
begin
L.Prev_Lines_Chars :=
L.Prev_Lines_Chars + L.Pos - L.Line_Start;
if L.Pos = L.Internal.Sentinel then
Refill_Buffer (L);
L.Pos := 1;
end if;
L.Line_Start := L.Pos;
L.Cur_Line := L.Cur_Line + 1;
end Handle_LF;
procedure Finalize (Object : in out Instance) is
procedure Free is new Ada.Unchecked_Deallocation
(Source.Instance'Class, Source.Pointer);
use type Source.Pointer;
begin
if Object.Internal.Input /= null then
Free (Object.Internal.Input);
end if;
end Finalize;
end Lexer.Base;
|
Tubbz-alt/Ada-IntelliJ | Ada | 631 | ads | <fold text='with Play_Control, Record_Control, Ada.Text_IO, Sequencer; ...' expand='false'>with Play_Control, Record_Control, Ada.Text_IO, Sequencer;
with Ada.Text_IO;
with Pattern_Control;</fold>
<fold text='package Bens_New_Packge is ...' expand='true'>package Bens_New_Packge is
<fold text=' function test_1 return Integer is ...' expand='true'> function test_1 return Integer is
begin
return 1;
End Test_1;</fold>
<fold text=' function test_2 return Integer is ...' expand='true'> function test_2 return Integer is
begin
return 2;
End Test_2;</fold>
end Bens_New_Package</fold> |
stcarrez/ada-mail | Ada | 3,533 | ads | -----------------------------------------------------------------------
-- mgrep-scanner -- Scan a directory and parse mail
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Mgrep.Matcher;
private with Util.Strings.Vectors;
private with Ada.Finalization;
private with Ada.Exceptions;
private with Util.Executors;
private with Util.Concurrent.Counters;
package Mgrep.Scanner is
type Scanner_Type (Count : Positive;
Rule : access Matcher.Mail_Rule) is tagged limited private;
procedure Add_Directory (Scanner : in out Scanner_Type;
Path : in String);
procedure Add_File (Scanner : in out Scanner_Type;
Path : in String);
procedure Scan_File (Scanner : in out Scanner_Type;
Path : in String);
procedure Scan_Directory (Scanner : in out Scanner_Type;
Path : in String);
procedure Start (Scanner : in out Scanner_Type);
procedure Stop (Scanner : in out Scanner_Type);
procedure Process (Scanner : in out Scanner_Type;
Done : out Boolean);
function Get_File_Count (Scanner : in Scanner_Type) return Natural;
function Get_Directory_Count (Scanner : in Scanner_Type) return Natural;
private
type Scanner_Access is access all Scanner_Type'Class;
type Work_Kind is (SCAN_DIRECTORY, SCAN_MAIL);
type Work_Type is record
Kind : Work_Kind;
Scanner : Scanner_Access;
Path : Ada.Strings.Unbounded.Unbounded_String;
end record;
procedure Execute (Work : in out Work_Type);
procedure Error (Work : in out Work_Type;
Ex : in Ada.Exceptions.Exception_Occurrence);
QUEUE_SIZE : constant := 100000;
package Executors is
new Util.Executors (Work_Type => Work_Type,
Execute => Execute,
Error => Error,
Default_Queue_Size => QUEUE_SIZE);
type Task_Manager (Count : Positive) is limited
new Executors.Executor_Manager (Count) with null record;
type Scanner_Type (Count : Positive;
Rule : access Matcher.Mail_Rule) is
limited new Ada.Finalization.Limited_Controlled with record
Job_Count : Util.Concurrent.Counters.Counter;
Scan_Dir_Count : Util.Concurrent.Counters.Counter;
Scan_File_Count : Util.Concurrent.Counters.Counter;
Dir_Count : Util.Concurrent.Counters.Counter;
File_Count : Util.Concurrent.Counters.Counter;
Self : Scanner_Access;
Directories : Util.Strings.Vectors.Vector;
Manager : Task_Manager (Count);
end record;
overriding
procedure Initialize (Scanner : in out Scanner_Type);
end Mgrep.Scanner;
|
reznikmm/matreshka | Ada | 4,688 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Visitors;
with ODF.DOM.Office_Forms_Elements;
package Matreshka.ODF_Office.Forms_Elements is
type Office_Forms_Element_Node is
new Matreshka.ODF_Office.Abstract_Office_Element_Node
and ODF.DOM.Office_Forms_Elements.ODF_Office_Forms
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Office_Forms_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Forms_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Office_Forms_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Office_Forms_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Office_Forms_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Office.Forms_Elements;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.